import { Provider } from 'ethers'; /** * Per-(chainId, address) nonce sequencing for transaction submission. * * Acquisitions for the same key serialize through a Promise chain: * each caller stores the "released" Promise of the previous caller in * the `locks` map (the tail of the chain). The next caller reads that * tail, captures it in closure, and stores its own tail. The read / * store / await sequence is synchronous from the event loop's * perspective, so concurrent acquisitions for the same key never lose * their place in line — the previous bug where two waiters could each * "see" the same tail and both proceed concurrently is gone. * * Memory: the `locks` map only holds the latest tail per key. * Previously-acquired (and released) Promises are referenced only by * the closures of any callers still awaiting them; once all such * waiters drain, they become unreachable and are garbage collected. * * Different (chainId, address) keys never block each other. */ export declare class AsyncNonceManager { private nonces; /** Latest "released" Promise per key (the tail of the FIFO chain). */ private locks; /** * Generate a unique key for (address, chainId) pair. */ private getKey; /** * Acquire the lock for `key` and return a `release()` function that * the caller MUST invoke to unblock the next waiter. The returned * Promise resolves when this caller holds the lock. */ private acquireLock; /** * Get the next nonce for the given address on the given chain. * * @param provider - Ethers provider to fetch nonce from chain * @param address - The address to get the nonce for * @param chainId - Optional chain ID (will be fetched from provider if not provided) * @returns The next nonce to use */ getNonce(provider: Provider, address: string, chainId?: number): Promise; /** * Reset the nonce for the given address by fetching from chain. * * @param provider - Ethers provider to fetch nonce from chain * @param address - The address to reset the nonce for * @param chainId - Optional chain ID (will be fetched from provider if not provided) */ resetNonce(provider: Provider, address: string, chainId?: number): Promise; /** * Clear the cached nonce for the given address (without fetching from chain). * * @param address - The address to clear the nonce for * @param chainId - The chain ID */ clearNonce(address: string, chainId: number): void; /** * Clear all cached nonces. */ clearAll(): void; /** * Get the current cached nonce value (for testing/debugging). * Returns undefined if no nonce is cached. */ getCachedNonce(address: string, chainId: number): number | undefined; } //# sourceMappingURL=nonceManager.d.ts.map