fix(chains): separate deleted-chain display fallback#221
fix(chains): separate deleted-chain display fallback#221
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-019d666d-8566-709d-b5df-9ab5bf028c0e Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d666d-8566-709d-b5df-9ab5bf028c0e Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d666d-8566-709d-b5df-9ab5bf028c0e Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d666d-8566-709d-b5df-9ab5bf028c0e Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d666d-8566-709d-b5df-9ab5bf028c0e Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d666d-8566-709d-b5df-9ab5bf028c0e Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d66c1-6e72-770d-870a-b5e275bde32c Co-authored-by: Amp <amp@ampcode.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdded a display-aware chain resolver returning either active registry chains or compact deleted-chain fallbacks, plus a type guard and enabled-state utilities. Updated UI components and ExplorerLink to use the new resolver and handle deleted-chain display/fallback cases. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Component (Claimable/Withdrawals/ExplorerLink)
participant Hook as useFindChainDisplay
participant Registry as Active Registry
participant Profiles as profiles.json (deleted-chain fallback)
UI->>Hook: request chainId
Hook->>Registry: lookup chainId
alt found in registry
Registry-->>Hook: NormalizedChain
else not found
Hook->>Profiles: lookup deleted-chain display info
Profiles-->>Hook: DeletedChainFallback
end
Hook-->>UI: ResolvedChain (NormalizedChain | DeletedChainFallback)
alt ResolvedChain is deleted
UI-->>UI: render informational fallback / non-link span
else ResolvedChain active
UI->>UI: build explorer URL & render link/header/content
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
Deploying interwovenkit with
|
| Latest commit: |
1a4217c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://81fdda8c.interwovenkit.pages.dev |
| Branch Preview URL: | https://fix-deleted-chain-display-fa.interwovenkit.pages.dev |
Deploying interwovenkit-testnet with
|
| Latest commit: |
1a4217c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://17c7bf9c.interwovenkit-testnet.pages.dev |
| Branch Preview URL: | https://fix-deleted-chain-display-fa.interwovenkit-testnet.pages.dev |
Deploying interwovenkit-staging with
|
| Latest commit: |
1a4217c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1d236fe2.interwovenkit-staging.pages.dev |
| Branch Preview URL: | https://fix-deleted-chain-display-fa.interwovenkit-staging.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/interwovenkit-react/src/data/chains.ts (1)
149-152: Avoid duplicate registry lookups insideuseFindChainDisplay.This hook calls
useInitiaRegistry()directly and indirectly again throughuseLayer1(). Prefer deriving layer1 from the localchainsvalue to keep one source and reduce extra query subscriptions/suspense coupling.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/interwovenkit-react/src/data/chains.ts` around lines 149 - 152, useFindChainDisplay currently calls useInitiaRegistry() as chains and also calls useLayer1(), causing duplicate registry lookups; change it to derive layer1 from the local chains value instead of calling useLayer1() so there’s a single source of truth and no extra subscriptions. Locate the useFindChainDisplay function and remove the direct call to useLayer1(), compute the layer1 value from the chains variable returned by useInitiaRegistry() (or from the appropriate field on chains), and update any subsequent logic that references layer1 to use this derived value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/interwovenkit-react/src/data/chains.ts`:
- Around line 157-160: The current useFindChainDisplay implementation throws
when a chainId is missing from both the active registry and the profiles array
(the block that does const profile = profiles.find(...); if (!profile) throw new
Error(...)), which causes render-time crashes in components like ClaimableList
and Withdrawals; change this behavior to return a safe fallback display object
instead of throwing (e.g., { chainId, name: `Unknown chain (${chainId})`,
shortName: 'Unknown', color: '#999', icon: 'unknown' } or similar minimal
display fields your UI expects) so renders can continue, and keep the existing
lookup logic for registry/profile but replace the throw with the fallback return
in useFindChainDisplay.
---
Nitpick comments:
In `@packages/interwovenkit-react/src/data/chains.ts`:
- Around line 149-152: useFindChainDisplay currently calls useInitiaRegistry()
as chains and also calls useLayer1(), causing duplicate registry lookups; change
it to derive layer1 from the local chains value instead of calling useLayer1()
so there’s a single source of truth and no extra subscriptions. Locate the
useFindChainDisplay function and remove the direct call to useLayer1(), compute
the layer1 value from the chains variable returned by useInitiaRegistry() (or
from the appropriate field on chains), and update any subsequent logic that
references layer1 to use this derived value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4a76289e-fb03-4247-b2d2-0b157a074008
📒 Files selected for processing (3)
packages/interwovenkit-react/src/data/chains.tspackages/interwovenkit-react/src/pages/bridge/op/ClaimableList.tsxpackages/interwovenkit-react/src/pages/bridge/op/Withdrawals.tsx
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Removed fallback in
useFindChainbreaks OP withdrawal history itemsExplorerLinknow resolves chains throughuseFindChainDisplayand falls back to a non-clickable span for deleted chains instead of throwing.
Or push these changes by commenting:
@cursor push 6d29aed7a3
Preview (6d29aed7a3)
diff --git a/packages/interwovenkit-react/src/components/ExplorerLink.tsx b/packages/interwovenkit-react/src/components/ExplorerLink.tsx
--- a/packages/interwovenkit-react/src/components/ExplorerLink.tsx
+++ b/packages/interwovenkit-react/src/components/ExplorerLink.tsx
@@ -2,7 +2,7 @@
import xss from "xss"
import { IconExternalLink } from "@initia/icons-react"
import { truncate } from "@initia/utils"
-import { useChain } from "@/data/chains"
+import { isDeletedChain, useFindChainDisplay } from "@/data/chains"
import { buildExplorerUrl, sanitizeLink } from "./explorer"
import styles from "./ExplorerLink.module.css"
@@ -19,9 +19,12 @@
const ExplorerLink = ({ chainId, txHash, accountAddress, pathSuffix, ...props }: Props) => {
const { showIcon, className, children, onClick, ...attrs } = props
- const chain = useChain(chainId)
+ const findChain = useFindChainDisplay()
+ const chain = findChain(chainId)
- const url = buildExplorerUrl(chain, { txHash, accountAddress, pathSuffix })
+ const url = isDeletedChain(chain)
+ ? undefined
+ : buildExplorerUrl(chain, { txHash, accountAddress, pathSuffix })
const defaultText = txHash ? truncate(txHash) : accountAddress ? truncate(accountAddress) : ""
const text = children ?? defaultTextYou can send follow-ups to the cloud agent here.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/interwovenkit-react/src/components/ExplorerLink.tsx`:
- Around line 26-30: The fallback renderer renderFallback currently spreads
attrs (AnchorHTMLAttributes<HTMLAnchorElement>) onto a <span>, which can add
anchor-only props; instead, restrict what is passed to the span by creating a
safeAttrs object (or destructuring) that only includes valid
span/ARIA/interaction props (e.g., id, className handled separately, style,
role, tabIndex, onClick, and any aria-* props) and exclude anchor-only keys like
target, rel, download, ping, referrerPolicy, hreflang, media, type; update
renderFallback to spread safeAttrs rather than attrs and keep anchor-specific
attrs for the anchor-rendering path (use the same pattern around the anchor
rendering code to use the full attrs when rendering <a>).
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0fd96329-8581-47fc-a530-005823921975
📒 Files selected for processing (1)
packages/interwovenkit-react/src/components/ExplorerLink.tsx
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 1 file(s) based on 1 unresolved review comment. Files modified:
Commit: The changes have been pushed to the Time taken: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Error wrapping discards original value in state resolver
- Updated both non-Error fallbacks in
resolveEnabledChainStateto includeString(error)in the wrapped message.
- Updated both non-Error fallbacks in
- ✅ Fixed: Query fires before chain dependency is available
- Added
!!chainto the fee-check queryenabledcondition so it waits for the chain dependency before executing.
- Added
Or push these changes by commenting:
@cursor push 7813e03f34
Preview (7813e03f34)
diff --git a/packages/interwovenkit-react/src/data/chains.ts b/packages/interwovenkit-react/src/data/chains.ts
--- a/packages/interwovenkit-react/src/data/chains.ts
+++ b/packages/interwovenkit-react/src/data/chains.ts
@@ -74,7 +74,8 @@
if (error && !chains) {
return {
chain: undefined,
- error: error instanceof Error ? error : new Error("Failed to load chains"),
+ error:
+ error instanceof Error ? error : new Error(`Failed to load chains: ${String(error)}`),
isLoading: false,
}
}
@@ -86,7 +87,8 @@
if (error) {
return {
chain: undefined,
- error: error instanceof Error ? error : new Error("Failed to load chains"),
+ error:
+ error instanceof Error ? error : new Error(`Failed to load chains: ${String(error)}`),
isLoading: false,
}
}
diff --git a/packages/interwovenkit-react/src/pages/bridge/FooterWithExactFeeCheck.tsx b/packages/interwovenkit-react/src/pages/bridge/FooterWithExactFeeCheck.tsx
--- a/packages/interwovenkit-react/src/pages/bridge/FooterWithExactFeeCheck.tsx
+++ b/packages/interwovenkit-react/src/pages/bridge/FooterWithExactFeeCheck.tsx
@@ -115,7 +115,7 @@
throw await normalizeError(error)
}
},
- enabled: requiresExactFeeCheck && balances !== undefined,
+ enabled: requiresExactFeeCheck && !!chain && balances !== undefined,
retry: false,
})You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 51a8ec7. Configure here.
| }) | ||
| } | ||
|
|
||
| if (isLoadingBalances || balances === undefined || isLoading) { |
There was a problem hiding this comment.
Query fires before chain dependency is available
Low Severity
The enabled condition on the fee-check query is requiresExactFeeCheck && balances !== undefined but omits !!chain. When requiresExactFeeCheck is true and balances are loaded but chain is still loading from useChainEnabled, the query fires immediately and the queryFn guard throws "Invalid transaction data". This error gets cached in React Query under a throwaway key. It's not user-visible because isLoadingChain takes render priority, but it's a needless failed query execution that could confuse debugging and is fragile if the render order changes later.
Reviewed by Cursor Bugbot for commit 51a8ec7. Configure here.
Fixed 1 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>



Summary
Context
mainafter fix(bridge): guard preview fee checks for external chains #219 mergesVerification
pnpm --filter @initia/interwovenkit-react testpnpm --filter @initia/interwovenkit-react typecheckNote
Medium Risk
Touches chain-resolution and bridge exact-fee validation paths; mistakes could surface as missing links/withdrawal data or incorrect fee-check behavior, but changes are localized and covered by new unit tests.
Overview
Adds a distinct display-only deleted-chain fallback (
ResolvedChain+isDeletedChain) and splits lookups intouseFindChain(active registry only) vsuseFindChainDisplay(profiles-based fallback).Updates consumers to handle unavailable chains gracefully:
ExplorerLinknow renders non-clickable text for deleted/missing chains (and strips anchor-only attrs), and OP withdrawals surfaces show an informational message instead of throwing.Bridge exact-fee checking is refactored to a shared
shouldCheckExactFeehelper and now usesuseChainEnabled/resolveEnabledChainStateto only fetch chain registry data when needed, with added tests for both the gating logic and enabled-query state handling.Reviewed by Cursor Bugbot for commit 1a4217c. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes