@fangorn-network/sdk 2026.4.7-0 → 2026.4.10

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 (39) hide show
  1. package/README.md +30 -26
  2. package/lib/cli/cli.js +115 -153
  3. package/lib/config.d.ts +241 -241
  4. package/lib/config.js +3 -3
  5. package/lib/fangorn.d.ts +5 -0
  6. package/lib/fangorn.js +13 -8
  7. package/lib/index.js +1 -2
  8. package/lib/modules/encryption/lit.d.ts +0 -1
  9. package/lib/modules/encryption/lit.js +1 -7
  10. package/lib/modules/gadgets/settledGadget.d.ts +1 -8
  11. package/lib/modules/gadgets/settledGadget.js +1 -13
  12. package/lib/providers/storage/index.d.ts +1 -1
  13. package/lib/providers/storage/index.js +3 -1
  14. package/lib/providers/storage/pinata.js +1 -1
  15. package/lib/registries/datasource-registry/abi.d.ts +116 -43
  16. package/lib/registries/datasource-registry/abi.js +190 -12
  17. package/lib/registries/datasource-registry/index.d.ts +11 -6
  18. package/lib/registries/datasource-registry/index.js +89 -25
  19. package/lib/registries/index.js +1 -1
  20. package/lib/registries/schema-registry/abi.d.ts +157 -66
  21. package/lib/registries/schema-registry/abi.js +242 -15
  22. package/lib/registries/schema-registry/index.d.ts +8 -3
  23. package/lib/registries/schema-registry/index.js +82 -17
  24. package/lib/registries/settlement-registry/abi.d.ts +199 -145
  25. package/lib/registries/settlement-registry/abi.js +331 -25
  26. package/lib/registries/settlement-registry/index.d.ts +35 -38
  27. package/lib/registries/settlement-registry/index.js +125 -91
  28. package/lib/registries/settlement-registry/types.d.ts +6 -3
  29. package/lib/roles/consumer/index.d.ts +6 -5
  30. package/lib/roles/consumer/index.js +21 -20
  31. package/lib/roles/consumer/types.d.ts +4 -4
  32. package/lib/roles/publisher/index.d.ts +22 -19
  33. package/lib/roles/publisher/index.js +63 -59
  34. package/lib/roles/publisher/types.d.ts +3 -3
  35. package/lib/roles/schema/index.d.ts +1 -7
  36. package/lib/roles/schema/index.js +4 -34
  37. package/lib/test/testbed.d.ts +7 -32
  38. package/lib/test/testbed.js +20 -43
  39. package/package.json +1 -1
@@ -1,19 +1,246 @@
1
- import { parseAbi } from "viem";
2
-
3
1
  //#region src/registries/schema-registry/abi.ts
