Skip to content

Commit 8eaec28

Browse files
Merge pull request #249 from BitGo/WIN-6575
chore: ethers migration v6, added signal for creating recovery wallet
2 parents 67e6676 + 72074ef commit 8eaec28

24 files changed

+3312
-6729
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
typechain
2+
typechain-types

.prettierrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
21
{
32
"useTabs": false,
43
"printWidth": 80,
54
"tabWidth": 2,
65
"singleQuote": true,
76
"trailingComma": "none",
8-
"jsxBracketSameLine": false,
7+
"bracketSameLine": false,
98
"semi": true,
10-
"bracketSpacing": true,
9+
"bracketSpacing": true
1110
}

contracts/recoveryContracts/RecoveryWalletFactory.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import '../CloneFactory.sol';
66
contract RecoveryWalletFactory is CloneFactory {
77
address public immutable implementationAddress;
88

9+
// Emitted when a new recovery wallet clone is created
10+
event WalletCreated(address indexed newWalletAddress);
11+
912
constructor(address _implementationAddress) {
1013
implementationAddress = _implementationAddress;
1114
}
@@ -18,5 +21,7 @@ contract RecoveryWalletFactory is CloneFactory {
1821

1922
address payable clone = createClone(implementationAddress, finalSalt);
2023
RecoveryWalletSimple(clone).init(allowedSigners[2]);
24+
25+
emit WalletCreated(clone);
2126
}
2227
}

deployUtils.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import hre, { ethers } from 'hardhat';
22
import fs from 'fs';
3-
import { Contract } from 'ethers';
3+
import { BaseContract, getCreateAddress } from 'ethers';
44
import { HardhatRuntimeEnvironment } from 'hardhat/types';
55
import { verifyOnCustomEtherscan } from './scripts/customContractVerifier';
66

