Skip to content

Commit

Permalink
Merge branch 'main' into fix/sui-gmp
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Aug 27, 2024
2 parents a32d184 + efe9836 commit 11a7a3e
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 96 deletions.
18 changes: 9 additions & 9 deletions axelar-chains-config/info/devnet-amplifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,24 @@
"contracts": {
"ServiceRegistry": {
"governanceAccount": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"codeId": 499,
"codeId": 624,
"address": "axelar1c9fkszt5lq34vvvlat3fxj6yv7ejtqapz04e97vtc9m5z9cwnamq8zjlhz"
},
"Router": {
"adminAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"codeId": 509,
"codeId": 623,
"address": "axelar14jjdxqhuxk803e9pq64w4fgf385y86xxhkpzswe9crmu6vxycezst0zq8y"
},
"Multisig": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"blockExpiry": 10,
"codeId": 494,
"codeId": 617,
"address": "axelar19jxy26z0qnnspa45y5nru0l5rmy9d637z5km2ndjxthfxf5qaswst9290r"
},
"Coordinator": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"codeId": 492,
"codeId": 615,
"address": "axelar1m2498n4h2tskcsmssjnzswl5e6eflmqnh487ds47yxyu6y5h4zuqr9zk4g"
},
"Rewards": {
Expand All @@ -302,12 +302,12 @@
"10"
]
},
"codeId": 497,
"codeId": 620,
"address": "axelar1vaj9sfzc3z0gpel90wu4ljutncutv0wuhvvwfsh30rqxq422z89qnd989l"
},
"NexusGateway": {
"nexus": "axelar17h8uk4ct0mdv9mgkuxszt4gp2htpfr08mge20r",
"codeId": 496,
"codeId": 619,
"address": "axelar1jjjr3tqs0nzjv3y9fg4xvzkww50jq06a9qp77r8kzmqyla97556sxx7702"
},
"VotingVerifier": {
Expand All @@ -324,7 +324,7 @@
"msgIdFormat": "hex_tx_hash_and_event_index",
"address": "axelar1ty7mx0cllgz8xuvhn2j7e3qy8999ssgmjtktyqetl335em0g88lq6rjhl2"
},
"codeId": 500,
"codeId": 626,
"fantom": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"serviceName": "validators",
Expand Down Expand Up @@ -369,7 +369,7 @@
"avalanche": {
"address": "axelar16hdkkxjyapw5zyf2wxs42854278tpwgqkz87kst8wamvr4pcy4pqrpn96s"
},
"codeId": 493,
"codeId": 616,
"fantom": {
"address": "axelar1pvcj8m7gp30tl26kt7n2ncg9g7xnt86wlqatlvwehh8s2ve2anmq6ea96w"
},
Expand All @@ -396,7 +396,7 @@
"domainSeparator": "0x598ba04d225cec385d1ce3cf3c9a076af803aa5c614bc0e0d176f04ac8d28f55",
"address": "axelar1g6520uhs8u37el40wqngf60z06mjgk6z7nezytd2mxrmh7yesnmsyc0zjw"
},
"codeId": 505,
"codeId": 618,
"fantom": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"adminAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
Expand Down
56 changes: 10 additions & 46 deletions common/cli-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

require('dotenv').config();

const fs = require('fs');
const { Option } = require('commander');

// A path to the chain configuration files
const CHAIN_CONFIG_PATH = `${__dirname}/../axelar-chains-config/info`;

// A list of available chain environments which are the names of the files in the CHAIN_CONFIG_PATH
const CHAIN_ENVIRONMENTS = fs.readdirSync(CHAIN_CONFIG_PATH).map((chainName) => chainName.split('.')[0]);

const addBaseOptions = (program, options = {}) => {
program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'devnet-amplifier', 'devnet-sui', 'devnet-verifiers', 'stagenet', 'testnet', 'mainnet'])
.default('testnet')
.makeOptionMandatory(true)
.env('ENV'),
new Option('-e, --env <env>', 'environment').choices(CHAIN_ENVIRONMENTS).default('testnet').makeOptionMandatory(true).env('ENV'),
);
program.addOption(new Option('-y, --yes', 'skip deployment prompt confirmation').env('YES'));
program.addOption(new Option('--parallel', 'run script parallely wrt chains'));
Expand Down Expand Up @@ -41,47 +44,8 @@ const addBaseOptions = (program, options = {}) => {
return program;
};

