@@ -14,7 +14,10 @@ import { CreateAccount, type CreateAccountInput, type CreateAccountOutput } from
1414
1515const WaitForReceiptError = Symbol ( "WaitForReceiptError" )
1616
17- async function createAccount ( { salt, owner } : CreateAccountInput ) : Promise < CreateAccountOutput > {
17+ async function createAccount (
18+ { salt, owner } : CreateAccountInput ,
19+ noNonceRetry ?: "noNonceRetry" ,
20+ ) : Promise < CreateAccountOutput > {
1821 assertDef ( salt ) // from validator
1922 let evmTxInfo : Optional < EvmTxInfo , "evmTxHash" > | undefined
2023 const predictedAddress = computeHappyAccountAddress ( salt , owner )
@@ -75,7 +78,14 @@ async function createAccount({ salt, owner }: CreateAccountInput): Promise<Creat
7578 logger . trace ( "Successfully created account" , address , owner , salt )
7679 return { status : CreateAccount . Success , owner, salt, address }
7780 } catch ( error ) {
78- if ( isNonceTooLowError ( error ) ) evmNonceManager . resyncIfTooLow ( accountDeployer . address )
81+ if ( isNonceTooLowError ( error ) ) {
82+ evmNonceManager . resyncIfTooLow ( accountDeployer . address )
83+ if ( ! noNonceRetry ) {
84+ logger . warn ( "EVM nonce too low, retrying account creation" , { salt, owner } )
85+ return await createAccount ( { salt, owner } , "noNonceRetry" )
86+ }
87+ return { ...outputForGenericError ( error ) , owner, salt }
88+ }
7989
8090 if ( evmTxInfo ) {
8191 // The nonce has been consumed. A transaction must occur with that nonce because other other transactions
0 commit comments