Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect bundlerUrl in waitForUserReceipt #5277

Merged
merged 1 commit into from
Nov 4, 2024
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/perfect-pandas-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Respect bundlerUrl in waitForUserReceipt
2 changes: 1 addition & 1 deletion packages/thirdweb/.size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{
"name": "thirdweb/chains (tree-shaking)",
"path": "./dist/esm/exports/chains.js",
"limit": "500 B",
"limit": "600 B",
"import": "{ ethereum }"
},
{
Expand Down
14 changes: 12 additions & 2 deletions packages/thirdweb/src/utils/any-evm/zksync/isZkSyncChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@
chain.id === 4654 ||
chain.id === 333271 ||
chain.id === 37111 ||
chain.id === 978658
chain.id === 978658 ||
chain.id === 531050104 ||
chain.id === 4457845
) {
return true;
}

return false;
// fallback to checking the stack on rpc
try {
const { getChainMetadata } = await import("../../../chains/utils.js");
const chainMetadata = await getChainMetadata(chain);
return chainMetadata.stackType === "zksync_stack";
} catch {
// If the network check fails, assume it's not a ZkSync chain
return false;
}

Check warning on line 34 in packages/thirdweb/src/utils/any-evm/zksync/isZkSyncChain.ts

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L33 - L34 were not covered by tests
}
2 changes: 1 addition & 1 deletion packages/thirdweb/src/wallets/smart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ async function _sendUserOp(args: {
});
// wait for tx receipt rather than return the userOp hash
const receipt = await waitForUserOpReceipt({
...options,
...bundlerOptions,
Copy link
Member

@gregfromstl gregfromstl Nov 4, 2024

Choose a reason for hiding this comment

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

Are we losing anything here from options? Would it be better to do:

...options,
...bundlerOptions,
userOpHash

so all the same values are still included just in case?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, should just be by doer options here. In fact I might change it to be fully explicit instead of spreading

userOpHash,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ANVIL_CHAIN } from "~test/chains.js";
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
import { TEST_CLIENT } from "~test/test-clients.js";
import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
import { defineChain } from "../../chains/utils.js";
import { getContract } from "../../contract/contract.js";
import { mintTo } from "../../extensions/erc20/write/mintTo.js";
import { deployERC20Contract } from "../../extensions/prebuilts/deploy-erc20.js";
Expand Down Expand Up @@ -57,12 +56,11 @@ describe.runIf(process.env.TW_SECRET_KEY)("getWalletBalance", () => {
expect(result.displayValue).toBe(amount.toString());
});

it("should work for un-named token", async () => {
it("should work for native currency", async () => {
const result = await getWalletBalance({
address: TEST_ACCOUNT_A.address,
client: TEST_CLIENT,
chain: defineChain(97),
tokenAddress: "0xd66c6B4F0be8CE5b39D52E0Fd1344c389929B378",
chain: ANVIL_CHAIN,
});
expect(result).toBeDefined();
expect(result.decimals).toBe(18);
Expand Down
Loading