diff --git a/packages/sdk38/src/cosmosclient.searchtx.spec.ts b/packages/sdk38/src/cosmosclient.searchtx.spec.ts index b1c75d60..3bf1210f 100644 --- a/packages/sdk38/src/cosmosclient.searchtx.spec.ts +++ b/packages/sdk38/src/cosmosclient.searchtx.spec.ts @@ -4,6 +4,7 @@ import { assert, sleep } from "@cosmjs/utils"; import { Coin } from "./coins"; import { CosmosClient, isPostTxFailure } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; +import { isMsgSend, MsgSend } from "./msgs"; import { Secp256k1Pen } from "./pen"; import { RestClient } from "./restclient"; import { SigningCosmosClient } from "./signingcosmosclient"; @@ -15,7 +16,7 @@ import { wasmd, wasmdEnabled, } from "./testutils.spec"; -import { CosmosSdkTx, isMsgSend, MsgSend } from "./types"; +import { CosmosSdkTx } from "./types"; describe("CosmosClient.searchTx", () => { let sendSuccessful: diff --git a/packages/sdk38/src/cosmosclient.spec.ts b/packages/sdk38/src/cosmosclient.spec.ts index 8cf1c1e4..cdea2316 100644 --- a/packages/sdk38/src/cosmosclient.spec.ts +++ b/packages/sdk38/src/cosmosclient.spec.ts @@ -5,6 +5,7 @@ import { ReadonlyDate } from "readonly-date"; import { CosmosClient, isPostTxFailure, PrivateCosmWasmClient } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; import { findAttribute } from "./logs"; +import { MsgSend } from "./msgs"; import { Secp256k1Pen } from "./pen"; import cosmoshub from "./testdata/cosmoshub.json"; import { @@ -15,7 +16,7 @@ import { unused, wasmd, } from "./testutils.spec"; -import { MsgSend, StdFee } from "./types"; +import { StdFee } from "./types"; const blockTime = 1_000; // ms diff --git a/packages/sdk38/src/encoding.ts b/packages/sdk38/src/encoding.ts index 30a3193e..b4275fe9 100644 --- a/packages/sdk38/src/encoding.ts +++ b/packages/sdk38/src/encoding.ts @@ -1,6 +1,7 @@ import { toUtf8 } from "@cosmjs/encoding"; -import { Msg, StdFee } from "./types"; +import { Msg } from "./msgs"; +import { StdFee } from "./types"; function sortJson(json: any): any { if (typeof json !== "object" || json === null) { diff --git a/packages/sdk38/src/index.ts b/packages/sdk38/src/index.ts index 50ca53e3..c8fafcad 100644 --- a/packages/sdk38/src/index.ts +++ b/packages/sdk38/src/index.ts @@ -30,20 +30,10 @@ export { SearchTxsResponse, TxsResponse, } from "./restclient"; +export { isMsgSend, Msg, MsgSend } from "./msgs"; export { Pen, Secp256k1Pen, makeCosmoshubPath } from "./pen"; export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey"; export { findSequenceForSignedTx } from "./sequence"; export { encodeSecp256k1Signature, decodeSignature } from "./signature"; export { FeeTable, SigningCallback, SigningCosmosClient } from "./signingcosmosclient"; -export { - isMsgSend, - isStdTx, - pubkeyType, - CosmosSdkTx, - PubKey, - Msg, - MsgSend, - StdFee, - StdSignature, - StdTx, -} from "./types"; +export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types"; diff --git a/packages/sdk38/src/msgs.ts b/packages/sdk38/src/msgs.ts new file mode 100644 index 00000000..f503515d --- /dev/null +++ b/packages/sdk38/src/msgs.ts @@ -0,0 +1,22 @@ +import { Coin } from "./coins"; + +export interface Msg { + readonly type: string; + readonly value: any; +} + +/** A Cosmos SDK token transfer message */ +export interface MsgSend extends Msg { + readonly type: "cosmos-sdk/MsgSend"; + readonly value: { + /** Bech32 account address */ + readonly from_address: string; + /** Bech32 account address */ + readonly to_address: string; + readonly amount: ReadonlyArray; + }; +} + +export function isMsgSend(msg: Msg): msg is MsgSend { + return (msg as MsgSend).type === "cosmos-sdk/MsgSend"; +} diff --git a/packages/sdk38/src/restclient.spec.ts b/packages/sdk38/src/restclient.spec.ts index bdaea11a..33a184bc 100644 --- a/packages/sdk38/src/restclient.spec.ts +++ b/packages/sdk38/src/restclient.spec.ts @@ -7,6 +7,7 @@ import { rawSecp256k1PubkeyToAddress } from "./address"; import { isPostTxFailure } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; import { parseLogs } from "./logs"; +import { Msg, MsgSend } from "./msgs"; import { makeCosmoshubPath, Secp256k1Pen } from "./pen"; import { encodeBech32Pubkey } from "./pubkey"; import { RestClient, TxsResponse } from "./restclient"; @@ -26,7 +27,7 @@ import { wasmd, wasmdEnabled, } from "./testutils.spec"; -import { Msg, MsgSend, StdFee, StdSignature, StdTx } from "./types"; +import { StdFee, StdSignature, StdTx } from "./types"; const emptyAddress = "cosmos1ltkhnmdcqemmd2tkhnx7qx66tq7e0wykw2j85k"; diff --git a/packages/sdk38/src/signingcosmosclient.ts b/packages/sdk38/src/signingcosmosclient.ts index c144955e..5d758071 100644 --- a/packages/sdk38/src/signingcosmosclient.ts +++ b/packages/sdk38/src/signingcosmosclient.ts @@ -1,8 +1,9 @@ import { Coin, coins } from "./coins"; import { Account, CosmosClient, GetNonceResult, PostTxResult } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; +import { MsgSend } from "./msgs"; import { BroadcastMode } from "./restclient"; -import { MsgSend, StdFee, StdSignature } from "./types"; +import { StdFee, StdSignature } from "./types"; export interface SigningCallback { (signBytes: Uint8Array): Promise; diff --git a/packages/sdk38/src/types.ts b/packages/sdk38/src/types.ts index 814c393c..49346bf7 100644 --- a/packages/sdk38/src/types.ts +++ b/packages/sdk38/src/types.ts @@ -1,4 +1,5 @@ import { Coin } from "./coins"; +import { Msg } from "./msgs"; /** An Amino/Cosmos SDK StdTx */ export interface StdTx { @@ -20,27 +21,6 @@ export interface CosmosSdkTx { readonly value: StdTx; } -export interface Msg { - readonly type: string; - readonly value: any; -} - -/** A Cosmos SDK token transfer message */ -export interface MsgSend extends Msg { - readonly type: "cosmos-sdk/MsgSend"; - readonly value: { - /** Bech32 account address */ - readonly from_address: string; - /** Bech32 account address */ - readonly to_address: string; - readonly amount: ReadonlyArray; - }; -} - -export function isMsgSend(msg: Msg): msg is MsgSend { - return (msg as MsgSend).type === "cosmos-sdk/MsgSend"; -} - export interface StdFee { readonly amount: ReadonlyArray; readonly gas: string; diff --git a/packages/sdk38/types/encoding.d.ts b/packages/sdk38/types/encoding.d.ts index e51c7168..6eece8ca 100644 --- a/packages/sdk38/types/encoding.d.ts +++ b/packages/sdk38/types/encoding.d.ts @@ -1,4 +1,5 @@ -import { Msg, StdFee } from "./types"; +import { Msg } from "./msgs"; +import { StdFee } from "./types"; export declare function makeSignBytes( msgs: readonly Msg[], fee: StdFee, diff --git a/packages/sdk38/types/index.d.ts b/packages/sdk38/types/index.d.ts index 7a9de872..9b84fb42 100644 --- a/packages/sdk38/types/index.d.ts +++ b/packages/sdk38/types/index.d.ts @@ -28,20 +28,10 @@ export { SearchTxsResponse, TxsResponse, } from "./restclient"; +export { isMsgSend, Msg, MsgSend } from "./msgs"; export { Pen, Secp256k1Pen, makeCosmoshubPath } from "./pen"; export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey"; export { findSequenceForSignedTx } from "./sequence"; export { encodeSecp256k1Signature, decodeSignature } from "./signature"; export { FeeTable, SigningCallback, SigningCosmosClient } from "./signingcosmosclient"; -export { - isMsgSend, - isStdTx, - pubkeyType, - CosmosSdkTx, - PubKey, - Msg, - MsgSend, - StdFee, - StdSignature, - StdTx, -} from "./types"; +export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types"; diff --git a/packages/sdk38/types/msgs.d.ts b/packages/sdk38/types/msgs.d.ts new file mode 100644 index 00000000..a0ed1280 --- /dev/null +++ b/packages/sdk38/types/msgs.d.ts @@ -0,0 +1,17 @@ +import { Coin } from "./coins"; +export interface Msg { + readonly type: string; + readonly value: any; +} +/** A Cosmos SDK token transfer message */ +export interface MsgSend extends Msg { + readonly type: "cosmos-sdk/MsgSend"; + readonly value: { + /** Bech32 account address */ + readonly from_address: string; + /** Bech32 account address */ + readonly to_address: string; + readonly amount: ReadonlyArray; + }; +} +export declare function isMsgSend(msg: Msg): msg is MsgSend; diff --git a/packages/sdk38/types/types.d.ts b/packages/sdk38/types/types.d.ts index bb8390ed..2eb30fc9 100644 --- a/packages/sdk38/types/types.d.ts +++ b/packages/sdk38/types/types.d.ts @@ -1,4 +1,5 @@ import { Coin } from "./coins"; +import { Msg } from "./msgs"; /** An Amino/Cosmos SDK StdTx */ export interface StdTx { readonly msg: ReadonlyArray; @@ -11,22 +12,6 @@ export interface CosmosSdkTx { readonly type: string; readonly value: StdTx; } -export interface Msg { - readonly type: string; - readonly value: any; -} -/** A Cosmos SDK token transfer message */ -export interface MsgSend extends Msg { - readonly type: "cosmos-sdk/MsgSend"; - readonly value: { - /** Bech32 account address */ - readonly from_address: string; - /** Bech32 account address */ - readonly to_address: string; - readonly amount: ReadonlyArray; - }; -} -export declare function isMsgSend(msg: Msg): msg is MsgSend; export interface StdFee { readonly amount: ReadonlyArray; readonly gas: string;