Skip to content

Implement ChainRegistry for dynamic chain contract verification#800

Draft
mirshko wants to merge 4 commits intotempoxyz:mainfrom
mirshko:feat/dynamic-chains-for-contract-verifier
Draft

Implement ChainRegistry for dynamic chain contract verification#800
mirshko wants to merge 4 commits intotempoxyz:mainfrom
mirshko:feat/dynamic-chains-for-contract-verifier

Conversation

@mirshko
Copy link
Copy Markdown

@mirshko mirshko commented Mar 31, 2026

Summary

Adds a dynamic chain registry to the contract-verification service, allowing it to fetch chain configurations from an external URL at runtime -- expanding which chains can be verified beyond the hardcoded Tempo chains.

What changed

  • New ChainRegistry class (src/lib/chain-registry.ts) -- fetches chain configs from an optional external URL (CHAINS_CONFIG_URL), validates with Zod against a chainlist.org-compatible schema, and merges with static Tempo chains. Static chains always take precedence and cannot be overridden.
  • chainRegistry() Hono middleware -- initializes the registry per-request and sets it on context as c.get('chainRegistry'). All route files access chains through this instead of module-level imports.
  • hidden chain support -- chains marked hidden: true in the external config are fully functional for verification and lookup, but excluded from GET /chains and filtered from GET /v2/contract/all-chains/:address responses to prevent leaking chain IDs.
  • Sourcify-compliant /chains response -- added traceSupportedRPCs (required by Sourcify spec), removed non-standard _extra field, made title optional. SourcifyChain type is now derived from a Zod schema.
  • Auth via Cloudflare Secrets Store -- CHAINS_CONFIG_AUTH_TOKEN_SECRET (Secrets Store binding, preferred) with CHAINS_CONFIG_AUTH_TOKEN (env var) as fallback. Token resolved at startup via resolveAuthToken().
  • 12 new unit tests for ChainRegistry covering: static-only, fetch+merge, hidden filtering, static precedence, auth header, fetch failure fallback, invalid schema rejection, websocket-only filtering, and Sourcify-compliant output shape.

New env vars

Var Type Required Purpose
CHAINS_CONFIG_URL string No URL to fetch dynamic chain configs from
CHAINS_CONFIG_AUTH_TOKEN_SECRET Secrets Store No Bearer token (preferred)
CHAINS_CONFIG_AUTH_TOKEN string No Bearer token (fallback)

When no CHAINS_CONFIG_URL is set, the service behaves exactly as before -- only static Tempo chains.

@mirshko mirshko changed the title Implement first pass at chainregistry as middleware Implement ChainRegistry for dynamic chain verification Mar 31, 2026
@mirshko mirshko changed the title Implement ChainRegistry for dynamic chain verification Implement ChainRegistry for dynamic chain contract verification Mar 31, 2026
@mirshko mirshko force-pushed the feat/dynamic-chains-for-contract-verifier branch 3 times, most recently from 4e1718d to 2b03e46 Compare April 2, 2026 14:28
mirshko added 4 commits April 3, 2026 16:12
Replace non-standard _extra field with traceSupportedRPCs (required by
Sourcify spec). Make title optional per spec.
…egistry auth token

Add secrets_store_secrets binding for CHAINS_CONFIG_AUTH_TOKEN_SECRET
with env var CHAINS_CONFIG_AUTH_TOKEN as fallback. Token is resolved at
startup via resolveAuthToken() which checks type: SecretsStoreSecret
(.get()) > string > undefined.
@o-az o-az force-pushed the feat/dynamic-chains-for-contract-verifier branch from 2b03e46 to a85e4a3 Compare April 3, 2026 23:12
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