@fangorn-network/sdk 2026.7.29 → 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 +313 -31
  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 +22 -14
  13. package/lib/contracts/data-registry/index.js +40 -58
  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 +15 -13
  30. package/lib/engine/index.js +14 -8
  31. package/lib/fangorn.d.ts +45 -8
  32. package/lib/fangorn.js +59 -8
  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 -96
package/lib/fangorn.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { AppConfig } from "./config.js";
2
2
  import { DataRegistryClient, PreparedTx } from "./contracts/data-registry/index.js";
3
+ import { AppRegistryClient } from "./contracts/app-registry/index.js";
4
+ import { SettlementRegistryClient } from "./contracts/settlement-registry/index.js";
5
+ import { SubscriptionRegistryClient } from "./contracts/subscription-registry/index.js";
3
6
  import "./contracts/index.js";
4
7
  import { MetadataStorage } from "./providers/storage/types.js";
5
8
  import { CommitDiff, FangornEngine, MetagraphRegistry, NamespaceContents, NamespaceDiff } from "./engine/index.js";
@@ -8,16 +11,12 @@ import { AppFeed } from "./feed.js";
8
11
  import { Hex, WalletClient } from "viem";
9
12
 
10
13
  //#region src/fangorn.d.ts
11
- /** One namespace-scoped update surfaced by `subscribe`. */
12
14
  interface NamespaceChange extends NamespaceDiff {
13
15
  namespace: string;
14
16
  owner: Hex;
15
- /** The commit CID (string) this update settled to — the new on-chain tip. */
16
17
  commitCid: string;
17
- /** Raw on-chain roots this delta spans (`oldRoot` → `newRoot`). */
18
18
  oldRoot: Hex;
19
19
  newRoot: Hex;
20
- /** Block the `StateCommitted` event landed in — persist as the resume cursor. */
21
20
  blockNumber: bigint;
22
21
  }
