From 4e1faff25e519519e32cf0416f2496abfae55768 Mon Sep 17 00:00:00 2001 From: Edwin Guajardo Date: Thu, 15 Aug 2024 13:56:53 -0600 Subject: [PATCH 1/4] move common options to utils --- common/cli-utils.js | 19 +++++++++++++---- cosmwasm/cli-utils.js | 41 +++++++++++++++++++++++++++++++++++++ cosmwasm/deploy-contract.js | 27 +++--------------------- cosmwasm/submit-proposal.js | 28 ++----------------------- 4 files changed, 61 insertions(+), 54 deletions(-) create mode 100644 cosmwasm/cli-utils.js diff --git a/common/cli-utils.js b/common/cli-utils.js index 88fbc4a9..1bcb7173 100644 --- a/common/cli-utils.js +++ b/common/cli-utils.js @@ -13,9 +13,18 @@ const addBaseOptions = (program, options = {}) => { .env('ENV'), ); program.addOption(new Option('-y, --yes', 'skip deployment prompt confirmation').env('YES')); - program.addOption(new Option('--parallel', 'run script parallely wrt chains')); - program.addOption(new Option('--saveChainSeparately', 'save chain info separately')); - program.addOption(new Option('--gasOptions ', 'gas options cli override')); + + if (!options.ignoreParallel) { + program.addOption(new Option('--parallel', 'run script parallely wrt chains')); + } + + if (!options.ignoreSaveChainSeparately) { + program.addOption(new Option('--saveChainSeparately', 'save chain info separately')); + } + + if (!options.ignoreGasOptions) { + program.addOption(new Option('--gasOptions ', 'gas options cli override')); + } if (!options.ignoreChainNames) { program.addOption( @@ -44,7 +53,9 @@ const addBaseOptions = (program, options = {}) => { const addExtendedOptions = (program, options = {}) => { addBaseOptions(program, options); - program.addOption(new Option('-v, --verify', 'verify the deployed contract on the explorer').env('VERIFY')); + if (!options.ignoreVerify) { + program.addOption(new Option('-v, --verify', 'verify the deployed contract on the explorer').env('VERIFY')); + } if (options.artifactPath) { program.addOption(new Option('--artifactPath ', 'artifact path')); diff --git a/cosmwasm/cli-utils.js b/cosmwasm/cli-utils.js new file mode 100644 index 00000000..e3a7bc61 --- /dev/null +++ b/cosmwasm/cli-utils.js @@ -0,0 +1,41 @@ +'use strict'; + +require('dotenv').config(); + +const { addExtendedOptions } = require('../common'); +const { governanceAddress } = require('./utils'); + +const { Option } = require('commander'); + +const addCommonAmplifierOptions = (program, options = {}) => { + const ops = { + ignoreParallel: true, + ignoreSaveChainSeparately: true, + ignoreGasOptions: true, + ignoreChainNames: true, + ignorePrivateKey: true, + ignoreVerify: true, + contractName: true, + salt: true, + ...options, + }; + + addExtendedOptions(program, ops); + + program.addOption(new Option('-m, --mnemonic ', 'mnemonic').makeOptionMandatory(true).env('MNEMONIC')); + program.addOption(new Option('-a, --artifactPath ', 'artifact path').makeOptionMandatory(true).env('ARTIFACT_PATH')); + program.addOption(new Option('--aarch64', 'aarch64').env('AARCH64').default(false)); + program.addOption(new Option('-n, --chainNames ', 'chain names').default('none')); + program.addOption( + new Option('--admin
', 'when instantiating contract, set an admin address. Defaults to governance module account').default( + governanceAddress, + ), + ); + program.addOption(new Option('--instantiate2', 'use instantiate2 for constant address deployment')); + program.addOption(new Option('--fetchCodeId', 'fetch code id from the chain by comparing to the uploaded code hash')); + program.addOption(new Option('-l, --label