Skip to content

feat: restrict public api and swap widget to production-validated chains#12425

Merged
kaladinlight merged 2 commits into
developfrom
feat/supported-chains-alignment
Jun 11, 2026
Merged

feat: restrict public api and swap widget to production-validated chains#12425
kaladinlight merged 2 commits into
developfrom
feat/supported-chains-alignment

Conversation

@kaladinlight

@kaladinlight kaladinlight commented Jun 11, 2026

Copy link
Copy Markdown
Member

Description

Aligns the supported chain set of the public API and swap widget with the chains fully validated and enabled in the production web app. Previously the public API exposed all 49 KnownChainIds (including ~29 chains feature-flagged off in production) and the widget shipped WorldChain, which is also flagged off.

public-api:

  • New SUPPORTED_CHAIN_IDS allowlist (16 chains: 8 EVM, 4 UTXO, 3 Cosmos SDK, Solana) in constants.ts, documented to stay in sync with production feature flags
  • /v1/chains lists only supported chains
  • /v1/assets (list/count/by-id) excludes assets on unsupported chains; /v1/rates and /v1/quote consequently reject them as unknown assets
  • getAssetsById() stays unfiltered for swapper deps — NearIntents denominates its affiliate fee in NEAR's fee asset, which would otherwise silently drop affiliate fee metadata
  • chainNamespaceToType is now an exhaustive Record<ChainNamespace, ChainType> keyed by CHAIN_NAMESPACE constants

swap-widget:

  • Removed WorldChain (flagged off in production) and Monad/HyperEVM/Plasma/Katana (second-class EVM chains with no chain adapters in the public API — rates partially degrade and quotes fail; to be re-added properly in a follow-up PR with SecondClassEvmAdapter wiring)
  • VIEM_CHAINS_BY_ID keyed by chain.id instead of hardcoded numbers

The widget derives its visible chain list from /v1/assets, so the server-side filter drives the UI; the local constant edits keep wallet networks and icons consistent.

Issue (if applicable)

closes #

Risk

Low risk. No on-chain transaction logic changes — this only narrows which chains/assets the public API and widget expose. The web app is unaffected (its chain enablement still comes from feature flags). Existing quotes on removed chains were already broken or degraded (no chain adapters registered in the API).

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Swap rates/quotes via the public API and swap widget only. Chains removed from the widget: WorldChain, Monad, HyperEVM, Plasma, Katana.

Testing

Engineering

  • pnpm dev in packages/public-api, then:
    • GET /v1/chains returns exactly the 16 allowlisted chains
    • GET /v1/assets?chainId=eip155:480 (WorldChain) returns empty; supported chains return assets
    • GET /v1/swap/rates with a supported pair (e.g. ETH→USDC) works; with an unsupported-chain asset returns 400 "Unknown sell/buy asset"
    • POST /v1/swap/quote with a non-enabled swapper name returns 400 "Swapper not available"
  • Widget demo (pnpm dev in packages/swap-widget, port 5174): chain selector no longer shows WorldChain/Monad/HyperEVM/Plasma/Katana; wallet network switching works on remaining EVM chains

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Public API/widget surface only — verify in the widget demo that the chain list matches production web app chains and swaps quote end-to-end on a couple of chains (e.g. ETH mainnet, BTC).

Screenshots (if applicable)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Removals

    • Removed support for hyperEvm, katana, monad, plasma, and worldchain EVM chains.
  • Improvements

    • Enhanced asset filtering to ensure only assets available on supported chains are displayed.

kaladinlight and others added 2 commits June 11, 2026 10:35
Add a SUPPORTED_CHAIN_IDS allowlist matching the chains fully validated
and enabled in the production web app, and filter the public surface by it:

- /v1/chains now lists only supported chains instead of all KnownChainIds
- /v1/assets and asset lookups exclude assets on unsupported chains, so
  /v1/rates and /v1/quote reject them as unknown assets
