Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dry-toes-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Switch to v2 bundler for all user operations for better performance
8 changes: 1 addition & 7 deletions packages/thirdweb/src/wallets/smart/lib/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
ENTRYPOINT_ADDRESS_v0_6,
MANAGED_ACCOUNT_GAS_BUFFER,
getDefaultBundlerUrl,
getEntryPointVersion,
} from "./constants.js";
import { hexlifyUserOp } from "./utils.js";

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

const entryPointVersion = getEntryPointVersion(
options.entrypointAddress || ENTRYPOINT_ADDRESS_v0_6,
);
const bundlerVersion = entryPointVersion === "v0.6" ? "v1" : "v2";
const bundlerUrl =
options.bundlerUrl ?? getDefaultBundlerUrl(options.chain, bundlerVersion);
const bundlerUrl = options.bundlerUrl ?? getDefaultBundlerUrl(options.chain);
const fetchWithHeaders = getClientFetch(options.client);
const response = await fetchWithHeaders(bundlerUrl, {
method: "POST",
Expand Down
6 changes: 3 additions & 3 deletions packages/thirdweb/src/wallets/smart/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
/**
* @internal
*/
export const getDefaultBundlerUrl = (chain: Chain, version: "v1" | "v2") => {
export const getDefaultBundlerUrl = (chain: Chain) => {
const domain = getThirdwebDomains().bundler;
if (domain.startsWith("localhost:")) {
return `http://${domain}/${version ?? "v1"}?chain=${chain.id}`;
return `http://${domain}/v2?chain=${chain.id}`;

Check warning on line 42 in packages/thirdweb/src/wallets/smart/lib/constants.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L42 was not covered by tests
}
return `https://${chain.id}.${domain}/${version ?? "v1"}`;
return `https://${chain.id}.${domain}/v2`;
};

export const getEntryPointVersion = (address: string): "v0.6" | "v0.7" => {
Expand Down
5 changes: 1 addition & 4 deletions packages/thirdweb/src/wallets/smart/lib/paymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DEBUG,
ENTRYPOINT_ADDRESS_v0_6,
getDefaultBundlerUrl,
getEntryPointVersion,
} from "./constants.js";
import { hexlifyUserOp } from "./utils.js";

Expand Down Expand Up @@ -53,9 +52,7 @@ export async function getPaymasterAndData(args: {
};

const entrypoint = entrypointAddress ?? ENTRYPOINT_ADDRESS_v0_6;
const entrypointVersion = getEntryPointVersion(entrypoint);
const paymasterVersion = entrypointVersion === "v0.6" ? "v1" : "v2";
const paymasterUrl = getDefaultBundlerUrl(chain, paymasterVersion);
const paymasterUrl = getDefaultBundlerUrl(chain);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was no reason why we would need to point at /v1? /v2 handles everything /v1 did?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it does


// Ask the paymaster to sign the transaction and return a valid paymasterAndData value.
const fetchWithHeaders = getClientFetch(client);
Expand Down
7 changes: 1 addition & 6 deletions packages/thirdweb/src/wallets/smart/lib/userop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,7 @@ async function getGasFees(args: {
const { executeTx, bundlerOptions, chain, client } = args;
let { maxFeePerGas, maxPriorityFeePerGas } = executeTx;

const entrypointVersion = getEntryPointVersion(
bundlerOptions.entrypointAddress || ENTRYPOINT_ADDRESS_v0_6,
);
const bundlerVersion = entrypointVersion === "v0.6" ? "v1" : "v2";
const bundlerUrl =
bundlerOptions?.bundlerUrl ?? getDefaultBundlerUrl(chain, bundlerVersion);
const bundlerUrl = bundlerOptions?.bundlerUrl ?? getDefaultBundlerUrl(chain);

if (isThirdwebUrl(bundlerUrl)) {
// get gas prices from bundler
Expand Down