From 60a45f622f4c5472d021dcb51a9b0d88498abeff Mon Sep 17 00:00:00 2001 From: Alex Forshtat Date: Sun, 23 Nov 2025 09:08:37 +0000 Subject: [PATCH] WIP: Fix handling of multiple nonces on single chain --- packages/sdk/src/sdk/builder/CrossChainBuilder.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/sdk/src/sdk/builder/CrossChainBuilder.ts b/packages/sdk/src/sdk/builder/CrossChainBuilder.ts index 065f39d..2505f0b 100644 --- a/packages/sdk/src/sdk/builder/CrossChainBuilder.ts +++ b/packages/sdk/src/sdk/builder/CrossChainBuilder.ts @@ -240,14 +240,22 @@ export class CrossChainBuilder implements ICrossChainBuilder { unspentVoucherFee: BigInt(unspentVoucherFeePercent * 10_000), } } - + + lastNonce: Map = new Map() /** * Call the paymaster's 'getSenderNonce' view function for the account. */ async _getVoucherSenderNonce (chainId: bigint) { let smartAccount = this.getAccount() - return await this.config.paymasters.call(chainId, + if (this.lastNonce.has(chainId)) { + const nonce = this.lastNonce.get(chainId) + this.lastNonce.set(chainId, nonce + 1n) + return nonce + } + const nonce = await this.config.paymasters.call(chainId, 'getSenderNonce', [smartAccount.addressOn(chainId)]) + this.lastNonce.set(chainId, nonce + 1n) + return nonce } /**