import type { AssetList, Chain } from "@chain-registry/types"; import { EncodeObject } from "@cosmjs/proto-signing"; import { MainWalletBase, WalletConnectOptions, WalletManager } from "@cosmos-kit/core"; import { ChainedFunctionifyTuple, ChainGetter, CosmosQueries, CosmwasmQueries, QueriesStore } from "@keplr-wallet/stores"; import { KeplrSignOptions } from "@keplr-wallet/types"; import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { IPromiseBasedObservable } from "mobx-utils"; import { WalletConnectionInProgressError } from "src/account/wallet-errors"; import { Optional, UnionToIntersection } from "utility-types"; import { OsmosisQueries } from "../queries"; import { AccountStoreWallet, DeliverTxResponse } from "./types"; import { TxFee } from "./utils"; export declare class AccountStore[] = []> { readonly chains: (Chain & { features?: string[]; })[]; readonly osmosisChainId: string; protected readonly assets: AssetList[]; protected readonly wallets: MainWalletBase[]; protected readonly queriesStore: QueriesStore<[ CosmosQueries, CosmwasmQueries, OsmosisQueries ]>; protected readonly chainGetter: ChainGetter; protected readonly options: { walletConnectOptions?: WalletConnectOptions; preTxEvents?: { onBroadcastFailed?: (string: string, e?: Error) => void; onBroadcasted?: (string: string, txHash: Uint8Array) => void; onFulfill?: (string: string, tx: any) => void; }; broadcastUrl?: string; simulateUrl?: string; wsObject?: new (url: string, protocols?: string | string[]) => WebSocket; }; protected accountSetCreators: ChainedFunctionifyTuple, [ ChainGetter, string ], Injects>; injectedAccounts: import("mobx").ObservableMap>; private _refreshRequests; txTypeInProgressByChain: import("mobx").ObservableMap; private _walletManager; private _wallets; /** * Keep track of the promise based observable for each wallet and chain id. * Used to prevent multiple calls to the same promise based observable and cache * the result. */ private _walletToSupportChainPromise; private aminoTypes; private registry; constructor(chains: (Chain & { features?: string[]; })[], osmosisChainId: string, assets: AssetList[], wallets: MainWalletBase[], queriesStore: QueriesStore<[ CosmosQueries, CosmwasmQueries, OsmosisQueries ]>, chainGetter: ChainGetter, options?: { walletConnectOptions?: WalletConnectOptions; preTxEvents?: { onBroadcastFailed?: (string: string, e?: Error) => void; onBroadcasted?: (string: string, txHash: Uint8Array) => void; onFulfill?: (string: string, tx: any) => void; }; broadcastUrl?: string; simulateUrl?: string; wsObject?: new (url: string, protocols?: string | string[]) => WebSocket; }, ...accountSetCreators: ChainedFunctionifyTuple, [ ChainGetter, string ], Injects>); private _createWalletManager; private refresh; addWallet(wallet: MainWalletBase): Promise; get walletManager(): WalletManager; /** * Get wallet repository for a given chain name or chain id. * * @param chainNameOrId - Chain name or chain id * @returns Wallet repository */ getWalletRepo(chainNameOrId: string): import("@cosmos-kit/core").WalletRepo; /** * Get the current wallet for the given chain id * @param chainNameOrId - Chain Id * @returns AccountStoreWallet */ getWallet(chainNameOrId: string): AccountStoreWallet | undefined; /** * This method is used to get the injected accounts for a given chain. * If the injected accounts for the chain are already available, it returns them. * Otherwise, it creates new injected accounts by iterating over the account set creators. * * @param chainNameOrId - The name or id of the chain for which to get the injected accounts. * @returns The injected accounts for the given chain. */ getInjectedAccounts(chainNameOrId: string): UnionToIntersection; hasWallet(string: string): boolean; connectedWalletSupportsChain(chainId: string): IPromiseBasedObservable | undefined; /** * Standardizes wallet-specific errors into predefined error types. * * @param {Error | string} error - The error or message from a wallet. * * @returns {Error | WalletConnectionInProgressError} - The appropriate error type * or the original error message within an `Error`. */ matchError(error: Error | string): Error | WalletConnectionInProgressError; signAndBroadcast(chainNameOrId: string, type: string | "unknown", msgs: EncodeObject[] | (() => Promise | EncodeObject[]), memo?: string, fee?: TxFee, _signOptions?: KeplrSignOptions, onTxEvents?: ((tx: DeliverTxResponse) => void) | { onBroadcastFailed?: (e?: Error) => void; onBroadcasted?: (txHash: Uint8Array) => void; onFulfill?: (tx: DeliverTxResponse) => void; }): Promise; sign(wallet: AccountStoreWallet, messages: readonly EncodeObject[], fee: TxFee, memo: string): Promise; private signAmino; private signDirect; getAccountFromNode(wallet: AccountStoreWallet): Promise<{ accountNumber: import("@keplr-wallet/unit").Int; sequence: import("@keplr-wallet/unit").Int; }>; getSequence(wallet: AccountStoreWallet): Promise<{ accountNumber: number; sequence: number; }>; /** * Simulates a transaction and estimates the transaction fee (gas cost) needed to execute it. * * @param wallet - The wallet object containing information about the blockchain wallet. * @param messages - An array of message objects to be encoded and included in the transaction. * @param fee - An optional fee structure that might be used as a backup fee if the chain doesn't support transaction simulation. * @param memo - A string used as a memo or note with the transaction. * * @returns A promise that resolves to the estimated transaction fee, including the estimated gas cost. * * @remarks * The function performs the following steps: * 1. Encodes the messages using the available registry. * 2. Constructs an unsigned transaction object, including specific signing modes, and possibly ignores the public key in simulation. * 3. Sends a POST request to simulate the transaction. * 4. Calculates the estimated gas used, multiplying by a fixed factor (1.5) to provide a buffer. * 5. Includes specific error handling for errors returned from the axios request. * 6. Utilizes a placeholder signature since the transaction signature is not actually verified. * * Note: The estimated gas might be slightly lower than actual given fluctuations in gas prices. * This is offset by multiplying the estimated gas by a fixed factor (1.5) to provide a buffer. * * If the chain does not support transaction simulation, the function may * fall back to using the provided fee parameter. */ estimateFee(wallet: AccountStoreWallet, messages: readonly EncodeObject[], fee: Optional, memo: string): Promise; }