Skip to content

Commit

Permalink
Update the portal deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
zkJoaquin committed Mar 29, 2024
1 parent d65ff36 commit 68baaf9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions script/deploy_log_name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// consumed in deploy_portal.ts
export const DEPLOY_PORTAL_LOG_PREFIX = 'deploy_portal';
export const DEPLOY_LOG_PORTAL_COMMITEE = 'commiteeAddress';
export const DEPLOY_LOG_PORTAL_TARGET = 'portalTarget';
export const DEPLOY_LOG_PORTAL_TARGET_VERIFIED = 'portalTargetVerified';
export const DEPLOY_LOG_PORTAL_PROXY = 'portalProxy';
Expand Down
26 changes: 25 additions & 1 deletion script/deploy_portal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import {
DEPLOY_PORTAL_LOG_PREFIX,
DEPLOY_LOG_DEPLOYER,
DEPLOY_LOG_PORTAL_COMMITEE,
DEPLOY_LOG_PORTAL_TARGET,
DEPLOY_LOG_PORTAL_TARGET_VERIFIED,
DEPLOY_LOG_PORTAL_PROXY,
Expand All @@ -28,9 +29,12 @@ function getMergeTokenContractName() {
}

task('deployPortal', 'Deploy portal')
.addParam('commitee', 'Commitee address', undefined, types.string, false)
.addParam('skipVerify', 'Skip verify', false, types.boolean, true)
.setAction(async (taskArgs, hardhat) => {
let commiteeAddress = taskArgs.commitee;
let skipVerify = taskArgs.skipVerify;
console.log('commitee address', commiteeAddress);
console.log('skip verify contracts?', skipVerify);

const contractDeployer = new ChainContractDeployer(hardhat);
Expand All @@ -40,14 +44,15 @@ task('deployPortal', 'Deploy portal')
const { deployLogPath, deployLog } = createOrGetDeployLog(DEPLOY_PORTAL_LOG_PREFIX, hardhat.network.name);
const dLog = deployLog as any;
dLog[DEPLOY_LOG_DEPLOYER] = await deployerWallet?.getAddress();
dLog[DEPLOY_LOG_PORTAL_COMMITEE] = commiteeAddress;
fs.writeFileSync(deployLogPath, JSON.stringify(dLog, null, 2));

// deploy portal
let portalAddr;
if (!(DEPLOY_LOG_PORTAL_PROXY in dLog)) {
console.log('deploy portal...');
const contractName = getPortalContractName();
const contract = await contractDeployer.deployProxy(contractName, [], {
const contract = await contractDeployer.deployProxy(contractName, [commiteeAddress], {
unsafeAllow: ['constructor'],
});
const transaction = await getDeployTx(contract);
Expand Down Expand Up @@ -270,3 +275,22 @@ task('encodeUpdateDepositLimit', 'Get the calldata of update deposit limit for p

return calldata;
});

task('encodeGrantCommiteeRole', 'Get the calldata of grant commitee role for portal')
.addParam('commitee', 'Commitee address', undefined, types.string, false)
.addParam('portal', 'The portal address (default get from portal deploy log)', undefined, types.string, true)
.setAction(async (taskArgs, hre) => {
let commitee = taskArgs.commitee;
console.log('commitee', commitee);
let portal = taskArgs.portal;
if (portal === undefined) {
portal = readDeployContract(DEPLOY_PORTAL_LOG_PREFIX, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
}
console.log('portal address', portal);

const portalContract = await hre.ethers.getContractAt(getPortalContractName(), portal);
const calldata = portalContract.interface.encodeFunctionData('grantCommiteeRole', [commitee]);
console.log('calldata', calldata);

return calldata;
});

0 comments on commit 68baaf9

Please sign in to comment.