Skip to content

Commit 92a42e9

Browse files
committed
feat(sdk): export ERC-8004 validation, rename Endpoint to ServiceDefinition
- Export Zod schemas (RegistrationFileSchema, ServiceDefinitionSchema, etc.) - Add validateRegistrationFile(), parseRegistrationFile(), normalizeRegistrationFile() - Add CAIP validation helpers (isValidAgentRegistry, isSatiAgentRegistry) - Add network-aware buildSatiRegistrationEntry() with devnet support - Add ERC8004_TYPE, VALID_TRUST_MODELS, SATI_CHAIN_IDS constants - Add strict mode to fetchRegistrationFile() - Rename Endpoint -> ServiceDefinition (deprecated re-export kept) - Rename setEndpoint/removeEndpoint -> setService/removeService on builder - Harden sati-agent0-sdk adapters with optional chaining and validation guards - Update dashboard to use ServiceDefinition, SATI_CHAIN_IDS, strict fetch - Add ERC-8004 best practices reference docs (spec, registration, reputation)
1 parent cf59d06 commit 92a42e9

21 files changed

Lines changed: 1688 additions & 99 deletions

File tree

apps/dashboard/src/react-app/lib/sati.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ export type AgentMetadata = RegistrationFile;
483483
* - Returns null on network errors or invalid URIs (never throws)
484484
*/
485485
export async function fetchAgentMetadata(uri: string): Promise<AgentMetadata | null> {
486-
return fetchRegistrationFile(uri);
486+
return fetchRegistrationFile(uri, { strict: true });
487487
}
488488

489489
/**

apps/dashboard/src/react-app/lib/x402.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,18 @@ import { x402Client, wrapFetchWithPayment, type SelectPaymentRequirements } from
1818
import { ExactSvmScheme } from "@x402/svm/exact/client";
1919
import { ExactSvmSchemeV1 } from "@x402/svm/exact/v1/client";
2020
import { getChain, type SolanaChain } from "./network";
21-
22-
// CAIP-2 network identifiers used by x402 (based on genesis hash)
23-
const SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
24-
const SOLANA_DEVNET_CAIP2 = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
21+
import { SATI_CHAIN_IDS } from "@cascade-fyi/sati-sdk";
2522

2623
/**
2724
* Maps our app's chain identifier to x402's CAIP-2 network identifier.
2825
*/
2926
function chainToCaip2(chain: SolanaChain): string {
3027
switch (chain) {
3128
case "solana:mainnet":
32-
return SOLANA_MAINNET_CAIP2;
29+
return SATI_CHAIN_IDS.mainnet;
3330
default:
3431
// devnet, testnet, localnet all use devnet CAIP-2
35-
return SOLANA_DEVNET_CAIP2;
32+
return SATI_CHAIN_IDS.devnet;
3633
}
3734
}
3835

apps/dashboard/src/worker/identity-api.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import {
2323
Outcome as OutcomeEnum,
2424
type FeedbackData,
2525
SATI_PROGRAM_ADDRESS,
26+
SATI_CHAIN_IDS,
2627
type AgentIdentity,
2728
} from "@cascade-fyi/sati-sdk";
28-
import type { Endpoint, TrustMechanism } from "@cascade-fyi/sati-sdk";
29+
import type { ServiceDefinition, TrustMechanism } from "@cascade-fyi/sati-sdk";
2930
import bs58 from "bs58";
3031
import type { Env } from "../env";
3132

@@ -104,11 +105,8 @@ interface FeedbackRequest {
104105
feedbackHash?: string;
105106
}
106107

107-
// CAIP-2 chain identifiers
108-
const CAIP2_CHAINS = {
109-
mainnet: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
110-
devnet: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
111-
} as const;
108+
// CAIP-2 chain identifiers (from SDK)
109+
const CAIP2_CHAINS = SATI_CHAIN_IDS;
112110

113111
// =============================================================================
114112
// Helpers
@@ -199,7 +197,7 @@ export function createIdentityApi(env: Env) {
199197
description: body.description.trim(),
200198
image: body.image.trim(),
201199
externalUrl: body.externalUrl,
202-
services: body.services as Endpoint[],
200+
services: body.services as ServiceDefinition[],
203201
supportedTrust: body.supportedTrust as TrustMechanism[],
204202
active: body.active ?? true,
205203
x402Support: body.x402Support,
@@ -276,7 +274,7 @@ export function createIdentityApi(env: Env) {
276274
for (const agent of agents) {
277275
if (results.length >= limit) break;
278276

279-
const regFile = await fetchRegistrationFile(agent.uri);
277+
const regFile = await fetchRegistrationFile(agent.uri, { strict: true });
280278

281279
if (nameFilter) {
282280
const agentName = (regFile?.name ?? agent.name).toLowerCase();
@@ -326,7 +324,7 @@ export function createIdentityApi(env: Env) {
326324
return c.json({ error: "Agent not found" }, 404);
327325
}
328326

329-
const regFile = await fetchRegistrationFile(agent.uri);
327+
const regFile = await fetchRegistrationFile(agent.uri, { strict: true });
330328

331329
// Fetch reputation summary
332330
const networkConfig = getNetworkConfig(sati);

apps/dashboard/src/worker/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
ContentType,
2222
type ParsedAttestation,
2323
type ParsedValidationAttestation,
24+
SATI_CHAIN_IDS,
2425
} from "@cascade-fyi/sati-sdk";
2526
import bs58 from "bs58";
2627
import { paymentMiddleware, x402ResourceServer } from "@x402/hono";
@@ -90,8 +91,8 @@ const FACILITATOR_URL_MAINNET = "https://x402.dexter.cash";
9091
// const FACILITATOR_URL_MAINNET = "https://pay.openfacilitator.io";
9192

9293
// Solana CAIP-2 network identifiers (used for x402 payments)
93-
const SOLANA_DEVNET_NETWORK = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1" as const;
94-
const SOLANA_MAINNET_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" as const;
94+
const SOLANA_DEVNET_NETWORK = SATI_CHAIN_IDS.devnet;
95+
const SOLANA_MAINNET_NETWORK = SATI_CHAIN_IDS.mainnet;
9596

9697
// Helper to get deployed config for a network
9798
function getNetworkConfig(network: "devnet" | "mainnet") {

docs/.vitepress/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ export default defineConfig({
5959
{ text: 'sati-sdk', link: '/reference/sati-sdk' },
6060
]
6161
},
62+
{
63+
text: 'ERC-8004 Reference',
64+
collapsed: true,
65+
items: [
66+
{ text: 'Specification', link: '/reference/erc-8004/spec' },
67+
{ text: 'Registration Guide', link: '/reference/erc-8004/registration' },
68+
{ text: 'Reputation Guide', link: '/reference/erc-8004/reputation' },
69+
]
70+
},
6271
{
6372
text: 'Deep Dive',
6473
items: [
611 KB
Loading
1.77 MB
Loading
528 KB
Loading

0 commit comments

Comments
 (0)