@fangorn-network/sdk 2026.3.29 → 2026.4.7-0

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.
Files changed (36) hide show
  1. package/README.md +24 -31
  2. package/lib/cli/cli.js +18 -2
  3. package/lib/cli/index.d.ts +159 -159
  4. package/lib/config.d.ts +241 -238
  5. package/lib/config.js +4 -2
  6. package/lib/fangorn.d.ts +0 -8
  7. package/lib/fangorn.js +12 -29
  8. package/lib/index.d.ts +3 -3
  9. package/lib/index.js +3 -3
  10. package/lib/modules/gadgets/settledGadget.d.ts +8 -1
  11. package/lib/modules/gadgets/settledGadget.js +13 -1
  12. package/lib/providers/storage/index.d.ts +12 -12
  13. package/lib/providers/storage/index.js +47 -2
  14. package/lib/providers/storage/pinata.d.ts +11 -0
  15. package/lib/providers/storage/pinata.js +24 -0
  16. package/lib/registries/datasource-registry/index.d.ts +4 -3
  17. package/lib/registries/datasource-registry/index.js +14 -2
  18. package/lib/registries/schema-registry/index.d.ts +2 -2
  19. package/lib/registries/settlement-registry/index.d.ts +2 -2
  20. package/lib/roles/consumer/index.d.ts +2 -24
  21. package/lib/roles/consumer/index.js +5 -26
  22. package/lib/roles/publisher/index.d.ts +17 -15
  23. package/lib/roles/publisher/index.js +43 -36
  24. package/lib/roles/publisher/types.d.ts +5 -7
  25. package/lib/roles/schema/index.d.ts +9 -2
  26. package/lib/roles/schema/index.js +35 -2
  27. package/lib/test/testbed.d.ts +3 -2
  28. package/lib/test/testbed.js +12 -8
  29. package/lib/types/index.d.ts +10 -20
  30. package/package.json +1 -1
  31. package/lib/providers/storage/pinata/index.d.ts +0 -13
  32. package/lib/providers/storage/pinata/index.js +0 -41
  33. package/lib/providers/storage/storacha/index.d.ts +0 -13
  34. package/lib/providers/storage/storacha/index.js +0 -49
  35. package/lib/providers/storage/storacha/readOnly.d.ts +0 -8
  36. package/lib/providers/storage/storacha/readOnly.js +0 -16
package/README.md CHANGED
@@ -123,11 +123,11 @@ const fangorn = await Fangorn.create({
123
123
 
124
124
  **Storage options:**
125
125
 
126
- | Config | Mode |
127
- |---|---|
128
- | `{ pinata: { jwt, gateway } }` | Read + write |
129
- | `{ storacha: { email } }` | Read + write |
130
- | `{ storacha: { readOnly: true } }` | Read only |
126
+ | Config | Mode |
127
+ | ---------------------------------- | ------------ |
128
+ | `{ pinata: { jwt, gateway } }` | Read + write |
129
+ | `{ storacha: { email } }` | Read + write |
130
+ | `{ storacha: { readOnly: true } }` | Read only |
131
131
 
132
132
  ### Schemas
133
133
 
@@ -210,22 +210,15 @@ import { SettlementRegistry } from "@fangorn-network/sdk/registries";
210
210
 
211
211
  const owner = fangorn.getAddress();
212
212
 
213
+ // Default gadget = payment settled
213
214
  await fangorn.publisher.upload(
214
215
  {
215
216
  records: [
216
217
  { tag: "track1", field: "audio", data: audioBytes, extension: ".mp3", fileType: "audio/mpeg" },
217
218
  { tag: "track1", field: "cover", data: imageBytes, extension: ".png", fileType: "image/png" },
218
219
  ],
219
- schema: schemaDefinition,
220
- schemaId,
220
+ schemaName: 'schema.name.v1'
221
221
  gateway: "https://your-gateway.mypinata.cloud",
222
- gadgetFactory: (tag) =>
223
- new SettledGadget({
224
- resourceId: SettlementRegistry.deriveResourceId(owner, schemaId, tag),
225
- settlementRegistryAddress: FangornConfig.ArbitrumSepolia.settlementRegistryContractAddress,
226
- chainName: "arbitrumSepolia",
227
- pinataJwt: "...",
228
- }),
229
222
  },
230
223
  1n, // price in smallest USDC units
231
224
  );
@@ -313,8 +306,8 @@ const plaintext = await fangorn.consumer.decrypt({
313
306
 
314
307
  Gadgets define the access control condition baked into encryption. Built-in gadgets:
315
308
 
316
- | Gadget | Condition |
317
- |---|---|
309
+ | Gadget | Condition |
310
+ | --------------- | --------------------------------------------------- |
318
311
  | `SettledGadget` | Caller must complete a USDC payment + ZK claim flow |
319
312
 
320
313
  More coming soon ;)
@@ -327,10 +320,10 @@ See the [gadgets](./src/modules/gadgets/README.md) docs for details on implement
327
320
 
328
321
  ### Arbitrum Sepolia
329
322
 
330
- | Contract | Address |
331
- |---|---|
323
+ | Contract | Address |
324
+ | ------------------- | -------------------------------------------- |
332
325
  | DataSource Registry | `0x3941c7d50caa56f7f676554bc4e78d77aaf27ebb` |
333
- | Schema Registry | `0x49ab3d52b997e63ad56c91178df48263fd80b2dc` |
326
+ | Schema Registry | `0x49ab3d52b997e63ad56c91178df48263fd80b2dc` |
334
327
  | Settlement Registry | `0x4536881306ee355c2f18ae81658771c4488139a3` |
335
328
 
336
329
  ---
@@ -354,19 +347,19 @@ pnpm test:e2e
354
347
 
355
348
  Required variables:
356
349
 
357
- | Variable | Description |
358
- |---|---|
350
+ | Variable | Description |
351
+ | --------------------------- | ----------------------------------------- |
359
352
  | `DELEGATOR_ETH_PRIVATE_KEY` | Publisher private key (needs testnet ETH) |
360
- | `DELEGATEE_ETH_PRIVATE_KEY` | Consumer private key |
361
- | `PINATA_JWT` | Pinata API JWT |
362
- | `PINATA_GATEWAY` | Pinata gateway URL |
363
- | `CHAIN_NAME` | `arbitrumSepolia` |
364
- | `CAIP2` | `421614` |
365
- | `CHAIN_RPC_URL` | RPC endpoint |
366
- | `USDC_CONTRACT_ADDRESS` | USDC contract address |
367
- | `DS_REGISTRY_ADDR` | DataSourceRegistry address |
368
- | `SCHEMA_REGISTRY_ADDR` | SchemaRegistry address |
369
- | `SETTLEMENT_TRACKER_ADDR` | SettlementTracker address |
353
+ | `DELEGATEE_ETH_PRIVATE_KEY` | Consumer private key |
354
+ | `PINATA_JWT` | Pinata API JWT |
355
+ | `PINATA_GATEWAY` | Pinata gateway URL |
356
+ | `CHAIN_NAME` | `arbitrumSepolia` |
357
+ | `CAIP2` | `421614` |
358
+ | `CHAIN_RPC_URL` | RPC endpoint |
359
+ | `USDC_CONTRACT_ADDRESS` | USDC contract address |
360
+ | `DS_REGISTRY_ADDR` | DataSourceRegistry address |
361
+ | `SCHEMA_REGISTRY_ADDR` | SchemaRegistry address |
362
+ | `SETTLEMENT_TRACKER_ADDR` | SettlementTracker address |
370
363
 
371
364
  Sample `.env` for Arbitrum Sepolia:
372
365
 
package/lib/cli/cli.js CHANGED
@@ -173,12 +173,28 @@ program.command("init").description("Configure your Fangorn credentials").action
173
173
  outro(`Config saved to ${CONFIG_PATH}`);
174
174
  });
175
175
  const schemaCmd = program.command("schema").description("Schema registry operations");
176
- schemaCmd.command("register").description("Register an agent identity and/or a schema on-chain").argument("<name>", "Schema / agent name").action(async () => {
176
+ schemaCmd.command("register").description("Register an agent identity and/or a schema on-chain").argument("<name>", "Schema / agent name").option("-e, --skip-erc", "Skip ERC-8004 agent registration").action(async (name, options) => {
177
177
  try {
178
178
  intro("Chain selection");
179
179
  outro(`Selected chain: ${(await selectChain()).name}`);
180
180
  const fangorn = await getFangorn();
181
- const datasourceAgentId = "";
181
+ let datasourceAgentId = "";
182
+ let description = "";
183
+ if (!options.skipErc) {
184
+ intro("ERC-8004 Agent Registration");
185
+ description = await text({ message: "Agent description:" });
186
+ handleCancel(description);
187
+ const s$1 = spinner();
188
+ s$1.start("Registering agent...");
189
+ const { agentId } = await fangorn.schema.registerAgent({
190
+ name,
191
+ description
192
+ });
193
+ s$1.stop();
194
+ datasourceAgentId = agentId;
195
+ note(`Agent ID: ${agentId}`, "ERC-8004 registered");
196
+ outro("Agent Registration complete.");
197
+ }
182
198
  intro("Schema Registration");
183
199
  const schemaFilePath = await text({
184
200
  message: "Path to your JSON schema file:",