import type { Hex } from '@metamask/utils'; import type { TransactionControllerMessenger } from '../TransactionController.js'; /** * Feature flags supporting the transaction controller. */ export declare enum FeatureFlag { EIP7702 = "confirmations_eip_7702", GasBuffer = "confirmations_gas_buffer", Transactions = "confirmations_transactions" } type GasEstimateFallback = { /** * The fixed gas estimate fallback for a transaction. */ fixed?: number; /** * The percentage multiplier gas estimate fallback for a transaction. */ percentage?: number; /** * The maximum gas limit the fallback can resolve to, representing the chain's * per-transaction gas cap. Clamps the `fixed` or `percentage`-derived fallback * so it can never exceed the gas limit the RPC will accept (e.g. ~33.5M on * Polygon, whereas 35% of its ~140M block gas limit would otherwise be ~49M). */ maxGasLimit?: number; }; export type TransactionControllerFeatureFlags = { /** Feature flags to support EIP-7702 / type-4 transactions. */ [FeatureFlag.EIP7702]?: { /** * All contracts that support EIP-7702 batch transactions. * Keyed by chain ID. * First entry in each array is the contract that standard EOAs will be upgraded to. */ contracts?: Record; /** Chains enabled for EIP-7702 batch transactions. */ supportedChains?: Hex[]; }; /** * Buffers added to gas limit estimations. * Values are multipliers such as `1.5` meaning 150% of the original gas limit. */ [FeatureFlag.GasBuffer]?: { /** Fallback buffer for all chains and transactions. */ default?: number; /** * Buffer for included network RPCs only and not those added by user. * Takes priority over `default`. */ included?: number; /** Buffers for specific chains. */ perChainConfig?: { [chainId: Hex]: { /** * Buffer for the chain for all transactions. * Takes priority over non-chain `included`. */ base?: number; /** * Buffer if network RPC is included and not added by user. * Takes priority over `base`. */ included?: number; /** * Buffer for the chain for EIP-7702 / type 4 transactions only. * Only if `data` included and `to` matches `from`. * Takes priority over `included` and `base`. */ eip7702?: number; }; }; }; /** Miscellaneous feature flags to support the transaction controller. */ [FeatureFlag.Transactions]?: { /** Maximum number of transactions that can be in an external batch. */ batchSizeLimit?: number; /** Maximum number of entries in the submit history. */ submitHistoryLimit?: number; /** Maximum number of transactions stored in state. */ transactionHistoryLimit?: number; /** * Accelerated polling is used to speed up the polling process for * transactions that are not yet confirmed. */ acceleratedPolling?: { /** Accelerated polling parameters on a per-chain basis. */ perChainConfig?: { [chainId: Hex]: { /** * Block time in milliseconds. */ blockTime?: number; /** * Maximum number of polling requests that can be made in a row, before * the normal polling resumes. */ countMax?: number; /** Interval between polling requests in milliseconds. */ intervalMs?: number; }; }; /** Default `countMax` in case no chain-specific parameter is set. */ defaultCountMax?: number; /** Default `intervalMs` in case no chain-specific parameter is set. */ defaultIntervalMs?: number; }; gasFeeRandomisation?: { /** Randomised gas fee digits per chainId. */ randomisedGasFeeDigits?: Record; /** Number of digits to preserve for randomised gas fee digits. */ preservedNumberOfDigits?: number; }; /** Gas estimate fallback is used as a fallback in case of failure to obtain the gas estimate values. */ gasEstimateFallback?: { /** Gas estimate fallback per-chain basis. */ perChainConfig?: { [chainId: Hex]: GasEstimateFallback; }; /** * Default gas estimate fallback. * This value is used when no specific gas estimate fallback is found for a chain ID. */ default?: GasEstimateFallback; }; /** * Number of attempts to wait before automatically marking a transaction as failed * if it has no receipt status and hash is not found on the network. */ timeoutAttempts?: { /** Automatic fail threshold on a per-chain basis. */ perChainConfig?: { [chainId: Hex]: number; }; /** * Default automatic fail threshold. * This value is used when no specific threshold is found for a chain ID. */ default?: number; }; /** * Replacement of underpriced dapp-suggested gas fees. * If enabled, dapp-suggested EIP-1559 fees with a `maxFeePerGas` below the * current low estimate are replaced with the wallet's suggested fees, as * they are unlikely to be included in a block before fee values change. */ replaceUnderpricedDappGasFees?: { /** Enablement on a per-chain basis. */ perChainConfig?: { [chainId: Hex]: boolean; }; /** * Default enablement. * This value is used when no specific value is found for a chain ID. */ default?: boolean; }; /** * Replacement of underpriced saved (advanced) gas fee preferences. * If enabled, saved custom fees with a `maxBaseFee` below the current low * estimate are ignored in favour of the wallet's suggested fees, as they * are unlikely to be included in a block before fee values change. * Level-based saved preferences track current estimates and are never * ignored. */ replaceUnderpricedSavedGasFees?: { /** Enablement on a per-chain basis. */ perChainConfig?: { [chainId: Hex]: boolean; }; /** * Default enablement. * This value is used when no specific value is found for a chain ID. */ default?: boolean; }; }; }; /** * Retrieves the supported EIP-7702 chains. * * @param messenger - The controller messenger instance. * @returns The supported chains. */ export declare function getEIP7702SupportedChains(messenger: TransactionControllerMessenger): Hex[]; /** * Retrieves the supported EIP-7702 contract addresses for a given chain ID. * * @param chainId - The chain ID. * @param messenger - The controller messenger instance. * @param publicKey - The public key used to validate the contract authenticity. * @returns The supported contract addresses. */ export declare function getEIP7702ContractAddresses(chainId: Hex, messenger: TransactionControllerMessenger, publicKey: Hex): Hex[]; /** * Retrieves the EIP-7702 upgrade contract address. * * @param chainId - The chain ID. * @param messenger - The controller messenger instance. * @param publicKey - The public key used to validate the contract authenticity. * @returns The upgrade contract address. */ export declare function getEIP7702UpgradeContractAddress(chainId: Hex, messenger: TransactionControllerMessenger, publicKey: Hex): Hex | undefined; /** * Retrieves the batch size limit. * Defaults to 10 if not set. * * @param messenger - The controller messenger instance. * @returns The batch size limit. */ export declare function getBatchSizeLimit(messenger: TransactionControllerMessenger): number; /** * Retrieves the submit history limit. * Defaults to 100 if not set. * * @param messenger - The controller messenger instance. * @returns The submit history limit. */ export declare function getSubmitHistoryLimit(messenger: TransactionControllerMessenger): number; /** * Retrieves the transaction history limit. * Defaults to 40 if not set. * * @param messenger - The controller messenger instance. * @returns The transaction history limit. */ export declare function getTransactionHistoryLimit(messenger: TransactionControllerMessenger): number | undefined; /** * Retrieves the accelerated polling parameters for a given chain ID. * * @param chainId - The chain ID. * @param messenger - The controller messenger instance. * @returns The accelerated polling parameters: `countMax` and `intervalMs`. */ export declare function getAcceleratedPollingParams(chainId: Hex, messenger: TransactionControllerMessenger): { blockTime: number; countMax: number; intervalMs: number; }; /** * Retrieves the gas fee randomisation parameters. * * @param messenger - The controller messenger instance. * @returns The gas fee randomisation parameters. */ export declare function getGasFeeRandomisation(messenger: TransactionControllerMessenger): { randomisedGasFeeDigits: Record; preservedNumberOfDigits: number | undefined; }; /** * Retrieves the gas estimate fallback for a given chain ID. * Defaults to the default gas estimate fallback if not set. * * @param chainId - The chain ID. * @param messenger - The controller messenger instance. * @returns The gas estimate fallback. */ export declare function getGasEstimateFallback(chainId: Hex, messenger: TransactionControllerMessenger): { fixed?: number; percentage: number; maxGasLimit?: number; }; /** * Retrieves the gas buffers for a given chain ID. * * @param request - The request object. * @param request.chainId - The chain ID. * @param request.isCustomRPC - Whether the network RPC is added by the user. * @param request.isUpgradeWithData - Whether the transaction is an EIP-7702 upgrade combined with a call. * @param request.messenger - The controller messenger instance. * @returns The gas buffers. */ export declare function getGasEstimateBuffer({ chainId, isCustomRPC, isUpgradeWithData, messenger, }: { chainId: Hex; isCustomRPC: boolean; isUpgradeWithData: boolean; messenger: TransactionControllerMessenger; }): number; /** * Retrieves the incoming transactions polling interval. * Retrieves the number of attempts to wait before automatically marking a transaction as dropped * if it has no receipt status. * * @param chainId - The chain ID. * @param messenger - The controller messenger instance. * @returns The threshold number of attempts, or undefined if the feature is disabled. */ export declare function getTimeoutAttempts(chainId: Hex, messenger: TransactionControllerMessenger): number | undefined; /** * Retrieves whether underpriced dapp-suggested gas fees should be replaced * with the wallet's suggested fees. * * @param chainId - The chain ID. * @param messenger - The controller messenger instance. * @returns Whether the replacement is enabled. */ export declare function getReplaceUnderpricedDappGasFeesEnabled(chainId: Hex, messenger: TransactionControllerMessenger): boolean; /** * Retrieves whether underpriced saved (advanced) gas fee preferences should be * ignored in favour of the wallet's suggested fees. * * @param chainId - The chain ID. * @param messenger - The controller messenger instance. * @returns Whether the replacement is enabled. */ export declare function getReplaceUnderpricedSavedGasFeesEnabled(chainId: Hex, messenger: TransactionControllerMessenger): boolean; export {}; //# sourceMappingURL=feature-flags.d.ts.map