Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions eth-custodian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ERC20_DECIMALS=

NEAR_RECIPIENT=${NEAR_ACCOUNT}
ETH_CUSTODIAN_PROXY=
CONFIG_NAME=ethereum-config

compile:
mkdir -p build/proofs && yarn hardhat compile
Expand All @@ -40,10 +41,10 @@ eth-deploy-contracts:
yarn hardhat run --network ${NETWORK} scripts/eth_deploy_contracts.js

eth-deploy-proxy:
yarn hardhat run --network ${NETWORK} scripts/eth_deploy_proxy.js
yarn hardhat --network ${NETWORK} eth-deploy-proxy --config-name ${CONFIG_NAME}

eth-upgrade-proxy:
yarn hardhat run --network ${NETWORK} scripts/eth_upgrade_proxy.js
yarn hardhat run --network ${NETWORK} scripts/eth_upgrade_proxy.js

update-admin-legacy:
yarn hardhat --network ${NETWORK} update-admin-legacy --new-admin ${ETH_CUSTODIAN_PROXY}
Expand Down
17 changes: 17 additions & 0 deletions eth-custodian/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ task('update-admin-legacy', 'Nominate new admin for Eth Custodian')
await updateAdminLegacy(hre.ethers.provider, taskArgs.newAdmin);
});

task('eth-deploy-proxy', 'Deploy Eth Custodian Proxy')
.addParam('configName', 'File name without extension for the config')
.setAction(async taskArgs => {
const { deployEthProxy } = require('./scripts/eth_deploy_proxy');
const ethereumConfig = require(`./scripts/json/${taskArgs.configName}.json`);
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 => {
Expand Down
13 changes: 2 additions & 11 deletions eth-custodian/scripts/eth_deploy_proxy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const hre = require('hardhat');

const ethereumConfig = require('./json/ethereum-config.json');

async function main() {
async function deployEthProxy(ethereumConfig) {
const [deployerAccount] = await hre.ethers.getSigners();

console.log(`Deploying proxy with the account: ${deployerAccount.address}`);
Expand All @@ -20,11 +18,4 @@ async function main() {
console.log(`Next, proxy must be made the admin of EthCustodian. The existing admin needs to first call nominateAdmin and then acceptAdmin on EthCustodian passing the proxy address`);
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
exports.deployEthProxy = deployEthProxy;
5 changes: 3 additions & 2 deletions eth-custodian/scripts/json/ethereum-config-mainnet.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"proverAddress": "0x051ad3f020274910065dcb421629cd2e6e5b46c4",
"clientAddress": "0x0151568af92125fb289f1dd81d9d8f7484efc362",
"clientAddress": "0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873",
"ethConnectorAddress": "0x6BFaD42cFC4EfC96f529D786D643Ff4A8B89FA52",
"nearEvmAccount": "aurora",
"bridgeFactoryAccount": "factory.bridge.near"
"bridgeFactoryAccount": "factory.bridge.near",
"proxyAddress": "TODO"
}

30 changes: 30 additions & 0 deletions eth-custodian/scripts/update_admin_proxy.js
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this from the other script is equivalent and an easier way to get the signer
const [signerWallet] = await hre.ethers.getSigners();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns HardhatEthersSigner, but I need Wallet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signer seem to be enough for all subsequent uses of this object


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}`);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to wait for the transaction to complete.

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;