Skip to content

Commit 7fb5ce1

Browse files
[SDK] fix: Reset deploy flag on bundler errors (#5924)
1 parent ba86d51 commit 7fb5ce1

File tree

2 files changed

+45
-38
lines changed

2 files changed

+45
-38
lines changed

.changeset/cool-pianos-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Ensure resetting deploy flag on bundler errors

packages/thirdweb/src/wallets/smart/index.ts

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -463,45 +463,47 @@ async function _sendUserOp(args: {
463463
options: SmartAccountOptions;
464464
}): Promise<WaitForReceiptOptions> {
465465
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+
});
499497

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+
}
505507
}
506508

507509
async function getEntrypointFromFactory(

0 commit comments

Comments
 (0)