@fangorn-network/sdk 2026.8.12-dev → 2026.8.18-dev

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 (37) hide show
  1. package/README.md +175 -62
  2. package/lib/cli/cli.d.ts +0 -0
  3. package/lib/cli/cli.js +290 -17
  4. package/lib/config.d.ts +9 -8
  5. package/lib/config.js +6 -8
  6. package/lib/contracts/app-registry/abi.d.ts +466 -0
  7. package/lib/contracts/app-registry/abi.js +529 -0
  8. package/lib/contracts/app-registry/index.d.ts +139 -0
  9. package/lib/contracts/app-registry/index.js +271 -0
  10. package/lib/contracts/data-registry/abi.d.ts +124 -125
  11. package/lib/contracts/data-registry/abi.js +145 -142
  12. package/lib/contracts/data-registry/index.d.ts +16 -14
  13. package/lib/contracts/data-registry/index.js +19 -50
  14. package/lib/contracts/index.d.ts +8 -3
  15. package/lib/contracts/index.js +8 -3
  16. package/lib/contracts/settlement-registry/abi.d.ts +430 -11
  17. package/lib/contracts/settlement-registry/abi.js +528 -41
  18. package/lib/contracts/settlement-registry/index.d.ts +148 -10
  19. package/lib/contracts/settlement-registry/index.js +233 -9
  20. package/lib/contracts/subscription-registry/abi.d.ts +179 -0
  21. package/lib/contracts/subscription-registry/abi.js +195 -0
  22. package/lib/contracts/subscription-registry/index.d.ts +59 -0
  23. package/lib/contracts/subscription-registry/index.js +116 -0
  24. package/lib/contracts/types.d.ts +8 -0
  25. package/lib/contracts/types.js +10 -0
  26. package/lib/contracts/write.d.ts +27 -0
  27. package/lib/contracts/write.js +55 -0
  28. package/lib/crypto/encryption.js +4 -4
  29. package/lib/engine/index.d.ts +14 -12
  30. package/lib/engine/index.js +13 -7
  31. package/lib/fangorn.d.ts +35 -5
  32. package/lib/fangorn.js +49 -6
  33. package/lib/index.d.ts +8 -3
  34. package/lib/index.js +8 -3
  35. package/lib/test/testbed.js +9 -3
  36. package/lib/types/index.d.ts +6 -0
  37. package/package.json +72 -85
@@ -1,16 +1,160 @@
1
1
  //#region src/contracts/settlement-registry/abi.d.ts
2
2
  /**
3
- * The Settlement Registry: the on-chain rail that gates who can read a
4
- * settlement-priced resource. A consumer settles (pays) for a `resourceId`
5
- * out of band; the access worker (and anyone else) then reads `isSettled` to
6
- * decide whether to release the bytes.
3
+ * The SettlementRegistry: the on-chain payment + access rail for a priced resource.
7
4
  *
8
- * This is the exact ABI the deployed access worker calls
9
- * (`webworker/src/index.ts`), kept in lock-step so the SDK and worker agree on
10
- * the settlement check. Read-only here: the pay/settle write path is a separate
11
- * payment rail (x402 / ERC-3009 USDC) and is out of band for the SDK.
5
+ * One resource is one Semaphore group. A consumer `register`s into the group by
6
+ * paying (an EIP-3009 USDC authorization the facilitator relays, so the consumer
7
+ * spends no gas), then `settle`s with a zero-knowledge proof of membership from a
8
+ * fresh stealth address. The two steps are deliberately unlinkable: the address that
9
+ * paid and the address that reads are different, and only the group ties them.
10
+ *
11
+ * `isSettled(stealthAddress, resourceId)` is the question the access worker asks
12
+ * before releasing bytes. `getPrice(resourceId) === 0` means the resource is free.
13
+ *
14
+ * Generated from `cargo stylus export-abi --json`; the events are appended by hand
15
+ * because export-abi does not emit `sol!` event definitions.
12
16
  */
