diff --git a/packages/bcp/src/decode.spec.ts b/packages/bcp/src/decode.spec.ts index 26e57a1f..c97e20ed 100644 --- a/packages/bcp/src/decode.spec.ts +++ b/packages/bcp/src/decode.spec.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/camelcase */ import { MsgExecuteContract } from "@cosmwasm/cosmwasm"; -import { Coin, IndexedTx, PubKey, StdSignature, StdTx } from "@cosmwasm/sdk38"; -import { Msg } from "@cosmwasm/sdk38/types/types"; +import { Coin, IndexedTx, Msg, PubKey, StdSignature, StdTx } from "@cosmwasm/sdk38"; import { Address, Algorithm, isSendTransaction, SendTransaction, TokenTicker } from "@iov/bcp"; import { Encoding } from "@iov/encoding"; import { assert } from "@iov/utils"; diff --git a/packages/bcp/src/decode.ts b/packages/bcp/src/decode.ts index c8a91626..cab2543b 100644 --- a/packages/bcp/src/decode.ts +++ b/packages/bcp/src/decode.ts @@ -1,6 +1,16 @@ import { isMsgExecuteContract } from "@cosmwasm/cosmwasm"; -import { Coin, IndexedTx, PubKey, StdSignature } from "@cosmwasm/sdk38"; -import { isMsgSend, isStdTx, Msg, pubkeyType, StdFee, StdTx } from "@cosmwasm/sdk38/types/types"; +import { + Coin, + IndexedTx, + isMsgSend, + isStdTx, + Msg, + PubKey, + pubkeyType, + StdFee, + StdSignature, + StdTx, +} from "@cosmwasm/sdk38"; import { Address, Algorithm, diff --git a/packages/bcp/types/decode.d.ts b/packages/bcp/types/decode.d.ts index ae0da97d..495a92f9 100644 --- a/packages/bcp/types/decode.d.ts +++ b/packages/bcp/types/decode.d.ts @@ -1,5 +1,4 @@ -import { Coin, IndexedTx, PubKey, StdSignature } from "@cosmwasm/sdk38"; -import { Msg, StdFee, StdTx } from "@cosmwasm/sdk38/types/types"; +import { Coin, IndexedTx, Msg, PubKey, StdFee, StdSignature, StdTx } from "@cosmwasm/sdk38"; import { Amount, ChainId, diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index f6a6c0c2..c1bc1bf7 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -72,6 +72,7 @@ export function main(originalArgs: readonly string[]): void { "marshalTx", "IndexedTx", "Coin", + "Msg", "MsgSend", "Pen", "PubKey", diff --git a/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts b/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts index 4a152dd5..e7f981ea 100644 --- a/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts +++ b/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/camelcase */ -import { Coin, CosmosSdkTx, makeSignBytes, Secp256k1Pen } from "@cosmwasm/sdk38"; +import { Coin, CosmosSdkTx, isMsgSend, makeSignBytes, MsgSend, Secp256k1Pen } from "@cosmwasm/sdk38"; import { assert, sleep } from "@iov/utils"; import { CosmWasmClient } from "./cosmwasmclient"; -import { isMsgExecuteContract, isMsgInstantiateContract, isMsgSend, MsgSend } from "./msgs"; +import { isMsgExecuteContract, isMsgInstantiateContract } from "./msgs"; import { RestClient } from "./restclient"; import { SigningCosmWasmClient } from "./signingcosmwasmclient"; import { diff --git a/packages/cosmwasm/src/cosmwasmclient.spec.ts b/packages/cosmwasm/src/cosmwasmclient.spec.ts index c9998ec8..011e1495 100644 --- a/packages/cosmwasm/src/cosmwasmclient.spec.ts +++ b/packages/cosmwasm/src/cosmwasmclient.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/camelcase */ -import { makeSignBytes, Secp256k1Pen, StdFee } from "@cosmwasm/sdk38"; +import { makeSignBytes, MsgSend, Secp256k1Pen, StdFee } from "@cosmwasm/sdk38"; import { Sha256 } from "@iov/crypto"; import { Bech32, Encoding } from "@iov/encoding"; import { assert, sleep } from "@iov/utils"; @@ -7,7 +7,6 @@ import { ReadonlyDate } from "readonly-date"; import { Code, CosmWasmClient, PrivateCosmWasmClient } from "./cosmwasmclient"; import { findAttribute } from "./logs"; -import { MsgSend } from "./msgs"; import { SigningCosmWasmClient } from "./signingcosmwasmclient"; import cosmoshub from "./testdata/cosmoshub.json"; import { diff --git a/packages/cosmwasm/src/msgs.ts b/packages/cosmwasm/src/msgs.ts index bf47a18c..e29eeaea 100644 --- a/packages/cosmwasm/src/msgs.ts +++ b/packages/cosmwasm/src/msgs.ts @@ -1,28 +1,11 @@ -import { Coin } from "@cosmwasm/sdk38"; - -interface MsgTemplate { - readonly type: string; - readonly value: any; -} - -/** A Cosmos SDK token transfer message */ -export interface MsgSend extends MsgTemplate { - readonly type: "cosmos-sdk/MsgSend"; - readonly value: { - /** Bech32 account address */ - readonly from_address: string; - /** Bech32 account address */ - readonly to_address: string; - readonly amount: ReadonlyArray; - }; -} +import { Coin, Msg } from "@cosmwasm/sdk38"; /** * Uploads Wam code to the chain * * @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L17 */ -export interface MsgStoreCode extends MsgTemplate { +export interface MsgStoreCode extends Msg { readonly type: "wasm/store-code"; readonly value: { /** Bech32 account address */ @@ -41,7 +24,7 @@ export interface MsgStoreCode extends MsgTemplate { * * @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L73 */ -export interface MsgInstantiateContract extends MsgTemplate { +export interface MsgInstantiateContract extends Msg { readonly type: "wasm/instantiate"; readonly value: { /** Bech32 account address */ @@ -61,7 +44,7 @@ export interface MsgInstantiateContract extends MsgTemplate { * * @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L103 */ -export interface MsgExecuteContract extends MsgTemplate { +export interface MsgExecuteContract extends Msg { readonly type: "wasm/execute"; readonly value: { /** Bech32 account address */ @@ -74,12 +57,6 @@ export interface MsgExecuteContract extends MsgTemplate { }; } -export type Msg = MsgSend | MsgStoreCode | MsgInstantiateContract | MsgExecuteContract | MsgTemplate; - -export function isMsgSend(msg: Msg): msg is MsgSend { - return (msg as MsgSend).type === "cosmos-sdk/MsgSend"; -} - export function isMsgStoreCode(msg: Msg): msg is MsgStoreCode { return (msg as MsgStoreCode).type === "wasm/store-code"; } diff --git a/packages/cosmwasm/src/restclient.spec.ts b/packages/cosmwasm/src/restclient.spec.ts index 1fe1d856..02884c16 100644 --- a/packages/cosmwasm/src/restclient.spec.ts +++ b/packages/cosmwasm/src/restclient.spec.ts @@ -4,6 +4,8 @@ import { encodeBech32Pubkey, makeCosmoshubPath, makeSignBytes, + Msg, + MsgSend, Pen, rawSecp256k1PubkeyToAddress, Secp256k1Pen, @@ -20,10 +22,8 @@ import { findAttribute, parseLogs } from "./logs"; import { isMsgInstantiateContract, isMsgStoreCode, - Msg, MsgExecuteContract, MsgInstantiateContract, - MsgSend, MsgStoreCode, } from "./msgs"; import { PostTxsResponse, RestClient, TxsResponse } from "./restclient"; diff --git a/packages/cosmwasm/src/signingcosmwasmclient.ts b/packages/cosmwasm/src/signingcosmwasmclient.ts index 9c44fd09..11ed27dd 100644 --- a/packages/cosmwasm/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm/src/signingcosmwasmclient.ts @@ -1,4 +1,4 @@ -import { Coin, coins, makeSignBytes, StdFee, StdSignature } from "@cosmwasm/sdk38"; +import { Coin, coins, makeSignBytes, MsgSend, StdFee, StdSignature } from "@cosmwasm/sdk38"; import { Sha256 } from "@iov/crypto"; import { Encoding } from "@iov/encoding"; import pako from "pako"; @@ -6,7 +6,7 @@ import pako from "pako"; import { isValidBuilder } from "./builder"; import { Account, CosmWasmClient, GetNonceResult, PostTxResult } from "./cosmwasmclient"; import { findAttribute, Log } from "./logs"; -import { MsgExecuteContract, MsgInstantiateContract, MsgSend, MsgStoreCode } from "./msgs"; +import { MsgExecuteContract, MsgInstantiateContract, MsgStoreCode } from "./msgs"; import { BroadcastMode } from "./restclient"; export interface SigningCallback { diff --git a/packages/cosmwasm/types/msgs.d.ts b/packages/cosmwasm/types/msgs.d.ts index 2fb0ae6f..ed636a26 100644 --- a/packages/cosmwasm/types/msgs.d.ts +++ b/packages/cosmwasm/types/msgs.d.ts @@ -1,25 +1,10 @@ -import { Coin } from "@cosmwasm/sdk38"; -interface MsgTemplate { - readonly type: string; - readonly value: any; -} -/** A Cosmos SDK token transfer message */ -export interface MsgSend extends MsgTemplate { - readonly type: "cosmos-sdk/MsgSend"; - readonly value: { - /** Bech32 account address */ - readonly from_address: string; - /** Bech32 account address */ - readonly to_address: string; - readonly amount: ReadonlyArray; - }; -} +import { Coin, Msg } from "@cosmwasm/sdk38"; /** * Uploads Wam code to the chain * * @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L17 */ -export interface MsgStoreCode extends MsgTemplate { +export interface MsgStoreCode extends Msg { readonly type: "wasm/store-code"; readonly value: { /** Bech32 account address */ @@ -37,7 +22,7 @@ export interface MsgStoreCode extends MsgTemplate { * * @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L73 */ -export interface MsgInstantiateContract extends MsgTemplate { +export interface MsgInstantiateContract extends Msg { readonly type: "wasm/instantiate"; readonly value: { /** Bech32 account address */ @@ -56,7 +41,7 @@ export interface MsgInstantiateContract extends MsgTemplate { * * @see https://github.com/cosmwasm/wasmd/blob/9842678d89/x/wasm/internal/types/msg.go#L103 */ -export interface MsgExecuteContract extends MsgTemplate { +export interface MsgExecuteContract extends Msg { readonly type: "wasm/execute"; readonly value: { /** Bech32 account address */ @@ -68,9 +53,6 @@ export interface MsgExecuteContract extends MsgTemplate { readonly sent_funds: ReadonlyArray; }; } -export declare type Msg = MsgSend | MsgStoreCode | MsgInstantiateContract | MsgExecuteContract | MsgTemplate; -export declare function isMsgSend(msg: Msg): msg is MsgSend; export declare function isMsgStoreCode(msg: Msg): msg is MsgStoreCode; export declare function isMsgInstantiateContract(msg: Msg): msg is MsgInstantiateContract; export declare function isMsgExecuteContract(msg: Msg): msg is MsgExecuteContract; -export {}; diff --git a/packages/sdk38/src/index.ts b/packages/sdk38/src/index.ts index b1f290f7..57e3091b 100644 --- a/packages/sdk38/src/index.ts +++ b/packages/sdk38/src/index.ts @@ -37,6 +37,7 @@ export { pubkeyType, CosmosSdkTx, PubKey, + Msg, MsgSend, StdFee, StdSignature, diff --git a/packages/sdk38/src/types.ts b/packages/sdk38/src/types.ts index 7d10fe3c..0db122f9 100644 --- a/packages/sdk38/src/types.ts +++ b/packages/sdk38/src/types.ts @@ -24,13 +24,13 @@ export interface CosmosSdkTx { readonly value: StdTx; } -interface MsgTemplate { +export interface Msg { readonly type: string; readonly value: any; } /** A Cosmos SDK token transfer message */ -export interface MsgSend extends MsgTemplate { +export interface MsgSend extends Msg { readonly type: "cosmos-sdk/MsgSend"; readonly value: { /** Bech32 account address */ @@ -41,8 +41,6 @@ export interface MsgSend extends MsgTemplate { }; } -export type Msg = MsgSend | MsgTemplate; - export function isMsgSend(msg: Msg): msg is MsgSend { return (msg as MsgSend).type === "cosmos-sdk/MsgSend"; } diff --git a/packages/sdk38/types/index.d.ts b/packages/sdk38/types/index.d.ts index 424559eb..829a4403 100644 --- a/packages/sdk38/types/index.d.ts +++ b/packages/sdk38/types/index.d.ts @@ -35,6 +35,7 @@ export { pubkeyType, CosmosSdkTx, PubKey, + Msg, MsgSend, StdFee, StdSignature, diff --git a/packages/sdk38/types/types.d.ts b/packages/sdk38/types/types.d.ts index a38796a2..8083027c 100644 --- a/packages/sdk38/types/types.d.ts +++ b/packages/sdk38/types/types.d.ts @@ -11,12 +11,12 @@ export interface CosmosSdkTx { readonly type: string; readonly value: StdTx; } -interface MsgTemplate { +export interface Msg { readonly type: string; readonly value: any; } /** A Cosmos SDK token transfer message */ -export interface MsgSend extends MsgTemplate { +export interface MsgSend extends Msg { readonly type: "cosmos-sdk/MsgSend"; readonly value: { /** Bech32 account address */ @@ -26,7 +26,6 @@ export interface MsgSend extends MsgTemplate { readonly amount: ReadonlyArray; }; } -export declare type Msg = MsgSend | MsgTemplate; export declare function isMsgSend(msg: Msg): msg is MsgSend; export interface StdFee { readonly amount: ReadonlyArray; @@ -63,4 +62,3 @@ export declare function parseWasmData({ key, val }: WasmData): Model; * This doen't privide any type safety over `any` but expresses intent in the code. */ export declare type JsonObject = any; -export {};