From ff7188b3b5849948037508decc2ebd601c9bc61f Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 7 Jul 2020 23:10:09 +0200 Subject: [PATCH] Move API types into lcdapi --- packages/sdk38/src/cosmosclient.ts | 3 +- packages/sdk38/src/index.ts | 4 +- packages/sdk38/src/lcdapi/index.ts | 173 +++++++++++++++++- packages/sdk38/src/lcdclient.spec.ts | 2 +- packages/sdk38/src/lcdclient.ts | 6 +- packages/sdk38/src/restclient.spec.ts | 3 +- packages/sdk38/src/restclient.ts | 173 +----------------- packages/sdk38/src/signingcosmosclient.ts | 2 +- packages/sdk38/types/cosmosclient.d.ts | 3 +- packages/sdk38/types/index.d.ts | 4 +- packages/sdk38/types/lcdapi/index.d.ts | 145 +++++++++++++++ packages/sdk38/types/lcdclient.d.ts | 2 +- packages/sdk38/types/restclient.d.ts | 155 +--------------- packages/sdk38/types/signingcosmosclient.d.ts | 2 +- 14 files changed, 354 insertions(+), 323 deletions(-) diff --git a/packages/sdk38/src/cosmosclient.ts b/packages/sdk38/src/cosmosclient.ts index 077e354c..890d2d8a 100644 --- a/packages/sdk38/src/cosmosclient.ts +++ b/packages/sdk38/src/cosmosclient.ts @@ -3,9 +3,10 @@ import { fromBase64, fromHex, toHex } from "@cosmjs/encoding"; import { Uint53 } from "@cosmjs/math"; import { Coin } from "./coins"; +import { BroadcastMode } from "./lcdapi"; import { Log, parseLogs } from "./logs"; import { decodeBech32Pubkey } from "./pubkey"; -import { BroadcastMode, RestClient } from "./restclient"; +import { RestClient } from "./restclient"; import { CosmosSdkTx, PubKey, StdTx } from "./types"; export interface GetNonceResult { diff --git a/packages/sdk38/src/index.ts b/packages/sdk38/src/index.ts index 7735fa63..b7bed9a0 100644 --- a/packages/sdk38/src/index.ts +++ b/packages/sdk38/src/index.ts @@ -27,10 +27,10 @@ export { EncodeTxResponse, PostTxsResponse, NodeInfoResponse, - RestClient, SearchTxsResponse, TxsResponse, -} from "./restclient"; +} from "./lcdapi"; +export { RestClient } from "./restclient"; export { isMsgDelegate, isMsgSend, Msg, MsgDelegate, MsgSend } from "./msgs"; export { Pen, Secp256k1Pen, makeCosmoshubPath } from "./pen"; export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey"; diff --git a/packages/sdk38/src/lcdapi/index.ts b/packages/sdk38/src/lcdapi/index.ts index 353d2fb3..567e1517 100644 --- a/packages/sdk38/src/lcdapi/index.ts +++ b/packages/sdk38/src/lcdapi/index.ts @@ -1,3 +1,174 @@ -// See tracking issue https://github.com/CosmWasm/cosmjs/issues/276 for module support +import { Coin } from "../coins"; +import { CosmosSdkTx } from "../types"; + +// +// Standard modules (see tracking issue https://github.com/CosmWasm/cosmjs/issues/276) +// export { SupplyModule, TotalSupplyAllReponse, TotalSupplyReponse } from "./supply"; + +// +// Base types +// + +/** + * The mode used to send transaction + * + * @see https://cosmos.network/rpc/#/Transactions/post_txs + */ +export enum BroadcastMode { + /** Return after tx commit */ + Block = "block", + /** Return afer CheckTx */ + Sync = "sync", + /** Return right away */ + Async = "async", +} + +/** A reponse from the /txs/encode endpoint */ +export interface EncodeTxResponse { + /** base64-encoded amino-binary encoded representation */ + readonly tx: string; +} + +interface NodeInfo { + readonly protocol_version: { + readonly p2p: string; + readonly block: string; + readonly app: string; + }; + readonly id: string; + readonly listen_addr: string; + readonly network: string; + readonly version: string; + readonly channels: string; + readonly moniker: string; + readonly other: { + readonly tx_index: string; + readonly rpc_address: string; + }; +} + +interface ApplicationVersion { + readonly name: string; + readonly server_name: string; + readonly client_name: string; + readonly version: string; + readonly commit: string; + readonly build_tags: string; + readonly go: string; +} + +export interface NodeInfoResponse { + readonly node_info: NodeInfo; + readonly application_version: ApplicationVersion; +} + +interface BlockId { + readonly hash: string; + // TODO: here we also have this + // parts: { + // total: '1', + // hash: '7AF200C78FBF9236944E1AB270F4045CD60972B7C265E3A9DA42973397572931' + // } +} + +interface BlockHeader { + readonly version: { + readonly block: string; + readonly app: string; + }; + readonly height: string; + readonly chain_id: string; + /** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */ + readonly time: string; + readonly last_commit_hash: string; + readonly last_block_id: BlockId; + /** Can be empty */ + readonly data_hash: string; + readonly validators_hash: string; + readonly next_validators_hash: string; + readonly consensus_hash: string; + readonly app_hash: string; + /** Can be empty */ + readonly last_results_hash: string; + /** Can be empty */ + readonly evidence_hash: string; + readonly proposer_address: string; +} + +interface Block { + readonly header: BlockHeader; + readonly data: { + /** Array of base64 encoded transactions */ + readonly txs: readonly string[] | null; + }; +} + +export interface BlockResponse { + readonly block_id: BlockId; + readonly block: Block; +} + +export interface CosmosSdkAccount { + /** Bech32 account address */ + readonly address: string; + readonly coins: readonly Coin[]; + /** Bech32 encoded pubkey */ + readonly public_key: string; + readonly account_number: number; + readonly sequence: number; +} + +export interface AuthAccountsResponse { + readonly height: string; + readonly result: { + readonly type: "cosmos-sdk/Account"; + readonly value: CosmosSdkAccount; + }; +} + +export interface TxsResponse { + readonly height: string; + readonly txhash: string; + /** 🤷‍♂️ */ + readonly codespace?: string; + /** Falsy when transaction execution succeeded. Contains error code on error. */ + readonly code?: number; + readonly raw_log: string; + readonly logs?: object; + readonly tx: CosmosSdkTx; + /** The gas limit as set by the user */ + readonly gas_wanted?: string; + /** The gas used by the execution */ + readonly gas_used?: string; + readonly timestamp: string; +} + +export interface SearchTxsResponse { + readonly total_count: string; + readonly count: string; + readonly page_number: string; + readonly page_total: string; + readonly limit: string; + readonly txs: readonly TxsResponse[]; +} + +export interface PostTxsResponse { + readonly height: string; + readonly txhash: string; + readonly code?: number; + /** + * The result data of the execution (hex encoded). + * + * @see https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/types/result.go#L101 + */ + readonly data?: string; + readonly raw_log?: string; + /** The same as `raw_log` but deserialized? */ + readonly logs?: object; + /** The gas limit as set by the user */ + readonly gas_wanted?: string; + /** The gas used by the execution */ + readonly gas_used?: string; +} diff --git a/packages/sdk38/src/lcdclient.spec.ts b/packages/sdk38/src/lcdclient.spec.ts index acaf33d0..e6b43eb8 100644 --- a/packages/sdk38/src/lcdclient.spec.ts +++ b/packages/sdk38/src/lcdclient.spec.ts @@ -5,11 +5,11 @@ import { rawSecp256k1PubkeyToAddress } from "./address"; import { Coin } from "./coins"; import { isPostTxFailure } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; +import { TxsResponse } from "./lcdapi"; import { LcdApiArray, LcdClient, normalizeArray } from "./lcdclient"; import { parseLogs } from "./logs"; import { MsgSend } from "./msgs"; import { makeCosmoshubPath, Secp256k1Pen } from "./pen"; -import { TxsResponse } from "./restclient"; import { SigningCosmosClient } from "./signingcosmosclient"; import cosmoshub from "./testdata/cosmoshub.json"; import { diff --git a/packages/sdk38/src/lcdclient.ts b/packages/sdk38/src/lcdclient.ts index 2a1581ba..c15d2d8f 100644 --- a/packages/sdk38/src/lcdclient.ts +++ b/packages/sdk38/src/lcdclient.ts @@ -11,13 +11,13 @@ import { PostTxsResponse, SearchTxsResponse, TxsResponse, -} from "./restclient"; +} from "./lcdapi"; import { CosmosSdkTx, StdTx } from "./types"; /** Unfortunately, Cosmos SDK encodes empty arrays as null */ -export type LcdApiArray = ReadonlyArray | null; +export type LcdApiArray = readonly T[] | null; -export function normalizeArray(backend: LcdApiArray): ReadonlyArray { +export function normalizeArray(backend: LcdApiArray): readonly T[] { return backend || []; } diff --git a/packages/sdk38/src/restclient.spec.ts b/packages/sdk38/src/restclient.spec.ts index bc6cffc3..14d18f61 100644 --- a/packages/sdk38/src/restclient.spec.ts +++ b/packages/sdk38/src/restclient.spec.ts @@ -5,11 +5,12 @@ import { ReadonlyDate } from "readonly-date"; import { rawSecp256k1PubkeyToAddress } from "./address"; import { isPostTxFailure } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; +import { TxsResponse } from "./lcdapi"; import { parseLogs } from "./logs"; import { MsgSend } from "./msgs"; import { makeCosmoshubPath, Secp256k1Pen } from "./pen"; import { encodeBech32Pubkey } from "./pubkey"; -import { RestClient, TxsResponse } from "./restclient"; +import { RestClient } from "./restclient"; import { SigningCosmosClient } from "./signingcosmosclient"; import cosmoshub from "./testdata/cosmoshub.json"; import { diff --git a/packages/sdk38/src/restclient.ts b/packages/sdk38/src/restclient.ts index 67edfb99..fdc572e6 100644 --- a/packages/sdk38/src/restclient.ts +++ b/packages/sdk38/src/restclient.ts @@ -1,171 +1,18 @@ import { isNonNullObject } from "@cosmjs/utils"; import axios, { AxiosError, AxiosInstance } from "axios"; -import { Coin } from "./coins"; +import { + AuthAccountsResponse, + BlockResponse, + BroadcastMode, + EncodeTxResponse, + NodeInfoResponse, + PostTxsResponse, + SearchTxsResponse, + TxsResponse, +} from "./lcdapi"; import { CosmosSdkTx, StdTx } from "./types"; -export interface CosmosSdkAccount { - /** Bech32 account address */ - readonly address: string; - readonly coins: readonly Coin[]; - /** Bech32 encoded pubkey */ - readonly public_key: string; - readonly account_number: number; - readonly sequence: number; -} - -interface NodeInfo { - readonly protocol_version: { - readonly p2p: string; - readonly block: string; - readonly app: string; - }; - readonly id: string; - readonly listen_addr: string; - readonly network: string; - readonly version: string; - readonly channels: string; - readonly moniker: string; - readonly other: { - readonly tx_index: string; - readonly rpc_address: string; - }; -} - -interface ApplicationVersion { - readonly name: string; - readonly server_name: string; - readonly client_name: string; - readonly version: string; - readonly commit: string; - readonly build_tags: string; - readonly go: string; -} - -export interface NodeInfoResponse { - readonly node_info: NodeInfo; - readonly application_version: ApplicationVersion; -} - -interface BlockId { - readonly hash: string; - // TODO: here we also have this - // parts: { - // total: '1', - // hash: '7AF200C78FBF9236944E1AB270F4045CD60972B7C265E3A9DA42973397572931' - // } -} - -interface BlockHeader { - readonly version: { - readonly block: string; - readonly app: string; - }; - readonly height: string; - readonly chain_id: string; - /** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */ - readonly time: string; - readonly last_commit_hash: string; - readonly last_block_id: BlockId; - /** Can be empty */ - readonly data_hash: string; - readonly validators_hash: string; - readonly next_validators_hash: string; - readonly consensus_hash: string; - readonly app_hash: string; - /** Can be empty */ - readonly last_results_hash: string; - /** Can be empty */ - readonly evidence_hash: string; - readonly proposer_address: string; -} - -interface Block { - readonly header: BlockHeader; - readonly data: { - /** Array of base64 encoded transactions */ - readonly txs: readonly string[] | null; - }; -} - -export interface BlockResponse { - readonly block_id: BlockId; - readonly block: Block; -} - -export interface AuthAccountsResponse { - readonly height: string; - readonly result: { - readonly type: "cosmos-sdk/Account"; - readonly value: CosmosSdkAccount; - }; -} - -export interface TxsResponse { - readonly height: string; - readonly txhash: string; - /** 🤷‍♂️ */ - readonly codespace?: string; - /** Falsy when transaction execution succeeded. Contains error code on error. */ - readonly code?: number; - readonly raw_log: string; - readonly logs?: object; - readonly tx: CosmosSdkTx; - /** The gas limit as set by the user */ - readonly gas_wanted?: string; - /** The gas used by the execution */ - readonly gas_used?: string; - readonly timestamp: string; -} - -export interface SearchTxsResponse { - readonly total_count: string; - readonly count: string; - readonly page_number: string; - readonly page_total: string; - readonly limit: string; - readonly txs: readonly TxsResponse[]; -} - -export interface PostTxsResponse { - readonly height: string; - readonly txhash: string; - readonly code?: number; - /** - * The result data of the execution (hex encoded). - * - * @see https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/types/result.go#L101 - */ - readonly data?: string; - readonly raw_log?: string; - /** The same as `raw_log` but deserialized? */ - readonly logs?: object; - /** The gas limit as set by the user */ - readonly gas_wanted?: string; - /** The gas used by the execution */ - readonly gas_used?: string; -} - -/** A reponse from the /txs/encode endpoint */ -export interface EncodeTxResponse { - /** base64-encoded amino-binary encoded representation */ - readonly tx: string; -} - -/** - * The mode used to send transaction - * - * @see https://cosmos.network/rpc/#/Transactions/post_txs - */ -export enum BroadcastMode { - /** Return after tx commit */ - Block = "block", - /** Return afer CheckTx */ - Sync = "sync", - /** Return right away */ - Async = "async", -} - // We want to get message data from 500 errors // https://stackoverflow.com/questions/56577124/how-to-handle-500-error-message-with-axios // this should be chained to catch one error and throw a more informative one diff --git a/packages/sdk38/src/signingcosmosclient.ts b/packages/sdk38/src/signingcosmosclient.ts index 4768bf60..74f23fef 100644 --- a/packages/sdk38/src/signingcosmosclient.ts +++ b/packages/sdk38/src/signingcosmosclient.ts @@ -1,8 +1,8 @@ import { Coin, coins } from "./coins"; import { Account, CosmosClient, GetNonceResult, PostTxResult } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; +import { BroadcastMode } from "./lcdapi"; import { MsgSend } from "./msgs"; -import { BroadcastMode } from "./restclient"; import { StdFee, StdSignature, StdTx } from "./types"; export interface SigningCallback { diff --git a/packages/sdk38/types/cosmosclient.d.ts b/packages/sdk38/types/cosmosclient.d.ts index b62fb2c6..e83f6059 100644 --- a/packages/sdk38/types/cosmosclient.d.ts +++ b/packages/sdk38/types/cosmosclient.d.ts @@ -1,6 +1,7 @@ import { Coin } from "./coins"; +import { BroadcastMode } from "./lcdapi"; import { Log } from "./logs"; -import { BroadcastMode, RestClient } from "./restclient"; +import { RestClient } from "./restclient"; import { CosmosSdkTx, PubKey, StdTx } from "./types"; export interface GetNonceResult { readonly accountNumber: number; diff --git a/packages/sdk38/types/index.d.ts b/packages/sdk38/types/index.d.ts index 633dc24b..c6bcbb3c 100644 --- a/packages/sdk38/types/index.d.ts +++ b/packages/sdk38/types/index.d.ts @@ -25,10 +25,10 @@ export { EncodeTxResponse, PostTxsResponse, NodeInfoResponse, - RestClient, SearchTxsResponse, TxsResponse, -} from "./restclient"; +} from "./lcdapi"; +export { RestClient } from "./restclient"; export { isMsgDelegate, isMsgSend, Msg, MsgDelegate, MsgSend } from "./msgs"; export { Pen, Secp256k1Pen, makeCosmoshubPath } from "./pen"; export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey"; diff --git a/packages/sdk38/types/lcdapi/index.d.ts b/packages/sdk38/types/lcdapi/index.d.ts index 0e8ba9fe..7341b9bf 100644 --- a/packages/sdk38/types/lcdapi/index.d.ts +++ b/packages/sdk38/types/lcdapi/index.d.ts @@ -1 +1,146 @@ +import { Coin } from "../coins"; +import { CosmosSdkTx } from "../types"; export { SupplyModule, TotalSupplyAllReponse, TotalSupplyReponse } from "./supply"; +/** + * The mode used to send transaction + * + * @see https://cosmos.network/rpc/#/Transactions/post_txs + */ +export declare enum BroadcastMode { + /** Return after tx commit */ + Block = "block", + /** Return afer CheckTx */ + Sync = "sync", + /** Return right away */ + Async = "async", +} +/** A reponse from the /txs/encode endpoint */ +export interface EncodeTxResponse { + /** base64-encoded amino-binary encoded representation */ + readonly tx: string; +} +interface NodeInfo { + readonly protocol_version: { + readonly p2p: string; + readonly block: string; + readonly app: string; + }; + readonly id: string; + readonly listen_addr: string; + readonly network: string; + readonly version: string; + readonly channels: string; + readonly moniker: string; + readonly other: { + readonly tx_index: string; + readonly rpc_address: string; + }; +} +interface ApplicationVersion { + readonly name: string; + readonly server_name: string; + readonly client_name: string; + readonly version: string; + readonly commit: string; + readonly build_tags: string; + readonly go: string; +} +export interface NodeInfoResponse { + readonly node_info: NodeInfo; + readonly application_version: ApplicationVersion; +} +interface BlockId { + readonly hash: string; +} +interface BlockHeader { + readonly version: { + readonly block: string; + readonly app: string; + }; + readonly height: string; + readonly chain_id: string; + /** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */ + readonly time: string; + readonly last_commit_hash: string; + readonly last_block_id: BlockId; + /** Can be empty */ + readonly data_hash: string; + readonly validators_hash: string; + readonly next_validators_hash: string; + readonly consensus_hash: string; + readonly app_hash: string; + /** Can be empty */ + readonly last_results_hash: string; + /** Can be empty */ + readonly evidence_hash: string; + readonly proposer_address: string; +} +interface Block { + readonly header: BlockHeader; + readonly data: { + /** Array of base64 encoded transactions */ + readonly txs: ReadonlyArray | null; + }; +} +export interface BlockResponse { + readonly block_id: BlockId; + readonly block: Block; +} +export interface CosmosSdkAccount { + /** Bech32 account address */ + readonly address: string; + readonly coins: ReadonlyArray; + /** Bech32 encoded pubkey */ + readonly public_key: string; + readonly account_number: number; + readonly sequence: number; +} +export interface AuthAccountsResponse { + readonly height: string; + readonly result: { + readonly type: "cosmos-sdk/Account"; + readonly value: CosmosSdkAccount; + }; +} +export interface TxsResponse { + readonly height: string; + readonly txhash: string; + /** 🤷‍♂️ */ + readonly codespace?: string; + /** Falsy when transaction execution succeeded. Contains error code on error. */ + readonly code?: number; + readonly raw_log: string; + readonly logs?: object; + readonly tx: CosmosSdkTx; + /** The gas limit as set by the user */ + readonly gas_wanted?: string; + /** The gas used by the execution */ + readonly gas_used?: string; + readonly timestamp: string; +} +export interface SearchTxsResponse { + readonly total_count: string; + readonly count: string; + readonly page_number: string; + readonly page_total: string; + readonly limit: string; + readonly txs: readonly TxsResponse[]; +} +export interface PostTxsResponse { + readonly height: string; + readonly txhash: string; + readonly code?: number; + /** + * The result data of the execution (hex encoded). + * + * @see https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/types/result.go#L101 + */ + readonly data?: string; + readonly raw_log?: string; + /** The same as `raw_log` but deserialized? */ + readonly logs?: object; + /** The gas limit as set by the user */ + readonly gas_wanted?: string; + /** The gas used by the execution */ + readonly gas_used?: string; +} diff --git a/packages/sdk38/types/lcdclient.d.ts b/packages/sdk38/types/lcdclient.d.ts index f8c2519a..349373ea 100644 --- a/packages/sdk38/types/lcdclient.d.ts +++ b/packages/sdk38/types/lcdclient.d.ts @@ -7,7 +7,7 @@ import { PostTxsResponse, SearchTxsResponse, TxsResponse, -} from "./restclient"; +} from "./lcdapi"; import { CosmosSdkTx, StdTx } from "./types"; /** Unfortunately, Cosmos SDK encodes empty arrays as null */ export declare type LcdApiArray = ReadonlyArray | null; diff --git a/packages/sdk38/types/restclient.d.ts b/packages/sdk38/types/restclient.d.ts index b1134d30..6ee4890c 100644 --- a/packages/sdk38/types/restclient.d.ts +++ b/packages/sdk38/types/restclient.d.ts @@ -1,148 +1,14 @@ -import { Coin } from "./coins"; +import { + AuthAccountsResponse, + BlockResponse, + BroadcastMode, + EncodeTxResponse, + NodeInfoResponse, + PostTxsResponse, + SearchTxsResponse, + TxsResponse, +} from "./lcdapi"; import { CosmosSdkTx, StdTx } from "./types"; -export interface CosmosSdkAccount { - /** Bech32 account address */ - readonly address: string; - readonly coins: readonly Coin[]; - /** Bech32 encoded pubkey */ - readonly public_key: string; - readonly account_number: number; - readonly sequence: number; -} -interface NodeInfo { - readonly protocol_version: { - readonly p2p: string; - readonly block: string; - readonly app: string; - }; - readonly id: string; - readonly listen_addr: string; - readonly network: string; - readonly version: string; - readonly channels: string; - readonly moniker: string; - readonly other: { - readonly tx_index: string; - readonly rpc_address: string; - }; -} -interface ApplicationVersion { - readonly name: string; - readonly server_name: string; - readonly client_name: string; - readonly version: string; - readonly commit: string; - readonly build_tags: string; - readonly go: string; -} -export interface NodeInfoResponse { - readonly node_info: NodeInfo; - readonly application_version: ApplicationVersion; -} -interface BlockId { - readonly hash: string; -} -interface BlockHeader { - readonly version: { - readonly block: string; - readonly app: string; - }; - readonly height: string; - readonly chain_id: string; - /** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */ - readonly time: string; - readonly last_commit_hash: string; - readonly last_block_id: BlockId; - /** Can be empty */ - readonly data_hash: string; - readonly validators_hash: string; - readonly next_validators_hash: string; - readonly consensus_hash: string; - readonly app_hash: string; - /** Can be empty */ - readonly last_results_hash: string; - /** Can be empty */ - readonly evidence_hash: string; - readonly proposer_address: string; -} -interface Block { - readonly header: BlockHeader; - readonly data: { - /** Array of base64 encoded transactions */ - readonly txs: readonly string[] | null; - }; -} -export interface BlockResponse { - readonly block_id: BlockId; - readonly block: Block; -} -export interface AuthAccountsResponse { - readonly height: string; - readonly result: { - readonly type: "cosmos-sdk/Account"; - readonly value: CosmosSdkAccount; - }; -} -export interface TxsResponse { - readonly height: string; - readonly txhash: string; - /** 🤷‍♂️ */ - readonly codespace?: string; - /** Falsy when transaction execution succeeded. Contains error code on error. */ - readonly code?: number; - readonly raw_log: string; - readonly logs?: object; - readonly tx: CosmosSdkTx; - /** The gas limit as set by the user */ - readonly gas_wanted?: string; - /** The gas used by the execution */ - readonly gas_used?: string; - readonly timestamp: string; -} -export interface SearchTxsResponse { - readonly total_count: string; - readonly count: string; - readonly page_number: string; - readonly page_total: string; - readonly limit: string; - readonly txs: readonly TxsResponse[]; -} -export interface PostTxsResponse { - readonly height: string; - readonly txhash: string; - readonly code?: number; - /** - * The result data of the execution (hex encoded). - * - * @see https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/types/result.go#L101 - */ - readonly data?: string; - readonly raw_log?: string; - /** The same as `raw_log` but deserialized? */ - readonly logs?: object; - /** The gas limit as set by the user */ - readonly gas_wanted?: string; - /** The gas used by the execution */ - readonly gas_used?: string; -} -/** A reponse from the /txs/encode endpoint */ -export interface EncodeTxResponse { - /** base64-encoded amino-binary encoded representation */ - readonly tx: string; -} -/** - * The mode used to send transaction - * - * @see https://cosmos.network/rpc/#/Transactions/post_txs - */ -export declare enum BroadcastMode { - /** Return after tx commit */ - Block = "block", - /** Return afer CheckTx */ - Sync = "sync", - /** Return right away */ - Async = "async", -} export declare class RestClient { private readonly client; private readonly broadcastMode; @@ -177,4 +43,3 @@ export declare class RestClient { */ postTx(tx: StdTx): Promise; } -export {}; diff --git a/packages/sdk38/types/signingcosmosclient.d.ts b/packages/sdk38/types/signingcosmosclient.d.ts index d9ac523a..a733b8f6 100644 --- a/packages/sdk38/types/signingcosmosclient.d.ts +++ b/packages/sdk38/types/signingcosmosclient.d.ts @@ -1,6 +1,6 @@ import { Coin } from "./coins"; import { Account, CosmosClient, GetNonceResult, PostTxResult } from "./cosmosclient"; -import { BroadcastMode } from "./restclient"; +import { BroadcastMode } from "./lcdapi"; import { StdFee, StdSignature } from "./types"; export interface SigningCallback { (signBytes: Uint8Array): Promise;