-
Notifications
You must be signed in to change notification settings - Fork 620
[thirdweb] Ensure bigints are stringified before usage with server wallets #7145
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "thirdweb": patch | ||
| --- | ||
|
|
||
| Ensure bigints are stringified before usage with server wallets |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,13 +3,14 @@ import { TEST_CLIENT } from "../../test/src/test-clients.js"; | |||||
| import { TEST_ACCOUNT_B } from "../../test/src/test-wallets.js"; | ||||||
| import { typedData } from "../../test/src/typed-data.js"; | ||||||
| import { arbitrumSepolia } from "../chains/chain-definitions/arbitrum-sepolia.js"; | ||||||
| import { baseSepolia } from "../chains/chain-definitions/base-sepolia.js"; | ||||||
| import { sepolia } from "../chains/chain-definitions/sepolia.js"; | ||||||
| import { getContract } from "../contract/contract.js"; | ||||||
| import { setContractURI } from "../extensions/common/__generated__/IContractMetadata/write/setContractURI.js"; | ||||||
| import { mintTo } from "../extensions/erc20/write/mintTo.js"; | ||||||
| import { claimTo } from "../extensions/erc1155/drops/write/claimTo.js"; | ||||||
| import { getAllActiveSigners } from "../extensions/erc4337/__generated__/IAccountPermissions/read/getAllActiveSigners.js"; | ||||||
| import { sendTransaction } from "../transaction/actions/send-transaction.js"; | ||||||
| import { setThirdwebDomains } from "../utils/domains.js"; | ||||||
| import { | ||||||
| DEFAULT_ACCOUNT_FACTORY_V0_6, | ||||||
| ENTRYPOINT_ADDRESS_v0_6, | ||||||
|
|
@@ -32,12 +33,12 @@ describe.runIf( | |||||
| let serverWallet: Engine.ServerWallet; | ||||||
|
|
||||||
| beforeAll(async () => { | ||||||
| setThirdwebDomains({ | ||||||
| rpc: "rpc.thirdweb-dev.com", | ||||||
| storage: "storage.thirdweb-dev.com", | ||||||
| bundler: "bundler.thirdweb-dev.com", | ||||||
| engineCloud: "engine.thirdweb-dev.com", | ||||||
| }); | ||||||
| // setThirdwebDomains({ | ||||||
| // rpc: "rpc.thirdweb-dev.com", | ||||||
| // storage: "storage.thirdweb-dev.com", | ||||||
| // bundler: "bundler.thirdweb-dev.com", | ||||||
| // engineCloud: "engine.thirdweb-dev.com", | ||||||
| // }); | ||||||
| serverWallet = Engine.serverWallet({ | ||||||
| client: TEST_CLIENT, | ||||||
| vaultAccessToken: process.env.VAULT_TOKEN as string, | ||||||
|
|
@@ -81,7 +82,7 @@ describe.runIf( | |||||
| }); | ||||||
| const claimTx = claimTo({ | ||||||
| contract: nftContract, | ||||||
| to: TEST_ACCOUNT_B.address, | ||||||
| to: serverWallet.address, | ||||||
| tokenId: 0n, | ||||||
| quantity: 1n, | ||||||
| }); | ||||||
|
|
@@ -97,16 +98,15 @@ describe.runIf( | |||||
| }); | ||||||
|
|
||||||
| it("should send a extension tx", async () => { | ||||||
| const nftContract = getContract({ | ||||||
| const tokenContract = getContract({ | ||||||
| client: TEST_CLIENT, | ||||||
| chain: sepolia, | ||||||
| address: "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8", | ||||||
| chain: baseSepolia, | ||||||
| address: "0x87C52295891f208459F334975a3beE198fE75244", | ||||||
| }); | ||||||
| const claimTx = claimTo({ | ||||||
| contract: nftContract, | ||||||
| to: TEST_ACCOUNT_B.address, | ||||||
| tokenId: 0n, | ||||||
| quantity: 1n, | ||||||
| const claimTx = mintTo({ | ||||||
| contract: tokenContract, | ||||||
| to: serverWallet.address, | ||||||
| amount: "0.001", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Potential issue: String amount parameter may not test bigint serialization. The - amount: "0.001",
+ amount: 1000000000000000n, // 0.001 ETH in wei as bigintThis change would better test the bigint serialization functionality while maintaining the same monetary value. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| }); | ||||||
|
Comment on lines
+101
to
110
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify contract addresses and test parameter consistency. The test has been updated to use an ERC20 contract on Base Sepolia instead of an ERC1155 contract on Sepolia. Key observations:
The string parameter format aligns with the PR's objective of bigint serialization, but please ensure: Additionally, confirm that:
🏁 Script executed: #!/bin/bash
# Verify the contract addresses exist and are valid ERC20/ERC1155 contracts
echo "Checking ERC1155 contract on Sepolia..."
curl -s "https://api.etherscan.io/api?module=contract&action=getabi&address=0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8&apikey=YourApiKeyToken" | jq '.status'
echo "Checking ERC20 contract on Base Sepolia..."
curl -s "https://api.basescan.org/api?module=contract&action=getabi&address=0x87C52295891f208459F334975a3beE198fE75244&apikey=YourApiKeyToken" | jq '.status'Length of output: 507 Invalid contract addresses – ABI fetch failed for both Sepolia and Base Sepolia Both Etherscan and BaseScan returned • Verify that these addresses are correct and the contracts are actually deployed on the specified networks. Fix these before merging to guarantee the test still validates server-wallet functionality. 🤖 Prompt for AI Agents |
||||||
| const tx = await sendTransaction({ | ||||||
| account: serverWallet, | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the replacer function chaining logic.
The implementation correctly handles bigint conversion while preserving optional user replacer functionality. However, let me verify the logic:
The logic looks correct, but there's a potential edge case where a user replacer might expect to handle bigint values directly.
🏁 Script executed:
Length of output: 67258
Swap replacer and bigint conversion order in
stringifyTo allow custom replacers to see and handle raw
bigintvalues, you should invoke the user’sreplaceron the originalvalue_first, then convert anybigintresult to a string forJSON.stringify.• Location:
packages/engine/src/configure.ts, the inline replacer passed toJSON.stringify• Change the logic from converting first → calling replacer, to calling replacer first → converting any returned bigint.
This adjustment preserves the JSON signature, safely serializes
bigint, and still lets custom replacers handlebigintvalues directly.📝 Committable suggestion
🤖 Prompt for AI Agents