/// import { EventEmitter } from 'events'; import { Mutex } from 'async-mutex'; import { TxOptions, TypedTransaction } from '@ethereumjs/tx'; import { PrefixedHexString } from 'ethereumjs-util'; import { Address, ContractInteractor, IntString, LoggerInterface, ObjectMap, TransactionType } from '@opengsn/common'; import { TxStoreManager } from './TxStoreManager'; import { KeyManager } from './KeyManager'; import { ServerConfigParams, ServerDependencies } from './ServerConfigParams'; import { ServerAction, ShortBlockInfo, StoredTransaction } from './StoredTransaction'; import { GasPriceFetcher } from './GasPriceFetcher'; export interface SignedTransactionDetails { transactionHash: PrefixedHexString; signedTx: PrefixedHexString; nonce: number; } export interface SendTransactionDetails { signer: Address; serverAction: ServerAction; method?: any; destination: Address; value?: IntString; gasLimit?: number; maxFeePerGas?: IntString; maxPriorityFeePerGas?: IntString; creationBlockNumber: number; creationBlockHash: string; creationBlockTimestamp: number; } export interface BalanceRequiredDetails { signer: Address; signerBalance: IntString; requiredBalance: IntString; isSufficient: boolean; } export interface BoostingResult { /** * Mapping old transaction hashes to new ones for transactions that were successfully boosted */ boostedTransactions: Map; /** * Details for the first transaction that could not be boosted due to insufficient balance */ balanceRequiredDetails?: BalanceRequiredDetails; } export declare class TransactionManager extends EventEmitter { nonceMutex: Mutex; managerKeyManager: KeyManager; workersKeyManager: KeyManager; contractInteractor: ContractInteractor; nonces: Record; txStoreManager: TxStoreManager; config: ServerConfigParams; logger: LoggerInterface; gasPriceFetcher: GasPriceFetcher; transactionType: TransactionType; rawTxOptions: TxOptions; constructor(dependencies: ServerDependencies, config: ServerConfigParams); _initNonces(): void; init(transactionType: TransactionType): Promise; printBoostedTransactionLog(txHash: string, creationBlock: ShortBlockInfo, maxFeePerGas: number, maxPriorityFeePerGas: number, isMaxGasPriceReached: boolean): void; printSendTransactionLog(transaction: StoredTransaction, from: Address): void; validateBalance(signer: string, maxFeePerGas: number, gasLimit: number, signerBalance: string): Promise; broadcastTransaction(signedTx: string, verifiedTxId: string, nonce: number): Promise; getNonceGapFilled(signer: Address, fromNonce: number, toNonce: number): Promise>; sendTransaction(txDetails: SendTransactionDetails): Promise; updateTransactionWithMinedBlock(tx: StoredTransaction, minedBlock: ShortBlockInfo): Promise; updateTransactionWithAttempt(txToUpdate: TypedTransaction, tx: StoredTransaction, currentBlock: ShortBlockInfo): Promise; resendTransaction(tx: StoredTransaction, currentBlock: ShortBlockInfo, newMaxFee: number, newMaxPriorityFee: number, isMaxGasPriceReached: boolean): Promise<{ signedTransactionDetails?: SignedTransactionDetails; balanceRequiredDetails: BalanceRequiredDetails; }>; _resolveNewGasPrice(oldMaxFee: number, oldMaxPriorityFee: number, minMaxPriorityFee: number, minMaxFee: number): { newMaxFee: number; newMaxPriorityFee: number; isMaxGasPriceReached: boolean; }; pollNonce(signer: Address): Promise; removeArchivedTransactions(currentBlock: ShortBlockInfo): Promise; fillMinedBlockDetailsForTransactions(currentBlock: ShortBlockInfo): Promise; /** * This method uses the oldest pending transaction for reference. If it was not mined in a reasonable time, * it is boosted. All consequent transactions with gas price lower than that are boosted as well. */ boostUnderpricedPendingTransactionsForSigner(signer: string, currentBlock: ShortBlockInfo, minMaxPriorityFee: number): Promise; }