Skip to content

Commit e548675

Browse files
feat: switch to v2 bundler for all user operations (#4884)
1 parent 514647c commit e548675

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

.changeset/dry-toes-clean.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+
Switch to v2 bundler for all user operations for better performance

packages/thirdweb/src/wallets/smart/lib/bundler.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
ENTRYPOINT_ADDRESS_v0_6,
2222
MANAGED_ACCOUNT_GAS_BUFFER,
2323
getDefaultBundlerUrl,
24-
getEntryPointVersion,
2524
} from "./constants.js";
2625
import { hexlifyUserOp } from "./utils.js";
2726

@@ -269,12 +268,7 @@ async function sendBundlerRequest(args: {
269268
console.debug(`>>> sending ${operation} with payload:`, params);
270269
}
271270

272-
const entryPointVersion = getEntryPointVersion(
273-
options.entrypointAddress || ENTRYPOINT_ADDRESS_v0_6,
274-
);
275-
const bundlerVersion = entryPointVersion === "v0.6" ? "v1" : "v2";
276-
const bundlerUrl =
277-
options.bundlerUrl ?? getDefaultBundlerUrl(options.chain, bundlerVersion);
271+
const bundlerUrl = options.bundlerUrl ?? getDefaultBundlerUrl(options.chain);
278272
const fetchWithHeaders = getClientFetch(options.client);
279273
const response = await fetchWithHeaders(bundlerUrl, {
280274
method: "POST",

packages/thirdweb/src/wallets/smart/lib/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export const getDefaultAccountFactory = (entryPointAddress?: string) => {
3636
/**
3737
* @internal
3838
*/
39-
export const getDefaultBundlerUrl = (chain: Chain, version: "v1" | "v2") => {
39+
export const getDefaultBundlerUrl = (chain: Chain) => {
4040
const domain = getThirdwebDomains().bundler;
4141
if (domain.startsWith("localhost:")) {
42-
return `http://${domain}/${version ?? "v1"}?chain=${chain.id}`;
42+
return `http://${domain}/v2?chain=${chain.id}`;
4343
}
44-
return `https://${chain.id}.${domain}/${version ?? "v1"}`;
44+
return `https://${chain.id}.${domain}/v2`;
4545
};
4646

4747
export const getEntryPointVersion = (address: string): "v0.6" | "v0.7" => {

packages/thirdweb/src/wallets/smart/lib/paymaster.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
DEBUG,
1212
ENTRYPOINT_ADDRESS_v0_6,
1313
getDefaultBundlerUrl,
14-
getEntryPointVersion,
1514
} from "./constants.js";
1615
import { hexlifyUserOp } from "./utils.js";
1716

@@ -53,9 +52,7 @@ export async function getPaymasterAndData(args: {
5352
};
5453

5554
const entrypoint = entrypointAddress ?? ENTRYPOINT_ADDRESS_v0_6;
56-
const entrypointVersion = getEntryPointVersion(entrypoint);
57-
const paymasterVersion = entrypointVersion === "v0.6" ? "v1" : "v2";
58-
const paymasterUrl = getDefaultBundlerUrl(chain, paymasterVersion);
55+
const paymasterUrl = getDefaultBundlerUrl(chain);
5956

6057
// Ask the paymaster to sign the transaction and return a valid paymasterAndData value.
6158
const fetchWithHeaders = getClientFetch(client);

packages/thirdweb/src/wallets/smart/lib/userop.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,7 @@ async function getGasFees(args: {
218218
const { executeTx, bundlerOptions, chain, client } = args;
219219
let { maxFeePerGas, maxPriorityFeePerGas } = executeTx;
220220

221-
const entrypointVersion = getEntryPointVersion(
222-
bundlerOptions.entrypointAddress || ENTRYPOINT_ADDRESS_v0_6,
223-
);
224-
const bundlerVersion = entrypointVersion === "v0.6" ? "v1" : "v2";
225-
const bundlerUrl =
226-
bundlerOptions?.bundlerUrl ?? getDefaultBundlerUrl(chain, bundlerVersion);
221+
const bundlerUrl = bundlerOptions?.bundlerUrl ?? getDefaultBundlerUrl(chain);
227222

228223
if (isThirdwebUrl(bundlerUrl)) {
229224
// get gas prices from bundler

0 commit comments

Comments
 (0)