4
- const SCHEMA_REGISTRY_ABI = parseAbi([
5
- "function schemaId(string calldata name) external view returns (bytes32)",
6
- "function registerSchema(string calldata name, string calldata spec_cid, string calldata agent_id) external returns (bytes32)",
7
- "function updateSchema(bytes32 id, string calldata new_spec_cid, string calldata new_agent_id) external",
8
- "function getSchemaSpec(bytes32 id) external view returns (string memory)",
9
- "function getSchemaAgent(bytes32 id) external view returns (string memory)",
10
- "function schemaExists(bytes32 id) external view returns (bool)",
11
- "event SchemaRegistered(bytes32 indexed id, address indexed owner, string name, string spec_cid, string agent_id)",
12
- "event SchemaUpdated(bytes32 indexed id, string new_spec_cid, string new_agent_id)",
13
- "error NotOwner()",
14
- "error SchemaNotFound()",
15
- "error SchemaAlreadyExists()"
16
- ]);
2
+ const SCHEMA_REGISTRY_ABI = [
3
+ {
4
+ "inputs": [],
5
+ "name": "NotDataSourceRegistry",
6
+ "type": "error"
7
+ },
8
+ {
9
+ "inputs": [],
10
+ "name": "NotOwner",
11
+ "type": "error"
12
+ },
13
+ {
14
+ "inputs": [],
15
+ "name": "SchemaAlreadyExists",
16
+ "type": "error"
17
+ },
18
+ {
19
+ "inputs": [],
20
+ "name": "SchemaInUse",
21
+ "type": "error"
22
+ },
23
+ {
24
+ "inputs": [],
25
+ "name": "SchemaNotFound",
26
+ "type": "error"
27
+ },
28
+ {
29
+ "inputs": [{
30
+ "internalType": "bytes32",
31
+ "name": "schema_id",
32
+ "type": "bytes32"
33
+ }, {
34
+ "internalType": "address",
35
+ "name": "publisher",
36
+ "type": "address"
37
+ }],
38
+ "name": "addPublisher",
39
+ "outputs": [],
40
+ "stateMutability": "nonpayable",
41
+ "type": "function"
42
+ },
43
+ {
44
+ "inputs": [{
45
+ "internalType": "bytes32",
46
+ "name": "id",
47
+ "type": "bytes32"
48
+ }],
49
+ "name": "deleteSchema",
50
+ "outputs": [],
51
+ "stateMutability": "nonpayable",
52
+ "type": "function"
53
+ },
54
+ {
55
+ "inputs": [{
56
+ "internalType": "bytes32",
57
+ "name": "schema_id",
58
+ "type": "bytes32"
59
+ }],
60
+ "name": "getPublisherCount",
61
+ "outputs": [{
62
+ "internalType": "uint256",
63
+ "name": "",
64
+ "type": "uint256"
65
+ }],
66
+ "stateMutability": "view",
67
+ "type": "function"
68
+ },
69
+ {
70
+ "inputs": [{
71
+ "internalType": "bytes32",
72
+ "name": "id",
73
+ "type": "bytes32"
74
+ }],
75
+ "name": "getSchemaAgent",
76
+ "outputs": [{
77
+ "internalType": "string",
78
+ "name": "",
79
+ "type": "string"
80
+ }],
81
+ "stateMutability": "view",
82
+ "type": "function"
83
+ },
84
+ {
85
+ "inputs": [{
86
+ "internalType": "bytes32",
87
+ "name": "id",
88
+ "type": "bytes32"
89
+ }],
90
+ "name": "getSchemaName",
91
+ "outputs": [{
92
+ "internalType": "string",
93
+ "name": "",
94
+ "type": "string"
95
+ }],
96
+ "stateMutability": "view",
97
+ "type": "function"
98
+ },
99
+ {
100
+ "inputs": [{
101
+ "internalType": "bytes32",
102
+ "name": "id",
103
+ "type": "bytes32"
104
+ }],
105
+ "name": "getSchemaOwner",
106
+ "outputs": [{
107
+ "internalType": "address",
108
+ "name": "",
109
+ "type": "address"
110
+ }],
111
+ "stateMutability": "view",
112
+ "type": "function"
113
+ },
114
+ {
115
+ "inputs": [{
116
+ "internalType": "bytes32",
117
+ "name": "id",
118
+ "type": "bytes32"
119
+ }],
120
+ "name": "getSchemaSpec",
121
+ "outputs": [{
122
+ "internalType": "string",
123
+ "name": "",
124
+ "type": "string"
125
+ }],
126
+ "stateMutability": "view",
127
+ "type": "function"
128
+ },
129
+ {
130
+ "inputs": [{
131
+ "internalType": "bytes32",
132
+ "name": "schema_id",
133
+ "type": "bytes32"
134
+ }],
135
+ "name": "hasPublishers",
136
+ "outputs": [{
137
+ "internalType": "bool",
138
+ "name": "",
139
+ "type": "bool"
140
+ }],
141
+ "stateMutability": "view",
142
+ "type": "function"
143
+ },
144
+ {
145
+ "inputs": [{
146
+ "internalType": "bytes32",
147
+ "name": "schema_id",
148
+ "type": "bytes32"
149
+ }, {
150
+ "internalType": "address",
151
+ "name": "publisher",
152
+ "type": "address"
153
+ }],
154
+ "name": "isPublisher",
155
+ "outputs": [{
156
+ "internalType": "bool",
157
+ "name": "",
158
+ "type": "bool"
159
+ }],
160
+ "stateMutability": "view",
161
+ "type": "function"
162
+ },
163
+ {
164
+ "inputs": [
165
+ {
166
+ "internalType": "string",
167
+ "name": "name",
168
+ "type": "string"
169
+ },
170
+ {
171
+ "internalType": "string",
172
+ "name": "spec_cid",
173
+ "type": "string"
174
+ },
175
+ {
176
+ "internalType": "string",
177
+ "name": "agent_id",
178
+ "type": "string"
179
+ }
180
+ ],
181
+ "name": "registerSchema",
182
+ "outputs": [{
183
+ "internalType": "bytes32",
184
+ "name": "",
185
+ "type": "bytes32"
186
+ }],
187
+ "stateMutability": "nonpayable",
188
+ "type": "function"
189
+ },
190
+ {
191
+ "inputs": [{
192
+ "internalType": "bytes32",
193
+ "name": "id",
194
+ "type": "bytes32"
195
+ }],
196
+ "name": "schemaExists",
197
+ "outputs": [{
198
+ "internalType": "bool",
199
+ "name": "",
200
+ "type": "bool"
201
+ }],
202
+ "stateMutability": "view",
203
+ "type": "function"
204
+ },
205
+ {
206
+ "inputs": [{
207
+ "internalType": "string",
208
+ "name": "name",
209
+ "type": "string"
210
+ }],
211
+ "name": "schemaId",
212
+ "outputs": [{
213
+ "internalType": "bytes32",
214
+ "name": "",
215
+ "type": "bytes32"
216
+ }],
217
+ "stateMutability": "view",
218
+ "type": "function"
219
+ },
220
+ {
221
+ "inputs": [
222
+ {
223
+ "internalType": "bytes32",
224
+ "name": "id",
225
+ "type": "bytes32"
226
+ },
227
+ {
228
+ "internalType": "string",
229
+ "name": "new_spec_cid",
230
+ "type": "string"
231
+ },
232
+ {
233
+ "internalType": "string",
234
+ "name": "new_agent_id",
235
+ "type": "string"
236
+ }
237
+ ],
238
+ "name": "updateSchema",
239
+ "outputs": [],
240
+ "stateMutability": "nonpayable",
241
+ "type": "function"
242
+ }
243
+ ];
17
244
 