- getAssetsById stays unfiltered for swapper deps (e.g. NearIntents
  denominates its affiliate fee in NEAR's fee asset)

Second-class EVM chains (Monad, HyperEVM, Plasma, Katana) are excluded
until their chain adapters are wired into the API in a follow-up PR.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Remove chains not fully validated in production from the widget's chain
constants, wallet networks, and viem chain configs:

- WorldChain (feature flag off in production)
- Monad, HyperEVM, Plasma, Katana (second-class EVM chains pending
  chain adapter support in the public api)

The widget derives its visible chain list from /v1/assets, so this
aligns its local constants with the public api's supported chain set.
Also key VIEM_CHAINS_BY_ID by chain.id instead of hardcoded numbers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kaladinlight kaladinlight requested a review from a team as a code owner June 11, 2026 16:54
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR reduces the supported blockchain networks across the codebase by explicitly defining a SUPPORTED_CHAIN_IDS list and enforcing that constraint in asset export and chain enumeration logic. Five EVM chains (hyperevm, katana, monad, plasma, worldchain) are removed from swap widget configuration to maintain consistency.

Changes

Supported Chains Reduction

Layer / File(s) Summary
Define supported chain IDs
packages/public-api/src/constants.ts
SUPPORTED_CHAIN_IDS exports a curated readonly array of KnownChainIds grouped by blockchain type (EVM, UTXO, Cosmos SDK, Solana), and SUPPORTED_CHAIN_IDS_SET provides efficient ReadonlySet-based membership testing.
Filter assets by supported chains
packages/public-api/src/assets.ts
initAssets filters assetIds to only those whose chainId is in SUPPORTED_CHAIN_IDS_SET; getAsset and getAllAssets are updated to respect this constraint, returning undefined or filtered arrays when assets fall outside supported chains.
Update chain enumeration to use supported chains
packages/public-api/src/routes/chains/utils.ts
buildChainList iterates over SUPPORTED_CHAIN_IDS instead of all KnownChainIds; the namespace-to-type mapping is strongly typed with ChainNamespace constants instead of hardcoded strings; runtime warnings for unknown chain types are removed.
Remove unsupported chains from swap widget
packages/swap-widget/src/config/appkit.ts, packages/swap-widget/src/constants/viemChains.ts, packages/swap-widget/src/constants/chains.ts, packages/swap-widget/src/types/index.ts
AppKit network imports, Viem chain ID mappings, base asset chain IDs, and exported EVM chain ID constants are all updated to remove hyperevm, katana, monad, plasma, and worldchain entries.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With chainlinks trimmed and curated well,
Five networks bid the code farewell,
SUPPORTED_CHAIN_IDS guides the way,
Assets filter bright today!
Consistency throughout we weave,
A cleaner swap widget to believe! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: restricting the public API and swap widget to production-validated chains, which is the primary focus across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/supported-chains-alignment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/public-api/src/constants.ts (1)

4-25: ⚡ Quick win

Add inline documentation for production sync requirement.

The PR objectives mention that SUPPORTED_CHAIN_IDS should stay in sync with production feature flags, but there's no inline comment documenting this constraint. Adding a brief comment here will help future maintainers understand the sync requirement and prevent drift.

📝 Suggested documentation
+// IMPORTANT: This list must stay in sync with production feature flags.
+// Only chains fully validated and enabled in the production web app should be included.
 export const SUPPORTED_CHAIN_IDS: readonly KnownChainIds[] = [
   // EVM
   KnownChainIds.ArbitrumMainnet,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/public-api/src/constants.ts` around lines 4 - 25, Add a brief inline
comment above the SUPPORTED_CHAIN_IDS constant stating that this list must be
kept in sync with production feature flags (mentioning source of truth if known)
and that any change here requires updating the production feature flags and
running relevant deployment/tests; update the comment near the
SUPPORTED_CHAIN_IDS declaration so future maintainers see the sync requirement
when editing that array.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/public-api/src/routes/chains/utils.ts`:
- Around line 1-18: The comment claiming SUPPORTED_CHAIN_IDS only uses a subset
of CAIP namespaces is incorrect; update the documentation or in-code comment to
state that chainNamespaceToType (Record<ChainNamespace, ChainType>) exhaustively
covers all CAIP namespaces used by SUPPORTED_CHAIN_IDS (eip155, bip122, cosmos,
solana, near, starknet, sui, ton, tron). Locate the mapping in
chainNamespaceToType and the usage of SUPPORTED_CHAIN_IDS and change the
namespace coverage statement to list all the actual namespaces or simply assert
exhaustiveness via ChainNamespace so the claim matches the mapping.

---

Nitpick comments:
In `@packages/public-api/src/constants.ts`:
- Around line 4-25: Add a brief inline comment above the SUPPORTED_CHAIN_IDS
constant stating that this list must be kept in sync with production feature
flags (mentioning source of truth if known) and that any change here requires
updating the production feature flags and running relevant deployment/tests;
update the comment near the SUPPORTED_CHAIN_IDS declaration so future
maintainers see the sync requirement when editing that array.
🪄 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: a3a0cf20-0901-4321-be99-2fc5dbea759f

📥 Commits

Reviewing files that changed from the base of the PR and between 1e62d75 and 82899d3.

📒 Files selected for processing (7)
  • packages/public-api/src/assets.ts
  • packages/public-api/src/constants.ts
  • packages/public-api/src/routes/chains/utils.ts
  • packages/swap-widget/src/config/appkit.ts
  • packages/swap-widget/src/constants/chains.ts
  • packages/swap-widget/src/constants/viemChains.ts
  • packages/swap-widget/src/types/index.ts
💤 Files with no reviewable changes (3)
  • packages/swap-widget/src/constants/chains.ts
  • packages/swap-widget/src/config/appkit.ts
  • packages/swap-widget/src/types/index.ts

Comment thread packages/public-api/src/routes/chains/utils.ts
@kaladinlight kaladinlight merged commit a64dddb into develop Jun 11, 2026
4 checks passed
@kaladinlight kaladinlight deleted the feat/supported-chains-alignment branch June 11, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant