Skip to content

Commit 58fb28d

Browse files
fix: respect bundlerUrl in waitForUserReceipt (#5277)
## Problem solved Fixes CNCT-2217 <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on improving the `thirdweb` package by updating configurations, modifying wallet functionalities, enhancing chain checks, and refining tests for wallet balance functionality. ### Detailed summary - Updated `limit` in `.size-limit.json` from `500 B` to `600 B`. - Changed `options` to `bundlerOptions` in `waitForUserOpReceipt` call. - Added additional chain IDs in `isZkSyncChain.ts`. - Implemented fallback to RPC stack check in `isZkSyncChain.ts`. - Renamed test case from "should work for un-named token" to "should work for native currency" in `getWalletBalance.test.ts`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 322e449 commit 58fb28d

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

.changeset/perfect-pandas-exercise.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+
Respect bundlerUrl in waitForUserReceipt

packages/thirdweb/.size-limit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{
2020
"name": "thirdweb/chains (tree-shaking)",
2121
"path": "./dist/esm/exports/chains.js",
22-
"limit": "500 B",
22+
"limit": "600 B",
2323
"import": "{ ethereum }"
2424
},
2525
{

packages/thirdweb/src/utils/any-evm/zksync/isZkSyncChain.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ export async function isZkSyncChain(chain: Chain) {
1616
chain.id === 4654 ||
1717
chain.id === 333271 ||
1818
chain.id === 37111 ||
19-
chain.id === 978658
19+
chain.id === 978658 ||
20+
chain.id === 531050104 ||
21+
chain.id === 4457845
2022
) {
2123
return true;
2224
}
2325

24-
return false;
26+
// fallback to checking the stack on rpc
27+
try {
28+
const { getChainMetadata } = await import("../../../chains/utils.js");
29+
const chainMetadata = await getChainMetadata(chain);
30+
return chainMetadata.stackType === "zksync_stack";
31+
} catch {
32+
// If the network check fails, assume it's not a ZkSync chain
33+
return false;
34+
}
2535
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ async function _sendUserOp(args: {
624624
});
625625
// wait for tx receipt rather than return the userOp hash
626626
const receipt = await waitForUserOpReceipt({
627-
...options,
627+
...bundlerOptions,
628628
userOpHash,
629629
});
630630

packages/thirdweb/src/wallets/utils/getWalletBalance.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { ANVIL_CHAIN } from "~test/chains.js";
33
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
44
import { TEST_CLIENT } from "~test/test-clients.js";
55
import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
6-
import { defineChain } from "../../chains/utils.js";
76
import { getContract } from "../../contract/contract.js";
87
import { mintTo } from "../../extensions/erc20/write/mintTo.js";
98
import { deployERC20Contract } from "../../extensions/prebuilts/deploy-erc20.js";
@@ -57,12 +56,11 @@ describe.runIf(process.env.TW_SECRET_KEY)("getWalletBalance", () => {
5756
expect(result.displayValue).toBe(amount.toString());
5857
});
5958

60-
it("should work for un-named token", async () => {
59+
it("should work for native currency", async () => {
6160
const result = await getWalletBalance({
6261
address: TEST_ACCOUNT_A.address,
6362
client: TEST_CLIENT,
64-
chain: defineChain(97),
65-
tokenAddress: "0xd66c6B4F0be8CE5b39D52E0Fd1344c389929B378",
63+
chain: ANVIL_CHAIN,
6664
});
6765
expect(result).toBeDefined();
6866
expect(result.decimals).toBe(18);

0 commit comments

Comments
 (0)