-
Notifications
You must be signed in to change notification settings - Fork 608
[MNY-289] SDK: Fix token selection UI loading state when wallet is connected to a chain that is not supported by tw bridge #8304
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
[MNY-289] SDK: Fix token selection UI loading state when wallet is connected to a chain that is not supported by tw bridge #8304
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 3e9eb49 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
WalkthroughChange updates a changeset and modifies Select Token chain-resolution logic so the component sequentially tries the token's chain, the active wallet chain, then chain ID 1 to avoid persistent loading when the wallet is on an unsupported chain. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as SelectTokenUI
participant Data as AvailableChains
participant Wallet as WalletState
Note over UI: User opens Select Token component
UI->>Data: findChain(selectedToken?.chainId)
alt found
Data-->>UI: chain
UI->>UI: select chain
else not found
UI->>Wallet: get activeChain.id
Wallet-->>UI: activeChain.id (may be undefined/unsupported)
UI->>Data: findChain(activeChain.id)
alt found
Data-->>UI: chain
UI->>UI: select chain
else not found
UI->>Data: findChain(1)
Data-->>UI: fallback chain (1)
UI->>UI: select fallback chain
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.changeset/fine-bobcats-rhyme.md(1 hunks)packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md: Each change inpackages/*must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/fine-bobcats-rhyme.md
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
packages/thirdweb/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling@exampleand a custom tag (@beta,@internal,@experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g.,const { jsPDF } = await import("jspdf"))
Files:
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
🧬 Code graph analysis (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)
packages/thirdweb/src/bridge/types/Chain.ts (1)
BridgeChain(42-42)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)
70-72: Excellent fix for the loading state bug.The sequential fallback logic correctly handles unsupported chains. When the active wallet's chain ID is undefined,
findChainreturnsundefinedinstead of forcing a default, allowing the loading UI (Lines 464-475) to properly display a spinner until a valid chain is selected or defaults to chain 1 as a final fallback..changeset/fine-bobcats-rhyme.md (1)
1-5: LGTM! Changeset properly documents the bug fix.The patch version bump is appropriate for this non-breaking UI bug fix, and the description accurately captures the issue and affected widgets.
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
Show resolved
Hide resolved
4126563 to
e688555
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8304 +/- ##
==========================================
+ Coverage 54.89% 54.90% +0.01%
==========================================
Files 919 919
Lines 60677 60675 -2
Branches 4125 4126 +1
==========================================
+ Hits 33310 33315 +5
+ Misses 27265 27259 -6
+ Partials 102 101 -1
🚀 New features to boost your workflow:
|
size-limit report 📦
|
Merge activity
|
…nnected to a chain that is not supported by tw bridge (#8304) <!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR addresses an issue with the `Select Token` UI being stuck in a loading state when the wallet is connected to an unsupported chain by the `thirdweb Bridge`. It modifies the logic for selecting the default chain in various widgets. ### Detailed summary - Updated the function from `getDefaultSelectedChain` to `findChain` for clarity. - Improved logic to handle cases where `activeChainId` is undefined. - Adjusted the selection of `selectedChain` to use the new `findChain` function, ensuring proper fallback options. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Bug Fixes * Fixed Select Token components from remaining in loading state when the connected wallet chain is not supported by thirdweb Bridge. This affects BuyWidget, SwapWidget, and BridgeWidget. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
e688555 to
3e9eb49
Compare

PR-Codex overview
This PR addresses an issue where the Select Token UI gets stuck in a loading state when the wallet is connected to an unsupported chain in the
BuyWidget,SwapWidget, andBridgeWidget. It refines the chain selection logic to improve functionality.Detailed summary
getDefaultSelectedChaintofindChain.undefinedifactiveChainIdis not provided.findChainfor better clarity and functionality.Summary by CodeRabbit