diff --git a/packages/launchpad/src/coins.spec.ts b/packages/amino/src/coins.spec.ts similarity index 100% rename from packages/launchpad/src/coins.spec.ts rename to packages/amino/src/coins.spec.ts diff --git a/packages/launchpad/src/coins.ts b/packages/amino/src/coins.ts similarity index 81% rename from packages/launchpad/src/coins.ts rename to packages/amino/src/coins.ts index e62617c8..1254f27f 100644 --- a/packages/launchpad/src/coins.ts +++ b/packages/amino/src/coins.ts @@ -1,18 +1,26 @@ -import { Coin } from "@cosmjs/amino"; import { Uint53, Uint64 } from "@cosmjs/math"; -/** Creates a coin */ +export interface Coin { + readonly denom: string; + readonly amount: string; +} + +/** + * Creates a coin. + */ export function coin(amount: number, denom: string): Coin { return { amount: new Uint53(amount).toString(), denom: denom }; } -/** Creates a list of coins with one element */ +/** + * Creates a list of coins with one element. + */ export function coins(amount: number, denom: string): Coin[] { return [coin(amount, denom)]; } /** - * Takes a coins list like "819966000ucosm,700000000ustake" and parses it + * Takes a coins list like "819966000ucosm,700000000ustake" and parses it. */ export function parseCoins(input: string): Coin[] { return input diff --git a/packages/amino/src/index.ts b/packages/amino/src/index.ts index f6f8fc85..21bec81d 100644 --- a/packages/amino/src/index.ts +++ b/packages/amino/src/index.ts @@ -1,4 +1,5 @@ export { pubkeyToAddress, pubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress } from "./addresses"; +export { Coin, coin, coins, parseCoins } from "./coins"; export { decodeAminoPubkey, decodeBech32Pubkey, @@ -23,6 +24,6 @@ export { makeCosmoshubPath } from "./paths"; export { extractKdfConfiguration, Secp256k1HdWallet } from "./secp256k1hdwallet"; export { Secp256k1Wallet } from "./secp256k1wallet"; export { decodeSignature, encodeSecp256k1Signature, StdSignature } from "./signature"; -export { AminoMsg, Coin, makeSignDoc, serializeSignDoc, StdFee, StdSignDoc } from "./signdoc"; +export { AminoMsg, makeSignDoc, serializeSignDoc, StdFee, StdSignDoc } from "./signdoc"; export { AccountData, Algo, AminoSignResponse, OfflineAminoSigner } from "./signer"; export { executeKdf, KdfConfiguration } from "./wallet"; diff --git a/packages/amino/src/signdoc.ts b/packages/amino/src/signdoc.ts index bfd75dce..54bf86b0 100644 --- a/packages/amino/src/signdoc.ts +++ b/packages/amino/src/signdoc.ts @@ -2,16 +2,13 @@ import { toUtf8 } from "@cosmjs/encoding"; import { Uint53 } from "@cosmjs/math"; +import { Coin } from "./coins"; + export interface AminoMsg { readonly type: string; readonly value: any; } -export interface Coin { - readonly denom: string; - readonly amount: string; -} - export interface StdFee { readonly amount: readonly Coin[]; readonly gas: string; diff --git a/packages/cosmwasm-stargate/src/cosmwasmclient.ts b/packages/cosmwasm-stargate/src/cosmwasmclient.ts index 1669bd19..fb2af52d 100644 --- a/packages/cosmwasm-stargate/src/cosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/cosmwasmclient.ts @@ -7,25 +7,23 @@ import { JsonObject, } from "@cosmjs/cosmwasm-launchpad"; import { fromAscii, toHex } from "@cosmjs/encoding"; -import { - Block, - isSearchByHeightQuery, - isSearchBySentFromOrToQuery, - isSearchByTagsQuery, - SearchTxFilter, - SearchTxQuery, -} from "@cosmjs/launchpad"; import { Uint53 } from "@cosmjs/math"; import { Account, accountFromAny, AuthExtension, BankExtension, + Block, BroadcastTxResponse, Coin, coinFromProto, IndexedTx, + isSearchByHeightQuery, + isSearchBySentFromOrToQuery, + isSearchByTagsQuery, QueryClient, + SearchTxFilter, + SearchTxQuery, SequenceResponse, setupAuthExtension, setupBankExtension, diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts index 16da8341..dcb84e5b 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts @@ -13,7 +13,6 @@ import { } from "@cosmjs/cosmwasm-launchpad"; import { sha256 } from "@cosmjs/crypto"; import { fromBase64, toHex, toUtf8 } from "@cosmjs/encoding"; -import { CosmosFeeTable } from "@cosmjs/launchpad"; import { Int53, Uint53 } from "@cosmjs/math"; import { EncodeObject, @@ -30,6 +29,7 @@ import { BroadcastTxResponse, buildFeeTable, Coin, + CosmosFeeTable, defaultRegistryTypes, GasLimits, GasPrice, diff --git a/packages/launchpad/src/cosmosclient.searchtx.spec.ts b/packages/launchpad/src/cosmosclient.searchtx.spec.ts index 5fa17338..e3e6c56f 100644 --- a/packages/launchpad/src/cosmosclient.searchtx.spec.ts +++ b/packages/launchpad/src/cosmosclient.searchtx.spec.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino"; +import { coins, makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino"; import { assert, sleep } from "@cosmjs/utils"; -import { coins } from "./coins"; import { CosmosClient, isBroadcastTxFailure } from "./cosmosclient"; import { LcdClient } from "./lcdapi"; import { isMsgSend, MsgSend } from "./msgs"; diff --git a/packages/launchpad/src/fee.ts b/packages/launchpad/src/fee.ts index 1703792f..c76062cc 100644 --- a/packages/launchpad/src/fee.ts +++ b/packages/launchpad/src/fee.ts @@ -1,8 +1,6 @@ -import { StdFee } from "@cosmjs/amino"; +import { coins, StdFee } from "@cosmjs/amino"; import { Decimal, Uint53 } from "@cosmjs/math"; -import { coins } from "./coins"; - export type FeeTable = Record; export class GasPrice { diff --git a/packages/launchpad/src/index.ts b/packages/launchpad/src/index.ts index 6231d334..210f8e40 100644 --- a/packages/launchpad/src/index.ts +++ b/packages/launchpad/src/index.ts @@ -5,6 +5,8 @@ export { AminoMsg as Msg, AminoSignResponse, Coin, + coin, + coins, KdfConfiguration, OfflineAminoSigner as OfflineSigner, Secp256k1HdWallet, @@ -23,6 +25,7 @@ export { executeKdf, makeCosmoshubPath, makeSignDoc, + parseCoins, pubkeyToAddress, pubkeyType, serializeSignDoc, @@ -34,7 +37,6 @@ export type PubKey = SinglePubkey; import * as logs from "./logs"; export { logs }; -export { coin, coins, parseCoins } from "./coins"; export { Account, assertIsBroadcastTxSuccess, diff --git a/packages/launchpad/src/lcdapi/distribution.spec.ts b/packages/launchpad/src/lcdapi/distribution.spec.ts index c28b34f1..c2d320e8 100644 --- a/packages/launchpad/src/lcdapi/distribution.spec.ts +++ b/packages/launchpad/src/lcdapi/distribution.spec.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino"; +import { coin, coins, makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino"; import { Bech32 } from "@cosmjs/encoding"; import { sleep } from "@cosmjs/utils"; -import { coin, coins } from "../coins"; import { assertIsBroadcastTxSuccess } from "../cosmosclient"; import { MsgDelegate } from "../msgs"; import { SigningCosmosClient } from "../signingcosmosclient"; diff --git a/packages/launchpad/src/lcdapi/gov.spec.ts b/packages/launchpad/src/lcdapi/gov.spec.ts index 94fe81d3..8fe54e47 100644 --- a/packages/launchpad/src/lcdapi/gov.spec.ts +++ b/packages/launchpad/src/lcdapi/gov.spec.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino"; +import { coins, makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino"; import { sleep } from "@cosmjs/utils"; -import { coins } from "../coins"; import { assertIsBroadcastTxSuccess } from "../cosmosclient"; import { SigningCosmosClient } from "../signingcosmosclient"; import { diff --git a/packages/launchpad/src/lcdapi/staking.spec.ts b/packages/launchpad/src/lcdapi/staking.spec.ts index 0dcf12c1..90ff26f9 100644 --- a/packages/launchpad/src/lcdapi/staking.spec.ts +++ b/packages/launchpad/src/lcdapi/staking.spec.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino"; +import { coin, coins, makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino"; import { assert, sleep } from "@cosmjs/utils"; -import { coin, coins } from "../coins"; import { assertIsBroadcastTxSuccess } from "../cosmosclient"; import { MsgDelegate, MsgUndelegate } from "../msgs"; import { SigningCosmosClient } from "../signingcosmosclient"; diff --git a/packages/launchpad/src/signingcosmosclient.spec.ts b/packages/launchpad/src/signingcosmosclient.spec.ts index 4763d583..244ce067 100644 --- a/packages/launchpad/src/signingcosmosclient.spec.ts +++ b/packages/launchpad/src/signingcosmosclient.spec.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { Coin, makeCosmoshubPath, Secp256k1HdWallet } from "@cosmjs/amino"; +import { Coin, coin, coins, makeCosmoshubPath, Secp256k1HdWallet } from "@cosmjs/amino"; import { assert } from "@cosmjs/utils"; -import { coin, coins } from "./coins"; import { assertIsBroadcastTxSuccess, PrivateCosmosClient } from "./cosmosclient"; import { GasPrice } from "./fee"; import { MsgDelegate, MsgSend } from "./msgs"; diff --git a/packages/launchpad/src/tx.spec.ts b/packages/launchpad/src/tx.spec.ts index bb6d11f7..9fec53b4 100644 --- a/packages/launchpad/src/tx.spec.ts +++ b/packages/launchpad/src/tx.spec.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { StdFee, StdSignature } from "@cosmjs/amino"; +import { coins, StdFee, StdSignature } from "@cosmjs/amino"; import { makeSignDoc } from "@cosmjs/amino/build/signdoc"; -import { coins } from "./coins"; import { makeStdTx } from "./tx"; describe("tx", () => { diff --git a/packages/proto-signing/src/coins.spec.ts b/packages/proto-signing/src/coins.spec.ts deleted file mode 100644 index 5f74c4cb..00000000 --- a/packages/proto-signing/src/coins.spec.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { coin, coins, parseCoins } from "./coins"; - -describe("coins", () => { - describe("coin", () => { - it("works for basic values", () => { - expect(coin(123, "utoken")).toEqual({ amount: "123", denom: "utoken" }); - expect(coin(123.0, "utoken")).toEqual({ amount: "123", denom: "utoken" }); - expect(coin(Number.MAX_SAFE_INTEGER, "utoken")).toEqual({ - amount: "9007199254740991", - denom: "utoken", - }); - expect(coin(+0, "utoken")).toEqual({ amount: "0", denom: "utoken" }); - expect(coin(-0, "utoken")).toEqual({ amount: "0", denom: "utoken" }); - }); - - it("throws for non-safe-integer values", () => { - expect(() => coin(1.23, "utoken")).toThrow(); - expect(() => coin(NaN, "utoken")).toThrow(); - expect(() => coin(Number.POSITIVE_INFINITY, "utoken")).toThrow(); - expect(() => coin(Number.MAX_SAFE_INTEGER + 1, "utoken")).toThrow(); - }); - - it("throws for negative values", () => { - expect(() => coin(-1, "utoken")).toThrow(); - expect(() => coin(Number.MIN_SAFE_INTEGER, "utoken")).toThrow(); - expect(() => coin(Number.NEGATIVE_INFINITY, "utoken")).toThrow(); - }); - }); - - describe("coins", () => { - it("returns one element array of coin", () => { - expect(coins(123, "utoken")).toEqual([{ amount: "123", denom: "utoken" }]); - }); - }); - - describe("parseCoins", () => { - it("works for empty", () => { - expect(parseCoins("")).toEqual([]); - }); - - it("works for one element", () => { - expect(parseCoins("7643ureef")).toEqual([ - { - amount: "7643", - denom: "ureef", - }, - ]); - }); - - it("works for two", () => { - expect(parseCoins("819966000ucosm,700000000ustake")).toEqual([ - { - amount: "819966000", - denom: "ucosm", - }, - { - amount: "700000000", - denom: "ustake", - }, - ]); - }); - - it("ignores empty elements", () => { - // start - expect(parseCoins(",819966000ucosm,700000000ustake")).toEqual([ - { - amount: "819966000", - denom: "ucosm", - }, - { - amount: "700000000", - denom: "ustake", - }, - ]); - // middle - expect(parseCoins("819966000ucosm,,700000000ustake")).toEqual([ - { - amount: "819966000", - denom: "ucosm", - }, - { - amount: "700000000", - denom: "ustake", - }, - ]); - // end - expect(parseCoins("819966000ucosm,700000000ustake,")).toEqual([ - { - amount: "819966000", - denom: "ucosm", - }, - { - amount: "700000000", - denom: "ustake", - }, - ]); - }); - - it("throws for invalid inputs", () => { - // denom missing - expect(() => parseCoins("3456")).toThrowError(/invalid coin string/i); - - // amount missing - expect(() => parseCoins("ucosm")).toThrowError(/invalid coin string/i); - }); - }); -}); diff --git a/packages/proto-signing/src/coins.ts b/packages/proto-signing/src/coins.ts deleted file mode 100644 index ec6881c0..00000000 --- a/packages/proto-signing/src/coins.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Uint53, Uint64 } from "@cosmjs/math"; - -/** - * This is the same as Coin from @cosmjs/launchpad but those might diverge in the future. - */ -export interface Coin { - readonly denom: string; - readonly amount: string; -} - -/** - * Creates a coin. - * - * This is the same as coin from @cosmjs/launchpad but those might diverge in the future. - */ -export function coin(amount: number, denom: string): Coin { - return { amount: new Uint53(amount).toString(), denom: denom }; -} - -/** - * Creates a list of coins with one element - * - * This is the same as coins from @cosmjs/launchpad but those might diverge in the future. - */ -export function coins(amount: number, denom: string): Coin[] { - return [coin(amount, denom)]; -} - -/** - * Takes a coins list like "819966000ucosm,700000000ustake" and parses it - * - * This is the same as parseCoins from @cosmjs/launchpad but those might diverge in the future. - */ -export function parseCoins(input: string): Coin[] { - return input - .replace(/\s/g, "") - .split(",") - .filter(Boolean) - .map((part) => { - const match = part.match(/^([0-9]+)([a-zA-Z]+)/); - if (!match) throw new Error("Got an invalid coin string"); - return { - amount: Uint64.fromString(match[1]).toString(), - denom: match[2], - }; - }); -} diff --git a/packages/proto-signing/src/directsecp256k1hdwallet.spec.ts b/packages/proto-signing/src/directsecp256k1hdwallet.spec.ts index 59b86612..1c6e99db 100644 --- a/packages/proto-signing/src/directsecp256k1hdwallet.spec.ts +++ b/packages/proto-signing/src/directsecp256k1hdwallet.spec.ts @@ -1,7 +1,7 @@ +import { coins } from "@cosmjs/amino"; import { Secp256k1, Secp256k1Signature, sha256 } from "@cosmjs/crypto"; import { fromBase64, fromHex } from "@cosmjs/encoding"; -import { coins } from "./coins"; import { DirectSecp256k1HdWallet } from "./directsecp256k1hdwallet"; import { makeAuthInfoBytes, makeSignBytes, makeSignDoc } from "./signing"; import { faucet, testVectors } from "./testutils.spec"; diff --git a/packages/proto-signing/src/directsecp256k1wallet.spec.ts b/packages/proto-signing/src/directsecp256k1wallet.spec.ts index a90d123c..933403e8 100644 --- a/packages/proto-signing/src/directsecp256k1wallet.spec.ts +++ b/packages/proto-signing/src/directsecp256k1wallet.spec.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/naming-convention */ +import { coins } from "@cosmjs/amino"; import { Secp256k1, Secp256k1Signature, sha256 } from "@cosmjs/crypto"; import { fromBase64, fromHex } from "@cosmjs/encoding"; -import { coins } from "./coins"; import { DirectSecp256k1Wallet } from "./directsecp256k1wallet"; import { makeAuthInfoBytes, makeSignBytes, makeSignDoc } from "./signing"; import { testVectors } from "./testutils.spec"; diff --git a/packages/proto-signing/src/index.ts b/packages/proto-signing/src/index.ts index a27372db..ea5182c9 100644 --- a/packages/proto-signing/src/index.ts +++ b/packages/proto-signing/src/index.ts @@ -1,4 +1,6 @@ -export { Coin, coin, coins, parseCoins } from "./coins"; +// This type happens to be shared between Amino and Direct sign modes +export { Coin, coin, coins, parseCoins } from "@cosmjs/amino"; + export { isPbjsGeneratedType, isTsProtoGeneratedType, diff --git a/packages/stargate/src/fee.ts b/packages/stargate/src/fee.ts index f82f0ddd..628c0350 100644 --- a/packages/stargate/src/fee.ts +++ b/packages/stargate/src/fee.ts @@ -1,13 +1,6 @@ +import { StdFee } from "@cosmjs/amino"; import { Decimal, Uint53 } from "@cosmjs/math"; -import { Coin, coins } from "@cosmjs/proto-signing"; - -/** - * This is the same as StdFee from @cosmjs/launchpad but those might diverge in the future. - */ -export interface StdFee { - readonly amount: readonly Coin[]; - readonly gas: string; -} +import { coins } from "@cosmjs/proto-signing"; /** * This is the same as FeeTable from @cosmjs/launchpad but those might diverge in the future. diff --git a/packages/stargate/src/index.ts b/packages/stargate/src/index.ts index fe379222..6dd9e6eb 100644 --- a/packages/stargate/src/index.ts +++ b/packages/stargate/src/index.ts @@ -1,8 +1,9 @@ +export { StdFee } from "@cosmjs/amino"; export { Coin, coin, coins, parseCoins } from "@cosmjs/proto-signing"; export { Account, accountFromAny } from "./accounts"; export { AminoConverter, AminoTypes } from "./aminotypes"; -export { buildFeeTable, FeeTable, GasLimits, GasPrice, StdFee } from "./fee"; +export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./fee"; export * as logs from "./logs"; export { makeMultisignedTx } from "./multisignature"; export { @@ -21,8 +22,20 @@ export { setupStakingExtension, StakingExtension, } from "./queries"; +export { + SearchByHeightQuery, + SearchBySentFromOrToQuery, + SearchByTagsQuery, + SearchTxQuery, + SearchTxFilter, + isSearchByHeightQuery, + isSearchBySentFromOrToQuery, + isSearchByTagsQuery, +} from "./search"; export { assertIsBroadcastTxSuccess, + Block, + BlockHeader, BroadcastTxFailure, BroadcastTxResponse, BroadcastTxSuccess, @@ -34,6 +47,7 @@ export { StargateClient, } from "./stargateclient"; export { + CosmosFeeTable, defaultRegistryTypes, SignerData, SigningStargateClient, diff --git a/packages/stargate/src/multisignature.ts b/packages/stargate/src/multisignature.ts index 08b579c8..4d3e91f9 100644 --- a/packages/stargate/src/multisignature.ts +++ b/packages/stargate/src/multisignature.ts @@ -1,3 +1,4 @@ +import { StdFee } from "@cosmjs/amino"; import { Bech32 } from "@cosmjs/encoding"; import { encodePubkey } from "@cosmjs/proto-signing"; import Long from "long"; @@ -7,7 +8,6 @@ import { CompactBitArray, MultiSignature } from "./codec/cosmos/crypto/multisig/ import { SignMode } from "./codec/cosmos/tx/signing/v1beta1/signing"; import { AuthInfo, SignerInfo } from "./codec/cosmos/tx/v1beta1/tx"; import { TxRaw } from "./codec/cosmos/tx/v1beta1/tx"; -import { StdFee } from "./fee"; export function makeCompactBitArray(bits: readonly boolean[]): CompactBitArray { const byteCount = Math.ceil(bits.length / 8); diff --git a/packages/stargate/src/search.ts b/packages/stargate/src/search.ts new file mode 100644 index 00000000..aae61508 --- /dev/null +++ b/packages/stargate/src/search.ts @@ -0,0 +1,34 @@ +export interface SearchByHeightQuery { + readonly height: number; +} + +export interface SearchBySentFromOrToQuery { + readonly sentFromOrTo: string; +} + +/** + * This query type allows you to pass arbitrary key/value pairs to the backend. It is + * more powerful and slightly lower level than the other search options. + */ +export interface SearchByTagsQuery { + readonly tags: ReadonlyArray<{ readonly key: string; readonly value: string }>; +} + +export type SearchTxQuery = SearchByHeightQuery | SearchBySentFromOrToQuery | SearchByTagsQuery; + +export function isSearchByHeightQuery(query: SearchTxQuery): query is SearchByHeightQuery { + return (query as SearchByHeightQuery).height !== undefined; +} + +export function isSearchBySentFromOrToQuery(query: SearchTxQuery): query is SearchBySentFromOrToQuery { + return (query as SearchBySentFromOrToQuery).sentFromOrTo !== undefined; +} + +export function isSearchByTagsQuery(query: SearchTxQuery): query is SearchByTagsQuery { + return (query as SearchByTagsQuery).tags !== undefined; +} + +export interface SearchTxFilter { + readonly minHeight?: number; + readonly maxHeight?: number; +} diff --git a/packages/stargate/src/signingstargateclient.ts b/packages/stargate/src/signingstargateclient.ts index 271b5069..6a875f57 100644 --- a/packages/stargate/src/signingstargateclient.ts +++ b/packages/stargate/src/signingstargateclient.ts @@ -1,6 +1,5 @@ -import { encodeSecp256k1Pubkey, makeSignDoc as makeSignDocAmino } from "@cosmjs/amino"; +import { encodeSecp256k1Pubkey, makeSignDoc as makeSignDocAmino, StdFee } from "@cosmjs/amino"; import { fromBase64 } from "@cosmjs/encoding"; -import { CosmosFeeTable } from "@cosmjs/launchpad"; import { Int53 } from "@cosmjs/math"; import { EncodeObject, @@ -57,9 +56,18 @@ import { MsgConnectionOpenInit, MsgConnectionOpenTry, } from "./codec/ibc/core/connection/v1/tx"; -import { buildFeeTable, GasLimits, GasPrice, StdFee } from "./fee"; +import { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./fee"; import { BroadcastTxResponse, StargateClient } from "./stargateclient"; +/** + * These fees are used by the higher level methods of SigningCosmosClient + * + * This is the same as CosmosFeeTable from @cosmjs/launchpad but those might diverge in the future. + */ +export interface CosmosFeeTable extends FeeTable { + readonly send: StdFee; +} + const defaultGasPrice = GasPrice.fromString("0.025ucosm"); const defaultGasLimits: GasLimits = { send: 80000 }; diff --git a/packages/stargate/src/stargateclient.ts b/packages/stargate/src/stargateclient.ts index 6ba5914a..8ee069bd 100644 --- a/packages/stargate/src/stargateclient.ts +++ b/packages/stargate/src/stargateclient.ts @@ -1,13 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { toHex } from "@cosmjs/encoding"; -import { - Block, - isSearchByHeightQuery, - isSearchBySentFromOrToQuery, - isSearchByTagsQuery, - SearchTxFilter, - SearchTxQuery, -} from "@cosmjs/launchpad"; import { Uint53 } from "@cosmjs/math"; import { broadcastTxCommitSuccess, @@ -20,6 +12,38 @@ import { Account, accountFromAny } from "./accounts"; import { MsgData, TxMsgData } from "./codec/cosmos/base/abci/v1beta1/abci"; import { Coin } from "./codec/cosmos/base/v1beta1/coin"; import { AuthExtension, BankExtension, QueryClient, setupAuthExtension, setupBankExtension } from "./queries"; +import { + isSearchByHeightQuery, + isSearchBySentFromOrToQuery, + isSearchByTagsQuery, + SearchTxFilter, + SearchTxQuery, +} from "./search"; + +/** + * This is the same as BlockHeader from @cosmjs/launchpad but those might diverge in the future. + */ +export interface BlockHeader { + readonly version: { + readonly block: string; + readonly app: string; + }; + readonly height: number; + readonly chainId: string; + /** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */ + readonly time: string; +} + +/** + * This is the same as Block from @cosmjs/launchpad but those might diverge in the future. + */ +export interface Block { + /** The ID is a hash of the block header (uppercase hex) */ + readonly id: string; + readonly header: BlockHeader; + /** Array of raw transactions */ + readonly txs: readonly Uint8Array[]; +} /** A transaction that is indexed as part of the transaction history */ export interface IndexedTx {