diff --git a/packages/sdk/src/cosmwasmclient.spec.ts b/packages/sdk/src/cosmwasmclient.spec.ts index 4742790f..32f9ea5e 100644 --- a/packages/sdk/src/cosmwasmclient.spec.ts +++ b/packages/sdk/src/cosmwasmclient.spec.ts @@ -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, diff --git a/packages/sdk/src/cosmwasmclient.ts b/packages/sdk/src/cosmwasmclient.ts index b7dd7c0f..b74be3f0 100644 --- a/packages/sdk/src/cosmwasmclient.ts +++ b/packages/sdk/src/cosmwasmclient.ts @@ -334,7 +334,7 @@ export class CosmWasmClient { recipientAddress: string, transferAmount: readonly Coin[], memo = "", - ): Promise { + ): Promise { 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)); } /** diff --git a/packages/sdk/types/cosmwasmclient.d.ts b/packages/sdk/types/cosmwasmclient.d.ts index f3fba702..43a72f4b 100644 --- a/packages/sdk/types/cosmwasmclient.d.ts +++ b/packages/sdk/types/cosmwasmclient.d.ts @@ -83,7 +83,7 @@ export declare class CosmWasmClient { memo?: string, transferAmount?: readonly Coin[], ): Promise; - sendToken(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise; + sendToken(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise; /** * Returns the data at the key if present (raw contract dependent storage data) * or null if no data at this key.