import { AccountSetBaseSuper, MsgOpt } from "./base"; import { AppCurrency, Keplr, KeplrSignOptions, SignDoc, StdFee, StdSignDoc } from "@keplr-wallet/types"; import { Any } from "@keplr-wallet/proto-types/google/protobuf/any"; import { BaseAccount } from "@keplr-wallet/cosmos"; import { CosmosQueries, IQueriesStore, QueriesSetBase } from "../query"; import { DeepPartial, DeepReadonly } from "utility-types"; import { ChainGetter } from "../chain"; import { KeplrSignOptionsWithAltSignMethods, MakeTxResponse, ProtoMsgsOrWithAminoMsgs } from "./types"; import { IAccountStore } from "./store"; export interface CosmosAccount { cosmos: CosmosAccountImpl; } export declare const CosmosAccount: { use(options: { msgOptsCreator?: ((chainId: string) => DeepPartial | undefined) | undefined; queriesStore: IQueriesStore; wsObject?: (new (url: string, protocols?: string | string[]) => WebSocket) | undefined; preTxEvents?: { onBroadcastFailed?: ((chainId: string, e?: Error) => void) | undefined; onBroadcasted?: ((chainId: string, txHash: Uint8Array) => void) | undefined; onFulfill?: ((chainId: string, tx: any) => void) | undefined; } | undefined; }): (base: AccountSetBaseSuper, chainGetter: ChainGetter, chainId: string) => CosmosAccount; }; /** * @deprecated Predict gas through simulation rather than using a fixed gas. */ export interface CosmosMsgOpts { readonly send: { readonly native: MsgOpt; }; readonly ibcTransfer: MsgOpt; readonly delegate: MsgOpt; readonly undelegate: MsgOpt; readonly redelegate: MsgOpt; readonly withdrawRewards: MsgOpt; readonly govVote: MsgOpt; } /** * @deprecated Predict gas through simulation rather than using a fixed gas. */ export declare const defaultCosmosMsgOpts: CosmosMsgOpts; export declare class CosmosAccountImpl { protected readonly base: AccountSetBaseSuper; protected readonly chainGetter: ChainGetter; protected readonly chainId: string; protected readonly queriesStore: IQueriesStore; protected readonly _msgOpts: CosmosMsgOpts; protected readonly txOpts: { wsObject?: new (url: string, protocols?: string | string[]) => WebSocket; preTxEvents?: { onBroadcastFailed?: (chainId: string, e?: Error) => void; onBroadcasted?: (chainId: string, txHash: Uint8Array) => void; onFulfill?: (chainId: string, tx: any) => void; }; }; constructor(base: AccountSetBaseSuper, chainGetter: ChainGetter, chainId: string, queriesStore: IQueriesStore, _msgOpts: CosmosMsgOpts, txOpts: { wsObject?: new (url: string, protocols?: string | string[]) => WebSocket; preTxEvents?: { onBroadcastFailed?: (chainId: string, e?: Error) => void; onBroadcasted?: (chainId: string, txHash: Uint8Array) => void; onFulfill?: (chainId: string, tx: any) => void; }; }); /** * @deprecated Predict gas through simulation rather than using a fixed gas. */ get msgOpts(): CosmosMsgOpts; protected processMakeSendTokenTx(amount: string, currency: AppCurrency, recipient: string): MakeTxResponse | undefined; sendMsgs(type: string | "unknown", msgs: ProtoMsgsOrWithAminoMsgs | (() => Promise | ProtoMsgsOrWithAminoMsgs), memo: string | undefined, fee: StdFee, signOptions?: KeplrSignOptionsWithAltSignMethods, onTxEvents?: ((tx: any) => void) | { onBroadcastFailed?: (e?: Error) => void; onBroadcasted?: (txHash: Uint8Array) => void; onFulfill?: (tx: any) => void; }): Promise; protected signMsgs(msgs: ProtoMsgsOrWithAminoMsgs | (() => Promise | ProtoMsgsOrWithAminoMsgs), fee: StdFee, memo?: string, signOptions?: KeplrSignOptionsWithAltSignMethods, keplrClient?: Keplr): Promise<{ tx: Uint8Array; signDoc: SignDoc; } | { tx: Uint8Array; signDoc: StdSignDoc; }>; protected broadcastMsgs(msgs: ProtoMsgsOrWithAminoMsgs, fee: StdFee, memo?: string, signOptions?: KeplrSignOptionsWithAltSignMethods): Promise<{ txHash: Uint8Array; signDoc: StdSignDoc | SignDoc; }>; protected createSignedTxWithDirectSign(keplr: Keplr, account: BaseAccount, protoMsgs: Any[], fee: StdFee, memo: string, signOptions: KeplrSignOptionsWithAltSignMethods | undefined): Promise<{ tx: Uint8Array; signDoc: SignDoc; }>; /** * Simulate tx without making state transition on chain or not waiting the tx committed. * Mainly used to estimate the gas needed to process tx. * You should multiply arbitrary number (gas adjustment) for gas before sending tx. * * NOTE: "/cosmos/tx/v1beta1/simulate" returns 400, 500 or (more?) status and error code as a response when tx fails on stimulate. * Currently, non 200~300 status is handled as error, thus error would be thrown. * * XXX: Uses the simulate request format for cosmos-sdk@0.43+ * Thus, may throw an error if the chain is below cosmos-sdk@0.43 * And, for simplicity, doesn't set the public key to tx bytes. * Thus, the gas estimated doesn't include the tx bytes size of public key. * * @param msgs * @param fee * @param memo */ simulateTx(msgs: Any[], fee: Omit, memo?: string): Promise<{ gasUsed: number; }>; makeTx(defaultType: string | "unknown", msgs: ProtoMsgsOrWithAminoMsgs | (() => Promise), preOnTxEvents?: ((tx: any) => void) | { onBroadcastFailed?: (e?: Error) => void; onBroadcasted?: (txHash: Uint8Array) => void; onFulfill?: (tx: any) => void; }): MakeTxResponse; makePacketForwardIBCTransferTx(accountStore: IAccountStore, channels: { portId: string; channelId: string; counterpartyChainId: string; }[], amount: string, currency: AppCurrency, recipient: string): MakeTxResponse; makeIBCTransferTx(channel: { portId: string; channelId: string; counterpartyChainId: string; }, amount: string, currency: AppCurrency, recipient: string, memo?: string): MakeTxResponse; makeIBCTransferTxWithAsyncMemoConstructor(channel: { portId: string; channelId: string; counterpartyChainId: string; }, amount: string, currency: AppCurrency, recipient: string | (() => Promise), memoConstructor: () => Promise): MakeTxResponse; sendIBCTransferMsg(channel: { portId: string; channelId: string; counterpartyChainId: string; }, amount: string, currency: AppCurrency, recipient: string, memo?: string, stdFee?: Partial, signOptions?: KeplrSignOptions, onTxEvents?: ((tx: any) => void) | { onBroadcasted?: (txHash: Uint8Array) => void; onFulfill?: (tx: any) => void; }): Promise; makeRevokeMsg(grantee: string, messageType: string): MakeTxResponse; makeDelegateTx(amount: string, validatorAddress: string): MakeTxResponse; /** * Send `MsgDelegate` msg to the chain. * @param amount Decimal number used by humans. * If amount is 0.1 and the stake currenct is uatom, actual amount will be changed to the 100000uatom. * @param validatorAddress * @param memo * @param onFulfill */ sendDelegateMsg(amount: string, validatorAddress: string, memo?: string, stdFee?: Partial, signOptions?: KeplrSignOptions, onTxEvents?: ((tx: any) => void) | { onBroadcasted?: (txHash: Uint8Array) => void; onFulfill?: (tx: any) => void; }): Promise; makeUndelegateTx(amount: string, validatorAddress: string): MakeTxResponse; makeBeginRedelegateTx(amount: string, srcValidatorAddress: string, dstValidatorAddress: string): MakeTxResponse; makeWithdrawDelegationRewardTx(validatorAddresses: string[]): MakeTxResponse; makeCCTPDepositForBurnWithCallerTx(rawCCTPMsgValue: string, rawSendMsg: string): MakeTxResponse; makeCCTPDepositForBurnTx(from: string, amount: string, destinationDomain: number, mintRecipient: string, burnToken: string): MakeTxResponse; protected get queries(): DeepReadonly; }