@@ -33,7 +33,7 @@ export async function deployIfNeededAtNonce(
3333
contractName: string,
3434
deployFn: () => Promise<string>
3535
): Promise<string> {
36-
const predictedAddress = ethers.utils.getContractAddress({
36+
const predictedAddress = getCreateAddress({
3737
from: deployerAddress,
3838
nonce: expectedNonce
3939
});
@@ -115,7 +115,7 @@ export function saveOutput(output: DeploymentAddresses) {
115115
*/
116116
export async function waitAndVerify(
117117
hre: HardhatRuntimeEnvironment,
118-
contract: Contract,
118+
contract: BaseContract,
119119
contractName: string,
120120
constructorArguments: string[] = []
121121
) {
@@ -132,8 +132,15 @@ export async function waitAndVerify(
132132
const artifact = await hre.artifacts.readArtifact(contractName);
133133
const verificationString = `${artifact.sourceName}:${artifact.contractName}`;
134134
console.log(`Verification string: ${verificationString}`);
135-
await contract.deployTransaction.wait(confirmationCount);
136-
logger.success(`Contract confirmed on the network at ${contract.address}.`);
135+
136+
const deployTx = contract.deploymentTransaction();
137+
await deployTx?.wait(confirmationCount);
138+
139+
logger.success(
140+
`Contract ${contractName} confirmed on the network after ${confirmationCount} confirmations.`
141+
);
142+
const contractAddress = await contract.getAddress();
143+
logger.success(`Contract confirmed on the network at ${contractAddress}.`);
137144

138145
const maxRetries = 20;
139146
const retryDelay = 180000; // 180 seconds
@@ -144,7 +151,7 @@ export async function waitAndVerify(
144151
// --- Primary Attempt: Standard Verifier ---
145152
logger.info('Attempting verification with standard Hardhat verifier...');
146153
await hre.run('verify:verify', {
147-
address: contract.address,
154+
address: contractAddress,
148155
constructorArguments: constructorArguments,
149156
contract: verificationString
150157
});
@@ -153,7 +160,6 @@ export async function waitAndVerify(
153160
} catch (standardError: any) {
154161
logger.warn(`Standard verifier failed: ${standardError.message}`);
155162

156-
// If already verified by standard verifier, we're done.
157163
if (standardError.message.toLowerCase().includes('already verified')) {
158164
logger.success('Contract is already verified.');
159165
return;
@@ -164,20 +170,18 @@ export async function waitAndVerify(
164170
try {
165171
await verifyOnCustomEtherscan({
166172
hre,
167-
contractAddress: contract.address,
173+
contractAddress: contractAddress, // Use the fetched address
168174
contractName: contractName,
169175
constructorArguments: constructorArguments
170176
});
171177
logger.success('Custom verifier fallback successful!');
172178
return; // Success, exit the loop.
173179
} catch (customError: any) {
174-
// If already verified by custom verifier, we're done.
175180
if (customError.message.toLowerCase().includes('already verified')) {
176181
logger.success('Contract is already verified.');
177182
return;
178183
}
179184

180-
// Log the custom verifier failure and decide whether to retry the whole process
181185
logger.warn(
182186
`Custom verifier fallback also failed: ${customError.message}`
183187
);

hardhat.config.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import * as dotenv from 'dotenv';
22
dotenv.config();
33
import { HardhatUserConfig } from 'hardhat/config';
4+
import '@nomicfoundation/hardhat-toolbox';
45
import '@nomicfoundation/hardhat-verify';
5-
import '@nomiclabs/hardhat-waffle';
6-
import '@nomiclabs/hardhat-truffle5';
7-
import '@typechain/hardhat';
86
import 'hardhat-gas-reporter';
97
import 'solidity-coverage';
108
import { CHAIN_IDS } from './config/chainIds';
@@ -275,7 +273,7 @@ const config: HardhatUserConfig = {
275273
]
276274
},
277275
stt: {
278-
url: `https://rpc.somnia.network`,
276+
url: `https://api.infra.mainnet.somnia.network`,
279277
accounts: [
280278
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`,
281279
`${PLACEHOLDER_KEY}`,
@@ -939,8 +937,8 @@ const config: HardhatUserConfig = {
939937
network: 'somniaMainnet',
940938
chainId: CHAIN_IDS.SOMNIA,
941939
urls: {
942-
apiURL: 'https://api.infra.mainnet.somnia.network/',
943-
browserURL: 'https://shannon-explorer.somnia.network/' //TODO: WIN-5278: change it with mainnet explorer, when its available
940+
apiURL: 'https://mainnet.somnia.w3us.site/api',
941+
browserURL: 'https://mainnet.somnia.w3us.site/'
944942
}
945943
},
946944
{

package.json

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"test": "hardhat test",
1616
"coverage": "hardhat coverage",
1717
"solhint": "./node_modules/.bin/solhint --fix 'contracts/**/*.sol'",
18-
"prettier-check": "./node_modules/.bin/prettier --config .prettierrc --check './**/*.js' './**/*.ts'",
18+
"prettier-check": "prettier --config .prettierrc --check \"**/*.{js,ts}\"",
1919
"prettier-lint": "./node_modules/.bin/prettier --config .prettierrc --write './**/*.js' './**/*.ts'",
2020
"prettier:solidity": "./node_modules/.bin/prettier --write contracts/*.sol",
2121
"lint": "npm run prettier-check"
@@ -26,42 +26,28 @@
2626
"ethereum"
2727
],
2828
"dependencies": {
29-
"@ethersproject/bytes": "^5.8.0",
30-
"@ethersproject/wallet": "^5.8.0",
3129
"@msgpack/msgpack": "^3.1.2",
32-
"@noble/hashes": "^1.8.0",
33-
"@noble/secp256k1": "^2.3.0",
30+
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
3431
"@openzeppelin/contracts": "5.0.0",
35-
"@truffle/hdwallet-provider": "^2.0.0",
36-
"bignumber.js": "^9.0.0",
37-
"bluebird": "^3.3.5",
38-
"bn": "^1.0.1",
39-
"bn.js": "^4.11.3",
40-
"ethereumjs-abi": "^0.6.8",
41-
"ethereumjs-util": "^7.0.4",
42-
"ethers": "^5.7.0",
43-
"ganache-cli": "^6.12.2",
44-
"lodash": "^4.12.0",
45-
"mocha": "^9.1.0",
46-
"q": "^1.5.1",
47-
"should": "^8.3.1",
48-
"solc": "0.8.20"
32+
"chai": "^4.3.4",
33+
"ethereum-waffle": "^3.4.4",
34+
"ethereumjs-util": "^7.1.5",
35+
"ethers": "^6.7.0"
4936
},
5037
"devDependencies": {
51-
"@nomicfoundation/hardhat-verify": "^2.0.14",
52-
"@nomiclabs/hardhat-ethers": "^2.0.4",
53-
"@nomiclabs/hardhat-truffle5": "^2.0.3",
54-
"@nomiclabs/hardhat-waffle": "^2.0.2",
55-
"@nomiclabs/hardhat-web3": "^2.0.0",
38+
"@nomicfoundation/hardhat-chai-matchers": "^2.1.0",
39+
"@nomicfoundation/hardhat-ethers": "^3.1.0",
40+
"@nomicfoundation/hardhat-network-helpers": "^1.1.0",
41+
"@nomicfoundation/hardhat-verify": "^1.1.1",
5642
"@openzeppelin/test-helpers": "^0.5.15",
57-
"@typechain/ethers-v5": "^7.2.0",
58-
"@typechain/hardhat": "^2.3.1",
59-
"@types/chai": "^4.3.0",
60-
"@types/mocha": "^9.1.0",
43+
"@typechain/ethers-v6": "^0.4.3",
44+
"@typechain/hardhat": "^8.0.3",
45+
"@types/chai": "^4.3.20",
46+
"@types/mocha": "^10.0.10",
6147
"@types/node": "^12.20.43",
48+
"@types/sinon": "^17.0.4",
6249
"@typescript-eslint/eslint-plugin": "^4.33.0",
6350
"@typescript-eslint/parser": "^4.33.0",
64-
"chai": "^4.3.6",
6551
"dotenv": "^10.0.0",
6652
"dotenv-cli": "^8.0.0",
6753
"eslint": "^7.32.0",
@@ -71,18 +57,17 @@
7157
"eslint-plugin-node": "^11.1.0",
7258
"eslint-plugin-prettier": "^3.4.1",
7359
"eslint-plugin-promise": "^5.2.0",
74-
"ethereum-waffle": "^3.4.0",
75-
"hardhat": "^2.17.4",
60+
"hardhat": "^2.26.2",
7661
"hardhat-gas-reporter": "^1.0.10",
7762
"prettier": "^2.5.1",
7863
"prettier-plugin-solidity": "^1.0.0-beta.13",
7964
"sinon": "^21.0.0",
8065
"solhint": "^3.3.6",
8166
"solhint-plugin-prettier": "0.0.5",
82-
"solidity-coverage": "^0.7.18",
67+
"solidity-coverage": "^0.8.16",
8368
"truffle-assertions": "^0.9.2",
8469
"ts-node": "^10.4.0",
85-
"typechain": "^5.2.0",
70+
"typechain": "^8.3.2",
8671
"typescript": "^4.5.5",
8772
"web3": "^1.7.0"
8873
},

0 commit comments

Comments
 (0)