Skip to content

Commit

Permalink
Merge branch 'main' into refactor/factory-imports-verify-script
Browse files Browse the repository at this point in the history
  • Loading branch information
blockchainguyy authored Oct 18, 2023
2 parents 0c1fa64 + 16d97d4 commit efd1c1f
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 81 deletions.
64 changes: 62 additions & 2 deletions axelar-chains-config/info/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"explorer": {
"url": "https://etherscan.io",
"api": "https://api.etherscan.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 150000000000
}
},
"avalanche": {
Expand Down Expand Up @@ -94,6 +98,10 @@
"explorer": {
"url": "https://snowtrace.io",
"api": "https://api.snowtrace.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 150000000000
}
},
"fantom": {
Expand Down Expand Up @@ -145,6 +153,10 @@
},
"gasOptions": {
"gasLimit": 5000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 1000000000000
}
},
"polygon": {
Expand Down Expand Up @@ -196,6 +208,10 @@
},
"gasOptions": {
"gasLimit": 6000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 350000000000
}
},
"moonbeam": {
Expand Down Expand Up @@ -244,6 +260,10 @@
"explorer": {
"url": "https://moonbeam.moonscan.io",
"api": "https://api-moonbeam.moonscan.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 625000000000
}
},
"binance": {
Expand Down Expand Up @@ -293,6 +313,10 @@
"explorer": {
"url": "https://bscscan.com",
"api": "https://api.bscscan.com/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 30000000000
}
},
"arbitrum": {
Expand Down Expand Up @@ -344,6 +368,10 @@
},
"gasOptions": {
"gasLimit": 20000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 2000000000
}
},
"celo": {
Expand Down Expand Up @@ -392,6 +420,10 @@
"explorer": {
"url": "https://celoscan.io",
"api": "https://api.celoscan.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 100000000000
}
},
"kava": {
Expand Down Expand Up @@ -440,6 +472,10 @@
"explorer": {
"url": "https://explorer.kava.io",
"api": "https://explorer.kava.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 50000000000
}
},
"filecoin": {
Expand Down Expand Up @@ -494,6 +530,10 @@
},
"gasOptions": {
"gasLimit": 500000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 1000000000
}
},
"optimism": {
Expand Down Expand Up @@ -550,7 +590,11 @@
"gasOptions": {
"gasLimit": 5000000
},
"confirmations": 3
"confirmations": 3,
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 10000000000
}
},
"linea": {
"name": "Linea",
Expand Down Expand Up @@ -602,6 +646,10 @@
"explorer": {
"url": "https://lineascan.build",
"api": "https://api.lineascan.build/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 10000000000
}
},
"base": {
Expand Down Expand Up @@ -654,6 +702,10 @@
"explorer": {
"url": "https://basescan.org",
"api": "https://api.basescan.org/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 10000000000
}
},
"mantle": {
Expand Down Expand Up @@ -710,7 +762,11 @@
"gasOptions": {
"gasLimit": 8000000
},
"skipRevertTests": true
"skipRevertTests": true,
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 25000000000
}
},
"scroll": {
"name": "Scroll",
Expand Down Expand Up @@ -761,6 +817,10 @@
"confirmations": 2,
"gasOptions": {
"gasLimit": 8000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 25000000000
}
}
},
Expand Down
53 changes: 4 additions & 49 deletions axelar-chains-config/info/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -1646,55 +1646,10 @@
"gasOptions": {
"gasLimit": 8000000
},
"skipRevertTests": true
},
"centrifuge": {
"name": "Centrifuge",
"status": "deactive",
"id": "centrifuge",
"chainId": 2089,
"rpc": "https://fullnode.algol.cntrfg.com",
"tokenSymbol": "ALGL",
"contracts": {
"AxelarGateway": {
"deployer": "0xB8Cd93C83A974649D76B1c19f311f639e62272BC",
"address": "0xe432150cce91c13a887f7D836923d5597adD8E31",
"implementation": "0x05823c334150a48ACD5D325fBA16147c21bA3653",
"authModule": "0x1a920B29eBD437074225cAeE44f78FC700B27a5d",
"tokenDeployer": "0x8A156bCA562FB75385c4d41ea6903E270A34B727"
},
"AxelarGasService": {
"collector": "0x7F83F5cA2AE4206AbFf8a3C3668e88ce5F11C0B5",
"address": "0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6",
"implementation": "0x125AAf72B24a78f7aE5Cae92D7717f533633320d",
"deployer": "0x5b593E7b1725dc6FcbbFe80b2415B19153F94A85",
"owner": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05"
},
"AxelarDepositService": {
"wrappedSymbol": "",
"refundIssuer": "0x4f671f34d2d23fec3eE3087E3A0221f8D314D9dF",
"salt": "AxelarDepositService",
"address": "0xc1DCb196BA862B337Aa23eDA1Cb9503C0801b955",
"implementation": "0xd883C8bA523253c93d97b6C7a5087a7B5ff23d79",
"deployer": "0xd55cd98cdE61c3CcE1286F9aF50cDbF16f5dba5b"
},
"ConstAddressDeployer": {
"address": "0x98B2920D53612483F91F12Ed7754E51b4A77919e"
},
"Operators": {
"owner": "0xB8Cd93C83A974649D76B1c19f311f639e62272BC",
"address": "0x7F83F5cA2AE4206AbFf8a3C3668e88ce5F11C0B5",
"deployer": "0xB8Cd93C83A974649D76B1c19f311f639e62272BC",
"deploymentMethod": "create2",
"salt": "Operators"
}
},
"explorer": {
"url": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ffullnode.algol.cntrfg.com%2Fpublic-ws#/explorer",
"api": ""
},
"gasOptions": {
"gasLimit": 8000000
"skipRevertTests": true,
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 1000000000
}
},
"scroll": {
Expand Down
4 changes: 2 additions & 2 deletions axelar-chains-config/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion axelar-chains-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axelar-network/axelar-chains-config",
"version": "0.1.2",
"version": "0.1.3",
"description": "A utility to get chain information from Axelar",
"main": "src/index.js",
"types": "dist/index.d.ts",
Expand Down
35 changes: 13 additions & 22 deletions axelar-chains-config/src/utils/verifyContract.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const { exec } = require('child_process');
const { writeFile, writeFileSync, existsSync } = require('fs');
const { promisify } = require('util');

const execAsync = promisify(exec);
const writeFileAsync = promisify(writeFile);
const { execSync } = require('child_process');
const { writeFileSync } = require('fs');

/**
* Verifies a contract on etherscan-like explorer of the provided chain using hardhat.
Expand All @@ -14,31 +10,26 @@ const writeFileAsync = promisify(writeFile);
* @param {string} chain
* @param {string} contract
* @param {any[]} args
* @returns {Promise<void>}
* @returns {void}
*/
const verifyContract = async (env, chain, contract, args, options = {}) => {
const verifyContract = (env, chain, contract, args, options = {}) => {
const stringArgs = args.map((arg) => JSON.stringify(arg));
const content = `module.exports = [\n ${stringArgs.join(',\n ')}\n];`;
const file = options.dir ? `${options.dir}/temp-arguments.js` : 'temp-arguments.js';

if (!existsSync(file)) {
writeFileSync(file, '', 'utf-8');
}
const file = 'temp-arguments.js';
const filePath = options.dir ? `${options.dir}/temp-arguments.js` : 'temp-arguments.js';

const contractArg = options.contractPath ? `--contract ${options.contractPath}` : '';
const dirPrefix = options.dir ? `cd ${options.dir};` : '';
const cmd = `${dirPrefix} ENV=${env} npx hardhat verify --network ${chain.toLowerCase()} ${contractArg} --no-compile --constructor-args ${file} ${contract} --show-stack-traces`;

return writeFileAsync(file, content, 'utf-8')
.then(() => {
console.log(`Verifying contract ${contract} with args '${stringArgs.join(',')}'`);
console.log(cmd);
writeFileSync(filePath, content, 'utf-8');

console.log(`Verifying contract ${contract} with args '${stringArgs.join(',')}'`);
console.log(cmd);

execSync(cmd, { stdio: 'inherit' });

return execAsync(cmd, { stdio: 'inherit' });
})
.then(() => {
console.log('Verified!');
});
console.log('Verified!');
};

module.exports = {
Expand Down
40 changes: 35 additions & 5 deletions evm/update-static-gas-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,51 @@ const { printInfo, mainProcessor, prompt } = require('./utils');
const defaultGasLimit = 3e6;
const gasPriceMultiplier = 5;

async function processCommand(config, chain, options) {
const { rpc, yes } = options;
const minGasPrices = {
mainnet: {
ethereum: 150,
moonbeam: 500,
avalanche: 150,
polygon: 350,
fantom: 1000,
binance: 30,
arbitrum: 2,
celo: 100,
kava: 50,
optimism: 10,
filecoin: 1,
base: 10,
linea: 10,
mantle: 25,
scroll: 25,
},
testnet: {
mantle: 1,
},
};

async function processCommand(_, chain, options) {
const { env, rpc, yes } = options;
const provider = rpc ? getDefaultProvider(rpc) : getDefaultProvider(chain.rpc);

if (prompt(`Proceed with the static gasOption update on ${chalk.green(chain.name)}`, yes)) {
return;
}

const gasPrice = parseUnits((await provider.getGasPrice()).toString(), 'wei') * gasPriceMultiplier;
const gasPriceWei = await provider.getGasPrice();
printInfo(`${chain.name} gas price`, `${gasPriceWei / 1e9} gwei`);

const gasPrice = parseUnits(gasPriceWei.toString(), 'wei') * gasPriceMultiplier;

if (!(chain.staticGasOptions && chain.staticGasOptions.gasLimit !== undefined)) {
chain.staticGasOptions = { gasLimit: defaultGasLimit };
}

chain.staticGasOptions.gasPrice = gasPrice;
const minGasPrice = ((minGasPrices[env] || {})[chain.name.toLowerCase()] || 0) * 1e9;
chain.staticGasOptions.gasPrice = gasPrice < minGasPrice ? minGasPrice : gasPrice;

printInfo(`${chain.name} static gas price set to`, `${chain.staticGasOptions.gasPrice / 1e9} gwei`);

printInfo(`staticGasOptions updated succesfully and stored in config file`);
}

Expand All @@ -37,7 +67,7 @@ async function main(options) {

const program = new Command();

program.name('update-static-gas-options').description('Update staticGasOptions to be used when offline signing');
program.name('update-static-gas-options').description('Update staticGasOptions');

program.addOption(
new Option('-e, --env <env>', 'environment')
Expand Down

0 comments on commit efd1c1f

Please sign in to comment.