mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Rename transferAmount -> amount for MsgSend
This commit is contained in:
parent
00b2cc6b87
commit
9a1d889742
@ -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 = {
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -343,7 +343,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
|
||||
public async sendTokens(
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
amount: readonly Coin[],
|
||||
memo = "",
|
||||
): Promise<BroadcastTxResult> {
|
||||
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);
|
||||
|
@ -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]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -368,7 +368,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
public async sendTokens(
|
||||
senderAddress: string,
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
amount: readonly Coin[],
|
||||
memo = "",
|
||||
): Promise<BroadcastTxResponse> {
|
||||
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);
|
||||
|
@ -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 = {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -67,7 +67,7 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
|
||||
public async sendTokens(
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
amount: readonly Coin[],
|
||||
memo = "",
|
||||
): Promise<BroadcastTxResult> {
|
||||
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);
|
||||
|
@ -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]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -212,7 +212,7 @@ export class SigningStargateClient extends StargateClient {
|
||||
public async sendTokens(
|
||||
senderAddress: string,
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
amount: readonly Coin[],
|
||||
memo = "",
|
||||
): Promise<BroadcastTxResponse> {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user