@fangorn-network/sdk 2026.6.16 → 2026.7.1-2.0
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 +210 -266
- package/lib/cli/cli.d.ts +0 -0
- package/lib/cli/cli.js +261 -167
- package/lib/cli/index.d.ts +13 -651
- package/lib/config.d.ts +137 -792
- package/lib/config.js +6 -22
- package/lib/contracts/data-registry/abi.d.ts +38 -0
- package/lib/contracts/data-registry/abi.js +237 -0
- package/lib/contracts/data-registry/index.d.ts +81 -0
- package/lib/contracts/data-registry/index.js +184 -0
- package/lib/contracts/index.d.ts +3 -0
- package/lib/contracts/index.js +4 -0
- package/lib/crypto/aes.d.ts +26 -0
- package/lib/crypto/aes.js +58 -0
- package/lib/crypto/encryption.d.ts +53 -0
- package/lib/crypto/encryption.js +82 -0
- package/lib/{modules/encryption → crypto}/rand.d.ts +1 -1
- package/lib/{modules/encryption → crypto}/rand.js +1 -1
- package/lib/{modules/encryption → crypto}/types.d.ts +1 -1
- package/lib/engine/blockstore.d.ts +24 -0
- package/lib/engine/blockstore.js +85 -0
- package/lib/engine/index.d.ts +180 -0
- package/lib/engine/index.js +367 -0
- package/lib/fangorn.d.ts +149 -16
- package/lib/fangorn.js +256 -37
- package/lib/harness/examples/hackmd/build-markdown-graph.js +17 -0
- package/lib/harness/index.d.ts +57 -0
- package/lib/harness/index.js +67 -0
- package/lib/index.d.ts +2 -2
- package/lib/node_modules/.pnpm/@noble_ciphers@1.3.0/node_modules/@noble/ciphers/esm/_polyval.js +218 -0
- package/lib/node_modules/.pnpm/@noble_ciphers@1.3.0/node_modules/@noble/ciphers/esm/aes.js +261 -0
- package/lib/node_modules/.pnpm/@noble_ciphers@1.3.0/node_modules/@noble/ciphers/esm/utils.js +156 -0
- package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/abstract/curve.js +299 -0
- package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/abstract/edwards.js +532 -0
- package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/abstract/modular.js +344 -0
- package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/abstract/montgomery.js +137 -0
- package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/ed25519.js +262 -0
- package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/utils.js +150 -0
- package/lib/providers/storage/car.d.ts +36 -0
- package/lib/providers/storage/car.js +80 -0
- package/lib/providers/storage/pinata.d.ts +29 -1
- package/lib/providers/storage/pinata.js +135 -20
- package/lib/providers/storage/types.d.ts +25 -18
- package/lib/roles/repo/index.d.ts +56 -0
- package/lib/roles/repo/index.js +73 -0
- package/lib/test/car_smoke.d.ts +1 -0
- package/lib/test/car_smoke.js +81 -0
- package/lib/test/cleanup-embeddings-testdata.js +9 -38
- package/lib/test/setup-embeddings-testdata.d.ts +4 -6
- package/lib/test/setup-embeddings-testdata.js +40 -94
- package/lib/test/testbed.d.ts +35 -32
- package/lib/test/testbed.js +48 -138
- package/lib/types/index.d.ts +3 -19
- package/lib/utils/manifest.d.ts +23 -0
- package/lib/utils/manifest.js +77 -0
- package/package.json +99 -81
- package/lib/modules/encryption/actions.d.ts +0 -4
- package/lib/modules/encryption/actions.js +0 -18
- package/lib/modules/encryption/aes.d.ts +0 -10
- package/lib/modules/encryption/aes.js +0 -51
- package/lib/registries/datasource-registry/abi.d.ts +0 -186
- package/lib/registries/datasource-registry/abi.js +0 -229
- package/lib/registries/datasource-registry/index.d.ts +0 -39
- package/lib/registries/datasource-registry/index.js +0 -158
- package/lib/registries/index.d.ts +0 -3
- package/lib/registries/index.js +0 -4
- package/lib/registries/schema-registry/abi.d.ts +0 -218
- package/lib/registries/schema-registry/abi.js +0 -246
- package/lib/registries/schema-registry/index.d.ts +0 -34
- package/lib/registries/schema-registry/index.js +0 -179
- package/lib/registries/settlement-registry/abi.d.ts +0 -218
- package/lib/registries/settlement-registry/abi.js +0 -259
- package/lib/registries/settlement-registry/index.d.ts +0 -63
- package/lib/registries/settlement-registry/index.js +0 -325
- package/lib/registries/settlement-registry/types.d.ts +0 -54
- package/lib/registries/settlement-registry/types.js +0 -1
- package/lib/roles/consumer/index.d.ts +0 -39
- package/lib/roles/consumer/index.js +0 -150
- package/lib/roles/consumer/types.d.ts +0 -47
- package/lib/roles/consumer/types.js +0 -1
- package/lib/roles/publisher/builders/bundle.d.ts +0 -32
- package/lib/roles/publisher/builders/bundle.js +0 -137
- package/lib/roles/publisher/builders/record-set.d.ts +0 -17
- package/lib/roles/publisher/builders/record-set.js +0 -55
- package/lib/roles/publisher/builders/types.d.ts +0 -38
- package/lib/roles/publisher/builders/types.js +0 -1
- package/lib/roles/publisher/builders/utils.d.ts +0 -9
- package/lib/roles/publisher/builders/utils.js +0 -29
- package/lib/roles/publisher/encryption.d.ts +0 -18
- package/lib/roles/publisher/encryption.js +0 -38
- package/lib/roles/publisher/index.d.ts +0 -68
- package/lib/roles/publisher/index.js +0 -179
- package/lib/roles/publisher/types.d.ts +0 -114
- package/lib/roles/publisher/types.js +0 -1
- package/lib/roles/schema/index.d.ts +0 -44
- package/lib/roles/schema/index.js +0 -127
- package/lib/roles/schema/types.d.ts +0 -113
- package/lib/roles/schema/types.js +0 -1
- package/lib/roles/schema/validate.d.ts +0 -9
- package/lib/roles/schema/validate.js +0 -128
- package/lib/test/publish_mb_bundle.js +0 -296
- /package/lib/{modules/encryption/index.d.ts → contracts/data-registry/test.d.ts} +0 -0
- /package/lib/{modules/encryption/index.js → contracts/data-registry/test.js} +0 -0
- /package/lib/{modules/encryption → crypto}/types.js +0 -0
- /package/lib/{test/publish_mb_bundle.d.ts → harness/examples/hackmd/build-markdown-graph.d.ts} +0 -0
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
//#region src/registries/datasource-registry/abi.ts
|
|
2
|
-
const DS_REGISTRY_ABI = [
|
|
3
|
-
{
|
|
4
|
-
"inputs": [],
|
|
5
|
-
"name": "DataSourceNotFound",
|
|
6
|
-
"type": "error"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"inputs": [],
|
|
10
|
-
"name": "NameRequired",
|
|
11
|
-
"type": "error"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"inputs": [],
|
|
15
|
-
"name": "ResourceSetupFailed",
|
|
16
|
-
"type": "error"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"inputs": [],
|
|
20
|
-
"name": "SchemaNotFound",
|
|
21
|
-
"type": "error"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"inputs": [],
|
|
25
|
-
"name": "SchemaRequired",
|
|
26
|
-
"type": "error"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"inputs": [
|
|
30
|
-
{
|
|
31
|
-
"internalType": "address",
|
|
32
|
-
"name": "owner",
|
|
33
|
-
"type": "address"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"internalType": "bytes32",
|
|
37
|
-
"name": "schema_id",
|
|
38
|
-
"type": "bytes32"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"internalType": "string",
|
|
42
|
-
"name": "name",
|
|
43
|
-
"type": "string"
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
"name": "get",
|
|
47
|
-
"outputs": [{
|
|
48
|
-
"internalType": "string",
|
|
49
|
-
"name": "",
|
|
50
|
-
"type": "string"
|
|
51
|
-
}, {
|
|
52
|
-
"internalType": "bytes32",
|
|
53
|
-
"name": "",
|
|
54
|
-
"type": "bytes32"
|
|
55
|
-
}],
|
|
56
|
-
"stateMutability": "view",
|
|
57
|
-
"type": "function"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"inputs": [
|
|
61
|
-
{
|
|
62
|
-
"internalType": "address",
|
|
63
|
-
"name": "owner",
|
|
64
|
-
"type": "address"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"internalType": "bytes32",
|
|
68
|
-
"name": "schema_id",
|
|
69
|
-
"type": "bytes32"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"internalType": "bytes32",
|
|
73
|
-
"name": "name_hash",
|
|
74
|
-
"type": "bytes32"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
"name": "getByHash",
|
|
78
|
-
"outputs": [{
|
|
79
|
-
"internalType": "string",
|
|
80
|
-
"name": "",
|
|
81
|
-
"type": "string"
|
|
82
|
-
}, {
|
|
83
|
-
"internalType": "bytes32",
|
|
84
|
-
"name": "",
|
|
85
|
-
"type": "bytes32"
|
|
86
|
-
}],
|
|
87
|
-
"stateMutability": "view",
|
|
88
|
-
"type": "function"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"inputs": [
|
|
92
|
-
{
|
|
93
|
-
"internalType": "address",
|
|
94
|
-
"name": "owner",
|
|
95
|
-
"type": "address"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"internalType": "bytes32",
|
|
99
|
-
"name": "schema_id",
|
|
100
|
-
"type": "bytes32"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"internalType": "bytes32",
|
|
104
|
-
"name": "name_hash",
|
|
105
|
-
"type": "bytes32"
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
"name": "getMerkleRoot",
|
|
109
|
-
"outputs": [{
|
|
110
|
-
"internalType": "bytes32",
|
|
111
|
-
"name": "",
|
|
112
|
-
"type": "bytes32"
|
|
113
|
-
}],
|
|
114
|
-
"stateMutability": "view",
|
|
115
|
-
"type": "function"
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"inputs": [
|
|
119
|
-
{
|
|
120
|
-
"internalType": "address",
|
|
121
|
-
"name": "owner",
|
|
122
|
-
"type": "address"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
"internalType": "bytes32",
|
|
126
|
-
"name": "schema_id",
|
|
127
|
-
"type": "bytes32"
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
"internalType": "bytes32",
|
|
131
|
-
"name": "name_hash",
|
|
132
|
-
"type": "bytes32"
|
|
133
|
-
}
|
|
134
|
-
],
|
|
135
|
-
"name": "getName",
|
|
136
|
-
"outputs": [{
|
|
137
|
-
"internalType": "string",
|
|
138
|
-
"name": "",
|
|
139
|
-
"type": "string"
|
|
140
|
-
}],
|
|
141
|
-
"stateMutability": "view",
|
|
142
|
-
"type": "function"
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"inputs": [
|
|
146
|
-
{
|
|
147
|
-
"internalType": "address",
|
|
148
|
-
"name": "owner",
|
|
149
|
-
"type": "address"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"internalType": "bytes32",
|
|
153
|
-
"name": "schema_id",
|
|
154
|
-
"type": "bytes32"
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"internalType": "string",
|
|
158
|
-
"name": "name",
|
|
159
|
-
"type": "string"
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
"name": "getVersion",
|
|
163
|
-
"outputs": [{
|
|
164
|
-
"internalType": "uint64",
|
|
165
|
-
"name": "",
|
|
166
|
-
"type": "uint64"
|
|
167
|
-
}],
|
|
168
|
-
"stateMutability": "view",
|
|
169
|
-
"type": "function"
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"inputs": [
|
|
173
|
-
{
|
|
174
|
-
"internalType": "string",
|
|
175
|
-
"name": "manifest_cid",
|
|
176
|
-
"type": "string"
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
"internalType": "bytes32",
|
|
180
|
-
"name": "merkle_root",
|
|
181
|
-
"type": "bytes32"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"internalType": "bytes32",
|
|
185
|
-
"name": "schema_id",
|
|
186
|
-
"type": "bytes32"
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
"internalType": "string",
|
|
190
|
-
"name": "name",
|
|
191
|
-
"type": "string"
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
"name": "publish",
|
|
195
|
-
"outputs": [],
|
|
196
|
-
"stateMutability": "nonpayable",
|
|
197
|
-
"type": "function"
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
"inputs": [
|
|
201
|
-
{
|
|
202
|
-
"internalType": "address",
|
|
203
|
-
"name": "owner",
|
|
204
|
-
"type": "address"
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
"internalType": "bytes32",
|
|
208
|
-
"name": "schema_id",
|
|
209
|
-
"type": "bytes32"
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
"internalType": "string",
|
|
213
|
-
"name": "name",
|
|
214
|
-
"type": "string"
|
|
215
|
-
}
|
|
216
|
-
],
|
|
217
|
-
"name": "resourceId",
|
|
218
|
-
"outputs": [{
|
|
219
|
-
"internalType": "bytes32",
|
|
220
|
-
"name": "",
|
|
221
|
-
"type": "bytes32"
|
|
222
|
-
}],
|
|
223
|
-
"stateMutability": "view",
|
|
224
|
-
"type": "function"
|
|
225
|
-
}
|
|
226
|
-
];
|
|
227
|
-
|
|
228
|
-
//#endregion
|
|
229
|
-
export { DS_REGISTRY_ABI };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
2
|
-
|
|
3
|
-
//#region src/registries/datasource-registry/index.d.ts
|
|
4
|
-
declare function poseidonHash(inputs: bigint[]): bigint;
|
|
5
|
-
declare function hashString(value: string): bigint;
|
|
6
|
-
interface ManifestLeaf {
|
|
7
|
-
index: bigint;
|
|
8
|
-
name: string;
|
|
9
|
-
}
|
|
10
|
-
declare class MerkleTree {
|
|
11
|
-
protected constructor();
|
|
12
|
-
static leafHash(leaf: ManifestLeaf): bigint;
|
|
13
|
-
static buildTree(leaves: ManifestLeaf[]): {
|
|
14
|
-
root: bigint;
|
|
15
|
-
layers: bigint[][];
|
|
16
|
-
};
|
|
17
|
-
static buildProof(layers: bigint[][], index: number): bigint[];
|
|
18
|
-
static rootToHex(root: bigint): Hex;
|
|
19
|
-
}
|
|
20
|
-
interface DataSource {
|
|
21
|
-
manifestCid: string;
|
|
22
|
-
merkleRoot: Hex;
|
|
23
|
-
name: string;
|
|
24
|
-
schemaId: Hex;
|
|
25
|
-
version: bigint;
|
|
26
|
-
}
|
|
27
|
-
declare class DataSourceRegistry {
|
|
28
|
-
private contractAddress;
|
|
29
|
-
private publicClient;
|
|
30
|
-
private walletClient;
|
|
31
|
-
constructor(contractAddress: Address, publicClient: PublicClient, walletClient: WalletClient);
|
|
32
|
-
private getWriteConfig;
|
|
33
|
-
publish(manifestCid: string, merkleRoot: Hex, schemaId: Hex, name: string): Promise<Hash>;
|
|
34
|
-
get(owner: Address, schemaId: Hex, name: string): Promise<DataSource>;
|
|
35
|
-
static resourceId(owner: Address, schemaId: Hex, name: string): Hex;
|
|
36
|
-
static hashName(name: string): Hex;
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
export { DataSource, DataSourceRegistry, ManifestLeaf, MerkleTree, hashString, poseidonHash };
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { DS_REGISTRY_ABI } from "./abi.js";
|
|
2
|
-
import { encodePacked, keccak256 } from "viem";
|
|
3
|
-
import { poseidon2 } from "poseidon-lite";
|
|
4
|
-
|
|
5
|
-
//#region src/registries/datasource-registry/index.ts
|
|
6
|
-
const MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
7
|
-
function normalize(v) {
|
|
8
|
-
return (v % MODULUS + MODULUS) % MODULUS;
|
|
9
|
-
}
|
|
10
|
-
function poseidonHash(inputs) {
|
|
11
|
-
return poseidon2(inputs.map(normalize));
|
|
12
|
-
}
|
|
13
|
-
function bytesToField(chunk) {
|
|
14
|
-
let acc = 0n;
|
|
15
|
-
for (const b of chunk) acc = acc << 8n | BigInt(b);
|
|
16
|
-
return acc;
|
|
17
|
-
}
|
|
18
|
-
function hashString(value) {
|
|
19
|
-
const bytes = new TextEncoder().encode(value);
|
|
20
|
-
let h = 0n;
|
|
21
|
-
for (let i = 0; i < bytes.length; i += 31) h = poseidonHash([h, bytesToField(bytes.subarray(i, i + 31))]);
|
|
22
|
-
return h;
|
|
23
|
-
}
|
|
24
|
-
var MerkleTree = class MerkleTree {
|
|
25
|
-
constructor() {
|
|
26
|
-
throw new Error("MerkleTree is a static utility class and cannot be instantiated.");
|
|
27
|
-
}
|
|
28
|
-
static leafHash(leaf) {
|
|
29
|
-
return poseidonHash([leaf.index, hashString(leaf.name)]);
|
|
30
|
-
}
|
|
31
|
-
static buildTree(leaves) {
|
|
32
|
-
if (leaves.length === 0) throw new Error("Empty tree");
|
|
33
|
-
let current = [...leaves].sort((a, b) => Number(a.index - b.index)).map((leaf) => MerkleTree.leafHash(leaf));
|
|
34
|
-
const layers = [current];
|
|
35
|
-
while (current.length > 1) {
|
|
36
|
-
const next = [];
|
|
37
|
-
for (let i = 0; i < current.length; i += 2) {
|
|
38
|
-
const left = current[i];
|
|
39
|
-
const right = current[i + 1] ?? left;
|
|
40
|
-
next.push(poseidonHash([left, right]));
|
|
41
|
-
}
|
|
42
|
-
current = next;
|
|
43
|
-
layers.push(next);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
root: current[0],
|
|
47
|
-
layers
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
static buildProof(layers, index) {
|
|
51
|
-
const proof = [];
|
|
52
|
-
for (let d = 0; d < layers.length - 1; d++) {
|
|
53
|
-
const layer = layers[d];
|
|
54
|
-
const sibling = index % 2 === 0 ? layer[index + 1] ?? layer[index] : layer[index - 1];
|
|
55
|
-
proof.push(sibling);
|
|
56
|
-
index = Math.floor(index / 2);
|
|
57
|
-
}
|
|
58
|
-
return proof;
|
|
59
|
-
}
|
|
60
|
-
static rootToHex(root) {
|
|
61
|
-
return `0x${root.toString(16).padStart(64, "0")}`;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var DataSourceRegistry = class {
|
|
65
|
-
constructor(contractAddress, publicClient, walletClient) {
|
|
66
|
-
this.contractAddress = contractAddress;
|
|
67
|
-
this.publicClient = publicClient;
|
|
68
|
-
this.walletClient = walletClient;
|
|
69
|
-
}
|
|
70
|
-
getWriteConfig() {
|
|
71
|
-
if (!this.walletClient.chain) throw new Error("Chain required");
|
|
72
|
-
if (!this.walletClient.account) throw new Error("Account required");
|
|
73
|
-
return {
|
|
74
|
-
chain: this.walletClient.chain,
|
|
75
|
-
account: this.walletClient.account
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
async publish(manifestCid, merkleRoot, schemaId, name) {
|
|
79
|
-
const { chain, account } = this.getWriteConfig();
|
|
80
|
-
const fees = await this.publicClient.estimateFeesPerGas();
|
|
81
|
-
const gas = await this.publicClient.estimateContractGas({
|
|
82
|
-
address: this.contractAddress,
|
|
83
|
-
abi: DS_REGISTRY_ABI,
|
|
84
|
-
functionName: "publish",
|
|
85
|
-
args: [
|
|
86
|
-
manifestCid,
|
|
87
|
-
merkleRoot,
|
|
88
|
-
schemaId,
|
|
89
|
-
name
|
|
90
|
-
],
|
|
91
|
-
account
|
|
92
|
-
});
|
|
93
|
-
const hash = await this.walletClient.writeContract({
|
|
94
|
-
address: this.contractAddress,
|
|
95
|
-
abi: DS_REGISTRY_ABI,
|
|
96
|
-
functionName: "publish",
|
|
97
|
-
args: [
|
|
98
|
-
manifestCid,
|
|
99
|
-
merkleRoot,
|
|
100
|
-
schemaId,
|
|
101
|
-
name
|
|
102
|
-
],
|
|
103
|
-
chain,
|
|
104
|
-
account,
|
|
105
|
-
gas: gas * 130n / 100n,
|
|
106
|
-
maxFeePerGas: fees.maxFeePerGas * 3n,
|
|
107
|
-
maxPriorityFeePerGas: fees.maxPriorityFeePerGas
|
|
108
|
-
});
|
|
109
|
-
await this.publicClient.waitForTransactionReceipt({ hash });
|
|
110
|
-
return hash;
|
|
111
|
-
}
|
|
112
|
-
async get(owner, schemaId, name) {
|
|
113
|
-
const [tuple, version] = await Promise.all([this.publicClient.readContract({
|
|
114
|
-
address: this.contractAddress,
|
|
115
|
-
abi: DS_REGISTRY_ABI,
|
|
116
|
-
functionName: "get",
|
|
117
|
-
args: [
|
|
118
|
-
owner,
|
|
119
|
-
schemaId,
|
|
120
|
-
name
|
|
121
|
-
]
|
|
122
|
-
}), this.publicClient.readContract({
|
|
123
|
-
address: this.contractAddress,
|
|
124
|
-
abi: DS_REGISTRY_ABI,
|
|
125
|
-
functionName: "getVersion",
|
|
126
|
-
args: [
|
|
127
|
-
owner,
|
|
128
|
-
schemaId,
|
|
129
|
-
name
|
|
130
|
-
]
|
|
131
|
-
})]);
|
|
132
|
-
const [manifestCid, merkleRoot] = tuple;
|
|
133
|
-
return {
|
|
134
|
-
manifestCid,
|
|
135
|
-
merkleRoot,
|
|
136
|
-
name,
|
|
137
|
-
schemaId,
|
|
138
|
-
version
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
static resourceId(owner, schemaId, name) {
|
|
142
|
-
return keccak256(encodePacked([
|
|
143
|
-
"address",
|
|
144
|
-
"bytes32",
|
|
145
|
-
"bytes32"
|
|
146
|
-
], [
|
|
147
|
-
owner,
|
|
148
|
-
schemaId,
|
|
149
|
-
keccak256(new TextEncoder().encode(name))
|
|
150
|
-
]));
|
|
151
|
-
}
|
|
152
|
-
static hashName(name) {
|
|
153
|
-
return keccak256(new TextEncoder().encode(name));
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
//#endregion
|
|
158
|
-
export { DataSourceRegistry, MerkleTree, hashString, poseidonHash };
|
package/lib/registries/index.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
//#region src/registries/schema-registry/abi.d.ts
|
|
2
|
-
declare const SCHEMA_REGISTRY_ABI: readonly [{
|
|
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
|
-
}, {
|
|
23
|
-
readonly inputs: readonly [{
|
|
24
|
-
readonly internalType: "bytes32";
|
|
25
|
-
readonly name: "schema_id";
|
|
26
|
-
readonly type: "bytes32";
|
|
27
|
-
}, {
|
|
28
|
-
readonly internalType: "address";
|
|
29
|
-
readonly name: "publisher";
|
|
30
|
-
readonly type: "address";
|
|
31
|
-
}];
|
|
32
|
-
readonly name: "addPublisher";
|
|
33
|
-
readonly outputs: readonly [];
|
|
34
|
-
readonly stateMutability: "nonpayable";
|
|
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 [];
|
|
44
|
-
readonly stateMutability: "nonpayable";
|
|
45
|
-
readonly type: "function";
|
|
46
|
-
}, {
|
|
47
|
-
readonly inputs: readonly [{
|
|
48
|
-
readonly internalType: "bytes32";
|
|
49
|
-
readonly name: "schema_id";
|
|
50
|
-
readonly type: "bytes32";
|
|
51
|
-
}];
|
|
52
|
-
readonly name: "getPublisherCount";
|
|
53
|
-
readonly outputs: readonly [{
|
|
54
|
-
readonly internalType: "uint256";
|
|
55
|
-
readonly name: "";
|
|
56
|
-
readonly type: "uint256";
|
|
57
|
-
}];
|
|
58
|
-
readonly stateMutability: "view";
|
|
59
|
-
readonly type: "function";
|
|
60
|
-
}, {
|
|
61
|
-
readonly inputs: readonly [{
|
|
62
|
-
readonly internalType: "bytes32";
|
|
63
|
-
readonly name: "id";
|
|
64
|
-
readonly type: "bytes32";
|
|
65
|
-
}];
|
|
66
|
-
readonly name: "getSchemaAgent";
|
|
67
|
-
readonly outputs: readonly [{
|
|
68
|
-
readonly internalType: "string";
|
|
69
|
-
readonly name: "";
|
|
70
|
-
readonly type: "string";
|
|
71
|
-
}];
|
|
72
|
-
readonly stateMutability: "view";
|
|
73
|
-
readonly type: "function";
|
|
74
|
-
}, {
|
|
75
|
-
readonly inputs: readonly [{
|
|
76
|
-
readonly internalType: "bytes32";
|
|
77
|
-
readonly name: "id";
|
|
78
|
-
readonly type: "bytes32";
|
|
79
|
-
}];
|
|
80
|
-
readonly name: "getSchemaName";
|
|
81
|
-
readonly outputs: readonly [{
|
|
82
|
-
readonly internalType: "string";
|
|
83
|
-
readonly name: "";
|
|
84
|
-
readonly type: "string";
|
|
85
|
-
}];
|
|
86
|
-
readonly stateMutability: "view";
|
|
87
|
-
readonly type: "function";
|
|
88
|
-
}, {
|
|
89
|
-
readonly inputs: readonly [{
|
|
90
|
-
readonly internalType: "bytes32";
|
|
91
|
-
readonly name: "id";
|
|
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";
|
|
105
|
-
readonly name: "id";
|
|
106
|
-
readonly type: "bytes32";
|
|
107
|
-
}];
|
|
108
|
-
readonly name: "getSchemaSpec";
|
|
109
|
-
readonly outputs: readonly [{
|
|
110
|
-
readonly internalType: "string";
|
|
111
|
-
readonly name: "";
|
|
112
|
-
readonly type: "string";
|
|
113
|
-
}];
|
|
114
|
-
readonly stateMutability: "view";
|
|
115
|
-
readonly type: "function";
|
|
116
|
-
}, {
|
|
117
|
-
readonly inputs: readonly [{
|
|
118
|
-
readonly internalType: "bytes32";
|
|
119
|
-
readonly name: "schema_id";
|
|
120
|
-
readonly type: "bytes32";
|
|
121
|
-
}];
|
|
122
|
-
readonly name: "hasPublishers";
|
|
123
|
-
readonly outputs: readonly [{
|
|
124
|
-
readonly internalType: "bool";
|
|
125
|
-
readonly name: "";
|
|
126
|
-
readonly type: "bool";
|
|
127
|
-
}];
|
|
128
|
-
readonly stateMutability: "view";
|
|
129
|
-
readonly type: "function";
|
|
130
|
-
}, {
|
|
131
|
-
readonly inputs: readonly [{
|
|
132
|
-
readonly internalType: "bytes32";
|
|
133
|
-
readonly name: "schema_id";
|
|
134
|
-
readonly type: "bytes32";
|
|
135
|
-
}, {
|
|
136
|
-
readonly internalType: "address";
|
|
137
|
-
readonly name: "publisher";
|
|
138
|
-
readonly type: "address";
|
|
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";
|
|
151
|
-
readonly name: "name";
|
|
152
|
-
readonly type: "string";
|
|
153
|
-
}, {
|
|
154
|
-
readonly internalType: "string";
|
|
155
|
-
readonly name: "spec_cid";
|
|
156
|
-
readonly type: "string";
|
|
157
|
-
}, {
|
|
158
|
-
readonly internalType: "string";
|
|
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";
|
|
181
|
-
}];
|
|
182
|
-
readonly stateMutability: "view";
|
|
183
|
-
readonly type: "function";
|
|
184
|
-
}, {
|
|
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: "";
|
|
194
|
-
readonly type: "bytes32";
|
|
195
|
-
}];
|
|
196
|
-
readonly stateMutability: "view";
|
|
197
|
-
readonly type: "function";
|
|
198
|
-
}, {
|
|
199
|
-
readonly inputs: readonly [{
|
|
200
|
-
readonly internalType: "bytes32";
|
|
201
|
-
readonly name: "id";
|
|
202
|
-
readonly type: "bytes32";
|
|
203
|
-
}, {
|
|
204
|
-
readonly internalType: "string";
|
|
205
|
-
readonly name: "new_spec_cid";
|
|
206
|
-
readonly type: "string";
|
|
207
|
-
}, {
|
|
208
|
-
readonly internalType: "string";
|
|
209
|
-
readonly name: "new_agent_id";
|
|
210
|
-
readonly type: "string";
|
|
211
|
-
}];
|
|
212
|
-
readonly name: "updateSchema";
|
|
213
|
-
readonly outputs: readonly [];
|
|
214
|
-
readonly stateMutability: "nonpayable";
|
|
215
|
-
readonly type: "function";
|
|
216
|
-
}];
|
|
217
|
-
//#endregion
|
|
218
|
-
export { SCHEMA_REGISTRY_ABI };
|