@@ -463,45 +463,47 @@ async function _sendUserOp(args: {
463
463
options : SmartAccountOptions ;
464
464
} ) : Promise < WaitForReceiptOptions > {
465
465
const { executeTx, options } = args ;
466
- const unsignedUserOp = await createUnsignedUserOp ( {
467
- transaction : executeTx ,
468
- factoryContract : options . factoryContract ,
469
- accountContract : options . accountContract ,
470
- adminAddress : options . personalAccount . address ,
471
- sponsorGas : options . sponsorGas ,
472
- overrides : options . overrides ,
473
- } ) ;
474
- const signedUserOp = await signUserOp ( {
475
- client : options . client ,
476
- chain : options . chain ,
477
- adminAccount : options . personalAccount ,
478
- entrypointAddress : options . overrides ?. entrypointAddress ,
479
- userOp : unsignedUserOp ,
480
- } ) ;
481
- const bundlerOptions : BundlerOptions = {
482
- chain : options . chain ,
483
- client : options . client ,
484
- bundlerUrl : options . overrides ?. bundlerUrl ,
485
- entrypointAddress : options . overrides ?. entrypointAddress ,
486
- } ;
487
- const userOpHash = await bundleUserOp ( {
488
- options : bundlerOptions ,
489
- userOp : signedUserOp ,
490
- } ) ;
491
- // wait for tx receipt rather than return the userOp hash
492
- const receipt = await waitForUserOpReceipt ( {
493
- ...bundlerOptions ,
494
- userOpHash,
495
- } ) ;
496
-
497
- // reset the isDeploying flag after every transaction
498
- clearAccountDeploying ( options . accountContract ) ;
466
+ try {
467
+ const unsignedUserOp = await createUnsignedUserOp ( {
468
+ transaction : executeTx ,
469
+ factoryContract : options . factoryContract ,
470
+ accountContract : options . accountContract ,
471
+ adminAddress : options . personalAccount . address ,
472
+ sponsorGas : options . sponsorGas ,
473
+ overrides : options . overrides ,
474
+ } ) ;
475
+ const signedUserOp = await signUserOp ( {
476
+ client : options . client ,
477
+ chain : options . chain ,
478
+ adminAccount : options . personalAccount ,
479
+ entrypointAddress : options . overrides ?. entrypointAddress ,
480
+ userOp : unsignedUserOp ,
481
+ } ) ;
482
+ const bundlerOptions : BundlerOptions = {
483
+ chain : options . chain ,
484
+ client : options . client ,
485
+ bundlerUrl : options . overrides ?. bundlerUrl ,
486
+ entrypointAddress : options . overrides ?. entrypointAddress ,
487
+ } ;
488
+ const userOpHash = await bundleUserOp ( {
489
+ options : bundlerOptions ,
490
+ userOp : signedUserOp ,
491
+ } ) ;
492
+ // wait for tx receipt rather than return the userOp hash
493
+ const receipt = await waitForUserOpReceipt ( {
494
+ ...bundlerOptions ,
495
+ userOpHash,
496
+ } ) ;
499
497
500
- return {
501
- client : options . client ,
502
- chain : options . chain ,
503
- transactionHash : receipt . transactionHash ,
504
- } ;
498
+ return {
499
+ client : options . client ,
500
+ chain : options . chain ,
501
+ transactionHash : receipt . transactionHash ,
502
+ } ;
503
+ } finally {
504
+ // reset the isDeploying flag after every transaction or error
505
+ clearAccountDeploying ( options . accountContract ) ;
506
+ }
505
507
}
506
508
507
509
async function getEntrypointFromFactory (
0 commit comments