import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base"; import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types"; import { Network, NetworkEndpoints } from "@injectivelabs/networks"; import { TxResponse } from "@injectivelabs/sdk-ts/core/tx"; import { StdSignDoc } from "@keplr-wallet/types"; import { OfflineSigner } from "@cosmjs/proto-signing"; import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types"; import { Msgs } from "@injectivelabs/sdk-ts/core/modules"; //#region src/utils/tx.d.ts declare const checkIfTxRunOutOfGas: (e: unknown) => boolean; //#endregion //#region src/strategy/BaseWalletStrategy.d.ts declare class BaseWalletStrategy implements WalletStrategy { strategies: ConcreteStrategiesArg; wallet: Wallet; args: WalletStrategyArguments; metadata?: WalletMetadata; wallets?: Wallet[]; private emitter; on: WalletStrategyEmitter['on']; off: WalletStrategyEmitter['off']; emit: WalletStrategyEmitter['emit']; constructor(args: WalletStrategyArguments); /** * Get the emitter instance. * Used to pass to strategies so they can emit events directly. */ getEmitter(): WalletStrategyEmitter; getWallet(): Wallet; setWallet(wallet: Wallet): Promise; setMetadata(metadata?: WalletMetadata): void; getStrategy(): ConcreteWalletStrategy; getAddresses(args?: unknown): Promise; getAddressesInfo(args?: unknown): Promise<{ address: string; derivationPath: string; baseDerivationPath: string; }[]>; getWalletDeviceType(): Promise; getPubKey(address?: string): Promise; enable(args?: unknown): Promise; enableAndGetAddresses(args?: unknown): Promise; getEthereumChainId(): Promise; getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise; getSessionOrConfirm(address?: AccountAddress): Promise; getWalletClient(): Promise; sendTransaction(tx: DirectSignResponse | TxRaw, options: SendTransactionOptions): Promise; sendEvmTransaction(tx: any, options: { evmChainId: EvmChainId; address: AccountAddress; }): Promise; signEip712TypedData(eip712TypedData: string, address: AccountAddress, options?: { txTimeout?: number; }): Promise; signAminoCosmosTransaction(transaction: { signDoc: StdSignDoc; address: string; }): Promise; signCosmosTransaction(transaction: { txRaw: TxRaw; accountNumber: number; chainId: string; address: string; }): Promise; signArbitrary(signer: string, data: string | Uint8Array): Promise; onAccountChange(callback: onAccountChangeCallback): Promise; onChainIdChange(callback: onChainIdChangeCallback): Promise; disconnect(): Promise; getCosmosWallet(chainId: ChainId): CosmosWalletAbstraction; getEip1193Provider(): Promise; getOfflineSigner(chainId: string): Promise; } //#endregion //#region src/broadcaster/types.d.ts interface MsgBroadcasterTxOptions { memo?: string; ethereumAddress?: string; injectiveAddress?: string; msgs: Msgs | Msgs[]; gas?: { gasPrice?: string; gas?: number; /** gas limit */ feePayer?: string; granter?: string; }; } interface MsgBroadcasterTxOptionsWithAddresses extends MsgBroadcasterTxOptions { ethereumAddress: string; injectiveAddress: string; } interface MsgBroadcasterOptions { network: Network; endpoints?: NetworkEndpoints; chainId?: ChainId; evmChainId?: EvmChainId; feePayerPubKey?: string; simulateTx?: boolean; txTimeoutOnFeeDelegation?: boolean; txTimeout?: number; walletStrategy: BaseWalletStrategy; gasBufferCoefficient?: number; httpHeaders?: Record; } //#endregion //#region src/broadcaster/MsgBroadcaster.d.ts /** * This class is used to broadcast transactions * using the WalletStrategy as a handler * for the sign/broadcast flow of the transactions * * Mainly used for building UI products */ declare class MsgBroadcaster { options: MsgBroadcasterOptions; walletStrategy: BaseWalletStrategy; endpoints: NetworkEndpoints; chainId: ChainId; txTimeout: number; simulateTx: boolean; txTimeoutOnFeeDelegation: boolean; evmChainId?: EvmChainId; gasBufferCoefficient: number; retriesOnError: { [x: string]: { retries: number; maxRetries: number; timeout: number; }; }; httpHeaders?: Record; constructor(options: MsgBroadcasterOptions); setOptions(options: Partial): void; getEvmChainId(): Promise; /** * Broadcasting the transaction using the client * side approach for both cosmos and ethereum native wallets * * @param tx * @returns {string} transaction hash */ broadcast(tx: MsgBroadcasterTxOptions): Promise; /** * Broadcasting the transaction using the client * side approach for both cosmos and ethereum native wallets * Note: using EIP712_V2 for Ethereum wallets * * @param tx * @returns {string} transaction hash */ broadcastV2(tx: MsgBroadcasterTxOptions): Promise; /** * Broadcasting the transaction using the feeDelegation * support approach for both cosmos and ethereum native wallets * * @param tx * @returns {string} transaction hash */ broadcastWithFeeDelegation(tx: MsgBroadcasterTxOptions): Promise; /** * Prepare/sign/broadcast transaction using * Ethereum native wallets on the client side. * * Note: Gas estimation not available * * @param tx The transaction that needs to be broadcasted * @returns transaction hash */ private broadcastEip712; /** * Prepare/sign/broadcast transaction using * Ethereum native wallets on the client side. * * Note: Gas estimation not available * * @param tx The transaction that needs to be broadcasted * @returns transaction hash */ private broadcastEip712V2; /** * Prepare/sign/broadcast transaction using * Ethereum native wallets using the Web3Gateway. * * @param tx The transaction that needs to be broadcasted * @returns transaction hash */ private broadcastEip712WithFeeDelegation; /** * Prepare/sign/broadcast transaction using * Cosmos native wallets on the client side. * * @param tx The transaction that needs to be broadcasted * @returns transaction hash */ private broadcastDirectSign; /** * We use this method only when we want to broadcast a transaction using Ledger on Keplr/Leap for Injective * * Note: Gas estimation not available * @param tx the transaction that needs to be broadcasted */ private experimentalBroadcastWalletThroughLedger; /** * Prepare/sign/broadcast transaction using * Cosmos native wallets using the Web3Gateway. * * @param tx The transaction that needs to be broadcasted * @returns transaction hash */ private broadcastDirectSignWithFeeDelegation; /** * Fetch the fee payer's pub key from the web3 gateway * * Returns a base64 version of it */ private fetchFeePayerPubKey; private getStdFeeWithDynamicBaseFee; /** * In case we don't want to simulate the transaction * we get the gas limit based on the message type. * * If we want to simulate the transaction we set the * gas limit based on the simulation and add a small multiplier * to be safe (factor of 1.2 as default) */ private getTxWithSignersAndStdFee; /** * Create TxRaw and simulate it */ private simulateTxRaw; /** * Create TxRaw and simulate it */ private simulateTxWithSigners; private retryOnException; private fetchAccountAndBlockDetails; } //#endregion //#region src/broadcaster/Web3Broadcaster.d.ts interface SendTransactionOptions$1 { tx: { from: string; to: string; gas: string; maxFeePerGas: string; maxPriorityFeePerGas: string | null; data: any; }; address: string; evmChainId?: EvmChainId; } /** * Preparing and broadcasting * Ethereum transactions */ declare class Web3Broadcaster { private walletStrategy; private evmChainId; constructor({ walletStrategy, evmChainId }: { walletStrategy: BaseWalletStrategy; evmChainId: EvmChainId; network: Network; }); sendTransaction(args: SendTransactionOptions$1): Promise; } //#endregion export { BaseWalletStrategy, MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses, Web3Broadcaster, checkIfTxRunOutOfGas };