23
22
  interface SubscribeOptions {
@@ -40,14 +39,35 @@ declare class Fangorn {
40
39
  private _engine;
41
40
  private readonly _metagraph;
42
41
  private _feed;
43
- /** Insertion order = LRU order; see `readNamespace`. */
42
+ /**
43
+ * The namespace cache
44
+ * Insertion order = LRU order
45
+ */
44
46
  private readonly nsCache;
45
47
  private constructor();
46
48
  get engine(): FangornEngine;
47
49
  get metagraph(): MetagraphRegistry;
50
+ /**
51
+ * Static creation of a new Fangorn client
52
+ *
53
+ * @param options
54
+ * @returns the client
55
+ */
48
56
  static create(options: FangornCreateOptions): Fangorn;
57
+ /**
58
+ * Resets a namespace's onchain state root to zero.
59
+ * TODO: also unpin all data
60
+ * Use at your own risk.
61
+ */
49
62
  reset(namespace: string): Promise<void>;
50
63
  /**
64
+ * TODO: this isn't really needed here, it's cosmetic
65
+ * instead, what if we moved this to a new paradigm where...
66
+ *
67
+ * each app registers as an ERC-8004 agent with the validation registry
68
+ * pointing to these rules essentially?
69
+ *
70
+ *
51
71
  * Register permissive (no required fields) schemas for every tag/relation a
52
72
  * staged graph uses, unless the caller has already registered stricter rules
53
73
  * via `this.metagraph` directly — schema ids are free-form tags by default.
@@ -56,9 +76,8 @@ declare class Fangorn {
56
76
  /** Stage a graph into one commit on top of `base` (engine shapes adapted from CLI shapes). */
57
77
  private createCommit;
58
78
  /**
59
- * Allocates a namespace in the publisher's root map. A no-op (no on-chain tx)
60
- * if the namespace is already initialized, so callers can call this
61
- * unconditionally before every publish.
79
+ * Allocates a namespace in the publisher's root map.
80
+ * A no-op (no on-chain tx) if the namespace is already initialized.
62
81
  */
63
82
  initRepo(repoName: string): Promise<{
64
83
  cid: undefined;
@@ -276,6 +295,24 @@ declare class Fangorn {
276
295
  private toNamespaceChange;
277
296
  getConfig(): AppConfig;
278
297
  getDataRegistry(): DataRegistryClient;
298
+ /**
299
+ * Apps, their publisher terms, and per-app membership.
300
+ *
301
+ * `commitStateRoot` cross-calls this contract, so joining the app here is a
302
+ * precondition for publishing under it — `registerForApp()` before
303
+ * `commit()`, or the commit reverts `NotRegisteredForApp`.
304
+ */
305
+ getAppRegistry(): AppRegistryClient;
306
+ /**
307
+ * The publisher-side storage paywall. Per-wallet, not per-app: one
308
+ * subscription covers everything this publisher writes, under every app.
309
+ */
310
+ getSubscriptionRegistry(): SubscriptionRegistryClient;
311
+ /**
312
+ * The consumer-side pay-then-read rail. Resources are keyed by owner+uid, so
313
+ * this client is app-agnostic too.
314
+ */
315
+ getSettlementRegistry(): SettlementRegistryClient;
279
316
  /** The app (global namespace) this client publishes and reads under. */
280
317
  getAppId(): Hex;
281
318
  /**
package/lib/fangorn.js CHANGED
@@ -2,7 +2,10 @@ import { DEFAULT_APP, FangornConfig, toAppId } from "./config.js";
2
2
  import { SignedUrlBackend } from "./providers/storage/signed-url.js";
3
3
  import { PinataBackend } from "./providers/storage/pinata.js";
4
4
  import { FangornEngine, MetagraphRegistry, assertValidNamespace, rootHexFromCid } from "./engine/index.js";
5
+ import { AppRegistryClient } from "./contracts/app-registry/index.js";
5
6
  import { DataRegistryClient, subspaceId } from "./contracts/data-registry/index.js";
7
+ import { SettlementRegistryClient } from "./contracts/settlement-registry/index.js";
8
+ import { SubscriptionRegistryClient } from "./contracts/subscription-registry/index.js";
6
9
  import "./contracts/index.js";
7
10
  import { AppFeed } from "./feed.js";
8
11
  import { createPublicClient, createWalletClient, http } from "viem";
@@ -11,9 +14,7 @@ import { CID } from "multiformats/cid";
11
14
 
12
15
  //#region src/fangorn.ts
13
16
  const ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
14
- /** Max namespaces held in `readNamespace`'s tip-keyed cache. */
15
17
  const NS_CACHE_MAX = 256;
16
- /** Build a signer for the access worker's ownership handshake from a wallet. */
17
18
  function walletSigner(walletClient) {
18
19
  const account = walletClient.account;
19
20
  if (!account) throw new Error("Signed-url storage requires a wallet account to sign the access worker's challenge.");
@@ -36,7 +37,10 @@ var Fangorn = class Fangorn {
36
37
  _engine = null;
37
38
  _metagraph = new MetagraphRegistry();
38
39
  _feed = null;
39
- /** Insertion order = LRU order; see `readNamespace`. */
40
+ /**
41
+ * The namespace cache
42
+ * Insertion order = LRU order
43
+ */
40
44
  nsCache = /* @__PURE__ */ new Map();
41
45
  constructor(ctx) {
42
46
  this.ctx = ctx;
@@ -49,6 +53,12 @@ var Fangorn = class Fangorn {
49
53
  get metagraph() {
50
54
  return this._metagraph;
51
55
  }
56
+ /**
57
+ * Static creation of a new Fangorn client
58
+ *
59
+ * @param options
60
+ * @returns the client
61
+ */
52
62
  static create(options) {
53
63
  if (!options.privateKey && !options.walletClient) throw new Error("Either privateKey or walletClient must be provided");
54
64
  const resolvedConfig = options.config ?? FangornConfig;
@@ -60,20 +70,36 @@ var Fangorn = class Fangorn {
60
70
  const metadataStorage = resolveStorage(options.storage, walletClient, resolvedConfig);
61
71
  const domain = options.domain ?? new URL(resolvedConfig.rpcUrl).hostname;
62
72
  const publicClient = createPublicClient({ transport: http(resolvedConfig.rpcUrl) });
73
+ const appId = toAppId(options.appId ?? DEFAULT_APP);
63
74
  return new Fangorn({
64
75
  walletClient,
65
76
  metadataStorage,
66
77
  domain,
67
- dataRegistry: new DataRegistryClient(resolvedConfig.dataRegistryContractAddress, toAppId(options.appId ?? DEFAULT_APP), publicClient, walletClient),
78
+ dataRegistry: new DataRegistryClient(resolvedConfig.dataRegistryContractAddress, appId, publicClient, walletClient),
79
+ appRegistry: new AppRegistryClient(resolvedConfig.appRegistryContractAddress, appId, publicClient, walletClient),
80
+ subscriptionRegistry: new SubscriptionRegistryClient(resolvedConfig.subscriptionRegistryContractAddress, publicClient, walletClient),
81
+ settlementRegistry: new SettlementRegistryClient(resolvedConfig.settlementRegistryContractAddress, publicClient, walletClient),
68
82
  config: resolvedConfig
69
83
  });
70
84
  }
85
+ /**
86
+ * Resets a namespace's onchain state root to zero.
87
+ * TODO: also unpin all data
88
+ * Use at your own risk.
89
+ */
71
90
  async reset(namespace) {
72
91
  const registry = this.getDataRegistry();
73
92
  const currentRoot = await registry.getNamespaceHead(this.getAddress(), namespace);
74
93
  await registry.commitStateRoot(namespace, currentRoot, ZERO_BYTES32);
75
94
  }
76
95
  /**
96
+ * TODO: this isn't really needed here, it's cosmetic
97
+ * instead, what if we moved this to a new paradigm where...
98
+ *
99
+ * each app registers as an ERC-8004 agent with the validation registry
100
+ * pointing to these rules essentially?
101
+ *
102
+ *
77
103
  * Register permissive (no required fields) schemas for every tag/relation a
78
104
  * staged graph uses, unless the caller has already registered stricter rules
79
105
  * via `this.metagraph` directly — schema ids are free-form tags by default.
@@ -122,9 +148,8 @@ var Fangorn = class Fangorn {
122
148
  });
123
149
  }
124
150
  /**
125
- * Allocates a namespace in the publisher's root map. A no-op (no on-chain tx)
126
- * if the namespace is already initialized, so callers can call this
127
- * unconditionally before every publish.
151
+ * Allocates a namespace in the publisher's root map.
152
+ * A no-op (no on-chain tx) if the namespace is already initialized.
128
153
  */
129
154
  async initRepo(repoName) {
130
155
  assertValidNamespace(repoName);
@@ -486,6 +511,30 @@ var Fangorn = class Fangorn {
486
511
  getDataRegistry() {
487
512
  return this.ctx.dataRegistry;
488
513
  }
514
+ /**
515
+ * Apps, their publisher terms, and per-app membership.
516
+ *
517
+ * `commitStateRoot` cross-calls this contract, so joining the app here is a
518
+ * precondition for publishing under it — `registerForApp()` before
519
+ * `commit()`, or the commit reverts `NotRegisteredForApp`.
520
+ */
521
+ getAppRegistry() {
522
+ return this.ctx.appRegistry;
523
+ }
524
+ /**
525
+ * The publisher-side storage paywall. Per-wallet, not per-app: one
526
+ * subscription covers everything this publisher writes, under every app.
527
+ */
528
+ getSubscriptionRegistry() {
529
+ return this.ctx.subscriptionRegistry;
530
+ }
531
+ /**
532
+ * The consumer-side pay-then-read rail. Resources are keyed by owner+uid, so
533
+ * this client is app-agnostic too.
534
+ */
535
+ getSettlementRegistry() {
536
+ return this.ctx.settlementRegistry;
537
+ }
489
538
  /** The app (global namespace) this client publishes and reads under. */
490
539
  getAppId() {
491
540
  return this.ctx.dataRegistry.getAppId();
@@ -501,7 +550,9 @@ var Fangorn = class Fangorn {
501
550
  * from `subscribe`/`subscribeApp` keep their original filter until aborted.
502
551
  */
503
552
  setAppId(nameOrId) {
504
- this.ctx.dataRegistry.setAppId(toAppId(nameOrId));
553
+ const appId = toAppId(nameOrId);
554
+ this.ctx.dataRegistry.setAppId(appId);
555
+ this.ctx.appRegistry.setAppId(appId);
505
556
  this.nsCache.clear();
506
557
  this._feed = null;
507
558
  }
package/lib/index.d.ts CHANGED
@@ -1,8 +1,13 @@
1
1
  import { AppConfig, DEFAULT_APP, FangornConfig, SupportedNetworks, appId, toAppId } from "./config.js";
2
+ import { APP_REGISTRY_ABI } from "./contracts/app-registry/abi.js";
3
+ import { PublisherStatus } from "./contracts/types.js";
4
+ import { CommitFilter, DataRegistryClient, PreparedTx, StateCommittedLog, namespaceKey, subspaceId } from "./contracts/data-registry/index.js";
5
+ import { AppJoinInfo, AppRegistryClient, needsReacceptance } from "./contracts/app-registry/index.js";
2
6
  import { DATA_REGISTRY_ABI } from "./contracts/data-registry/abi.js";
3
- import { CommitFilter, DataRegistryClient, PreparedTx, PublisherStatus, StateCommittedLog, namespaceKey, subspaceId } from "./contracts/data-registry/index.js";
4
- import { SettlementRegistryClient } from "./contracts/settlement-registry/index.js";
7
+ import { Resource, SemaphoreProof, SettlementRegistryClient, TransferAuthorization, packResourceUri, resourceIdOf } from "./contracts/settlement-registry/index.js";
5
8
  import { SETTLEMENT_REGISTRY_ABI } from "./contracts/settlement-registry/abi.js";
9
+ import { SubscriptionAccess, SubscriptionRegistryClient } from "./contracts/subscription-registry/index.js";
10
+ import { SUBSCRIPTION_REGISTRY_ABI } from "./contracts/subscription-registry/abi.js";
6
11
  import "./contracts/index.js";
7
12
  import { AccessRequest, AccessSigner, DecryptHandleParams, EncryptAndUploadParams, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, Gadget, HandleFieldInput, X25519_PUBKEY_LENGTH, accessMessageHash, buildAccessRequest, decryptHandle, encryptAndUpload, seal, sealSelf, sha256Hex, unseal, unsealSelf } from "./crypto/encryption.js";
8
13
  import { FangornContext, FangornCreateOptions, StorageConfig } from "./types/index.js";
@@ -12,4 +17,4 @@ import { AssetProcessor, BuildAssetGraphOptions, CommitFileGraph, Edge, FileFaca
12
17
  import { PinataBackend } from "./providers/storage/pinata.js";
13
18
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend, SignedUrlSigner } from "./providers/storage/signed-url.js";
14
19
  import { MAX_UPLOAD_ATTEMPTS, deserialize, fetchRawByCid, isTransientUpload, retrieveByCid, serialize, withUploadRetry } from "./providers/storage/utils.js";
15
- export { AccessRequest, AccessSigner, AppConfig, AppFeed, AssetProcessor, BuildAssetGraphOptions, CommitFileGraph, CommitFilter, DATA_REGISTRY_ABI, DEFAULT_APP, DEFAULT_SIGNED_URL_WORKER, DataRegistryClient, DecryptHandleParams, Edge, EncryptAndUploadParams, Fangorn, FangornConfig, FangornContext, FangornCreateOptions, FileFacade, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, Gadget, HandleFieldInput, MAX_UPLOAD_ATTEMPTS, NamespaceChange, PinataBackend, PreparedTx, ProcessorResult, PublisherStatus, SETTLEMENT_REGISTRY_ABI, SettlementRegistryClient, SignedUrlBackend, SignedUrlSigner, StateCommittedLog, StorageConfig, SubscribeOptions, SupportedNetworks, Vertex, X25519_PUBKEY_LENGTH, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, decryptHandle, deserialize, encryptAndUpload, extractMarkdownLinks, fetchRawByCid, isTransientUpload, namespaceKey, retrieveByCid, seal, sealSelf, serialize, sha256Hex, subspaceId, toAppId, unseal, unsealSelf, withUploadRetry };
20
+ export { APP_REGISTRY_ABI, AccessRequest, AccessSigner, AppConfig, AppFeed, AppJoinInfo, AppRegistryClient, AssetProcessor, BuildAssetGraphOptions, CommitFileGraph, CommitFilter, DATA_REGISTRY_ABI, DEFAULT_APP, DEFAULT_SIGNED_URL_WORKER, DataRegistryClient, DecryptHandleParams, Edge, EncryptAndUploadParams, Fangorn, FangornConfig, FangornContext, FangornCreateOptions, FileFacade, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, Gadget, HandleFieldInput, MAX_UPLOAD_ATTEMPTS, NamespaceChange, PinataBackend, PreparedTx, ProcessorResult, PublisherStatus, Resource, SETTLEMENT_REGISTRY_ABI, SUBSCRIPTION_REGISTRY_ABI, SemaphoreProof, SettlementRegistryClient, SignedUrlBackend, SignedUrlSigner, StateCommittedLog, StorageConfig, SubscribeOptions, SubscriptionAccess, SubscriptionRegistryClient, SupportedNetworks, TransferAuthorization, Vertex, X25519_PUBKEY_LENGTH, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, decryptHandle, deserialize, encryptAndUpload, extractMarkdownLinks, fetchRawByCid, isTransientUpload, namespaceKey, needsReacceptance, packResourceUri, resourceIdOf, retrieveByCid, seal, sealSelf, serialize, sha256Hex, subspaceId, toAppId, unseal, unsealSelf, withUploadRetry };
package/lib/index.js CHANGED
@@ -2,14 +2,19 @@ import { DEFAULT_APP, FangornConfig, SupportedNetworks, appId, toAppId } from ".
2
2
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend } from "./providers/storage/signed-url.js";
3
3
  import { MAX_UPLOAD_ATTEMPTS, deserialize, fetchRawByCid, isTransientUpload, retrieveByCid, serialize, withUploadRetry } from "./providers/storage/utils.js";
4
4
  import { PinataBackend } from "./providers/storage/pinata.js";
5
+ import { APP_REGISTRY_ABI } from "./contracts/app-registry/abi.js";
6
+ import { PublisherStatus } from "./contracts/types.js";
7
+ import { AppRegistryClient, needsReacceptance } from "./contracts/app-registry/index.js";
5
8
  import { DATA_REGISTRY_ABI } from "./contracts/data-registry/abi.js";
6
- import { DataRegistryClient, PublisherStatus, namespaceKey, subspaceId } from "./contracts/data-registry/index.js";
9
+ import { DataRegistryClient, namespaceKey, subspaceId } from "./contracts/data-registry/index.js";
7
10
  import { SETTLEMENT_REGISTRY_ABI } from "./contracts/settlement-registry/abi.js";
8
- import { SettlementRegistryClient } from "./contracts/settlement-registry/index.js";
11
+ import { SettlementRegistryClient, packResourceUri, resourceIdOf } from "./contracts/settlement-registry/index.js";
12
+ import { SUBSCRIPTION_REGISTRY_ABI } from "./contracts/subscription-registry/abi.js";
13
+ import { SubscriptionRegistryClient } from "./contracts/subscription-registry/index.js";
9
14
  import "./contracts/index.js";
10
15
  import { AppFeed } from "./feed.js";
11
16
  import { Fangorn } from "./fangorn.js";
12
17
  import { buildAssetGraph, buildMarkdownGraph, extractMarkdownLinks } from "./harness/index.js";
13
18
  import { GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, X25519_PUBKEY_LENGTH, accessMessageHash, buildAccessRequest, decryptHandle, encryptAndUpload, seal, sealSelf, sha256Hex, unseal, unsealSelf } from "./crypto/encryption.js";
14
19
 
15
- export { AppFeed, DATA_REGISTRY_ABI, DEFAULT_APP, DEFAULT_SIGNED_URL_WORKER, DataRegistryClient, Fangorn, FangornConfig, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, MAX_UPLOAD_ATTEMPTS, PinataBackend, PublisherStatus, SETTLEMENT_REGISTRY_ABI, SettlementRegistryClient, SignedUrlBackend, SupportedNetworks, X25519_PUBKEY_LENGTH, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, decryptHandle, deserialize, encryptAndUpload, extractMarkdownLinks, fetchRawByCid, isTransientUpload, namespaceKey, retrieveByCid, seal, sealSelf, serialize, sha256Hex, subspaceId, toAppId, unseal, unsealSelf, withUploadRetry };
20
+ export { APP_REGISTRY_ABI, AppFeed, AppRegistryClient, DATA_REGISTRY_ABI, DEFAULT_APP, DEFAULT_SIGNED_URL_WORKER, DataRegistryClient, Fangorn, FangornConfig, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, MAX_UPLOAD_ATTEMPTS, PinataBackend, PublisherStatus, SETTLEMENT_REGISTRY_ABI, SUBSCRIPTION_REGISTRY_ABI, SettlementRegistryClient, SignedUrlBackend, SubscriptionRegistryClient, SupportedNetworks, X25519_PUBKEY_LENGTH, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, decryptHandle, deserialize, encryptAndUpload, extractMarkdownLinks, fetchRawByCid, isTransientUpload, namespaceKey, needsReacceptance, packResourceUri, resourceIdOf, retrieveByCid, seal, sealSelf, serialize, sha256Hex, subspaceId, toAppId, unseal, unsealSelf, withUploadRetry };
@@ -2,6 +2,7 @@ import { FangornConfig } from "../config.js";
2
2
  import { Fangorn } from "../fangorn.js";
3
3
 
4
4
  //#region src/test/testbed.ts
5
+ const TESTBED_APP_TERMS = "0x0000000000000000000000000000000000000000000000000000000000000002";
5
6
  var TestBed = class TestBed {
6
7
  constructor(f_list) {
7
8
  this.f_list = f_list;
@@ -40,10 +41,15 @@ var TestBed = class TestBed {
40
41
  * else already owns it: apps are shared, not per-test.
41
42
  */
42
43
  async registerApp(index) {
43
- const registry = this.getFangorn(index).getDataRegistry();
44
+ const registry = this.getFangorn(index).getAppRegistry();
44
45
  if (await registry.getAppOwner() === "0x0000000000000000000000000000000000000000") {
45
46
  console.log(`Registering app ${registry.getAppId()} on-chain...`);
46
- await registry.registerApp();
47
+ await registry.registerApp(TESTBED_APP_TERMS, "https://example.test/terms", 0n);
48
+ }
49
+ const self = this.getFangorn(index).getAddress();
50
+ if (!await registry.isRegisteredForApp(self)) {
51
+ console.log(`Joining app ${registry.getAppId()} as ${self}...`);
52
+ await registry.registerForApp();
47
53
  }
48
54
  }
49
55
  async register(index) {
@@ -70,7 +76,7 @@ var TestBed = class TestBed {
70
76
  }
71
77
  /** Owner of the configured app namespace, or the zero address if unclaimed. */
72
78
  async appOwner(index) {
73
- return this.getFangorn(index).getDataRegistry().getAppOwner();
79
+ return this.getFangorn(index).getAppRegistry().getAppOwner();
74
80
  }
75
81
  /** The raw on-chain head of one namespace — the slot the CAS actually guards. */
76
82
  async head(index, namespace) {
@@ -1,5 +1,8 @@
1
1
  import { AppConfig } from "../config.js";
2
2
  import { DataRegistryClient } from "../contracts/data-registry/index.js";
3
+ import { AppRegistryClient } from "../contracts/app-registry/index.js";
4
+ import { SettlementRegistryClient } from "../contracts/settlement-registry/index.js";
5
+ import { SubscriptionRegistryClient } from "../contracts/subscription-registry/index.js";
3
6
  import { MetadataStorage } from "../providers/storage/types.js";
4
7
  import { Hex, WalletClient } from "viem";
5
8
 
@@ -10,6 +13,9 @@ interface FangornContext {
10
13
  metadataStorage: MetadataStorage | undefined;
11
14
  domain: string;
12
15
  dataRegistry: DataRegistryClient;
16
+ appRegistry: AppRegistryClient;
17
+ subscriptionRegistry: SubscriptionRegistryClient;
18
+ settlementRegistry: SettlementRegistryClient;
13
19
  }
14
20
  type StorageConfig = {
15
21
  pinata: {
package/package.json CHANGED
@@ -1,97 +1,73 @@
1
1
  {
2
- "name": "@fangorn-network/sdk",
3
- "version": "2026.07.29",
4
- "description": "Git for knowledge graphs",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/fangorn-network/fangorn.git"
8
- },
9
- "bin": {
10
- "fangorn": "lib/cli/cli.js"
11
- },
12
- "license": "MIT",
13
- "type": "module",
14
- "main": "lib/index.js",
15
- "files": [
16
- "lib/"
17
- ],
18
- "scripts": {
19
- "build": "tsdown",
20
- "format": "prettier . --write",
21
- "lint": "eslint . --max-warnings 0",
22
- "prepare": "husky",
23
- "test": "dotenvx run -f .env -- vitest run",
24
- "test:e2e": "dotenvx run -f .env -- vitest run --config vitest.e2e.config.ts",
25
- "tsc": "tsc",
26
- "deploy": "dotenvx run -f .env -- tsx deploy.ts",
27
- "setup:embeddings": "dotenvx run -f .env -- tsx src/test/setup-embeddings-testdata.ts",
28
- "cleanup:embeddings": "dotenvx run -f .env -- tsx src/test/cleanup-embeddings-testdata.ts",
29
- "prepare:cli": "npm run build",
30
- "fangorn": "dotenvx run -f .env -- node dist/src/cli/cli.js"
31
- },
32
- "lint-staged": {
33
- "*": "prettier --ignore-unknown --write"
34
- },
35
- "devDependencies": {
36
- "@dotenvx/dotenvx": "^1.51.1",
37
- "@eslint/js": "9.39.1",
38
- "@noble/ciphers": "^1.3.0",
39
- "@noble/curves": "^1.2.0",
40
- "@types/node": "24.10.1",
41
- "@vitest/coverage-v8": "4.0.15",
42
- "@vitest/eslint-plugin": "1.5.1",
43
- "eslint": "9.39.1",
44
- "husky": "9.1.7",
45
- "lint-staged": "16.2.7",
46
- "prettier": "3.7.3",
47
- "tsdown": "0.16.8",
48
- "tsx": "^4.21.0",
49
- "typescript": "5.8.3",
50
- "typescript-eslint": "8.48.1",
51
- "vitest": "^4.0.18"
52
- },
53
- "packageManager": "pnpm@10.4.0",
54
- "engines": {
55
- "node": ">=20.19.0"
56
- },
57
- "dependencies": {
58
- "@a2a-js/sdk": "^0.3.10",
59
- "@aztec/bb.js": "^4.3.0",
60
- "@clack/prompts": "^1.0.1",
61
- "@ipld/car": "^5.4.6",
62
- "@ipld/dag-cbor": "^10.0.1",
63
- "@ipld/unixfs": "^3.0.0",
64
- "@noble/ciphers": "^1.3.0",
65
- "@noble/curves": "^1.9.7",
66
- "@noble/hashes": "^2.2.0",
67
- "@noir-lang/noir_js": "1.0.0-beta.22",
68
- "@semaphore-protocol/group": "^4.14.2",
69
- "@semaphore-protocol/identity": "^4.14.2",
70
- "@semaphore-protocol/proof": "^4.14.2",
71
- "agent0-sdk": "^1.5.3",
72
- "commander": "^14.0.3",
73
- "dotenv": "^17.2.3",
74
- "ethers": "^6.16.0",
75
- "multiformats": "^14.0.0",
76
- "pinata": "^2.5.2",
77
- "poseidon-lite": "^0.3.0",
78
- "solc": "^0.8.28",
79
- "stream-json": "^3.4.0",
80
- "uint8arrays": "^6.1.1",
81
- "viem": "^2.47.1"
82
- },
83
- "overrides": {
84
- "viem": "$viem"
85
- },
86
- "pnpm": {
87
- "overrides": {
88
- "write-file-atomic": "7.0.0"
89
- },
90
- "peerDependencyRules": {
91
- "allowedVersions": {
92
- "viem": ">=2.38.3",
93
- "ethers": ">=5.7.2"
94
- }
95
- }
96
- }
97
- }
2
+ "name": "@fangorn-network/sdk",
3
+ "version": "2026.08.18-dev",
4
+ "description": "Git for knowledge graphs",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/fangorn-network/fangorn.git"
8
+ },
9
+ "bin": {
10
+ "fangorn": "lib/cli/cli.js"
11
+ },
12
+ "license": "MIT",
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "files": [
16
+ "lib/"
17
+ ],
18
+ "lint-staged": {
19
+ "*": "prettier --ignore-unknown --write"
20
+ },
21
+ "devDependencies": {
22
+ "@dotenvx/dotenvx": "^1.51.1",
23
+ "@eslint/js": "9.39.1",
24
+ "@noble/ciphers": "^1.3.0",
25
+ "@noble/curves": "^1.2.0",
26
+ "@types/node": "24.10.1",
27
+ "@vitest/coverage-v8": "4.0.15",
28
+ "@vitest/eslint-plugin": "1.5.1",
29
+ "eslint": "9.39.1",
30
+ "husky": "9.1.7",
31
+ "lint-staged": "16.2.7",
32
+ "prettier": "3.7.3",
33
+ "tsdown": "0.16.8",
34
+ "tsx": "^4.21.0",
35
+ "typescript": "5.8.3",
36
+ "typescript-eslint": "8.48.1",
37
+ "vitest": "^4.0.18"
38
+ },
39
+ "engines": {
40
+ "node": ">=20.19.0"
41
+ },
42
+ "dependencies": {
43
+ "@clack/prompts": "^1.0.1",
44
+ "@ipld/car": "^5.4.6",
45
+ "@ipld/dag-cbor": "^10.0.1",
46
+ "@ipld/unixfs": "^3.0.0",
47
+ "@noble/ciphers": "^1.3.0",
48
+ "@noble/curves": "^1.9.7",
49
+ "@noble/hashes": "^2.2.0",
50
+ "commander": "^14.0.3",
51
+ "dotenv": "^17.2.3",
52
+ "multiformats": "^14.0.0",
53
+ "pinata": "^2.5.2",
54
+ "solc": "^0.8.28",
55
+ "viem": "^2.47.1"
56
+ },
57
+ "overrides": {
58
+ "viem": "$viem"
59
+ },
60
+ "scripts": {
61
+ "build": "tsdown",
62
+ "format": "prettier . --write",
63
+ "lint": "eslint . --max-warnings 0",
64
+ "test": "dotenvx run -f .env -- vitest run",
65
+ "test:e2e": "dotenvx run -f .env -- vitest run --config vitest.e2e.config.ts",
66
+ "tsc": "tsc",
67
+ "deploy": "dotenvx run -f .env -- tsx deploy.ts",
68
+ "setup:embeddings": "dotenvx run -f .env -- tsx src/test/setup-embeddings-testdata.ts",
69
+ "cleanup:embeddings": "dotenvx run -f .env -- tsx src/test/cleanup-embeddings-testdata.ts",
70
+ "prepare:cli": "npm run build",
71
+ "fangorn": "dotenvx run -f .env -- node dist/src/cli/cli.js"
72
+ }
73
+ }