UNPKG

@dojima-wallet/connection

Version:

Initialise and connection for layer 1&2 blockchain

107 lines (106 loc) 3.46 kB
import { cosmosclient, proto } from "@cosmos-client/core"; import { cosmos } from "@cosmos-client/core/cjs/proto"; import { Fees, RootDerivationPaths, Tx } from "../client"; import { Asset, BaseAmount } from "@dojima-wallet/utils"; import BigNumber from "bignumber.js"; import Long from "long"; import { APIQueryParam, TxResponse, UnsignedTxParams } from "./cosmos"; import { ChainId, ChainIds, ClientUrls as ClientUrls } from "./types"; /** * Type guard for MsgSend * * @param {Msg} msg * @returns {boolean} `true` or `false`. */ export declare const isMsgSend: (msg: unknown) => msg is cosmos.bank.v1beta1.MsgSend; /** * Type guard for MsgMultiSend * * @param {Msg} msg * @returns {boolean} `true` or `false`. */ export declare const isMsgMultiSend: (msg: unknown) => msg is cosmos.bank.v1beta1.MsgMultiSend; /** * Get denomination from Asset - currently `ATOM` supported only * * @param {Asset} asset * @returns {string} The denomination of the given asset. */ export declare const getDenom: (asset: Asset) => string | null; /** * Get Asset from denomination * * @param {string} denom * @returns {Asset|null} The asset of the given denomination. */ export declare const getAsset: (denom: string) => Asset | null; /** * Parses transaction history * * @param {TxResponse[]} txs The transaction response from the node. * @param {Asset} asset Asset to get history of transactions from * * @returns {Tx[]} List of transactions */ export declare const getTxsFromHistory: (txs: TxResponse[], asset: Asset) => Tx[]; /** * Get Query String * * @param {APIQueryParam} * @returns {string} The query string. */ export declare const getQueryString: (params: APIQueryParam) => string; /** * Get the default fee. * * @returns {Fees} The default fee. */ export declare const getDefaultFees: () => Fees; /** * Get address prefix based on the network. * * @returns {string} The address prefix based on the network. * **/ export declare const getPrefix: () => string; /** * Default client urls * * @returns {ClientUrls} The client urls for Cosmos. */ export declare const getDefaultClientUrls: () => ClientUrls; /** * Default chain ids * * @returns {ChainIds} Chain ids for Cosmos. */ export declare const getDefaultChainIds: () => ChainIds; export declare const getDefaultRootDerivationPaths: () => RootDerivationPaths; export declare const protoFee: ({ denom, amount, gasLimit, }: { denom: string; amount: BaseAmount; gasLimit?: BigNumber; }) => proto.cosmos.tx.v1beta1.Fee; export declare const protoMsgSend: ({ from, to, amount, denom, }: { from: string; to: string; amount: BaseAmount; denom: string; }) => proto.cosmos.bank.v1beta1.MsgSend; export declare const protoTxBody: ({ from, to, amount, denom, memo, }: UnsignedTxParams) => proto.cosmos.tx.v1beta1.TxBody; export declare const protoAuthInfo: ({ pubKey, sequence, mode, fee, }: { pubKey: cosmosclient.PubKey; sequence: Long.Long; mode: proto.cosmos.tx.signing.v1beta1.SignMode; fee?: cosmos.tx.v1beta1.IFee; }) => proto.cosmos.tx.v1beta1.AuthInfo; /** * Helper to get Cosmos' chain id * @param {string} url API url */ export declare const getChainId: (url: string) => Promise<ChainId>; /** * Helper to get Cosmos' chain id for all networks * @param {ClientUrl} urls urls (use `getDefaultClientUrl()` if you don't need to use custom urls) */ export declare const getChainIds: (urls: ClientUrls) => Promise<ChainIds>;