18
245
  //#endregion
19
246
  export { SCHEMA_REGISTRY_ABI };
@@ -1,11 +1,12 @@
1
- import * as viem0 from "viem";
1
+ import * as viem173 from "viem";
2
2
  import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
3
3
 
4
4
  //#region src/registries/schema-registry/index.d.ts
5
5
  interface Schema {
6
6
  name: string;
7
- cid: string;
7
+ specCid: string;
8
8
  agentId: string;
9
+ owner: Address;
9
10
  }
10
11
  declare class SchemaRegistry {
11
12
  private publicClient;
@@ -20,9 +21,13 @@ declare class SchemaRegistry {
20
21
  schemaId: Hex;
21
22
  }>;
22
23
  updateSchema(nameOrId: string, newSpecCid: string, newAgentId: string): Promise<Hash>;
24
+ deleteSchema(nameOrId: string): Promise<Hash>;
23
25
  getSchema(nameOrId: string): Promise<Schema>;
24
26
  schemaExists(nameOrId: string): Promise<boolean>;
25
- waitForTransaction(hash: Hash): Promise<viem0.TransactionReceipt>;
27
+ hasPublishers(nameOrId: string): Promise<boolean>;
28
+ isPublisher(nameOrId: string, publisher: Address): Promise<boolean>;
29
+ getPublisherCount(nameOrId: string): Promise<bigint>;
30
+ waitForTransaction(hash: Hash): Promise<viem173.TransactionReceipt>;
26
31
  private resolveId;
27
32
  }
28
33
  //#endregion
@@ -1,5 +1,4 @@
1
1
  import { SCHEMA_REGISTRY_ABI } from "./abi.js";
2
- import { parseEventLogs } from "viem";
3
2
 
4
3
  //#region src/registries/schema-registry/index.ts