13
17
  declare const SETTLEMENT_REGISTRY_ABI: readonly [{
18
+ readonly inputs: readonly [{
19
+ readonly internalType: "bytes32";
20
+ readonly name: "uid";
21
+ readonly type: "bytes32";
22
+ }, {
23
+ readonly internalType: "uint256";
24
+ readonly name: "price";
25
+ readonly type: "uint256";
26
+ }, {
27
+ readonly internalType: "string";
28
+ readonly name: "uri";
29
+ readonly type: "string";
30
+ }];
31
+ readonly name: "createResource";
32
+ readonly outputs: readonly [{
33
+ readonly internalType: "bytes32";
34
+ readonly name: "";
35
+ readonly type: "bytes32";
36
+ }];
37
+ readonly stateMutability: "nonpayable";
38
+ readonly type: "function";
39
+ }, {
40
+ readonly inputs: readonly [];
41
+ readonly name: "getAdmin";
42
+ readonly outputs: readonly [{
43
+ readonly internalType: "address";
44
+ readonly name: "";
45
+ readonly type: "address";
46
+ }];
47
+ readonly stateMutability: "view";
48
+ readonly type: "function";
49
+ }, {
50
+ readonly inputs: readonly [{
51
+ readonly internalType: "bytes32";
52
+ readonly name: "resource_id";
53
+ readonly type: "bytes32";
54
+ }];
55
+ readonly name: "getGroupId";
56
+ readonly outputs: readonly [{
57
+ readonly internalType: "uint256";
58
+ readonly name: "";
59
+ readonly type: "uint256";
60
+ }];
61
+ readonly stateMutability: "view";
62
+ readonly type: "function";
63
+ }, {
64
+ readonly inputs: readonly [{
65
+ readonly internalType: "bytes32";
66
+ readonly name: "resource_id";
67
+ readonly type: "bytes32";
68
+ }];
69
+ readonly name: "getOwner";
70
+ readonly outputs: readonly [{
71
+ readonly internalType: "address";
72
+ readonly name: "";
73
+ readonly type: "address";
74
+ }];
75
+ readonly stateMutability: "view";
76
+ readonly type: "function";
77
+ }, {
78
+ readonly inputs: readonly [{
79
+ readonly internalType: "bytes32";
80
+ readonly name: "resource_id";
81
+ readonly type: "bytes32";
82
+ }];
83
+ readonly name: "getPrice";
84
+ readonly outputs: readonly [{
85
+ readonly internalType: "uint256";
86
+ readonly name: "";
87
+ readonly type: "uint256";
88
+ }];
89
+ readonly stateMutability: "view";
90
+ readonly type: "function";
91
+ }, {
92
+ readonly inputs: readonly [];
93
+ readonly name: "getSemaphore";
94
+ readonly outputs: readonly [{
95
+ readonly internalType: "address";
96
+ readonly name: "";
97
+ readonly type: "address";
98
+ }];
99
+ readonly stateMutability: "view";
100
+ readonly type: "function";
101
+ }, {
102
+ readonly inputs: readonly [{
103
+ readonly internalType: "bytes32";
104
+ readonly name: "resource_id";
105
+ readonly type: "bytes32";
106
+ }];
107
+ readonly name: "getUri";
108
+ readonly outputs: readonly [{
109
+ readonly internalType: "string";
110
+ readonly name: "";
111
+ readonly type: "string";
112
+ }];
113
+ readonly stateMutability: "view";
114
+ readonly type: "function";
115
+ }, {
116
+ readonly inputs: readonly [];
117
+ readonly name: "getUsdc";
118
+ readonly outputs: readonly [{
119
+ readonly internalType: "address";
120
+ readonly name: "";
121
+ readonly type: "address";
122
+ }];
123
+ readonly stateMutability: "view";
124
+ readonly type: "function";
125
+ }, {
126
+ readonly inputs: readonly [{
127
+ readonly internalType: "bytes32";
128
+ readonly name: "resource_id";
129
+ readonly type: "bytes32";
130
+ }];
131
+ readonly name: "isDisabled";
132
+ readonly outputs: readonly [{
133
+ readonly internalType: "bool";
134
+ readonly name: "";
135
+ readonly type: "bool";
136
+ }];
137
+ readonly stateMutability: "view";
138
+ readonly type: "function";
139
+ }, {
140
+ readonly inputs: readonly [{
141
+ readonly internalType: "bytes32";
142
+ readonly name: "resource_id";
143
+ readonly type: "bytes32";
144
+ }, {
145
+ readonly internalType: "uint256";
146
+ readonly name: "identity_commitment";
147
+ readonly type: "uint256";
148
+ }];
149
+ readonly name: "isRegistered";
150
+ readonly outputs: readonly [{
151
+ readonly internalType: "bool";
152
+ readonly name: "";
153
+ readonly type: "bool";
154
+ }];
155
+ readonly stateMutability: "view";
156
+ readonly type: "function";
157
+ }, {
14
158
  readonly inputs: readonly [{
15
159
  readonly internalType: "address";
16
160
  readonly name: "stealth_address";
@@ -33,15 +177,290 @@ declare const SETTLEMENT_REGISTRY_ABI: readonly [{
33
177
  readonly internalType: "bytes32";
34
178
  readonly name: "resource_id";
35
179
  readonly type: "bytes32";
180
+ }, {
181
+ readonly internalType: "uint256";
182
+ readonly name: "identity_commitment";
183
+ readonly type: "uint256";
184
+ }, {
185
+ readonly internalType: "address";
186
+ readonly name: "from";
187
+ readonly type: "address";
188
+ }, {
189
+ readonly internalType: "uint256";
190
+ readonly name: "amount";
191
+ readonly type: "uint256";
192
+ }, {
193
+ readonly internalType: "uint256";
194
+ readonly name: "valid_after";
195
+ readonly type: "uint256";
196
+ }, {
197
+ readonly internalType: "uint256";
198
+ readonly name: "valid_before";
199
+ readonly type: "uint256";
200
+ }, {
201
+ readonly internalType: "bytes32";
202
+ readonly name: "nonce";
203
+ readonly type: "bytes32";
204
+ }, {
205
+ readonly internalType: "uint8";
206
+ readonly name: "v";
207
+ readonly type: "uint8";
208
+ }, {
209
+ readonly internalType: "bytes32";
210
+ readonly name: "r";
211
+ readonly type: "bytes32";
212
+ }, {
213
+ readonly internalType: "bytes32";
214
+ readonly name: "s";
215
+ readonly type: "bytes32";
36
216
  }];
37
- readonly name: "getPrice";
217
+ readonly name: "register";
218
+ readonly outputs: readonly [];
219
+ readonly stateMutability: "nonpayable";
220
+ readonly type: "function";
221
+ }, {
222
+ readonly inputs: readonly [{
223
+ readonly internalType: "bytes32";
224
+ readonly name: "resource_id";
225
+ readonly type: "bytes32";
226
+ }, {
227
+ readonly internalType: "address";
228
+ readonly name: "hook";
229
+ readonly type: "address";
230
+ }];
231
+ readonly name: "registerHook";
232
+ readonly outputs: readonly [];
233
+ readonly stateMutability: "nonpayable";
234
+ readonly type: "function";
235
+ }, {
236
+ readonly inputs: readonly [{
237
+ readonly internalType: "address";
238
+ readonly name: "publisher";
239
+ readonly type: "address";
240
+ }, {
241
+ readonly internalType: "bytes32";
242
+ readonly name: "uid";
243
+ readonly type: "bytes32";
244
+ }];
245
+ readonly name: "resourceIdFor";
38
246
  readonly outputs: readonly [{
39
- readonly internalType: "uint256";
247
+ readonly internalType: "bytes32";
40
248
  readonly name: "";
41
- readonly type: "uint256";
249
+ readonly type: "bytes32";
42
250
  }];
43
251
  readonly stateMutability: "view";
44
252
  readonly type: "function";
253
+ }, {
254
+ readonly inputs: readonly [{
255
+ readonly internalType: "address";
256
+ readonly name: "new_admin";
257
+ readonly type: "address";
258
+ }];
259
+ readonly name: "setAdmin";
260
+ readonly outputs: readonly [];
261
+ readonly stateMutability: "nonpayable";
262
+ readonly type: "function";
263
+ }, {
264
+ readonly inputs: readonly [{
265
+ readonly internalType: "bytes32";
266
+ readonly name: "resource_id";
267
+ readonly type: "bytes32";
268
+ }, {
269
+ readonly internalType: "bool";
270
+ readonly name: "disabled";
271
+ readonly type: "bool";
272
+ }];
273
+ readonly name: "setDisabled";
274
+ readonly outputs: readonly [];
275
+ readonly stateMutability: "nonpayable";
276
+ readonly type: "function";
277
+ }, {
278
+ readonly inputs: readonly [{
279
+ readonly internalType: "bytes32";
280
+ readonly name: "resource_id";
281
+ readonly type: "bytes32";
282
+ }, {
283
+ readonly internalType: "address";
284
+ readonly name: "stealth_address";
285
+ readonly type: "address";
286
+ }, {
287
+ readonly internalType: "uint256";
288
+ readonly name: "merkle_tree_depth";
289
+ readonly type: "uint256";
290
+ }, {
291
+ readonly internalType: "uint256";
292
+ readonly name: "merkle_tree_root";
293
+ readonly type: "uint256";
294
+ }, {
295
+ readonly internalType: "uint256";
296
+ readonly name: "nullifier";
297
+ readonly type: "uint256";
298
+ }, {
299
+ readonly internalType: "uint256";
300
+ readonly name: "message";
301
+ readonly type: "uint256";
302
+ }, {
303
+ readonly internalType: "uint256[8]";
304
+ readonly name: "points";
305
+ readonly type: "uint256[8]";
306
+ }, {
307
+ readonly internalType: "uint8[]";
308
+ readonly name: "hook_data";
309
+ readonly type: "uint8[]";
310
+ }];
311
+ readonly name: "settle";
312
+ readonly outputs: readonly [];
313
+ readonly stateMutability: "nonpayable";
314
+ readonly type: "function";
315
+ }, {
316
+ readonly inputs: readonly [{
317
+ readonly internalType: "bytes32";
318
+ readonly name: "resource_id";
319
+ readonly type: "bytes32";
320
+ }, {
321
+ readonly internalType: "uint256";
322
+ readonly name: "price";
323
+ readonly type: "uint256";
324
+ }];
325
+ readonly name: "updatePrice";
326
+ readonly outputs: readonly [];
327
+ readonly stateMutability: "nonpayable";
328
+ readonly type: "function";
329
+ }, {
330
+ readonly type: "event";
331
+ readonly name: "ResourceCreated";
332
+ readonly anonymous: false;
333
+ readonly inputs: readonly [{
334
+ readonly type: "bytes32";
335
+ readonly name: "resourceId";
336
+ readonly internalType: "bytes32";
337
+ readonly indexed: true;
338
+ }, {
339
+ readonly type: "address";
340
+ readonly name: "owner";
341
+ readonly internalType: "address";
342
+ readonly indexed: false;
343
+ }, {
344
+ readonly type: "uint256";
345
+ readonly name: "price";
346
+ readonly internalType: "uint256";
347
+ readonly indexed: false;
348
+ }, {
349
+ readonly type: "uint256";
350
+ readonly name: "groupId";
351
+ readonly internalType: "uint256";
352
+ readonly indexed: false;
353
+ }, {
354
+ readonly type: "string";
355
+ readonly name: "uri";
356
+ readonly internalType: "string";
357
+ readonly indexed: false;
358
+ }];
359
+ }, {
360
+ readonly type: "event";
361
+ readonly name: "MemberRegistered";
362
+ readonly anonymous: false;
363
+ readonly inputs: readonly [{
364
+ readonly type: "bytes32";
365
+ readonly name: "resourceId";
366
+ readonly internalType: "bytes32";
367
+ readonly indexed: true;
368
+ }, {
369
+ readonly type: "uint256";
370
+ readonly name: "identityCommitment";
371
+ readonly internalType: "uint256";
372
+ readonly indexed: false;
373
+ }];
374
+ }, {
375
+ readonly type: "event";
376
+ readonly name: "SettlementFinalized";
377
+ readonly anonymous: false;
378
+ readonly inputs: readonly [{
379
+ readonly type: "bytes32";
380
+ readonly name: "resourceId";
381
+ readonly internalType: "bytes32";
382
+ readonly indexed: true;
383
+ }, {
384
+ readonly type: "uint256";
385
+ readonly name: "nullifierHash";
386
+ readonly internalType: "uint256";
387
+ readonly indexed: true;
388
+ }, {
389
+ readonly type: "uint256";
390
+ readonly name: "message";
391
+ readonly internalType: "uint256";
392
+ readonly indexed: false;
393
+ }];
394
+ }, {
395
+ readonly type: "event";
396
+ readonly name: "PriceUpdated";
397
+ readonly anonymous: false;
398
+ readonly inputs: readonly [{
399
+ readonly type: "bytes32";
400
+ readonly name: "resourceId";
401
+ readonly internalType: "bytes32";
402
+ readonly indexed: true;
403
+ }, {
404
+ readonly type: "address";
405
+ readonly name: "owner";
406
+ readonly internalType: "address";
407
+ readonly indexed: false;
408
+ }, {
409
+ readonly type: "uint256";
410
+ readonly name: "price";
411
+ readonly internalType: "uint256";
412
+ readonly indexed: false;
413
+ }];
414
+ }, {
415
+ readonly type: "event";
416
+ readonly name: "ResourceDisabled";
417
+ readonly anonymous: false;
418
+ readonly inputs: readonly [{
419
+ readonly type: "bytes32";
420
+ readonly name: "resourceId";
421
+ readonly internalType: "bytes32";
422
+ readonly indexed: true;
423
+ }, {
424
+ readonly type: "bool";
425
+ readonly name: "disabled";
426
+ readonly internalType: "bool";
427
+ readonly indexed: false;
428
+ }, {
429
+ readonly type: "address";
430
+ readonly name: "by";
431
+ readonly internalType: "address";
432
+ readonly indexed: false;
433
+ }];
434
+ }, {
435
+ readonly type: "event";
436
+ readonly name: "HookRegistered";
437
+ readonly anonymous: false;
438
+ readonly inputs: readonly [{
439
+ readonly type: "bytes32";
440
+ readonly name: "resourceId";
441
+ readonly internalType: "bytes32";
442
+ readonly indexed: true;
443
+ }, {
444
+ readonly type: "address";
445
+ readonly name: "hook";
446
+ readonly internalType: "address";
447
+ readonly indexed: false;
448
+ }];
449
+ }, {
450
+ readonly type: "event";
451
+ readonly name: "AdminChanged";
452
+ readonly anonymous: false;
453
+ readonly inputs: readonly [{
454
+ readonly type: "address";
455
+ readonly name: "previousAdmin";
456
+ readonly internalType: "address";
457
+ readonly indexed: false;
458
+ }, {
459
+ readonly type: "address";
460
+ readonly name: "newAdmin";
461
+ readonly internalType: "address";
462
+ readonly indexed: false;
463
+ }];
45
464
  }];
46
465
  //#endregion
47
466
  export { SETTLEMENT_REGISTRY_ABI };