Skip to content

Commit

Permalink
Merge pull request #95 from zkLinkProtocol/issues_94
Browse files Browse the repository at this point in the history
add deployERC20BridgeTarget task
  • Loading branch information
zkbenny authored Apr 3, 2024
2 parents d8f0ff2 + b09c9ea commit 8ebeaa1
Showing 1 changed file with 32 additions and 0 deletions.
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));
}
});

0 comments on commit 8ebeaa1

Please sign in to comment.