diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 83be077d..9db452f5 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -1,8 +1,59 @@ import amino from "@tendermint/amino-js"; -export type AminoTx = amino.Tx & { readonly value: amino.StdTx }; +// We will move all needed *interfaces* from amino-js here +// This means bcp can just import them from here (if needed at all) +export interface Tx { + type: string; + value: any; +} -export function isAminoStdTx(txValue: amino.TxValue): txValue is amino.StdTx { +export interface StdTx { + readonly msg: ReadonlyArray; + readonly fee: StdFee; + readonly signatures: ReadonlyArray; + readonly memo: string | undefined; +} + +export interface Msg { + type: string; + // TODO: make better union type + readonly value: MsgSend; +} + +export interface MsgSend { + /** Bech32 account address */ + readonly from_address: string; + /** Bech32 account address */ + readonly to_address: string; + readonly amount: ReadonlyArray; +} + + +export interface StdFee { + readonly amount: ReadonlyArray; + readonly gas: string; +} + +export interface Coin { + denom: string; + amount: string; +} + +export interface StdSignature { + pub_key: PubKey; + signature: string; +} + +export interface PubKey { + /** Amino registered name, e.g. `"tendermint/PubKeySecp256k1"` */ + type: string; + /** Base64-encoded key bytes */ + value: string; +} + +export type AminoTx = Tx & { readonly value: StdTx }; + +export function isAminoStdTx(txValue: unknown): txValue is amino.StdTx { const { memo, msg, fee, signatures } = txValue as amino.StdTx; return ( typeof memo === "string" && Array.isArray(msg) && typeof fee === "object" && Array.isArray(signatures) diff --git a/packages/sdk/types/types.d.ts b/packages/sdk/types/types.d.ts index e41597e4..654dccc3 100644 --- a/packages/sdk/types/types.d.ts +++ b/packages/sdk/types/types.d.ts @@ -1,8 +1,47 @@ import amino from "@tendermint/amino-js"; -export declare type AminoTx = amino.Tx & { - readonly value: amino.StdTx; +export interface Tx { + type: string; + value: any; +} +export interface StdTx { + readonly msg: ReadonlyArray; + readonly fee: StdFee; + readonly signatures: ReadonlyArray; + readonly memo: string | undefined; +} +export interface Msg { + type: string; + readonly value: MsgSend; +} +export interface MsgSend { + /** Bech32 account address */ + readonly from_address: string; + /** Bech32 account address */ + readonly to_address: string; + readonly amount: ReadonlyArray; +} +export interface StdFee { + readonly amount: ReadonlyArray; + readonly gas: string; +} +export interface Coin { + denom: string; + amount: string; +} +export interface StdSignature { + pub_key: PubKey; + signature: string; +} +export interface PubKey { + /** Amino registered name, e.g. `"tendermint/PubKeySecp256k1"` */ + type: string; + /** Base64-encoded key bytes */ + value: string; +} +export declare type AminoTx = Tx & { + readonly value: StdTx; }; -export declare function isAminoStdTx(txValue: amino.TxValue): txValue is amino.StdTx; +export declare function isAminoStdTx(txValue: unknown): txValue is amino.StdTx; export interface TokenInfo { readonly denom: string; readonly ticker: string;