@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.
- package/README.md +24 -31
- package/lib/cli/cli.js +18 -2
- package/lib/cli/index.d.ts +159 -159
- package/lib/config.d.ts +241 -238
- package/lib/config.js +4 -2
- package/lib/fangorn.d.ts +0 -8
- package/lib/fangorn.js +12 -29
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -3
- package/lib/modules/gadgets/settledGadget.d.ts +8 -1
- package/lib/modules/gadgets/settledGadget.js +13 -1
- package/lib/providers/storage/index.d.ts +12 -12
- package/lib/providers/storage/index.js +47 -2
- package/lib/providers/storage/pinata.d.ts +11 -0
- package/lib/providers/storage/pinata.js +24 -0
- package/lib/registries/datasource-registry/index.d.ts +4 -3
- package/lib/registries/datasource-registry/index.js +14 -2
- package/lib/registries/schema-registry/index.d.ts +2 -2
- package/lib/registries/settlement-registry/index.d.ts +2 -2
- package/lib/roles/consumer/index.d.ts +2 -24
- package/lib/roles/consumer/index.js +5 -26
- package/lib/roles/publisher/index.d.ts +17 -15
- package/lib/roles/publisher/index.js +43 -36
- package/lib/roles/publisher/types.d.ts +5 -7
- package/lib/roles/schema/index.d.ts +9 -2
- package/lib/roles/schema/index.js +35 -2
- package/lib/test/testbed.d.ts +3 -2
- package/lib/test/testbed.js +12 -8
- package/lib/types/index.d.ts +10 -20
- package/package.json +1 -1
- package/lib/providers/storage/pinata/index.d.ts +0 -13
- package/lib/providers/storage/pinata/index.js +0 -41
- package/lib/providers/storage/storacha/index.d.ts +0 -13
- package/lib/providers/storage/storacha/index.js +0 -49
- package/lib/providers/storage/storacha/readOnly.d.ts +0 -8
- 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
|
|
127
|
-
|
|
128
|
-
| `{ pinata: { jwt, gateway } }`
|
|
129
|
-
| `{ storacha: { email } }`
|
|
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
|
-
|
|
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
|
|
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
|
|
331
|
-
|
|
323
|
+
| Contract | Address |
|
|
324
|
+
| ------------------- | -------------------------------------------- |
|
|
332
325
|
| DataSource Registry | `0x3941c7d50caa56f7f676554bc4e78d77aaf27ebb` |
|
|
333
|
-
| Schema Registry
|
|
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
|
|
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`
|
|
362
|
-
| `PINATA_GATEWAY`
|
|
363
|
-
| `CHAIN_NAME`
|
|
364
|
-
| `CAIP2`
|
|
365
|
-
| `CHAIN_RPC_URL`
|
|
366
|
-
| `USDC_CONTRACT_ADDRESS`
|
|
367
|
-
| `DS_REGISTRY_ADDR`
|
|
368
|
-
| `SCHEMA_REGISTRY_ADDR`
|
|
369
|
-
| `SETTLEMENT_TRACKER_ADDR`
|
|
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
|
-
|
|
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:",
|