@@ -21,6 +21,11 @@ const requestBodySchema = Type.Object({
2121 description :
2222 "The backend wallet address to reset nonces for. Omit to reset all backend wallets." ,
2323 } ) ,
24+ syncOnchainNonces : Type . Boolean ( {
25+ description :
26+ "Resync nonces to match the onchain transaction count for your backend wallets. (Default: true)" ,
27+ default : true ,
28+ } ) ,
2429} ) ;
2530
2631const responseSchema = Type . Object ( {
@@ -61,7 +66,11 @@ export const resetBackendWalletNoncesRoute = async (
6166 } ,
6267 } ,
6368 handler : async ( req , reply ) => {
64- const { chainId, walletAddress : _walletAddress } = req . body ;
69+ const {
70+ chainId,
71+ walletAddress : _walletAddress ,
72+ syncOnchainNonces,
73+ } = req . body ;
6574
6675 // If chain+wallet are provided, only process that wallet.
6776 // Otherwise process all used wallets that has nonce state.
@@ -70,19 +79,21 @@ export const resetBackendWalletNoncesRoute = async (
7079 ? [ { chainId, walletAddress : getAddress ( _walletAddress ) } ]
7180 : await getUsedBackendWallets ( ) ;
7281
73- const RESYNC_BATCH_SIZE = 50 ;
74- for ( let i = 0 ; i < backendWallets . length ; i += RESYNC_BATCH_SIZE ) {
75- const batch = backendWallets . slice ( i , i + RESYNC_BATCH_SIZE ) ;
82+ const BATCH_SIZE = 50 ;
83+ for ( let i = 0 ; i < backendWallets . length ; i += BATCH_SIZE ) {
84+ const batch = backendWallets . slice ( i , i + BATCH_SIZE ) ;
7685
7786 // Delete nonce state for these backend wallets.
7887 await deleteNoncesForBackendWallets ( backendWallets ) ;
7988
80- // Resync nonces for these backend wallets.
81- await Promise . allSettled (
82- batch . map ( ( { chainId, walletAddress } ) =>
83- syncLatestNonceFromOnchain ( chainId , walletAddress ) ,
84- ) ,
85- ) ;
89+ if ( syncOnchainNonces ) {
90+ // Resync nonces for these backend wallets.
91+ await Promise . allSettled (
92+ batch . map ( ( { chainId, walletAddress } ) =>
93+ syncLatestNonceFromOnchain ( chainId , walletAddress ) ,
94+ ) ,
95+ ) ;
96+ }
8697 }
8798
8899 reply . status ( StatusCodes . OK ) . send ( {
0 commit comments