From cae93b77958aa32dff6bb6ebe73594d1b630ce53 Mon Sep 17 00:00:00 2001 From: Olga Kunyavskaya Date: Wed, 11 Sep 2024 12:28:19 +0300 Subject: [PATCH] update proxy admin --- eth-custodian/hardhat.config.js | 9 +++++++ eth-custodian/scripts/update_admin_proxy.js | 30 +++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 eth-custodian/scripts/update_admin_proxy.js diff --git a/eth-custodian/hardhat.config.js b/eth-custodian/hardhat.config.js index 8c39f00..f5d69b0 100644 --- a/eth-custodian/hardhat.config.js +++ b/eth-custodian/hardhat.config.js @@ -37,6 +37,15 @@ task('eth-deploy-proxy', 'Deploy Eth Custodian Proxy') await deployEthProxy(ethereumConfig); }); +task('update-admin-proxy', 'Update admin for Eth Custodian Proxy') + .addParam('configName', 'File name without extension for the config') + .addParam('newAdmin', 'Eth address of new admin') + .setAction(async taskArgs => { + const { updateAdminProxy } = require('./scripts/update_admin_proxy'); + const ethereumConfig = require(`./scripts/json/${taskArgs.configName}.json`); + await updateAdminProxy(ethereumConfig, taskArgs.newAdmin); + }); + task('nominate-admin', 'Nominate new admin for Eth Custodian') .addParam('newAdmin', 'Eth address of new admin') .setAction(async taskArgs => { diff --git a/eth-custodian/scripts/update_admin_proxy.js b/eth-custodian/scripts/update_admin_proxy.js new file mode 100644 index 0000000..7fa6742 --- /dev/null +++ b/eth-custodian/scripts/update_admin_proxy.js @@ -0,0 +1,30 @@ +const hre = require('hardhat'); + +async function updateAdminProxy(ethereumConfig, newAdmin) { + const privateKey = hre.network.config.accounts[0]; + const signerWallet = new hre.ethers.Wallet(privateKey, hre.ethers.provider); + + console.log(`Update admin proxy with the account: ${signerWallet.address}`); + + const ethCustodianProxyContractFactory = await hre.ethers.getContractFactory('EthCustodianProxy'); + const ethCustodianProxy = await ethCustodianProxyContractFactory.attach(ethereumConfig.proxyAddress); + + console.log(`EthCustodian Proxy address: ${await ethCustodianProxy.getAddress()}`); + + let tx_grant_admin = await ethCustodianProxy + .connect(signerWallet) + .grantRole("0x0000000000000000000000000000000000000000000000000000000000000000", newAdmin); + console.log(`Grant Admin Role for ${newAdmin} Tx Hash: ${tx_grant_admin.hash}`); + + let tx_grant_pausable = await ethCustodianProxy + .connect(signerWallet) + .grantRole("0x1e1db0d9c63b4a23ec134ff71a2f56610c32f638cbff81e96e14734c4daf0b4d", newAdmin); + console.log(`Grant Pausable Admin Role for ${newAdmin} Tx Hash: ${tx_grant_pausable.hash}`); + + let tx_revoke_pausable = await ethCustodianProxy + .connect(signerWallet) + .revokeRole("0x1e1db0d9c63b4a23ec134ff71a2f56610c32f638cbff81e96e14734c4daf0b4d", signerWallet.address); + console.log(`Revoke Pausable Admin Role for ${signerWallet.address} Tx Hash: ${tx_revoke_pausable.hash}`); +} + +exports.updateAdminProxy = updateAdminProxy;