Skip to content

perf: replace viem/chains wildcard import with named imports in paywall#1928

Open
natsukingly wants to merge 1 commit intox402-foundation:mainfrom
natsukingly:perf/viem-chains-import
Open

perf: replace viem/chains wildcard import with named imports in paywall#1928
natsukingly wants to merge 1 commit intox402-foundation:mainfrom
natsukingly:perf/viem-chains-import

Conversation

@natsukingly
Copy link
Copy Markdown

Summary

@x402/paywall imports all 100+ chain definitions from viem/chains via import * as allChains, but only uses Base Mainnet and Base Sepolia. This unnecessarily inflates the client bundle.

Changes

  • Replaced import * as allChains from "viem/chains" with import { base, baseSepolia } from "viem/chains"
  • Created a local SUPPORTED_EVM_CHAINS array for chain lookups
  • getNetworkDisplayName and isTestnetNetwork now use the local array instead of scanning all chains

Impact

Removes ~100 unused chain definitions from the paywall bundle. Also improves lookup performance from O(n) to constant time.

Test plan

  • Full monorepo build passes
  • Verify paywall renders correct network names for Base and Base Sepolia

@github-actions github-actions bot added typescript sdk Changes to core v2 packages labels Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk Changes to core v2 packages typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant