From 9a1d889742145b3167bd18c36f4796995896e359 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 18 May 2021 14:27:47 +0200 Subject: [PATCH] Rename transferAmount -> amount for MsgSend --- .../src/cosmwasmclient.searchtx.spec.ts | 16 ++++++---------- .../src/signingcosmwasmclient.spec.ts | 6 +++--- .../src/signingcosmwasmclient.ts | 4 ++-- .../src/signingcosmwasmclient.spec.ts | 12 ++++++------ .../src/signingcosmwasmclient.ts | 4 ++-- .../launchpad/src/cosmosclient.searchtx.spec.ts | 8 ++++---- packages/launchpad/src/lcdapi/lcdclient.spec.ts | 12 ++++++------ .../launchpad/src/signingcosmosclient.spec.ts | 13 ++++--------- packages/launchpad/src/signingcosmosclient.ts | 4 ++-- .../stargate/src/signingstargateclient.spec.ts | 12 ++++++------ packages/stargate/src/signingstargateclient.ts | 4 ++-- 11 files changed, 43 insertions(+), 52 deletions(-) diff --git a/packages/cosmwasm-launchpad/src/cosmwasmclient.searchtx.spec.ts b/packages/cosmwasm-launchpad/src/cosmwasmclient.searchtx.spec.ts index 8884630f..99cfac6d 100644 --- a/packages/cosmwasm-launchpad/src/cosmwasmclient.searchtx.spec.ts +++ b/packages/cosmwasm-launchpad/src/cosmwasmclient.searchtx.spec.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { - Coin, coins, isBroadcastTxFailure, isMsgSend, @@ -57,8 +56,8 @@ describe("CosmWasmClient.getTx and .searchTx", () => { { const recipient = makeRandomAddress(); - const transferAmount = coins(1234567, "ucosm"); - const result = await client.sendTokens(recipient, transferAmount); + const amount = coins(1234567, "ucosm"); + const result = await client.sendTokens(recipient, amount); await sleep(75); // wait until tx is indexed const txDetails = await new LcdClient(launchpad.endpoint).txById(result.transactionHash); sendSuccessful = { @@ -72,11 +71,8 @@ describe("CosmWasmClient.getTx and .searchTx", () => { { const recipient = alice.address0; - const transferAmount: Coin = { - denom: "ucosm", - amount: "2345678", - }; - const result = await client.sendTokens(recipient, [transferAmount]); + const amount = coins(2345678, "ucosm"); + const result = await client.sendTokens(recipient, amount); await sleep(75); // wait until tx is indexed const txDetails = await new LcdClient(launchpad.endpoint).txById(result.transactionHash); sendSelfSuccessful = { @@ -91,13 +87,13 @@ describe("CosmWasmClient.getTx and .searchTx", () => { { const memo = "Sending more than I can afford"; const recipient = makeRandomAddress(); - const transferAmount = coins(123456700000000, "ucosm"); + const amount = coins(123456700000000, "ucosm"); const sendMsg: MsgSend = { type: "cosmos-sdk/MsgSend", value: { from_address: alice.address0, to_address: recipient, - amount: transferAmount, + amount: amount, }, }; const fee = { diff --git a/packages/cosmwasm-launchpad/src/signingcosmwasmclient.spec.ts b/packages/cosmwasm-launchpad/src/signingcosmwasmclient.spec.ts index b102a334..2cd5c49a 100644 --- a/packages/cosmwasm-launchpad/src/signingcosmwasmclient.spec.ts +++ b/packages/cosmwasm-launchpad/src/signingcosmwasmclient.spec.ts @@ -525,7 +525,7 @@ describe("SigningCosmWasmClient", () => { const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(launchpad.endpoint, alice.address0, wallet); - const transferAmount = coins(7890, "ucosm"); + const amount = coins(7890, "ucosm"); const beneficiaryAddress = makeRandomAddress(); // no tokens here @@ -533,7 +533,7 @@ describe("SigningCosmWasmClient", () => { expect(before).toBeUndefined(); // send - const result = await client.sendTokens(beneficiaryAddress, transferAmount, "for dinner"); + const result = await client.sendTokens(beneficiaryAddress, amount, "for dinner"); assertIsBroadcastTxSuccess(result); const [firstLog] = result.logs; expect(firstLog).toBeTruthy(); @@ -541,7 +541,7 @@ describe("SigningCosmWasmClient", () => { // got tokens const after = await client.getAccount(beneficiaryAddress); assert(after); - expect(after.balance).toEqual(transferAmount); + expect(after.balance).toEqual(amount); }); }); diff --git a/packages/cosmwasm-launchpad/src/signingcosmwasmclient.ts b/packages/cosmwasm-launchpad/src/signingcosmwasmclient.ts index e872ea1d..35998fcf 100644 --- a/packages/cosmwasm-launchpad/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-launchpad/src/signingcosmwasmclient.ts @@ -343,7 +343,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { public async sendTokens( recipientAddress: string, - transferAmount: readonly Coin[], + amount: readonly Coin[], memo = "", ): Promise { const sendMsg: MsgSend = { @@ -351,7 +351,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { value: { from_address: this.signerAddress, to_address: recipientAddress, - amount: transferAmount, + amount: amount, }, }; return this.signAndBroadcast([sendMsg], this.fees.send, memo); diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts index ec916bc1..ff14f70d 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts @@ -491,7 +491,7 @@ describe("SigningCosmWasmClient", () => { const options = { prefix: wasmd.prefix }; const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options); - const transferAmount = coins(7890, "ucosm"); + const amount = coins(7890, "ucosm"); const beneficiaryAddress = makeRandomAddress(); const memo = "for dinner"; @@ -503,14 +503,14 @@ describe("SigningCosmWasmClient", () => { }); // send - const result = await client.sendTokens(alice.address0, beneficiaryAddress, transferAmount, memo); + const result = await client.sendTokens(alice.address0, beneficiaryAddress, amount, memo); assertIsBroadcastTxSuccess(result); expect(result.rawLog).toBeTruthy(); // got tokens const after = await client.getBalance(beneficiaryAddress, "ucosm"); assert(after); - expect(after).toEqual(transferAmount[0]); + expect(after).toEqual(amount[0]); }); it("works with legacy Amino signer", async () => { @@ -519,7 +519,7 @@ describe("SigningCosmWasmClient", () => { const options = { prefix: wasmd.prefix }; const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options); - const transferAmount = coins(7890, "ucosm"); + const amount = coins(7890, "ucosm"); const beneficiaryAddress = makeRandomAddress(); const memo = "for dinner"; @@ -531,14 +531,14 @@ describe("SigningCosmWasmClient", () => { }); // send - const result = await client.sendTokens(alice.address0, beneficiaryAddress, transferAmount, memo); + const result = await client.sendTokens(alice.address0, beneficiaryAddress, amount, memo); assertIsBroadcastTxSuccess(result); expect(result.rawLog).toBeTruthy(); // got tokens const after = await client.getBalance(beneficiaryAddress, "ucosm"); assert(after); - expect(after).toEqual(transferAmount[0]); + expect(after).toEqual(amount[0]); }); }); diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts index a5161c67..b1894aeb 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts @@ -368,7 +368,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { public async sendTokens( senderAddress: string, recipientAddress: string, - transferAmount: readonly Coin[], + amount: readonly Coin[], memo = "", ): Promise { const sendMsg: MsgSendEncodeObject = { @@ -376,7 +376,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { value: { fromAddress: senderAddress, toAddress: recipientAddress, - amount: [...transferAmount], + amount: [...amount], }, }; return this.signAndBroadcast(senderAddress, [sendMsg], this.fees.send, memo); diff --git a/packages/launchpad/src/cosmosclient.searchtx.spec.ts b/packages/launchpad/src/cosmosclient.searchtx.spec.ts index e3e6c56f..d4e4c197 100644 --- a/packages/launchpad/src/cosmosclient.searchtx.spec.ts +++ b/packages/launchpad/src/cosmosclient.searchtx.spec.ts @@ -38,13 +38,13 @@ describe("CosmosClient.getTx and .searchTx", () => { { const memo = "Sending more than I can afford"; const recipient = makeRandomAddress(); - const transferAmount = coins(123456700000000, "ucosm"); + const amount = coins(123456700000000, "ucosm"); const sendMsg: MsgSend = { type: "cosmos-sdk/MsgSend", value: { from_address: faucet.address0, to_address: recipient, - amount: transferAmount, + amount: amount, }, }; const fee = { @@ -74,8 +74,8 @@ describe("CosmosClient.getTx and .searchTx", () => { { const recipient = makeRandomAddress(); - const transferAmount = coins(1234567, "ucosm"); - const result = await client.sendTokens(recipient, transferAmount); + const amount = coins(1234567, "ucosm"); + const result = await client.sendTokens(recipient, amount); await sleep(75); // wait until tx is indexed const txDetails = await new LcdClient(launchpad.endpoint).txById(result.transactionHash); sendSuccessful = { diff --git a/packages/launchpad/src/lcdapi/lcdclient.spec.ts b/packages/launchpad/src/lcdapi/lcdclient.spec.ts index f9374b92..a06086fe 100644 --- a/packages/launchpad/src/lcdapi/lcdclient.spec.ts +++ b/packages/launchpad/src/lcdapi/lcdclient.spec.ts @@ -195,8 +195,8 @@ describe("LcdClient", () => { { const recipient = makeRandomAddress(); - const transferAmount = coins(1234567, "ucosm"); - const result = await client.sendTokens(recipient, transferAmount); + const amount = coins(1234567, "ucosm"); + const result = await client.sendTokens(recipient, amount); successful = { sender: faucet.address0, recipient: recipient, @@ -207,13 +207,13 @@ describe("LcdClient", () => { { const memo = "Sending more than I can afford"; const recipient = makeRandomAddress(); - const transferAmount = coins(123456700000000, "ucosm"); + const amount = coins(123456700000000, "ucosm"); const sendMsg: MsgSend = { type: "cosmos-sdk/MsgSend", value: { from_address: faucet.address0, to_address: recipient, - amount: transferAmount, + amount: amount, }, }; const fee = { @@ -306,8 +306,8 @@ describe("LcdClient", () => { const client = new SigningCosmosClient(launchpad.endpoint, faucet.address0, wallet); const recipient = makeRandomAddress(); - const transferAmount = coins(1234567, "ucosm"); - const result = await client.sendTokens(recipient, transferAmount); + const amount = coins(1234567, "ucosm"); + const result = await client.sendTokens(recipient, amount); await sleep(75); // wait until tx is indexed const txDetails = await new LcdClient(launchpad.endpoint).txById(result.transactionHash); diff --git a/packages/launchpad/src/signingcosmosclient.spec.ts b/packages/launchpad/src/signingcosmosclient.spec.ts index 81758156..5878700c 100644 --- a/packages/launchpad/src/signingcosmosclient.spec.ts +++ b/packages/launchpad/src/signingcosmosclient.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { Coin, coin, coins, makeCosmoshubPath, Secp256k1HdWallet } from "@cosmjs/amino"; +import { coin, coins, makeCosmoshubPath, Secp256k1HdWallet } from "@cosmjs/amino"; import { assert } from "@cosmjs/utils"; import { assertIsBroadcastTxSuccess, PrivateCosmosClient } from "./cosmosclient"; @@ -129,12 +129,7 @@ describe("SigningCosmosClient", () => { const wallet = await Secp256k1HdWallet.fromMnemonic(faucet.mnemonic); const client = new SigningCosmosClient(launchpad.endpoint, faucet.address0, wallet); - const transferAmount: readonly Coin[] = [ - { - amount: "7890", - denom: "ucosm", - }, - ]; + const amount = coins(7890, "ucosm"); const beneficiaryAddress = makeRandomAddress(); // no tokens here @@ -142,7 +137,7 @@ describe("SigningCosmosClient", () => { expect(before).toBeUndefined(); // send - const result = await client.sendTokens(beneficiaryAddress, transferAmount, "for dinner"); + const result = await client.sendTokens(beneficiaryAddress, amount, "for dinner"); assertIsBroadcastTxSuccess(result); const [firstLog] = result.logs; expect(firstLog).toBeTruthy(); @@ -150,7 +145,7 @@ describe("SigningCosmosClient", () => { // got tokens const after = await client.getAccount(beneficiaryAddress); assert(after); - expect(after.balance).toEqual(transferAmount); + expect(after.balance).toEqual(amount); }); }); diff --git a/packages/launchpad/src/signingcosmosclient.ts b/packages/launchpad/src/signingcosmosclient.ts index f97e7da2..125807ec 100644 --- a/packages/launchpad/src/signingcosmosclient.ts +++ b/packages/launchpad/src/signingcosmosclient.ts @@ -67,7 +67,7 @@ export class SigningCosmosClient extends CosmosClient { public async sendTokens( recipientAddress: string, - transferAmount: readonly Coin[], + amount: readonly Coin[], memo = "", ): Promise { const sendMsg: MsgSend = { @@ -75,7 +75,7 @@ export class SigningCosmosClient extends CosmosClient { value: { from_address: this.signerAddress, to_address: recipientAddress, - amount: transferAmount, + amount: amount, }, }; return this.signAndBroadcast([sendMsg], this.fees.send, memo); diff --git a/packages/stargate/src/signingstargateclient.spec.ts b/packages/stargate/src/signingstargateclient.spec.ts index 79214bd7..f882f8cc 100644 --- a/packages/stargate/src/signingstargateclient.spec.ts +++ b/packages/stargate/src/signingstargateclient.spec.ts @@ -273,7 +273,7 @@ describe("SigningStargateClient", () => { const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic); const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, wallet); - const transferAmount = coins(7890, "ucosm"); + const amount = coins(7890, "ucosm"); const beneficiaryAddress = makeRandomAddress(); const memo = "for dinner"; @@ -285,13 +285,13 @@ describe("SigningStargateClient", () => { }); // send - const result = await client.sendTokens(faucet.address0, beneficiaryAddress, transferAmount, memo); + const result = await client.sendTokens(faucet.address0, beneficiaryAddress, amount, memo); assertIsBroadcastTxSuccess(result); expect(result.rawLog).toBeTruthy(); // got tokens const after = await client.getBalance(beneficiaryAddress, "ucosm"); - expect(after).toEqual(transferAmount[0]); + expect(after).toEqual(amount[0]); }); it("works with legacy Amino signer", async () => { @@ -299,7 +299,7 @@ describe("SigningStargateClient", () => { const wallet = await Secp256k1HdWallet.fromMnemonic(faucet.mnemonic); const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, wallet); - const transferAmount = coins(7890, "ucosm"); + const amount = coins(7890, "ucosm"); const beneficiaryAddress = makeRandomAddress(); const memo = "for dinner"; @@ -311,13 +311,13 @@ describe("SigningStargateClient", () => { }); // send - const result = await client.sendTokens(faucet.address0, beneficiaryAddress, transferAmount, memo); + const result = await client.sendTokens(faucet.address0, beneficiaryAddress, amount, memo); assertIsBroadcastTxSuccess(result); expect(result.rawLog).toBeTruthy(); // got tokens const after = await client.getBalance(beneficiaryAddress, "ucosm"); - expect(after).toEqual(transferAmount[0]); + expect(after).toEqual(amount[0]); }); }); diff --git a/packages/stargate/src/signingstargateclient.ts b/packages/stargate/src/signingstargateclient.ts index 02b80ce6..e2b66329 100644 --- a/packages/stargate/src/signingstargateclient.ts +++ b/packages/stargate/src/signingstargateclient.ts @@ -212,7 +212,7 @@ export class SigningStargateClient extends StargateClient { public async sendTokens( senderAddress: string, recipientAddress: string, - transferAmount: readonly Coin[], + amount: readonly Coin[], memo = "", ): Promise { const sendMsg: MsgSendEncodeObject = { @@ -220,7 +220,7 @@ export class SigningStargateClient extends StargateClient { value: { fromAddress: senderAddress, toAddress: recipientAddress, - amount: [...transferAmount], + amount: [...amount], }, }; return this.signAndBroadcast(senderAddress, [sendMsg], this.fees.send, memo);