From c20a77a5ac17718acc5add374b7cb0dd7dcb906a Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 19 Jun 2020 14:12:08 +0200 Subject: [PATCH] Use coins helper to create amounts --- .../src/cosmwasmclient.searchtx.spec.ts | 23 ++++--------------- .../sdk38/src/cosmosclient.searchtx.spec.ts | 23 ++++--------------- 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts b/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts index 19d9d102..13b44308 100644 --- a/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts +++ b/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/camelcase */ -import { Coin, CosmosSdkTx, isMsgSend, makeSignBytes, MsgSend, Secp256k1Pen } from "@cosmjs/sdk38"; +import { Coin, coins, CosmosSdkTx, isMsgSend, makeSignBytes, MsgSend, Secp256k1Pen } from "@cosmjs/sdk38"; import { assert, sleep } from "@cosmjs/utils"; import { CosmWasmClient, isPostTxFailure } from "./cosmwasmclient"; @@ -47,11 +47,8 @@ describe("CosmWasmClient.searchTx", () => { { const recipient = makeRandomAddress(); - const transferAmount: Coin = { - denom: "ucosm", - amount: "1234567", - }; - const result = await client.sendTokens(recipient, [transferAmount]); + const transferAmount = coins(1234567, "ucosm"); + const result = await client.sendTokens(recipient, transferAmount); await sleep(75); // wait until tx is indexed const txDetails = await new RestClient(wasmd.endpoint).txById(result.transactionHash); sendSuccessful = { @@ -84,12 +81,7 @@ describe("CosmWasmClient.searchTx", () => { { const memo = "Sending more than I can afford"; const recipient = makeRandomAddress(); - const transferAmount = [ - { - denom: "ucosm", - amount: "123456700000000", - }, - ]; + const transferAmount = coins(123456700000000, "ucosm"); const sendMsg: MsgSend = { type: "cosmos-sdk/MsgSend", value: { @@ -101,12 +93,7 @@ describe("CosmWasmClient.searchTx", () => { }, }; const fee = { - amount: [ - { - denom: "ucosm", - amount: "2000", - }, - ], + amount: coins(2000, "ucosm"), gas: "80000", // 80k }; const { accountNumber, sequence } = await client.getNonce(); diff --git a/packages/sdk38/src/cosmosclient.searchtx.spec.ts b/packages/sdk38/src/cosmosclient.searchtx.spec.ts index cc55d221..38a9a77d 100644 --- a/packages/sdk38/src/cosmosclient.searchtx.spec.ts +++ b/packages/sdk38/src/cosmosclient.searchtx.spec.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/camelcase */ import { assert, sleep } from "@cosmjs/utils"; -import { Coin } from "./coins"; +import { coins } from "./coins"; import { CosmosClient, isPostTxFailure } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; import { Secp256k1Pen } from "./pen"; @@ -39,12 +39,7 @@ describe("CosmosClient.searchTx", () => { { const memo = "Sending more than I can afford"; const recipient = makeRandomAddress(); - const transferAmount = [ - { - denom: "ucosm", - amount: "123456700000000", - }, - ]; + const transferAmount = coins(123456700000000, "ucosm"); const sendMsg: MsgSend = { type: "cosmos-sdk/MsgSend", value: { @@ -56,12 +51,7 @@ describe("CosmosClient.searchTx", () => { }, }; const fee = { - amount: [ - { - denom: "ucosm", - amount: "2000", - }, - ], + amount: coins(2000, "ucosm"), gas: "80000", // 80k }; const { accountNumber, sequence } = await client.getNonce(); @@ -92,11 +82,8 @@ describe("CosmosClient.searchTx", () => { { const recipient = makeRandomAddress(); - const transferAmount: Coin = { - denom: "ucosm", - amount: "1234567", - }; - const result = await client.sendTokens(recipient, [transferAmount]); + const transferAmount = coins(1234567, "ucosm"); + const result = await client.sendTokens(recipient, transferAmount); await sleep(75); // wait until tx is indexed const txDetails = await new RestClient(wasmd.endpoint).txById(result.transactionHash); sendSuccessful = {