ccip-router 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -15
- package/dist/chain/client.d.ts +10 -10
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +14 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/db/sqlite.d.ts +5 -1
- package/dist/db/sqlite.d.ts.map +1 -1
- package/dist/db/sqlite.js +54 -0
- package/dist/db/sqlite.js.map +1 -1
- package/dist/db/types.d.ts +12 -0
- package/dist/db/types.d.ts.map +1 -1
- package/dist/ens/dns.d.ts +3 -0
- package/dist/ens/dns.d.ts.map +1 -0
- package/dist/ens/dns.js +27 -0
- package/dist/ens/dns.js.map +1 -0
- package/dist/ens/withEns.d.ts +17 -0
- package/dist/ens/withEns.d.ts.map +1 -0
- package/dist/ens/withEns.js +60 -0
- package/dist/ens/withEns.js.map +1 -0
- package/dist/lib.d.ts +3 -0
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +2 -0
- package/dist/lib.js.map +1 -1
- package/dist/mesh/records.js +2 -2
- package/dist/mesh/vni.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@ ccip-router is a general-purpose CCIP-Read gateway. The resolver function is you
|
|
|
17
17
|
**ENS name resolution**
|
|
18
18
|
Point an ENS `wildcard` or `offchainLookup` resolver at your gateway. ccip-router handles the EIP-3668 `/{sender}/{data}.json` endpoint, signs every response, and replicates it to peer nodes — so your ENS names stay live even if one gateway goes down.
|
|
19
19
|
|
|
20
|
+
**Native full web3 dapps**
|
|
21
|
+
Pin your app's pages as IPFS CIDs and set them as the ENS contenthash — the frontend has no server to take down. Serve dynamic data through ccip-router: any node in the mesh can answer a CCIP-Read request, so if one goes offline the others keep the app running. The ENS name ties both layers together on-chain. The result is a dapp with no single point of failure at either the frontend or the data layer.
|
|
22
|
+
|
|
20
23
|
**Off-chain data for on-chain contracts**
|
|
21
24
|
Any smart contract that uses `OffchainLookup` can delegate reads to ccip-router. Store token metadata, user profiles, game state, or permit trees off-chain and serve them through a verifiable gateway rather than a trusted API.
|
|
22
25
|
|
|
@@ -162,6 +165,40 @@ What you get:
|
|
|
162
165
|
- Admin dashboard at `/admin` with peer management + sync controls
|
|
163
166
|
- Setup wizard at `/setup` on first boot
|
|
164
167
|
|
|
168
|
+
### ENS — built-in wildcard resolver
|
|
169
|
+
|
|
170
|
+
`withEns()` decodes `resolve(bytes name, bytes data)` calldata (EIP-137 wildcard pattern), dispatches to a clean handler, and ABI-encodes the response. DNS wire-format, selector dispatch, and null-to-zero-value fallbacks are handled for you.
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { CcipRouter, withEns } from 'ccip-router'
|
|
174
|
+
import type { EnsResolverFn } from 'ccip-router'
|
|
175
|
+
|
|
176
|
+
const resolver: EnsResolverFn = async (name, record) => {
|
|
177
|
+
// name → "vitalik.eth"
|
|
178
|
+
// record → { type: 'addr' } | { type: 'addr', coinType: 60n }
|
|
179
|
+
// { type: 'text', key: 'avatar' } | { type: 'contenthash' }
|
|
180
|
+
return db.lookup(name, record) // return string or null
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const ccip = new CcipRouter({
|
|
184
|
+
namespace: 'ens-offchain',
|
|
185
|
+
db,
|
|
186
|
+
gatewayKey: process.env.GATEWAY_PRIVATE_KEY,
|
|
187
|
+
resolver: withEns(resolver),
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Standalone mode:** ENS records are managed from the admin panel ("ENS Records" panel — no code required). Any name pointing to this gateway via an on-chain CCIP-Read wildcard resolver is served automatically.
|
|
192
|
+
|
|
193
|
+
**Compose with attestation:**
|
|
194
|
+
```typescript
|
|
195
|
+
resolver: withWyriwe(withEns(resolver), attestationOpts)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Use `isEnsCalldata(calldata)` to safely gate `withEns()` in a multi-purpose resolver that also handles non-ENS calldata.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
165
202
|
### Advanced — wrap any resolver with WYRIWE EIP-712 attestation
|
|
166
203
|
|
|
167
204
|
```typescript
|
|
@@ -197,9 +234,13 @@ What `withWyriwe()` adds on top of basic:
|
|
|
197
234
|
```bash
|
|
198
235
|
npm install
|
|
199
236
|
npm run dev
|
|
200
|
-
# → open http://localhost:3000
|
|
201
|
-
# →
|
|
202
|
-
# →
|
|
237
|
+
# → open http://localhost:3000/setup
|
|
238
|
+
# → step 1: generate or import your signing key
|
|
239
|
+
# → step 2: optional Bearer secret for CLI access
|
|
240
|
+
# → step 3: namespace, port, sync interval
|
|
241
|
+
# → step 4: confirm → config.json written, node restarts
|
|
242
|
+
# → /admin/login: connect any MetaMask wallet → first signer claims admin
|
|
243
|
+
# → /admin: dashboard ready
|
|
203
244
|
```
|
|
204
245
|
|
|
205
246
|
Or configure via environment (no wizard needed):
|
|
@@ -241,12 +282,17 @@ Visit `/admin` after setup. Features:
|
|
|
241
282
|
- Live stats: record count, peer count, last sync time
|
|
242
283
|
- Peer panel: add/remove peers, per-peer health + signer address + last sync
|
|
243
284
|
- Recent records panel: local vs peer-synced, timestamps
|
|
285
|
+
- ENS records panel — add/edit/delete addr, text, contenthash records without a restart
|
|
244
286
|
- Manual sync trigger
|
|
245
287
|
- Auto-refresh every 15 seconds
|
|
246
288
|
|
|
247
|
-
**Auth:**
|
|
289
|
+
**Auth — claim on first login (EIP-4361 SIWE):** On a fresh node the login page shows an amber "Unclaimed node" banner. Connect any browser wallet and sign once — that wallet address is saved to `config.json` as the permanent admin. Subsequent logins must match that address. Admin wallet is completely decoupled from the gateway signing key (`GATEWAY_PRIVATE_KEY` stays server-side).
|
|
290
|
+
|
|
291
|
+
**Transfer admin:** While logged in, open the "Admin wallet" panel → Transfer. Switch MetaMask to the new wallet, sign a transfer message to prove ownership — `adminAddress` is updated live and a new session is issued, no restart required.
|
|
292
|
+
|
|
293
|
+
**Bearer fallback:** `Authorization: Bearer <ADMIN_SECRET>` always works for CLI / scripts regardless of SIWE state.
|
|
248
294
|
|
|
249
|
-
**Stack status row:** A compact pill row below the header shows which tiers are active — Signing / ERC-8004 / WYRIWE / OCP — derived from `/admin/api/status`. Green = active, grey = unconfigured.
|
|
295
|
+
**Stack status row:** A compact pill row below the header shows which tiers are active — Signing / ERC-8004 / WYRIWE / OCP / VNI / On-chain — derived from `/admin/api/status`. Green = active, grey = unconfigured.
|
|
250
296
|
|
|
251
297
|
**Node logs panel:** Live ring buffer of the last 200 log lines (info/warn/error), colour-coded. Auto-refreshes every 10 seconds.
|
|
252
298
|
|
|
@@ -311,7 +357,7 @@ GET /{sender}/{data}.json
|
|
|
311
357
|
GET /records?namespace=<str>&since=<unix>&limit=<n>&cursor=<str>
|
|
312
358
|
→ {
|
|
313
359
|
protocol: 1,
|
|
314
|
-
node_version: "0.
|
|
360
|
+
node_version: "0.2.0",
|
|
315
361
|
namespace: "agent-attestations",
|
|
316
362
|
records: [{ inputHash, namespace, key, value, timestamp, signature, sourcePeer }],
|
|
317
363
|
cursor: "<next>" | null
|
|
@@ -399,19 +445,37 @@ GET /health
|
|
|
399
445
|
}
|
|
400
446
|
```
|
|
401
447
|
|
|
402
|
-
### Admin
|
|
448
|
+
### Admin auth (SIWE + Bearer)
|
|
449
|
+
```
|
|
450
|
+
GET /admin/siwe/nonce → { nonce, domain, chainId, authorizedAddress, claimed }
|
|
451
|
+
POST /admin/siwe/verify { message, signature }
|
|
452
|
+
unclaimed node → first caller claims admin, saved to config.json
|
|
453
|
+
claimed node → must match stored adminAddress
|
|
454
|
+
→ { ok, address, claimed, redirect }
|
|
455
|
+
POST /admin/siwe/transfer { message, signature } — signed by NEW wallet
|
|
456
|
+
current session required; updates adminAddress live
|
|
457
|
+
→ { ok, address }
|
|
458
|
+
POST /admin/logout clear session cookie
|
|
403
459
|
```
|
|
404
|
-
|
|
460
|
+
|
|
461
|
+
### Admin API (requires auth)
|
|
462
|
+
```
|
|
463
|
+
GET /admin/api/status node info, peers, recent records, tiers, adminAddress
|
|
405
464
|
GET /admin/api/logs last 200 log lines [{ ts, level, msg }]
|
|
406
|
-
GET /admin/api/audit per-spec compliance report (EIP-3668/WYRIWE/ERC-8004/OCP)
|
|
465
|
+
GET /admin/api/audit per-spec compliance report (EIP-3668/WYRIWE/ERC-8004/OCP/VNI)
|
|
407
466
|
POST /admin/api/sync trigger immediate peer sync
|
|
408
467
|
POST /admin/api/publish batch-publish recent WYRIWE records to AttestationIndex
|
|
409
468
|
body: { limit?: number } (default 50, max 200)
|
|
410
469
|
→ { published, skipped, errors }
|
|
411
470
|
POST /admin/api/peers { url } — add peer
|
|
412
471
|
DEL /admin/api/peers { url } — remove peer
|
|
413
|
-
|
|
414
|
-
POST /admin/
|
|
472
|
+
GET /admin/api/ens-records ?name= — list ENS records
|
|
473
|
+
POST /admin/api/ens-records { name, type, coinType?, textKey?, value } — upsert
|
|
474
|
+
DEL /admin/api/ens-records { name, type, coinType?, textKey? } — delete
|
|
475
|
+
GET /admin/api/config safe config snapshot (never exposes private key)
|
|
476
|
+
POST /admin/api/config update config fields → writes config.json, restarts node
|
|
477
|
+
POST /admin/api/key { gatewayKey } — rotate signing key → restart
|
|
478
|
+
POST /admin/api/register register node on-chain via NodeRegistry
|
|
415
479
|
```
|
|
416
480
|
|
|
417
481
|
---
|
|
@@ -509,6 +573,12 @@ Protocol version `1` is the current stable spec. Nodes on a different version ar
|
|
|
509
573
|
**Setup wizard — node owner onboarding**
|
|
510
574
|
- [x] Admin secret as dedicated step 2 — prominent warning box, two-step skip confirmation
|
|
511
575
|
- [x] Post-setup checklist — signing ✓, admin ✓/⚠, WYRIWE/ERC-8004/VNI ○ with next-step hints
|
|
576
|
+
- [x] Spawn-based node restart (setup + config save) — works without a process manager
|
|
577
|
+
- [x] Claim-on-first-login — first MetaMask wallet to sign becomes permanent admin, no pre-configuration required
|
|
578
|
+
- [x] Admin transfer — logged-in admin proves new wallet ownership via SIWE, `adminAddress` updated live with no restart
|
|
579
|
+
- [x] ENS records panel — live table, add/delete addr / text / addr_coin / contenthash records, changes take effect immediately
|
|
580
|
+
- [x] Admin wallet panel in dashboard — current address, two-step transfer UI
|
|
581
|
+
- [x] `withEns()` — ENS wildcard resolver wrapper; DNS wire-format decode, selector dispatch (addr / addr_coin / text / contenthash), null → zero-value fallbacks, `isEnsCalldata()` guard
|
|
512
582
|
|
|
513
583
|
---
|
|
514
584
|
|
|
@@ -523,9 +593,9 @@ npm test
|
|
|
523
593
|
Expected output:
|
|
524
594
|
|
|
525
595
|
```
|
|
526
|
-
ℹ tests
|
|
527
|
-
ℹ suites
|
|
528
|
-
ℹ pass
|
|
596
|
+
ℹ tests 61
|
|
597
|
+
ℹ suites 22
|
|
598
|
+
ℹ pass 61
|
|
529
599
|
ℹ fail 0
|
|
530
600
|
```
|
|
531
601
|
|
|
@@ -535,15 +605,37 @@ Expected output:
|
|
|
535
605
|
|---|---|
|
|
536
606
|
| `src/__tests__/gateway.test.ts` | `decodeRequest` — address + calldata parsing, `.json` suffix stripping, `CcipRequestError` on bad inputs; `encodeResponse` envelope |
|
|
537
607
|
| `src/__tests__/crypto.test.ts` | `signRecord` / `recoverRecordSigner` round-trip; `verifyRecord` correct signer → `true`, wrong signer / tampered value → `false` |
|
|
538
|
-
| `src/__tests__/db.test.ts` | `insertRecord`, `getRecord` (with/without namespace), `getRecordsByInputHash`, `INSERT OR IGNORE` deduplication, cursor pagination, `getContributions` grouping, peer upsert + remove |
|
|
608
|
+
| `src/__tests__/db.test.ts` | `insertRecord`, `getRecord` (with/without namespace), `getRecordsByInputHash`, `INSERT OR IGNORE` deduplication, cursor pagination, `getContributions` grouping, peer upsert + remove, ENS record upsert/delete/list |
|
|
539
609
|
| `src/__tests__/ocp.test.ts` | `buildCommitmentHash` determinism, 32-byte hex output, field-sensitivity (agentId / outputHash / timestamp) |
|
|
540
610
|
| `src/__tests__/wyriwe.test.ts` | Sentinel path (`inputHash === rawInputHash`), non-sentinel path (`keccak256(abi.encode(rawInputHash, sanitizationPipelineHash))`), paths produce distinct hashes for same calldata |
|
|
541
611
|
| `src/__tests__/vni.test.ts` | `makeVni` field shape + stable `nodeId`; `verifyVni` round-trip; tamper detection (url / signerAddress / nodeId → `null`) |
|
|
612
|
+
| `src/__tests__/ens.test.ts` | DNS wire-format encode/decode round-trip; `withEns()` dispatch for all 4 record types (addr, addr_coin, text, contenthash); null → zero-value fallbacks; unknown selector → `0x`; wrong outer selector throws |
|
|
542
613
|
|
|
543
614
|
Tests use `SQLiteDB(':memory:')` directly (bypassing the runtime singleton) and Hardhat dev key 0 for any signing operations — both are safe to commit and require no external services.
|
|
544
615
|
|
|
545
616
|
---
|
|
546
617
|
|
|
618
|
+
## Roadmap
|
|
619
|
+
|
|
620
|
+
### v0.3.0 — IPFS browser resolution
|
|
621
|
+
Native ENS browsers (Brave, eth.link) resolve `contenthash` directly on-chain — they don't follow CCIP-Read. v0.3.0 will add an **IPFS + Browser resolution** admin panel that closes this gap:
|
|
622
|
+
|
|
623
|
+
- Pin a file or CID to IPFS (via Pinata) from the admin panel
|
|
624
|
+
- Set the resulting CID as the ENS name's `contenthash` on-chain (MetaMask, no stored key)
|
|
625
|
+
- Manage multiple names from one panel
|
|
626
|
+
|
|
627
|
+
Combined with `withEns()` (CCIP-Read, dynamic records) this makes the gateway handle both resolution paths:
|
|
628
|
+
|
|
629
|
+
| Path | Who | How |
|
|
630
|
+
|---|---|---|
|
|
631
|
+
| Static pages | Brave / native ENS browsers | `contenthash` on-chain → IPFS |
|
|
632
|
+
| Dynamic data | dapps / smart contracts | `offchainLookup` → CCIP-Read → `withEns()` |
|
|
633
|
+
|
|
634
|
+
### v0.4.0+ — Phase 2 / Phase 3
|
|
635
|
+
See [GATEWAY_DECENTRALIZATION_PLAN.md](https://github.com/Echo-Merlini/ccip-router) for the full decentralisation roadmap (chain as source of truth, incentivised node network).
|
|
636
|
+
|
|
637
|
+
---
|
|
638
|
+
|
|
547
639
|
## Related
|
|
548
640
|
|
|
549
641
|
- [ens-boiler](https://github.com/Echo-Merlini/ens-boiler) — opinionated ENS agent stack built on `ccip-router`
|
package/dist/chain/client.d.ts
CHANGED
|
@@ -387,6 +387,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
387
387
|
withdrawalsRoot?: `0x${string}` | undefined;
|
|
388
388
|
transactions: includeTransactions extends true ? ({
|
|
389
389
|
type: "legacy";
|
|
390
|
+
value: bigint;
|
|
390
391
|
r: import("viem").Hex;
|
|
391
392
|
s: import("viem").Hex;
|
|
392
393
|
v: bigint;
|
|
@@ -400,7 +401,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
400
401
|
nonce: number;
|
|
401
402
|
to: import("viem").Address | null;
|
|
402
403
|
typeHex: import("viem").Hex | null;
|
|
403
|
-
value: bigint;
|
|
404
404
|
accessList?: undefined | undefined;
|
|
405
405
|
authorizationList?: undefined | undefined;
|
|
406
406
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -413,6 +413,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
413
413
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_2 ? T_2 extends (blockTag extends "pending" ? true : false) ? T_2 extends true ? null : number : never : never;
|
|
414
414
|
} | {
|
|
415
415
|
type: "eip2930";
|
|
416
|
+
value: bigint;
|
|
416
417
|
r: import("viem").Hex;
|
|
417
418
|
s: import("viem").Hex;
|
|
418
419
|
v: bigint;
|
|
@@ -426,7 +427,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
426
427
|
nonce: number;
|
|
427
428
|
to: import("viem").Address | null;
|
|
428
429
|
typeHex: import("viem").Hex | null;
|
|
429
|
-
value: bigint;
|
|
430
430
|
accessList: import("viem").AccessList;
|
|
431
431
|
authorizationList?: undefined | undefined;
|
|
432
432
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -439,6 +439,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
439
439
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_5 ? T_5 extends (blockTag extends "pending" ? true : false) ? T_5 extends true ? null : number : never : never;
|
|
440
440
|
} | {
|
|
441
441
|
type: "eip1559";
|
|
442
|
+
value: bigint;
|
|
442
443
|
r: import("viem").Hex;
|
|
443
444
|
s: import("viem").Hex;
|
|
444
445
|
v: bigint;
|
|
@@ -452,7 +453,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
452
453
|
nonce: number;
|
|
453
454
|
to: import("viem").Address | null;
|
|
454
455
|
typeHex: import("viem").Hex | null;
|
|
455
|
-
value: bigint;
|
|
456
456
|
accessList: import("viem").AccessList;
|
|
457
457
|
authorizationList?: undefined | undefined;
|
|
458
458
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -465,6 +465,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
465
465
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_8 ? T_8 extends (blockTag extends "pending" ? true : false) ? T_8 extends true ? null : number : never : never;
|
|
466
466
|
} | {
|
|
467
467
|
type: "eip4844";
|
|
468
|
+
value: bigint;
|
|
468
469
|
r: import("viem").Hex;
|
|
469
470
|
s: import("viem").Hex;
|
|
470
471
|
v: bigint;
|
|
@@ -478,7 +479,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
478
479
|
nonce: number;
|
|
479
480
|
to: import("viem").Address | null;
|
|
480
481
|
typeHex: import("viem").Hex | null;
|
|
481
|
-
value: bigint;
|
|
482
482
|
accessList: import("viem").AccessList;
|
|
483
483
|
authorizationList?: undefined | undefined;
|
|
484
484
|
blobVersionedHashes: readonly import("viem").Hex[];
|
|
@@ -491,6 +491,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
491
491
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_11 ? T_11 extends (blockTag extends "pending" ? true : false) ? T_11 extends true ? null : number : never : never;
|
|
492
492
|
} | {
|
|
493
493
|
type: "eip7702";
|
|
494
|
+
value: bigint;
|
|
494
495
|
r: import("viem").Hex;
|
|
495
496
|
s: import("viem").Hex;
|
|
496
497
|
v: bigint;
|
|
@@ -504,7 +505,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
504
505
|
nonce: number;
|
|
505
506
|
to: import("viem").Address | null;
|
|
506
507
|
typeHex: import("viem").Hex | null;
|
|
507
|
-
value: bigint;
|
|
508
508
|
accessList: import("viem").AccessList;
|
|
509
509
|
authorizationList: import("viem").SignedAuthorizationList;
|
|
510
510
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -652,6 +652,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
652
652
|
getStorageAt: (args: import("viem").GetStorageAtParameters) => Promise<import("viem").GetStorageAtReturnType>;
|
|
653
653
|
getTransaction: <blockTag extends import("viem").BlockTag = "latest">(args: import("viem").GetTransactionParameters<blockTag>) => Promise<{
|
|
654
654
|
type: "legacy";
|
|
655
|
+
value: bigint;
|
|
655
656
|
r: import("viem").Hex;
|
|
656
657
|
s: import("viem").Hex;
|
|
657
658
|
v: bigint;
|
|
@@ -665,7 +666,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
665
666
|
nonce: number;
|
|
666
667
|
to: import("viem").Address | null;
|
|
667
668
|
typeHex: import("viem").Hex | null;
|
|
668
|
-
value: bigint;
|
|
669
669
|
accessList?: undefined | undefined;
|
|
670
670
|
authorizationList?: undefined | undefined;
|
|
671
671
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -678,6 +678,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
678
678
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_2 ? T_2 extends (blockTag extends "pending" ? true : false) ? T_2 extends true ? null : number : never : never;
|
|
679
679
|
} | {
|
|
680
680
|
type: "eip2930";
|
|
681
|
+
value: bigint;
|
|
681
682
|
r: import("viem").Hex;
|
|
682
683
|
s: import("viem").Hex;
|
|
683
684
|
v: bigint;
|
|
@@ -691,7 +692,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
691
692
|
nonce: number;
|
|
692
693
|
to: import("viem").Address | null;
|
|
693
694
|
typeHex: import("viem").Hex | null;
|
|
694
|
-
value: bigint;
|
|
695
695
|
accessList: import("viem").AccessList;
|
|
696
696
|
authorizationList?: undefined | undefined;
|
|
697
697
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -704,6 +704,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
704
704
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_5 ? T_5 extends (blockTag extends "pending" ? true : false) ? T_5 extends true ? null : number : never : never;
|
|
705
705
|
} | {
|
|
706
706
|
type: "eip1559";
|
|
707
|
+
value: bigint;
|
|
707
708
|
r: import("viem").Hex;
|
|
708
709
|
s: import("viem").Hex;
|
|
709
710
|
v: bigint;
|
|
@@ -717,7 +718,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
717
718
|
nonce: number;
|
|
718
719
|
to: import("viem").Address | null;
|
|
719
720
|
typeHex: import("viem").Hex | null;
|
|
720
|
-
value: bigint;
|
|
721
721
|
accessList: import("viem").AccessList;
|
|
722
722
|
authorizationList?: undefined | undefined;
|
|
723
723
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -730,6 +730,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
730
730
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_8 ? T_8 extends (blockTag extends "pending" ? true : false) ? T_8 extends true ? null : number : never : never;
|
|
731
731
|
} | {
|
|
732
732
|
type: "eip4844";
|
|
733
|
+
value: bigint;
|
|
733
734
|
r: import("viem").Hex;
|
|
734
735
|
s: import("viem").Hex;
|
|
735
736
|
v: bigint;
|
|
@@ -743,7 +744,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
743
744
|
nonce: number;
|
|
744
745
|
to: import("viem").Address | null;
|
|
745
746
|
typeHex: import("viem").Hex | null;
|
|
746
|
-
value: bigint;
|
|
747
747
|
accessList: import("viem").AccessList;
|
|
748
748
|
authorizationList?: undefined | undefined;
|
|
749
749
|
blobVersionedHashes: readonly import("viem").Hex[];
|
|
@@ -756,6 +756,7 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
756
756
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_11 ? T_11 extends (blockTag extends "pending" ? true : false) ? T_11 extends true ? null : number : never : never;
|
|
757
757
|
} | {
|
|
758
758
|
type: "eip7702";
|
|
759
|
+
value: bigint;
|
|
759
760
|
r: import("viem").Hex;
|
|
760
761
|
s: import("viem").Hex;
|
|
761
762
|
v: bigint;
|
|
@@ -769,7 +770,6 @@ export declare function getPublicClient(rpcUrl: string, chainId: number): {
|
|
|
769
770
|
nonce: number;
|
|
770
771
|
to: import("viem").Address | null;
|
|
771
772
|
typeHex: import("viem").Hex | null;
|
|
772
|
-
value: bigint;
|
|
773
773
|
accessList: import("viem").AccessList;
|
|
774
774
|
authorizationList: import("viem").SignedAuthorizationList;
|
|
775
775
|
blobVersionedHashes?: undefined | undefined;
|
package/dist/db/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,8YAalB,CAAA;AAMD,eAAO,MAAM,UAAU,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,8YAalB,CAAA;AAMD,eAAO,MAAM,UAAU,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAiCxD,CAAA"}
|
package/dist/db/schema.js
CHANGED
|
@@ -37,5 +37,19 @@ export const MIGRATIONS = [
|
|
|
37
37
|
ON records (namespace, timestamp);
|
|
38
38
|
`,
|
|
39
39
|
},
|
|
40
|
+
{
|
|
41
|
+
version: 2,
|
|
42
|
+
sql: `
|
|
43
|
+
CREATE TABLE IF NOT EXISTS ens_records (
|
|
44
|
+
name TEXT NOT NULL,
|
|
45
|
+
type TEXT NOT NULL,
|
|
46
|
+
coin_type INTEGER NOT NULL DEFAULT -1,
|
|
47
|
+
text_key TEXT NOT NULL DEFAULT '',
|
|
48
|
+
value TEXT NOT NULL,
|
|
49
|
+
modified_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
|
50
|
+
PRIMARY KEY (name, type, coin_type, text_key)
|
|
51
|
+
);
|
|
52
|
+
`,
|
|
53
|
+
},
|
|
40
54
|
];
|
|
41
55
|
//# sourceMappingURL=schema.js.map
|
package/dist/db/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,iFAAiF;AACjF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;CAarB,CAAA;AAED,wEAAwE;AACxE,iFAAiF;AACjF,wEAAwE;AACxE,sDAAsD;AACtD,MAAM,CAAC,MAAM,UAAU,GAAuC;IAC5D;QACE,OAAO,EAAE,CAAC;QACV,GAAG,EAAE;;;;;;;;;;;;;;KAcJ;KACF;CACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,iFAAiF;AACjF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;CAarB,CAAA;AAED,wEAAwE;AACxE,iFAAiF;AACjF,wEAAwE;AACxE,sDAAsD;AACtD,MAAM,CAAC,MAAM,UAAU,GAAuC;IAC5D;QACE,OAAO,EAAE,CAAC;QACV,GAAG,EAAE;;;;;;;;;;;;;;KAcJ;KACF;IACD;QACE,OAAO,EAAE,CAAC;QACV,GAAG,EAAE;;;;;;;;;;KAUJ;KACF;CACF,CAAA"}
|
package/dist/db/sqlite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DB, MeshRecord, PeerState, Contribution } from './types.js';
|
|
1
|
+
import type { DB, MeshRecord, PeerState, Contribution, NameRecord } from './types.js';
|
|
2
2
|
export declare class SQLiteDB implements DB {
|
|
3
3
|
private db;
|
|
4
4
|
private stmts;
|
|
@@ -14,6 +14,10 @@ export declare class SQLiteDB implements DB {
|
|
|
14
14
|
getRecentRecords(namespace: string, limit: number): Promise<MeshRecord[]>;
|
|
15
15
|
getContributions(namespace: string): Promise<Contribution[]>;
|
|
16
16
|
removePeer(url: string): Promise<void>;
|
|
17
|
+
upsertNameRecord(r: Omit<NameRecord, 'modifiedAt'>): Promise<void>;
|
|
18
|
+
deleteNameRecord(name: string, type: string, coinType: number, textKey: string): Promise<void>;
|
|
19
|
+
getNameRecordValue(name: string, type: string, coinType?: number, textKey?: string): Promise<string | null>;
|
|
20
|
+
listNameRecords(name?: string): Promise<NameRecord[]>;
|
|
17
21
|
close(): void;
|
|
18
22
|
}
|
|
19
23
|
//# sourceMappingURL=sqlite.d.ts.map
|
package/dist/db/sqlite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/db/sqlite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/db/sqlite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,E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G,OAAO,CAAC,IAAI,CAAC;IAI9F,kBAAkB,CACtB,IAAI,EAAM,MAAM,EAChB,IAAI,EAAM,MAAM,EAChB,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAG,MAAY,GACrB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKnB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAO3D,KAAK,IAAI,IAAI;CAGd"}
|
package/dist/db/sqlite.js
CHANGED
|
@@ -77,6 +77,27 @@ export class SQLiteDB {
|
|
|
77
77
|
WHERE input_hash = @inputHash
|
|
78
78
|
AND namespace = @namespace
|
|
79
79
|
AND signature != @signature
|
|
80
|
+
`),
|
|
81
|
+
ensUpsert: this.db.prepare(`
|
|
82
|
+
INSERT INTO ens_records (name, type, coin_type, text_key, value, modified_at)
|
|
83
|
+
VALUES (@name, @type, @coinType, @textKey, @value, @modifiedAt)
|
|
84
|
+
ON CONFLICT (name, type, coin_type, text_key) DO UPDATE SET
|
|
85
|
+
value = excluded.value,
|
|
86
|
+
modified_at = excluded.modified_at
|
|
87
|
+
`),
|
|
88
|
+
ensDelete: this.db.prepare(`
|
|
89
|
+
DELETE FROM ens_records
|
|
90
|
+
WHERE name = @name AND type = @type AND coin_type = @coinType AND text_key = @textKey
|
|
91
|
+
`),
|
|
92
|
+
ensGet: this.db.prepare(`
|
|
93
|
+
SELECT value FROM ens_records
|
|
94
|
+
WHERE name = @name AND type = @type AND coin_type = @coinType AND text_key = @textKey
|
|
95
|
+
`),
|
|
96
|
+
ensList: this.db.prepare(`
|
|
97
|
+
SELECT * FROM ens_records WHERE name = ? ORDER BY type ASC, coin_type ASC, text_key ASC
|
|
98
|
+
`),
|
|
99
|
+
ensListAll: this.db.prepare(`
|
|
100
|
+
SELECT * FROM ens_records ORDER BY name ASC, type ASC, coin_type ASC, text_key ASC
|
|
80
101
|
`),
|
|
81
102
|
};
|
|
82
103
|
}
|
|
@@ -169,6 +190,29 @@ export class SQLiteDB {
|
|
|
169
190
|
async removePeer(url) {
|
|
170
191
|
this.stmts.removePeer.run(url);
|
|
171
192
|
}
|
|
193
|
+
async upsertNameRecord(r) {
|
|
194
|
+
this.stmts.ensUpsert.run({
|
|
195
|
+
name: r.name,
|
|
196
|
+
type: r.type,
|
|
197
|
+
coinType: r.coinType,
|
|
198
|
+
textKey: r.textKey,
|
|
199
|
+
value: r.value,
|
|
200
|
+
modifiedAt: Math.floor(Date.now() / 1000),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
async deleteNameRecord(name, type, coinType, textKey) {
|
|
204
|
+
this.stmts.ensDelete.run({ name, type, coinType, textKey });
|
|
205
|
+
}
|
|
206
|
+
async getNameRecordValue(name, type, coinType = -1, textKey = '') {
|
|
207
|
+
const row = this.stmts.ensGet.get({ name, type, coinType, textKey });
|
|
208
|
+
return row?.value ?? null;
|
|
209
|
+
}
|
|
210
|
+
async listNameRecords(name) {
|
|
211
|
+
const rows = (name
|
|
212
|
+
? this.stmts.ensList.all(name)
|
|
213
|
+
: this.stmts.ensListAll.all());
|
|
214
|
+
return rows.map(toNameRecord);
|
|
215
|
+
}
|
|
172
216
|
close() {
|
|
173
217
|
this.db.close();
|
|
174
218
|
}
|
|
@@ -193,4 +237,14 @@ function toPeerState(row) {
|
|
|
193
237
|
signerAddress: row.signer_address,
|
|
194
238
|
};
|
|
195
239
|
}
|
|
240
|
+
function toNameRecord(row) {
|
|
241
|
+
return {
|
|
242
|
+
name: row.name,
|
|
243
|
+
type: row.type,
|
|
244
|
+
coinType: row.coin_type,
|
|
245
|
+
textKey: row.text_key,
|
|
246
|
+
value: row.value,
|
|
247
|
+
modifiedAt: row.modified_at,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
196
250
|
//# sourceMappingURL=sqlite.js.map
|
package/dist/db/sqlite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../../src/db/sqlite.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zB,GAAG,EAAS,GAAG,CAAC,GAAG;QACnB,KAAK,EAAO,GAAG,CAAC,KAAK;QACrB,SAAS,EAAG,GAAG,CAAC,SAAS;QACzB,SAAS,EAAG,GAAG,CAAC,SAAS;QACzB,UAAU,EAAE,GAAG,CAAC,WAAW;KAC5B,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,GAAY;IAC/B,OAAO;QACL,GAAG,EAAY,GAAG,CAAC,GAAG;QACtB,UAAU,EAAK,GAAG,CAAC,YAAY;QAC/B,OAAO,EAAQ,GAAG,CAAC,OAAO,KAAK,CAAC;QAChC,WAAW,EAAI,GAAG,CAAC,YAAY;QAC/B,aAAa,EAAE,GAAG,CAAC,cAAc;KAClC,CAAA;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO;QACL,IAAI,EAAQ,GAAG,CAAC,IAAI;QACpB,IAAI,EAAQ,GAAG,CAAC,IAA0B;QAC1C,QAAQ,EAAI,GAAG,CAAC,SAAS;QACzB,OAAO,EAAK,GAAG,CAAC,QAAQ;QACxB,KAAK,EAAO,GAAG,CAAC,KAAK;QACrB,UAAU,EAAE,GAAG,CAAC,WAAW;KAC5B,CAAA;AACH,CAAC"}
|
package/dist/db/types.d.ts
CHANGED
|
@@ -18,6 +18,14 @@ export type Contribution = {
|
|
|
18
18
|
sourcePeer: string | null;
|
|
19
19
|
count: number;
|
|
20
20
|
};
|
|
21
|
+
export type NameRecord = {
|
|
22
|
+
name: string;
|
|
23
|
+
type: 'addr' | 'addr_coin' | 'text' | 'contenthash';
|
|
24
|
+
coinType: number;
|
|
25
|
+
textKey: string;
|
|
26
|
+
value: string;
|
|
27
|
+
modifiedAt: number;
|
|
28
|
+
};
|
|
21
29
|
export interface DB {
|
|
22
30
|
insertRecord(record: MeshRecord): Promise<void>;
|
|
23
31
|
getRecordsSince(namespace: string, since: number, limit: number, cursor?: string): Promise<MeshRecord[]>;
|
|
@@ -29,6 +37,10 @@ export interface DB {
|
|
|
29
37
|
removePeer(url: string): Promise<void>;
|
|
30
38
|
getPeers(): Promise<PeerState[]>;
|
|
31
39
|
recordCount(namespace: string): Promise<number>;
|
|
40
|
+
upsertNameRecord(r: Omit<NameRecord, 'modifiedAt'>): Promise<void>;
|
|
41
|
+
deleteNameRecord(name: string, type: string, coinType: number, textKey: string): Promise<void>;
|
|
42
|
+
getNameRecordValue(name: string, type: string, coinType?: number, textKey?: string): Promise<string | null>;
|
|
43
|
+
listNameRecords(name?: string): Promise<NameRecord[]>;
|
|
32
44
|
close(): void;
|
|
33
45
|
}
|
|
34
46
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/db/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,KAAK,EAAO,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,WAAW,EAAE;IACjB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,eAAe,CAAC,SAAS,EAAE,MAAM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AO,CAAC,IAAI,CAAC,CAAA;IACtC,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAA;IAChC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAE/C,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClE,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9F,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAC3G,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IACrD,KAAK,IAAI,IAAI,CAAA;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dns.d.ts","sourceRoot":"","sources":["../../src/ens/dns.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAUvD;AAGD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAStD"}
|
package/dist/ens/dns.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// DNS wire-format name decoder (RFC 1035)
|
|
2
|
+
// Converts a DNS-encoded name byte array to a dot-separated string.
|
|
3
|
+
// e.g. 0x 07 vitalik 03 eth 00 → "vitalik.eth"
|
|
4
|
+
export function decodeDnsName(bytes) {
|
|
5
|
+
const labels = [];
|
|
6
|
+
let i = 0;
|
|
7
|
+
while (i < bytes.length && bytes[i] !== 0) {
|
|
8
|
+
const len = bytes[i];
|
|
9
|
+
i++;
|
|
10
|
+
labels.push(new TextDecoder().decode(bytes.slice(i, i + len)));
|
|
11
|
+
i += len;
|
|
12
|
+
}
|
|
13
|
+
return labels.join('.');
|
|
14
|
+
}
|
|
15
|
+
// Encode a dot-separated name to DNS wire format
|
|
16
|
+
export function encodeDnsName(name) {
|
|
17
|
+
const labels = name.split('.');
|
|
18
|
+
const parts = [];
|
|
19
|
+
for (const label of labels) {
|
|
20
|
+
parts.push(label.length);
|
|
21
|
+
for (const char of label)
|
|
22
|
+
parts.push(char.charCodeAt(0));
|
|
23
|
+
}
|
|
24
|
+
parts.push(0);
|
|
25
|
+
return new Uint8Array(parts);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=dns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dns.js","sourceRoot":"","sources":["../../src/ens/dns.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,oEAAoE;AACpE,+CAA+C;AAC/C,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACpB,CAAC,EAAE,CAAA;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;QAC9D,CAAC,IAAI,GAAG,CAAA;IACV,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACzB,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,MAAM,GAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACxB,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1D,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACb,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ResolverFn } from '../router/index.js';
|
|
2
|
+
export type EnsRecord = {
|
|
3
|
+
type: 'addr';
|
|
4
|
+
} | {
|
|
5
|
+
type: 'addr';
|
|
6
|
+
coinType: bigint;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'text';
|
|
9
|
+
key: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'contenthash';
|
|
12
|
+
};
|
|
13
|
+
export type EnsResolverFn = (name: string, record: EnsRecord) => Promise<string | null>;
|
|
14
|
+
export declare const RESOLVE_SELECTOR = "0x9061b923";
|
|
15
|
+
export declare function isEnsCalldata(calldata: string): boolean;
|
|
16
|
+
export declare function withEns(resolver: EnsResolverFn): ResolverFn;
|
|
17
|
+
//# sourceMappingURL=withEns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withEns.d.ts","sourceRoot":"","sources":["../../src/ens/withEns.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAIpD,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAA;AAQ3B,MAAM,MAAM,aAAa,GAAG,CAC1B,IAAI,EAAI,MAAM,EACd,MAAM,EAAE,SAAS,KACd,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;AAE3B,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAI5C,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvD;AAaD,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,UAAU,CAuD3D"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { decodeAbiParameters, encodeAbiParameters, hexToBytes } from 'viem';
|
|
2
|
+
import { decodeDnsName } from './dns.js';
|
|
3
|
+
export const RESOLVE_SELECTOR = '0x9061b923'; // resolve(bytes,bytes)
|
|
4
|
+
// Returns true if the calldata looks like an ENS resolve(bytes,bytes) call.
|
|
5
|
+
// Use to guard withEns() in multi-purpose resolvers before dispatching.
|
|
6
|
+
export function isEnsCalldata(calldata) {
|
|
7
|
+
return calldata.toLowerCase().startsWith(RESOLVE_SELECTOR);
|
|
8
|
+
}
|
|
9
|
+
const ADDR_SELECTOR = '0x3b3b57de'; // addr(bytes32)
|
|
10
|
+
const ADDR_CT_SELECTOR = '0xf1cb7e06'; // addr(bytes32,uint256)
|
|
11
|
+
const TEXT_SELECTOR = '0x59d1d43c'; // text(bytes32,string)
|
|
12
|
+
const CONTENTHASH_SEL = '0xbc1c58d1'; // contenthash(bytes32)
|
|
13
|
+
// Wrap any EnsResolverFn as a ResolverFn for use with CcipRouter.
|
|
14
|
+
//
|
|
15
|
+
// Decodes the ENS resolve(bytes name, bytes data) calldata, dispatches to
|
|
16
|
+
// the clean resolver with a typed EnsRecord, and ABI-encodes the response.
|
|
17
|
+
//
|
|
18
|
+
// Composes with withWyriwe — put withEns inside:
|
|
19
|
+
// resolver = withWyriwe(withEns(myEnsResolver), wyriweOpts)
|
|
20
|
+
export function withEns(resolver) {
|
|
21
|
+
return async (sender, calldata, namespace) => {
|
|
22
|
+
if (!calldata.toLowerCase().startsWith(RESOLVE_SELECTOR)) {
|
|
23
|
+
throw new Error(`[withEns] unexpected selector: ${calldata.slice(0, 10)}`);
|
|
24
|
+
}
|
|
25
|
+
// Decode outer resolve(bytes name, bytes data)
|
|
26
|
+
const [nameBytes, innerData] = decodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], `0x${calldata.slice(10)}`);
|
|
27
|
+
// DNS wire-format → "vitalik.eth"
|
|
28
|
+
const name = decodeDnsName(hexToBytes(nameBytes));
|
|
29
|
+
const selector = innerData.slice(0, 10).toLowerCase();
|
|
30
|
+
const inner = `0x${innerData.slice(10)}`;
|
|
31
|
+
switch (selector) {
|
|
32
|
+
case ADDR_SELECTOR: {
|
|
33
|
+
// addr(bytes32) → address
|
|
34
|
+
const result = await resolver(name, { type: 'addr' });
|
|
35
|
+
const addr = (result ?? '0x0000000000000000000000000000000000000000');
|
|
36
|
+
return encodeAbiParameters([{ type: 'address' }], [addr]);
|
|
37
|
+
}
|
|
38
|
+
case ADDR_CT_SELECTOR: {
|
|
39
|
+
// addr(bytes32,uint256) → bytes (coin-type specific encoding)
|
|
40
|
+
const [, coinType] = decodeAbiParameters([{ type: 'bytes32' }, { type: 'uint256' }], inner);
|
|
41
|
+
const result = await resolver(name, { type: 'addr', coinType: coinType });
|
|
42
|
+
return encodeAbiParameters([{ type: 'bytes' }], [(result ?? '0x')]);
|
|
43
|
+
}
|
|
44
|
+
case TEXT_SELECTOR: {
|
|
45
|
+
// text(bytes32,string) → string
|
|
46
|
+
const [, key] = decodeAbiParameters([{ type: 'bytes32' }, { type: 'string' }], inner);
|
|
47
|
+
const result = await resolver(name, { type: 'text', key: key });
|
|
48
|
+
return encodeAbiParameters([{ type: 'string' }], [result ?? '']);
|
|
49
|
+
}
|
|
50
|
+
case CONTENTHASH_SEL: {
|
|
51
|
+
// contenthash(bytes32) → bytes
|
|
52
|
+
const result = await resolver(name, { type: 'contenthash' });
|
|
53
|
+
return encodeAbiParameters([{ type: 'bytes' }], [(result ?? '0x')]);
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
return '0x';
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=withEns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withEns.js","sourceRoot":"","sources":["../../src/ens/withEns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAoBxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAA,CAAC,uBAAuB;AAEpE,4EAA4E;AAC5E,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;AAC5D,CAAC;AACD,MAAM,aAAa,GAAM,YAAY,CAAA,CAAC,gBAAgB;AACtD,MAAM,gBAAgB,GAAG,YAAY,CAAA,CAAC,wBAAwB;AAC9D,MAAM,aAAa,GAAM,YAAY,CAAA,CAAC,uBAAuB;AAC7D,MAAM,eAAe,GAAI,YAAY,CAAA,CAAC,uBAAuB;AAE7D,kEAAkE;AAClE,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,EAAE;AACF,iDAAiD;AACjD,8DAA8D;AAC9D,MAAM,UAAU,OAAO,CAAC,QAAuB;IAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE;QAC3C,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAA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
|
10
10
|
export { makeVni, verifyVni, fetchPeerVni } from './mesh/vni.js';
|
|
11
11
|
export type { SignedVni, VniDocument } from './mesh/vni.js';
|
|
12
|
+
export { withEns, isEnsCalldata } from './ens/withEns.js';
|
|
13
|
+
export type { EnsResolverFn, EnsRecord } from './ens/withEns.js';
|
|
14
|
+
export { encodeDnsName, decodeDnsName } from './ens/dns.js';
|
|
12
15
|
//# sourceMappingURL=lib.d.ts.map
|
package/dist/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,YAAY,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,YAAY,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACrE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAChE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,YAAY,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,YAAY,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACrE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAChE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzD,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/lib.js
CHANGED
|
@@ -5,4 +5,6 @@ export { publishAttestation, checkOnChain } from './chain/publish.js';
|
|
|
5
5
|
export { registerNode } from './chain/register.js';
|
|
6
6
|
export { ATTESTATION_INDEX_ABI, NODE_REGISTRY_ABI, WYRIWE_ATTESTATION_VERIFIER_ABI } from './chain/abi.js';
|
|
7
7
|
export { makeVni, verifyVni, fetchPeerVni } from './mesh/vni.js';
|
|
8
|
+
export { withEns, isEnsCalldata } from './ens/withEns.js';
|
|
9
|
+
export { encodeDnsName, decodeDnsName } from './ens/dns.js';
|
|
8
10
|
//# sourceMappingURL=lib.js.map
|
package/dist/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEhE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEzD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/mesh/records.js
CHANGED
|
@@ -18,7 +18,7 @@ recordsRouter.get('/', async (c) => {
|
|
|
18
18
|
: null;
|
|
19
19
|
return c.json({
|
|
20
20
|
protocol: 1,
|
|
21
|
-
node_version: '0.
|
|
21
|
+
node_version: '0.2.0',
|
|
22
22
|
namespace,
|
|
23
23
|
records,
|
|
24
24
|
cursor: nextCursor,
|
|
@@ -34,7 +34,7 @@ peersRouter.get('/', async (c) => {
|
|
|
34
34
|
const signerAddress = config.gatewayKey ? privateKeyToAccount(config.gatewayKey).address : null;
|
|
35
35
|
return c.json({
|
|
36
36
|
protocol: 1,
|
|
37
|
-
node_version: '0.
|
|
37
|
+
node_version: '0.2.0',
|
|
38
38
|
signerAddress,
|
|
39
39
|
peers: peers.map((p) => ({
|
|
40
40
|
url: p.url,
|
package/dist/mesh/vni.js
CHANGED
|
@@ -5,7 +5,7 @@ function vniMessage(doc) {
|
|
|
5
5
|
return 'ccip-router:vni:' + JSON.stringify(doc);
|
|
6
6
|
}
|
|
7
7
|
// Produce a fresh signed VNI for this node.
|
|
8
|
-
export async function makeVni(gatewayKey, url, version = '0.
|
|
8
|
+
export async function makeVni(gatewayKey, url, version = '0.2.0') {
|
|
9
9
|
const account = privateKeyToAccount(gatewayKey);
|
|
10
10
|
const timestamp = Math.floor(Date.now() / 1000);
|
|
11
11
|
const nodeId = keccak256(toBytes(account.address));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccip-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "The coordination layer CCIP-Read was missing. Peer sync, deduplication, and cryptographic attestation for any CCIP-Read gateway.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/lib.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"dist/lib.js.map",
|
|
22
22
|
"dist/lib.d.ts",
|
|
23
23
|
"dist/lib.d.ts.map",
|
|
24
|
+
"dist/ens",
|
|
24
25
|
"dist/mesh",
|
|
25
26
|
"dist/router",
|
|
26
27
|
"contracts/IAttestationVerifier.sol",
|