Remove types from VCS

This commit is contained in:
willclarktech
2021-02-09 14:57:24 +00:00
parent 31cdd91991
commit 1c6f3ee9a5
151 changed files with 0 additions and 11856 deletions
-3
View File
@@ -1,3 +0,0 @@
import { PubKey } from "./types";
export declare function rawSecp256k1PubkeyToAddress(pubkeyRaw: Uint8Array, prefix: string): string;
export declare function pubkeyToAddress(pubkey: PubKey, prefix: string): string;
-12
View File
@@ -1,12 +0,0 @@
export interface Coin {
readonly denom: string;
readonly amount: string;
}
/** Creates a coin */
export declare function coin(amount: number, denom: string): Coin;
/** Creates a list of coins with one element */
export declare function coins(amount: number, denom: string): Coin[];
/**
* Takes a coins list like "819966000ucosm,700000000ustake" and parses it
*/
export declare function parseCoins(input: string): Coin[];
-143
View File
@@ -1,143 +0,0 @@
import { Coin } from "./coins";
import { AuthExtension, BroadcastMode, LcdClient } from "./lcdapi";
import { Log } from "./logs";
import { StdTx, WrappedStdTx } from "./tx";
import { PubKey } from "./types";
export interface GetSequenceResult {
readonly accountNumber: number;
readonly sequence: number;
}
export interface Account {
/** Bech32 account address */
readonly address: string;
readonly balance: readonly Coin[];
readonly pubkey: PubKey | undefined;
readonly accountNumber: number;
readonly sequence: number;
}
export interface BroadcastTxFailure {
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
readonly transactionHash: string;
readonly height: number;
readonly code: number;
readonly rawLog: string;
}
export interface BroadcastTxSuccess {
readonly logs: readonly Log[];
readonly rawLog: string;
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
readonly transactionHash: string;
readonly data?: Uint8Array;
}
export declare type BroadcastTxResult = BroadcastTxSuccess | BroadcastTxFailure;
export declare function isBroadcastTxFailure(result: BroadcastTxResult): result is BroadcastTxFailure;
export declare function isBroadcastTxSuccess(result: BroadcastTxResult): result is BroadcastTxSuccess;
/**
* Ensures the given result is a success. Throws a detailed error message otherwise.
*/
export declare function assertIsBroadcastTxSuccess(
result: BroadcastTxResult,
): asserts result is BroadcastTxSuccess;
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 declare type SearchTxQuery = SearchByHeightQuery | SearchBySentFromOrToQuery | SearchByTagsQuery;
export declare function isSearchByHeightQuery(query: SearchTxQuery): query is SearchByHeightQuery;
export declare function isSearchBySentFromOrToQuery(query: SearchTxQuery): query is SearchBySentFromOrToQuery;
export declare function isSearchByTagsQuery(query: SearchTxQuery): query is SearchByTagsQuery;
export interface SearchTxFilter {
readonly minHeight?: number;
readonly maxHeight?: number;
}
/** A transaction that is indexed as part of the transaction history */
export interface IndexedTx {
readonly height: number;
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
readonly hash: string;
/** Transaction execution error code. 0 on success. */
readonly code: number;
readonly rawLog: string;
readonly logs: readonly Log[];
readonly tx: WrappedStdTx;
/** The gas limit as set by the user */
readonly gasWanted?: number;
/** The gas used by the execution */
readonly gasUsed?: number;
/** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */
readonly timestamp: string;
}
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;
}
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[];
}
/** Use for testing only */
export interface PrivateCosmosClient {
readonly lcdClient: LcdClient & AuthExtension;
}
export declare class CosmosClient {
protected readonly lcdClient: LcdClient & AuthExtension;
/** Any address the chain considers valid (valid bech32 with proper prefix) */
protected anyValidAddress: string | undefined;
private chainId;
/**
* Creates a new client to interact with a CosmWasm blockchain.
*
* This instance does a lot of caching. In order to benefit from that you should try to use one instance
* for the lifetime of your application. When switching backends, a new instance must be created.
*
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
*/
constructor(apiUrl: string, broadcastMode?: BroadcastMode);
getChainId(): Promise<string>;
getHeight(): Promise<number>;
/**
* Returns a 32 byte upper-case hex transaction hash (typically used as the transaction ID)
*/
getIdentifier(tx: WrappedStdTx): Promise<string>;
/**
* Returns account number and sequence.
*
* Throws if the account does not exist on chain.
*
* @param address returns data for this address. When unset, the client's sender adddress is used.
*/
getSequence(address: string): Promise<GetSequenceResult>;
getAccount(address: string): Promise<Account | undefined>;
/**
* Gets block header and meta
*
* @param height The height of the block. If undefined, the latest height is used.
*/
getBlock(height?: number): Promise<Block>;
getTx(id: string): Promise<IndexedTx | null>;
searchTx(query: SearchTxQuery, filter?: SearchTxFilter): Promise<readonly IndexedTx[]>;
broadcastTx(tx: StdTx): Promise<BroadcastTxResult>;
private txsQuery;
}
-26
View File
@@ -1,26 +0,0 @@
import { Msg } from "./msgs";
import { StdFee } from "./types";
/** Returns a JSON string with objects sorted by key */
export declare function sortedJsonStringify(obj: any): string;
/**
* The document to be signed
*
* @see https://docs.cosmos.network/master/modules/auth/03_types.html#stdsigndoc
*/
export interface StdSignDoc {
readonly chain_id: string;
readonly account_number: string;
readonly sequence: string;
readonly fee: StdFee;
readonly msgs: readonly Msg[];
readonly memo: string;
}
export declare function makeSignDoc(
msgs: readonly Msg[],
fee: StdFee,
chainId: string,
memo: string | undefined,
accountNumber: number | string,
sequence: number | string,
): StdSignDoc;
export declare function serializeSignDoc(signDoc: StdSignDoc): Uint8Array;
-17
View File
@@ -1,17 +0,0 @@
import { Decimal } from "@cosmjs/math";
import { StdFee } from "./types";
export declare type FeeTable = Record<string, StdFee>;
export declare class GasPrice {
readonly amount: Decimal;
readonly denom: string;
constructor(amount: Decimal, denom: string);
static fromString(gasPrice: string): GasPrice;
}
export declare type GasLimits<T extends Record<string, StdFee>> = {
readonly [key in keyof T]: number;
};
export declare function buildFeeTable<T extends Record<string, StdFee>>(
gasPrice: GasPrice,
defaultGasLimits: GasLimits<T>,
gasLimits: Partial<GasLimits<T>>,
): T;
-140
View File
@@ -1,140 +0,0 @@
import * as logs from "./logs";
export { logs };
export { pubkeyToAddress, rawSecp256k1PubkeyToAddress } from "./address";
export { Coin, coin, coins, parseCoins } from "./coins";
export {
Account,
assertIsBroadcastTxSuccess,
Block,
BlockHeader,
CosmosClient,
GetSequenceResult,
IndexedTx,
isBroadcastTxFailure,
isBroadcastTxSuccess,
BroadcastTxFailure,
BroadcastTxResult,
BroadcastTxSuccess,
SearchByHeightQuery,
SearchBySentFromOrToQuery,
SearchByTagsQuery,
SearchTxQuery,
SearchTxFilter,
isSearchByHeightQuery,
isSearchBySentFromOrToQuery,
isSearchByTagsQuery,
} from "./cosmosclient";
export { makeSignDoc, serializeSignDoc, StdSignDoc } from "./encoding";
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
export {
AuthAccountsResponse,
AuthExtension,
BankBalancesResponse,
BankExtension,
BaseAccount,
BlockResponse,
BroadcastMode,
DistributionCommunityPoolResponse,
DistributionDelegatorRewardResponse,
DistributionDelegatorRewardsResponse,
DistributionExtension,
DistributionParametersResponse,
DistributionValidatorOutstandingRewardsResponse,
DistributionValidatorResponse,
DistributionValidatorRewardsResponse,
DistributionWithdrawAddressResponse,
EncodeTxResponse,
GovExtension,
GovParametersResponse,
GovProposalsResponse,
GovProposalResponse,
GovProposerResponse,
GovDepositsResponse,
GovDepositResponse,
GovTallyResponse,
GovVotesResponse,
GovVoteResponse,
LcdApiArray,
LcdClient,
MintAnnualProvisionsResponse,
MintExtension,
MintInflationResponse,
MintParametersResponse,
NodeInfoResponse,
normalizeLcdApiArray,
normalizePubkey,
BroadcastTxsResponse,
SearchTxsResponse,
setupAuthExtension,
setupBankExtension,
setupDistributionExtension,
setupGovExtension,
setupMintExtension,
setupSlashingExtension,
setupStakingExtension,
setupSupplyExtension,
SlashingExtension,
SlashingParametersResponse,
SlashingSigningInfosResponse,
StakingExtension,
StakingDelegatorDelegationsResponse,
StakingDelegatorUnbondingDelegationsResponse,
StakingDelegatorTransactionsResponse,
StakingDelegatorValidatorsResponse,
StakingDelegatorValidatorResponse,
StakingDelegationResponse,
StakingUnbondingDelegationResponse,
StakingRedelegationsResponse,
StakingValidatorsResponse,
StakingValidatorResponse,
StakingValidatorDelegationsResponse,
StakingValidatorUnbondingDelegationsResponse,
StakingHistoricalInfoResponse,
StakingParametersResponse,
StakingPoolResponse,
SupplyExtension,
TxsResponse,
uint64ToNumber,
uint64ToString,
} from "./lcdapi";
export {
isMsgBeginRedelegate,
isMsgCreateValidator,
isMsgDelegate,
isMsgEditValidator,
isMsgFundCommunityPool,
isMsgMultiSend,
isMsgSend,
isMsgSetWithdrawAddress,
isMsgUndelegate,
isMsgWithdrawDelegatorReward,
isMsgWithdrawValidatorCommission,
Msg,
MsgBeginRedelegate,
MsgCreateValidator,
MsgDelegate,
MsgEditValidator,
MsgFundCommunityPool,
MsgMultiSend,
MsgSend,
MsgSetWithdrawAddress,
MsgUndelegate,
MsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission,
} from "./msgs";
export {
decodeAminoPubkey,
decodeBech32Pubkey,
encodeAminoPubkey,
encodeBech32Pubkey,
encodeSecp256k1Pubkey,
} from "./pubkey";
export { findSequenceForSignedTx } from "./sequence";
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
export { AccountData, Algo, AminoSignResponse, OfflineSigner } from "./signer";
export { CosmosFeeTable, SigningCosmosClient } from "./signingcosmosclient";
export { isStdTx, isWrappedStdTx, makeStdTx, CosmosSdkTx, StdTx, WrappedStdTx, WrappedTx } from "./tx";
export { pubkeyType, PubKey, StdFee, StdSignature } from "./types";
export { makeCosmoshubPath, executeKdf, KdfConfiguration } from "./wallet";
export { extractKdfConfiguration, Secp256k1HdWallet } from "./secp256k1hdwallet";
export { Secp256k1Wallet } from "./secp256k1wallet";
-60
View File
@@ -1,60 +0,0 @@
import { Coin } from "../coins";
import { PubKey } from "../types";
import { LcdClient } from "./lcdclient";
/**
* A Cosmos SDK base account.
*
* This type describes the base account representation as returned
* by the Cosmos SDK 0.370.39 LCD API.
*
* @see https://docs.cosmos.network/master/modules/auth/02_state.html#base-account
*/
export interface BaseAccount {
/** Bech32 account address */
readonly address: string;
readonly coins: readonly Coin[];
/**
* The public key of the account. This is not available on-chain as long as the account
* did not send a transaction.
*
* This was a type/value object in Cosmos SDK 0.37, changed to bech32 in Cosmos SDK 0.38 ([1])
* and changed back to type/value object in Cosmos SDK 0.39 ([2]).
*
* [1]: https://github.com/cosmos/cosmos-sdk/pull/5280
* [2]: https://github.com/cosmos/cosmos-sdk/pull/6749
*/
readonly public_key: string | PubKey | null;
/**
* The account number assigned by the blockchain.
*
* This was string encoded in Cosmos SDK 0.37, changed to number in Cosmos SDK 0.38 ([1])
* and changed back to string in Cosmos SDK 0.39 ([2]).
*
* [1]: https://github.com/cosmos/cosmos-sdk/pull/5280
* [2]: https://github.com/cosmos/cosmos-sdk/pull/6749
*/
readonly account_number: number | string;
/**
* The sequence number for replay protection.
*
* This was string encoded in Cosmos SDK 0.37, changed to number in Cosmos SDK 0.38 ([1])
* and changed back to string in Cosmos SDK 0.39 ([2]).
*
* [1]: https://github.com/cosmos/cosmos-sdk/pull/5280
* [2]: https://github.com/cosmos/cosmos-sdk/pull/6749
*/
readonly sequence: number | string;
}
export interface AuthAccountsResponse {
readonly height: string;
readonly result: {
readonly type: "cosmos-sdk/Account";
readonly value: BaseAccount;
};
}
export interface AuthExtension {
readonly auth: {
readonly account: (address: string) => Promise<AuthAccountsResponse>;
};
}
export declare function setupAuthExtension(base: LcdClient): AuthExtension;
-12
View File
@@ -1,12 +0,0 @@
import { Coin } from "../coins";
import { LcdClient } from "./lcdclient";
export interface BankBalancesResponse {
readonly height: string;
readonly result: readonly Coin[];
}
export interface BankExtension {
readonly bank: {
readonly balances: (address: string) => Promise<BankBalancesResponse>;
};
}
export declare function setupBankExtension(base: LcdClient): BankExtension;
-129
View File
@@ -1,129 +0,0 @@
import { WrappedStdTx } from "../tx";
/**
* 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 after CheckTx */
Sync = "sync",
/** Return right away */
Async = "async",
}
/** A response 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;
}
export 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 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?: unknown[];
readonly tx: WrappedStdTx;
/** 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 BroadcastTxsResponse {
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?: unknown[];
/** The gas limit as set by the user */
readonly gas_wanted?: string;
/** The gas used by the execution */
readonly gas_used?: string;
}
export {};
-68
View File
@@ -1,68 +0,0 @@
import { Coin } from "../coins";
import { LcdClient } from "./lcdclient";
export interface RewardContainer {
readonly validator_address: string;
readonly reward: readonly Coin[] | null;
}
export interface DistributionDelegatorRewardsResponse {
readonly height: string;
readonly result: {
readonly rewards: readonly RewardContainer[] | null;
readonly total: readonly Coin[] | null;
};
}
export interface DistributionDelegatorRewardResponse {
readonly height: string;
readonly result: readonly Coin[];
}
export interface DistributionWithdrawAddressResponse {
readonly height: string;
readonly result: string;
}
export interface DistributionValidatorResponse {
readonly height: string;
readonly result: {
readonly operator_address: string;
readonly self_bond_rewards: readonly Coin[];
readonly val_commission: readonly Coin[];
};
}
export interface DistributionValidatorRewardsResponse {
readonly height: string;
readonly result: readonly Coin[];
}
export interface DistributionValidatorOutstandingRewardsResponse {
readonly height: string;
readonly result: readonly Coin[];
}
export interface DistributionParametersResponse {
readonly height: string;
readonly result: {
readonly community_tax: string;
readonly base_proposer_reward: string;
readonly bonus_proposer_reward: string;
readonly withdraw_addr_enabled: boolean;
};
}
export interface DistributionCommunityPoolResponse {
readonly height: string;
readonly result: readonly Coin[];
}
export interface DistributionExtension {
readonly distribution: {
readonly delegatorRewards: (delegatorAddress: string) => Promise<DistributionDelegatorRewardsResponse>;
readonly delegatorReward: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<DistributionDelegatorRewardResponse>;
readonly withdrawAddress: (delegatorAddress: string) => Promise<DistributionWithdrawAddressResponse>;
readonly validator: (validatorAddress: string) => Promise<DistributionValidatorResponse>;
readonly validatorRewards: (validatorAddress: string) => Promise<DistributionValidatorRewardsResponse>;
readonly validatorOutstandingRewards: (
validatorAddress: string,
) => Promise<DistributionValidatorOutstandingRewardsResponse>;
readonly parameters: () => Promise<DistributionParametersResponse>;
readonly communityPool: () => Promise<DistributionCommunityPoolResponse>;
};
}
export declare function setupDistributionExtension(base: LcdClient): DistributionExtension;
-114
View File
@@ -1,114 +0,0 @@
import { Coin } from "../coins";
import { LcdClient } from "./lcdclient";
export declare enum GovParametersType {
Deposit = "deposit",
Tallying = "tallying",
Voting = "voting",
}
export interface GovParametersDepositResponse {
readonly height: string;
readonly result: {
readonly min_deposit: readonly Coin[];
readonly max_deposit_period: string;
};
}
export interface GovParametersTallyingResponse {
readonly height: string;
readonly result: {
readonly quorum: string;
readonly threshold: string;
readonly veto: string;
};
}
export interface GovParametersVotingResponse {
readonly height: string;
readonly result: {
readonly voting_period: string;
};
}
export declare type GovParametersResponse =
| GovParametersDepositResponse
| GovParametersTallyingResponse
| GovParametersVotingResponse;
export interface Tally {
readonly yes: string;
readonly abstain: string;
readonly no: string;
readonly no_with_veto: string;
}
export interface Proposal {
readonly id: string;
readonly proposal_status: string;
readonly final_tally_result: Tally;
readonly submit_time: string;
readonly total_deposit: readonly Coin[];
readonly deposit_end_time: string;
readonly voting_start_time: string;
readonly voting_end_time: string;
readonly content: {
readonly type: string;
readonly value: {
readonly title: string;
readonly description: string;
};
};
}
export interface GovProposalsResponse {
readonly height: string;
readonly result: readonly Proposal[];
}
export interface GovProposalResponse {
readonly height: string;
readonly result: Proposal;
}
export interface GovProposerResponse {
readonly height: string;
readonly result: {
readonly proposal_id: string;
readonly proposer: string;
};
}
export interface Deposit {
readonly amount: readonly Coin[];
readonly proposal_id: string;
readonly depositor: string;
}
export interface GovDepositsResponse {
readonly height: string;
readonly result: readonly Deposit[];
}
export interface GovDepositResponse {
readonly height: string;
readonly result: Deposit;
}
export interface GovTallyResponse {
readonly height: string;
readonly result: Tally;
}
export interface Vote {
readonly voter: string;
readonly proposal_id: string;
readonly option: string;
}
export interface GovVotesResponse {
readonly height: string;
readonly result: readonly Vote[];
}
export interface GovVoteResponse {
readonly height: string;
readonly result: Vote;
}
export interface GovExtension {
readonly gov: {
readonly parameters: (parametersType: GovParametersType) => Promise<GovParametersResponse>;
readonly proposals: () => Promise<GovProposalsResponse>;
readonly proposal: (proposalId: string) => Promise<GovProposalResponse>;
readonly proposer: (proposalId: string) => Promise<GovProposerResponse>;
readonly deposits: (proposalId: string) => Promise<GovDepositsResponse>;
readonly deposit: (proposalId: string, depositorAddress: string) => Promise<GovDepositResponse>;
readonly tally: (proposalId: string) => Promise<GovTallyResponse>;
readonly votes: (proposalId: string) => Promise<GovVotesResponse>;
readonly vote: (proposalId: string, voterAddress: string) => Promise<GovVoteResponse>;
};
}
export declare function setupGovExtension(base: LcdClient): GovExtension;
-71
View File
@@ -1,71 +0,0 @@
export { AuthExtension, AuthAccountsResponse, BaseAccount, setupAuthExtension } from "./auth";
export { BankBalancesResponse, BankExtension, setupBankExtension } from "./bank";
export {
DistributionCommunityPoolResponse,
DistributionDelegatorRewardResponse,
DistributionDelegatorRewardsResponse,
DistributionExtension,
DistributionParametersResponse,
DistributionValidatorOutstandingRewardsResponse,
DistributionValidatorResponse,
DistributionValidatorRewardsResponse,
DistributionWithdrawAddressResponse,
setupDistributionExtension,
} from "./distribution";
export {
GovExtension,
GovParametersResponse,
GovProposalsResponse,
GovProposalResponse,
GovProposerResponse,
GovDepositsResponse,
GovDepositResponse,
GovTallyResponse,
GovVotesResponse,
GovVoteResponse,
setupGovExtension,
} from "./gov";
export {
MintAnnualProvisionsResponse,
MintExtension,
MintInflationResponse,
MintParametersResponse,
setupMintExtension,
} from "./mint";
export {
setupSlashingExtension,
SlashingExtension,
SlashingParametersResponse,
SlashingSigningInfosResponse,
} from "./slashing";
export {
setupStakingExtension,
StakingDelegatorDelegationsResponse,
StakingDelegatorUnbondingDelegationsResponse,
StakingDelegatorTransactionsResponse,
StakingDelegatorValidatorsResponse,
StakingDelegatorValidatorResponse,
StakingDelegationResponse,
StakingUnbondingDelegationResponse,
StakingRedelegationsResponse,
StakingValidatorsResponse,
StakingValidatorResponse,
StakingValidatorDelegationsResponse,
StakingValidatorUnbondingDelegationsResponse,
StakingHistoricalInfoResponse,
StakingExtension,
StakingParametersResponse,
StakingPoolResponse,
} from "./staking";
export { setupSupplyExtension, SupplyExtension, TotalSupplyAllResponse, TotalSupplyResponse } from "./supply";
export {
BlockResponse,
BroadcastMode,
EncodeTxResponse,
BroadcastTxsResponse,
NodeInfoResponse,
SearchTxsResponse,
TxsResponse,
} from "./base";
export { LcdApiArray, LcdClient, normalizeLcdApiArray } from "./lcdclient";
export { normalizePubkey, uint64ToNumber, uint64ToString } from "./utils";
-164
View File
@@ -1,164 +0,0 @@
import { StdTx, WrappedStdTx } from "../tx";
import {
BlockResponse,
BroadcastMode,
BroadcastTxsResponse,
EncodeTxResponse,
NodeInfoResponse,
SearchTxsResponse,
TxsResponse,
} from "./base";
/** Unfortunately, Cosmos SDK encodes empty arrays as null */
export declare type LcdApiArray<T> = readonly T[] | null;
export declare function normalizeLcdApiArray<T>(backend: LcdApiArray<T>): readonly T[];
declare type LcdExtensionSetup<P> = (base: LcdClient) => P;
export interface LcdClientBaseOptions {
readonly apiUrl: string;
readonly broadcastMode?: BroadcastMode;
}
/**
* A client to the LCD's (light client daemon) API.
* This light client connects to Tendermint (i.e. the chain), encodes/decodes Amino data for us and provides a convenient JSON interface.
*
* This _JSON over HTTP_ API is sometimes referred to as "REST" or "RPC", which are both misleading terms
* for the same thing.
*
* Please note that the client to the LCD can not verify light client proofs. When using this,
* you need to trust the API provider as well as the network connection between client and API.
*
* @see https://cosmos.network/rpc
*/
export declare class LcdClient {
/** Constructs an LCD client with 0 extensions */
static withExtensions(options: LcdClientBaseOptions): LcdClient;
/** Constructs an LCD client with 1 extension */
static withExtensions<A extends object>(
options: LcdClientBaseOptions,
setupExtensionA: LcdExtensionSetup<A>,
): LcdClient & A;
/** Constructs an LCD client with 2 extensions */
static withExtensions<A extends object, B extends object>(
options: LcdClientBaseOptions,
setupExtensionA: LcdExtensionSetup<A>,
setupExtensionB: LcdExtensionSetup<B>,
): LcdClient & A & B;
/** Constructs an LCD client with 3 extensions */
static withExtensions<A extends object, B extends object, C extends object>(
options: LcdClientBaseOptions,
setupExtensionA: LcdExtensionSetup<A>,
setupExtensionB: LcdExtensionSetup<B>,
setupExtensionC: LcdExtensionSetup<C>,
): LcdClient & A & B & C;
/** Constructs an LCD client with 4 extensions */
static withExtensions<A extends object, B extends object, C extends object, D extends object>(
options: LcdClientBaseOptions,
setupExtensionA: LcdExtensionSetup<A>,
setupExtensionB: LcdExtensionSetup<B>,
setupExtensionC: LcdExtensionSetup<C>,
setupExtensionD: LcdExtensionSetup<D>,
): LcdClient & A & B & C & D;
/** Constructs an LCD client with 5 extensions */
static withExtensions<
A extends object,
B extends object,
C extends object,
D extends object,
E extends object
>(
options: LcdClientBaseOptions,
setupExtensionA: LcdExtensionSetup<A>,
setupExtensionB: LcdExtensionSetup<B>,
setupExtensionC: LcdExtensionSetup<C>,
setupExtensionD: LcdExtensionSetup<D>,
setupExtensionE: LcdExtensionSetup<E>,
): LcdClient & A & B & C & D & E;
/** Constructs an LCD client with 6 extensions */
static withExtensions<
A extends object,
B extends object,
C extends object,
D extends object,
E extends object,
F extends object
>(
options: LcdClientBaseOptions,
setupExtensionA: LcdExtensionSetup<A>,
setupExtensionB: LcdExtensionSetup<B>,
setupExtensionC: LcdExtensionSetup<C>,
setupExtensionD: LcdExtensionSetup<D>,
setupExtensionE: LcdExtensionSetup<E>,
setupExtensionF: LcdExtensionSetup<F>,
): LcdClient & A & B & C & D & E & F;
/** Constructs an LCD client with 7 extensions */
static withExtensions<
A extends object,
B extends object,
C extends object,
D extends object,
E extends object,
F extends object,
G extends object
>(
options: LcdClientBaseOptions,
setupExtensionA: LcdExtensionSetup<A>,
setupExtensionB: LcdExtensionSetup<B>,
setupExtensionC: LcdExtensionSetup<C>,
setupExtensionD: LcdExtensionSetup<D>,
setupExtensionE: LcdExtensionSetup<E>,
setupExtensionF: LcdExtensionSetup<F>,
setupExtensionG: LcdExtensionSetup<G>,
): LcdClient & A & B & C & D & E & F & G;
/** Constructs an LCD client with 8 extensions */
static withExtensions<
A extends object,
B extends object,
C extends object,
D extends object,
E extends object,
F extends object,
G extends object,
H extends object
>(
options: LcdClientBaseOptions,
setupExtensionA: LcdExtensionSetup<A>,
setupExtensionB: LcdExtensionSetup<B>,
setupExtensionC: LcdExtensionSetup<C>,
setupExtensionD: LcdExtensionSetup<D>,
setupExtensionE: LcdExtensionSetup<E>,
setupExtensionF: LcdExtensionSetup<F>,
setupExtensionG: LcdExtensionSetup<G>,
setupExtensionH: LcdExtensionSetup<H>,
): LcdClient & A & B & C & D & E & F & G & H;
private readonly client;
private readonly broadcastMode;
/**
* Creates a new client to interact with a Cosmos SDK light client daemon.
* This class tries to be a direct mapping onto the API. Some basic decoding and normalizatin is done
* but things like caching are done at a higher level.
*
* When building apps, you should not need to use this class directly. If you do, this indicates a missing feature
* in higher level components. Feel free to raise an issue in this case.
*
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
*/
constructor(apiUrl: string, broadcastMode?: BroadcastMode);
get(path: string, params?: Record<string, any>): Promise<any>;
post(path: string, params: any): Promise<any>;
blocksLatest(): Promise<BlockResponse>;
blocks(height: number): Promise<BlockResponse>;
nodeInfo(): Promise<NodeInfoResponse>;
txById(id: string): Promise<TxsResponse>;
txsQuery(query: string): Promise<SearchTxsResponse>;
/** returns the amino-encoding of the transaction performed by the server */
encodeTx(tx: WrappedStdTx): Promise<EncodeTxResponse>;
/**
* Broadcasts a signed transaction to the transaction pool.
* Depending on the client's broadcast mode, this might or might
* wait for checkTx or deliverTx to be executed before returning.
*
* @param tx a signed transaction as StdTx (i.e. not wrapped in type/value container)
*/
broadcastTx(tx: StdTx): Promise<BroadcastTxsResponse>;
}
export {};
-28
View File
@@ -1,28 +0,0 @@
import { LcdClient } from "./lcdclient";
export interface MintParametersResponse {
readonly height: string;
readonly result: {
readonly mint_denom: string;
readonly inflation_rate_change: string;
readonly inflation_max: string;
readonly inflation_min: string;
readonly goal_bonded: string;
readonly blocks_per_year: string;
};
}
export interface MintInflationResponse {
readonly height: string;
readonly result: string;
}
export interface MintAnnualProvisionsResponse {
readonly height: string;
readonly result: string;
}
export interface MintExtension {
readonly mint: {
readonly parameters: () => Promise<MintParametersResponse>;
readonly inflation: () => Promise<MintInflationResponse>;
readonly annualProvisions: () => Promise<MintAnnualProvisionsResponse>;
};
}
export declare function setupMintExtension(base: LcdClient): MintExtension;
-31
View File
@@ -1,31 +0,0 @@
import { LcdClient } from "./lcdclient";
interface SlashingSigningInfo {
readonly address: string;
readonly start_height: string;
readonly index_offset: string;
readonly jailed_until: string;
readonly tombstoned: boolean;
readonly missed_blocks_counter: string;
}
export interface SlashingSigningInfosResponse {
readonly height: string;
readonly result: readonly SlashingSigningInfo[];
}
export interface SlashingParametersResponse {
readonly height: string;
readonly result: {
readonly signed_blocks_window: string;
readonly min_signed_per_window: string;
readonly downtime_jail_duration: string;
readonly slash_fraction_double_sign: string;
readonly slash_fraction_downtime: string;
};
}
export interface SlashingExtension {
readonly slashing: {
readonly signingInfos: () => Promise<SlashingSigningInfosResponse>;
readonly parameters: () => Promise<SlashingParametersResponse>;
};
}
export declare function setupSlashingExtension(base: LcdClient): SlashingExtension;
export {};
-194
View File
@@ -1,194 +0,0 @@
import { Coin } from "../coins";
import { BlockHeader, SearchTxsResponse } from "./base";
import { LcdClient } from "./lcdclient";
/**
* Numeric bonding status
*
* @see https://github.com/cosmos/cosmos-sdk/blob/v0.38.5/types/staking.go#L43-L49
*/
export declare enum BondStatus {
Unbonded = 0,
Unbonding = 1,
Bonded = 2,
}
interface Validator {
readonly operator_address: string;
readonly consensus_pubkey: string;
readonly jailed: boolean;
readonly status: BondStatus;
readonly tokens: string;
readonly delegator_shares: string;
readonly description: {
readonly moniker: string;
readonly identity: string;
readonly website: string;
readonly security_contact: string;
readonly details: string;
};
readonly unbonding_height: string;
readonly unbonding_time: string;
readonly commission: {
readonly commission_rates: {
readonly rate: string;
readonly max_rate: string;
readonly max_change_rate: string;
};
readonly update_time: string;
};
readonly min_self_delegation: string;
}
interface Delegation {
readonly delegator_address: string;
readonly validator_address: string;
readonly shares: string;
readonly balance: Coin;
}
export interface StakingDelegatorDelegationsResponse {
readonly height: string;
readonly result: readonly Delegation[];
}
interface UnbondingDelegationEntry {
readonly creation_height: string;
readonly completion_time: string;
readonly initial_balance: string;
readonly balance: string;
}
interface UnbondingDelegation {
readonly delegator_address: string;
readonly validator_address: string;
readonly entries: readonly UnbondingDelegationEntry[];
}
export interface StakingDelegatorUnbondingDelegationsResponse {
readonly height: string;
readonly result: readonly UnbondingDelegation[];
}
export declare type StakingDelegatorTransactionsResponse = readonly SearchTxsResponse[];
export interface StakingDelegatorValidatorsResponse {
readonly height: string;
readonly result: readonly Validator[];
}
export interface StakingDelegatorValidatorResponse {
readonly height: string;
readonly result: Validator;
}
export interface StakingDelegationResponse {
readonly height: string;
readonly result: Delegation;
}
export interface StakingUnbondingDelegationResponse {
readonly height: string;
readonly result: UnbondingDelegation | null;
}
interface RedelegationEntry {
readonly creation_height: string;
readonly completion_time: string;
readonly initial_balance: Coin;
readonly shares_dst: string;
}
interface Redelegation {
readonly delegator_address: string;
readonly validator_src_address: string;
readonly validator_dst_address: string;
readonly entries: readonly RedelegationEntry[];
}
export interface StakingRedelegationsResponse {
readonly height: string;
readonly result: readonly Redelegation[];
}
export interface StakingValidatorsParams {
/** @see https://github.com/cosmos/cosmos-sdk/blob/v0.38.5/types/staking.go#L43-L49 */
readonly status?: "bonded" | "unbonded" | "unbonding";
readonly page?: number;
readonly limit?: number;
}
export interface StakingValidatorsResponse {
readonly height: string;
readonly result: readonly Validator[];
}
export interface StakingValidatorResponse {
readonly height: string;
readonly result: Validator;
}
export interface StakingValidatorDelegationsResponse {
readonly height: string;
readonly result: readonly Delegation[];
}
export interface StakingValidatorUnbondingDelegationsResponse {
readonly height: string;
readonly result: readonly UnbondingDelegation[];
}
interface HistoricalInfo {
readonly header: BlockHeader;
readonly validators: readonly Validator[];
}
export interface StakingHistoricalInfoResponse {
readonly height: string;
readonly result: HistoricalInfo;
}
export interface StakingPoolResponse {
readonly height: string;
readonly result: {
readonly not_bonded_tokens: string;
readonly bonded_tokens: string;
};
}
export interface StakingParametersResponse {
readonly height: string;
readonly result: {
readonly unbonding_time: string;
readonly max_validators: number;
readonly max_entries: number;
readonly historical_entries: number;
readonly bond_denom: string;
};
}
export interface StakingExtension {
readonly staking: {
/** Get all delegations from a delegator */
readonly delegatorDelegations: (delegatorAddress: string) => Promise<StakingDelegatorDelegationsResponse>;
/** Get all unbonding delegations from a delegator */
readonly delegatorUnbondingDelegations: (
delegatorAddress: string,
) => Promise<StakingDelegatorUnbondingDelegationsResponse>;
/** Get all staking txs (i.e msgs) from a delegator */
readonly delegatorTransactions: (
delegatorAddress: string,
) => Promise<StakingDelegatorTransactionsResponse>;
/** Query all validators that a delegator is bonded to */
readonly delegatorValidators: (delegatorAddress: string) => Promise<StakingDelegatorValidatorsResponse>;
/** Query a validator that a delegator is bonded to */
readonly delegatorValidator: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<StakingDelegatorValidatorResponse>;
/** Query a delegation between a delegator and a validator */
readonly delegation: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<StakingDelegationResponse>;
/** Query all unbonding delegations between a delegator and a validator */
readonly unbondingDelegation: (
delegatorAddress: string,
validatorAddress: string,
) => Promise<StakingUnbondingDelegationResponse>;
/** Query redelegations (filters in query params) */
readonly redelegations: () => Promise<StakingRedelegationsResponse>;
/** Get all validators */
readonly validators: (options?: StakingValidatorsParams) => Promise<StakingValidatorsResponse>;
/** Get a single validator info */
readonly validator: (validatorAddress: string) => Promise<StakingValidatorResponse>;
readonly validatorDelegations: (validatorAddress: string) => Promise<StakingValidatorDelegationsResponse>;
/** Get all unbonding delegations from a validator */
readonly validatorUnbondingDelegations: (
validatorAddress: string,
) => Promise<StakingValidatorUnbondingDelegationsResponse>;
/** Get HistoricalInfo at a given height */
readonly historicalInfo: (height: string) => Promise<StakingHistoricalInfoResponse>;
/** Get the current state of the staking pool */
readonly pool: () => Promise<StakingPoolResponse>;
/** Get the current staking parameter values */
readonly parameters: () => Promise<StakingParametersResponse>;
};
}
export declare function setupStakingExtension(base: LcdClient): StakingExtension;
export {};
-18
View File
@@ -1,18 +0,0 @@
import { Coin } from "../coins";
import { LcdApiArray, LcdClient } from "./lcdclient";
export interface TotalSupplyAllResponse {
readonly height: string;
readonly result: LcdApiArray<Coin>;
}
export interface TotalSupplyResponse {
readonly height: string;
/** The amount */
readonly result: string;
}
export interface SupplyExtension {
readonly supply: {
readonly totalAll: () => Promise<TotalSupplyAllResponse>;
readonly total: (denom: string) => Promise<TotalSupplyResponse>;
};
}
export declare function setupSupplyExtension(base: LcdClient): SupplyExtension;
-22
View File
@@ -1,22 +0,0 @@
import { PubKey } from "../types";
/**
* Converts an integer expressed as number or string to a number.
* Throws if input is not a valid uint64 or if the value exceeds MAX_SAFE_INTEGER.
*
* This is needed for supporting Comsos SDK 0.37/0.38/0.39 with one client.
*/
export declare function uint64ToNumber(input: number | string): number;
/**
* Converts an integer expressed as number or string to a string.
* Throws if input is not a valid uint64.
*
* This is needed for supporting Comsos SDK 0.37/0.38/0.39 with one client.
*/
export declare function uint64ToString(input: number | string): string;
/**
* Normalizes a pubkey as in `BaseAccount.public_key` to allow supporting
* Comsos SDK 0.370.39.
*
* Returns null when unset.
*/
export declare function normalizePubkey(input: string | PubKey | null): PubKey | null;
-28
View File
@@ -1,28 +0,0 @@
export interface Attribute {
readonly key: string;
readonly value: string;
}
export interface Event {
readonly type: string;
readonly attributes: readonly Attribute[];
}
export interface Log {
readonly msg_index: number;
readonly log: string;
readonly events: readonly Event[];
}
export declare function parseAttribute(input: unknown): Attribute;
export declare function parseEvent(input: unknown): Event;
export declare function parseLog(input: unknown): Log;
export declare function parseLogs(input: unknown): readonly Log[];
/**
* Searches in logs for the first event of the given event type and in that event
* for the first first attribute with the given attribute key.
*
* Throws if the attribute was not found.
*/
export declare function findAttribute(
logs: readonly Log[],
eventType: "message" | "transfer",
attrKey: string,
): Attribute;
-237
View File
@@ -1,237 +0,0 @@
import { Coin } from "./coins";
export interface Msg {
readonly type: string;
readonly value: any;
}
/** A high level transaction of the coin module */
export interface MsgSend extends Msg {
readonly type: "cosmos-sdk/MsgSend";
readonly value: {
/** Bech32 account address */
readonly from_address: string;
/** Bech32 account address */
readonly to_address: string;
readonly amount: readonly Coin[];
};
}
export declare function isMsgSend(msg: Msg): msg is MsgSend;
interface Input {
/** Bech32 account address */
readonly address: string;
readonly coins: readonly Coin[];
}
interface Output {
/** Bech32 account address */
readonly address: string;
readonly coins: readonly Coin[];
}
/** A high level transaction of the coin module */
export interface MsgMultiSend extends Msg {
readonly type: "cosmos-sdk/MsgMultiSend";
readonly value: {
readonly inputs: readonly Input[];
readonly outputs: readonly Output[];
};
}
export declare function isMsgMultiSend(msg: Msg): msg is MsgMultiSend;
/** Verifies a particular invariance */
export interface MsgVerifyInvariant extends Msg {
readonly type: "cosmos-sdk/MsgVerifyInvariant";
readonly value: {
/** Bech32 account address */
readonly sender: string;
readonly invariant_module_name: string;
readonly invariant_route: string;
};
}
export declare function isMsgVerifyInvariant(msg: Msg): msg is MsgVerifyInvariant;
/** Changes the withdraw address for a delegator (or validator self-delegation) */
export interface MsgSetWithdrawAddress extends Msg {
readonly type: "cosmos-sdk/MsgModifyWithdrawAddress";
readonly value: {
/** Bech32 account address */
readonly delegator_address: string;
/** Bech32 account address */
readonly withdraw_address: string;
};
}
export declare function isMsgSetWithdrawAddress(msg: Msg): msg is MsgSetWithdrawAddress;
/** Message for delegation withdraw from a single validator */
export interface MsgWithdrawDelegatorReward extends Msg {
readonly type: "cosmos-sdk/MsgWithdrawDelegationReward";
readonly value: {
/** Bech32 account address */
readonly delegator_address: string;
/** Bech32 account address */
readonly validator_address: string;
};
}
export declare function isMsgWithdrawDelegatorReward(msg: Msg): msg is MsgWithdrawDelegatorReward;
/** Message for validator withdraw */
export interface MsgWithdrawValidatorCommission extends Msg {
readonly type: "cosmos-sdk/MsgWithdrawValidatorCommission";
readonly value: {
/** Bech32 account address */
readonly validator_address: string;
};
}
export declare function isMsgWithdrawValidatorCommission(msg: Msg): msg is MsgWithdrawValidatorCommission;
/** Allows an account to directly fund the community pool. */
export interface MsgFundCommunityPool extends Msg {
readonly type: "cosmos-sdk/MsgFundCommunityPool";
readonly value: {
readonly amount: readonly Coin[];
/** Bech32 account address */
readonly depositor: string;
};
}
export declare function isMsgFundCommunityPool(msg: Msg): msg is MsgFundCommunityPool;
interface Any {
readonly type_url: string;
readonly value: Uint8Array;
}
/** Supports submitting arbitrary evidence */
export interface MsgSubmitEvidence extends Msg {
readonly type: "cosmos-sdk/MsgSubmitEvidence";
readonly value: {
/** Bech32 account address */
readonly submitter: string;
readonly evidence: Any;
};
}
export declare function isMsgSubmitEvidence(msg: Msg): msg is MsgSubmitEvidence;
/** Supports submitting arbitrary proposal content. */
export interface MsgSubmitProposal extends Msg {
readonly type: "cosmos-sdk/MsgSubmitProposal";
readonly value: {
readonly content: Any;
readonly initial_deposit: readonly Coin[];
/** Bech32 account address */
readonly proposer: string;
};
}
export declare function isMsgSubmitProposal(msg: Msg): msg is MsgSubmitProposal;
declare enum VoteOption {
VoteOptionUnspecified = 0,
VoteOptionYes = 1,
VoteOptionAbstain = 2,
VoteOptionNo = 3,
VoteOptionNoWithVeto = 4,
}
/** Casts a vote */
export interface MsgVote extends Msg {
readonly type: "cosmos-sdk/MsgVote";
readonly value: {
readonly proposal_id: number;
/** Bech32 account address */
readonly voter: string;
readonly option: VoteOption;
};
}
export declare function isMsgVote(msg: Msg): msg is MsgVote;
/** Submits a deposit to an existing proposal */
export interface MsgDeposit extends Msg {
readonly type: "cosmos-sdk/MsgDeposit";
readonly value: {
readonly proposal_id: number;
/** Bech32 account address */
readonly depositor: string;
readonly amount: readonly Coin[];
};
}
export declare function isMsgDeposit(msg: Msg): msg is MsgDeposit;
/** Unjails a jailed validator */
export interface MsgUnjail extends Msg {
readonly type: "cosmos-sdk/MsgUnjail";
readonly value: {
/** Bech32 account address */
readonly validator_addr: string;
};
}
export declare function isMsgUnjail(msg: Msg): msg is MsgUnjail;
/** The initial commission rates to be used for creating a validator */
interface CommissionRates {
readonly rate: string;
readonly max_rate: string;
readonly max_change_rate: string;
}
/** A validator description. */
interface Description {
readonly moniker: string;
readonly identity: string;
readonly website: string;
readonly security_contact: string;
readonly details: string;
}
/** Creates a new validator. */
export interface MsgCreateValidator extends Msg {
readonly type: "cosmos-sdk/MsgCreateValidator";
readonly value: {
readonly description: Description;
readonly commission: CommissionRates;
readonly min_self_delegation: string;
/** Bech32 encoded delegator address */
readonly delegator_address: string;
/** Bech32 encoded validator address */
readonly validator_address: string;
/** Bech32 encoded public key */
readonly pubkey: string;
readonly value: Coin;
};
}
export declare function isMsgCreateValidator(msg: Msg): msg is MsgCreateValidator;
/** Edits an existing validator. */
export interface MsgEditValidator extends Msg {
readonly type: "cosmos-sdk/MsgEditValidator";
readonly value: {
readonly description: Description;
/** Bech32 encoded validator address */
readonly validator_address: string;
readonly commission_rate: string;
readonly min_self_delegation: string;
};
}
export declare function isMsgEditValidator(msg: Msg): msg is MsgEditValidator;
/**
* Performs a delegation from a delegate to a validator.
*
* @see https://docs.cosmos.network/master/modules/staking/03_messages.html#msgdelegate
*/
export interface MsgDelegate extends Msg {
readonly type: "cosmos-sdk/MsgDelegate";
readonly value: {
/** Bech32 encoded delegator address */
readonly delegator_address: string;
/** Bech32 encoded validator address */
readonly validator_address: string;
readonly amount: Coin;
};
}
export declare function isMsgDelegate(msg: Msg): msg is MsgDelegate;
/** Performs a redelegation from a delegate and source validator to a destination validator */
export interface MsgBeginRedelegate extends Msg {
readonly type: "cosmos-sdk/MsgBeginRedelegate";
readonly value: {
/** Bech32 encoded delegator address */
readonly delegator_address: string;
/** Bech32 encoded source validator address */
readonly validator_src_address: string;
/** Bech32 encoded destination validator address */
readonly validator_dst_address: string;
readonly amount: Coin;
};
}
export declare function isMsgBeginRedelegate(msg: Msg): msg is MsgBeginRedelegate;
/** Performs an undelegation from a delegate and a validator */
export interface MsgUndelegate extends Msg {
readonly type: "cosmos-sdk/MsgUndelegate";
readonly value: {
/** Bech32 encoded delegator address */
readonly delegator_address: string;
/** Bech32 encoded validator address */
readonly validator_address: string;
readonly amount: Coin;
};
}
export declare function isMsgUndelegate(msg: Msg): msg is MsgUndelegate;
export {};
-24
View File
@@ -1,24 +0,0 @@
import { PubKey } from "./types";
export declare function encodeSecp256k1Pubkey(pubkey: Uint8Array): PubKey;
/**
* Decodes a pubkey in the Amino binary format to a type/value object.
*/
export declare function decodeAminoPubkey(data: Uint8Array): PubKey;
/**
* Decodes a bech32 pubkey to Amino binary, which is then decoded to a type/value object.
* The bech32 prefix is ignored and discareded.
*
* @param bechEncoded the bech32 encoded pubkey
*/
export declare function decodeBech32Pubkey(bechEncoded: string): PubKey;
/**
* Encodes a public key to binary Amino.
*/
export declare function encodeAminoPubkey(pubkey: PubKey): Uint8Array;
/**
* Encodes a public key to binary Amino and then to bech32.
*
* @param pubkey the public key to encode
* @param prefix the bech32 prefix (human readable part)
*/
export declare function encodeBech32Pubkey(pubkey: PubKey, prefix: string): string;
-97
View File
@@ -1,97 +0,0 @@
import { EnglishMnemonic, HdPath } from "@cosmjs/crypto";
import { StdSignDoc } from "./encoding";
import { AccountData, AminoSignResponse, OfflineSigner } from "./signer";
import { EncryptionConfiguration, KdfConfiguration } from "./wallet";
/**
* This interface describes a JSON object holding the encrypted wallet and the meta data.
* All fields in here must be JSON types.
*/
export interface Secp256k1HdWalletSerialization {
/** A format+version identifier for this serialization format */
readonly type: string;
/** Information about the key derivation function (i.e. password to encryption key) */
readonly kdf: KdfConfiguration;
/** Information about the symmetric encryption */
readonly encryption: EncryptionConfiguration;
/** An instance of Secp256k1HdWalletData, which is stringified, encrypted and base64 encoded. */
readonly data: string;
}
export declare function extractKdfConfiguration(serialization: string): KdfConfiguration;
export declare class Secp256k1HdWallet implements OfflineSigner {
/**
* Restores a wallet from the given BIP39 mnemonic.
*
* @param mnemonic Any valid English mnemonic.
* @param hdPath The BIP-32/SLIP-10 derivation path. Defaults to the Cosmos Hub/ATOM path `m/44'/118'/0'/0/0`.
* @param prefix The bech32 address prefix (human readable part). Defaults to "cosmos".
*/
static fromMnemonic(mnemonic: string, hdPath?: HdPath, prefix?: string): Promise<Secp256k1HdWallet>;
/**
* Generates a new wallet with a BIP39 mnemonic of the given length.
*
* @param length The number of words in the mnemonic (12, 15, 18, 21 or 24).
* @param hdPath The BIP-32/SLIP-10 derivation path. Defaults to the Cosmos Hub/ATOM path `m/44'/118'/0'/0/0`.
* @param prefix The bech32 address prefix (human readable part). Defaults to "cosmos".
*/
static generate(
length?: 12 | 15 | 18 | 21 | 24,
hdPath?: HdPath,
prefix?: string,
): Promise<Secp256k1HdWallet>;
/**
* Restores a wallet from an encrypted serialization.
*
* @param password The user provided password used to generate an encryption key via a KDF.
* This is not normalized internally (see "Unicode normalization" to learn more).
*/
static deserialize(serialization: string, password: string): Promise<Secp256k1HdWallet>;
/**
* Restores a wallet from an encrypted serialization.
*
* This is an advanced alternative to calling `deserialize(serialization, password)` directly, which allows
* you to offload the KDF execution to a non-UI thread (e.g. in a WebWorker).
*
* The caller is responsible for ensuring the key was derived with the given KDF configuration. This can be
* done using `extractKdfConfiguration(serialization)` and `executeKdf(password, kdfConfiguration)` from this package.
*/
static deserializeWithEncryptionKey(
serialization: string,
encryptionKey: Uint8Array,
): Promise<Secp256k1HdWallet>;
private static deserializeTypeV1;
/** Base secret */
private readonly secret;
/** Derivation instruction */
private readonly accounts;
/** Derived data */
private readonly pubkey;
private readonly privkey;
protected constructor(
mnemonic: EnglishMnemonic,
hdPath: HdPath,
privkey: Uint8Array,
pubkey: Uint8Array,
prefix: string,
);
get mnemonic(): string;
private get address();
getAccounts(): Promise<readonly AccountData[]>;
signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<AminoSignResponse>;
/**
* Generates an encrypted serialization of this wallet.
*
* @param password The user provided password used to generate an encryption key via a KDF.
* This is not normalized internally (see "Unicode normalization" to learn more).
*/
serialize(password: string): Promise<string>;
/**
* Generates an encrypted serialization of this wallet.
*
* This is an advanced alternative to calling `serialize(password)` directly, which allows you to
* offload the KDF execution to a non-UI thread (e.g. in a WebWorker).
*
* The caller is responsible for ensuring the key was derived with the given KDF options. If this
* is not the case, the wallet cannot be restored with the original password.
*/
serializeWithEncryptionKey(encryptionKey: Uint8Array, kdfConfiguration: KdfConfiguration): Promise<string>;
}
-23
View File
@@ -1,23 +0,0 @@
import { StdSignDoc } from "./encoding";
import { AccountData, AminoSignResponse, OfflineSigner } from "./signer";
/**
* A wallet that holds a single secp256k1 keypair.
*
* If you want to work with BIP39 mnemonics and multiple accounts, use Secp256k1HdWallet.
*/
export declare class Secp256k1Wallet implements OfflineSigner {
/**
* Creates a Secp256k1Wallet from the given private key
*
* @param privkey The private key.
* @param prefix The bech32 address prefix (human readable part). Defaults to "cosmos".
*/
static fromKey(privkey: Uint8Array, prefix?: string): Promise<Secp256k1Wallet>;
private readonly pubkey;
private readonly privkey;
private readonly prefix;
private constructor();
private get address();
getAccounts(): Promise<readonly AccountData[]>;
signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<AminoSignResponse>;
}
-19
View File
@@ -1,19 +0,0 @@
import { WrappedStdTx } from "./tx";
/**
* Serach for sequence s with `min` <= `s` < `upperBound` to find the sequence that was used to sign the transaction
*
* @param tx The signed transaction
* @param chainId The chain ID for which this transaction was signed
* @param accountNumber The account number for which this transaction was signed
* @param upperBound The upper bound for the testing, i.e. sequence must be lower than this value
* @param min The lowest sequence that is tested
*
* @returns the sequence if a match was found and undefined otherwise
*/
export declare function findSequenceForSignedTx(
tx: WrappedStdTx,
chainId: string,
accountNumber: number,
upperBound: number,
min?: number,
): Promise<number | undefined>;
-14
View File
@@ -1,14 +0,0 @@
import { StdSignature } from "./types";
/**
* Takes a binary pubkey and signature to create a signature object
*
* @param pubkey a compressed secp256k1 public key
* @param signature a 64 byte fixed length representation of secp256k1 signature components r and s
*/
export declare function encodeSecp256k1Signature(pubkey: Uint8Array, signature: Uint8Array): StdSignature;
export declare function decodeSignature(
signature: StdSignature,
): {
readonly pubkey: Uint8Array;
readonly signature: Uint8Array;
};
-33
View File
@@ -1,33 +0,0 @@
import { StdSignDoc } from "./encoding";
import { StdSignature } from "./types";
export declare type Algo = "secp256k1" | "ed25519" | "sr25519";
export interface AccountData {
/** A printable address (typically bech32 encoded) */
readonly address: string;
readonly algo: Algo;
readonly pubkey: Uint8Array;
}
export interface AminoSignResponse {
/**
* The sign doc that was signed.
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
*/
readonly signed: StdSignDoc;
readonly signature: StdSignature;
}
export interface OfflineSigner {
/**
* Get AccountData array from wallet. Rejects if not enabled.
*/
readonly getAccounts: () => Promise<readonly AccountData[]>;
/**
* Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled.
*
* The signer implementation may offer the user the ability to override parts of the signDoc. It must
* return the doc that was signed in the response.
*
* @param signerAddress The address of the account that should sign the transaction
* @param signDoc The content that should be signed
*/
readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<AminoSignResponse>;
}
-66
View File
@@ -1,66 +0,0 @@
import { Coin } from "./coins";
import { Account, BroadcastTxResult, CosmosClient, GetSequenceResult } from "./cosmosclient";
import { FeeTable, GasLimits, GasPrice } from "./gas";
import { BroadcastMode } from "./lcdapi";
import { Msg } from "./msgs";
import { OfflineSigner } from "./signer";
import { StdTx } from "./tx";
import { StdFee } from "./types";
/**
* These fees are used by the higher level methods of SigningCosmosClient
*/
export interface CosmosFeeTable extends FeeTable {
readonly send: StdFee;
}
/** Use for testing only */
export interface PrivateSigningCosmosClient {
readonly fees: CosmosFeeTable;
}
export declare class SigningCosmosClient extends CosmosClient {
readonly signerAddress: string;
private readonly signer;
private readonly fees;
/**
* Creates a new client with signing capability to interact with a Cosmos SDK blockchain. This is the bigger brother of CosmosClient.
*
* This instance does a lot of caching. In order to benefit from that you should try to use one instance
* for the lifetime of your application. When switching backends, a new instance must be created.
*
* @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API)
* @param signerAddress The address that will sign transactions using this instance. The `signer` must be able to sign with this address.
* @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input.
* @param gasPrice The price paid per unit of gas
* @param gasLimits Custom overrides for gas limits related to specific transaction types
* @param broadcastMode Defines at which point of the transaction processing the broadcastTx method returns
*/
constructor(
apiUrl: string,
signerAddress: string,
signer: OfflineSigner,
gasPrice?: GasPrice,
gasLimits?: Partial<GasLimits<CosmosFeeTable>>,
broadcastMode?: BroadcastMode,
);
getSequence(address?: string): Promise<GetSequenceResult>;
getAccount(address?: string): Promise<Account | undefined>;
sendTokens(
recipientAddress: string,
transferAmount: readonly Coin[],
memo?: string,
): Promise<BroadcastTxResult>;
/**
* Gets account number and sequence from the API, creates a sign doc,
* creates a single signature, assembles the signed transaction and broadcasts it.
*/
signAndBroadcast(msgs: readonly Msg[], fee: StdFee, memo?: string): Promise<BroadcastTxResult>;
/**
* Gets account number and sequence from the API, creates a sign doc,
* creates a single signature and assembles the signed transaction.
*/
sign(msgs: readonly Msg[], fee: StdFee, memo?: string): Promise<StdTx>;
/**
* Gets account number and sequence from the API, creates a sign doc,
* creates a single signature and appends it to the existing signatures.
*/
appendSignature(signedTx: StdTx): Promise<StdTx>;
}
-36
View File
@@ -1,36 +0,0 @@
import { StdSignDoc } from "./encoding";
import { Msg } from "./msgs";
import { StdFee, StdSignature } from "./types";
/**
* A Cosmos SDK StdTx
*
* @see https://docs.cosmos.network/master/modules/auth/03_types.html#stdtx
*/
export interface StdTx {
readonly msg: readonly Msg[];
readonly fee: StdFee;
readonly signatures: readonly StdSignature[];
readonly memo: string | undefined;
}
export declare function isStdTx(txValue: unknown): txValue is StdTx;
export declare function makeStdTx(
content: Pick<StdSignDoc, "msgs" | "fee" | "memo">,
signatures: StdSignature | readonly StdSignature[],
): StdTx;
/**
* An Amino JSON wrapper around the Tx interface
*/
export interface WrappedTx {
readonly type: string;
readonly value: any;
}
/**
* An Amino JSON wrapper around StdTx
*/
export interface WrappedStdTx extends WrappedTx {
readonly type: "cosmos-sdk/StdTx";
readonly value: StdTx;
}
export declare function isWrappedStdTx(wrapped: WrappedTx): wrapped is WrappedStdTx;
/** @deprecated use WrappedStdTx */
export declare type CosmosSdkTx = WrappedStdTx;
-21
View File
@@ -1,21 +0,0 @@
import { Coin } from "./coins";
export interface StdFee {
readonly amount: readonly Coin[];
readonly gas: string;
}
export interface StdSignature {
readonly pub_key: PubKey;
readonly signature: string;
}
export interface PubKey {
readonly type: string;
readonly value: string;
}
export declare const pubkeyType: {
/** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/ed25519/ed25519.go#L22 */
secp256k1: "tendermint/PubKeySecp256k1";
/** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/secp256k1/secp256k1.go#L23 */
ed25519: "tendermint/PubKeyEd25519";
/** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/sr25519/codec.go#L12 */
sr25519: "tendermint/PubKeySr25519";
};
-46
View File
@@ -1,46 +0,0 @@
import { HdPath } from "@cosmjs/crypto";
/**
* The Cosmoshub derivation path in the form `m/44'/118'/0'/0/a`
* with 0-based account index `a`.
*/
export declare function makeCosmoshubPath(a: number): HdPath;
/**
* A fixed salt is chosen to archive a deterministic password to key derivation.
* This reduces the scope of a potential rainbow attack to all CosmJS users.
* Must be 16 bytes due to implementation limitations.
*/
export declare const cosmjsSalt: Uint8Array;
export interface KdfConfiguration {
/**
* An algorithm identifier, such as "argon2id" or "scrypt".
*/
readonly algorithm: string;
/** A map of algorithm-specific parameters */
readonly params: Record<string, unknown>;
}
export declare function executeKdf(password: string, configuration: KdfConfiguration): Promise<Uint8Array>;
/**
* Configuration how to encrypt data or how data was encrypted.
* This is stored as part of the wallet serialization and must only contain JSON types.
*/
export interface EncryptionConfiguration {
/**
* An algorithm identifier, such as "xchacha20poly1305-ietf".
*/
readonly algorithm: string;
/** A map of algorithm-specific parameters */
readonly params?: Record<string, unknown>;
}
export declare const supportedAlgorithms: {
xchacha20poly1305Ietf: string;
};
export declare function encrypt(
plaintext: Uint8Array,
encryptionKey: Uint8Array,
config: EncryptionConfiguration,
): Promise<Uint8Array>;
export declare function decrypt(
ciphertext: Uint8Array,
encryptionKey: Uint8Array,
config: EncryptionConfiguration,
): Promise<Uint8Array>;