From e4d28439155389195baa47c85d2e9cc0bcee97c5 Mon Sep 17 00:00:00 2001 From: zkbenny Date: Mon, 10 Jun 2024 16:09:22 +0800 Subject: [PATCH] add encode call data for scroll --- examples/scroll/scripts/changeFeeParams.js | 24 ++++++++++++++++- examples/scroll/scripts/setValidator.js | 30 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/examples/scroll/scripts/changeFeeParams.js b/examples/scroll/scripts/changeFeeParams.js index 8ac13e8..c64d3cc 100644 --- a/examples/scroll/scripts/changeFeeParams.js +++ b/examples/scroll/scripts/changeFeeParams.js @@ -3,6 +3,7 @@ const { readDeployContract, getLogName } = require('../../../script/utils'); const logName = require('../../../script/deploy_log_name'); const { task } = require('hardhat/config'); const { ScrollSDK } = require('./scrollSDK'); +const { INIT_FEE_PARAMS } = require('../../../script/zksync_era'); require('dotenv').config(); @@ -52,7 +53,6 @@ task('changeFeeParams', 'Change fee params for zkLink').setAction(async (taskArg * finalizeMessageGasLimit: the gas limit for the L2 to finalize the message. */ const zkLink = await hre.ethers.getContractFactory('ZkLink'); - const { INIT_FEE_PARAMS } = require('../../../script/zksync_era'); const zkLinkCallValue = BigInt(0); const zkLinkCallData = zkLink.interface.encodeFunctionData('changeFeeParams', [INIT_FEE_PARAMS]); const l2GatewayFactory = await hre.ethers.getContractFactory('ScrollL2Gateway'); @@ -81,3 +81,25 @@ task('changeFeeParams', 'Change fee params for zkLink').setAction(async (taskArg // Waiting for the official Scroll bridge to forward the message to L2 // No user action is required for follow-up. }); + +task('encodeChangeFeeParams', 'Get the calldata of changing fee params for zkLink').setAction(async (_, hre) => { + const ethereumName = process.env.ETHEREUM; + const scrollName = process.env.SCROLL; + const l1GatewayLogName = getLogName(logName.DEPLOY_L1_GATEWAY_LOG_PREFIX, scrollName); + const l1GatewayAddr = readDeployContract(l1GatewayLogName, logName.DEPLOY_GATEWAY, ethereumName); + if (l1GatewayAddr === undefined) { + console.log('The l1 gateway address not exist'); + return; + } + console.log(`The l1 gateway address: ${l1GatewayAddr}`); + + const adapterParams = AbiCoder.defaultAbiCoder().encode(['uint256'], [200000]); + + const arbitratorFactory = await hre.ethers.getContractFactory('Arbitrator'); + const calldata = arbitratorFactory.interface.encodeFunctionData('changeFeeParams', [ + l1GatewayAddr, + INIT_FEE_PARAMS, + adapterParams, + ]); + console.log(`The changeFeeParams calldata: ${calldata}`); +}); diff --git a/examples/scroll/scripts/setValidator.js b/examples/scroll/scripts/setValidator.js index 5670d76..2e8382b 100644 --- a/examples/scroll/scripts/setValidator.js +++ b/examples/scroll/scripts/setValidator.js @@ -87,3 +87,33 @@ task('setValidator', 'Set validator for zkLink') // Waiting for the official Scroll bridge to forward the message to L2 // No user action is required for follow-up. }); + +task('encodeSetValidator', 'Get the calldata of set validator for zkLink') + .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; + console.log(`The validator: address: ${validatorAddr}, active: ${isActive}`); + + const ethereumName = process.env.ETHEREUM; + const scrollName = process.env.SCROLL; + const l1GatewayLogName = getLogName(logName.DEPLOY_L1_GATEWAY_LOG_PREFIX, scrollName); + const l1GatewayAddr = readDeployContract(l1GatewayLogName, logName.DEPLOY_GATEWAY, ethereumName); + if (l1GatewayAddr === undefined) { + console.log('The l1 gateway address not exist'); + return; + } + console.log(`The l1 gateway address: ${l1GatewayAddr}`); + + const adapterParams = AbiCoder.defaultAbiCoder().encode(['uint256'], [200000]); + + const arbitratorFactory = await hre.ethers.getContractFactory('Arbitrator'); + const calldata = arbitratorFactory.interface.encodeFunctionData('setValidator', [ + l1GatewayAddr, + validatorAddr, + isActive, + adapterParams, + ]); + console.log(`The setValidator calldata: ${calldata}`); + });