mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Clean up test cases
This commit is contained in:
parent
6d3865a27e
commit
2d7c4e09a3
@ -222,50 +222,23 @@ describe("CosmWasmClient", () => {
|
||||
beforeAll(async () => {
|
||||
if (cosmosEnabled()) {
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = CosmWasmClient.makeReadOnly(httpUrl);
|
||||
const client = CosmWasmClient.makeWritable(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
|
||||
|
||||
const memo = "My first contract on chain";
|
||||
const sendMsg: MsgSend = {
|
||||
type: "cosmos-sdk/MsgSend",
|
||||
value: {
|
||||
from_address: faucet.address,
|
||||
to_address: makeRandomAddress(),
|
||||
amount: [
|
||||
{
|
||||
denom: "ucosm",
|
||||
amount: "1234567",
|
||||
},
|
||||
],
|
||||
const recipient = makeRandomAddress();
|
||||
const transferAmount = [
|
||||
{
|
||||
denom: "ucosm",
|
||||
amount: "1234567",
|
||||
},
|
||||
};
|
||||
];
|
||||
const result = await client.sendToken(recipient, transferAmount, memo);
|
||||
|
||||
const fee: StdFee = {
|
||||
amount: [
|
||||
{
|
||||
amount: "5000",
|
||||
denom: "ucosm",
|
||||
},
|
||||
],
|
||||
gas: "890000",
|
||||
};
|
||||
|
||||
const chainId = await client.chainId();
|
||||
const { accountNumber, sequence } = await client.getNonce(faucet.address);
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await pen.sign(signBytes);
|
||||
const signedTx = {
|
||||
msg: [sendMsg],
|
||||
fee: fee,
|
||||
memo: memo,
|
||||
signatures: [signature],
|
||||
};
|
||||
|
||||
const result = await client.postTx(marshalTx(signedTx));
|
||||
await sleep(50); // wait until tx is indexed
|
||||
const txDetails = await new RestClient(httpUrl).txsById(result.transactionHash);
|
||||
posted = {
|
||||
sender: sendMsg.value.from_address,
|
||||
recipient: sendMsg.value.to_address,
|
||||
sender: faucet.address,
|
||||
recipient: recipient,
|
||||
hash: result.transactionHash,
|
||||
height: Number.parseInt(txDetails.height, 10),
|
||||
tx: txDetails.tx,
|
||||
|
@ -334,7 +334,7 @@ export class CosmWasmClient {
|
||||
recipientAddress: string,
|
||||
transferAmount: readonly Coin[],
|
||||
memo = "",
|
||||
): Promise<ExecuteResult> {
|
||||
): Promise<PostTxResult> {
|
||||
const sendMsg: MsgSend = {
|
||||
type: "cosmos-sdk/MsgSend",
|
||||
value: {
|
||||
@ -357,10 +357,7 @@ export class CosmWasmClient {
|
||||
signatures: [signature],
|
||||
};
|
||||
|
||||
const result = await this.postTx(marshalTx(signedTx));
|
||||
return {
|
||||
logs: result.logs,
|
||||
};
|
||||
return this.postTx(marshalTx(signedTx));
|
||||
}
|
||||
|
||||
/**
|
||||
|
2
packages/sdk/types/cosmwasmclient.d.ts
vendored
2
packages/sdk/types/cosmwasmclient.d.ts
vendored
@ -83,7 +83,7 @@ export declare class CosmWasmClient {
|
||||
memo?: string,
|
||||
transferAmount?: readonly Coin[],
|
||||
): Promise<ExecuteResult>;
|
||||
sendToken(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise<ExecuteResult>;
|
||||
sendToken(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise<PostTxResult>;
|
||||
/**
|
||||
* Returns the data at the key if present (raw contract dependent storage data)
|
||||
* or null if no data at this key.
|
||||
|
Loading…
x
Reference in New Issue
Block a user