@fangorn-network/sdk 2026.4.7 → 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.
- package/README.md +30 -26
- package/lib/cli/cli.js +115 -153
- package/lib/cli/index.d.ts +170 -170
- package/lib/config.d.ts +260 -257
- package/lib/config.js +7 -5
- package/lib/fangorn.d.ts +0 -3
- package/lib/fangorn.js +16 -28
- package/lib/index.d.ts +3 -3
- package/lib/index.js +4 -5
- package/lib/modules/encryption/lit.d.ts +0 -1
- package/lib/modules/encryption/lit.js +1 -7
- package/lib/modules/gadgets/settledGadget.d.ts +1 -8
- package/lib/modules/gadgets/settledGadget.js +1 -13
- package/lib/providers/storage/index.d.ts +12 -12
- package/lib/providers/storage/index.js +49 -2
- package/lib/providers/storage/pinata.d.ts +11 -0
- package/lib/providers/storage/pinata.js +24 -0
- package/lib/registries/datasource-registry/abi.d.ts +116 -43
- package/lib/registries/datasource-registry/abi.js +190 -12
- package/lib/registries/datasource-registry/index.d.ts +12 -6
- package/lib/registries/datasource-registry/index.js +96 -20
- package/lib/registries/index.js +1 -1
- package/lib/registries/schema-registry/abi.d.ts +157 -66
- package/lib/registries/schema-registry/abi.js +242 -15
- package/lib/registries/schema-registry/index.d.ts +8 -3
- package/lib/registries/schema-registry/index.js +82 -17
- package/lib/registries/settlement-registry/abi.d.ts +199 -145
- package/lib/registries/settlement-registry/abi.js +331 -25
- package/lib/registries/settlement-registry/index.d.ts +36 -39
- package/lib/registries/settlement-registry/index.js +125 -91
- package/lib/registries/settlement-registry/types.d.ts +6 -3
- package/lib/roles/consumer/index.d.ts +8 -29
- package/lib/roles/consumer/index.js +25 -45
- package/lib/roles/consumer/types.d.ts +4 -4
- package/lib/roles/publisher/index.d.ts +26 -29
- package/lib/roles/publisher/index.js +70 -77
- package/lib/roles/publisher/types.d.ts +7 -3
- package/lib/roles/schema/index.d.ts +3 -8
- package/lib/roles/schema/index.js +6 -34
- package/lib/test/testbed.d.ts +7 -32
- package/lib/test/testbed.js +22 -45
- package/lib/types/index.d.ts +10 -20
- package/package.json +1 -1
- package/lib/providers/storage/pinata/index.d.ts +0 -13
- package/lib/providers/storage/pinata/index.js +0 -41
- package/lib/providers/storage/storacha/index.d.ts +0 -13
- package/lib/providers/storage/storacha/index.js +0 -49
- package/lib/providers/storage/storacha/readOnly.d.ts +0 -8
- package/lib/providers/storage/storacha/readOnly.js +0 -16
|
@@ -1,19 +1,246 @@
|
|
|
1
|
-
import { parseAbi } from "viem";
|
|
2
|
-
|
|
3
1
|
//#region src/registries/schema-registry/abi.ts
|
|
4
|
-
const SCHEMA_REGISTRY_ABI =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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([
|
|
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: "
|
|
135
|
+
functionName: "schemaExists",
|
|
79
136
|
args: [id]
|
|
80
|
-
})
|
|
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: "
|
|
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
|
|
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: "
|
|
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
|
}
|