@fangorn-network/sdk 2026.8.18-dev → 2026.10.1-9.0-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 (91) hide show
  1. package/README.md +191 -195
  2. package/lib/cli/cli.d.ts +0 -0
  3. package/lib/cli/cli.js +198 -164
  4. package/lib/cli/index.d.ts +3 -91
  5. package/lib/cli/index.js +5 -2
  6. package/lib/config.d.ts +349 -433
  7. package/lib/config.js +41 -28
  8. package/lib/contracts/app-registry/abi.d.ts +1064 -265
  9. package/lib/contracts/app-registry/abi.js +1233 -308
  10. package/lib/contracts/app-registry/index.d.ts +123 -102
  11. package/lib/contracts/app-registry/index.js +200 -198
  12. package/lib/contracts/data-registry/abi.d.ts +166 -187
  13. package/lib/contracts/data-registry/abi.js +207 -237
  14. package/lib/contracts/data-registry/index.d.ts +4 -160
  15. package/lib/contracts/data-registry/index.js +5 -294
  16. package/lib/contracts/index.d.ts +6 -7
  17. package/lib/contracts/index.js +6 -8
  18. package/lib/contracts/logs.d.ts +21 -0
  19. package/lib/contracts/logs.js +32 -0
  20. package/lib/contracts/membership-registry/abi.d.ts +1145 -0
  21. package/lib/contracts/membership-registry/abi.js +1333 -0
  22. package/lib/contracts/membership-registry/index.d.ts +79 -0
  23. package/lib/contracts/membership-registry/index.js +104 -0
  24. package/lib/contracts/types.d.ts +3 -1
  25. package/lib/contracts/types.js +3 -1
  26. package/lib/contracts/write.d.ts +34 -2
  27. package/lib/contracts/write.js +48 -1
  28. package/lib/crypto/encryption.js +4 -4
  29. package/lib/engine/car.d.ts +2 -2
  30. package/lib/engine/car.js +10 -5
  31. package/lib/engine/index.d.ts +99 -143
  32. package/lib/engine/index.js +156 -295
  33. package/lib/engine/records.d.ts +110 -0
  34. package/lib/engine/records.js +165 -0
  35. package/lib/engine/test-helpers.d.ts +7 -14
  36. package/lib/engine/test-helpers.js +7 -18
  37. package/lib/fangorn.d.ts +163 -155
  38. package/lib/fangorn.js +284 -248
  39. package/lib/feed.d.ts +7 -4
  40. package/lib/feed.js +4 -1
  41. package/lib/index.d.ts +9 -9
  42. package/lib/index.js +9 -10
  43. package/lib/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +77 -0
  44. package/lib/node_modules/@vitest/expect/dist/index.js +1414 -0
  45. package/lib/node_modules/@vitest/pretty-format/dist/index.js +858 -0
  46. package/lib/node_modules/@vitest/runner/dist/chunk-tasks.js +51 -0
  47. package/lib/node_modules/@vitest/runner/dist/index.js +1199 -0
  48. package/lib/node_modules/@vitest/runner/dist/utils.js +3 -0
  49. package/lib/node_modules/@vitest/snapshot/dist/index.js +1075 -0
  50. package/lib/node_modules/@vitest/spy/dist/index.js +353 -0
  51. package/lib/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +7 -0
  52. package/lib/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +81 -0
  53. package/lib/node_modules/@vitest/utils/dist/diff.js +1345 -0
  54. package/lib/node_modules/@vitest/utils/dist/display.js +534 -0
  55. package/lib/node_modules/@vitest/utils/dist/error.js +30 -0
  56. package/lib/node_modules/@vitest/utils/dist/helpers.js +118 -0
  57. package/lib/node_modules/@vitest/utils/dist/serialize.js +76 -0
  58. package/lib/node_modules/@vitest/utils/dist/source-map.js +93 -0
  59. package/lib/node_modules/@vitest/utils/dist/timers.js +36 -0
  60. package/lib/node_modules/chai/index.js +2874 -0
  61. package/lib/node_modules/magic-string/dist/magic-string.es.js +939 -0
  62. package/lib/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +81 -0
  63. package/lib/node_modules/tinyrainbow/dist/index.js +85 -0
  64. package/lib/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +5 -0
  65. package/lib/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js +50 -0
  66. package/lib/node_modules/vitest/dist/chunks/utils.DvEY5TfP.js +44 -0
  67. package/lib/node_modules/vitest/dist/chunks/vi.2VT5v0um.js +2578 -0
  68. package/lib/providers/storage/signed-url.d.ts +16 -6
  69. package/lib/providers/storage/signed-url.js +20 -8
  70. package/lib/registry.d.ts +116 -0
  71. package/lib/registry.js +182 -0
  72. package/lib/test/mem-registry.d.ts +51 -0
  73. package/lib/test/mem-registry.js +107 -0
  74. package/lib/test/sdk-suite.d.ts +13 -0
  75. package/lib/test/sdk-suite.js +226 -0
  76. package/lib/test/testbed.d.ts +16411 -61
  77. package/lib/test/testbed.js +190 -84
  78. package/lib/types/index.d.ts +13 -11
  79. package/package.json +89 -72
  80. package/lib/contracts/data-registry/test.d.ts +0 -1
  81. package/lib/contracts/data-registry/test.js +0 -1
  82. package/lib/contracts/settlement-registry/abi.d.ts +0 -466
  83. package/lib/contracts/settlement-registry/abi.js +0 -535
  84. package/lib/contracts/settlement-registry/index.d.ts +0 -163
  85. package/lib/contracts/settlement-registry/index.js +0 -264
  86. package/lib/contracts/subscription-registry/abi.d.ts +0 -179
  87. package/lib/contracts/subscription-registry/abi.js +0 -195
  88. package/lib/contracts/subscription-registry/index.d.ts +0 -59
  89. package/lib/contracts/subscription-registry/index.js +0 -116
  90. package/lib/engine/graph.d.ts +0 -70
  91. package/lib/engine/graph.js +0 -73
