import { PolkadotClient } from "polkadot-api"; export default class NonceManager { private nonceCache; private clientFactory; private nonceLocks; constructor(clientFactory: () => Promise); /** * Get the current nonce for an address * * @param address - The SS58 address to get nonce for * @returns Promise with the current nonce * * @example * const nonce = await nonceManager.getNonce("5Gq2VNFP4yqK1bk5zt552hBxU68Q3ABewGN99zY7qGbpVTFc"); * console.log("Current nonce:", nonce); */ getNonce(address: string): Promise; /** * Get the cached nonce for an address or fetch it from the chain * * @param address - The SS58 address to get nonce for * @returns Promise with the current nonce */ getCurrentNonce(address: string): Promise; /** * Get and increment nonce atomically (thread-safe) * This method ensures that no two transactions get the same nonce * * @param address - The SS58 address to get and increment nonce for * @returns Promise with the nonce to use for the transaction */ getAndIncrementNonce(address: string): Promise; /** * Increment the nonce for an address after a successful transaction * * @param address - The SS58 address to increment nonce for */ incrementNonce(address: string): void; /** * Reset the nonce cache for an address (useful when transactions fail) * * @param address - The SS58 address to reset nonce for */ resetNonce(address: string): Promise; /** * Reset the nonce cache for all addresses */ resetAllNonces(): void; /** * Get the cached nonce for an address (does not fetch from chain) * * @param address - The SS58 address to get cached nonce for * @returns The cached nonce or undefined if not cached * * @example * const cachedNonce = nonceManager.getCachedNonce("5Gq2VNFP4yqK1bk5zt552hBxU68Q3ABewGN99zY7qGbpVTFc"); * console.log("Cached nonce:", cachedNonce); */ getCachedNonce(address: string): number | undefined; /** * Sync the cached nonce with the current nonce from the blockchain * This is useful when you want to ensure the cache is up to date * * @param address - The SS58 address to sync nonce for * @returns Promise with the updated nonce * * @example * const updatedNonce = await nonceManager.syncNonceFromChain("5Gq2VNFP4yqK1bk5zt552hBxU68Q3ABewGN99zY7qGbpVTFc"); * console.log("Synced nonce:", updatedNonce); */ syncNonceFromChain(address: string): Promise; /** * Get the current nonce from blockchain and update cache (alias for syncNonceFromChain) * * @param address - The SS58 address to get nonce for * @returns Promise with the current nonce from blockchain * * @example * const blockchainNonce = await nonceManager.getNonceFromChain("5Gq2VNFP4yqK1bk5zt552hBxU68Q3ABewGN99zY7qGbpVTFc"); * console.log("Blockchain nonce:", blockchainNonce); */ getNonceFromChain(address: string): Promise; }