import type { Hex } from '@metamask/utils'; import BN from 'bn.js'; import type { FeeMarketEIP1559Values, GasPriceValue, TransactionError, TransactionMeta, TransactionParams } from '../types.js'; export declare const ESTIMATE_GAS_ERROR = "eth_estimateGas rpc method error"; /** * Normalizes properties on transaction params. * * @param txParams - The transaction params to normalize. * @returns Normalized transaction params. */ export declare function normalizeTransactionParams(txParams: TransactionParams): TransactionParams; /** * Checks if a transaction is EIP-1559 by checking for the existence of * maxFeePerGas and maxPriorityFeePerGas within its parameters. * * @param txParams - Transaction params object to add. * @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false. */ export declare function isEIP1559Transaction(txParams: TransactionParams): boolean; export declare const validateGasValues: (gasValues: GasPriceValue | FeeMarketEIP1559Values) => void; /** * Validates that a transaction is unapproved. * Throws if the transaction is not unapproved. * * @param transactionMeta - The transaction metadata to check. * @param fnName - The name of the function calling this helper. */ export declare function validateIfTransactionUnapproved(transactionMeta: TransactionMeta | undefined, fnName: string): void; /** * Validates that a transaction is unapproved or submitted. * Throws if the transaction is not unapproved or submitted. * * @param transactionMeta - The transaction metadata to check. * @param fnName - The name of the function calling this helper. */ export declare function validateIfTransactionUnapprovedOrSubmitted(transactionMeta: TransactionMeta | undefined, fnName: string): void; /** * Normalizes properties on transaction params. * * @param error - The error to be normalize. * @returns Normalized transaction error. */ export declare function normalizeTxError(error: Error & { code?: string; value?: unknown; }): TransactionError; /** * Normalize an object containing gas fee values. * * @param gasFeeValues - An object containing gas fee values. * @returns An object containing normalized gas fee values. */ export declare function normalizeGasFeeValues(gasFeeValues: GasPriceValue | FeeMarketEIP1559Values): GasPriceValue | FeeMarketEIP1559Values; /** * Ensure a hex string is of even length by adding a leading 0 if necessary. * Any existing `0x` prefix is preserved but is not added if missing. * * @param hexValue - The hex string to ensure is even. * @returns The hex string with an even length. */ export declare function padHexToEvenLength(hexValue: string): string; /** * Create a BN from a hex string, accepting an optional 0x prefix. * * @param hexValue - Hex string with or without 0x prefix. * @returns BN parsed as base-16. */ export declare function bnFromHex(hexValue: string | Hex): BN; /** * Convert various numeric-like values to a BN instance. * Accepts BN, ethers BigNumber, hex string, bigint, or number. * * @param value - The value to convert. * @returns BN representation of the input value. */ export declare function toBN(value: unknown): BN; /** * Calculate the absolute percentage change between two values. * * @param originalValue - The first value. * @param newValue - The second value. * @returns The percentage change from the first value to the second value. * If the original value is zero and the new value is not, returns 100. */ export declare function getPercentageChange(originalValue: BN, newValue: BN): number; /** * Sets the envelope type for the given transaction parameters based on the * current network's EIP-1559 compatibility and the transaction parameters. * * @param txParams - The transaction parameters to set the envelope type for. * @param isEIP1559Compatible - Indicates if the current network supports EIP-1559. */ export declare function setEnvelopeType(txParams: TransactionParams, isEIP1559Compatible: boolean): void; /** * Convert CAIP-2 chain ID to hex format. * * @param caip2ChainId - Chain ID in CAIP-2 format (e.g., 'eip155:1') * @returns Hex chain ID (e.g., '0x1') or undefined if invalid format */ export declare function caip2ToHex(caip2ChainId: string): Hex | undefined; //# sourceMappingURL=utils.d.ts.map