Skip to content

Commit

Permalink
tasks restructure and linter run
Browse files Browse the repository at this point in the history
  • Loading branch information
aalavandhan committed Oct 25, 2021
1 parent 6b970a1 commit 24c4a60
Show file tree
Hide file tree
Showing 31 changed files with 904 additions and 155 deletions.
83 changes: 52 additions & 31 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require('@nomiclabs/hardhat-etherscan');
require('./tasks/deploy/ampleforth');
require('./tasks/deploy/chain_bridge');
require('./tasks/deploy/matic');
require('./tasks/deploy/arbitrum');
require('./tasks/deploy/rebase_reporter');

require('./tasks/ops/rebase');
Expand All @@ -26,94 +27,114 @@ module.exports = {
solidity: {
compilers: [
{
version: '0.4.24'
version: '0.4.24',
},
{
version: '0.7.6'
version: '0.5.12',
},
{
version: '0.6.4'
version: '0.6.4',
},
{
version: '0.6.8'
version: '0.6.8',
},
{
version: '0.5.12'
version: '0.6.11',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.7.3',
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
]
runs: 200,
},
},
},
{
version: '0.7.6',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},
mocha: {
timeout: 1000000
timeout: 1000000,
},
gasReporter: {
currency: 'USD',
enabled: !!process.env.REPORT_GAS,
excludeContracts: ['_mocks', '_external', 'uFragments'],
coinmarketcap: process.env.COINMARKETCAP_API_KEY
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},

etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY
apiKey: process.env.ETHERSCAN_API_KEY,
},

bscscan: {
apiKey: process.env.BSCSCAN_API_KEY
apiKey: process.env.BSCSCAN_API_KEY,
},

networks: {
localGethBaseChain: {
url: 'http://localhost:7545'
url: 'http://localhost:7545',
},
localGethSatChain1: {
url: 'http://localhost:7550'
url: 'http://localhost:7550',
},
localGethSatChain2: {
url: 'http://localhost:7555'
url: 'http://localhost:7555',
},

// meter-passport
dev1RopstenBaseChain: {
url: 'https://eth-ropsten.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET
url: 'https://eth-ropsten.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET,
},
dev1BscTestnetSatChain: {
url: 'https://data-seed-prebsc-1-s1.binance.org:8545'
url: 'https://data-seed-prebsc-1-s1.binance.org:8545',
},
dev1MeterTestnetSatChain: {
url: 'https://rpctest.meter.io'
url: 'https://rpctest.meter.io',
},

// matic
dev2GoerliBaseChain: {
url: 'https://eth-goerli.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET
url: 'https://eth-goerli.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET,
},
dev2MumbaiSatChain: {
url: 'https://polygon-mumbai.infura.io/v3/' + process.env.INFURA_SECRET
url: 'https://polygon-mumbai.infura.io/v3/' + process.env.INFURA_SECRET,
},

// arbitrum
dev3RinkebyBaseChain: {
url: 'https://eth-rinkeby.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET,
},
dev3RinkebyArbitrumSatChain: {
url: 'https://rinkeby.arbitrum.io/rpc',
},

// prod
prodEthereumBaseChain: {
url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_SECRET
url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_SECRET,
},
prodBscSatChain: {
url: 'https://bsc-dataseed.binance.org'
},
prodAvaxSatChain: {
url: 'https://api.avax.network/ext/bc/C/rpc'
url: 'https://bsc-dataseed.binance.org',
},
prodMeterSatChain: {
url: 'https://rpc.meter.io'
url: 'https://rpc.meter.io',
},
prodMaticSatChain: {
url: 'https://polygon-mainnet.infura.io/v3/' + process.env.INFURA_SECRET
}
}
url: 'https://polygon-mainnet.infura.io/v3/' + process.env.INFURA_SECRET,
},
},
};
44 changes: 27 additions & 17 deletions helpers/contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const ContractABIPaths = {
MaticXCAmpleRebaseGateway: 'contracts/satellite-chain/bridge-gateways',
MaticXCAmpleTransferGateway: 'contracts/satellite-chain/bridge-gateways',

AMPLArbitrumGateway: 'contracts/base-chain/bridge-gateways',
ArbitrumXCAmpleGateway: 'contracts/satellite-chain/bridge-gateways',

// utilities
ChainBridgeBatchRebaseReport: 'contracts/_utilities',
};
Expand All @@ -54,11 +57,18 @@ const getCompiledContractFactory = (ethers, contract) => {
);
};

const deployContract = async (ethers, contractName, signer, args, txParams) => {
const deployContract = async (
ethers,
contractName,
signer,
args,
txParams,
waitBlocks = 0,
) => {
// console.log('Deploying', contractName);
const Factory = await getCompiledContractFactory(ethers, contractName);
const contract = await Factory.connect(signer).deploy(...args, txParams);
await contract.deployTransaction.wait();
await contract.deployTransaction.wait(waitBlocks);
// console.log('Deployed');
return contract;
};
Expand All @@ -75,6 +85,7 @@ const deployProxyContract = async (
args,
initializerDef,
txParams,
waitBlocks = 0,
) => {
// console.log('Deploying proxy', contractName);
const ProxyAdminFactory = await getCompiledContractFactory(
Expand All @@ -88,7 +99,7 @@ const deployProxyContract = async (
initializerDef,
txParams,
);
await contract.deployTransaction.wait();
await contract.deployTransaction.wait(waitBlocks);
// console.log('Deployed');

const defaultProxyAdmin = ProxyAdminFactory.connect(signer).attach(
Expand All @@ -99,7 +110,7 @@ const deployProxyContract = async (
newProxyAdmin.address,
txParams,
);
await refChangeTx.wait();
await refChangeTx.wait(waitBlocks);

return contract;
};
Expand All @@ -111,7 +122,7 @@ const upgradeProxyContract = async (
deployedContractRef,
signer,
txParams,
force=false,
force = false,
) => {
const proxyAdmin = await getDeployedContractInstance(
network,
Expand All @@ -125,25 +136,24 @@ const upgradeProxyContract = async (
ethers.provider,
);

const currentImplAddr = await proxyAdmin.getProxyImplementation(proxy.address);
console.log(`Current implementation for ${contractName} is at`, currentImplAddr);
const currentImplAddr = await proxyAdmin.getProxyImplementation(
proxy.address,
);
console.log(
`Current implementation for ${contractName} is at`,
currentImplAddr,
);

// deploy new implementation
let newImpl;
if(!force) {
if (!force) {
const Factory = await getCompiledContractFactory(ethers, contractName);
newImpl = await upgrades.prepareUpgrade(proxy.address, Factory);
} else {
console.log(`CAUTION: Skpping storage layout verification!`)
console.log(`CANCEL NOW to stop, this action is not reversable`)
console.log(`CAUTION: Skpping storage layout verification!`);
console.log(`CANCEL NOW to stop, this action is not reversable`);
await sleep(10);
newImpl = await deployContract(
ethers,
contractName,
signer,
[],
txParams,
);
newImpl = await deployContract(ethers, contractName, signer, [], txParams);
}
console.log(`New implementation for ${contractName} is at`, newImpl.address);

Expand Down
Loading

0 comments on commit 24c4a60

Please sign in to comment.