Skip to content

Commit

Permalink
Merge branch 'main' into feat/sui-ledger-support
Browse files Browse the repository at this point in the history
  • Loading branch information
blockchainguyy authored Dec 19, 2024
2 parents da33885 + 8e184cc commit ae40c09
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 192 deletions.
9 changes: 1 addition & 8 deletions axelar-chains-config/info/devnet-amplifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,6 @@
"codeId": 844,
"address": "axelar1wvms3cy5hxrgl7uxhkz7yth4qzqum6aaccwkmvafq8z0mgdfxr8qrnvw0k",
"nexus": "axelar17h8uk4ct0mdv9mgkuxszt4gp2htpfr08mge20r",
"axelar": {
"storeInstantiateProposalId": "59",
"codeId": 845
},
"storeCodeProposalCodeHash": "c7286d0f59276b794641bdfbb4f96fafcee3553b67f3397d662a4683968f525b",
"storeCodeProposalId": "60",
"lastUploadedCodeId": 845
Expand All @@ -852,10 +848,7 @@
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"codeId": 843,
"address": "axelar157hl7gpuknjmhtac2qnphuazv2yerfagva7lsu9vuj2pgn32z22qa26dk4",
"axelar": {
"codeId": 843,
"instantiateProposalId": "61"
},
"instantiateProposalId": "61",
"sui": {
"maxUintBits": 64,
"maxDecimalsWhenTruncating": 8
Expand Down
9 changes: 1 addition & 8 deletions axelar-chains-config/info/stagenet.json
Original file line number Diff line number Diff line change
Expand Up @@ -1851,10 +1851,7 @@
"storeCodeProposalCodeHash": "b60d0d227c7a400a0fcc80ed52f0e6688e5da6db676a61ed8b6942823294031d",
"governanceAddress": "axelar10d07y265gmmuvt4z0w9aw880jnsr700j7v9daj",
"adminAddress": "axelar12qvsvse32cjyw60ztysd3v655aj5urqeup82ky",
"axelar": {
"codeId": 17,
"address": "axelar1ph8qufmsh556e40uk0ceaufc06nwhnw0ksgdqqk6ldszxchh8llq8x52dk"
},
"codeId": 17,
"address": "axelar1ph8qufmsh556e40uk0ceaufc06nwhnw0ksgdqqk6ldszxchh8llq8x52dk",
"lastUploadedCodeId": 17
},
Expand All @@ -1864,10 +1861,6 @@
"nexus": "axelar17h8uk4ct0mdv9mgkuxszt4gp2htpfr08mge20r",
"address": "axelar1s9amtxejrdlsunwdf0cclhjtezdp6wmurxxnh45gfvtpa2jrsusqv934n6",
"codeId": 20,
"axelar": {
"codeId": 20,
"address": "axelar1s9amtxejrdlsunwdf0cclhjtezdp6wmurxxnh45gfvtpa2jrsusqv934n6"
},
"lastUploadedCodeId": 20
}
},
Expand Down
28 changes: 27 additions & 1 deletion cosmwasm/cli-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('dotenv').config();

const { isNumber, addEnvOption } = require('../common');
const { governanceAddress } = require('./utils');
const { CONTRACT_SCOPE_CHAIN, CONTRACT_SCOPE_GLOBAL, CONTRACTS, governanceAddress } = require('./utils');

const { Option, InvalidArgumentError } = require('commander');

