Skip to content

Commit

Permalink
Merge branch 'main' into chore/stagenet-ds
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth authored Aug 15, 2024
2 parents 31dd7cf + ecc8244 commit e94f9f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions cosmwasm/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const programHandler = () => {
),
);
program.addOption(new Option('--instantiate2', 'use instantiate2 for constant address deployment'));
program.addOption(new Option('-l, --label <label>', 'contract instance label'));
program.addOption(new Option('--aarch64', 'aarch64').env('AARCH64').default(false));
program.addOption(new Option('-y, --yes', 'skip deployment prompt confirmation').env('YES'));

Expand Down
2 changes: 2 additions & 0 deletions cosmwasm/submit-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ const programHandler = () => {

program.name('submit-proposal').description('Submit governance proposals');

// 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-verifiers', 'stagenet', 'testnet', 'mainnet'])
Expand All @@ -267,6 +268,7 @@ const programHandler = () => {
),
);
program.addOption(new Option('--instantiate2', 'use instantiate2 for constant address deployment'));
program.addOption(new Option('-l, --label <label>', 'contract instance label'));
program.addOption(new Option('--aarch64', 'aarch64').env('AARCH64').default(false));
program.addOption(new Option('-y, --yes', 'skip prompt confirmation').env('YES'));

Expand Down
18 changes: 12 additions & 6 deletions cosmwasm/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const calculateDomainSeparator = (chain, router, network) => keccak256(Buffer.fr

const getSalt = (salt, contractName, chainNames) => fromHex(getSaltFromKey(salt || contractName.concat(chainNames)));

const getLabel = ({ contractName, label }) => label || contractName;

const readWasmFile = ({ artifactPath, contractName, aarch64 }) =>
readFileSync(`${artifactPath}/${pascalToSnake(contractName)}${aarch64 ? '-aarch64' : ''}.wasm`);

Expand Down Expand Up @@ -94,7 +96,9 @@ const uploadContract = async (client, wallet, config, options) => {
});
};

const instantiateContract = (client, wallet, initMsg, config, { contractName, salt, instantiate2, chainNames, admin }) => {
const instantiateContract = (client, wallet, initMsg, config, options) => {
const { contractName, salt, instantiate2, chainNames, admin } = options;

return wallet
.getAccounts()
.then(([account]) => {
Expand All @@ -105,17 +109,19 @@ const instantiateContract = (client, wallet, initMsg, config, { contractName, sa
} = config;
const initFee = gasLimit === 'auto' ? 'auto' : calculateFee(gasLimit, GasPrice.fromString(gasPrice));

const contractLabel = getLabel(options);

return instantiate2
? client.instantiate2(
account.address,
contractConfig.codeId,
getSalt(salt, contractName, chainNames),
initMsg,
contractName,
contractLabel,
initFee,
{ admin },
)
: client.instantiate(account.address, contractConfig.codeId, initMsg, contractName, initFee, {
: client.instantiate(account.address, contractConfig.codeId, initMsg, contractLabel, initFee, {
admin,
});
})
Expand Down Expand Up @@ -573,12 +579,12 @@ const getStoreCodeParams = (options) => {
};

const getStoreInstantiateParams = (config, options, msg) => {
const { contractName, admin } = options;
const { admin } = options;

return {
...getStoreCodeParams(options),
admin,
label: contractName,
label: getLabel(options),
msg: Buffer.from(JSON.stringify(msg)),
};
};
Expand All @@ -592,7 +598,7 @@ const getInstantiateContractParams = (config, options, msg) => {
...getSubmitProposalParams(options),
admin,
codeId: contractConfig.codeId,
label: contractName,
label: getLabel(options),
msg: Buffer.from(JSON.stringify(msg)),
};
};
Expand Down

0 comments on commit e94f9f8

Please sign in to comment.