From bd2494c0747cd8f5fb555e317ae89a79175da6ff Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 5 May 2021 18:39:29 +0200 Subject: [PATCH 1/2] Fix fee table type in SigningCosmWasmClientOptions --- CHANGELOG.md | 5 +++++ packages/cosmwasm-stargate/src/index.ts | 1 + packages/cosmwasm-stargate/src/signingcosmwasmclient.ts | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d2442f6..206c706b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to ## [Unreleased] +### Fixed + +- @cosmjs/cosmwasm-stargate: Use `CosmWasmFeeTable` instead of `CosmosFeeTable` + in `SigningCosmWasmClientOptions`; export type `CosmWasmFeeTable`. + ## [0.25.0] - 2021-05-05 ### Added diff --git a/packages/cosmwasm-stargate/src/index.ts b/packages/cosmwasm-stargate/src/index.ts index ae8a2d24..3e60a6ba 100644 --- a/packages/cosmwasm-stargate/src/index.ts +++ b/packages/cosmwasm-stargate/src/index.ts @@ -16,6 +16,7 @@ export { } from "./encodeobjects"; export { defaultGasLimits, + CosmWasmFeeTable, // part of SigningCosmWasmClientOptions SigningCosmWasmClient, SigningCosmWasmClientOptions, } from "./signingcosmwasmclient"; diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts index c62f7da4..b42f9295 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts @@ -123,7 +123,7 @@ export interface SigningCosmWasmClientOptions { readonly aminoTypes?: AminoTypes; readonly prefix?: string; readonly gasPrice?: GasPrice; - readonly gasLimits?: Partial>; + readonly gasLimits?: Partial>; } /** Use for testing only */ @@ -133,7 +133,7 @@ export interface PrivateSigningCosmWasmClient { } export class SigningCosmWasmClient extends CosmWasmClient { - public readonly fees: CosmosFeeTable; + public readonly fees: CosmWasmFeeTable; public readonly registry: Registry; private readonly signer: OfflineSigner; @@ -176,7 +176,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { gasPrice = defaultGasPrice, gasLimits = {}, } = options; - this.fees = buildFeeTable(gasPrice, defaultGasLimits, gasLimits); + this.fees = buildFeeTable(gasPrice, defaultGasLimits, gasLimits); this.registry = registry; this.aminoTypes = aminoTypes; this.signer = signer; From 3eb243d5d68421cb2213be29b49a084b1a063160 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 5 May 2021 18:43:18 +0200 Subject: [PATCH 2/2] Remove Private* because fields are public --- .../src/signingcosmwasmclient.spec.ts | 11 ++++------- .../src/signingcosmwasmclient.ts | 5 ----- .../src/signingcosmwasmclient.spec.ts | 14 +++++--------- .../cosmwasm-stargate/src/signingcosmwasmclient.ts | 6 ------ 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/packages/cosmwasm-launchpad/src/signingcosmwasmclient.spec.ts b/packages/cosmwasm-launchpad/src/signingcosmwasmclient.spec.ts index 48978cb8..d6694533 100644 --- a/packages/cosmwasm-launchpad/src/signingcosmwasmclient.spec.ts +++ b/packages/cosmwasm-launchpad/src/signingcosmwasmclient.spec.ts @@ -16,7 +16,7 @@ import { assert } from "@cosmjs/utils"; import { PrivateCosmWasmClient } from "./cosmwasmclient"; import { setupWasmExtension, WasmExtension } from "./lcdapi/wasm"; -import { PrivateSigningCosmWasmClient, SigningCosmWasmClient, UploadMeta } from "./signingcosmwasmclient"; +import { SigningCosmWasmClient, UploadMeta } from "./signingcosmwasmclient"; import { alice, getHackatom, @@ -42,8 +42,7 @@ describe("SigningCosmWasmClient", () => { const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic); const gasPrice = GasPrice.fromString("3.14utest"); const client = new SigningCosmWasmClient(launchpad.endpoint, alice.address0, wallet, gasPrice); - const openedClient = (client as unknown) as PrivateSigningCosmWasmClient; - expect(openedClient.fees).toEqual({ + expect(client.fees).toEqual({ upload: { amount: [ { @@ -113,8 +112,7 @@ describe("SigningCosmWasmClient", () => { undefined, gasLimits, ); - const openedClient = (client as unknown) as PrivateSigningCosmWasmClient; - expect(openedClient.fees).toEqual({ + expect(client.fees).toEqual({ upload: { amount: [ { @@ -185,8 +183,7 @@ describe("SigningCosmWasmClient", () => { gasPrice, gasLimits, ); - const openedClient = (client as unknown) as PrivateSigningCosmWasmClient; - expect(openedClient.fees).toEqual({ + expect(client.fees).toEqual({ upload: { amount: [ { diff --git a/packages/cosmwasm-launchpad/src/signingcosmwasmclient.ts b/packages/cosmwasm-launchpad/src/signingcosmwasmclient.ts index 3235096c..693df2a6 100644 --- a/packages/cosmwasm-launchpad/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-launchpad/src/signingcosmwasmclient.ts @@ -143,11 +143,6 @@ function createBroadcastTxErrorMessage(result: BroadcastTxFailure): string { return `Error when broadcasting tx ${result.transactionHash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.rawLog}`; } -/** Use for testing only */ -export interface PrivateSigningCosmWasmClient { - readonly fees: CosmWasmFeeTable; -} - export class SigningCosmWasmClient extends CosmWasmClient { public readonly fees: CosmWasmFeeTable; public readonly signerAddress: string; diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts index eb233981..8d2d13cf 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts @@ -25,7 +25,7 @@ import protobuf from "protobufjs/minimal"; import { MsgStoreCode } from "./codec/cosmwasm/wasm/v1beta1/tx"; import { MsgStoreCodeEncodeObject } from "./encodeobjects"; -import { PrivateSigningCosmWasmClient, SigningCosmWasmClient } from "./signingcosmwasmclient"; +import { SigningCosmWasmClient } from "./signingcosmwasmclient"; import { alice, getHackatom, @@ -56,8 +56,7 @@ describe("SigningCosmWasmClient", () => { registry.register("/custom.MsgCustom", MsgSend); const options = { prefix: wasmd.prefix, registry: registry }; const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options); - const openedClient = (client as unknown) as PrivateSigningCosmWasmClient; - expect(openedClient.registry.lookupType("/custom.MsgCustom")).toEqual(MsgSend); + expect(client.registry.lookupType("/custom.MsgCustom")).toEqual(MsgSend); }); it("can be constructed with custom gas price", async () => { @@ -68,8 +67,7 @@ describe("SigningCosmWasmClient", () => { gasPrice: GasPrice.fromString("3.14utest"), }; const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options); - const openedClient = (client as unknown) as PrivateSigningCosmWasmClient; - expect(openedClient.fees).toEqual({ + expect(client.fees).toEqual({ upload: { amount: coins(4710000, "utest"), gas: "1500000", @@ -123,8 +121,7 @@ describe("SigningCosmWasmClient", () => { }, }; const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options); - const openedClient = (client as unknown) as PrivateSigningCosmWasmClient; - expect(openedClient.fees).toEqual({ + expect(client.fees).toEqual({ upload: { amount: coins(37500, "ucosm"), gas: "1500000", @@ -179,8 +176,7 @@ describe("SigningCosmWasmClient", () => { }, }; const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options); - const openedClient = (client as unknown) as PrivateSigningCosmWasmClient; - expect(openedClient.fees).toEqual({ + expect(client.fees).toEqual({ upload: { amount: coins(4710000, "utest"), gas: "1500000", diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts index b42f9295..51319870 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts @@ -126,12 +126,6 @@ export interface SigningCosmWasmClientOptions { readonly gasLimits?: Partial>; } -/** Use for testing only */ -export interface PrivateSigningCosmWasmClient { - readonly fees: CosmWasmFeeTable; - readonly registry: Registry; -} - export class SigningCosmWasmClient extends CosmWasmClient { public readonly fees: CosmWasmFeeTable; public readonly registry: Registry;