@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,4 +1,5 @@
1
1
  import { DS_REGISTRY_ABI } from "./abi.js";
2
+ import { encodePacked, keccak256 } from "viem";
2
3
 
3
4
  //#region src/registries/datasource-registry/index.ts
4
5
  var DataSourceRegistry = class {
@@ -21,66 +22,129 @@ var DataSourceRegistry = class {
21
22
  getContractAddress() {
22
23
  return this.contractAddress;
23
24
  }
24
- async initialize(schemaRegistryAddress) {
25
- const { chain, account } = this.getWriteConfig();
26
- const hash = await this.walletClient.writeContract({
27
- address: this.contractAddress,
28
- abi: DS_REGISTRY_ABI,
29
- functionName: "initialize",
30
- args: [schemaRegistryAddress],
31
- chain,
32
- account
33
- });
34
- await this.waitForTransaction(hash);
35
- return hash;
36
- }
37
- async publishManifest(manifestCid, schemaId, gas) {
25
+ async publish(manifestCid, schemaId, name, price, gas) {
38
26
  const { chain, account } = this.getWriteConfig();
39
27
  const gasLimit = await this.estimateGas(() => this.publicClient.estimateContractGas({
40
28
  address: this.contractAddress,
41
29
  abi: DS_REGISTRY_ABI,
42
- functionName: "publishManifest",
43
- args: [manifestCid, schemaId],
30
+ functionName: "publish",
31
+ args: [
32
+ manifestCid,
33
+ schemaId,
34
+ name,
35
+ price
36
+ ],
44
37
  account
45
38
  }), gas);
39
+ const fees = await this.publicClient.estimateFeesPerGas();
46
40
  const hash = await this.walletClient.writeContract({
47
41
  address: this.contractAddress,
48
42
  abi: DS_REGISTRY_ABI,
49
- functionName: "publishManifest",
50
- args: [manifestCid, schemaId],
43
+ functionName: "publish",
44
+ args: [
45
+ manifestCid,
46
+ schemaId,
47
+ name,
48
+ price
49
+ ],
51
50
  chain,
52
51
  account,
53
- gas: gasLimit
52
+ gas: gasLimit,
53
+ maxFeePerGas: fees.maxFeePerGas * 3n,
54
+ maxPriorityFeePerGas: fees.maxPriorityFeePerGas
54
55
  });
55
56
  await this.waitForTransaction(hash);
56
57
  return hash;
57
58
  }
58
- async getManifest(owner, schemaId) {
59
+ async get(owner, schemaId, name) {
59
60
  const [manifestCid, version] = await Promise.all([this.publicClient.readContract({
60
61
  address: this.contractAddress,
61
62
  abi: DS_REGISTRY_ABI,
62
- functionName: "getManifest",
63
- args: [owner, schemaId]
63
+ functionName: "get",
64
+ args: [
65
+ owner,
66
+ schemaId,
67
+ name
68
+ ]
64
69
  }), this.publicClient.readContract({
65
70
  address: this.contractAddress,
66
71
  abi: DS_REGISTRY_ABI,
67
72
  functionName: "getVersion",
68
- args: [owner, schemaId]
73
+ args: [
74
+ owner,
75
+ schemaId,
76
+ name
77
+ ]
69
78
  })]);
70
79
  return {
71
80
  manifestCid,
81
+ name,
72
82
  schemaId,
73
83
  version
74
84
  };
75
85
  }
76
- async getVersion(owner, schemaId) {
86
+ async getByHash(owner, schemaId, nameHash) {
87
+ return this.publicClient.readContract({
88
+ address: this.contractAddress,
89
+ abi: DS_REGISTRY_ABI,
90
+ functionName: "getByHash",
91
+ args: [
92
+ owner,
93
+ schemaId,
94
+ nameHash
95
+ ]
96
+ });
97
+ }
98
+ async getName(owner, schemaId, nameHash) {
99
+ return this.publicClient.readContract({
100
+ address: this.contractAddress,
101
+ abi: DS_REGISTRY_ABI,
102
+ functionName: "getName",
103
+ args: [
104
+ owner,
105
+ schemaId,
106
+ nameHash
107
+ ]
108
+ });
109
+ }
110
+ async getVersion(owner, schemaId, name) {
77
111
  return this.publicClient.readContract({
78
112
  address: this.contractAddress,
79
113
  abi: DS_REGISTRY_ABI,
80
114
  functionName: "getVersion",
81
- args: [owner, schemaId]
115
+ args: [
116
+ owner,
117
+ schemaId,
118
+ name
119
+ ]
120
+ });
121
+ }
122
+ async resourceId(owner, schemaId, name) {
123
+ return this.publicClient.readContract({
124
+ address: this.contractAddress,
125
+ abi: DS_REGISTRY_ABI,
126
+ functionName: "resourceId",
127
+ args: [
128
+ owner,
129
+ schemaId,
130
+ name
131
+ ]
82
132
  });
83
133
  }
134
+ static resourceIdLocal(owner, schemaId, name) {
135
+ return keccak256(encodePacked([
136
+ "address",
137
+ "bytes32",
138
+ "bytes32"
139
+ ], [
140
+ owner,
141
+ schemaId,
142
+ keccak256(new TextEncoder().encode(name))
143
+ ]));
144
+ }
145
+ hashName(name) {
146
+ return keccak256(new TextEncoder().encode(name));
147
+ }
84
148
  async waitForTransaction(hash) {
85
149
  return this.publicClient.waitForTransactionReceipt({ hash });
86
150
  }
@@ -1,4 +1,4 @@
1
- import { SETTLEMENT_REGISTRY_ABI } from "./settlement-registry/abi.js";
2
1
  import { DS_REGISTRY_ABI } from "./datasource-registry/abi.js";
2
+ import { SETTLEMENT_REGISTRY_ABI } from "./settlement-registry/abi.js";
3
3
 
4
4
  export { DS_REGISTRY_ABI, SETTLEMENT_REGISTRY_ABI };
@@ -1,127 +1,218 @@
1
1
  //#region src/registries/schema-registry/abi.d.ts
2
2
  declare const SCHEMA_REGISTRY_ABI: readonly [{
3
- readonly name: "schemaId";
4
- readonly type: "function";
5
- readonly stateMutability: "view";
3
+ readonly inputs: readonly [];
4
+ readonly name: "NotDataSourceRegistry";
5
+ readonly type: "error";
6
+ }, {
7
+ readonly inputs: readonly [];
8
+ readonly name: "NotOwner";
9
+ readonly type: "error";
10
+ }, {
11
+ readonly inputs: readonly [];
12
+ readonly name: "SchemaAlreadyExists";
13
+ readonly type: "error";
14
+ }, {
15
+ readonly inputs: readonly [];
16
+ readonly name: "SchemaInUse";
17
+ readonly type: "error";
18
+ }, {
19
+ readonly inputs: readonly [];
20
+ readonly name: "SchemaNotFound";
21
+ readonly type: "error";
22
+ }, {
6
23
  readonly inputs: readonly [{
7
- readonly type: "string";
8
- readonly name: "name";
9
- }];
10
- readonly outputs: readonly [{
24
+ readonly internalType: "bytes32";
25
+ readonly name: "schema_id";
11
26
  readonly type: "bytes32";
27
+ }, {
28
+ readonly internalType: "address";
29
+ readonly name: "publisher";
30
+ readonly type: "address";
12
31
  }];
13
- }, {
14
- readonly name: "registerSchema";
32
+ readonly name: "addPublisher";
33
+ readonly outputs: readonly [];
34
+ readonly stateMutability: "nonpayable";
15
35
  readonly type: "function";
36
+ }, {
37
+ readonly inputs: readonly [{
38
+ readonly internalType: "bytes32";
39
+ readonly name: "id";
40
+ readonly type: "bytes32";
41
+ }];
42
+ readonly name: "deleteSchema";
43
+ readonly outputs: readonly [];
16
44
  readonly stateMutability: "nonpayable";
45
+ readonly type: "function";
46
+ }, {
17
47
  readonly inputs: readonly [{
18
- readonly type: "string";
19
- readonly name: "name";
20
- }, {
21
- readonly type: "string";
22
- readonly name: "spec_cid";
23
- }, {
24
- readonly type: "string";
25
- readonly name: "agent_id";
48
+ readonly internalType: "bytes32";
49
+ readonly name: "schema_id";
50
+ readonly type: "bytes32";
26
51
  }];
52
+ readonly name: "getPublisherCount";
27
53
  readonly outputs: readonly [{
28
- readonly type: "bytes32";
54
+ readonly internalType: "uint256";
55
+ readonly name: "";
56
+ readonly type: "uint256";
29
57
  }];
30
- }, {
31
- readonly name: "updateSchema";
58
+ readonly stateMutability: "view";
32
59
  readonly type: "function";
33
- readonly stateMutability: "nonpayable";
60
+ }, {
34
61
  readonly inputs: readonly [{
35
- readonly type: "bytes32";
62
+ readonly internalType: "bytes32";
36
63
  readonly name: "id";
37
- }, {
38
- readonly type: "string";
39
- readonly name: "new_spec_cid";
40
- }, {
64
+ readonly type: "bytes32";
65
+ }];
66
+ readonly name: "getSchemaAgent";
67
+ readonly outputs: readonly [{
68
+ readonly internalType: "string";
69
+ readonly name: "";
41
70
  readonly type: "string";
42
- readonly name: "new_agent_id";
43
71
  }];
44
- readonly outputs: readonly [];
45
- }, {
46
- readonly name: "getSchemaSpec";
47
- readonly type: "function";
48
72
  readonly stateMutability: "view";
73
+ readonly type: "function";
74
+ }, {
49
75
  readonly inputs: readonly [{
50
- readonly type: "bytes32";
76
+ readonly internalType: "bytes32";
51
77
  readonly name: "id";
78
+ readonly type: "bytes32";
52
79
  }];
80
+ readonly name: "getSchemaName";
53
81
  readonly outputs: readonly [{
82
+ readonly internalType: "string";
83
+ readonly name: "";
54
84
  readonly type: "string";
55
85
  }];
56
- }, {
57
- readonly name: "getSchemaAgent";
58
- readonly type: "function";
59
86
  readonly stateMutability: "view";
87
+ readonly type: "function";
88
+ }, {
60
89
  readonly inputs: readonly [{
90
+ readonly internalType: "bytes32";
91
+ readonly name: "id";
61
92
  readonly type: "bytes32";
93
+ }];
94
+ readonly name: "getSchemaOwner";
95
+ readonly outputs: readonly [{
96
+ readonly internalType: "address";
97
+ readonly name: "";
98
+ readonly type: "address";
99
+ }];
100
+ readonly stateMutability: "view";
101
+ readonly type: "function";
102
+ }, {
103
+ readonly inputs: readonly [{
104
+ readonly internalType: "bytes32";
62
105
  readonly name: "id";
106
+ readonly type: "bytes32";
63
107
  }];
108
+ readonly name: "getSchemaSpec";
64
109
  readonly outputs: readonly [{
110
+ readonly internalType: "string";
111
+ readonly name: "";
65
112
  readonly type: "string";
66
113
  }];
67
- }, {
68
- readonly name: "schemaExists";
69
- readonly type: "function";
70
114
  readonly stateMutability: "view";
115
+ readonly type: "function";
116
+ }, {
71
117
  readonly inputs: readonly [{
118
+ readonly internalType: "bytes32";
119
+ readonly name: "schema_id";
72
120
  readonly type: "bytes32";
73
- readonly name: "id";
74
121
  }];
122
+ readonly name: "hasPublishers";
75
123
  readonly outputs: readonly [{
124
+ readonly internalType: "bool";
125
+ readonly name: "";
76
126
  readonly type: "bool";
77
127
  }];
128
+ readonly stateMutability: "view";
129
+ readonly type: "function";
78
130
  }, {
79
- readonly name: "SchemaRegistered";
80
- readonly type: "event";
81
131
  readonly inputs: readonly [{
132
+ readonly internalType: "bytes32";
133
+ readonly name: "schema_id";
82
134
  readonly type: "bytes32";
83
- readonly name: "id";
84
- readonly indexed: true;
85
135
  }, {
136
+ readonly internalType: "address";
137
+ readonly name: "publisher";
86
138
  readonly type: "address";
87
- readonly name: "owner";
88
- readonly indexed: true;
89
- }, {
90
- readonly type: "string";
139
+ }];
140
+ readonly name: "isPublisher";
141
+ readonly outputs: readonly [{
142
+ readonly internalType: "bool";
143
+ readonly name: "";
144
+ readonly type: "bool";
145
+ }];
146
+ readonly stateMutability: "view";
147
+ readonly type: "function";
148
+ }, {
149
+ readonly inputs: readonly [{
150
+ readonly internalType: "string";
91
151
  readonly name: "name";
92
- }, {
93
152
  readonly type: "string";
94
- readonly name: "spec_cid";
95
153
  }, {
154
+ readonly internalType: "string";
155
+ readonly name: "spec_cid";
96
156
  readonly type: "string";
157
+ }, {
158
+ readonly internalType: "string";
97
159
  readonly name: "agent_id";
160
+ readonly type: "string";
161
+ }];
162
+ readonly name: "registerSchema";
163
+ readonly outputs: readonly [{
164
+ readonly internalType: "bytes32";
165
+ readonly name: "";
166
+ readonly type: "bytes32";
167
+ }];
168
+ readonly stateMutability: "nonpayable";
169
+ readonly type: "function";
170
+ }, {
171
+ readonly inputs: readonly [{
172
+ readonly internalType: "bytes32";
173
+ readonly name: "id";
174
+ readonly type: "bytes32";
175
+ }];
176
+ readonly name: "schemaExists";
177
+ readonly outputs: readonly [{
178
+ readonly internalType: "bool";
179
+ readonly name: "";
180
+ readonly type: "bool";
98
181
  }];
182
+ readonly stateMutability: "view";
183
+ readonly type: "function";
99
184
  }, {
100
- readonly name: "SchemaUpdated";
101
- readonly type: "event";
102
185
  readonly inputs: readonly [{
186
+ readonly internalType: "string";
187
+ readonly name: "name";
188
+ readonly type: "string";
189
+ }];
190
+ readonly name: "schemaId";
191
+ readonly outputs: readonly [{
192
+ readonly internalType: "bytes32";
193
+ readonly name: "";
103
194
  readonly type: "bytes32";
195
+ }];
196
+ readonly stateMutability: "view";
197
+ readonly type: "function";
198
+ }, {
199
+ readonly inputs: readonly [{
200
+ readonly internalType: "bytes32";
104
201
  readonly name: "id";
105
- readonly indexed: true;
202
+ readonly type: "bytes32";
106
203
  }, {
107
- readonly type: "string";
204
+ readonly internalType: "string";
108
205
  readonly name: "new_spec_cid";
109
- }, {
110
206
  readonly type: "string";
207
+ }, {
208
+ readonly internalType: "string";
111
209
  readonly name: "new_agent_id";
210
+ readonly type: "string";
112
211
  }];
113
- }, {
114
- readonly name: "NotOwner";
115
- readonly type: "error";
116
- readonly inputs: readonly [];
117
- }, {
118
- readonly name: "SchemaNotFound";
119
- readonly type: "error";
120
- readonly inputs: readonly [];
121
- }, {
122
- readonly name: "SchemaAlreadyExists";
123
- readonly type: "error";
124
- readonly inputs: readonly [];
212
+ readonly name: "updateSchema";
213
+ readonly outputs: readonly [];
214
+ readonly stateMutability: "nonpayable";
215
+ readonly type: "function";
125
216
  }];
126
217
  //#endregion
127
218
  export { SCHEMA_REGISTRY_ABI };