Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TBRE-354] Add proxies as named accounts in Hardhat config #259

Merged
merged 2 commits into from
Aug 27, 2021
Merged
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
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