From 5630330c09d9665d82d00abe8c373c4cbff36fe6 Mon Sep 17 00:00:00 2001 From: willclarktech Date: Tue, 18 Aug 2020 17:46:50 +0100 Subject: [PATCH] cli: Update cli for CosmWasmFeeTable change --- packages/cli/examples/helpers.ts | 20 ++++++++++---------- packages/cli/src/cli.ts | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/cli/examples/helpers.ts b/packages/cli/examples/helpers.ts index 7001abb3..b3898317 100644 --- a/packages/cli/examples/helpers.ts +++ b/packages/cli/examples/helpers.ts @@ -16,8 +16,8 @@ const defaultOptions: Options = { const defaultFaucetUrl = "https://faucet.demo-10.cosmwasm.com/credit"; -const buildFeeTable = (feeToken: string, gasPrice: number): FeeTable => { - const stdFee = (gas: number, denom: string, price: number) => { +const buildFeeTable = (feeToken: string, gasPrice: number): CosmWasmFeeTable => { + const calculateFee = (gas: number, denom: string, price: number) => { const amount = Math.floor(gas * price); return { amount: [{ amount: amount.toString(), denom: denom }], @@ -26,12 +26,12 @@ const buildFeeTable = (feeToken: string, gasPrice: number): FeeTable => { }; return { - upload: stdFee(1000000, feeToken, gasPrice), - init: stdFee(500000, feeToken, gasPrice), - migrate: stdFee(500000, feeToken, gasPrice), - exec: stdFee(200000, feeToken, gasPrice), - send: stdFee(80000, feeToken, gasPrice), - changeAdmin: stdFee(80000, feeToken, gasPrice), + upload: calculateFee(1000000, feeToken, gasPrice), + init: calculateFee(500000, feeToken, gasPrice), + migrate: calculateFee(500000, feeToken, gasPrice), + exec: calculateFee(200000, feeToken, gasPrice), + send: calculateFee(80000, feeToken, gasPrice), + changeAdmin: calculateFee(80000, feeToken, gasPrice), }; }; @@ -51,11 +51,11 @@ const connect = async ( address: string; }> => { const options: Options = { ...defaultOptions, ...opts }; - const feeTable = buildFeeTable(options.feeToken, options.gasPrice); + const gasPrice = GasPrice.fromString(`${options.gasPrice}${options.feeToken}`); const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic); const [{ address }] = await wallet.getAccounts(); - const client = new SigningCosmWasmClient(options.httpUrl, address, wallet, feeTable); + const client = new SigningCosmWasmClient(options.httpUrl, address, wallet, gasPrice); return { client, address }; }; diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index bf937150..f72023af 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -57,7 +57,7 @@ export async function main(originalArgs: readonly string[]): Promise { "SearchTxFilter", // signingcosmwasmclient "ExecuteResult", - "FeeTable", + "CosmWasmFeeTable", "InstantiateResult", "SigningCosmWasmClient", "UploadMeta", @@ -102,6 +102,7 @@ export async function main(originalArgs: readonly string[]): Promise { "BroadcastTxResult", "Coin", "CosmosClient", + "GasPrice", "Msg", "MsgDelegate", "MsgSend",