55 * 1. ENS registry (veryclear.eth) — on-chain source of truth
66 * 2. Static fallback — bundled compiler output for offline use
77 *
8- * The ENS registry maps contract addresses to spec identifiers
9- * (specName, type, decimals, symbol). The spec AST is loaded from
10- * static JSON files generated by the Verity compiler.
8+ * ENS records map contract addresses to:
9+ * { spec: "ERC20", deploy: { symbol: "USDC", decimals: 6 }, circuits: {...} }
10+ *
11+ * The spec name points to a compiler-generated JSON in /public/specs/.
1112 */
1213
1314import type { IntentSpec } from "./types" ;
@@ -16,7 +17,7 @@ import { readSpecFromEns, type EnsSpecEntry } from "./ens";
1617import ERC20_INTENT_JSON from "../../../../public/specs/ERC20.intent.json" ;
1718import UNISWAP_V2_INTENT_JSON from "../../../../public/specs/UniswapV2.intent.json" ;
1819
19- // ─── Spec JSON index (keyed by specName from ENS) ─ ──────────────────────────
20+ // ─── Spec JSON index (keyed by spec name from ENS) ──────────────────────────
2021
2122/* eslint-disable @typescript-eslint/no-explicit-any */
2223const SPEC_JSONS : Record < string , any > = {
@@ -29,31 +30,23 @@ const SPEC_JSONS: Record<string, any> = {
2930
3031const STATIC_SPECS : Record < string , IntentSpec > = { } ;
3132
32- function registerStatic ( address : string , specName : string , meta : EnsSpecEntry ) {
33- const json = SPEC_JSONS [ specName ] ;
33+ function registerStatic ( address : string , entry : EnsSpecEntry ) {
34+ const json = SPEC_JSONS [ entry . spec ] ;
3435 if ( ! json ) return ;
35- STATIC_SPECS [ address . toLowerCase ( ) ] = loadIntentSpec ( json , address , meta ) ;
36+ STATIC_SPECS [ address . toLowerCase ( ) ] = loadIntentSpec ( json , address , entry ) ;
3637}
3738
38- // Pre-register known contracts as fallback
39- registerStatic ( "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" , "ERC20" , {
40- specName : "ERC20" , type : "token " , decimals : 6 , symbol : "USDC" ,
39+ registerStatic ( "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" , {
40+ spec : "ERC20" ,
41+ deploy : { symbol : "USDC " , decimals : 6 } ,
4142} ) ;
42- registerStatic ( "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" , "UniswapV2Router" , {
43- specName : "UniswapV2Router" , type : "protocol" ,
43+ registerStatic ( "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" , {
44+ spec : "UniswapV2Router" ,
45+ } ) ;
46+ registerStatic ( "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" , {
47+ spec : "ERC20" ,
48+ deploy : { symbol : "WETH" , decimals : 18 } ,
4449} ) ;
45-
46- // Address-only specs for display resolution
47- STATIC_SPECS [ "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" ] = {
48- contractName : "WETH" ,
49- address : "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" ,
50- type : "token" ,
51- decimals : 18 ,
52- symbol : "WETH" ,
53- constants : { } ,
54- fns : [ ] ,
55- bindings : [ ] ,
56- } ;
5750
5851export const SPECS = STATIC_SPECS ;
5952
@@ -66,16 +59,13 @@ export const SPECS = STATIC_SPECS;
6659export async function findSpecFromEns (
6760 contractAddress : string
6861) : Promise < IntentSpec | null > {
69- // Try ENS
7062 const ensEntry = await readSpecFromEns ( contractAddress ) ;
7163 if ( ensEntry ) {
72- const json = SPEC_JSONS [ ensEntry . specName ] ;
64+ const json = SPEC_JSONS [ ensEntry . spec ] ;
7365 if ( json ) {
7466 return loadIntentSpec ( json , contractAddress , ensEntry ) ;
7567 }
7668 }
77-
78- // Fall back to static
7969 return STATIC_SPECS [ contractAddress . toLowerCase ( ) ] ?? null ;
8070}
8171
0 commit comments