Skip to content

Commit 58eda4f

Browse files
Merge pull request #150 from BitGo/COIN-114-deploy-v1-wallet-factory-contracts
feat(deploy): add script to deploy v1 wallet and forwarder contracts
2 parents 9b196dd + 768bca9 commit 58eda4f

File tree

4 files changed

+94
-108
lines changed

4 files changed

+94
-108
lines changed

hardhat.config.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,31 @@ const config: HardhatUserConfig = {
9292
},
9393
tarbeth: {
9494
url: `${QUICKNODE_ARBITRUM_SEPOLIA_API_KEY}`,
95-
accounts: [`${TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT}`]
95+
accounts: [
96+
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
97+
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
98+
]
9699
},
97100
arbeth: {
98101
url: `${QUICKNODE_ARBITRUM_ONE_API_KEY}`,
99-
accounts: [`${MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT}`]
102+
accounts: [
103+
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
104+
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
105+
]
100106
},
101107
topeth: {
102108
url: `${QUICKNODE_OPTIMISM_SEPOLIA_API_KEY}`,
103-
accounts: [`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`]
109+
accounts: [
110+
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
111+
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
112+
]
104113
},
105114
opeth: {
106115
url: `${QUICKNODE_OPTIMISM_API_KEY}`,
107-
accounts: [`${MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT}`]
116+
accounts: [
117+
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
118+
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
119+
]
108120
},
109121
tzketh: {
110122
url: `${QUICKNODE_ZKSYNC_SEPOLIA_API_KEY}`,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"test": "test"
1010
},
1111
"scripts": {
12-
"deploy-prod": "hardhat run scripts/deploy.ts --network",
13-
"deploy-test": "hardhat run scripts/deployV1Wallet.ts --network",
12+
"deploy-prod": "hardhat run scripts/deployV1FactoryContracts.ts --network",
13+
"deploy-test": "hardhat run scripts/deployV1FactoryContracts.ts --network",
1414
"test": "hardhat test",
1515
"coverage": "hardhat coverage",
1616
"solhint": "./node_modules/.bin/solhint --fix 'contracts/**/*.sol'",

scripts/deployV1Wallet.ts renamed to scripts/deployV1FactoryContracts.ts

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,24 @@ const fs = require('fs');
55
async function main() {
66
const output = {
77
walletImplementation: '',
8-
walletFactory: ''
8+
walletFactory: '',
9+
forwarderImplementation: '',
10+
forwarderFactory: ''
911
};
1012

1113
const feeData = await ethers.provider.getFeeData();
14+
15+
const [walletDeployer, forwarderDeployer] = await ethers.getSigners();
16+
1217
const gasParams = {
13-
gasPrice: feeData.gasPrice!
18+
gasPrice: feeData.gasPrice!.mul('2')
1419
};
15-
const [deployer] = await ethers.getSigners();
16-
const selfTransactions = 2;
1720

18-
for (let i = 0; i < selfTransactions; i++) {
19-
const tx = await deployer.sendTransaction({
20-
to: deployer.address,
21+
console.log('Deploying wallet contracts....');
22+
const walletSelfTransactions = 2;
23+
for (let i = 0; i < walletSelfTransactions; i++) {
24+
const tx = await walletDeployer.sendTransaction({
25+
to: walletDeployer.address,
2126
value: ethers.utils.parseEther('0'),
2227
gasPrice: gasParams.gasPrice
2328
});
@@ -29,7 +34,8 @@ async function main() {
2934
const walletFactoryContractName = 'WalletFactory';
3035

3136
const WalletImplementation = await ethers.getContractFactory(
32-
walletImplementationContractName
37+
walletImplementationContractName,
38+
walletDeployer
3339
);
3440
const walletImplementation = await WalletImplementation.deploy(gasParams);
3541
await walletImplementation.deployed();
@@ -40,7 +46,8 @@ async function main() {
4046
);
4147

4248
const WalletFactory = await ethers.getContractFactory(
43-
walletFactoryContractName
49+
walletFactoryContractName,
50+
walletDeployer
4451
);
4552
const walletFactory = await WalletFactory.deploy(
4653
walletImplementation.address,
@@ -52,6 +59,54 @@ async function main() {
5259
`${walletFactoryContractName} deployed at ` + walletFactory.address
5360
);
5461

62+
const forwarderSelfTransactions = 234;
63+
console.log('Deploying forwarder contracts....');
64+
65+
for (let i = 0; i < forwarderSelfTransactions; i++) {
66+
const tx = await forwarderDeployer.sendTransaction({
67+
to: forwarderDeployer.address,
68+
value: ethers.utils.parseEther('0'),
69+
gasPrice: gasParams.gasPrice
70+
});
71+
await tx.wait();
72+
console.log(`Self transaction with nonce: ${i} complete`);
73+
}
74+
75+
const forwarderImplementationContractName = 'Forwarder';
76+
const forwarderFactoryContractName = 'ForwarderFactory';
77+
78+
const ForwarderImplementation = await ethers.getContractFactory(
79+
forwarderImplementationContractName,
80+
forwarderDeployer
81+
);
82+
83+
const forwarderImplementation = await ForwarderImplementation.deploy(
84+
gasParams
85+
);
86+
await forwarderImplementation.deployed();
87+
output.forwarderImplementation = forwarderImplementation.address;
88+
89+
console.log(
90+
`${forwarderImplementationContractName} deployed at ` +
91+
forwarderImplementation.address,
92+
forwarderDeployer
93+
);
94+
95+
const ForwarderFactory = await ethers.getContractFactory(
96+
forwarderFactoryContractName
97+
);
98+
99+
const forwarderFactory = await ForwarderFactory.deploy(
100+
forwarderImplementation.address,
101+
gasParams
102+
);
103+
104+
await forwarderFactory.deployed();
105+
output.forwarderFactory = forwarderFactory.address;
106+
console.log(
107+
`${forwarderFactoryContractName} deployed at ` + forwarderFactory.address
108+
);
109+
55110
fs.writeFileSync('output.json', JSON.stringify(output));
56111

57112
// Wait 5 minutes. It takes some time for the etherscan backend to index the transaction and store the contract.
@@ -62,6 +117,8 @@ async function main() {
62117

63118
await walletImplementation.deployTransaction.wait(10);
64119
await walletFactory.deployTransaction.wait(10);
120+
await forwarderImplementation.deployTransaction.wait(10);
121+
await forwarderFactory.deployTransaction.wait(10);
65122

66123
console.log('Done waiting, verifying');
67124
await verifyContract(
@@ -73,6 +130,16 @@ async function main() {
73130
walletImplementation.address
74131
]);
75132

133+
await verifyContract(
134+
forwarderImplementationContractName,
135+
forwarderImplementation.address,
136+
[]
137+
);
138+
139+
await verifyContract('ForwarderFactory', forwarderFactory.address, [
140+
forwarderImplementation.address
141+
]);
142+
76143
console.log('Contracts verified');
77144
}
78145

scripts/deployV1Forwarder.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)