5
4
  var SchemaRegistry = class {
@@ -32,6 +31,17 @@ var SchemaRegistry = class {
32
31
  }
33
32
  async registerSchema(name, specCid, agentId) {
34
33
  const { chain, account } = this.getWriteConfig();
34
+ const schemaId = await this.publicClient.simulateContract({
35
+ address: this.contractAddress,
36
+ abi: SCHEMA_REGISTRY_ABI,
37
+ functionName: "registerSchema",
38
+ args: [
39
+ name,
40
+ specCid,
41
+ agentId
42
+ ],
43
+ account
44
+ }).then((r) => r.result);
35
45
  const hash = await this.walletClient.writeContract({
36
46
  address: this.contractAddress,
37
47
  abi: SCHEMA_REGISTRY_ABI,
@@ -44,12 +54,10 @@ var SchemaRegistry = class {
44
54
  chain,
45
55
  account
46
56
  });
57
+ await this.waitForTransaction(hash);
47
58
  return {
48
59
  hash,
49
- schemaId: (parseEventLogs({
50
- abi: SCHEMA_REGISTRY_ABI,
51
- logs: (await this.waitForTransaction(hash)).logs
52
- }).find((log) => log.eventName === "SchemaRegistered")?.args).id
60
+ schemaId
53
61
  };
54
62
  }
55
63
  async updateSchema(nameOrId, newSpecCid, newAgentId) {
@@ -70,31 +78,88 @@ var SchemaRegistry = class {
70
78
  await this.waitForTransaction(hash);
71
79
  return hash;
72
80
  }
81
+ async deleteSchema(nameOrId) {
82
+ const { chain, account } = this.getWriteConfig();
83
+ const id = await this.resolveId(nameOrId);
84
+ const hash = await this.walletClient.writeContract({
85
+ address: this.contractAddress,
86
+ abi: SCHEMA_REGISTRY_ABI,
87
+ functionName: "deleteSchema",
88
+ args: [id],
89
+ chain,
90
+ account
91
+ });
92
+ await this.waitForTransaction(hash);
93
+ return hash;
94
+ }
73
95
  async getSchema(nameOrId) {
74
96
  const id = await this.resolveId(nameOrId);
75
- const [specCid, agentId] = await Promise.all([this.publicClient.readContract({
97
+ const [specCid, agentId, name, owner] = await Promise.all([
98
+ this.publicClient.readContract({
99
+ address: this.contractAddress,
100
+ abi: SCHEMA_REGISTRY_ABI,
101
+ functionName: "getSchemaSpec",
102
+ args: [id]
103
+ }),
104
+ this.publicClient.readContract({
105
+ address: this.contractAddress,
106
+ abi: SCHEMA_REGISTRY_ABI,
107
+ functionName: "getSchemaAgent",
108
+ args: [id]
109
+ }),
110
+ this.publicClient.readContract({
111
+ address: this.contractAddress,
112
+ abi: SCHEMA_REGISTRY_ABI,
113
+ functionName: "getSchemaName",
114
+ args: [id]
115
+ }),
116
+ this.publicClient.readContract({
117
+ address: this.contractAddress,
118
+ abi: SCHEMA_REGISTRY_ABI,
119
+ functionName: "getSchemaOwner",
120
+ args: [id]
121
+ })
122
+ ]);
123
+ return {
124
+ name,
125
+ specCid,
126
+ agentId,
127
+ owner
128
+ };
129
+ }
130
+ async schemaExists(nameOrId) {
131
+ const id = await this.resolveId(nameOrId);
132
+ return this.publicClient.readContract({
76
133
  address: this.contractAddress,
77
134
  abi: SCHEMA_REGISTRY_ABI,
78
- functionName: "getSchemaSpec",
135
+ functionName: "schemaExists",
79
136
  args: [id]
80
- }), this.publicClient.readContract({
137
+ });
138
+ }
139
+ async hasPublishers(nameOrId) {
140
+ const id = await this.resolveId(nameOrId);
141
+ return this.publicClient.readContract({
81
142
  address: this.contractAddress,
82
143
  abi: SCHEMA_REGISTRY_ABI,
83
- functionName: "getSchemaAgent",
144
+ functionName: "hasPublishers",
84
145
  args: [id]
85
- })]);
86
- return {
87
- name: typeof nameOrId === "string" ? nameOrId : id,
88
- cid: specCid,
89
- agentId
90
- };
146
+ });
91
147
  }
92
- async schemaExists(nameOrId) {
148
+ async isPublisher(nameOrId, publisher) {
93
149
  const id = await this.resolveId(nameOrId);
94
150
  return this.publicClient.readContract({
95
151
  address: this.contractAddress,
96
152
  abi: SCHEMA_REGISTRY_ABI,
97
- functionName: "schemaExists",
153
+ functionName: "isPublisher",
154
+ args: [id, publisher]
155
+ });
156
+ }
157
+ async getPublisherCount(nameOrId) {
158
+ const id = await this.resolveId(nameOrId);
159
+ return this.publicClient.readContract({
160
+ address: this.contractAddress,
161
+ abi: SCHEMA_REGISTRY_ABI,
162
+ functionName: "getPublisherCount",
98
163
  args: [id]
99
164
  });
100
165
  }