const addExtendedOptions = (program, options = {}) => {
addBaseOptions(program, options);

program.addOption(new Option('-v, --verify', 'verify the deployed contract on the explorer').env('VERIFY'));

if (options.artifactPath) {
program.addOption(new Option('--artifactPath <artifactPath>', 'artifact path'));
}

if (options.contractName) {
program.addOption(new Option('-c, --contractName <contractName>', 'contract name').makeOptionMandatory(true));
}

if (options.deployMethod) {
program.addOption(
new Option('-m, --deployMethod <deployMethod>', 'deployment method')
.choices(['create', 'create2', 'create3'])
.default(options.deployMethod),
);
}

if (options.salt) {
program.addOption(new Option('-s, --salt <salt>', 'salt to use for create2 deployment').env('SALT'));
}

if (options.skipExisting) {
program.addOption(new Option('-x, --skipExisting', 'skip existing if contract was already deployed on chain').env('SKIP_EXISTING'));
}

if (options.upgrade) {
program.addOption(new Option('-u, --upgrade', 'upgrade a deployed contract').env('UPGRADE'));
}

if (options.predictOnly) {
program.addOption(new Option('--predictOnly', 'output the predicted changes only').env('PREDICT_ONLY'));
}

return program;
};

module.exports = {
CHAIN_CONFIG_PATH,
CHAIN_ENVIRONMENTS,
addBaseOptions,
addExtendedOptions,
};
7 changes: 2 additions & 5 deletions cosmwasm/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require('dotenv').config();
const { isNil } = require('lodash');

const { CHAIN_ENVIRONMENTS } = require('../common');
const { isNumber, printInfo, loadConfig, saveConfig, prompt, getChainConfig } = require('../evm/utils');
const {
prepareWallet,
Expand Down Expand Up @@ -113,11 +114,7 @@ const programHandler = () => {
program.name('upload-contract').description('Upload CosmWasm contracts');

program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'stagenet', 'testnet', 'devnet-sui', 'mainnet'])
.default('testnet')
.makeOptionMandatory(true)
.env('ENV'),
new Option('-e, --env <env>', 'environment').choices(CHAIN_ENVIRONMENTS).default('testnet').makeOptionMandatory(true).env('ENV'),
);
program.addOption(new Option('-m, --mnemonic <mnemonic>', 'mnemonic').makeOptionMandatory(true).env('MNEMONIC'));
program.addOption(new Option('-a, --artifactPath <artifactPath>', 'artifact path').makeOptionMandatory(true).env('ARTIFACT_PATH'));
Expand Down
3 changes: 2 additions & 1 deletion cosmwasm/submit-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const {
governanceAddress,
} = require('./utils');
const { isNumber, saveConfig, loadConfig, printInfo, prompt } = require('../evm/utils');
const { CHAIN_ENVIRONMENTS } = require('../common');
const {
StoreCodeProposal,
StoreAndInstantiateContractProposal,
Expand Down Expand Up @@ -251,7 +252,7 @@ const programHandler = () => {
// TODO: combine deploy-contract and submit-proposal options to remove duplicates
program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'devnet-amplifier', 'devnet-sui', 'devnet-verifiers', 'stagenet', 'testnet', 'mainnet'])
.choices(CHAIN_ENVIRONMENTS)
.default('devnet-amplifier')
.makeOptionMandatory(true)
.env('ENV'),
Expand Down
47 changes: 46 additions & 1 deletion evm/cli-utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
const { Option } = require('commander');
const { addBaseOptions, ...exportedCliUtils } = require('../common/cli-utils');

