From 220743344f80ba83a5951bd3d426308f523a4212 Mon Sep 17 00:00:00 2001 From: Prithvish Baidya Date: Fri, 23 May 2025 01:35:56 +0530 Subject: [PATCH 1/2] Upgrade thirdweb to v5.100.1 and update UserOp handling for gas overrides --- package.json | 2 +- src/worker/tasks/send-transaction-worker.ts | 221 +++++++++--- yarn.lock | 361 +++++++++++++++++--- 3 files changed, 479 insertions(+), 105 deletions(-) diff --git a/package.json b/package.json index 373e8ac8..4b73fd49 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "prisma": "^5.14.0", "prom-client": "^15.1.3", "superjson": "^2.2.1", - "thirdweb": "5.96.5", + "thirdweb": "^5.100.1", "undici": "^6.20.1", "uuid": "^9.0.1", "viem": "2.22.17", diff --git a/src/worker/tasks/send-transaction-worker.ts b/src/worker/tasks/send-transaction-worker.ts index 71cac0bc..5ca62765 100644 --- a/src/worker/tasks/send-transaction-worker.ts +++ b/src/worker/tasks/send-transaction-worker.ts @@ -2,7 +2,10 @@ import assert from "node:assert"; import { type Job, type Processor, Worker } from "bullmq"; import superjson from "superjson"; import { + type Address, + type Chain, type Hex, + type ThirdwebClient, getAddress, getContract, readContract, @@ -13,9 +16,9 @@ import { getChainMetadata } from "thirdweb/chains"; import { isZkSyncChain, stringify } from "thirdweb/utils"; import type { Account } from "thirdweb/wallets"; import { - type UserOperation, bundleUserOp, - createAndSignUserOp, + prepareUserOp, + signUserOp, smartWallet, } from "thirdweb/wallets/smart"; import { getContractAddress } from "viem"; @@ -60,6 +63,8 @@ import { SendTransactionQueue, } from "../queues/send-transaction-queue"; +type VersionedUserOp = Awaited>; + /** * Submit a transaction to RPC (EOA transactions) or bundler (userOps). * @@ -180,61 +185,97 @@ const _sendUserOp = async ( }; } - let signedUserOp: UserOperation; - try { - // Resolve the user factory from the provided address, or from the `factory()` method if found. - let accountFactoryAddress = userProvidedAccountFactoryAddress; - if (!accountFactoryAddress) { - // TODO: this is not a good solution since the assumption that the account has a factory function is not guaranteed - // instead, we should use default account factory address or throw here. - try { - const smartAccountContract = getContract({ - client: thirdwebClient, - chain, - address: accountAddress, - }); - const onchainAccountFactoryAddress = await readContract({ - contract: smartAccountContract, - method: "function factory() view returns (address)", - params: [], - }); - accountFactoryAddress = getAddress(onchainAccountFactoryAddress); - } catch { - throw new Error( - `Failed to find factory address for account '${accountAddress}' on chain '${chainId}'`, - ); - } + // Part 1: Prepare the userop + // Step 1: Get factory address + let accountFactoryAddress: Address | undefined; + + if (userProvidedAccountFactoryAddress) { + accountFactoryAddress = userProvidedAccountFactoryAddress; + } else { + const smartAccountContract = getContract({ + client: thirdwebClient, + chain, + address: accountAddress, + }); + + try { + const onchainAccountFactoryAddress = await readContract({ + contract: smartAccountContract, + method: "function factory() view returns (address)", + params: [], + }); + accountFactoryAddress = getAddress(onchainAccountFactoryAddress); + } catch (error) { + const errorMessage = `${wrapError(error, "RPC").message} Failed to find factory address for account`; + const erroredTransaction: ErroredTransaction = { + ...queuedTransaction, + status: "errored", + errorMessage, + }; + job.log(`Failed to get account factory address: ${errorMessage}`); + return erroredTransaction; } + } - const transactions = queuedTransaction.batchOperations - ? queuedTransaction.batchOperations.map((op) => ({ - ...op, - chain, + // Step 2: Get entrypoint address + let entrypointAddress: string | undefined; + if (userProvidedEntrypointAddress) { + entrypointAddress = queuedTransaction.entrypointAddress; + } else { + try { + entrypointAddress = await getEntrypointFromFactory( + adminAccount.address, + thirdwebClient, + chain, + ); + } catch (error) { + const errorMessage = `${wrapError(error, "RPC").message} Failed to find entrypoint address for account factory`; + const erroredTransaction: ErroredTransaction = { + ...queuedTransaction, + status: "errored", + errorMessage, + }; + job.log( + `Failed to find entrypoint address for account factory: ${errorMessage}`, + ); + return erroredTransaction; + } + } + + // Step 3: Transform transactions for userop + const transactions = queuedTransaction.batchOperations + ? queuedTransaction.batchOperations.map((op) => ({ + ...op, + chain, + client: thirdwebClient, + })) + : [ + { client: thirdwebClient, - })) - : [ - { - client: thirdwebClient, - chain, - data: queuedTransaction.data, - value: queuedTransaction.value, - ...overrides, // gas-overrides - to: getChecksumAddress(toAddress), - }, - ]; - - signedUserOp = (await createAndSignUserOp({ - client: thirdwebClient, + chain, + data: queuedTransaction.data, + value: queuedTransaction.value, + ...overrides, // gas-overrides + to: getChecksumAddress(toAddress), + }, + ]; + + // Step 4: Prepare userop + let unsignedUserOp: VersionedUserOp | undefined; + + try { + unsignedUserOp = await prepareUserOp({ transactions, adminAccount, + client: thirdwebClient, smartWalletOptions: { chain, sponsorGas: true, - factoryAddress: accountFactoryAddress, + factoryAddress: accountFactoryAddress, // from step 1 overrides: { accountAddress, accountSalt, - entrypointAddress: userProvidedEntrypointAddress, + entrypointAddress, // from step 2 // TODO: let user pass entrypoint address for 0.7 support }, }, @@ -243,7 +284,7 @@ const _sendUserOp = async ( // until the previous userop for the same account is mined // we don't want this behavior in the engine context waitForDeployment: false, - })) as UserOperation; // TODO support entrypoint v0.7 accounts + }); } catch (error) { const errorMessage = wrapError(error, "Bundler").message; const erroredTransaction: ErroredTransaction = { @@ -255,16 +296,66 @@ const _sendUserOp = async ( return erroredTransaction; } - job.log(`Populated userOp: ${stringify(signedUserOp)}`); + // Handle if `maxFeePerGas` is overridden. + // Set it if the transaction will be sent, otherwise delay the job. + if (overrides?.maxFeePerGas && unsignedUserOp.maxFeePerGas) { + if (overrides.maxFeePerGas > unsignedUserOp.maxFeePerGas) { + unsignedUserOp.maxFeePerGas = overrides.maxFeePerGas; + } else { + const retryAt = _minutesFromNow(5); + job.log( + `Override gas fee (${overrides.maxFeePerGas}) is lower than onchain fee (${unsignedUserOp.maxFeePerGas}). Delaying job until ${retryAt}.`, + ); + await job.moveToDelayed(retryAt.getTime()); + return null; + } + } - const userOpHash = await bundleUserOp({ - userOp: signedUserOp, - options: { + // Part 2: Sign the userop + let signedUserOp: VersionedUserOp | undefined; + try { + signedUserOp = await signUserOp({ client: thirdwebClient, chain, - entrypointAddress: userProvidedEntrypointAddress, - }, - }); + adminAccount, + entrypointAddress, + userOp: unsignedUserOp, + }); + } catch (error) { + const errorMessage = `${wrapError(error, "Bundler").message} Failed to sign prepared userop`; + const erroredTransaction: ErroredTransaction = { + ...queuedTransaction, + status: "errored", + errorMessage, + }; + job.log(`Failed to sign userop: ${errorMessage}`); + return erroredTransaction; + } + + job.log(`Populated and signed userOp: ${stringify(signedUserOp)}`); + + // Finally: bundle the userop + let userOpHash: Hex; + + try { + userOpHash = await bundleUserOp({ + userOp: signedUserOp, + options: { + client: thirdwebClient, + chain, + entrypointAddress: userProvidedEntrypointAddress, + }, + }); + } catch (error) { + const errorMessage = `${wrapError(error, "Bundler").message} Failed to bundle userop`; + const erroredTransaction: ErroredTransaction = { + ...queuedTransaction, + status: "errored", + errorMessage, + }; + job.log(`Failed to bundle userop: ${errorMessage}`); + return erroredTransaction; + } return { ...queuedTransaction, @@ -646,6 +737,28 @@ export function _updateGasFees( return updated; } +async function getEntrypointFromFactory( + factoryAddress: string, + client: ThirdwebClient, + chain: Chain, +) { + const factoryContract = getContract({ + address: factoryAddress, + client, + chain, + }); + try { + const entrypointAddress = await readContract({ + contract: factoryContract, + method: "function entrypoint() public view returns (address)", + params: [], + }); + return entrypointAddress; + } catch { + return undefined; + } +} + // Must be explicitly called for the worker to run on this host. export const initSendTransactionWorker = () => { const _worker = new Worker(SendTransactionQueue.q.name, handler, { diff --git a/yarn.lock b/yarn.lock index 97b29499..5bac7d17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2114,6 +2114,11 @@ resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.1.tgz#2f3a8f1d688935c704dbc89132394a41029acbb8" integrity sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ== +"@lit-labs/ssr-dom-shim@^1.2.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.3.0.tgz#a28799c463177d1a0b0e5cefdc173da5ac859eb4" + integrity sha512-nQIWonJ6eFAvUUrSlwyHDm/aE8PBDu5kRpL0vHMg6K8fK3Diq1xdPjTnsJSwxABhaZ+5eBi1btQB5ShUTKo4nQ== + "@lit/reactive-element@^1.3.0", "@lit/reactive-element@^1.6.0": version "1.6.3" resolved "https://registry.yarnpkg.com/@lit/reactive-element/-/reactive-element-1.6.3.tgz#25b4eece2592132845d303e091bad9b04cdcfe03" @@ -2121,6 +2126,13 @@ dependencies: "@lit-labs/ssr-dom-shim" "^1.0.0" +"@lit/reactive-element@^2.0.0", "@lit/reactive-element@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@lit/reactive-element/-/reactive-element-2.1.0.tgz#177148214488068ae209669040b7ce0f4dcc0d36" + integrity sha512-L2qyoZSQClcBmq0qajBVbhYEcG6iK0XfLn66ifLe/RfC0/ihpc+pl0Wdn8bJ8o+hj38cG0fGXRgSS20MuXn7qA== + dependencies: + "@lit-labs/ssr-dom-shim" "^1.2.0" + "@lukeed/ms@^2.0.1": version "2.0.2" resolved "https://registry.yarnpkg.com/@lukeed/ms/-/ms-2.0.2.tgz#07f09e59a74c52f4d88c6db5c1054e819538e2a8" @@ -3130,6 +3142,98 @@ resolved "https://registry.yarnpkg.com/@radix-ui/rect/-/rect-1.1.1.tgz#78244efe12930c56fd255d7923865857c41ac8cb" integrity sha512-HPwpGIzkl28mWyZqG52jiqDJ12waP11Pa1lGoiyUkIEuMLBP0oeK/C89esbXrxsky5we7dfd8U58nm0SgAWpVw== +"@reown/appkit-common@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@reown/appkit-common/-/appkit-common-1.7.3.tgz#f9bf6b3d128bf79c3cd2755581621c2306d80cb1" + integrity sha512-wKTr6N3z8ly17cc51xBEVkZK4zAd8J1m7RubgsdQ1olFY9YJGe61RYoNv9yFjt6tUVeYT+z7iMUwPhX2PziefQ== + dependencies: + big.js "6.2.2" + dayjs "1.11.13" + viem ">=2.23.11" + +"@reown/appkit-controllers@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@reown/appkit-controllers/-/appkit-controllers-1.7.3.tgz#9137763b7bb3a95baf41741863d1da92d4e3bd95" + integrity sha512-aqAcX/nZe0gwqjncyCkVrAk3lEw0qZ9xGrdLOmA207RreO4J0Vxu8OJXCBn4C2AUI2OpBxCPah+vyuKTUJTeHQ== + dependencies: + "@reown/appkit-common" "1.7.3" + "@reown/appkit-wallet" "1.7.3" + "@walletconnect/universal-provider" "2.19.2" + valtio "1.13.2" + viem ">=2.23.11" + +"@reown/appkit-polyfills@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@reown/appkit-polyfills/-/appkit-polyfills-1.7.3.tgz#21895ed9521edd81898b10de16505708b05463f2" + integrity sha512-vQUiAyI7WiNTUV4iNwv27iigdeg8JJTEo6ftUowIrKZ2/gtE2YdMtGpavuztT/qrXhrIlTjDGp5CIyv9WOTu4g== + dependencies: + buffer "6.0.3" + +"@reown/appkit-scaffold-ui@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@reown/appkit-scaffold-ui/-/appkit-scaffold-ui-1.7.3.tgz#ea966de3ab3f992c6a8ffa408eb53906a87986f6" + integrity sha512-ssB15fcjmoKQ+VfoCo7JIIK66a4SXFpCH8uK1CsMmXmKIKqPN54ohLo291fniV6mKtnJxh5Xm68slGtGrO3bmA== + dependencies: + "@reown/appkit-common" "1.7.3" + "@reown/appkit-controllers" "1.7.3" + "@reown/appkit-ui" "1.7.3" + "@reown/appkit-utils" "1.7.3" + "@reown/appkit-wallet" "1.7.3" + lit "3.1.0" + +"@reown/appkit-ui@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@reown/appkit-ui/-/appkit-ui-1.7.3.tgz#a51e7397922b4ace20e991e38989065f951c3d22" + integrity sha512-zKmFIjLp0X24pF9KtPtSHmdsh/RjEWIvz+faIbPGm4tQbwcxdg9A35HeoP0rMgKYx49SX51LgPwVXne2gYacqQ== + dependencies: + "@reown/appkit-common" "1.7.3" + "@reown/appkit-controllers" "1.7.3" + "@reown/appkit-wallet" "1.7.3" + lit "3.1.0" + qrcode "1.5.3" + +"@reown/appkit-utils@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@reown/appkit-utils/-/appkit-utils-1.7.3.tgz#65fbd8748cae8946e069907c3f893dc6cc97452a" + integrity sha512-8/MNhmfri+2uu8WzBhZ5jm5llofOIa1dyXDXRC/hfrmGmCFJdrQKPpuqOFYoimo2s2g70pK4PYefvOKgZOWzgg== + dependencies: + "@reown/appkit-common" "1.7.3" + "@reown/appkit-controllers" "1.7.3" + "@reown/appkit-polyfills" "1.7.3" + "@reown/appkit-wallet" "1.7.3" + "@walletconnect/logger" "2.1.2" + "@walletconnect/universal-provider" "2.19.2" + valtio "1.13.2" + viem ">=2.23.11" + +"@reown/appkit-wallet@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@reown/appkit-wallet/-/appkit-wallet-1.7.3.tgz#77730d4457302eca7c20d696926c670197d42551" + integrity sha512-D0pExd0QUE71ursQPp3pq/0iFrz2oz87tOyFifrPANvH5X0RQCYn/34/kXr+BFVQzNFfCBDlYP+CniNA/S0KiQ== + dependencies: + "@reown/appkit-common" "1.7.3" + "@reown/appkit-polyfills" "1.7.3" + "@walletconnect/logger" "2.1.2" + zod "3.22.4" + +"@reown/appkit@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@reown/appkit/-/appkit-1.7.3.tgz#3d50f098ef305cf8ab59141e66ef47c316bb5f3a" + integrity sha512-aA/UIwi/dVzxEB62xlw3qxHa3RK1YcPMjNxoGj/fHNCqL2qWmbcOXT7coCUa9RG7/Bh26FZ3vdVT2v71j6hebQ== + dependencies: + "@reown/appkit-common" "1.7.3" + "@reown/appkit-controllers" "1.7.3" + "@reown/appkit-polyfills" "1.7.3" + "@reown/appkit-scaffold-ui" "1.7.3" + "@reown/appkit-ui" "1.7.3" + "@reown/appkit-utils" "1.7.3" + "@reown/appkit-wallet" "1.7.3" + "@walletconnect/types" "2.19.2" + "@walletconnect/universal-provider" "2.19.2" + bs58 "6.0.0" + valtio "1.13.2" + viem ">=2.23.11" + "@rollup/rollup-android-arm-eabi@4.28.1": version "4.28.1" resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.28.1.tgz#7f4c4d8cd5ccab6e95d6750dbe00321c1f30791e" @@ -3970,6 +4074,13 @@ resolved "https://registry.yarnpkg.com/@thirdweb-dev/dynamic-contracts/-/dynamic-contracts-1.2.5.tgz#f9735c0d46198e7bf2f98c277f0a9a79c54da1e8" integrity sha512-YVsz+jUWbwj+6aF2eTZGMfyw47a1HRmgNl4LQ3gW9gwYL5y5+OX/yOzv6aV5ibvoqCk/k10aIVK2eFrcpMubQA== +"@thirdweb-dev/engine@3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@thirdweb-dev/engine/-/engine-3.0.1.tgz#df4d1f201775d88c5f87283982187349047047e9" + integrity sha512-RlVwiqWC9n8pBO2dCMKoRxZ6llB3ojH0qydpyzLlqX4nBT/cfFxxzOz/V+BzuEvKIfv3DUozvkCKUBJ8A18fgg== + dependencies: + "@hey-api/client-fetch" "0.10.0" + "@thirdweb-dev/generated-abis@0.0.2": version "0.0.2" resolved "https://registry.yarnpkg.com/@thirdweb-dev/generated-abis/-/generated-abis-0.0.2.tgz#d0e4f51011ba2ce2bbc266c8a295b04ffd523bab" @@ -4449,10 +4560,10 @@ lodash.isequal "4.5.0" uint8arrays "3.1.0" -"@walletconnect/core@2.19.1": - version "2.19.1" - resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.19.1.tgz#71738940341b438326b65b3f49226decbe070bae" - integrity sha512-rMvpZS0tQXR/ivzOxN1GkHvw3jRRMlI/jRX5g7ZteLgg2L0ZcANsFvAU5IxILxIKcIkTCloF9TcfloKVbK3qmw== +"@walletconnect/core@2.19.2": + version "2.19.2" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.19.2.tgz#4bf3918dd8041843a1b796e2c4e1f101363d72a4" + integrity sha512-iu0mgLj51AXcKpdNj8+4EdNNBd/mkNjLEhZn6UMc/r7BM9WbmpPMEydA39WeRLbdLO4kbpmq4wTbiskI1rg+HA== dependencies: "@walletconnect/heartbeat" "1.2.2" "@walletconnect/jsonrpc-provider" "1.0.14" @@ -4465,8 +4576,31 @@ "@walletconnect/relay-auth" "1.1.0" "@walletconnect/safe-json" "1.0.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.19.1" - "@walletconnect/utils" "2.19.1" + "@walletconnect/types" "2.19.2" + "@walletconnect/utils" "2.19.2" + "@walletconnect/window-getters" "1.0.1" + es-toolkit "1.33.0" + events "3.3.0" + uint8arrays "3.1.0" + +"@walletconnect/core@2.20.1": + version "2.20.1" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.20.1.tgz#dc854a1b29e911c1f4dcec3a02ab3c343d235cd8" + integrity sha512-DxybNfznr7aE/U9tJqvpEorUW2f/6kR0S1Zk78NqKam1Ex+BQFDM5j2Az3WayfFDZz3adkxkLAszfdorvPxDlw== + dependencies: + "@walletconnect/heartbeat" "1.2.2" + "@walletconnect/jsonrpc-provider" "1.0.14" + "@walletconnect/jsonrpc-types" "1.0.4" + "@walletconnect/jsonrpc-utils" "1.0.8" + "@walletconnect/jsonrpc-ws-connection" "1.0.16" + "@walletconnect/keyvaluestorage" "1.1.1" + "@walletconnect/logger" "2.1.2" + "@walletconnect/relay-api" "1.0.11" + "@walletconnect/relay-auth" "1.1.0" + "@walletconnect/safe-json" "1.0.2" + "@walletconnect/time" "1.0.2" + "@walletconnect/types" "2.20.1" + "@walletconnect/utils" "2.20.1" "@walletconnect/window-getters" "1.0.1" es-toolkit "1.33.0" events "3.3.0" @@ -4495,21 +4629,21 @@ "@walletconnect/utils" "2.12.2" events "^3.3.0" -"@walletconnect/ethereum-provider@2.19.1": - version "2.19.1" - resolved "https://registry.yarnpkg.com/@walletconnect/ethereum-provider/-/ethereum-provider-2.19.1.tgz#1618d6bc98aad839e682940f451d1e9a2b2e46d0" - integrity sha512-bs8Kiwdw3cGb8ITO8+YymesGfFnucJreQmVbZ0vl/Ogoh38n1T5w0ekjmD/NjTDS3oZaUQyBm3V2UjIBR0qedw== +"@walletconnect/ethereum-provider@2.20.1": + version "2.20.1" + resolved "https://registry.yarnpkg.com/@walletconnect/ethereum-provider/-/ethereum-provider-2.20.1.tgz#942d516e4f14e463c7a43dbed91f214393dd4853" + integrity sha512-D/T7ctrVHSSCxKGPIRpWR3ICAU4Q5jKsUkYhaW3C8LFeIpgXoCllZHVgjYBmgjicqjT3faixIZ1tgmJmOeuY6g== dependencies: + "@reown/appkit" "1.7.3" "@walletconnect/jsonrpc-http-connection" "1.0.8" "@walletconnect/jsonrpc-provider" "1.0.14" "@walletconnect/jsonrpc-types" "1.0.4" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/keyvaluestorage" "1.1.1" - "@walletconnect/modal" "2.7.0" - "@walletconnect/sign-client" "2.19.1" - "@walletconnect/types" "2.19.1" - "@walletconnect/universal-provider" "2.19.1" - "@walletconnect/utils" "2.19.1" + "@walletconnect/sign-client" "2.20.1" + "@walletconnect/types" "2.20.1" + "@walletconnect/universal-provider" "2.20.1" + "@walletconnect/utils" "2.20.1" events "3.3.0" "@walletconnect/events@1.0.1", "@walletconnect/events@^1.0.1": @@ -4645,7 +4779,7 @@ motion "10.16.2" qrcode "1.5.3" -"@walletconnect/modal@2.7.0", "@walletconnect/modal@^2.6.2": +"@walletconnect/modal@^2.6.2": version "2.7.0" resolved "https://registry.yarnpkg.com/@walletconnect/modal/-/modal-2.7.0.tgz#55f969796d104cce1205f5f844d8f8438b79723a" integrity sha512-RQVt58oJ+rwqnPcIvRFeMGKuXb9qkgSmwz4noF8JZGUym3gUAzVs+uW2NQ1Owm9XOJAV+sANrtJ+VoVq1ftElw== @@ -4720,19 +4854,34 @@ "@walletconnect/utils" "2.17.1" events "3.3.0" -"@walletconnect/sign-client@2.19.1": - version "2.19.1" - resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.19.1.tgz#6cfbb4ee0eaf3a8774a8c70ff65ba23177e8f388" - integrity sha512-OgBHRPo423S02ceN3lAzcZ3MYb1XuLyTTkKqLmKp/icYZCyRzm3/ynqJDKndiBLJ5LTic0y07LiZilnliYqlvw== +"@walletconnect/sign-client@2.19.2": + version "2.19.2" + resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.19.2.tgz#6b728fd8b1ebf8f47b231bedf56b725de660633d" + integrity sha512-a/K5PRIFPCjfHq5xx3WYKHAAF8Ft2I1LtxloyibqiQOoUtNLfKgFB1r8sdMvXM7/PADNPe4iAw4uSE6PrARrfg== dependencies: - "@walletconnect/core" "2.19.1" + "@walletconnect/core" "2.19.2" "@walletconnect/events" "1.0.1" "@walletconnect/heartbeat" "1.2.2" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "2.1.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.19.1" - "@walletconnect/utils" "2.19.1" + "@walletconnect/types" "2.19.2" + "@walletconnect/utils" "2.19.2" + events "3.3.0" + +"@walletconnect/sign-client@2.20.1": + version "2.20.1" + resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.20.1.tgz#56fce57837c197055724b57dcefc6280fa3eade0" + integrity sha512-QXzIAHbyZZ52+97Bp/+/SBkN3hX0pam8l4lnA4P7g+aFPrVZUrMwZPIf+FV7UbEswqqwo3xmFI41TKgj8w8B9w== + dependencies: + "@walletconnect/core" "2.20.1" + "@walletconnect/events" "1.0.1" + "@walletconnect/heartbeat" "1.2.2" + "@walletconnect/jsonrpc-utils" "1.0.8" + "@walletconnect/logger" "2.1.2" + "@walletconnect/time" "1.0.2" + "@walletconnect/types" "2.20.1" + "@walletconnect/utils" "2.20.1" events "3.3.0" "@walletconnect/sign-client@^2.13.1": @@ -4793,10 +4942,22 @@ "@walletconnect/logger" "2.1.2" events "3.3.0" -"@walletconnect/types@2.19.1": - version "2.19.1" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.19.1.tgz#ec78c5a05238e220871cca3e360193584af2d968" - integrity sha512-XWWGLioddH7MjxhyGhylL7VVariVON2XatJq/hy0kSGJ1hdp31z194nHN5ly9M495J9Hw8lcYjGXpsgeKvgxzw== +"@walletconnect/types@2.19.2": + version "2.19.2" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.19.2.tgz#3518cffdd74a7d07a110c9da5da939c1b185e837" + integrity sha512-/LZWhkVCUN+fcTgQUxArxhn2R8DF+LSd/6Wh9FnpjeK/Sdupx1EPS8okWG6WPAqq2f404PRoNAfQytQ82Xdl3g== + dependencies: + "@walletconnect/events" "1.0.1" + "@walletconnect/heartbeat" "1.2.2" + "@walletconnect/jsonrpc-types" "1.0.4" + "@walletconnect/keyvaluestorage" "1.1.1" + "@walletconnect/logger" "2.1.2" + events "3.3.0" + +"@walletconnect/types@2.20.1": + version "2.20.1" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.20.1.tgz#8956e5c610430349ae5f49a2a09547fe16d055a7" + integrity sha512-HM0YZxT+wNqskoZkuju5owbKTlqUXNKfGlJk/zh9pWaVWBR2QamvQ+47Cx09OoGPRQjQH0JmgRiUV4bOwWNeHg== dependencies: "@walletconnect/events" "1.0.1" "@walletconnect/heartbeat" "1.2.2" @@ -4820,10 +4981,10 @@ "@walletconnect/utils" "2.12.2" events "^3.3.0" -"@walletconnect/universal-provider@2.19.1": - version "2.19.1" - resolved "https://registry.yarnpkg.com/@walletconnect/universal-provider/-/universal-provider-2.19.1.tgz#9908431b766fffcb0f617f3fdb7e85f27f05f9de" - integrity sha512-4rdLvJ2TGDIieNWW3sZw2MXlX65iHpTuKb5vyvUHQtjIVNLj+7X/09iUAI/poswhtspBK0ytwbH+AIT/nbGpjg== +"@walletconnect/universal-provider@2.19.2": + version "2.19.2" + resolved "https://registry.yarnpkg.com/@walletconnect/universal-provider/-/universal-provider-2.19.2.tgz#a87d2c5da01a16ac8c107adcd27ee8c894e2331b" + integrity sha512-LkKg+EjcSUpPUhhvRANgkjPL38wJPIWumAYD8OK/g4OFuJ4W3lS/XTCKthABQfFqmiNbNbVllmywiyE44KdpQg== dependencies: "@walletconnect/events" "1.0.1" "@walletconnect/jsonrpc-http-connection" "1.0.8" @@ -4832,9 +4993,27 @@ "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/keyvaluestorage" "1.1.1" "@walletconnect/logger" "2.1.2" - "@walletconnect/sign-client" "2.19.1" - "@walletconnect/types" "2.19.1" - "@walletconnect/utils" "2.19.1" + "@walletconnect/sign-client" "2.19.2" + "@walletconnect/types" "2.19.2" + "@walletconnect/utils" "2.19.2" + es-toolkit "1.33.0" + events "3.3.0" + +"@walletconnect/universal-provider@2.20.1": + version "2.20.1" + resolved "https://registry.yarnpkg.com/@walletconnect/universal-provider/-/universal-provider-2.20.1.tgz#8a553ce51c67460c15c29631d2193b8d4c555f67" + integrity sha512-0WfO4Unb+8UMEUr65vrVjd/a/3tF5059KLP7gX2kaDFjXXOma1/cjq/9/STd3hbHB8LKfxpXvOty97vuD8xfWQ== + dependencies: + "@walletconnect/events" "1.0.1" + "@walletconnect/jsonrpc-http-connection" "1.0.8" + "@walletconnect/jsonrpc-provider" "1.0.14" + "@walletconnect/jsonrpc-types" "1.0.4" + "@walletconnect/jsonrpc-utils" "1.0.8" + "@walletconnect/keyvaluestorage" "1.1.1" + "@walletconnect/logger" "2.1.2" + "@walletconnect/sign-client" "2.20.1" + "@walletconnect/types" "2.20.1" + "@walletconnect/utils" "2.20.1" es-toolkit "1.33.0" events "3.3.0" @@ -4910,10 +5089,33 @@ query-string "7.1.3" uint8arrays "3.1.0" -"@walletconnect/utils@2.19.1": - version "2.19.1" - resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.19.1.tgz#16cbc173cd3b28cbf86ca5c6e362057810da07f9" - integrity sha512-aOwcg+Hpph8niJSXLqkU25pmLR49B8ECXp5gFQDW5IeVgXHoOoK7w8a79GBhIBheMLlIt1322sTKQ7Rq5KzzFg== +"@walletconnect/utils@2.19.2": + version "2.19.2" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.19.2.tgz#90259b69367e30ccd13cf8252547a6850ca5fb2e" + integrity sha512-VU5CcUF4sZDg8a2/ov29OJzT3KfLuZqJUM0GemW30dlipI5fkpb0VPenZK7TcdLPXc1LN+Q+7eyTqHRoAu/BIA== + dependencies: + "@noble/ciphers" "1.2.1" + "@noble/curves" "1.8.1" + "@noble/hashes" "1.7.1" + "@walletconnect/jsonrpc-utils" "1.0.8" + "@walletconnect/keyvaluestorage" "1.1.1" + "@walletconnect/relay-api" "1.0.11" + "@walletconnect/relay-auth" "1.1.0" + "@walletconnect/safe-json" "1.0.2" + "@walletconnect/time" "1.0.2" + "@walletconnect/types" "2.19.2" + "@walletconnect/window-getters" "1.0.1" + "@walletconnect/window-metadata" "1.0.1" + bs58 "6.0.0" + detect-browser "5.3.0" + query-string "7.1.3" + uint8arrays "3.1.0" + viem "2.23.2" + +"@walletconnect/utils@2.20.1": + version "2.20.1" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.20.1.tgz#432689b559b573e14237b9f0f555835617e3cb84" + integrity sha512-u/uyJkVyxLLUbHbpMv7MmuOkGfElG08l6P2kMTAfN7nAVyTgpb8g6kWLMNqfmYXVz+h+finf5FSV4DgL2vOvPQ== dependencies: "@noble/ciphers" "1.2.1" "@noble/curves" "1.8.1" @@ -4924,12 +5126,11 @@ "@walletconnect/relay-auth" "1.1.0" "@walletconnect/safe-json" "1.0.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.19.1" + "@walletconnect/types" "2.20.1" "@walletconnect/window-getters" "1.0.1" "@walletconnect/window-metadata" "1.0.1" bs58 "6.0.0" detect-browser "5.3.0" - elliptic "6.6.1" query-string "7.1.3" uint8arrays "3.1.0" viem "2.23.2" @@ -5268,6 +5469,11 @@ bech32@1.1.4: resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== +big.js@6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-6.2.2.tgz#be3bb9ac834558b53b099deef2a1d06ac6368e1a" + integrity sha512-y/ie+Faknx7sZA5MfGA2xKlu0GDv8RWrXGsmlteyJQ2lvoKv9GBK/fpRMc2qlSoBAgNxrixICFCBefIq8WCQpQ== + bignumber.js@^9.0.0, bignumber.js@^9.0.1: version "9.1.2" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c" @@ -5475,7 +5681,7 @@ buffer@4.9.2, buffer@^4.3.0: ieee754 "^1.1.4" isarray "^1.0.0" -buffer@^6.0.3: +buffer@6.0.3, buffer@^6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== @@ -6040,6 +6246,11 @@ d@1, d@^1.0.1, d@^1.0.2: es5-ext "^0.10.64" type "^2.7.2" +dayjs@1.11.13: + version "1.11.13" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c" + integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg== + dc-polyfill@^0.1.4: version "0.1.6" resolved "https://registry.yarnpkg.com/dc-polyfill/-/dc-polyfill-0.1.6.tgz#c2940fa68ffb24a7bf127cc6cfdd15b39f0e7f02" @@ -6192,6 +6403,11 @@ depd@2.0.0: resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== +derive-valtio@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/derive-valtio/-/derive-valtio-0.1.0.tgz#4b9fb393dfefccfef15fcbbddd745dd22d5d63d7" + integrity sha512-OCg2UsLbXK7GmmpzMXhYkdO64vhJ1ROUUGaTFyHjVwEdMEcTTRj7W1TxLbSBxdY8QLBPCcp66MTyaSy0RpO17A== + des.js@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.1.0.tgz#1d37f5766f3bbff4ee9638e871a8768c173b81da" @@ -6314,7 +6530,7 @@ ejs@^3.1.10: dependencies: jake "^10.8.5" -elliptic@6.5.4, elliptic@6.5.7, elliptic@6.6.0, elliptic@6.6.1, elliptic@>=6.6.0, elliptic@^6.4.1, elliptic@^6.5.2, elliptic@^6.5.3, elliptic@^6.5.5, elliptic@^6.5.7: +elliptic@6.5.4, elliptic@6.5.7, elliptic@6.6.0, elliptic@>=6.6.0, elliptic@^6.4.1, elliptic@^6.5.2, elliptic@^6.5.3, elliptic@^6.5.5, elliptic@^6.5.7: version "6.6.1" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.1.tgz#3b8ffb02670bf69e382c7f65bf524c97c5405c06" integrity sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g== @@ -8247,6 +8463,15 @@ lit-element@^3.3.0: "@lit/reactive-element" "^1.3.0" lit-html "^2.8.0" +lit-element@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-4.2.0.tgz#75dcf9e5fae3e3b5fd3f02a5d297c582d0bb0ba3" + integrity sha512-MGrXJVAI5x+Bfth/pU9Kst1iWID6GHDLEzFEnyULB/sFiRLgkd8NPK/PeeXxktA3T6EIIaq8U3KcbTU5XFcP2Q== + dependencies: + "@lit-labs/ssr-dom-shim" "^1.2.0" + "@lit/reactive-element" "^2.1.0" + lit-html "^3.3.0" + lit-html@^2.8.0: version "2.8.0" resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-2.8.0.tgz#96456a4bb4ee717b9a7d2f94562a16509d39bffa" @@ -8254,6 +8479,13 @@ lit-html@^2.8.0: dependencies: "@types/trusted-types" "^2.0.2" +lit-html@^3.1.0, lit-html@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-3.3.0.tgz#f66c734a6c69dbb12abf9a718fa5d3dfb46d0b7c" + integrity sha512-RHoswrFAxY2d8Cf2mm4OZ1DgzCoBKUKSPvA1fhtSELxUERq2aQQ2h05pO9j81gS1o7RIRJ+CePLogfyahwmynw== + dependencies: + "@types/trusted-types" "^2.0.2" + lit@2.8.0, lit@^2.2.3: version "2.8.0" resolved "https://registry.yarnpkg.com/lit/-/lit-2.8.0.tgz#4d838ae03059bf9cafa06e5c61d8acc0081e974e" @@ -8263,6 +8495,15 @@ lit@2.8.0, lit@^2.2.3: lit-element "^3.3.0" lit-html "^2.8.0" +lit@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lit/-/lit-3.1.0.tgz#76429b85dc1f5169fed499a0f7e89e2e619010c9" + integrity sha512-rzo/hmUqX8zmOdamDAeydfjsGXbbdtAFqMhmocnh2j9aDYqbu0fjXygjCa0T99Od9VQ/2itwaGrjZz/ZELVl7w== + dependencies: + "@lit/reactive-element" "^2.0.0" + lit-element "^4.0.0" + lit-html "^3.1.0" + localforage@^1.7.4: version "1.10.0" resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4" @@ -9576,6 +9817,11 @@ proxy-compare@2.5.1: resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-2.5.1.tgz#17818e33d1653fbac8c2ec31406bce8a2966f600" integrity sha512-oyfc0Tx87Cpwva5ZXezSp5V9vht1c7dZBhvuV/y3ctkgMVUmiAGDVeeB0dKhGSyT0v1ZTEQYpe/RXlBVBNuCLA== +proxy-compare@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-2.6.0.tgz#5e8c8b5c3af7e7f17e839bf6cf1435bcc4d315b0" + integrity sha512-8xuCeM3l8yqdmbPoYeLbrAXCBWu19XEYc5/F28f5qOaoAIMyfmBUkl5axiK+x9olUvRlcekvnm98AP9RDngOIw== + proxy-from-env@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" @@ -10501,10 +10747,10 @@ thirdweb@5.29.6: uqr "0.1.2" viem "2.13.7" -thirdweb@5.96.5: - version "5.96.5" - resolved "https://registry.yarnpkg.com/thirdweb/-/thirdweb-5.96.5.tgz#03ba7fd68a8df3d8a58a12c03494813b4c924f94" - integrity sha512-OrHarfr2iOiWY3pFHvumz7GSbQq7wX8zwCvCOnFeg3AwITToIOXXXwlQ9ox7C98tgoMyBFh3fcdvZLqbz0Vocg== +thirdweb@^5.100.1: + version "5.100.1" + resolved "https://registry.yarnpkg.com/thirdweb/-/thirdweb-5.100.1.tgz#1ff4e1148b2c9aa56867ea1dd9882df249abd5c9" + integrity sha512-l6tStEQ35UBIWF7yKX+sX62zct8t2rD8Z0jV19T6gJs+Ow19p1jEW3HwjWaK6i/3vCn89IaH1xI/VmuNFaxusw== dependencies: "@coinbase/wallet-sdk" "4.3.0" "@emotion/react" "11.14.0" @@ -10517,9 +10763,10 @@ thirdweb@5.96.5: "@radix-ui/react-icons" "1.3.2" "@radix-ui/react-tooltip" "1.2.3" "@tanstack/react-query" "5.74.4" + "@thirdweb-dev/engine" "3.0.1" "@thirdweb-dev/insight" "1.0.0" - "@walletconnect/ethereum-provider" "2.19.1" - "@walletconnect/sign-client" "2.19.1" + "@walletconnect/ethereum-provider" "2.20.1" + "@walletconnect/sign-client" "2.20.1" abitype "1.0.8" cross-spawn "7.0.6" fuse.js "7.1.0" @@ -10531,7 +10778,7 @@ thirdweb@5.96.5: prompts "2.4.2" toml "3.0.0" uqr "0.1.2" - viem "2.27.2" + viem "2.28.1" thread-stream@^0.15.1: version "0.15.2" @@ -10948,6 +11195,15 @@ valtio@1.11.2: proxy-compare "2.5.1" use-sync-external-store "1.2.0" +valtio@1.13.2: + version "1.13.2" + resolved "https://registry.yarnpkg.com/valtio/-/valtio-1.13.2.tgz#e31d452d5da3550935417670aafd34d832dc7241" + integrity sha512-Qik0o+DSy741TmkqmRfjq+0xpZBXi/Y6+fXZLn0xNF1z/waFMbE3rkivv5Zcf9RrMUp6zswf2J7sbh2KBlba5A== + dependencies: + derive-valtio "0.1.0" + proxy-compare "2.6.0" + use-sync-external-store "1.2.0" + varint@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/varint/-/varint-5.0.2.tgz#5b47f8a947eb668b848e034dcfa87d0ff8a7f7a4" @@ -10958,7 +11214,7 @@ varint@^6.0.0: resolved "https://registry.yarnpkg.com/varint/-/varint-6.0.0.tgz#9881eb0ce8feaea6512439d19ddf84bf551661d0" integrity sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg== -viem@2.13.7, viem@2.22.17, viem@2.23.2, viem@2.27.2: +viem@2.13.7, viem@2.22.17, viem@2.23.2, viem@2.28.1, viem@>=2.23.11: version "2.22.17" resolved "https://registry.yarnpkg.com/viem/-/viem-2.22.17.tgz#71cb5793d898e7850d440653b0043803c2d00c8d" integrity sha512-eqNhlPGgRLR29XEVUT2uuaoEyMiaQZEKx63xT1py9OYsE+ZwlVgjnfrqbXad7Flg2iJ0Bs5Hh7o0FfRWUJGHvg== @@ -11528,6 +11784,11 @@ zod-to-json-schema@^3.23.0: resolved "https://registry.yarnpkg.com/zod-to-json-schema/-/zod-to-json-schema-3.24.1.tgz#f08c6725091aadabffa820ba8d50c7ab527f227a" integrity sha512-3h08nf3Vw3Wl3PK+q3ow/lIil81IT2Oa7YpQyUUDsEWbXveMesdfK1xBd2RhCkynwZndAxixji/7SYJJowr62w== +zod@3.22.4: + version "3.22.4" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff" + integrity sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg== + zod@3.23.8: version "3.23.8" resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" From 70bbdbd3f997864783432729358ac24768a4c392 Mon Sep 17 00:00:00 2001 From: Prithvish Baidya Date: Fri, 23 May 2025 04:03:23 +0530 Subject: [PATCH 2/2] correctly handle job delays for bullmq --- src/worker/tasks/send-transaction-worker.ts | 30 ++++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/worker/tasks/send-transaction-worker.ts b/src/worker/tasks/send-transaction-worker.ts index 5ca62765..836798c9 100644 --- a/src/worker/tasks/send-transaction-worker.ts +++ b/src/worker/tasks/send-transaction-worker.ts @@ -1,5 +1,5 @@ import assert from "node:assert"; -import { type Job, type Processor, Worker } from "bullmq"; +import { DelayedError, type Job, type Processor, Worker } from "bullmq"; import superjson from "superjson"; import { type Address, @@ -70,7 +70,10 @@ type VersionedUserOp = Awaited>; * * This worker also handles retried EOA transactions. */ -const handler: Processor = async (job: Job) => { +const handler: Processor = async ( + job: Job, + token?: string, +) => { const { queueId, resendCount } = superjson.parse( job.data, ); @@ -89,9 +92,9 @@ const handler: Processor = async (job: Job) => { if (transaction.status === "queued") { if (transaction.isUserOp) { - resultTransaction = await _sendUserOp(job, transaction); + resultTransaction = await _sendUserOp(job, transaction, token); } else { - resultTransaction = await _sendTransaction(job, transaction); + resultTransaction = await _sendTransaction(job, transaction, token); } } else if (transaction.status === "sent") { resultTransaction = await _resendTransaction(job, transaction, resendCount); @@ -121,6 +124,7 @@ const handler: Processor = async (job: Job) => { const _sendUserOp = async ( job: Job, queuedTransaction: QueuedTransaction, + token?: string, ): Promise => { assert(queuedTransaction.isUserOp); @@ -218,7 +222,7 @@ const _sendUserOp = async ( } // Step 2: Get entrypoint address - let entrypointAddress: string | undefined; + let entrypointAddress: Address | undefined; if (userProvidedEntrypointAddress) { entrypointAddress = queuedTransaction.entrypointAddress; } else { @@ -298,7 +302,10 @@ const _sendUserOp = async ( // Handle if `maxFeePerGas` is overridden. // Set it if the transaction will be sent, otherwise delay the job. - if (overrides?.maxFeePerGas && unsignedUserOp.maxFeePerGas) { + if ( + typeof overrides?.maxFeePerGas !== "undefined" && + unsignedUserOp.maxFeePerGas + ) { if (overrides.maxFeePerGas > unsignedUserOp.maxFeePerGas) { unsignedUserOp.maxFeePerGas = overrides.maxFeePerGas; } else { @@ -306,8 +313,10 @@ const _sendUserOp = async ( job.log( `Override gas fee (${overrides.maxFeePerGas}) is lower than onchain fee (${unsignedUserOp.maxFeePerGas}). Delaying job until ${retryAt}.`, ); - await job.moveToDelayed(retryAt.getTime()); - return null; + // token is required to acquire lock for delaying currently processing job: https://docs.bullmq.io/patterns/process-step-jobs#delaying + await job.moveToDelayed(retryAt.getTime(), token); + // throwing delayed error is required to notify bullmq worker not to complete or fail the job + throw new DelayedError("Delaying job due to gas fee override"); } } @@ -374,6 +383,7 @@ const _sendUserOp = async ( const _sendTransaction = async ( job: Job, queuedTransaction: QueuedTransaction, + token?: string, ): Promise => { assert(!queuedTransaction.isUserOp); @@ -463,8 +473,8 @@ const _sendTransaction = async ( job.log( `Override gas fee (${overrides.maxFeePerGas}) is lower than onchain fee (${populatedTransaction.maxFeePerGas}). Delaying job until ${retryAt}.`, ); - await job.moveToDelayed(retryAt.getTime()); - return null; + await job.moveToDelayed(retryAt.getTime(), token); + throw new DelayedError("Delaying job due to gas fee override"); } }