Expand Down Expand Up @@ -83,6 +83,32 @@ const addAmplifierOptions = (program, options) => {
const addContractOptions = (program) => {
program.addOption(new Option('-c, --contractName <contractName>', 'contract name').makeOptionMandatory(true));
program.addOption(new Option('-n, --chainName <chainName>', 'chain name').env('CHAIN').argParser((value) => value.toLowerCase()));
program.hook('preAction', (command) => {
const chainName = command.opts().chainName;
const contractName = command.opts().contractName;

if (!CONTRACTS[contractName]) {
throw new Error(`contract ${contractName} is not supported`);
}

if (!CONTRACTS[contractName].makeInstantiateMsg) {
throw new Error(`makeInstantiateMsg function for contract ${contractName} is not defined`);
}

const scope = CONTRACTS[contractName].scope;

if (!scope) {
throw new Error(`scope of contract ${contractName} is not defined`);
}

if (scope === CONTRACT_SCOPE_CHAIN && !chainName) {
throw new Error(`${contractName} requires chainName option`);
}

if (scope === CONTRACT_SCOPE_GLOBAL && chainName) {
throw new Error(`${contractName} does not support chainName option`);
}
});
};

const addStoreOptions = (program) => {
Expand Down
4 changes: 2 additions & 2 deletions cosmwasm/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { instantiate2Address } = require('@cosmjs/cosmwasm-stargate');

const { printInfo, loadConfig, saveConfig, prompt } = require('../common');
const {
CONTRACTS,
prepareWallet,
prepareClient,
fromHex,
Expand All @@ -16,7 +17,6 @@ const {
updateCodeId,
uploadContract,
instantiateContract,
makeInstantiateMsg,
} = require('./utils');

const { Command, Option } = require('commander');
Expand Down Expand Up @@ -66,7 +66,7 @@ const instantiate = async (client, wallet, config, options) => {

await updateCodeId(client, config, options);

const initMsg = makeInstantiateMsg(contractName, chainName, config);
const initMsg = CONTRACTS[contractName].makeInstantiateMsg(config, options, contractConfig);
const contractAddress = await instantiateContract(client, wallet, initMsg, config, options);

contractConfig.address = contractAddress;
Expand Down
10 changes: 5 additions & 5 deletions cosmwasm/submit-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { createHash } = require('crypto');
const { instantiate2Address } = require('@cosmjs/cosmwasm-stargate');

const {
CONTRACTS,
prepareWallet,
prepareClient,
fromHex,
Expand All @@ -26,7 +27,6 @@ const {
encodeParameterChangeProposal,
encodeMigrateContractProposal,
submitProposal,
makeInstantiateMsg,
} = require('./utils');
const { saveConfig, loadConfig, printInfo, prompt, getChainConfig, getItsEdgeContract } = require('../common');
const {
Expand Down Expand Up @@ -94,14 +94,14 @@ const storeCode = async (client, wallet, config, options) => {
};

const storeInstantiate = async (client, wallet, config, options) => {
const { contractName, instantiate2, chainName } = options;
const { contractName, instantiate2 } = options;
const { contractConfig, contractBaseConfig } = getAmplifierContractConfig(config, options);

if (instantiate2) {
throw new Error('instantiate2 not supported for storeInstantiate');
}

const initMsg = makeInstantiateMsg(contractName, chainName, config);
const initMsg = CONTRACTS[contractName].makeInstantiateMsg(config, options, contractConfig);
const proposal = encodeStoreInstantiateProposal(config, options, initMsg);

if (!confirmProposalSubmission(options, proposal, StoreAndInstantiateContractProposal)) {
Expand All @@ -115,7 +115,7 @@ const storeInstantiate = async (client, wallet, config, options) => {
};

const instantiate = async (client, wallet, config, options) => {
const { contractName, instantiate2, predictOnly, chainName } = options;
const { contractName, instantiate2, predictOnly } = options;
const { contractConfig } = getAmplifierContractConfig(config, options);

await updateCodeId(client, config, options);
Expand All @@ -129,7 +129,7 @@ const instantiate = async (client, wallet, config, options) => {
return;
}

const initMsg = makeInstantiateMsg(contractName, chainName, config);
const initMsg = CONTRACTS[contractName].makeInstantiateMsg(config, options, contractConfig);

let proposal;
let proposalType;
Expand Down
Loading

0 comments on commit ae40c09

Please sign in to comment.