const addEvmOptions = (program, options = {}) => {
addBaseOptions(program, options);

program.addOption(new Option('-v, --verify', 'verify the deployed contract on the explorer').env('VERIFY'));

if (options.artifactPath) {
program.addOption(new Option('--artifactPath <artifactPath>', 'artifact path'));
}

if (options.contractName) {
program.addOption(new Option('-c, --contractName <contractName>', 'contract name').makeOptionMandatory(true));
}

if (options.deployMethod) {
program.addOption(
new Option('-m, --deployMethod <deployMethod>', 'deployment method')
.choices(['create', 'create2', 'create3'])
.default(options.deployMethod),
);
}

if (options.salt) {
program.addOption(new Option('-s, --salt <salt>', 'salt to use for create2 deployment').env('SALT'));
}

if (options.skipExisting) {
program.addOption(new Option('-x, --skipExisting', 'skip existing if contract was already deployed on chain').env('SKIP_EXISTING'));
}

if (options.upgrade) {
program.addOption(new Option('-u, --upgrade', 'upgrade a deployed contract').env('UPGRADE'));
}

if (options.predictOnly) {
program.addOption(new Option('--predictOnly', 'output the predicted changes only').env('PREDICT_ONLY'));
}

return program;
};

module.exports = {
...require('../common/cli-utils'),
...exportedCliUtils,
addBaseOptions,
addEvmOptions,
};
4 changes: 2 additions & 2 deletions evm/deploy-amplifier-gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const {
getDeployOptions,
getDomainSeparator,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { addEvmOptions } = require('./cli-utils');
const { storeSignedTx, signTransaction, getWallet } = require('./sign-utils.js');

const { WEIGHTED_SIGNERS_TYPE, encodeWeightedSigners } = require('@axelar-network/axelar-gmp-sdk-solidity/scripts/utils');
Expand Down Expand Up @@ -399,7 +399,7 @@ async function programHandler() {
program.name('deploy-amplifier-gateway').description('Deploy Amplifier Gateway');

// use create3 as default deploy method
addExtendedOptions(program, { salt: true, deployMethod: 'create3', skipExisting: true, upgrade: true, predictOnly: true });
addEvmOptions(program, { salt: true, deployMethod: 'create3', skipExisting: true, upgrade: true, predictOnly: true });

program.addOption(new Option('-r, --rpc <rpc>', 'chain rpc url').env('URL'));
program.addOption(new Option('--previousSignersRetention <previousSignersRetention>', 'previous signer retention').default(15));
Expand Down
4 changes: 2 additions & 2 deletions evm/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const {
getContractJSON,
getDeployOptions,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { addEvmOptions } = require('./cli-utils');

async function getConstructorArgs(contractName, config, wallet, options) {
const args = options.args ? JSON.parse(options.args) : {};
Expand Down Expand Up @@ -335,7 +335,7 @@ if (require.main === module) {

program.name('deploy-contract').description('Deploy contracts using create, create2, or create3');

addExtendedOptions(program, {
addEvmOptions(program, {
artifactPath: true,
contractName: true,
salt: true,
Expand Down
4 changes: 2 additions & 2 deletions evm/deploy-gateway-v6.2.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const {
getGasOptions,
getDeployOptions,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { addEvmOptions } = require('./cli-utils');
const { storeSignedTx, signTransaction, getWallet } = require('./sign-utils.js');

const AxelarGatewayProxy = require('@axelar-network/axelar-cgp-solidity/artifacts/contracts/AxelarGatewayProxy.sol/AxelarGatewayProxy.json');
Expand Down Expand Up @@ -523,7 +523,7 @@ async function programHandler() {

program.name('deploy-gateway-v6.2.x').description('Deploy gateway v6.2.x');

addExtendedOptions(program, { salt: true, deployMethod: 'create', skipExisting: true, upgrade: true, predictOnly: true });
addEvmOptions(program, { salt: true, deployMethod: 'create', skipExisting: true, upgrade: true, predictOnly: true });

program.addOption(new Option('-r, --rpc <rpc>', 'chain rpc url').env('URL'));
program.addOption(new Option('--reuseProxy', 'reuse proxy contract modules for new implementation deployment'));
Expand Down
4 changes: 2 additions & 2 deletions evm/deploy-its.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const {
getDeployedAddress,
wasEventEmitted,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { addEvmOptions } = require('./cli-utils');
const { Command, Option } = require('commander');

/**
Expand Down Expand Up @@ -478,7 +478,7 @@ if (require.main === module) {
.default('create3'),
);

addExtendedOptions(program, { artifactPath: true, skipExisting: true, upgrade: true, predictOnly: true });
addEvmOptions(program, { artifactPath: true, skipExisting: true, upgrade: true, predictOnly: true });

program.addOption(new Option('--reuseProxy', 'reuse existing proxy (useful for upgrade deployments'));
program.addOption(new Option('--contractName <contractName>', 'contract name').default('InterchainTokenService')); // added for consistency
Expand Down
4 changes: 2 additions & 2 deletions evm/deploy-upgradable.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const {
getDeployOptions,
mainProcessor,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { addEvmOptions } = require('./cli-utils');

function getProxy(wallet, proxyAddress) {
return new Contract(proxyAddress, IUpgradable.abi, wallet);
Expand Down Expand Up @@ -297,7 +297,7 @@ if (require.main === module) {

program.name('deploy-upgradable').description('Deploy upgradable contracts');

addExtendedOptions(program, { artifactPath: true, contractName: true, salt: true, skipChains: true, upgrade: true, predictOnly: true });
addEvmOptions(program, { artifactPath: true, contractName: true, salt: true, skipChains: true, upgrade: true, predictOnly: true });

program.addOption(
new Option('-m, --deployMethod <deployMethod>', 'deployment method').choices(['create', 'create2', 'create3']).default('create2'),
Expand Down
4 changes: 2 additions & 2 deletions evm/interchainTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
} = ethers;
const { Command, Option } = require('commander');
const { printInfo, prompt, mainProcessor, validateParameters, getContractJSON, getGasOptions, printWalletInfo } = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { addEvmOptions } = require('./cli-utils');
const { getDeploymentSalt, handleTx, isValidDestinationChain } = require('./its');
const { getWallet } = require('./sign-utils');
const IInterchainTokenFactory = getContractJSON('IInterchainTokenFactory');
Expand Down Expand Up @@ -222,7 +222,7 @@ if (require.main === module) {

program.name('InterchainTokenFactory').description('Script to perform interchain token factory commands');

addExtendedOptions(program, { address: true, salt: true });
addEvmOptions(program, { address: true, salt: true });

program.addOption(
new Option('--action <action>', 'interchain token factory action')
Expand Down
4 changes: 2 additions & 2 deletions evm/its.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const InterchainTokenService = getContractJSON('InterchainTokenService');
const InterchainTokenFactory = getContractJSON('InterchainTokenFactory');
const IInterchainTokenDeployer = getContractJSON('IInterchainTokenDeployer');
const IOwnable = getContractJSON('IOwnable');
const { addExtendedOptions } = require('./cli-utils');
const { addEvmOptions } = require('./cli-utils');
const { getSaltFromKey } = require('@axelar-network/axelar-gmp-sdk-solidity/scripts/utils');
const tokenManagerImplementations = {
INTERCHAIN_TOKEN: 0,
Expand Down Expand Up @@ -656,7 +656,7 @@ if (require.main === module) {

program.name('ITS').description('Script to perform ITS commands');

addExtendedOptions(program, { address: true, salt: true });
addEvmOptions(program, { address: true, salt: true });

program.addOption(new Option('-c, --contractName <contractName>', 'contract name').default('InterchainTokenService'));
program.addOption(
Expand Down
7 changes: 2 additions & 5 deletions stellar/balances.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { Command, Option } = require('commander');
const { getWallet } = require('./utils');
const { loadConfig } = require('../evm/utils');
const { CHAIN_ENVIRONMENTS } = require('../common');
require('./cli-utils');

async function processCommand(options, _, chain) {
Expand All @@ -13,11 +14,7 @@ if (require.main === module) {
program.name('balances').description('Wallet balance');

program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'stagenet', 'testnet', 'mainnet'])
.default('testnet')
.makeOptionMandatory(true)
.env('ENV'),
new Option('-e, --env <env>', 'environment').choices(CHAIN_ENVIRONMENTS).default('testnet').makeOptionMandatory(true).env('ENV'),
);

program.addOption(new Option('-p, --privateKey <privateKey>', 'private key').makeOptionMandatory(true).env('PRIVATE_KEY'));
Expand Down
Loading

0 comments on commit 11a7a3e

Please sign in to comment.