-
Notifications
You must be signed in to change notification settings - Fork 629
[SDK] Support ERC5792 batch transactions for swaps, add slippage option to Bridge API #8484
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": minor | ||
| --- | ||
|
|
||
| Support erc5792 batch transactions for swaps, add slippage option to Bridge API |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,8 +116,6 @@ | |
| const json = (await response.json()) as TokenBalancesResponse; | ||
| return json.result; | ||
| }, | ||
| refetchOnMount: false, | ||
| retry: false, | ||
| refetchOnWindowFocus: false, | ||
| refetchOnMount: "always", | ||
|
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. The refetch behavior change may have unintended side effects. By removing the View Details📝 Patch Detailsdiff --git a/packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts b/packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts
index 19521d200..de9c92b31 100644
--- a/packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts
+++ b/packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts
@@ -117,5 +117,7 @@ export function useTokenBalances(options: {
return json.result;
},
refetchOnMount: "always",
+ retry: false,
+ refetchOnWindowFocus: false,
});
}
AnalysisUnintended query behavior change in useTokenBalances() after refactorWhat fails: How to reproduce:
Result: Removed three explicit query options without updating the feature:
Expected: Query options should maintain the explicit defensive configuration ( |
||
| }); | ||
| } | ||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 498
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 162
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 1514
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 41
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 4254
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 3892
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 3209
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 41
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 1633
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 430
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 266
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 4365
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 145
Check individual receipt statuses for non-atomic bundles.
The code only uses
lastReceipt.transactionHashfor polling without verifying receipt success. ERC-5792 supports both atomic and non-atomic call bundles. For atomic bundles,waitForCallsReceiptreturningbundle.status === "success"guarantees all receipts succeeded. However, for non-atomic bundles, individual calls can fail independently—their receipt statuses should be validated.Consider adding validation for non-atomic cases:
// get tx hash const callsStatus = await waitForCallsReceipt(result); const lastReceipt = callsStatus.receipts?.[callsStatus.receipts.length - 1]; if (!lastReceipt) { throw new Error("No receipts found"); } +// For non-atomic bundles, verify individual receipt success +if (!callsStatus.atomic) { + for (const receipt of callsStatus.receipts) { + if (receipt.status === "reverted") { + throw new Error("Transaction in batch failed"); + } + } +}📝 Committable suggestion
🤖 Prompt for AI Agents