diff --git a/packages/cosmwasm/src/cw1cosmwasmclient.spec.ts b/packages/cosmwasm/src/cw1cosmwasmclient.spec.ts index c3824ffd..471b0e64 100644 --- a/packages/cosmwasm/src/cw1cosmwasmclient.spec.ts +++ b/packages/cosmwasm/src/cw1cosmwasmclient.spec.ts @@ -46,7 +46,7 @@ describe("Cw1CosmWasmClient", () => { ); const result = await client.canSend(defaultMsg); - expect(result).toEqual({ can_send: true }); + expect(result).toEqual(true); }); it("returns false if client signer cannot send", async () => { @@ -62,7 +62,7 @@ describe("Cw1CosmWasmClient", () => { ); const result = await client.canSend(defaultMsg); - expect(result).toEqual({ can_send: false }); + expect(result).toEqual(false); }); it("returns true if supplied signer can send", async () => { @@ -78,7 +78,7 @@ describe("Cw1CosmWasmClient", () => { ); const result = await client.canSend(defaultMsg, alice.address0); - expect(result).toEqual({ can_send: true }); + expect(result).toEqual(true); }); it("returns false if supplied signer cannot send", async () => { @@ -94,7 +94,7 @@ describe("Cw1CosmWasmClient", () => { ); const result = await client.canSend(defaultMsg, alice.address1); - expect(result).toEqual({ can_send: false }); + expect(result).toEqual(false); }); }); @@ -114,26 +114,5 @@ describe("Cw1CosmWasmClient", () => { expect(result.transactionHash).toBeTruthy(); }); - - it("works with a transfer", async () => { - pendingWithoutLaunchpad(); - pendingWithoutCw1(); - - const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic); - const client = new Cw1CosmWasmClient( - launchpad.endpoint, - alice.address0, - wallet, - deployedCw1.instances[0], - ); - const balanceBefore = parseInt((await client.getAccount())!.balance[0].amount, 10); - const memo = "This time with coins"; - const transferAmount = coins(1000, "ucosm"); - const result = await client.executeSubkey([defaultMsg], memo, transferAmount); - const balanceAfter = parseInt((await client.getAccount())!.balance[0].amount, 10); - - expect(result.transactionHash).toBeTruthy(); - expect(balanceAfter).toEqual(balanceBefore + 999); - }); }); }); diff --git a/packages/cosmwasm/src/cw1cosmwasmclient.ts b/packages/cosmwasm/src/cw1cosmwasmclient.ts index 7d187133..a9c2bf54 100644 --- a/packages/cosmwasm/src/cw1cosmwasmclient.ts +++ b/packages/cosmwasm/src/cw1cosmwasmclient.ts @@ -1,13 +1,9 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { Account, BroadcastMode, Coin, GasLimits, GasPrice, OfflineSigner } from "@cosmjs/launchpad"; +import { Account, BroadcastMode, GasLimits, GasPrice, OfflineSigner } from "@cosmjs/launchpad"; import { CosmosMsg } from "./cosmosmsg"; import { CosmWasmFeeTable, ExecuteResult, SigningCosmWasmClient } from "./signingcosmwasmclient"; -export interface CanSendResult { - readonly can_send: boolean; -} - export class Cw1CosmWasmClient extends SigningCosmWasmClient { public readonly cw1ContractAddress: string; @@ -24,29 +20,26 @@ export class Cw1CosmWasmClient extends SigningCosmWasmClient { this.cw1ContractAddress = cw1ContractAddress; } - public getAccount(address?: string): Promise { + public async getAccount(address?: string): Promise { return super.getAccount(address || this.cw1ContractAddress); } - public canSend(msg: CosmosMsg, address = this.senderAddress): Promise { - return this.queryContractSmart(this.cw1ContractAddress, { + public async canSend(msg: CosmosMsg, address = this.senderAddress): Promise { + const result = await this.queryContractSmart(this.cw1ContractAddress, { can_send: { sender: address, msg: msg, }, }); + return result.can_send; } - public executeSubkey( - msgs: readonly CosmosMsg[], - memo = "", - transferAmount: readonly Coin[] = [], - ): Promise { + public async executeSubkey(msgs: readonly CosmosMsg[], memo = ""): Promise { const handleMsg = { execute: { msgs: msgs, }, }; - return this.execute(this.cw1ContractAddress, handleMsg, memo, transferAmount); + return this.execute(this.cw1ContractAddress, handleMsg, memo); } } diff --git a/packages/cosmwasm/types/cw1cosmwasmclient.d.ts b/packages/cosmwasm/types/cw1cosmwasmclient.d.ts index e5f36606..e75e20cc 100644 --- a/packages/cosmwasm/types/cw1cosmwasmclient.d.ts +++ b/packages/cosmwasm/types/cw1cosmwasmclient.d.ts @@ -1,9 +1,6 @@ -import { Account, BroadcastMode, Coin, GasLimits, GasPrice, OfflineSigner } from "@cosmjs/launchpad"; +import { Account, BroadcastMode, GasLimits, GasPrice, OfflineSigner } from "@cosmjs/launchpad"; import { CosmosMsg } from "./cosmosmsg"; import { CosmWasmFeeTable, ExecuteResult, SigningCosmWasmClient } from "./signingcosmwasmclient"; -export interface CanSendResult { - readonly can_send: boolean; -} export declare class Cw1CosmWasmClient extends SigningCosmWasmClient { readonly cw1ContractAddress: string; constructor( @@ -16,10 +13,6 @@ export declare class Cw1CosmWasmClient extends SigningCosmWasmClient { broadcastMode?: BroadcastMode, ); getAccount(address?: string): Promise; - canSend(msg: CosmosMsg, address?: string): Promise; - executeSubkey( - msgs: readonly CosmosMsg[], - memo?: string, - transferAmount?: readonly Coin[], - ): Promise; + canSend(msg: CosmosMsg, address?: string): Promise; + executeSubkey(msgs: readonly CosmosMsg[], memo?: string): Promise; }