Skip to content

Commit

Permalink
set validator for ethereum
Browse files Browse the repository at this point in the history
  • Loading branch information
zkbenny committed Feb 6, 2024
1 parent 68a2dac commit e5e2ff9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/scroll/scripts/4_setValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const { task, types } = require('hardhat/config');
require('dotenv').config();

task('setValidator', 'Set validator for zkLink')
.addParam('validator', 'Validator Address', undefined, types.string, true)
.addParam('active', 'Whether to activate the validator address', true, types.boolean, true)
.addParam('validator', 'Validator Address', undefined, types.string)
.addOptionalParam('active', 'Whether to activate the validator address', true, types.boolean)
.setAction(async (taskArgs, hre) => {
const validatorAddr = taskArgs.validator;
const isActive = taskArgs.active;
Expand Down
37 changes: 36 additions & 1 deletion script/deploy_arbitrator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const fs = require('fs');
const { getImplementationAddress } = require('@openzeppelin/upgrades-core');
const { verifyContractCode, createOrGetDeployLog, ChainContractDeployer, getDeployTx } = require('./utils');
const {
verifyContractCode,
createOrGetDeployLog,
ChainContractDeployer,
getDeployTx,
readDeployContract,
} = require('./utils');
const logName = require('./deploy_log_name');
const { task, types } = require('hardhat/config');

Expand Down Expand Up @@ -114,3 +120,32 @@ task('upgradeArbitrator', 'Upgrade arbitrator')
fs.writeFileSync(deployLogPath, JSON.stringify(deployLog, null, 2));
}
});

task('setValidatorForEthereum', 'Set validator for ethereum')
.addParam('validator', 'Validator Address', undefined, types.string)
.addOptionalParam('active', 'Whether to activate the validator address', true, types.boolean)
.setAction(async (taskArgs, hardhat) => {
const validatorAddr = taskArgs.validator;
const isActive = taskArgs.active;
console.log(`The validator: address: ${validatorAddr}, active: ${isActive}`);

const arbitratorAddr = readDeployContract(logName.DEPLOY_ARBITRATOR_LOG_PREFIX, logName.DEPLOY_LOG_ARBITRATOR);
if (arbitratorAddr === undefined) {
console.log('The arbitrator address not exist');
return;
}
console.log(`The arbitrator address: ${arbitratorAddr}`);

const ethGatewayAddr = readDeployContract(logName.DEPLOY_ETH_GATEWAY_LOG_PREFIX, logName.DEPLOY_GATEWAY);
if (ethGatewayAddr === undefined) {
console.log('The eth gateway address not exist');
return;
}
console.log(`The eth gateway address: ${ethGatewayAddr}`);

const arbitrator = await hardhat.ethers.getContractAt('Arbitrator', arbitratorAddr);
let tx = await arbitrator.setValidator(ethGatewayAddr, validatorAddr, isActive, '0x');
console.log(`The tx hash: ${tx.hash} , waiting confirm...`);
await tx.wait();
console.log(`The tx confirmed`);
});

0 comments on commit e5e2ff9

Please sign in to comment.