Skip to content

Commit

Permalink
[SDK] fix: Reset deploy flag on bundler errors (#5924)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges authored Jan 10, 2025
1 parent ba86d51 commit 7fb5ce1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-pianos-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Ensure resetting deploy flag on bundler errors
78 changes: 40 additions & 38 deletions packages/thirdweb/src/wallets/smart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,45 +463,47 @@ async function _sendUserOp(args: {
options: SmartAccountOptions;
}): Promise<WaitForReceiptOptions> {
const { executeTx, options } = args;
const unsignedUserOp = await createUnsignedUserOp({
transaction: executeTx,
factoryContract: options.factoryContract,
accountContract: options.accountContract,
adminAddress: options.personalAccount.address,
sponsorGas: options.sponsorGas,
overrides: options.overrides,
});
const signedUserOp = await signUserOp({
client: options.client,
chain: options.chain,
adminAccount: options.personalAccount,
entrypointAddress: options.overrides?.entrypointAddress,
userOp: unsignedUserOp,
});
const bundlerOptions: BundlerOptions = {
chain: options.chain,
client: options.client,
bundlerUrl: options.overrides?.bundlerUrl,
entrypointAddress: options.overrides?.entrypointAddress,
};
const userOpHash = await bundleUserOp({
options: bundlerOptions,
userOp: signedUserOp,
});
// wait for tx receipt rather than return the userOp hash
const receipt = await waitForUserOpReceipt({
...bundlerOptions,
userOpHash,
});

// reset the isDeploying flag after every transaction
clearAccountDeploying(options.accountContract);
try {
const unsignedUserOp = await createUnsignedUserOp({
transaction: executeTx,
factoryContract: options.factoryContract,
accountContract: options.accountContract,
adminAddress: options.personalAccount.address,
sponsorGas: options.sponsorGas,
overrides: options.overrides,
});
const signedUserOp = await signUserOp({
client: options.client,
chain: options.chain,
adminAccount: options.personalAccount,
entrypointAddress: options.overrides?.entrypointAddress,
userOp: unsignedUserOp,
});
const bundlerOptions: BundlerOptions = {
chain: options.chain,
client: options.client,
bundlerUrl: options.overrides?.bundlerUrl,
entrypointAddress: options.overrides?.entrypointAddress,
};
const userOpHash = await bundleUserOp({
options: bundlerOptions,
userOp: signedUserOp,
});
// wait for tx receipt rather than return the userOp hash
const receipt = await waitForUserOpReceipt({
...bundlerOptions,
userOpHash,
});

return {
client: options.client,
chain: options.chain,
transactionHash: receipt.transactionHash,
};
return {
client: options.client,
chain: options.chain,
transactionHash: receipt.transactionHash,
};
} finally {
// reset the isDeploying flag after every transaction or error
clearAccountDeploying(options.accountContract);
}
}

async function getEntrypointFromFactory(
Expand Down

0 comments on commit 7fb5ce1

Please sign in to comment.