package/lib/config.js CHANGED
@@ -4,47 +4,60 @@ import { arbitrumSepolia, baseSepolia } from "viem/chains";
4
4
  //#region src/config.ts
5
5
  /**
6
6
  * Derive an app id from a human-readable name (keccak256(hex(name)).
7
- * Apps are claim one of these on-chain with `AppRegistry.registerApp`
8
7
  */
9
8
  function appId(name) {
10
9
  return keccak256(toHex(name));
11
10
  }
12
- const DEFAULT_APP = "fangorn";
11
+ /**
12
+ * Blank input means "not set", never an app called "". Returns the trimmed value,
13
+ * or undefined when it is missing or only whitespace, so it can sit on the left of
14
+ * a `??` fallback. `??` on the raw value would let "" through: it is not nullish.
15
+ */
16
+ function nonBlank(value) {
17
+ const trimmed = value?.trim();
18
+ return trimmed === "" ? void 0 : trimmed;
19
+ }
13
20
  function toAppId(nameOrId) {
14
- return /^0x[0-9a-fA-F]{64}$/.test(nameOrId) ? nameOrId : appId(nameOrId);
21
+ const name = nameOrId.trim();
22
+ if (!name) throw new Error("App name or id must not be blank.");
23
+ return /^0x[0-9a-fA-F]{64}$/.test(name) ? name : appId(name);
15
24
  }
25
+ const FangornConfig = {
26
+ dataRegistryContractAddress: "0x72B5f83526F3893aF9f1eE0f32A27218EA09f8aE",
27
+ appRegistryContractAddress: "0x55e6209ea1833ceD900989a3b3b22466934E04A5",
28
+ membershipRegistryContractAddress: "0xDF17030Cd65435C86eb043F31DDACa99E819E347",
29
+ appRegistryFromBlock: 319536642n,
30
+ chain: arbitrumSepolia,
31
+ rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
32
+ caip2: 421614,
33
+ ipfsGateway: "https://ipfs.io"
34
+ };
35
+ const BaseSepoliaConfig = {
36
+ dataRegistryContractAddress: "0xE9183f768865dd2Cde5f1B71F8446F0Cd798ebe0",
37
+ appRegistryContractAddress: "0x0D3e98399df41b558048Cdd7D71723c37A3A9D6F",
38
+ membershipRegistryContractAddress: "0x0e96C012b5c53622EcDAA82F342E31C2623A04f5",
39
+ appRegistryFromBlock: 48340483n,
40
+ chain: baseSepolia,
41
+ rpcUrl: "https://sepolia.base.org",
42
+ caip2: 84532,
43
+ ipfsGateway: "https://ipfs.io"
44
+ };
16
45
  /**
17
- * The networks supproted by Fangorn currently
46
+ * The networks supported by Fangorn, by the name `CHAIN_NAME` takes.
18
47
  */
19
48
  const SupportedNetworks = {
20
- ArbitrumSepolia: {
21
- name: "arbitrumSepolia",
22
- chain: arbitrumSepolia
23
- },
24
- BaseSepolia: {
25
- name: "baseSepolia",
26
- chain: baseSepolia
27
- }
49
+ arbitrumSepolia: FangornConfig,
50
+ baseSepolia: BaseSepoliaConfig
28
51
  };
29
52
  /**
30
- * Get the network based on the string name
31
- * @param name "arbitrumSepolia" is the only one supported right now
32
- * @returns The corresponding network if it is supported, otherwise an error
53
+ * Get a network's deployment by name ("arbitrumSepolia" or "baseSepolia").
54
+ * @returns The corresponding config if it is supported, otherwise an error
33
55
  */
34
56
  function getNetwork(name) {
35
- if (name === SupportedNetworks.ArbitrumSepolia.name) return arbitrumSepolia;
36
- throw new Error(`Chain ${name} is not supported`);
57
+ const config = SupportedNetworks[name];
58
+ if (!config) throw new Error(`Chain ${name} is not supported. Use one of: ${Object.keys(SupportedNetworks).join(", ")}`);
59
+ return config;
37
60
  }
38
- const FangornConfig = {
39
- dataRegistryContractAddress: "0x97d63259bd91e386322c12fa7e923e5e1c0ddf91",
40
- appRegistryContractAddress: "0xeb1309d4607ffbe2051d296de72d3ca4d2795731",
41
- subscriptionRegistryContractAddress: "0x81681e4f89a24cb46112480f63404fdc35ee4cec",
42
- settlementRegistryContractAddress: "0x480d54411d77820701fd80f42b81fb6e20176d12",
43
- chain: arbitrumSepolia,
44
- rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
45
- caip2: 421614,
46
- ipfsGateway: "https://ipfs.io"
47
- };
48
61
 
49
62
  //#endregion
50
- export { DEFAULT_APP, FangornConfig, SupportedNetworks, appId, getNetwork as default, toAppId };
63
+ export { BaseSepoliaConfig, FangornConfig, SupportedNetworks, appId, getNetwork as default, nonBlank, toAppId };