Merge pull request #729 from cosmos/657-independent-stargate-6

Reorganise coins/CosmosFeeTable/search types and helpers
This commit is contained in:
Simon Warta
2021-03-24 23:04:37 +01:00
committed by GitHub
25 changed files with 133 additions and 214 deletions
+2 -9
View File
@@ -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.
+15 -1
View File
@@ -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,
+1 -1
View File
@@ -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);
+34
View File
@@ -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;
}
+11 -3
View File
@@ -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<CosmosFeeTable> = { send: 80000 };
+32 -8
View File
@@ -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 {