Skip to content

Commit

Permalink
Add proxies as named accounts, check if they exist before deploying t…
Browse files Browse the repository at this point in the history
…hem in migrations, refactor associated files (having added Prettier config for JS files)
  • Loading branch information
Marccio Silva committed Aug 26, 2021
1 parent 0e895d9 commit 62a0a94
Show file tree
Hide file tree
Showing 7 changed files with 492 additions and 388 deletions.
26 changes: 26 additions & 0 deletions bridge/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
}
},
{
"files": "*.js",
"options": {
"parser": "json5",
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false
}
}
]
}
23 changes: 10 additions & 13 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', {
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.tags = ['MultiSigWallet'];
};
module.exports.id = "deploy_multiSigWallet"; // id required to prevent reexecution
module.exports.tags = ["MultiSigWallet"];
22 changes: 10 additions & 12 deletions bridge/deploy/02_deploy_proxyAdmin.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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', {
const deployResult = await deploy("ProxyAdmin", {
from: deployer,
log: true,
});
Expand All @@ -12,14 +12,12 @@ module.exports = async function ({getNamedAccounts, deployments}) { // HardhatRu
log(
`Contract ProxyAdmin deployed at ${deployResult.address} using ${deployResult.receipt.gasUsed.toString()} gas`
);
const MultiSigWallet = await deployments.get('MultiSigWallet');
await execute('ProxyAdmin', {from: deployer}, 'transferOwnership', multiSig ?? MultiSigWallet.address);
log(
`Transfered Ownership to MultiSig`
);
const MultiSigWallet = await deployments.get("MultiSigWallet");
await execute("ProxyAdmin", { from: deployer }, "transferOwnership", multiSig ?? MultiSigWallet.address);
log(`Transfered Ownership to MultiSig`);
}
}
};
module.exports.id = 'deploy_proxyAdmin'; // id required to prevent reexecution
module.exports.tags = ['ProxyAdmin'];
module.exports.dependencies = ['MultiSigWallet'];
module.exports.id = "deploy_proxyAdmin"; // id required to prevent reexecution
module.exports.tags = ["ProxyAdmin"];
module.exports.dependencies = ["MultiSigWallet"];
61 changes: 29 additions & 32 deletions bridge/deploy/08_deploy_bridgeProxy.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
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;

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

const MultiSigWallet = await deployments.get('MultiSigWallet');
const ProxyAdmin = await deployments.get('ProxyAdmin');
const Federation_old = await deployments.get('Federation_old');
const AllowTokens_old = await deployments.get('AllowTokens_old');
const SideTokenFactory_old = await deployments.get('SideTokenFactory_old');
const MultiSigWallet = await deployments.get("MultiSigWallet");
const ProxyAdmin = await deployments.get("ProxyAdmin");
const Federation_old = await deployments.get("Federation_old");
const AllowTokens_old = await deployments.get("AllowTokens_old");
const SideTokenFactory_old = await deployments.get("SideTokenFactory_old");

const Bridge_old = await deployments.get('Bridge_old');
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,
const deployProxyResult = await deploy("BridgeProxy", {
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.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"];
Loading

0 comments on commit 62a0a94

Please sign in to comment.