Indexedex UI Refactor
This skill documents the frontend refactor that made the UI environment-aware across live Sepolia and the local SuperSim rehearsal.
Use This Skill For
- adding or changing deployment environments
- updating address artifact imports or registry wiring
- fixing chain-id to artifact resolution
- adjusting wagmi transport selection for local versus live networks
- reviewing pages that consume deployment artifacts and token lists
Core Architecture
The frontend now has one central artifact registry and one central deployment-environment state.
Single Source of Truth
- Money-path app is
frontend/apps/dtfon Robinhood 4663. Do not keep a second IndexedEx/Pachira app. - Shared protocol artifacts live under
frontend/packages/protocol/src/addresses/. Do not treatfrontend/app/addresses/index.tsas the money-path registry. frontend/packages/protocolowns chain-id resolution and typed access to bundles.- Wagmi transports for the money path target Robinhood 4663.
Do not scatter direct artifact JSON imports across feature pages when the data belongs in the shared registry.
Deployment Environment Model
Current supported environment:
type DeploymentEnvironment = 'robinhood_4663'
Rules:
- Default to
supersim_sepoliaunlessNEXT_PUBLIC_DEFAULT_DEPLOYMENT_ENVIRONMENToverrides it. - Persist the current environment in localStorage under
indexedex:deployment-environment. - Keep environment switching in provider and context code, not in individual pages.
Artifact Registry Rules
In frontend/app/addresses/index.ts:
- Import each environment's JSON artifacts once.
- Build bundles with
buildBundle(...)so every list is normalized consistently. - Stamp
chainIdinto normalized platform and token-list entries. - Keep the registry keyed by environment and canonical chain id.
Canonical chain ids:
11155111for Ethereum Sepolia84532for Base Sepolia
When adding a new artifact category, update:
- the import set in
frontend/app/addresses/index.ts - the
ArtifactBundletype buildBundle(...)- the registry entry for each supported environment
Chain Resolution Rules
In frontend/app/lib/addressArtifacts.ts:
- Treat canonical artifacts as Sepolia and Base Sepolia bundles.
- Resolve
31337and1337to Sepolia artifacts for local development. - Resolve chain id
8453to Base Sepolia artifacts only when the selected environment issupersim_sepolia. - Throw explicit errors for unsupported chain ids or missing bundles.
Do not duplicate ad hoc chain-id fallback logic in pages or hooks.
Provider Rules
In frontend/app/providers.tsx:
- Keep wagmi config dependent on the selected deployment environment.
- For
supersim_sepolia, route Sepolia traffic toNEXT_PUBLIC_LOCAL_RPC_URLand Base Sepolia traffic toNEXT_PUBLIC_BASE_RPC_URL. - For live
sepolia, route Sepolia and Base Sepolia traffic to their normal RPC URLs. - Update the in-memory default artifact environment whenever the UI environment changes.
This prevents the wallet layer and artifact lookup layer from drifting out of sync.
UI Pattern
The environment switcher is intentionally lightweight:
- fixed overlay
- explicit label
- simple select control
- no page-specific copies of the same control
Keep this as a shared control instead of re-implementing environment selection per page.
Refactor Checklist
When changing deployment-environment behavior:
- Update the environment union and registry first.
- Confirm chain-id resolution still maps local chains to the intended artifact bundle.
- Confirm provider transports match the selected environment.
- Confirm localStorage persistence still restores the previous selection.
- Confirm both
sepoliaandsupersim_sepoliarender with the expected artifacts.
Source Files
frontend/app/addresses/index.tsfrontend/app/lib/addressArtifacts.tsfrontend/app/lib/deploymentEnvironment.tsxfrontend/app/providers.tsx
What To Avoid
- page-level direct imports of deployment JSON that bypass the shared registry
- duplicate environment state in multiple hooks or pages
- inconsistent chain-id mapping between wagmi transports and artifact lookup
- defaulting to live RPCs while still reading local supersim artifacts