Skip to content

Commit

Permalink
Merge pull request #150 from BitGo/COIN-114-deploy-v1-wallet-factory-…
Browse files Browse the repository at this point in the history
…contracts

feat(deploy): add script to deploy v1 wallet and forwarder contracts
  • Loading branch information
mullapudipruthvik authored May 27, 2024
2 parents 9b196dd + 768bca9 commit 58eda4f
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 108 deletions.
20 changes: 16 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,31 @@ const config: HardhatUserConfig = {
},
tarbeth: {
url: `${QUICKNODE_ARBITRUM_SEPOLIA_API_KEY}`,
accounts: [`${TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT}`]
accounts: [
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
]
},
arbeth: {
url: `${QUICKNODE_ARBITRUM_ONE_API_KEY}`,
accounts: [`${MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT}`]
accounts: [
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
]
},
topeth: {
url: `${QUICKNODE_OPTIMISM_SEPOLIA_API_KEY}`,
accounts: [`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`]
accounts: [
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
]
},
opeth: {
url: `${QUICKNODE_OPTIMISM_API_KEY}`,
accounts: [`${MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT}`]
accounts: [
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
]
},
tzketh: {
url: `${QUICKNODE_ZKSYNC_SEPOLIA_API_KEY}`,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test": "test"
},
"scripts": {
"deploy-prod": "hardhat run scripts/deploy.ts --network",
"deploy-test": "hardhat run scripts/deployV1Wallet.ts --network",
"deploy-prod": "hardhat run scripts/deployV1FactoryContracts.ts --network",
"deploy-test": "hardhat run scripts/deployV1FactoryContracts.ts --network",
"test": "hardhat test",
"coverage": "hardhat coverage",
"solhint": "./node_modules/.bin/solhint --fix 'contracts/**/*.sol'",
Expand Down
85 changes: 76 additions & 9 deletions scripts/deployV1Wallet.ts → scripts/deployV1FactoryContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ const fs = require('fs');
async function main() {
const output = {
walletImplementation: '',
walletFactory: ''
walletFactory: '',
forwarderImplementation: '',
forwarderFactory: ''
};

const feeData = await ethers.provider.getFeeData();

const [walletDeployer, forwarderDeployer] = await ethers.getSigners();

const gasParams = {
gasPrice: feeData.gasPrice!
gasPrice: feeData.gasPrice!.mul('2')
};
const [deployer] = await ethers.getSigners();
const selfTransactions = 2;

for (let i = 0; i < selfTransactions; i++) {
const tx = await deployer.sendTransaction({
to: deployer.address,
console.log('Deploying wallet contracts....');
const walletSelfTransactions = 2;
for (let i = 0; i < walletSelfTransactions; i++) {
const tx = await walletDeployer.sendTransaction({
to: walletDeployer.address,
value: ethers.utils.parseEther('0'),
gasPrice: gasParams.gasPrice
});
Expand All @@ -29,7 +34,8 @@ async function main() {
const walletFactoryContractName = 'WalletFactory';

const WalletImplementation = await ethers.getContractFactory(
walletImplementationContractName
walletImplementationContractName,
walletDeployer
);
const walletImplementation = await WalletImplementation.deploy(gasParams);
await walletImplementation.deployed();
Expand All @@ -40,7 +46,8 @@ async function main() {
);

const WalletFactory = await ethers.getContractFactory(
walletFactoryContractName
walletFactoryContractName,
walletDeployer
);
const walletFactory = await WalletFactory.deploy(
walletImplementation.address,
Expand All @@ -52,6 +59,54 @@ async function main() {
`${walletFactoryContractName} deployed at ` + walletFactory.address
);

const forwarderSelfTransactions = 234;
console.log('Deploying forwarder contracts....');

for (let i = 0; i < forwarderSelfTransactions; i++) {
const tx = await forwarderDeployer.sendTransaction({
to: forwarderDeployer.address,
value: ethers.utils.parseEther('0'),
gasPrice: gasParams.gasPrice
});
await tx.wait();
console.log(`Self transaction with nonce: ${i} complete`);
}

const forwarderImplementationContractName = 'Forwarder';
const forwarderFactoryContractName = 'ForwarderFactory';

const ForwarderImplementation = await ethers.getContractFactory(
forwarderImplementationContractName,
forwarderDeployer
);

const forwarderImplementation = await ForwarderImplementation.deploy(
gasParams
);
await forwarderImplementation.deployed();
output.forwarderImplementation = forwarderImplementation.address;

console.log(
`${forwarderImplementationContractName} deployed at ` +
forwarderImplementation.address,
forwarderDeployer
);

const ForwarderFactory = await ethers.getContractFactory(
forwarderFactoryContractName
);

const forwarderFactory = await ForwarderFactory.deploy(
forwarderImplementation.address,
gasParams
);

await forwarderFactory.deployed();
output.forwarderFactory = forwarderFactory.address;
console.log(
`${forwarderFactoryContractName} deployed at ` + forwarderFactory.address
);

fs.writeFileSync('output.json', JSON.stringify(output));

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

await walletImplementation.deployTransaction.wait(10);
await walletFactory.deployTransaction.wait(10);
await forwarderImplementation.deployTransaction.wait(10);
await forwarderFactory.deployTransaction.wait(10);

console.log('Done waiting, verifying');
await verifyContract(
Expand All @@ -73,6 +130,16 @@ async function main() {
walletImplementation.address
]);

await verifyContract(
forwarderImplementationContractName,
forwarderImplementation.address,
[]
);

await verifyContract('ForwarderFactory', forwarderFactory.address, [
forwarderImplementation.address
]);

console.log('Contracts verified');
}

Expand Down
93 changes: 0 additions & 93 deletions scripts/deployV1Forwarder.ts

This file was deleted.

0 comments on commit 58eda4f

Please sign in to comment.