Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deployERC20BridgeTarget task #95

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions script/deploy_erc20_bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,35 @@ task('upgradeERC20Bridge', 'Upgrade erc20 bridge')
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2));
}
});

task('deployERC20BridgeTarget', 'Deploy erc20 bridge target')
.addParam('zklink', 'The zklink address (default get from zkLink deploy log)', undefined, types.string, true)
.addParam('skipVerify', 'Skip verify', false, types.boolean, true)
.setAction(async (taskArgs, hardhat) => {
let zklinkAddr = taskArgs.zklink;
if (zklinkAddr === undefined) {
zklinkAddr = readDeployLogField(logName.DEPLOY_ZKLINK_LOG_PREFIX, logName.DEPLOY_LOG_ZKLINK_PROXY);
}
let skipVerify = taskArgs.skipVerify;
console.log('zklink', zklinkAddr);
console.log('skip verify contracts?', skipVerify);

const { deployLogPath, deployLog } = createOrGetDeployLog(logName.DEPLOY_ERC20_BRIDGE_LOG_PREFIX);

const contractDeployer = new ChainContractDeployer(hardhat);
await contractDeployer.init();

const contract = await contractDeployer.deployContract('L1ERC20Bridge', [zklinkAddr]);
const tx = await getDeployTx(contract);
console.log('deploy tx', tx.hash);
const contractAddr = await contract.getAddress();
deployLog[logName.DEPLOY_ERC20_BRIDGE_TARGET] = contractAddr;
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2));

// verify target contract
if (!skipVerify) {
await verifyContractCode(hardhat, contractAddr, [zklinkAddr]);
deployLog[logName.DEPLOY_ERC20_BRIDGE_TARGET_VERIFIED] = true;
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2));
}
});
Loading