mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Merge pull request #791 from cosmos/fee-table-fix
Fix fee table type in SigningCosmWasmClientOptions
This commit is contained in:
commit
414874eeda
@ -6,6 +6,11 @@ and this project adheres to
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- @cosmjs/cosmwasm-stargate: Use `CosmWasmFeeTable` instead of `CosmosFeeTable`
|
||||||
|
in `SigningCosmWasmClientOptions`; export type `CosmWasmFeeTable`.
|
||||||
|
|
||||||
## [0.25.0] - 2021-05-05
|
## [0.25.0] - 2021-05-05
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -16,7 +16,7 @@ import { assert } from "@cosmjs/utils";
|
|||||||
|
|
||||||
import { PrivateCosmWasmClient } from "./cosmwasmclient";
|
import { PrivateCosmWasmClient } from "./cosmwasmclient";
|
||||||
import { setupWasmExtension, WasmExtension } from "./lcdapi/wasm";
|
import { setupWasmExtension, WasmExtension } from "./lcdapi/wasm";
|
||||||
import { PrivateSigningCosmWasmClient, SigningCosmWasmClient, UploadMeta } from "./signingcosmwasmclient";
|
import { SigningCosmWasmClient, UploadMeta } from "./signingcosmwasmclient";
|
||||||
import {
|
import {
|
||||||
alice,
|
alice,
|
||||||
getHackatom,
|
getHackatom,
|
||||||
@ -42,8 +42,7 @@ describe("SigningCosmWasmClient", () => {
|
|||||||
const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic);
|
const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic);
|
||||||
const gasPrice = GasPrice.fromString("3.14utest");
|
const gasPrice = GasPrice.fromString("3.14utest");
|
||||||
const client = new SigningCosmWasmClient(launchpad.endpoint, alice.address0, wallet, gasPrice);
|
const client = new SigningCosmWasmClient(launchpad.endpoint, alice.address0, wallet, gasPrice);
|
||||||
const openedClient = (client as unknown) as PrivateSigningCosmWasmClient;
|
expect(client.fees).toEqual({
|
||||||
expect(openedClient.fees).toEqual({
|
|
||||||
upload: {
|
upload: {
|
||||||
amount: [
|
amount: [
|
||||||
{
|
{
|
||||||
@ -113,8 +112,7 @@ describe("SigningCosmWasmClient", () => {
|
|||||||
undefined,
|
undefined,
|
||||||
gasLimits,
|
gasLimits,
|
||||||
);
|
);
|
||||||
const openedClient = (client as unknown) as PrivateSigningCosmWasmClient;
|
expect(client.fees).toEqual({
|
||||||
expect(openedClient.fees).toEqual({
|
|
||||||
upload: {
|
upload: {
|
||||||
amount: [
|
amount: [
|
||||||
{
|
{
|
||||||
@ -185,8 +183,7 @@ describe("SigningCosmWasmClient", () => {
|
|||||||
gasPrice,
|
gasPrice,
|
||||||
gasLimits,
|
gasLimits,
|
||||||
);
|
);
|
||||||
const openedClient = (client as unknown) as PrivateSigningCosmWasmClient;
|
expect(client.fees).toEqual({
|
||||||
expect(openedClient.fees).toEqual({
|
|
||||||
upload: {
|
upload: {
|
||||||
amount: [
|
amount: [
|
||||||
{
|
{
|
||||||
|
@ -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}`;
|
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 {
|
export class SigningCosmWasmClient extends CosmWasmClient {
|
||||||
public readonly fees: CosmWasmFeeTable;
|
public readonly fees: CosmWasmFeeTable;
|
||||||
public readonly signerAddress: string;
|
public readonly signerAddress: string;
|
||||||
|
@ -16,6 +16,7 @@ export {
|
|||||||
} from "./encodeobjects";
|
} from "./encodeobjects";
|
||||||
export {
|
export {
|
||||||
defaultGasLimits,
|
defaultGasLimits,
|
||||||
|
CosmWasmFeeTable, // part of SigningCosmWasmClientOptions
|
||||||
SigningCosmWasmClient,
|
SigningCosmWasmClient,
|
||||||
SigningCosmWasmClientOptions,
|
SigningCosmWasmClientOptions,
|
||||||
} from "./signingcosmwasmclient";
|
} from "./signingcosmwasmclient";
|
||||||
|
@ -25,7 +25,7 @@ import protobuf from "protobufjs/minimal";
|
|||||||
|
|
||||||
import { MsgStoreCode } from "./codec/cosmwasm/wasm/v1beta1/tx";
|
import { MsgStoreCode } from "./codec/cosmwasm/wasm/v1beta1/tx";
|
||||||
import { MsgStoreCodeEncodeObject } from "./encodeobjects";
|
import { MsgStoreCodeEncodeObject } from "./encodeobjects";
|
||||||
import { PrivateSigningCosmWasmClient, SigningCosmWasmClient } from "./signingcosmwasmclient";
|
import { SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||||
import {
|
import {
|
||||||
alice,
|
alice,
|
||||||
getHackatom,
|
getHackatom,
|
||||||
@ -56,8 +56,7 @@ describe("SigningCosmWasmClient", () => {
|
|||||||
registry.register("/custom.MsgCustom", MsgSend);
|
registry.register("/custom.MsgCustom", MsgSend);
|
||||||
const options = { prefix: wasmd.prefix, registry: registry };
|
const options = { prefix: wasmd.prefix, registry: registry };
|
||||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||||
const openedClient = (client as unknown) as PrivateSigningCosmWasmClient;
|
expect(client.registry.lookupType("/custom.MsgCustom")).toEqual(MsgSend);
|
||||||
expect(openedClient.registry.lookupType("/custom.MsgCustom")).toEqual(MsgSend);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can be constructed with custom gas price", async () => {
|
it("can be constructed with custom gas price", async () => {
|
||||||
@ -68,8 +67,7 @@ describe("SigningCosmWasmClient", () => {
|
|||||||
gasPrice: GasPrice.fromString("3.14utest"),
|
gasPrice: GasPrice.fromString("3.14utest"),
|
||||||
};
|
};
|
||||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||||
const openedClient = (client as unknown) as PrivateSigningCosmWasmClient;
|
expect(client.fees).toEqual({
|
||||||
expect(openedClient.fees).toEqual({
|
|
||||||
upload: {
|
upload: {
|
||||||
amount: coins(4710000, "utest"),
|
amount: coins(4710000, "utest"),
|
||||||
gas: "1500000",
|
gas: "1500000",
|
||||||
@ -123,8 +121,7 @@ describe("SigningCosmWasmClient", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||||
const openedClient = (client as unknown) as PrivateSigningCosmWasmClient;
|
expect(client.fees).toEqual({
|
||||||
expect(openedClient.fees).toEqual({
|
|
||||||
upload: {
|
upload: {
|
||||||
amount: coins(37500, "ucosm"),
|
amount: coins(37500, "ucosm"),
|
||||||
gas: "1500000",
|
gas: "1500000",
|
||||||
@ -179,8 +176,7 @@ describe("SigningCosmWasmClient", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||||
const openedClient = (client as unknown) as PrivateSigningCosmWasmClient;
|
expect(client.fees).toEqual({
|
||||||
expect(openedClient.fees).toEqual({
|
|
||||||
upload: {
|
upload: {
|
||||||
amount: coins(4710000, "utest"),
|
amount: coins(4710000, "utest"),
|
||||||
gas: "1500000",
|
gas: "1500000",
|
||||||
|
@ -123,17 +123,11 @@ export interface SigningCosmWasmClientOptions {
|
|||||||
readonly aminoTypes?: AminoTypes;
|
readonly aminoTypes?: AminoTypes;
|
||||||
readonly prefix?: string;
|
readonly prefix?: string;
|
||||||
readonly gasPrice?: GasPrice;
|
readonly gasPrice?: GasPrice;
|
||||||
readonly gasLimits?: Partial<GasLimits<CosmosFeeTable>>;
|
readonly gasLimits?: Partial<GasLimits<CosmWasmFeeTable>>;
|
||||||
}
|
|
||||||
|
|
||||||
/** Use for testing only */
|
|
||||||
export interface PrivateSigningCosmWasmClient {
|
|
||||||
readonly fees: CosmWasmFeeTable;
|
|
||||||
readonly registry: Registry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SigningCosmWasmClient extends CosmWasmClient {
|
export class SigningCosmWasmClient extends CosmWasmClient {
|
||||||
public readonly fees: CosmosFeeTable;
|
public readonly fees: CosmWasmFeeTable;
|
||||||
public readonly registry: Registry;
|
public readonly registry: Registry;
|
||||||
|
|
||||||
private readonly signer: OfflineSigner;
|
private readonly signer: OfflineSigner;
|
||||||
@ -176,7 +170,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
|||||||
gasPrice = defaultGasPrice,
|
gasPrice = defaultGasPrice,
|
||||||
gasLimits = {},
|
gasLimits = {},
|
||||||
} = options;
|
} = options;
|
||||||
this.fees = buildFeeTable<CosmosFeeTable>(gasPrice, defaultGasLimits, gasLimits);
|
this.fees = buildFeeTable<CosmWasmFeeTable>(gasPrice, defaultGasLimits, gasLimits);
|
||||||
this.registry = registry;
|
this.registry = registry;
|
||||||
this.aminoTypes = aminoTypes;
|
this.aminoTypes = aminoTypes;
|
||||||
this.signer = signer;
|
this.signer = signer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user