Skip to content

Commit

Permalink
Merge pull request #259 from rsksmart/feature/add-proxies-as-named-ac…
Browse files Browse the repository at this point in the history
…counts

[TBRE-354] Add proxies as named accounts in Hardhat config
  • Loading branch information
Marccio Silva authored Aug 27, 2021
2 parents 0e895d9 + 2d2b55f commit ac63f4b
Show file tree
Hide file tree
Showing 8 changed files with 694 additions and 381 deletions.
19 changes: 8 additions & 11 deletions bridge/deploy/01_deploy_multiSigWallet.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
const { deploy1820 } = require('@thinkanddev/deploy-eip-1820-web3-rsk')
const {deploy1820} = require('@thinkanddev/deploy-eip-1820-web3-rsk');

module.exports = async function ({getNamedAccounts, deployments, network}) { // HardhatRuntimeEnvironment
const {deployer, multiSig} = await getNamedAccounts()
const {deploy, log} = deployments
module.exports = async function({getNamedAccounts, deployments, network}) { // HardhatRuntimeEnvironment
const {deployer, multiSig} = await getNamedAccounts();
const {deploy, log} = deployments;

if (!multiSig) {
const deployResult = await deploy('MultiSigWallet', {
from: deployer,
args: [
[deployer],
1
],
log: true,
args: [[deployer], 1],
log: true
});

if (deployResult.newlyDeployed) {
Expand All @@ -23,6 +20,6 @@ module.exports = async function ({getNamedAccounts, deployments, network}) { //
if (!network.live) {
await deploy1820(web3);
}
}
module.exports.id = 'deploy_multiSigWallet'; // id required to prevent reexecution
};
module.exports.id = 'deploy_multiSigWallet'; // id required to prevent re-execution
module.exports.tags = ['MultiSigWallet'];
12 changes: 5 additions & 7 deletions bridge/deploy/02_deploy_proxyAdmin.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = async function ({getNamedAccounts, deployments}) { // HardhatRuntimeEnvironment
const {deployer, multiSig, proxyAdmin} = await getNamedAccounts()
const {deploy, log, execute} = deployments
module.exports = async function({getNamedAccounts, deployments}) { // HardhatRuntimeEnvironment
const {deployer, multiSig, proxyAdmin} = await getNamedAccounts();
const {deploy, log, execute} = deployments;

if (!proxyAdmin) {
const deployResult = await deploy('ProxyAdmin', {
from: deployer,
log: true,
log: true
});

if (deployResult.newlyDeployed) {
Expand All @@ -14,9 +14,7 @@ module.exports = async function ({getNamedAccounts, deployments}) { // HardhatRu
);
const MultiSigWallet = await deployments.get('MultiSigWallet');
await execute('ProxyAdmin', {from: deployer}, 'transferOwnership', multiSig ?? MultiSigWallet.address);
log(
`Transfered Ownership to MultiSig`
);
log(`Transfered Ownership to MultiSig`);
}
}
};
Expand Down
41 changes: 19 additions & 22 deletions bridge/deploy/08_deploy_bridgeProxy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module.exports = async function ({getNamedAccounts, deployments, network}) { // HardhatRuntimeEnvironment
const {deployer, multiSig, proxyAdmin} = await getNamedAccounts()
const {deploy, log} = deployments
module.exports = async function({getNamedAccounts, deployments, network}) { // HardhatRuntimeEnvironment
const {deployer, multiSig, proxyAdmin, bridgeProxy} = await getNamedAccounts();
const {deploy, log} = deployments;

if (!bridgeProxy) {
let symbol = 'e';
if(network.name == 'rskregtest' || network.name == 'rsktestnet' || network.name == 'rskmainnet')
symbol = 'r'
if (network.name === 'rskregtest' || network.name === 'rsktestnet' || network.name === 'rskmainnet') {
symbol = 'r';
}

const MultiSigWallet = await deployments.get('MultiSigWallet');
const ProxyAdmin = await deployments.get('ProxyAdmin');
Expand All @@ -15,29 +17,24 @@ module.exports = async function ({getNamedAccounts, deployments, network}) { //
const Bridge_old = await deployments.get('Bridge_old');
const bridge = new web3.eth.Contract(Bridge_old.abi, Bridge_old.address);
const methodCall = bridge.methods.initialize(
multiSig ?? MultiSigWallet.address,
Federation_old.address,
AllowTokens_old.address,
SideTokenFactory_old.address,
symbol
multiSig ?? MultiSigWallet.address,
Federation_old.address,
AllowTokens_old.address,
SideTokenFactory_old.address,
symbol
);
await methodCall.call({ from: deployer })
await methodCall.call({from: deployer});

const deployProxyResult = await deploy('BridgeProxy', {
from: deployer,
args: [
Bridge_old.address,
proxyAdmin ?? ProxyAdmin.address,
methodCall.encodeABI()
],
log: true,
from: deployer,
args: [Bridge_old.address, proxyAdmin ?? ProxyAdmin.address, methodCall.encodeABI()],
log: true
});
if (deployProxyResult.newlyDeployed) {
log(
`Contract BridgeProxy deployed at ${deployProxyResult.address} using ${deployProxyResult.receipt.gasUsed.toString()} gas`
);
log(`Contract BridgeProxy deployed at ${deployProxyResult.address} using ${deployProxyResult.receipt.gasUsed.toString()} gas`);
}
}
};
module.exports.id = 'deploy_bridgeProxy'; // id required to prevent reexecution
module.exports.tags = ['BridgeProxy', 'old'];
module.exports.dependencies = ['Bridge_old', 'MultiSigWallet', 'ProxyAdmin','Federation_old', 'AllowTokens_old', 'SideTokenFactory_old'];
module.exports.dependencies = ['Bridge_old', 'MultiSigWallet', 'ProxyAdmin', 'Federation_old', 'AllowTokens_old', 'SideTokenFactory_old'];
Loading

0 comments on commit ac63f4b

Please sign in to comment.