Skip to content

Commit

Permalink
cli: Update cli for CosmWasmFeeTable change
Browse files Browse the repository at this point in the history
  • Loading branch information
willclarktech committed Aug 19, 2020
1 parent 9abaa6e commit 8089c16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
20 changes: 10 additions & 10 deletions packages/cli/examples/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }],
Expand All @@ -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),
};
};

Expand All @@ -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 };
};

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function main(originalArgs: readonly string[]): Promise<void> {
"SearchTxFilter",
// signingcosmwasmclient
"ExecuteResult",
"FeeTable",
"CosmWasmFeeTable",
"InstantiateResult",
"SigningCosmWasmClient",
"UploadMeta",
Expand Down Expand Up @@ -102,6 +102,7 @@ export async function main(originalArgs: readonly string[]): Promise<void> {
"BroadcastTxResult",
"Coin",
"CosmosClient",
"GasPrice",
"Msg",
"MsgDelegate",
"MsgSend",
Expand Down

0 comments on commit 8089c16

Please sign in to comment.