@opendatalabs/vana-sdk 0.1.0-alpha.3bc04d8 → 0.1.0-alpha.3cd7595
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/dist/index.browser.d.ts +280 -73
- package/dist/index.browser.js +1259 -754
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +1294 -788
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +280 -73
- package/dist/index.node.d.ts +280 -73
- package/dist/index.node.js +1265 -759
- package/dist/index.node.js.map +1 -1
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -198,15 +198,176 @@ var init_dataSchema_schema = __esm({
|
|
|
198
198
|
}
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
+
// src/utils/ipfs.ts
|
|
202
|
+
var ipfs_exports = {};
|
|
203
|
+
__export(ipfs_exports, {
|
|
204
|
+
DEFAULT_IPFS_GATEWAY: () => DEFAULT_IPFS_GATEWAY,
|
|
205
|
+
IPFS_GATEWAYS: () => IPFS_GATEWAYS,
|
|
206
|
+
convertIpfsUrl: () => convertIpfsUrl,
|
|
207
|
+
convertIpfsUrlWithFallbacks: () => convertIpfsUrlWithFallbacks,
|
|
208
|
+
extractIpfsHash: () => extractIpfsHash,
|
|
209
|
+
fetchWithFallbacks: () => fetchWithFallbacks,
|
|
210
|
+
getGatewayUrls: () => getGatewayUrls,
|
|
211
|
+
isIpfsUrl: () => isIpfsUrl
|
|
212
|
+
});
|
|
213
|
+
function isIpfsUrl(url) {
|
|
214
|
+
return url.startsWith("ipfs://");
|
|
215
|
+
}
|
|
216
|
+
function convertIpfsUrl(url, gateway = DEFAULT_IPFS_GATEWAY) {
|
|
217
|
+
if (isIpfsUrl(url)) {
|
|
218
|
+
const hash = url.replace("ipfs://", "");
|
|
219
|
+
return `${gateway}${hash}`;
|
|
220
|
+
}
|
|
221
|
+
return url;
|
|
222
|
+
}
|
|
223
|
+
function extractIpfsHash(url) {
|
|
224
|
+
const patterns = [
|
|
225
|
+
/ipfs\/([a-zA-Z0-9]+)/,
|
|
226
|
+
// https://gateway.pinata.cloud/ipfs/HASH
|
|
227
|
+
/^ipfs:\/\/([a-zA-Z0-9]+)$/,
|
|
228
|
+
// ipfs://HASH
|
|
229
|
+
/^([a-zA-Z0-9]{46,})$/
|
|
230
|
+
// Just the hash (46+ chars for IPFS hashes)
|
|
231
|
+
];
|
|
232
|
+
for (const pattern of patterns) {
|
|
233
|
+
const match = url.match(pattern);
|
|
234
|
+
if (match) {
|
|
235
|
+
return match[1];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
function getGatewayUrls(hash) {
|
|
241
|
+
return IPFS_GATEWAYS.map((gateway) => `${gateway}${hash}`);
|
|
242
|
+
}
|
|
243
|
+
function convertIpfsUrlWithFallbacks(url) {
|
|
244
|
+
const hash = extractIpfsHash(url);
|
|
245
|
+
if (hash) {
|
|
246
|
+
return getGatewayUrls(hash);
|
|
247
|
+
}
|
|
248
|
+
return [url];
|
|
249
|
+
}
|
|
250
|
+
async function fetchWithFallbacks(url, options) {
|
|
251
|
+
const hash = extractIpfsHash(url);
|
|
252
|
+
if (!hash) {
|
|
253
|
+
return fetch(url, options);
|
|
254
|
+
}
|
|
255
|
+
const gatewayUrls = getGatewayUrls(hash);
|
|
256
|
+
let lastError = null;
|
|
257
|
+
for (let i = 0; i < gatewayUrls.length; i++) {
|
|
258
|
+
const gatewayUrl = gatewayUrls[i];
|
|
259
|
+
try {
|
|
260
|
+
const response = await fetch(gatewayUrl, {
|
|
261
|
+
...options,
|
|
262
|
+
// Add timeout to avoid hanging on slow gateways
|
|
263
|
+
signal: AbortSignal.timeout(1e4)
|
|
264
|
+
// 10 second timeout
|
|
265
|
+
});
|
|
266
|
+
if (response.ok) {
|
|
267
|
+
return response;
|
|
268
|
+
}
|
|
269
|
+
if (response.status === 429) {
|
|
270
|
+
lastError = new Error(`Gateway rate limited: ${gatewayUrl}`);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
lastError = new Error(`Gateway error ${response.status}: ${gatewayUrl}`);
|
|
274
|
+
} catch (error) {
|
|
275
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
276
|
+
if (lastError.message.includes("429") || lastError.name === "TimeoutError") {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (i < gatewayUrls.length - 1) {
|
|
281
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3 * (i + 1)));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
throw new Error(
|
|
285
|
+
`All IPFS gateways failed for hash ${hash}. Last error: ${lastError?.message}`
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
var DEFAULT_IPFS_GATEWAY, IPFS_GATEWAYS;
|
|
289
|
+
var init_ipfs = __esm({
|
|
290
|
+
"src/utils/ipfs.ts"() {
|
|
291
|
+
"use strict";
|
|
292
|
+
DEFAULT_IPFS_GATEWAY = "https://dweb.link/ipfs/";
|
|
293
|
+
IPFS_GATEWAYS = [
|
|
294
|
+
"https://dweb.link/ipfs/",
|
|
295
|
+
// Interplanetary Shipyard - highly reliable
|
|
296
|
+
"https://ipfs.io/ipfs/",
|
|
297
|
+
// IPFS Foundation - reliable
|
|
298
|
+
"https://cloudflare-ipfs.com/ipfs/",
|
|
299
|
+
// Cloudflare - good performance
|
|
300
|
+
"https://gateway.pinata.cloud/ipfs/",
|
|
301
|
+
// Pinata - backup option (has rate limits)
|
|
302
|
+
"https://ipfs.filebase.io/ipfs/"
|
|
303
|
+
// Filebase - emerging reliable option
|
|
304
|
+
];
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// src/utils/download.ts
|
|
309
|
+
var download_exports = {};
|
|
310
|
+
__export(download_exports, {
|
|
311
|
+
fetchWithRelayer: () => fetchWithRelayer
|
|
312
|
+
});
|
|
313
|
+
async function fetchWithRelayer(url, downloadRelayer) {
|
|
314
|
+
let processedUrl = url;
|
|
315
|
+
if (url.startsWith("ar://")) {
|
|
316
|
+
const txId = url.replace("ar://", "");
|
|
317
|
+
processedUrl = `https://arweave.net/${txId}`;
|
|
318
|
+
}
|
|
319
|
+
const ipfsHash = extractIpfsHash(processedUrl);
|
|
320
|
+
if (ipfsHash) {
|
|
321
|
+
try {
|
|
322
|
+
return await fetchWithFallbacks(url);
|
|
323
|
+
} catch (ipfsError) {
|
|
324
|
+
if (downloadRelayer) {
|
|
325
|
+
try {
|
|
326
|
+
const gatewayUrl = `https://gateway.pinata.cloud/ipfs/${ipfsHash}`;
|
|
327
|
+
const blob = await downloadRelayer.proxyDownload(gatewayUrl);
|
|
328
|
+
return new Response(blob);
|
|
329
|
+
} catch {
|
|
330
|
+
throw ipfsError;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
throw ipfsError;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
try {
|
|
337
|
+
const response = await fetch(processedUrl);
|
|
338
|
+
return response;
|
|
339
|
+
} catch (error) {
|
|
340
|
+
if (downloadRelayer) {
|
|
341
|
+
try {
|
|
342
|
+
const blob = await downloadRelayer.proxyDownload(processedUrl);
|
|
343
|
+
return new Response(blob);
|
|
344
|
+
} catch {
|
|
345
|
+
throw error;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
throw new Error(
|
|
349
|
+
`Failed to fetch from ${processedUrl}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
var init_download = __esm({
|
|
354
|
+
"src/utils/download.ts"() {
|
|
355
|
+
"use strict";
|
|
356
|
+
init_ipfs();
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
|
|
201
360
|
// src/utils/schemaValidation.ts
|
|
202
|
-
function
|
|
203
|
-
|
|
361
|
+
function validateDataSchemaAgainstMetaSchema(schema) {
|
|
362
|
+
const validator = schemaValidator;
|
|
363
|
+
validator.validateDataSchemaAgainstMetaSchema(schema);
|
|
364
|
+
return schema;
|
|
204
365
|
}
|
|
205
366
|
function validateDataAgainstSchema(data, schema) {
|
|
206
367
|
return schemaValidator.validateDataAgainstSchema(data, schema);
|
|
207
368
|
}
|
|
208
|
-
function fetchAndValidateSchema(url) {
|
|
209
|
-
return schemaValidator.fetchAndValidateSchema(url);
|
|
369
|
+
function fetchAndValidateSchema(url, downloadRelayer) {
|
|
370
|
+
return schemaValidator.fetchAndValidateSchema(url, downloadRelayer);
|
|
210
371
|
}
|
|
211
372
|
var import_ajv, import_ajv_formats, SchemaValidationError, SchemaValidator, schemaValidator;
|
|
212
373
|
var init_schemaValidation = __esm({
|
|
@@ -235,9 +396,9 @@ var init_schemaValidation = __esm({
|
|
|
235
396
|
this.dataSchemaValidator = this.ajv.compile(dataSchema_schema_default);
|
|
236
397
|
}
|
|
237
398
|
/**
|
|
238
|
-
* Validates a data schema against the Vana meta-schema
|
|
399
|
+
* Validates a data schema definition against the Vana meta-schema
|
|
239
400
|
*
|
|
240
|
-
* @param schema - The data schema to validate
|
|
401
|
+
* @param schema - The data schema definition to validate
|
|
241
402
|
* @throws SchemaValidationError if invalid
|
|
242
403
|
* @example
|
|
243
404
|
* ```typescript
|
|
@@ -256,10 +417,10 @@ var init_schemaValidation = __esm({
|
|
|
256
417
|
* }
|
|
257
418
|
* };
|
|
258
419
|
*
|
|
259
|
-
* validator.
|
|
420
|
+
* validator.validateDataSchemaAgainstMetaSchema(schema); // throws if invalid
|
|
260
421
|
* ```
|
|
261
422
|
*/
|
|
262
|
-
|
|
423
|
+
validateDataSchemaAgainstMetaSchema(schema) {
|
|
263
424
|
const isValid = this.dataSchemaValidator(schema);
|
|
264
425
|
if (!isValid) {
|
|
265
426
|
const errors = this.dataSchemaValidator.errors || [];
|
|
@@ -279,10 +440,10 @@ var init_schemaValidation = __esm({
|
|
|
279
440
|
}
|
|
280
441
|
}
|
|
281
442
|
/**
|
|
282
|
-
* Validates data against a JSON Schema
|
|
443
|
+
* Validates data against a JSON Schema
|
|
283
444
|
*
|
|
284
445
|
* @param data - The data to validate
|
|
285
|
-
* @param schema - The schema containing the validation rules (
|
|
446
|
+
* @param schema - The schema containing the validation rules (must have been validated or fetched from chain)
|
|
286
447
|
* @throws SchemaValidationError if invalid
|
|
287
448
|
* @example
|
|
288
449
|
* ```typescript
|
|
@@ -292,25 +453,22 @@ var init_schemaValidation = __esm({
|
|
|
292
453
|
* const schema = await vana.schemas.get(1);
|
|
293
454
|
* validator.validateDataAgainstSchema(userData, schema);
|
|
294
455
|
*
|
|
295
|
-
* // Also works with DataSchema object
|
|
296
|
-
* const dataSchema
|
|
456
|
+
* // Also works with pre-validated DataSchema object
|
|
457
|
+
* const dataSchema = validator.validateDataSchemaAgainstMetaSchema({
|
|
297
458
|
* name: "User Profile",
|
|
298
459
|
* version: "1.0.0",
|
|
299
460
|
* dialect: "json",
|
|
300
461
|
* schema: { type: "object", properties: { name: { type: "string" } } }
|
|
301
|
-
* };
|
|
462
|
+
* });
|
|
302
463
|
* validator.validateDataAgainstSchema(userData, dataSchema);
|
|
303
464
|
* ```
|
|
304
465
|
*/
|
|
305
466
|
validateDataAgainstSchema(data, schema) {
|
|
306
|
-
if (!("id" in schema)) {
|
|
307
|
-
this.validateDataSchema(schema);
|
|
308
|
-
}
|
|
309
467
|
if (schema.dialect !== "json") {
|
|
310
|
-
|
|
311
|
-
`Data validation
|
|
312
|
-
[]
|
|
468
|
+
console.warn(
|
|
469
|
+
`[SchemaValidator] Data validation skipped: dialect '${schema.dialect}' does not support data validation. Only JSON schemas can validate data structure.`
|
|
313
470
|
);
|
|
471
|
+
return;
|
|
314
472
|
}
|
|
315
473
|
if (typeof schema.schema !== "object") {
|
|
316
474
|
throw new SchemaValidationError(
|
|
@@ -376,9 +534,11 @@ var init_schemaValidation = __esm({
|
|
|
376
534
|
}
|
|
377
535
|
}
|
|
378
536
|
/**
|
|
379
|
-
* Fetches and validates a schema from a URL
|
|
537
|
+
* Fetches and validates a data schema from a URL
|
|
380
538
|
*
|
|
381
|
-
* @param url - The URL to fetch the schema from
|
|
539
|
+
* @param url - The URL to fetch the data schema from
|
|
540
|
+
* @param downloadRelayer - Optional download relayer for CORS bypass
|
|
541
|
+
* @param downloadRelayer.proxyDownload - Function to proxy downloads through application server
|
|
382
542
|
* @returns The validated data schema
|
|
383
543
|
* @throws SchemaValidationError if invalid or fetch fails
|
|
384
544
|
* @example
|
|
@@ -387,14 +547,15 @@ var init_schemaValidation = __esm({
|
|
|
387
547
|
* const schema = await validator.fetchAndValidateSchema("https://example.com/schema.json");
|
|
388
548
|
* ```
|
|
389
549
|
*/
|
|
390
|
-
async fetchAndValidateSchema(url) {
|
|
550
|
+
async fetchAndValidateSchema(url, downloadRelayer) {
|
|
391
551
|
try {
|
|
392
|
-
const
|
|
552
|
+
const { fetchWithRelayer: fetchWithRelayer2 } = await Promise.resolve().then(() => (init_download(), download_exports));
|
|
553
|
+
const response = await fetchWithRelayer2(url, downloadRelayer);
|
|
393
554
|
if (!response.ok) {
|
|
394
555
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
395
556
|
}
|
|
396
557
|
const schema = await response.json();
|
|
397
|
-
this.
|
|
558
|
+
this.validateDataSchemaAgainstMetaSchema(schema);
|
|
398
559
|
if (schema.dialect === "sqlite" && typeof schema.schema === "string") {
|
|
399
560
|
this.validateSQLiteDDL(schema.schema, schema.dialectVersion);
|
|
400
561
|
}
|
|
@@ -2812,6 +2973,19 @@ var init_DataRegistryImplementation = __esm({
|
|
|
2812
2973
|
name: "Upgraded",
|
|
2813
2974
|
type: "event"
|
|
2814
2975
|
},
|
|
2976
|
+
{
|
|
2977
|
+
inputs: [],
|
|
2978
|
+
name: "DATA_PORTABILITY_ROLE",
|
|
2979
|
+
outputs: [
|
|
2980
|
+
{
|
|
2981
|
+
internalType: "bytes32",
|
|
2982
|
+
name: "",
|
|
2983
|
+
type: "bytes32"
|
|
2984
|
+
}
|
|
2985
|
+
],
|
|
2986
|
+
stateMutability: "view",
|
|
2987
|
+
type: "function"
|
|
2988
|
+
},
|
|
2815
2989
|
{
|
|
2816
2990
|
inputs: [],
|
|
2817
2991
|
name: "DEFAULT_ADMIN_ROLE",
|
|
@@ -2909,14 +3083,9 @@ var init_DataRegistryImplementation = __esm({
|
|
|
2909
3083
|
{
|
|
2910
3084
|
inputs: [
|
|
2911
3085
|
{
|
|
2912
|
-
internalType: "
|
|
2913
|
-
name: "
|
|
2914
|
-
type: "
|
|
2915
|
-
},
|
|
2916
|
-
{
|
|
2917
|
-
internalType: "address",
|
|
2918
|
-
name: "ownerAddress",
|
|
2919
|
-
type: "address"
|
|
3086
|
+
internalType: "uint256",
|
|
3087
|
+
name: "fileId",
|
|
3088
|
+
type: "uint256"
|
|
2920
3089
|
},
|
|
2921
3090
|
{
|
|
2922
3091
|
components: [
|
|
@@ -2934,16 +3103,15 @@ var init_DataRegistryImplementation = __esm({
|
|
|
2934
3103
|
internalType: "struct IDataRegistry.Permission[]",
|
|
2935
3104
|
name: "permissions",
|
|
2936
3105
|
type: "tuple[]"
|
|
2937
|
-
}
|
|
2938
|
-
],
|
|
2939
|
-
name: "addFileWithPermissions",
|
|
2940
|
-
outputs: [
|
|
3106
|
+
},
|
|
2941
3107
|
{
|
|
2942
3108
|
internalType: "uint256",
|
|
2943
|
-
name: "",
|
|
3109
|
+
name: "schemaId",
|
|
2944
3110
|
type: "uint256"
|
|
2945
3111
|
}
|
|
2946
3112
|
],
|
|
3113
|
+
name: "addFilePermissionsAndSchema",
|
|
3114
|
+
outputs: [],
|
|
2947
3115
|
stateMutability: "nonpayable",
|
|
2948
3116
|
type: "function"
|
|
2949
3117
|
},
|
|
@@ -2975,14 +3143,9 @@ var init_DataRegistryImplementation = __esm({
|
|
|
2975
3143
|
internalType: "struct IDataRegistry.Permission[]",
|
|
2976
3144
|
name: "permissions",
|
|
2977
3145
|
type: "tuple[]"
|
|
2978
|
-
},
|
|
2979
|
-
{
|
|
2980
|
-
internalType: "uint256",
|
|
2981
|
-
name: "schemaId",
|
|
2982
|
-
type: "uint256"
|
|
2983
3146
|
}
|
|
2984
3147
|
],
|
|
2985
|
-
name: "
|
|
3148
|
+
name: "addFileWithPermissions",
|
|
2986
3149
|
outputs: [
|
|
2987
3150
|
{
|
|
2988
3151
|
internalType: "uint256",
|
|
@@ -3001,136 +3164,42 @@ var init_DataRegistryImplementation = __esm({
|
|
|
3001
3164
|
type: "string"
|
|
3002
3165
|
},
|
|
3003
3166
|
{
|
|
3004
|
-
internalType: "
|
|
3005
|
-
name: "
|
|
3006
|
-
type: "
|
|
3007
|
-
}
|
|
3008
|
-
],
|
|
3009
|
-
name: "addFileWithSchema",
|
|
3010
|
-
outputs: [
|
|
3011
|
-
{
|
|
3012
|
-
internalType: "uint256",
|
|
3013
|
-
name: "",
|
|
3014
|
-
type: "uint256"
|
|
3015
|
-
}
|
|
3016
|
-
],
|
|
3017
|
-
stateMutability: "nonpayable",
|
|
3018
|
-
type: "function"
|
|
3019
|
-
},
|
|
3020
|
-
{
|
|
3021
|
-
inputs: [
|
|
3022
|
-
{
|
|
3023
|
-
internalType: "uint256",
|
|
3024
|
-
name: "fileId",
|
|
3025
|
-
type: "uint256"
|
|
3167
|
+
internalType: "address",
|
|
3168
|
+
name: "ownerAddress",
|
|
3169
|
+
type: "address"
|
|
3026
3170
|
},
|
|
3027
3171
|
{
|
|
3028
3172
|
components: [
|
|
3029
3173
|
{
|
|
3030
|
-
internalType: "
|
|
3031
|
-
name: "
|
|
3032
|
-
type: "
|
|
3174
|
+
internalType: "address",
|
|
3175
|
+
name: "account",
|
|
3176
|
+
type: "address"
|
|
3033
3177
|
},
|
|
3034
3178
|
{
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
name: "score",
|
|
3039
|
-
type: "uint256"
|
|
3040
|
-
},
|
|
3041
|
-
{
|
|
3042
|
-
internalType: "uint256",
|
|
3043
|
-
name: "dlpId",
|
|
3044
|
-
type: "uint256"
|
|
3045
|
-
},
|
|
3046
|
-
{
|
|
3047
|
-
internalType: "string",
|
|
3048
|
-
name: "metadata",
|
|
3049
|
-
type: "string"
|
|
3050
|
-
},
|
|
3051
|
-
{
|
|
3052
|
-
internalType: "string",
|
|
3053
|
-
name: "proofUrl",
|
|
3054
|
-
type: "string"
|
|
3055
|
-
},
|
|
3056
|
-
{
|
|
3057
|
-
internalType: "string",
|
|
3058
|
-
name: "instruction",
|
|
3059
|
-
type: "string"
|
|
3060
|
-
}
|
|
3061
|
-
],
|
|
3062
|
-
internalType: "struct IDataRegistry.ProofData",
|
|
3063
|
-
name: "data",
|
|
3064
|
-
type: "tuple"
|
|
3179
|
+
internalType: "string",
|
|
3180
|
+
name: "key",
|
|
3181
|
+
type: "string"
|
|
3065
3182
|
}
|
|
3066
3183
|
],
|
|
3067
|
-
internalType: "struct IDataRegistry.
|
|
3068
|
-
name: "
|
|
3069
|
-
type: "tuple"
|
|
3070
|
-
}
|
|
3071
|
-
],
|
|
3072
|
-
name: "addProof",
|
|
3073
|
-
outputs: [],
|
|
3074
|
-
stateMutability: "nonpayable",
|
|
3075
|
-
type: "function"
|
|
3076
|
-
},
|
|
3077
|
-
{
|
|
3078
|
-
inputs: [
|
|
3079
|
-
{
|
|
3080
|
-
internalType: "uint256",
|
|
3081
|
-
name: "fileId",
|
|
3082
|
-
type: "uint256"
|
|
3184
|
+
internalType: "struct IDataRegistry.Permission[]",
|
|
3185
|
+
name: "permissions",
|
|
3186
|
+
type: "tuple[]"
|
|
3083
3187
|
},
|
|
3084
3188
|
{
|
|
3085
3189
|
internalType: "uint256",
|
|
3086
|
-
name: "
|
|
3190
|
+
name: "schemaId",
|
|
3087
3191
|
type: "uint256"
|
|
3088
|
-
},
|
|
3089
|
-
{
|
|
3090
|
-
internalType: "string",
|
|
3091
|
-
name: "url",
|
|
3092
|
-
type: "string"
|
|
3093
|
-
},
|
|
3094
|
-
{
|
|
3095
|
-
internalType: "address",
|
|
3096
|
-
name: "account",
|
|
3097
|
-
type: "address"
|
|
3098
|
-
},
|
|
3099
|
-
{
|
|
3100
|
-
internalType: "string",
|
|
3101
|
-
name: "key",
|
|
3102
|
-
type: "string"
|
|
3103
3192
|
}
|
|
3104
3193
|
],
|
|
3105
|
-
name: "
|
|
3106
|
-
outputs: [],
|
|
3107
|
-
stateMutability: "nonpayable",
|
|
3108
|
-
type: "function"
|
|
3109
|
-
},
|
|
3110
|
-
{
|
|
3111
|
-
inputs: [],
|
|
3112
|
-
name: "dataRefinerRegistry",
|
|
3113
|
-
outputs: [
|
|
3114
|
-
{
|
|
3115
|
-
internalType: "contract IDataRefinerRegistry",
|
|
3116
|
-
name: "",
|
|
3117
|
-
type: "address"
|
|
3118
|
-
}
|
|
3119
|
-
],
|
|
3120
|
-
stateMutability: "view",
|
|
3121
|
-
type: "function"
|
|
3122
|
-
},
|
|
3123
|
-
{
|
|
3124
|
-
inputs: [],
|
|
3125
|
-
name: "emitLegacyEvents",
|
|
3194
|
+
name: "addFileWithPermissionsAndSchema",
|
|
3126
3195
|
outputs: [
|
|
3127
3196
|
{
|
|
3128
|
-
internalType: "
|
|
3197
|
+
internalType: "uint256",
|
|
3129
3198
|
name: "",
|
|
3130
|
-
type: "
|
|
3199
|
+
type: "uint256"
|
|
3131
3200
|
}
|
|
3132
3201
|
],
|
|
3133
|
-
stateMutability: "
|
|
3202
|
+
stateMutability: "nonpayable",
|
|
3134
3203
|
type: "function"
|
|
3135
3204
|
},
|
|
3136
3205
|
{
|
|
@@ -3139,41 +3208,22 @@ var init_DataRegistryImplementation = __esm({
|
|
|
3139
3208
|
internalType: "string",
|
|
3140
3209
|
name: "url",
|
|
3141
3210
|
type: "string"
|
|
3142
|
-
}
|
|
3143
|
-
],
|
|
3144
|
-
name: "fileIdByUrl",
|
|
3145
|
-
outputs: [
|
|
3211
|
+
},
|
|
3146
3212
|
{
|
|
3147
3213
|
internalType: "uint256",
|
|
3148
|
-
name: "",
|
|
3214
|
+
name: "schemaId",
|
|
3149
3215
|
type: "uint256"
|
|
3150
3216
|
}
|
|
3151
3217
|
],
|
|
3152
|
-
|
|
3153
|
-
type: "function"
|
|
3154
|
-
},
|
|
3155
|
-
{
|
|
3156
|
-
inputs: [
|
|
3157
|
-
{
|
|
3158
|
-
internalType: "uint256",
|
|
3159
|
-
name: "fileId",
|
|
3160
|
-
type: "uint256"
|
|
3161
|
-
},
|
|
3162
|
-
{
|
|
3163
|
-
internalType: "address",
|
|
3164
|
-
name: "account",
|
|
3165
|
-
type: "address"
|
|
3166
|
-
}
|
|
3167
|
-
],
|
|
3168
|
-
name: "filePermissions",
|
|
3218
|
+
name: "addFileWithSchema",
|
|
3169
3219
|
outputs: [
|
|
3170
3220
|
{
|
|
3171
|
-
internalType: "
|
|
3221
|
+
internalType: "uint256",
|
|
3172
3222
|
name: "",
|
|
3173
|
-
type: "
|
|
3223
|
+
type: "uint256"
|
|
3174
3224
|
}
|
|
3175
3225
|
],
|
|
3176
|
-
stateMutability: "
|
|
3226
|
+
stateMutability: "nonpayable",
|
|
3177
3227
|
type: "function"
|
|
3178
3228
|
},
|
|
3179
3229
|
{
|
|
@@ -3183,14 +3233,173 @@ var init_DataRegistryImplementation = __esm({
|
|
|
3183
3233
|
name: "fileId",
|
|
3184
3234
|
type: "uint256"
|
|
3185
3235
|
},
|
|
3186
|
-
{
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3236
|
+
{
|
|
3237
|
+
components: [
|
|
3238
|
+
{
|
|
3239
|
+
internalType: "bytes",
|
|
3240
|
+
name: "signature",
|
|
3241
|
+
type: "bytes"
|
|
3242
|
+
},
|
|
3243
|
+
{
|
|
3244
|
+
components: [
|
|
3245
|
+
{
|
|
3246
|
+
internalType: "uint256",
|
|
3247
|
+
name: "score",
|
|
3248
|
+
type: "uint256"
|
|
3249
|
+
},
|
|
3250
|
+
{
|
|
3251
|
+
internalType: "uint256",
|
|
3252
|
+
name: "dlpId",
|
|
3253
|
+
type: "uint256"
|
|
3254
|
+
},
|
|
3255
|
+
{
|
|
3256
|
+
internalType: "string",
|
|
3257
|
+
name: "metadata",
|
|
3258
|
+
type: "string"
|
|
3259
|
+
},
|
|
3260
|
+
{
|
|
3261
|
+
internalType: "string",
|
|
3262
|
+
name: "proofUrl",
|
|
3263
|
+
type: "string"
|
|
3264
|
+
},
|
|
3265
|
+
{
|
|
3266
|
+
internalType: "string",
|
|
3267
|
+
name: "instruction",
|
|
3268
|
+
type: "string"
|
|
3269
|
+
}
|
|
3270
|
+
],
|
|
3271
|
+
internalType: "struct IDataRegistry.ProofData",
|
|
3272
|
+
name: "data",
|
|
3273
|
+
type: "tuple"
|
|
3274
|
+
}
|
|
3275
|
+
],
|
|
3276
|
+
internalType: "struct IDataRegistry.Proof",
|
|
3277
|
+
name: "proof",
|
|
3278
|
+
type: "tuple"
|
|
3279
|
+
}
|
|
3280
|
+
],
|
|
3281
|
+
name: "addProof",
|
|
3282
|
+
outputs: [],
|
|
3283
|
+
stateMutability: "nonpayable",
|
|
3284
|
+
type: "function"
|
|
3285
|
+
},
|
|
3286
|
+
{
|
|
3287
|
+
inputs: [
|
|
3288
|
+
{
|
|
3289
|
+
internalType: "uint256",
|
|
3290
|
+
name: "fileId",
|
|
3291
|
+
type: "uint256"
|
|
3292
|
+
},
|
|
3293
|
+
{
|
|
3294
|
+
internalType: "uint256",
|
|
3295
|
+
name: "refinerId",
|
|
3296
|
+
type: "uint256"
|
|
3297
|
+
},
|
|
3298
|
+
{
|
|
3299
|
+
internalType: "string",
|
|
3300
|
+
name: "url",
|
|
3301
|
+
type: "string"
|
|
3302
|
+
},
|
|
3303
|
+
{
|
|
3304
|
+
internalType: "address",
|
|
3305
|
+
name: "account",
|
|
3306
|
+
type: "address"
|
|
3307
|
+
},
|
|
3308
|
+
{
|
|
3309
|
+
internalType: "string",
|
|
3310
|
+
name: "key",
|
|
3311
|
+
type: "string"
|
|
3312
|
+
}
|
|
3313
|
+
],
|
|
3314
|
+
name: "addRefinementWithPermission",
|
|
3315
|
+
outputs: [],
|
|
3316
|
+
stateMutability: "nonpayable",
|
|
3317
|
+
type: "function"
|
|
3318
|
+
},
|
|
3319
|
+
{
|
|
3320
|
+
inputs: [],
|
|
3321
|
+
name: "dataRefinerRegistry",
|
|
3322
|
+
outputs: [
|
|
3323
|
+
{
|
|
3324
|
+
internalType: "contract IDataRefinerRegistry",
|
|
3325
|
+
name: "",
|
|
3326
|
+
type: "address"
|
|
3327
|
+
}
|
|
3328
|
+
],
|
|
3329
|
+
stateMutability: "view",
|
|
3330
|
+
type: "function"
|
|
3331
|
+
},
|
|
3332
|
+
{
|
|
3333
|
+
inputs: [],
|
|
3334
|
+
name: "emitLegacyEvents",
|
|
3335
|
+
outputs: [
|
|
3336
|
+
{
|
|
3337
|
+
internalType: "bool",
|
|
3338
|
+
name: "",
|
|
3339
|
+
type: "bool"
|
|
3340
|
+
}
|
|
3341
|
+
],
|
|
3342
|
+
stateMutability: "view",
|
|
3343
|
+
type: "function"
|
|
3344
|
+
},
|
|
3345
|
+
{
|
|
3346
|
+
inputs: [
|
|
3347
|
+
{
|
|
3348
|
+
internalType: "string",
|
|
3349
|
+
name: "url",
|
|
3350
|
+
type: "string"
|
|
3351
|
+
}
|
|
3352
|
+
],
|
|
3353
|
+
name: "fileIdByUrl",
|
|
3354
|
+
outputs: [
|
|
3355
|
+
{
|
|
3356
|
+
internalType: "uint256",
|
|
3357
|
+
name: "",
|
|
3358
|
+
type: "uint256"
|
|
3359
|
+
}
|
|
3360
|
+
],
|
|
3361
|
+
stateMutability: "view",
|
|
3362
|
+
type: "function"
|
|
3363
|
+
},
|
|
3364
|
+
{
|
|
3365
|
+
inputs: [
|
|
3366
|
+
{
|
|
3367
|
+
internalType: "uint256",
|
|
3368
|
+
name: "fileId",
|
|
3369
|
+
type: "uint256"
|
|
3370
|
+
},
|
|
3371
|
+
{
|
|
3372
|
+
internalType: "address",
|
|
3373
|
+
name: "account",
|
|
3374
|
+
type: "address"
|
|
3375
|
+
}
|
|
3376
|
+
],
|
|
3377
|
+
name: "filePermissions",
|
|
3378
|
+
outputs: [
|
|
3379
|
+
{
|
|
3380
|
+
internalType: "string",
|
|
3381
|
+
name: "",
|
|
3382
|
+
type: "string"
|
|
3383
|
+
}
|
|
3384
|
+
],
|
|
3385
|
+
stateMutability: "view",
|
|
3386
|
+
type: "function"
|
|
3387
|
+
},
|
|
3388
|
+
{
|
|
3389
|
+
inputs: [
|
|
3390
|
+
{
|
|
3391
|
+
internalType: "uint256",
|
|
3392
|
+
name: "fileId",
|
|
3393
|
+
type: "uint256"
|
|
3394
|
+
},
|
|
3395
|
+
{
|
|
3396
|
+
internalType: "uint256",
|
|
3397
|
+
name: "index",
|
|
3398
|
+
type: "uint256"
|
|
3399
|
+
}
|
|
3400
|
+
],
|
|
3401
|
+
name: "fileProofs",
|
|
3402
|
+
outputs: [
|
|
3194
3403
|
{
|
|
3195
3404
|
components: [
|
|
3196
3405
|
{
|
|
@@ -35884,110 +36093,644 @@ var init_transactionHandle = __esm({
|
|
|
35884
36093
|
}
|
|
35885
36094
|
});
|
|
35886
36095
|
|
|
35887
|
-
// src/
|
|
35888
|
-
var
|
|
35889
|
-
|
|
35890
|
-
|
|
35891
|
-
IPFS_GATEWAYS: () => IPFS_GATEWAYS,
|
|
35892
|
-
convertIpfsUrl: () => convertIpfsUrl,
|
|
35893
|
-
convertIpfsUrlWithFallbacks: () => convertIpfsUrlWithFallbacks,
|
|
35894
|
-
extractIpfsHash: () => extractIpfsHash,
|
|
35895
|
-
fetchWithFallbacks: () => fetchWithFallbacks,
|
|
35896
|
-
getGatewayUrls: () => getGatewayUrls,
|
|
35897
|
-
isIpfsUrl: () => isIpfsUrl
|
|
35898
|
-
});
|
|
35899
|
-
function isIpfsUrl(url) {
|
|
35900
|
-
return url.startsWith("ipfs://");
|
|
35901
|
-
}
|
|
35902
|
-
function convertIpfsUrl(url, gateway = DEFAULT_IPFS_GATEWAY) {
|
|
35903
|
-
if (isIpfsUrl(url)) {
|
|
35904
|
-
const hash = url.replace("ipfs://", "");
|
|
35905
|
-
return `${gateway}${hash}`;
|
|
35906
|
-
}
|
|
35907
|
-
return url;
|
|
35908
|
-
}
|
|
35909
|
-
function extractIpfsHash(url) {
|
|
35910
|
-
const patterns = [
|
|
35911
|
-
/ipfs\/([a-zA-Z0-9]+)/,
|
|
35912
|
-
// https://gateway.pinata.cloud/ipfs/HASH
|
|
35913
|
-
/^ipfs:\/\/([a-zA-Z0-9]+)$/,
|
|
35914
|
-
// ipfs://HASH
|
|
35915
|
-
/^([a-zA-Z0-9]{46,})$/
|
|
35916
|
-
// Just the hash (46+ chars for IPFS hashes)
|
|
35917
|
-
];
|
|
35918
|
-
for (const pattern of patterns) {
|
|
35919
|
-
const match = url.match(pattern);
|
|
35920
|
-
if (match) {
|
|
35921
|
-
return match[1];
|
|
35922
|
-
}
|
|
35923
|
-
}
|
|
35924
|
-
return null;
|
|
35925
|
-
}
|
|
35926
|
-
function getGatewayUrls(hash) {
|
|
35927
|
-
return IPFS_GATEWAYS.map((gateway) => `${gateway}${hash}`);
|
|
35928
|
-
}
|
|
35929
|
-
function convertIpfsUrlWithFallbacks(url) {
|
|
35930
|
-
const hash = extractIpfsHash(url);
|
|
35931
|
-
if (hash) {
|
|
35932
|
-
return getGatewayUrls(hash);
|
|
35933
|
-
}
|
|
35934
|
-
return [url];
|
|
35935
|
-
}
|
|
35936
|
-
async function fetchWithFallbacks(url, options) {
|
|
35937
|
-
const hash = extractIpfsHash(url);
|
|
35938
|
-
if (!hash) {
|
|
35939
|
-
return fetch(url, options);
|
|
35940
|
-
}
|
|
35941
|
-
const gatewayUrls = getGatewayUrls(hash);
|
|
35942
|
-
let lastError = null;
|
|
35943
|
-
for (let i = 0; i < gatewayUrls.length; i++) {
|
|
35944
|
-
const gatewayUrl = gatewayUrls[i];
|
|
35945
|
-
try {
|
|
35946
|
-
const response = await fetch(gatewayUrl, {
|
|
35947
|
-
...options,
|
|
35948
|
-
// Add timeout to avoid hanging on slow gateways
|
|
35949
|
-
signal: AbortSignal.timeout(1e4)
|
|
35950
|
-
// 10 second timeout
|
|
35951
|
-
});
|
|
35952
|
-
if (response.ok) {
|
|
35953
|
-
return response;
|
|
35954
|
-
}
|
|
35955
|
-
if (response.status === 429) {
|
|
35956
|
-
lastError = new Error(`Gateway rate limited: ${gatewayUrl}`);
|
|
35957
|
-
continue;
|
|
35958
|
-
}
|
|
35959
|
-
lastError = new Error(`Gateway error ${response.status}: ${gatewayUrl}`);
|
|
35960
|
-
} catch (error) {
|
|
35961
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
35962
|
-
if (lastError.message.includes("429") || lastError.name === "TimeoutError") {
|
|
35963
|
-
continue;
|
|
35964
|
-
}
|
|
35965
|
-
}
|
|
35966
|
-
if (i < gatewayUrls.length - 1) {
|
|
35967
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3 * (i + 1)));
|
|
35968
|
-
}
|
|
35969
|
-
}
|
|
35970
|
-
throw new Error(
|
|
35971
|
-
`All IPFS gateways failed for hash ${hash}. Last error: ${lastError?.message}`
|
|
35972
|
-
);
|
|
35973
|
-
}
|
|
35974
|
-
var DEFAULT_IPFS_GATEWAY, IPFS_GATEWAYS;
|
|
35975
|
-
var init_ipfs = __esm({
|
|
35976
|
-
"src/utils/ipfs.ts"() {
|
|
36096
|
+
// src/generated/subgraph.ts
|
|
36097
|
+
var GetUserPermissionsDocument, GetUserTrustedServersDocument, GetUserFilesDocument, GetFileProofsDocument, GetDlpDocument, GetSchemaDocument, ListSchemasDocument, CountSchemasDocument;
|
|
36098
|
+
var init_subgraph = __esm({
|
|
36099
|
+
"src/generated/subgraph.ts"() {
|
|
35977
36100
|
"use strict";
|
|
35978
|
-
|
|
35979
|
-
|
|
35980
|
-
|
|
35981
|
-
|
|
35982
|
-
|
|
35983
|
-
|
|
35984
|
-
|
|
35985
|
-
|
|
35986
|
-
|
|
35987
|
-
|
|
35988
|
-
|
|
35989
|
-
|
|
35990
|
-
|
|
36101
|
+
GetUserPermissionsDocument = {
|
|
36102
|
+
kind: "Document",
|
|
36103
|
+
definitions: [
|
|
36104
|
+
{
|
|
36105
|
+
kind: "OperationDefinition",
|
|
36106
|
+
operation: "query",
|
|
36107
|
+
name: { kind: "Name", value: "GetUserPermissions" },
|
|
36108
|
+
variableDefinitions: [
|
|
36109
|
+
{
|
|
36110
|
+
kind: "VariableDefinition",
|
|
36111
|
+
variable: {
|
|
36112
|
+
kind: "Variable",
|
|
36113
|
+
name: { kind: "Name", value: "userId" }
|
|
36114
|
+
},
|
|
36115
|
+
type: {
|
|
36116
|
+
kind: "NonNullType",
|
|
36117
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36118
|
+
}
|
|
36119
|
+
}
|
|
36120
|
+
],
|
|
36121
|
+
selectionSet: {
|
|
36122
|
+
kind: "SelectionSet",
|
|
36123
|
+
selections: [
|
|
36124
|
+
{
|
|
36125
|
+
kind: "Field",
|
|
36126
|
+
name: { kind: "Name", value: "user" },
|
|
36127
|
+
arguments: [
|
|
36128
|
+
{
|
|
36129
|
+
kind: "Argument",
|
|
36130
|
+
name: { kind: "Name", value: "id" },
|
|
36131
|
+
value: {
|
|
36132
|
+
kind: "Variable",
|
|
36133
|
+
name: { kind: "Name", value: "userId" }
|
|
36134
|
+
}
|
|
36135
|
+
}
|
|
36136
|
+
],
|
|
36137
|
+
selectionSet: {
|
|
36138
|
+
kind: "SelectionSet",
|
|
36139
|
+
selections: [
|
|
36140
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36141
|
+
{
|
|
36142
|
+
kind: "Field",
|
|
36143
|
+
name: { kind: "Name", value: "permissions" },
|
|
36144
|
+
selectionSet: {
|
|
36145
|
+
kind: "SelectionSet",
|
|
36146
|
+
selections: [
|
|
36147
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36148
|
+
{ kind: "Field", name: { kind: "Name", value: "grant" } },
|
|
36149
|
+
{ kind: "Field", name: { kind: "Name", value: "nonce" } },
|
|
36150
|
+
{
|
|
36151
|
+
kind: "Field",
|
|
36152
|
+
name: { kind: "Name", value: "signature" }
|
|
36153
|
+
},
|
|
36154
|
+
{
|
|
36155
|
+
kind: "Field",
|
|
36156
|
+
name: { kind: "Name", value: "startBlock" }
|
|
36157
|
+
},
|
|
36158
|
+
{
|
|
36159
|
+
kind: "Field",
|
|
36160
|
+
name: { kind: "Name", value: "endBlock" }
|
|
36161
|
+
},
|
|
36162
|
+
{
|
|
36163
|
+
kind: "Field",
|
|
36164
|
+
name: { kind: "Name", value: "addedAtBlock" }
|
|
36165
|
+
},
|
|
36166
|
+
{
|
|
36167
|
+
kind: "Field",
|
|
36168
|
+
name: { kind: "Name", value: "addedAtTimestamp" }
|
|
36169
|
+
},
|
|
36170
|
+
{
|
|
36171
|
+
kind: "Field",
|
|
36172
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36173
|
+
},
|
|
36174
|
+
{
|
|
36175
|
+
kind: "Field",
|
|
36176
|
+
name: { kind: "Name", value: "grantee" },
|
|
36177
|
+
selectionSet: {
|
|
36178
|
+
kind: "SelectionSet",
|
|
36179
|
+
selections: [
|
|
36180
|
+
{
|
|
36181
|
+
kind: "Field",
|
|
36182
|
+
name: { kind: "Name", value: "id" }
|
|
36183
|
+
},
|
|
36184
|
+
{
|
|
36185
|
+
kind: "Field",
|
|
36186
|
+
name: { kind: "Name", value: "address" }
|
|
36187
|
+
}
|
|
36188
|
+
]
|
|
36189
|
+
}
|
|
36190
|
+
},
|
|
36191
|
+
{
|
|
36192
|
+
kind: "Field",
|
|
36193
|
+
name: { kind: "Name", value: "filePermissions" },
|
|
36194
|
+
selectionSet: {
|
|
36195
|
+
kind: "SelectionSet",
|
|
36196
|
+
selections: [
|
|
36197
|
+
{
|
|
36198
|
+
kind: "Field",
|
|
36199
|
+
name: { kind: "Name", value: "file" },
|
|
36200
|
+
selectionSet: {
|
|
36201
|
+
kind: "SelectionSet",
|
|
36202
|
+
selections: [
|
|
36203
|
+
{
|
|
36204
|
+
kind: "Field",
|
|
36205
|
+
name: { kind: "Name", value: "id" }
|
|
36206
|
+
},
|
|
36207
|
+
{
|
|
36208
|
+
kind: "Field",
|
|
36209
|
+
name: { kind: "Name", value: "url" }
|
|
36210
|
+
}
|
|
36211
|
+
]
|
|
36212
|
+
}
|
|
36213
|
+
}
|
|
36214
|
+
]
|
|
36215
|
+
}
|
|
36216
|
+
}
|
|
36217
|
+
]
|
|
36218
|
+
}
|
|
36219
|
+
}
|
|
36220
|
+
]
|
|
36221
|
+
}
|
|
36222
|
+
}
|
|
36223
|
+
]
|
|
36224
|
+
}
|
|
36225
|
+
}
|
|
36226
|
+
]
|
|
36227
|
+
};
|
|
36228
|
+
GetUserTrustedServersDocument = {
|
|
36229
|
+
kind: "Document",
|
|
36230
|
+
definitions: [
|
|
36231
|
+
{
|
|
36232
|
+
kind: "OperationDefinition",
|
|
36233
|
+
operation: "query",
|
|
36234
|
+
name: { kind: "Name", value: "GetUserTrustedServers" },
|
|
36235
|
+
variableDefinitions: [
|
|
36236
|
+
{
|
|
36237
|
+
kind: "VariableDefinition",
|
|
36238
|
+
variable: {
|
|
36239
|
+
kind: "Variable",
|
|
36240
|
+
name: { kind: "Name", value: "userId" }
|
|
36241
|
+
},
|
|
36242
|
+
type: {
|
|
36243
|
+
kind: "NonNullType",
|
|
36244
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36245
|
+
}
|
|
36246
|
+
}
|
|
36247
|
+
],
|
|
36248
|
+
selectionSet: {
|
|
36249
|
+
kind: "SelectionSet",
|
|
36250
|
+
selections: [
|
|
36251
|
+
{
|
|
36252
|
+
kind: "Field",
|
|
36253
|
+
name: { kind: "Name", value: "user" },
|
|
36254
|
+
arguments: [
|
|
36255
|
+
{
|
|
36256
|
+
kind: "Argument",
|
|
36257
|
+
name: { kind: "Name", value: "id" },
|
|
36258
|
+
value: {
|
|
36259
|
+
kind: "Variable",
|
|
36260
|
+
name: { kind: "Name", value: "userId" }
|
|
36261
|
+
}
|
|
36262
|
+
}
|
|
36263
|
+
],
|
|
36264
|
+
selectionSet: {
|
|
36265
|
+
kind: "SelectionSet",
|
|
36266
|
+
selections: [
|
|
36267
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36268
|
+
{
|
|
36269
|
+
kind: "Field",
|
|
36270
|
+
name: { kind: "Name", value: "serverTrusts" },
|
|
36271
|
+
selectionSet: {
|
|
36272
|
+
kind: "SelectionSet",
|
|
36273
|
+
selections: [
|
|
36274
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36275
|
+
{
|
|
36276
|
+
kind: "Field",
|
|
36277
|
+
name: { kind: "Name", value: "server" },
|
|
36278
|
+
selectionSet: {
|
|
36279
|
+
kind: "SelectionSet",
|
|
36280
|
+
selections: [
|
|
36281
|
+
{
|
|
36282
|
+
kind: "Field",
|
|
36283
|
+
name: { kind: "Name", value: "id" }
|
|
36284
|
+
},
|
|
36285
|
+
{
|
|
36286
|
+
kind: "Field",
|
|
36287
|
+
name: { kind: "Name", value: "serverAddress" }
|
|
36288
|
+
},
|
|
36289
|
+
{
|
|
36290
|
+
kind: "Field",
|
|
36291
|
+
name: { kind: "Name", value: "url" }
|
|
36292
|
+
},
|
|
36293
|
+
{
|
|
36294
|
+
kind: "Field",
|
|
36295
|
+
name: { kind: "Name", value: "publicKey" }
|
|
36296
|
+
}
|
|
36297
|
+
]
|
|
36298
|
+
}
|
|
36299
|
+
},
|
|
36300
|
+
{
|
|
36301
|
+
kind: "Field",
|
|
36302
|
+
name: { kind: "Name", value: "trustedAt" }
|
|
36303
|
+
},
|
|
36304
|
+
{
|
|
36305
|
+
kind: "Field",
|
|
36306
|
+
name: { kind: "Name", value: "trustedAtBlock" }
|
|
36307
|
+
},
|
|
36308
|
+
{
|
|
36309
|
+
kind: "Field",
|
|
36310
|
+
name: { kind: "Name", value: "untrustedAtBlock" }
|
|
36311
|
+
},
|
|
36312
|
+
{
|
|
36313
|
+
kind: "Field",
|
|
36314
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36315
|
+
}
|
|
36316
|
+
]
|
|
36317
|
+
}
|
|
36318
|
+
}
|
|
36319
|
+
]
|
|
36320
|
+
}
|
|
36321
|
+
}
|
|
36322
|
+
]
|
|
36323
|
+
}
|
|
36324
|
+
}
|
|
36325
|
+
]
|
|
36326
|
+
};
|
|
36327
|
+
GetUserFilesDocument = {
|
|
36328
|
+
kind: "Document",
|
|
36329
|
+
definitions: [
|
|
36330
|
+
{
|
|
36331
|
+
kind: "OperationDefinition",
|
|
36332
|
+
operation: "query",
|
|
36333
|
+
name: { kind: "Name", value: "GetUserFiles" },
|
|
36334
|
+
variableDefinitions: [
|
|
36335
|
+
{
|
|
36336
|
+
kind: "VariableDefinition",
|
|
36337
|
+
variable: {
|
|
36338
|
+
kind: "Variable",
|
|
36339
|
+
name: { kind: "Name", value: "userId" }
|
|
36340
|
+
},
|
|
36341
|
+
type: {
|
|
36342
|
+
kind: "NonNullType",
|
|
36343
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36344
|
+
}
|
|
36345
|
+
}
|
|
36346
|
+
],
|
|
36347
|
+
selectionSet: {
|
|
36348
|
+
kind: "SelectionSet",
|
|
36349
|
+
selections: [
|
|
36350
|
+
{
|
|
36351
|
+
kind: "Field",
|
|
36352
|
+
name: { kind: "Name", value: "user" },
|
|
36353
|
+
arguments: [
|
|
36354
|
+
{
|
|
36355
|
+
kind: "Argument",
|
|
36356
|
+
name: { kind: "Name", value: "id" },
|
|
36357
|
+
value: {
|
|
36358
|
+
kind: "Variable",
|
|
36359
|
+
name: { kind: "Name", value: "userId" }
|
|
36360
|
+
}
|
|
36361
|
+
}
|
|
36362
|
+
],
|
|
36363
|
+
selectionSet: {
|
|
36364
|
+
kind: "SelectionSet",
|
|
36365
|
+
selections: [
|
|
36366
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36367
|
+
{
|
|
36368
|
+
kind: "Field",
|
|
36369
|
+
name: { kind: "Name", value: "files" },
|
|
36370
|
+
selectionSet: {
|
|
36371
|
+
kind: "SelectionSet",
|
|
36372
|
+
selections: [
|
|
36373
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36374
|
+
{ kind: "Field", name: { kind: "Name", value: "url" } },
|
|
36375
|
+
{
|
|
36376
|
+
kind: "Field",
|
|
36377
|
+
name: { kind: "Name", value: "schemaId" }
|
|
36378
|
+
},
|
|
36379
|
+
{
|
|
36380
|
+
kind: "Field",
|
|
36381
|
+
name: { kind: "Name", value: "addedAtBlock" }
|
|
36382
|
+
},
|
|
36383
|
+
{
|
|
36384
|
+
kind: "Field",
|
|
36385
|
+
name: { kind: "Name", value: "addedAtTimestamp" }
|
|
36386
|
+
},
|
|
36387
|
+
{
|
|
36388
|
+
kind: "Field",
|
|
36389
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36390
|
+
},
|
|
36391
|
+
{
|
|
36392
|
+
kind: "Field",
|
|
36393
|
+
name: { kind: "Name", value: "owner" },
|
|
36394
|
+
selectionSet: {
|
|
36395
|
+
kind: "SelectionSet",
|
|
36396
|
+
selections: [
|
|
36397
|
+
{
|
|
36398
|
+
kind: "Field",
|
|
36399
|
+
name: { kind: "Name", value: "id" }
|
|
36400
|
+
}
|
|
36401
|
+
]
|
|
36402
|
+
}
|
|
36403
|
+
}
|
|
36404
|
+
]
|
|
36405
|
+
}
|
|
36406
|
+
}
|
|
36407
|
+
]
|
|
36408
|
+
}
|
|
36409
|
+
}
|
|
36410
|
+
]
|
|
36411
|
+
}
|
|
36412
|
+
}
|
|
36413
|
+
]
|
|
36414
|
+
};
|
|
36415
|
+
GetFileProofsDocument = {
|
|
36416
|
+
kind: "Document",
|
|
36417
|
+
definitions: [
|
|
36418
|
+
{
|
|
36419
|
+
kind: "OperationDefinition",
|
|
36420
|
+
operation: "query",
|
|
36421
|
+
name: { kind: "Name", value: "GetFileProofs" },
|
|
36422
|
+
variableDefinitions: [
|
|
36423
|
+
{
|
|
36424
|
+
kind: "VariableDefinition",
|
|
36425
|
+
variable: {
|
|
36426
|
+
kind: "Variable",
|
|
36427
|
+
name: { kind: "Name", value: "fileIds" }
|
|
36428
|
+
},
|
|
36429
|
+
type: {
|
|
36430
|
+
kind: "NonNullType",
|
|
36431
|
+
type: {
|
|
36432
|
+
kind: "ListType",
|
|
36433
|
+
type: {
|
|
36434
|
+
kind: "NonNullType",
|
|
36435
|
+
type: {
|
|
36436
|
+
kind: "NamedType",
|
|
36437
|
+
name: { kind: "Name", value: "BigInt" }
|
|
36438
|
+
}
|
|
36439
|
+
}
|
|
36440
|
+
}
|
|
36441
|
+
}
|
|
36442
|
+
}
|
|
36443
|
+
],
|
|
36444
|
+
selectionSet: {
|
|
36445
|
+
kind: "SelectionSet",
|
|
36446
|
+
selections: [
|
|
36447
|
+
{
|
|
36448
|
+
kind: "Field",
|
|
36449
|
+
name: { kind: "Name", value: "dataRegistryProofs" },
|
|
36450
|
+
arguments: [
|
|
36451
|
+
{
|
|
36452
|
+
kind: "Argument",
|
|
36453
|
+
name: { kind: "Name", value: "where" },
|
|
36454
|
+
value: {
|
|
36455
|
+
kind: "ObjectValue",
|
|
36456
|
+
fields: [
|
|
36457
|
+
{
|
|
36458
|
+
kind: "ObjectField",
|
|
36459
|
+
name: { kind: "Name", value: "fileId_in" },
|
|
36460
|
+
value: {
|
|
36461
|
+
kind: "Variable",
|
|
36462
|
+
name: { kind: "Name", value: "fileIds" }
|
|
36463
|
+
}
|
|
36464
|
+
}
|
|
36465
|
+
]
|
|
36466
|
+
}
|
|
36467
|
+
}
|
|
36468
|
+
],
|
|
36469
|
+
selectionSet: {
|
|
36470
|
+
kind: "SelectionSet",
|
|
36471
|
+
selections: [
|
|
36472
|
+
{ kind: "Field", name: { kind: "Name", value: "fileId" } },
|
|
36473
|
+
{
|
|
36474
|
+
kind: "Field",
|
|
36475
|
+
name: { kind: "Name", value: "dlp" },
|
|
36476
|
+
selectionSet: {
|
|
36477
|
+
kind: "SelectionSet",
|
|
36478
|
+
selections: [
|
|
36479
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } }
|
|
36480
|
+
]
|
|
36481
|
+
}
|
|
36482
|
+
}
|
|
36483
|
+
]
|
|
36484
|
+
}
|
|
36485
|
+
}
|
|
36486
|
+
]
|
|
36487
|
+
}
|
|
36488
|
+
}
|
|
36489
|
+
]
|
|
36490
|
+
};
|
|
36491
|
+
GetDlpDocument = {
|
|
36492
|
+
kind: "Document",
|
|
36493
|
+
definitions: [
|
|
36494
|
+
{
|
|
36495
|
+
kind: "OperationDefinition",
|
|
36496
|
+
operation: "query",
|
|
36497
|
+
name: { kind: "Name", value: "GetDLP" },
|
|
36498
|
+
variableDefinitions: [
|
|
36499
|
+
{
|
|
36500
|
+
kind: "VariableDefinition",
|
|
36501
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
36502
|
+
type: {
|
|
36503
|
+
kind: "NonNullType",
|
|
36504
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36505
|
+
}
|
|
36506
|
+
}
|
|
36507
|
+
],
|
|
36508
|
+
selectionSet: {
|
|
36509
|
+
kind: "SelectionSet",
|
|
36510
|
+
selections: [
|
|
36511
|
+
{
|
|
36512
|
+
kind: "Field",
|
|
36513
|
+
name: { kind: "Name", value: "dlp" },
|
|
36514
|
+
arguments: [
|
|
36515
|
+
{
|
|
36516
|
+
kind: "Argument",
|
|
36517
|
+
name: { kind: "Name", value: "id" },
|
|
36518
|
+
value: {
|
|
36519
|
+
kind: "Variable",
|
|
36520
|
+
name: { kind: "Name", value: "id" }
|
|
36521
|
+
}
|
|
36522
|
+
}
|
|
36523
|
+
],
|
|
36524
|
+
selectionSet: {
|
|
36525
|
+
kind: "SelectionSet",
|
|
36526
|
+
selections: [
|
|
36527
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36528
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36529
|
+
{ kind: "Field", name: { kind: "Name", value: "metadata" } },
|
|
36530
|
+
{ kind: "Field", name: { kind: "Name", value: "status" } },
|
|
36531
|
+
{ kind: "Field", name: { kind: "Name", value: "address" } },
|
|
36532
|
+
{ kind: "Field", name: { kind: "Name", value: "owner" } }
|
|
36533
|
+
]
|
|
36534
|
+
}
|
|
36535
|
+
}
|
|
36536
|
+
]
|
|
36537
|
+
}
|
|
36538
|
+
}
|
|
36539
|
+
]
|
|
36540
|
+
};
|
|
36541
|
+
GetSchemaDocument = {
|
|
36542
|
+
kind: "Document",
|
|
36543
|
+
definitions: [
|
|
36544
|
+
{
|
|
36545
|
+
kind: "OperationDefinition",
|
|
36546
|
+
operation: "query",
|
|
36547
|
+
name: { kind: "Name", value: "GetSchema" },
|
|
36548
|
+
variableDefinitions: [
|
|
36549
|
+
{
|
|
36550
|
+
kind: "VariableDefinition",
|
|
36551
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
36552
|
+
type: {
|
|
36553
|
+
kind: "NonNullType",
|
|
36554
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36555
|
+
}
|
|
36556
|
+
}
|
|
36557
|
+
],
|
|
36558
|
+
selectionSet: {
|
|
36559
|
+
kind: "SelectionSet",
|
|
36560
|
+
selections: [
|
|
36561
|
+
{
|
|
36562
|
+
kind: "Field",
|
|
36563
|
+
name: { kind: "Name", value: "schema" },
|
|
36564
|
+
arguments: [
|
|
36565
|
+
{
|
|
36566
|
+
kind: "Argument",
|
|
36567
|
+
name: { kind: "Name", value: "id" },
|
|
36568
|
+
value: {
|
|
36569
|
+
kind: "Variable",
|
|
36570
|
+
name: { kind: "Name", value: "id" }
|
|
36571
|
+
}
|
|
36572
|
+
}
|
|
36573
|
+
],
|
|
36574
|
+
selectionSet: {
|
|
36575
|
+
kind: "SelectionSet",
|
|
36576
|
+
selections: [
|
|
36577
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36578
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36579
|
+
{ kind: "Field", name: { kind: "Name", value: "dialect" } },
|
|
36580
|
+
{
|
|
36581
|
+
kind: "Field",
|
|
36582
|
+
name: { kind: "Name", value: "definitionUrl" }
|
|
36583
|
+
},
|
|
36584
|
+
{ kind: "Field", name: { kind: "Name", value: "createdAt" } },
|
|
36585
|
+
{
|
|
36586
|
+
kind: "Field",
|
|
36587
|
+
name: { kind: "Name", value: "createdAtBlock" }
|
|
36588
|
+
},
|
|
36589
|
+
{
|
|
36590
|
+
kind: "Field",
|
|
36591
|
+
name: { kind: "Name", value: "createdTxHash" }
|
|
36592
|
+
},
|
|
36593
|
+
{
|
|
36594
|
+
kind: "Field",
|
|
36595
|
+
name: { kind: "Name", value: "refiners" },
|
|
36596
|
+
selectionSet: {
|
|
36597
|
+
kind: "SelectionSet",
|
|
36598
|
+
selections: [
|
|
36599
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36600
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36601
|
+
{ kind: "Field", name: { kind: "Name", value: "owner" } }
|
|
36602
|
+
]
|
|
36603
|
+
}
|
|
36604
|
+
}
|
|
36605
|
+
]
|
|
36606
|
+
}
|
|
36607
|
+
}
|
|
36608
|
+
]
|
|
36609
|
+
}
|
|
36610
|
+
}
|
|
36611
|
+
]
|
|
36612
|
+
};
|
|
36613
|
+
ListSchemasDocument = {
|
|
36614
|
+
kind: "Document",
|
|
36615
|
+
definitions: [
|
|
36616
|
+
{
|
|
36617
|
+
kind: "OperationDefinition",
|
|
36618
|
+
operation: "query",
|
|
36619
|
+
name: { kind: "Name", value: "ListSchemas" },
|
|
36620
|
+
variableDefinitions: [
|
|
36621
|
+
{
|
|
36622
|
+
kind: "VariableDefinition",
|
|
36623
|
+
variable: {
|
|
36624
|
+
kind: "Variable",
|
|
36625
|
+
name: { kind: "Name", value: "first" }
|
|
36626
|
+
},
|
|
36627
|
+
type: {
|
|
36628
|
+
kind: "NonNullType",
|
|
36629
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }
|
|
36630
|
+
}
|
|
36631
|
+
},
|
|
36632
|
+
{
|
|
36633
|
+
kind: "VariableDefinition",
|
|
36634
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "skip" } },
|
|
36635
|
+
type: {
|
|
36636
|
+
kind: "NonNullType",
|
|
36637
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }
|
|
36638
|
+
}
|
|
36639
|
+
}
|
|
36640
|
+
],
|
|
36641
|
+
selectionSet: {
|
|
36642
|
+
kind: "SelectionSet",
|
|
36643
|
+
selections: [
|
|
36644
|
+
{
|
|
36645
|
+
kind: "Field",
|
|
36646
|
+
name: { kind: "Name", value: "schemas" },
|
|
36647
|
+
arguments: [
|
|
36648
|
+
{
|
|
36649
|
+
kind: "Argument",
|
|
36650
|
+
name: { kind: "Name", value: "first" },
|
|
36651
|
+
value: {
|
|
36652
|
+
kind: "Variable",
|
|
36653
|
+
name: { kind: "Name", value: "first" }
|
|
36654
|
+
}
|
|
36655
|
+
},
|
|
36656
|
+
{
|
|
36657
|
+
kind: "Argument",
|
|
36658
|
+
name: { kind: "Name", value: "skip" },
|
|
36659
|
+
value: {
|
|
36660
|
+
kind: "Variable",
|
|
36661
|
+
name: { kind: "Name", value: "skip" }
|
|
36662
|
+
}
|
|
36663
|
+
},
|
|
36664
|
+
{
|
|
36665
|
+
kind: "Argument",
|
|
36666
|
+
name: { kind: "Name", value: "orderBy" },
|
|
36667
|
+
value: { kind: "EnumValue", value: "createdAt" }
|
|
36668
|
+
},
|
|
36669
|
+
{
|
|
36670
|
+
kind: "Argument",
|
|
36671
|
+
name: { kind: "Name", value: "orderDirection" },
|
|
36672
|
+
value: { kind: "EnumValue", value: "desc" }
|
|
36673
|
+
}
|
|
36674
|
+
],
|
|
36675
|
+
selectionSet: {
|
|
36676
|
+
kind: "SelectionSet",
|
|
36677
|
+
selections: [
|
|
36678
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36679
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36680
|
+
{ kind: "Field", name: { kind: "Name", value: "dialect" } },
|
|
36681
|
+
{
|
|
36682
|
+
kind: "Field",
|
|
36683
|
+
name: { kind: "Name", value: "definitionUrl" }
|
|
36684
|
+
},
|
|
36685
|
+
{ kind: "Field", name: { kind: "Name", value: "createdAt" } },
|
|
36686
|
+
{
|
|
36687
|
+
kind: "Field",
|
|
36688
|
+
name: { kind: "Name", value: "createdAtBlock" }
|
|
36689
|
+
},
|
|
36690
|
+
{
|
|
36691
|
+
kind: "Field",
|
|
36692
|
+
name: { kind: "Name", value: "createdTxHash" }
|
|
36693
|
+
}
|
|
36694
|
+
]
|
|
36695
|
+
}
|
|
36696
|
+
}
|
|
36697
|
+
]
|
|
36698
|
+
}
|
|
36699
|
+
}
|
|
36700
|
+
]
|
|
36701
|
+
};
|
|
36702
|
+
CountSchemasDocument = {
|
|
36703
|
+
kind: "Document",
|
|
36704
|
+
definitions: [
|
|
36705
|
+
{
|
|
36706
|
+
kind: "OperationDefinition",
|
|
36707
|
+
operation: "query",
|
|
36708
|
+
name: { kind: "Name", value: "CountSchemas" },
|
|
36709
|
+
selectionSet: {
|
|
36710
|
+
kind: "SelectionSet",
|
|
36711
|
+
selections: [
|
|
36712
|
+
{
|
|
36713
|
+
kind: "Field",
|
|
36714
|
+
name: { kind: "Name", value: "schemas" },
|
|
36715
|
+
arguments: [
|
|
36716
|
+
{
|
|
36717
|
+
kind: "Argument",
|
|
36718
|
+
name: { kind: "Name", value: "first" },
|
|
36719
|
+
value: { kind: "IntValue", value: "1000" }
|
|
36720
|
+
}
|
|
36721
|
+
],
|
|
36722
|
+
selectionSet: {
|
|
36723
|
+
kind: "SelectionSet",
|
|
36724
|
+
selections: [
|
|
36725
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } }
|
|
36726
|
+
]
|
|
36727
|
+
}
|
|
36728
|
+
}
|
|
36729
|
+
]
|
|
36730
|
+
}
|
|
36731
|
+
}
|
|
36732
|
+
]
|
|
36733
|
+
};
|
|
35991
36734
|
}
|
|
35992
36735
|
});
|
|
35993
36736
|
|
|
@@ -36002,7 +36745,7 @@ async function fetchSchemaFromChain(context, schemaId) {
|
|
|
36002
36745
|
"DataRefinerRegistry"
|
|
36003
36746
|
);
|
|
36004
36747
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36005
|
-
const dataRefinerRegistry = (0,
|
|
36748
|
+
const dataRefinerRegistry = (0, import_viem7.getContract)({
|
|
36006
36749
|
address: dataRefinerRegistryAddress,
|
|
36007
36750
|
abi: dataRefinerRegistryAbi,
|
|
36008
36751
|
client: context.publicClient
|
|
@@ -36032,7 +36775,7 @@ async function fetchSchemaCountFromChain(context) {
|
|
|
36032
36775
|
"DataRefinerRegistry"
|
|
36033
36776
|
);
|
|
36034
36777
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36035
|
-
const dataRefinerRegistry = (0,
|
|
36778
|
+
const dataRefinerRegistry = (0, import_viem7.getContract)({
|
|
36036
36779
|
address: dataRefinerRegistryAddress,
|
|
36037
36780
|
abi: dataRefinerRegistryAbi,
|
|
36038
36781
|
client: context.publicClient
|
|
@@ -36040,222 +36783,20 @@ async function fetchSchemaCountFromChain(context) {
|
|
|
36040
36783
|
const count = await dataRefinerRegistry.read.schemasCount();
|
|
36041
36784
|
return Number(count);
|
|
36042
36785
|
}
|
|
36043
|
-
var
|
|
36786
|
+
var import_viem7;
|
|
36044
36787
|
var init_registry = __esm({
|
|
36045
36788
|
"src/utils/blockchain/registry.ts"() {
|
|
36046
36789
|
"use strict";
|
|
36047
|
-
|
|
36790
|
+
import_viem7 = require("viem");
|
|
36048
36791
|
init_addresses();
|
|
36049
36792
|
init_abi();
|
|
36050
36793
|
}
|
|
36051
36794
|
});
|
|
36052
36795
|
|
|
36053
|
-
// src/generated/subgraph.ts
|
|
36054
|
-
var GetSchemaDocument, ListSchemasDocument, CountSchemasDocument;
|
|
36055
|
-
var init_subgraph = __esm({
|
|
36056
|
-
"src/generated/subgraph.ts"() {
|
|
36057
|
-
"use strict";
|
|
36058
|
-
GetSchemaDocument = {
|
|
36059
|
-
kind: "Document",
|
|
36060
|
-
definitions: [
|
|
36061
|
-
{
|
|
36062
|
-
kind: "OperationDefinition",
|
|
36063
|
-
operation: "query",
|
|
36064
|
-
name: { kind: "Name", value: "GetSchema" },
|
|
36065
|
-
variableDefinitions: [
|
|
36066
|
-
{
|
|
36067
|
-
kind: "VariableDefinition",
|
|
36068
|
-
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
36069
|
-
type: {
|
|
36070
|
-
kind: "NonNullType",
|
|
36071
|
-
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36072
|
-
}
|
|
36073
|
-
}
|
|
36074
|
-
],
|
|
36075
|
-
selectionSet: {
|
|
36076
|
-
kind: "SelectionSet",
|
|
36077
|
-
selections: [
|
|
36078
|
-
{
|
|
36079
|
-
kind: "Field",
|
|
36080
|
-
name: { kind: "Name", value: "schema" },
|
|
36081
|
-
arguments: [
|
|
36082
|
-
{
|
|
36083
|
-
kind: "Argument",
|
|
36084
|
-
name: { kind: "Name", value: "id" },
|
|
36085
|
-
value: {
|
|
36086
|
-
kind: "Variable",
|
|
36087
|
-
name: { kind: "Name", value: "id" }
|
|
36088
|
-
}
|
|
36089
|
-
}
|
|
36090
|
-
],
|
|
36091
|
-
selectionSet: {
|
|
36092
|
-
kind: "SelectionSet",
|
|
36093
|
-
selections: [
|
|
36094
|
-
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36095
|
-
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36096
|
-
{ kind: "Field", name: { kind: "Name", value: "dialect" } },
|
|
36097
|
-
{
|
|
36098
|
-
kind: "Field",
|
|
36099
|
-
name: { kind: "Name", value: "definitionUrl" }
|
|
36100
|
-
},
|
|
36101
|
-
{ kind: "Field", name: { kind: "Name", value: "createdAt" } },
|
|
36102
|
-
{
|
|
36103
|
-
kind: "Field",
|
|
36104
|
-
name: { kind: "Name", value: "createdAtBlock" }
|
|
36105
|
-
},
|
|
36106
|
-
{
|
|
36107
|
-
kind: "Field",
|
|
36108
|
-
name: { kind: "Name", value: "createdTxHash" }
|
|
36109
|
-
},
|
|
36110
|
-
{
|
|
36111
|
-
kind: "Field",
|
|
36112
|
-
name: { kind: "Name", value: "refiners" },
|
|
36113
|
-
selectionSet: {
|
|
36114
|
-
kind: "SelectionSet",
|
|
36115
|
-
selections: [
|
|
36116
|
-
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36117
|
-
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36118
|
-
{ kind: "Field", name: { kind: "Name", value: "owner" } }
|
|
36119
|
-
]
|
|
36120
|
-
}
|
|
36121
|
-
}
|
|
36122
|
-
]
|
|
36123
|
-
}
|
|
36124
|
-
}
|
|
36125
|
-
]
|
|
36126
|
-
}
|
|
36127
|
-
}
|
|
36128
|
-
]
|
|
36129
|
-
};
|
|
36130
|
-
ListSchemasDocument = {
|
|
36131
|
-
kind: "Document",
|
|
36132
|
-
definitions: [
|
|
36133
|
-
{
|
|
36134
|
-
kind: "OperationDefinition",
|
|
36135
|
-
operation: "query",
|
|
36136
|
-
name: { kind: "Name", value: "ListSchemas" },
|
|
36137
|
-
variableDefinitions: [
|
|
36138
|
-
{
|
|
36139
|
-
kind: "VariableDefinition",
|
|
36140
|
-
variable: {
|
|
36141
|
-
kind: "Variable",
|
|
36142
|
-
name: { kind: "Name", value: "first" }
|
|
36143
|
-
},
|
|
36144
|
-
type: {
|
|
36145
|
-
kind: "NonNullType",
|
|
36146
|
-
type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }
|
|
36147
|
-
}
|
|
36148
|
-
},
|
|
36149
|
-
{
|
|
36150
|
-
kind: "VariableDefinition",
|
|
36151
|
-
variable: { kind: "Variable", name: { kind: "Name", value: "skip" } },
|
|
36152
|
-
type: {
|
|
36153
|
-
kind: "NonNullType",
|
|
36154
|
-
type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }
|
|
36155
|
-
}
|
|
36156
|
-
}
|
|
36157
|
-
],
|
|
36158
|
-
selectionSet: {
|
|
36159
|
-
kind: "SelectionSet",
|
|
36160
|
-
selections: [
|
|
36161
|
-
{
|
|
36162
|
-
kind: "Field",
|
|
36163
|
-
name: { kind: "Name", value: "schemas" },
|
|
36164
|
-
arguments: [
|
|
36165
|
-
{
|
|
36166
|
-
kind: "Argument",
|
|
36167
|
-
name: { kind: "Name", value: "first" },
|
|
36168
|
-
value: {
|
|
36169
|
-
kind: "Variable",
|
|
36170
|
-
name: { kind: "Name", value: "first" }
|
|
36171
|
-
}
|
|
36172
|
-
},
|
|
36173
|
-
{
|
|
36174
|
-
kind: "Argument",
|
|
36175
|
-
name: { kind: "Name", value: "skip" },
|
|
36176
|
-
value: {
|
|
36177
|
-
kind: "Variable",
|
|
36178
|
-
name: { kind: "Name", value: "skip" }
|
|
36179
|
-
}
|
|
36180
|
-
},
|
|
36181
|
-
{
|
|
36182
|
-
kind: "Argument",
|
|
36183
|
-
name: { kind: "Name", value: "orderBy" },
|
|
36184
|
-
value: { kind: "EnumValue", value: "createdAt" }
|
|
36185
|
-
},
|
|
36186
|
-
{
|
|
36187
|
-
kind: "Argument",
|
|
36188
|
-
name: { kind: "Name", value: "orderDirection" },
|
|
36189
|
-
value: { kind: "EnumValue", value: "desc" }
|
|
36190
|
-
}
|
|
36191
|
-
],
|
|
36192
|
-
selectionSet: {
|
|
36193
|
-
kind: "SelectionSet",
|
|
36194
|
-
selections: [
|
|
36195
|
-
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36196
|
-
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36197
|
-
{ kind: "Field", name: { kind: "Name", value: "dialect" } },
|
|
36198
|
-
{
|
|
36199
|
-
kind: "Field",
|
|
36200
|
-
name: { kind: "Name", value: "definitionUrl" }
|
|
36201
|
-
},
|
|
36202
|
-
{ kind: "Field", name: { kind: "Name", value: "createdAt" } },
|
|
36203
|
-
{
|
|
36204
|
-
kind: "Field",
|
|
36205
|
-
name: { kind: "Name", value: "createdAtBlock" }
|
|
36206
|
-
},
|
|
36207
|
-
{
|
|
36208
|
-
kind: "Field",
|
|
36209
|
-
name: { kind: "Name", value: "createdTxHash" }
|
|
36210
|
-
}
|
|
36211
|
-
]
|
|
36212
|
-
}
|
|
36213
|
-
}
|
|
36214
|
-
]
|
|
36215
|
-
}
|
|
36216
|
-
}
|
|
36217
|
-
]
|
|
36218
|
-
};
|
|
36219
|
-
CountSchemasDocument = {
|
|
36220
|
-
kind: "Document",
|
|
36221
|
-
definitions: [
|
|
36222
|
-
{
|
|
36223
|
-
kind: "OperationDefinition",
|
|
36224
|
-
operation: "query",
|
|
36225
|
-
name: { kind: "Name", value: "CountSchemas" },
|
|
36226
|
-
selectionSet: {
|
|
36227
|
-
kind: "SelectionSet",
|
|
36228
|
-
selections: [
|
|
36229
|
-
{
|
|
36230
|
-
kind: "Field",
|
|
36231
|
-
name: { kind: "Name", value: "schemas" },
|
|
36232
|
-
arguments: [
|
|
36233
|
-
{
|
|
36234
|
-
kind: "Argument",
|
|
36235
|
-
name: { kind: "Name", value: "first" },
|
|
36236
|
-
value: { kind: "IntValue", value: "1000" }
|
|
36237
|
-
}
|
|
36238
|
-
],
|
|
36239
|
-
selectionSet: {
|
|
36240
|
-
kind: "SelectionSet",
|
|
36241
|
-
selections: [
|
|
36242
|
-
{ kind: "Field", name: { kind: "Name", value: "id" } }
|
|
36243
|
-
]
|
|
36244
|
-
}
|
|
36245
|
-
}
|
|
36246
|
-
]
|
|
36247
|
-
}
|
|
36248
|
-
}
|
|
36249
|
-
]
|
|
36250
|
-
};
|
|
36251
|
-
}
|
|
36252
|
-
});
|
|
36253
|
-
|
|
36254
36796
|
// src/utils/urlResolver.ts
|
|
36255
|
-
async function fetchFromUrl(url) {
|
|
36797
|
+
async function fetchFromUrl(url, downloadRelayer) {
|
|
36256
36798
|
try {
|
|
36257
|
-
const
|
|
36258
|
-
const response = await fetchWithRetry(httpUrl, url);
|
|
36799
|
+
const response = await fetchWithRelayer(url, downloadRelayer);
|
|
36259
36800
|
if (!response.ok) {
|
|
36260
36801
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
36261
36802
|
}
|
|
@@ -36269,43 +36810,11 @@ async function fetchFromUrl(url) {
|
|
|
36269
36810
|
);
|
|
36270
36811
|
}
|
|
36271
36812
|
}
|
|
36272
|
-
function resolveToHttp(url) {
|
|
36273
|
-
if (url.startsWith("ipfs://")) {
|
|
36274
|
-
return convertIpfsUrl(url);
|
|
36275
|
-
}
|
|
36276
|
-
if (url.startsWith("ar://")) {
|
|
36277
|
-
const txId = url.replace("ar://", "");
|
|
36278
|
-
return `https://arweave.net/${txId}`;
|
|
36279
|
-
}
|
|
36280
|
-
if (url.startsWith("https://") || url.startsWith("http://")) {
|
|
36281
|
-
return url;
|
|
36282
|
-
}
|
|
36283
|
-
throw new Error(`Unsupported protocol in URL: ${url}`);
|
|
36284
|
-
}
|
|
36285
|
-
async function fetchWithRetry(httpUrl, originalUrl) {
|
|
36286
|
-
try {
|
|
36287
|
-
const response = await fetch(httpUrl);
|
|
36288
|
-
if (response.ok) return response;
|
|
36289
|
-
} catch {
|
|
36290
|
-
}
|
|
36291
|
-
if (originalUrl.startsWith("ipfs://")) {
|
|
36292
|
-
for (const gateway of IPFS_GATEWAYS) {
|
|
36293
|
-
try {
|
|
36294
|
-
const alternativeUrl = convertIpfsUrl(originalUrl, gateway);
|
|
36295
|
-
if (alternativeUrl === httpUrl) continue;
|
|
36296
|
-
const response = await fetch(alternativeUrl);
|
|
36297
|
-
if (response.ok) return response;
|
|
36298
|
-
} catch {
|
|
36299
|
-
}
|
|
36300
|
-
}
|
|
36301
|
-
}
|
|
36302
|
-
return fetch(httpUrl);
|
|
36303
|
-
}
|
|
36304
36813
|
var UrlResolutionError;
|
|
36305
36814
|
var init_urlResolver = __esm({
|
|
36306
36815
|
"src/utils/urlResolver.ts"() {
|
|
36307
36816
|
"use strict";
|
|
36308
|
-
|
|
36817
|
+
init_download();
|
|
36309
36818
|
UrlResolutionError = class extends Error {
|
|
36310
36819
|
constructor(message, url, cause) {
|
|
36311
36820
|
super(message);
|
|
@@ -36398,7 +36907,7 @@ var init_schemas = __esm({
|
|
|
36398
36907
|
dialect,
|
|
36399
36908
|
schema: schemaDefinition
|
|
36400
36909
|
};
|
|
36401
|
-
|
|
36910
|
+
validateDataSchemaAgainstMetaSchema(dataSchema);
|
|
36402
36911
|
if (!this.context.storageManager) {
|
|
36403
36912
|
if (this.context.validateStorageRequired) {
|
|
36404
36913
|
this.context.validateStorageRequired();
|
|
@@ -36501,13 +37010,16 @@ var init_schemas = __esm({
|
|
|
36501
37010
|
);
|
|
36502
37011
|
}
|
|
36503
37012
|
}
|
|
36504
|
-
const definition = await fetchFromUrl(
|
|
37013
|
+
const definition = await fetchFromUrl(
|
|
37014
|
+
metadata.definitionUrl,
|
|
37015
|
+
this.context.downloadRelayer
|
|
37016
|
+
);
|
|
36505
37017
|
if (!definition || typeof definition !== "object") {
|
|
36506
37018
|
throw new Error(
|
|
36507
37019
|
`Invalid schema definition format for schema ${schemaId}`
|
|
36508
37020
|
);
|
|
36509
37021
|
}
|
|
36510
|
-
|
|
37022
|
+
validateDataSchemaAgainstMetaSchema(definition);
|
|
36511
37023
|
const dataSchema = definition;
|
|
36512
37024
|
if (dataSchema.name !== metadata.name) {
|
|
36513
37025
|
throw new Error(
|
|
@@ -36840,9 +37352,12 @@ var init_schemas = __esm({
|
|
|
36840
37352
|
schemas.map(async (schema) => {
|
|
36841
37353
|
if (!schema.definitionUrl) return;
|
|
36842
37354
|
try {
|
|
36843
|
-
const definition = await fetchFromUrl(
|
|
37355
|
+
const definition = await fetchFromUrl(
|
|
37356
|
+
schema.definitionUrl,
|
|
37357
|
+
this.context.downloadRelayer
|
|
37358
|
+
);
|
|
36844
37359
|
if (definition && typeof definition === "object") {
|
|
36845
|
-
|
|
37360
|
+
validateDataSchemaAgainstMetaSchema(definition);
|
|
36846
37361
|
const dataSchema = definition;
|
|
36847
37362
|
schema.version = dataSchema.version;
|
|
36848
37363
|
schema.description = dataSchema.description;
|
|
@@ -37225,7 +37740,7 @@ __export(index_node_exports, {
|
|
|
37225
37740
|
storeGrantFile: () => storeGrantFile,
|
|
37226
37741
|
summarizeGrant: () => summarizeGrant,
|
|
37227
37742
|
validateDataAgainstSchema: () => validateDataAgainstSchema,
|
|
37228
|
-
|
|
37743
|
+
validateDataSchemaAgainstMetaSchema: () => validateDataSchemaAgainstMetaSchema,
|
|
37229
37744
|
validateGrant: () => validateGrant,
|
|
37230
37745
|
validateGrantExpiry: () => validateGrantExpiry,
|
|
37231
37746
|
validateGrantFile: () => validateGrantFile,
|
|
@@ -37550,6 +38065,7 @@ function parseReplicateOutput(response, typeGuard) {
|
|
|
37550
38065
|
init_errors();
|
|
37551
38066
|
|
|
37552
38067
|
// src/controllers/permissions.ts
|
|
38068
|
+
var import_viem6 = require("viem");
|
|
37553
38069
|
init_multicall();
|
|
37554
38070
|
init_transactionHandle();
|
|
37555
38071
|
init_errors();
|
|
@@ -37603,63 +38119,26 @@ async function storeGrantFile(grantFile, relayerUrl) {
|
|
|
37603
38119
|
);
|
|
37604
38120
|
}
|
|
37605
38121
|
}
|
|
37606
|
-
async function retrieveGrantFile(grantUrl, _relayerUrl) {
|
|
38122
|
+
async function retrieveGrantFile(grantUrl, _relayerUrl, downloadRelayer) {
|
|
37607
38123
|
try {
|
|
37608
38124
|
if (grantUrl.startsWith("http") && grantUrl.includes("/ipfs/")) {
|
|
37609
38125
|
console.warn(
|
|
37610
38126
|
`\u26A0\uFE0F Grant URL uses HTTP gateway format instead of ipfs:// protocol. Found: ${grantUrl}. Consider using ipfs:// format for better protocol-agnostic storage.`
|
|
37611
38127
|
);
|
|
37612
38128
|
}
|
|
37613
|
-
|
|
37614
|
-
|
|
37615
|
-
|
|
37616
|
-
|
|
37617
|
-
}
|
|
37618
|
-
|
|
37619
|
-
if (response.ok) {
|
|
37620
|
-
const text = await response.text();
|
|
37621
|
-
const grantFile = JSON.parse(text);
|
|
37622
|
-
if (validateGrantFile(grantFile)) {
|
|
37623
|
-
return grantFile;
|
|
37624
|
-
}
|
|
37625
|
-
}
|
|
37626
|
-
} catch (directFetchError) {
|
|
37627
|
-
console.warn(`Direct fetch failed for ${grantUrl}:`, directFetchError);
|
|
37628
|
-
}
|
|
38129
|
+
const { fetchWithRelayer: fetchWithRelayer2 } = await Promise.resolve().then(() => (init_download(), download_exports));
|
|
38130
|
+
const response = await fetchWithRelayer2(grantUrl, downloadRelayer);
|
|
38131
|
+
if (!response.ok) {
|
|
38132
|
+
throw new NetworkError(
|
|
38133
|
+
`Failed to retrieve grant file: HTTP ${response.status}`
|
|
38134
|
+
);
|
|
37629
38135
|
}
|
|
37630
|
-
const
|
|
37631
|
-
const
|
|
37632
|
-
if (
|
|
37633
|
-
|
|
37634
|
-
`https://gateway.pinata.cloud/ipfs/${ipfsHash}`,
|
|
37635
|
-
`https://ipfs.io/ipfs/${ipfsHash}`,
|
|
37636
|
-
`https://dweb.link/ipfs/${ipfsHash}`
|
|
37637
|
-
];
|
|
37638
|
-
for (const gatewayUrl of gateways) {
|
|
37639
|
-
try {
|
|
37640
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
37641
|
-
setTimeout(() => reject(new Error("Request timeout")), 1e4);
|
|
37642
|
-
});
|
|
37643
|
-
const response = await Promise.race([
|
|
37644
|
-
fetch(gatewayUrl),
|
|
37645
|
-
timeoutPromise
|
|
37646
|
-
]);
|
|
37647
|
-
if (response.ok) {
|
|
37648
|
-
const text = await response.text();
|
|
37649
|
-
const grantFile = JSON.parse(text);
|
|
37650
|
-
if (validateGrantFile(grantFile)) {
|
|
37651
|
-
return grantFile;
|
|
37652
|
-
}
|
|
37653
|
-
}
|
|
37654
|
-
} catch (gatewayError) {
|
|
37655
|
-
console.warn(`Gateway ${gatewayUrl} failed:`, gatewayError);
|
|
37656
|
-
continue;
|
|
37657
|
-
}
|
|
37658
|
-
}
|
|
38136
|
+
const text = await response.text();
|
|
38137
|
+
const grantFile = JSON.parse(text);
|
|
38138
|
+
if (!validateGrantFile(grantFile)) {
|
|
38139
|
+
throw new NetworkError(`Invalid grant file format from ${grantUrl}`);
|
|
37659
38140
|
}
|
|
37660
|
-
|
|
37661
|
-
`Failed to retrieve grant file from ${grantUrl}. Tried direct fetch${ipfsHash ? " and IPFS gateways" : ""}.`
|
|
37662
|
-
);
|
|
38141
|
+
return grantFile;
|
|
37663
38142
|
} catch (error) {
|
|
37664
38143
|
if (error instanceof NetworkError) {
|
|
37665
38144
|
throw error;
|
|
@@ -37725,6 +38204,7 @@ function validateGrantFile(data) {
|
|
|
37725
38204
|
}
|
|
37726
38205
|
|
|
37727
38206
|
// src/utils/grantValidation.ts
|
|
38207
|
+
var import_viem4 = require("viem");
|
|
37728
38208
|
var import_ajv2 = __toESM(require("ajv"), 1);
|
|
37729
38209
|
var import_ajv_formats2 = __toESM(require("ajv-formats"), 1);
|
|
37730
38210
|
|
|
@@ -37928,7 +38408,9 @@ function extractFieldFromBusinessError(error) {
|
|
|
37928
38408
|
return void 0;
|
|
37929
38409
|
}
|
|
37930
38410
|
function validateGranteeAccess(grantFile, requestingAddress) {
|
|
37931
|
-
|
|
38411
|
+
const normalizedGrantee = (0, import_viem4.getAddress)(grantFile.grantee);
|
|
38412
|
+
const normalizedRequesting = (0, import_viem4.getAddress)(requestingAddress);
|
|
38413
|
+
if (normalizedGrantee !== normalizedRequesting) {
|
|
37932
38414
|
throw new GranteeMismatchError(
|
|
37933
38415
|
"Permission denied: requesting address does not match grantee",
|
|
37934
38416
|
grantFile.grantee,
|
|
@@ -37959,6 +38441,7 @@ function validateOperationAccess(grantFile, requestedOperation) {
|
|
|
37959
38441
|
}
|
|
37960
38442
|
|
|
37961
38443
|
// src/utils/signatureCache.ts
|
|
38444
|
+
var import_viem5 = require("viem");
|
|
37962
38445
|
init_crypto_utils();
|
|
37963
38446
|
var SignatureCache = class {
|
|
37964
38447
|
static PREFIX = "vana_sig_";
|
|
@@ -38052,7 +38535,7 @@ var SignatureCache = class {
|
|
|
38052
38535
|
}
|
|
38053
38536
|
}
|
|
38054
38537
|
static getCacheKey(walletAddress, messageHash) {
|
|
38055
|
-
return `${this.PREFIX}${
|
|
38538
|
+
return `${this.PREFIX}${(0, import_viem5.getAddress)(walletAddress)}:${messageHash}`;
|
|
38056
38539
|
}
|
|
38057
38540
|
/**
|
|
38058
38541
|
* Generate a deterministic hash of a message object for cache key generation
|
|
@@ -39325,20 +39808,22 @@ var PermissionsController = class {
|
|
|
39325
39808
|
if (!userData || !userData.permissions?.length) {
|
|
39326
39809
|
return [];
|
|
39327
39810
|
}
|
|
39328
|
-
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
39329
|
-
|
|
39330
|
-
|
|
39331
|
-
|
|
39332
|
-
|
|
39333
|
-
|
|
39334
|
-
|
|
39335
|
-
|
|
39336
|
-
|
|
39337
|
-
|
|
39338
|
-
|
|
39339
|
-
|
|
39340
|
-
|
|
39341
|
-
|
|
39811
|
+
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
39812
|
+
(permission) => ({
|
|
39813
|
+
id: BigInt(permission.id),
|
|
39814
|
+
grantUrl: permission.grant,
|
|
39815
|
+
grantSignature: permission.signature,
|
|
39816
|
+
nonce: BigInt(permission.nonce),
|
|
39817
|
+
startBlock: BigInt(permission.startBlock),
|
|
39818
|
+
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
39819
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
|
|
39820
|
+
transactionHash: permission.transactionHash || "",
|
|
39821
|
+
grantor: userAddress,
|
|
39822
|
+
grantee: permission.grantee,
|
|
39823
|
+
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
39824
|
+
// Active if no end block or end block is 0
|
|
39825
|
+
})
|
|
39826
|
+
);
|
|
39342
39827
|
return onChainGrants.sort((a, b) => {
|
|
39343
39828
|
if (a.id < b.id) return 1;
|
|
39344
39829
|
if (a.id > b.id) return -1;
|
|
@@ -39416,14 +39901,16 @@ var PermissionsController = class {
|
|
|
39416
39901
|
);
|
|
39417
39902
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
39418
39903
|
const userAddress = this.context.walletClient.account?.address || await this.getUserAddress();
|
|
39904
|
+
const normalizedUserAddress = (0, import_viem6.getAddress)(userAddress);
|
|
39905
|
+
const normalizedServerAddress = (0, import_viem6.getAddress)(params.serverAddress);
|
|
39419
39906
|
const txHash = await this.context.walletClient.writeContract({
|
|
39420
39907
|
address: DataPortabilityServersAddress,
|
|
39421
39908
|
abi: DataPortabilityServersAbi,
|
|
39422
39909
|
functionName: "addAndTrustServerByManager",
|
|
39423
39910
|
args: [
|
|
39424
|
-
|
|
39911
|
+
normalizedUserAddress,
|
|
39425
39912
|
{
|
|
39426
|
-
serverAddress:
|
|
39913
|
+
serverAddress: normalizedServerAddress,
|
|
39427
39914
|
serverUrl: params.serverUrl,
|
|
39428
39915
|
publicKey: params.publicKey
|
|
39429
39916
|
}
|
|
@@ -39493,9 +39980,10 @@ var PermissionsController = class {
|
|
|
39493
39980
|
async submitAddAndTrustServerWithSignature(params) {
|
|
39494
39981
|
try {
|
|
39495
39982
|
const nonce = await this.getServersUserNonce();
|
|
39983
|
+
const serverAddress = (0, import_viem6.getAddress)(params.serverAddress);
|
|
39496
39984
|
const addAndTrustServerInput = {
|
|
39497
39985
|
nonce,
|
|
39498
|
-
serverAddress
|
|
39986
|
+
serverAddress,
|
|
39499
39987
|
publicKey: params.publicKey,
|
|
39500
39988
|
serverUrl: params.serverUrl
|
|
39501
39989
|
};
|
|
@@ -40300,11 +40788,13 @@ var PermissionsController = class {
|
|
|
40300
40788
|
"DataPortabilityGrantees"
|
|
40301
40789
|
);
|
|
40302
40790
|
const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
|
|
40791
|
+
const ownerAddress = (0, import_viem6.getAddress)(params.owner);
|
|
40792
|
+
const granteeAddress = (0, import_viem6.getAddress)(params.granteeAddress);
|
|
40303
40793
|
const txHash = await this.context.walletClient.writeContract({
|
|
40304
40794
|
address: DataPortabilityGranteesAddress,
|
|
40305
40795
|
abi: DataPortabilityGranteesAbi,
|
|
40306
40796
|
functionName: "registerGrantee",
|
|
40307
|
-
args: [
|
|
40797
|
+
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
40308
40798
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
40309
40799
|
chain: this.context.walletClient.chain || null
|
|
40310
40800
|
});
|
|
@@ -40331,10 +40821,12 @@ var PermissionsController = class {
|
|
|
40331
40821
|
*/
|
|
40332
40822
|
async submitRegisterGranteeWithSignature(params) {
|
|
40333
40823
|
const nonce = await this.getServersUserNonce();
|
|
40824
|
+
const owner = (0, import_viem6.getAddress)(params.owner);
|
|
40825
|
+
const granteeAddress = (0, import_viem6.getAddress)(params.granteeAddress);
|
|
40334
40826
|
const registerGranteeInput = {
|
|
40335
40827
|
nonce,
|
|
40336
|
-
owner
|
|
40337
|
-
granteeAddress
|
|
40828
|
+
owner,
|
|
40829
|
+
granteeAddress,
|
|
40338
40830
|
publicKey: params.publicKey
|
|
40339
40831
|
};
|
|
40340
40832
|
const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
|
|
@@ -41842,10 +42334,12 @@ var PermissionsController = class {
|
|
|
41842
42334
|
};
|
|
41843
42335
|
|
|
41844
42336
|
// src/controllers/data.ts
|
|
41845
|
-
var
|
|
42337
|
+
var import_viem8 = require("viem");
|
|
41846
42338
|
init_transactionHandle();
|
|
41847
42339
|
init_addresses();
|
|
41848
42340
|
init_abi();
|
|
42341
|
+
init_subgraph();
|
|
42342
|
+
var import_graphql2 = require("graphql");
|
|
41849
42343
|
|
|
41850
42344
|
// src/utils/encryption.ts
|
|
41851
42345
|
var DEFAULT_ENCRYPTION_SEED = "Please sign to retrieve your encryption key";
|
|
@@ -42269,34 +42763,16 @@ var DataController = class {
|
|
|
42269
42763
|
);
|
|
42270
42764
|
}
|
|
42271
42765
|
try {
|
|
42272
|
-
const query = `
|
|
42273
|
-
query GetUserFiles($userId: ID!) {
|
|
42274
|
-
user(id: $userId) {
|
|
42275
|
-
id
|
|
42276
|
-
files {
|
|
42277
|
-
id
|
|
42278
|
-
url
|
|
42279
|
-
schemaId
|
|
42280
|
-
addedAtBlock
|
|
42281
|
-
addedAtTimestamp
|
|
42282
|
-
transactionHash
|
|
42283
|
-
owner {
|
|
42284
|
-
id
|
|
42285
|
-
}
|
|
42286
|
-
}
|
|
42287
|
-
}
|
|
42288
|
-
}
|
|
42289
|
-
`;
|
|
42290
42766
|
const response = await fetch(endpoint, {
|
|
42291
42767
|
method: "POST",
|
|
42292
42768
|
headers: {
|
|
42293
42769
|
"Content-Type": "application/json"
|
|
42294
42770
|
},
|
|
42295
42771
|
body: JSON.stringify({
|
|
42296
|
-
query,
|
|
42772
|
+
query: (0, import_graphql2.print)(GetUserFilesDocument),
|
|
42297
42773
|
variables: {
|
|
42298
42774
|
userId: owner.toLowerCase()
|
|
42299
|
-
// Subgraph
|
|
42775
|
+
// Subgraph requires lowercase addresses
|
|
42300
42776
|
}
|
|
42301
42777
|
})
|
|
42302
42778
|
});
|
|
@@ -42343,7 +42819,10 @@ var DataController = class {
|
|
|
42343
42819
|
try {
|
|
42344
42820
|
proofMap = await this._fetchProofsFromSubgraph(fileIds, endpoint);
|
|
42345
42821
|
} catch (subgraphError) {
|
|
42346
|
-
console.debug(
|
|
42822
|
+
console.debug(
|
|
42823
|
+
"Failed to fetch proofs from subgraph, trying chain:",
|
|
42824
|
+
subgraphError
|
|
42825
|
+
);
|
|
42347
42826
|
proofMap = await this._fetchProofsFromChain(fileIds);
|
|
42348
42827
|
}
|
|
42349
42828
|
for (const file of userFiles) {
|
|
@@ -42366,30 +42845,20 @@ var DataController = class {
|
|
|
42366
42845
|
}
|
|
42367
42846
|
/**
|
|
42368
42847
|
* Fetches proof data for multiple files from the subgraph.
|
|
42369
|
-
*
|
|
42848
|
+
*
|
|
42370
42849
|
* @private
|
|
42371
42850
|
* @param fileIds - Array of file IDs to fetch proofs for
|
|
42372
42851
|
* @param subgraphUrl - The subgraph endpoint URL
|
|
42373
42852
|
* @returns Map of file IDs to their associated DLP IDs
|
|
42374
42853
|
*/
|
|
42375
42854
|
async _fetchProofsFromSubgraph(fileIds, subgraphUrl) {
|
|
42376
|
-
const query = `
|
|
42377
|
-
query GetFileProofs($fileIds: [BigInt!]!) {
|
|
42378
|
-
dataRegistryProofs(where: { fileId_in: $fileIds }) {
|
|
42379
|
-
fileId
|
|
42380
|
-
dlp {
|
|
42381
|
-
id
|
|
42382
|
-
}
|
|
42383
|
-
}
|
|
42384
|
-
}
|
|
42385
|
-
`;
|
|
42386
42855
|
const response = await fetch(subgraphUrl, {
|
|
42387
42856
|
method: "POST",
|
|
42388
42857
|
headers: {
|
|
42389
42858
|
"Content-Type": "application/json"
|
|
42390
42859
|
},
|
|
42391
42860
|
body: JSON.stringify({
|
|
42392
|
-
query,
|
|
42861
|
+
query: (0, import_graphql2.print)(GetFileProofsDocument),
|
|
42393
42862
|
variables: {
|
|
42394
42863
|
fileIds: fileIds.map((id) => id.toString())
|
|
42395
42864
|
}
|
|
@@ -42427,7 +42896,7 @@ var DataController = class {
|
|
|
42427
42896
|
/**
|
|
42428
42897
|
* Fetches proof data for multiple files from the blockchain.
|
|
42429
42898
|
* Falls back to this when subgraph is unavailable.
|
|
42430
|
-
*
|
|
42899
|
+
*
|
|
42431
42900
|
* @private
|
|
42432
42901
|
* @param fileIds - Array of file IDs to fetch proofs for
|
|
42433
42902
|
* @returns Map of file IDs to their associated DLP IDs
|
|
@@ -42493,25 +42962,13 @@ var DataController = class {
|
|
|
42493
42962
|
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
42494
42963
|
if (subgraphUrl) {
|
|
42495
42964
|
try {
|
|
42496
|
-
const query = `
|
|
42497
|
-
query GetDLP($id: ID!) {
|
|
42498
|
-
dlp(id: $id) {
|
|
42499
|
-
id
|
|
42500
|
-
name
|
|
42501
|
-
metadata
|
|
42502
|
-
status
|
|
42503
|
-
address
|
|
42504
|
-
owner
|
|
42505
|
-
}
|
|
42506
|
-
}
|
|
42507
|
-
`;
|
|
42508
42965
|
const response = await fetch(subgraphUrl, {
|
|
42509
42966
|
method: "POST",
|
|
42510
42967
|
headers: {
|
|
42511
42968
|
"Content-Type": "application/json"
|
|
42512
42969
|
},
|
|
42513
42970
|
body: JSON.stringify({
|
|
42514
|
-
query,
|
|
42971
|
+
query: (0, import_graphql2.print)(GetDlpDocument),
|
|
42515
42972
|
variables: {
|
|
42516
42973
|
id: dlpId.toString()
|
|
42517
42974
|
}
|
|
@@ -42534,7 +42991,7 @@ var DataController = class {
|
|
|
42534
42991
|
return {
|
|
42535
42992
|
id: parseInt(result.data.dlp.id),
|
|
42536
42993
|
name: result.data.dlp.name || "",
|
|
42537
|
-
metadata: result.data.dlp.metadata,
|
|
42994
|
+
metadata: result.data.dlp.metadata || void 0,
|
|
42538
42995
|
status: result.data.dlp.status ? parseInt(result.data.dlp.status) : void 0,
|
|
42539
42996
|
address: result.data.dlp.address,
|
|
42540
42997
|
owner: result.data.dlp.owner
|
|
@@ -42591,7 +43048,7 @@ var DataController = class {
|
|
|
42591
43048
|
* // Get first 10 DLPs
|
|
42592
43049
|
* const dlps = await vana.data.listDLPs({ limit: 10 });
|
|
42593
43050
|
* dlps.forEach(dlp => console.log(`${dlp.id}: ${dlp.name}`));
|
|
42594
|
-
*
|
|
43051
|
+
*
|
|
42595
43052
|
* // Get next page
|
|
42596
43053
|
* const nextPage = await vana.data.listDLPs({ limit: 10, offset: 10 });
|
|
42597
43054
|
* ```
|
|
@@ -42748,32 +43205,13 @@ var DataController = class {
|
|
|
42748
43205
|
async _getUserPermissionsViaSubgraph(params) {
|
|
42749
43206
|
const { user, subgraphUrl } = params;
|
|
42750
43207
|
try {
|
|
42751
|
-
const query = `
|
|
42752
|
-
query GetUserPermissions($userId: ID!) {
|
|
42753
|
-
user(id: $userId) {
|
|
42754
|
-
id
|
|
42755
|
-
permissions {
|
|
42756
|
-
id
|
|
42757
|
-
grant
|
|
42758
|
-
nonce
|
|
42759
|
-
signature
|
|
42760
|
-
addedAtBlock
|
|
42761
|
-
addedAtTimestamp
|
|
42762
|
-
transactionHash
|
|
42763
|
-
user {
|
|
42764
|
-
id
|
|
42765
|
-
}
|
|
42766
|
-
}
|
|
42767
|
-
}
|
|
42768
|
-
}
|
|
42769
|
-
`;
|
|
42770
43208
|
const response = await fetch(subgraphUrl, {
|
|
42771
43209
|
method: "POST",
|
|
42772
43210
|
headers: {
|
|
42773
43211
|
"Content-Type": "application/json"
|
|
42774
43212
|
},
|
|
42775
43213
|
body: JSON.stringify({
|
|
42776
|
-
query,
|
|
43214
|
+
query: (0, import_graphql2.print)(GetUserPermissionsDocument),
|
|
42777
43215
|
variables: {
|
|
42778
43216
|
userId: user.toLowerCase()
|
|
42779
43217
|
}
|
|
@@ -42802,7 +43240,7 @@ var DataController = class {
|
|
|
42802
43240
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
42803
43241
|
addedAtTimestamp: BigInt(permission.addedAtTimestamp),
|
|
42804
43242
|
transactionHash: permission.transactionHash,
|
|
42805
|
-
user
|
|
43243
|
+
user
|
|
42806
43244
|
})).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
|
|
42807
43245
|
} catch (error) {
|
|
42808
43246
|
console.error("Failed to query user permissions from subgraph:", error);
|
|
@@ -42974,36 +43412,16 @@ var DataController = class {
|
|
|
42974
43412
|
);
|
|
42975
43413
|
}
|
|
42976
43414
|
try {
|
|
42977
|
-
const query = `
|
|
42978
|
-
query GetUserTrustedServers($userId: ID!) {
|
|
42979
|
-
user(id: $userId) {
|
|
42980
|
-
id
|
|
42981
|
-
serverTrusts {
|
|
42982
|
-
id
|
|
42983
|
-
server {
|
|
42984
|
-
id
|
|
42985
|
-
serverAddress
|
|
42986
|
-
url
|
|
42987
|
-
publicKey
|
|
42988
|
-
}
|
|
42989
|
-
trustedAt
|
|
42990
|
-
trustedAtBlock
|
|
42991
|
-
untrustedAtBlock
|
|
42992
|
-
transactionHash
|
|
42993
|
-
}
|
|
42994
|
-
}
|
|
42995
|
-
}
|
|
42996
|
-
`;
|
|
42997
43415
|
const response = await fetch(graphqlEndpoint, {
|
|
42998
43416
|
method: "POST",
|
|
42999
43417
|
headers: {
|
|
43000
43418
|
"Content-Type": "application/json"
|
|
43001
43419
|
},
|
|
43002
43420
|
body: JSON.stringify({
|
|
43003
|
-
query,
|
|
43421
|
+
query: (0, import_graphql2.print)(GetUserTrustedServersDocument),
|
|
43004
43422
|
variables: {
|
|
43005
43423
|
userId: user.toLowerCase()
|
|
43006
|
-
// Subgraph
|
|
43424
|
+
// Subgraph requires lowercase addresses
|
|
43007
43425
|
}
|
|
43008
43426
|
})
|
|
43009
43427
|
});
|
|
@@ -43153,7 +43571,7 @@ var DataController = class {
|
|
|
43153
43571
|
}
|
|
43154
43572
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
43155
43573
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
43156
|
-
const dataRegistry = (0,
|
|
43574
|
+
const dataRegistry = (0, import_viem8.getContract)({
|
|
43157
43575
|
address: dataRegistryAddress,
|
|
43158
43576
|
abi: dataRegistryAbi,
|
|
43159
43577
|
client: this.context.walletClient
|
|
@@ -43204,7 +43622,7 @@ var DataController = class {
|
|
|
43204
43622
|
}
|
|
43205
43623
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
43206
43624
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
43207
|
-
const dataRegistry = (0,
|
|
43625
|
+
const dataRegistry = (0, import_viem8.getContract)({
|
|
43208
43626
|
address: dataRegistryAddress,
|
|
43209
43627
|
abi: dataRegistryAbi,
|
|
43210
43628
|
client: this.context.walletClient
|
|
@@ -43511,7 +43929,7 @@ var DataController = class {
|
|
|
43511
43929
|
"DataRefinerRegistry"
|
|
43512
43930
|
);
|
|
43513
43931
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
43514
|
-
const dataRefinerRegistry = (0,
|
|
43932
|
+
const dataRefinerRegistry = (0, import_viem8.getContract)({
|
|
43515
43933
|
address: dataRefinerRegistryAddress,
|
|
43516
43934
|
abi: dataRefinerRegistryAbi,
|
|
43517
43935
|
client: this.context.walletClient
|
|
@@ -43567,7 +43985,7 @@ var DataController = class {
|
|
|
43567
43985
|
"DataRefinerRegistry"
|
|
43568
43986
|
);
|
|
43569
43987
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
43570
|
-
const dataRefinerRegistry = (0,
|
|
43988
|
+
const dataRefinerRegistry = (0, import_viem8.getContract)({
|
|
43571
43989
|
address: dataRefinerRegistryAddress,
|
|
43572
43990
|
abi: dataRefinerRegistryAbi,
|
|
43573
43991
|
client: this.context.walletClient
|
|
@@ -43606,7 +44024,7 @@ var DataController = class {
|
|
|
43606
44024
|
"DataRefinerRegistry"
|
|
43607
44025
|
);
|
|
43608
44026
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
43609
|
-
const dataRefinerRegistry = (0,
|
|
44027
|
+
const dataRefinerRegistry = (0, import_viem8.getContract)({
|
|
43610
44028
|
address: dataRefinerRegistryAddress,
|
|
43611
44029
|
abi: dataRefinerRegistryAbi,
|
|
43612
44030
|
client: this.context.walletClient
|
|
@@ -43837,19 +44255,31 @@ var DataController = class {
|
|
|
43837
44255
|
return await this.submitFilePermission(fileId, account, publicKey);
|
|
43838
44256
|
}
|
|
43839
44257
|
/**
|
|
43840
|
-
* Submits a file permission transaction
|
|
44258
|
+
* Submits a file permission transaction to the blockchain.
|
|
43841
44259
|
*
|
|
43842
|
-
*
|
|
44260
|
+
* @remarks
|
|
44261
|
+
* This method supports gasless transactions via relayer callbacks when configured.
|
|
44262
|
+
* It encrypts the user's encryption key with the recipient's public key before submission.
|
|
43843
44263
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
43844
44264
|
*
|
|
43845
|
-
* @param fileId - The ID of the file to
|
|
43846
|
-
* @param account - The
|
|
43847
|
-
* @param publicKey - The public key
|
|
43848
|
-
*
|
|
44265
|
+
* @param fileId - The ID of the file to grant permission for
|
|
44266
|
+
* @param account - The recipient's wallet address that will access the file
|
|
44267
|
+
* @param publicKey - The recipient's public key for encryption.
|
|
44268
|
+
* Obtain via `vana.server.getIdentity(account).public_key`
|
|
44269
|
+
* @returns Promise resolving to TransactionHandle for tracking the transaction
|
|
44270
|
+
* @throws {Error} When chain ID is not available
|
|
44271
|
+
* @throws {Error} When encryption key generation fails
|
|
44272
|
+
* @throws {Error} When public key encryption fails
|
|
44273
|
+
*
|
|
43849
44274
|
* @example
|
|
43850
44275
|
* ```typescript
|
|
43851
|
-
* const
|
|
43852
|
-
*
|
|
44276
|
+
* const tx = await vana.data.submitFilePermission(
|
|
44277
|
+
* fileId,
|
|
44278
|
+
* "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
44279
|
+
* recipientPublicKey
|
|
44280
|
+
* );
|
|
44281
|
+
* const result = await tx.waitForEvents();
|
|
44282
|
+
* console.log(`Permission granted with ID: ${result.permissionId}`);
|
|
43853
44283
|
* ```
|
|
43854
44284
|
*/
|
|
43855
44285
|
async submitFilePermission(fileId, account, publicKey) {
|
|
@@ -43905,7 +44335,7 @@ var DataController = class {
|
|
|
43905
44335
|
}
|
|
43906
44336
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
43907
44337
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
43908
|
-
const dataRegistry = (0,
|
|
44338
|
+
const dataRegistry = (0, import_viem8.getContract)({
|
|
43909
44339
|
address: dataRegistryAddress,
|
|
43910
44340
|
abi: dataRegistryAbi,
|
|
43911
44341
|
client: this.context.walletClient
|
|
@@ -44001,7 +44431,11 @@ var DataController = class {
|
|
|
44001
44431
|
*/
|
|
44002
44432
|
async fetch(url) {
|
|
44003
44433
|
try {
|
|
44004
|
-
const
|
|
44434
|
+
const { fetchWithRelayer: fetchWithRelayer2 } = await Promise.resolve().then(() => (init_download(), download_exports));
|
|
44435
|
+
const response = await fetchWithRelayer2(
|
|
44436
|
+
url,
|
|
44437
|
+
this.context.downloadRelayer
|
|
44438
|
+
);
|
|
44005
44439
|
if (!response.ok) {
|
|
44006
44440
|
throw new Error(
|
|
44007
44441
|
`HTTP error! status: ${response.status} ${response.statusText}`
|
|
@@ -44067,12 +44501,9 @@ var DataController = class {
|
|
|
44067
44501
|
"https://ipfs.io/ipfs/"
|
|
44068
44502
|
];
|
|
44069
44503
|
const gateways = options?.gateways || this.context.ipfsGateways || defaultGateways;
|
|
44070
|
-
|
|
44071
|
-
|
|
44072
|
-
|
|
44073
|
-
} else if (url.startsWith("Qm") || url.startsWith("bafy")) {
|
|
44074
|
-
cid = url;
|
|
44075
|
-
} else {
|
|
44504
|
+
const { extractIpfsHash: extractIpfsHash2 } = await Promise.resolve().then(() => (init_ipfs(), ipfs_exports));
|
|
44505
|
+
const cid = extractIpfsHash2(url);
|
|
44506
|
+
if (!cid) {
|
|
44076
44507
|
throw new Error(
|
|
44077
44508
|
`Invalid IPFS URL format. Expected ipfs://... or a raw CID, got: ${url}`
|
|
44078
44509
|
);
|
|
@@ -44126,6 +44557,17 @@ var DataController = class {
|
|
|
44126
44557
|
});
|
|
44127
44558
|
}
|
|
44128
44559
|
}
|
|
44560
|
+
if (this.context.downloadRelayer && gateways.length > 0) {
|
|
44561
|
+
try {
|
|
44562
|
+
const relayerUrl = gateways[0].endsWith("/") ? `${gateways[0]}${cid}` : `${gateways[0]}/${cid}`;
|
|
44563
|
+
return await this.context.downloadRelayer.proxyDownload(relayerUrl);
|
|
44564
|
+
} catch (relayerError) {
|
|
44565
|
+
errors.push({
|
|
44566
|
+
gateway: "download-relayer",
|
|
44567
|
+
error: `Proxy failed: ${relayerError instanceof Error ? relayerError.message : "Unknown error"}`
|
|
44568
|
+
});
|
|
44569
|
+
}
|
|
44570
|
+
}
|
|
44129
44571
|
const errorDetails = errors.map((e) => `${e.gateway}: ${e.error}`).join("\n ");
|
|
44130
44572
|
throw new Error(
|
|
44131
44573
|
`Failed to fetch IPFS content ${cid} from all gateways:
|
|
@@ -44133,10 +44575,10 @@ var DataController = class {
|
|
|
44133
44575
|
);
|
|
44134
44576
|
}
|
|
44135
44577
|
/**
|
|
44136
|
-
* Validates a data schema against the Vana meta-schema.
|
|
44578
|
+
* Validates a data schema definition against the Vana meta-schema.
|
|
44137
44579
|
*
|
|
44138
|
-
* @param schema - The data schema to validate
|
|
44139
|
-
* @returns
|
|
44580
|
+
* @param schema - The data schema definition to validate
|
|
44581
|
+
* @returns The validated DataSchema
|
|
44140
44582
|
* @throws SchemaValidationError if invalid
|
|
44141
44583
|
* @example
|
|
44142
44584
|
* ```typescript
|
|
@@ -44153,11 +44595,11 @@ var DataController = class {
|
|
|
44153
44595
|
* }
|
|
44154
44596
|
* };
|
|
44155
44597
|
*
|
|
44156
|
-
* vana.data.
|
|
44598
|
+
* const validatedSchema = vana.data.validateDataSchemaAgainstMetaSchema(schema);
|
|
44157
44599
|
* ```
|
|
44158
44600
|
*/
|
|
44159
|
-
|
|
44160
|
-
return
|
|
44601
|
+
validateDataSchemaAgainstMetaSchema(schema) {
|
|
44602
|
+
return validateDataSchemaAgainstMetaSchema(schema);
|
|
44161
44603
|
}
|
|
44162
44604
|
/**
|
|
44163
44605
|
* Validates data against a JSON Schema from a data schema.
|
|
@@ -44190,9 +44632,9 @@ var DataController = class {
|
|
|
44190
44632
|
return validateDataAgainstSchema(data, schema);
|
|
44191
44633
|
}
|
|
44192
44634
|
/**
|
|
44193
|
-
* Fetches and validates a schema from a URL, then returns the parsed data schema.
|
|
44635
|
+
* Fetches and validates a data schema from a URL, then returns the parsed data schema.
|
|
44194
44636
|
*
|
|
44195
|
-
* @param url - The URL to fetch the schema from
|
|
44637
|
+
* @param url - The URL to fetch the data schema from
|
|
44196
44638
|
* @returns The validated data schema
|
|
44197
44639
|
* @throws SchemaValidationError if invalid or fetch fails
|
|
44198
44640
|
* @example
|
|
@@ -44217,6 +44659,73 @@ init_schemas();
|
|
|
44217
44659
|
|
|
44218
44660
|
// src/controllers/server.ts
|
|
44219
44661
|
init_errors();
|
|
44662
|
+
|
|
44663
|
+
// src/utils/operationHandle.ts
|
|
44664
|
+
init_errors();
|
|
44665
|
+
var OperationHandle = class {
|
|
44666
|
+
constructor(controller, id) {
|
|
44667
|
+
this.controller = controller;
|
|
44668
|
+
this.id = id;
|
|
44669
|
+
}
|
|
44670
|
+
_resultPromise;
|
|
44671
|
+
/**
|
|
44672
|
+
* Waits for the operation to complete and returns the result.
|
|
44673
|
+
*
|
|
44674
|
+
* @remarks
|
|
44675
|
+
* Results are memoized - multiple calls return the same promise.
|
|
44676
|
+
* The method polls the server at regular intervals until the operation
|
|
44677
|
+
* succeeds, fails, or times out. Returns the raw string result from the
|
|
44678
|
+
* server - callers are responsible for parsing if needed.
|
|
44679
|
+
*
|
|
44680
|
+
* @param options - Optional polling configuration
|
|
44681
|
+
* @returns The operation result as a string when completed
|
|
44682
|
+
* @throws {PersonalServerError} When the operation fails or times out
|
|
44683
|
+
* @example
|
|
44684
|
+
* ```typescript
|
|
44685
|
+
* const result = await handle.waitForResult({
|
|
44686
|
+
* timeout: 60000,
|
|
44687
|
+
* pollingInterval: 500
|
|
44688
|
+
* });
|
|
44689
|
+
* // If expecting JSON, parse it:
|
|
44690
|
+
* const data = JSON.parse(result);
|
|
44691
|
+
* ```
|
|
44692
|
+
*/
|
|
44693
|
+
async waitForResult(options) {
|
|
44694
|
+
if (!this._resultPromise) {
|
|
44695
|
+
this._resultPromise = this.pollForCompletion(options);
|
|
44696
|
+
}
|
|
44697
|
+
return this._resultPromise;
|
|
44698
|
+
}
|
|
44699
|
+
async pollForCompletion(options) {
|
|
44700
|
+
const startTime = Date.now();
|
|
44701
|
+
const timeout = options?.timeout ?? 3e4;
|
|
44702
|
+
const interval = options?.pollingInterval ?? 500;
|
|
44703
|
+
while (true) {
|
|
44704
|
+
const result = await this.controller.getOperation(
|
|
44705
|
+
this.id
|
|
44706
|
+
);
|
|
44707
|
+
if (result.status === "succeeded") {
|
|
44708
|
+
if (result.result) {
|
|
44709
|
+
return result.result;
|
|
44710
|
+
}
|
|
44711
|
+
throw new PersonalServerError(
|
|
44712
|
+
"Operation succeeded but returned no result"
|
|
44713
|
+
);
|
|
44714
|
+
}
|
|
44715
|
+
if (result.status === "failed") {
|
|
44716
|
+
throw new PersonalServerError(
|
|
44717
|
+
`Operation ${result.status}: ${result.result || "Unknown error"}`
|
|
44718
|
+
);
|
|
44719
|
+
}
|
|
44720
|
+
if (Date.now() - startTime > timeout) {
|
|
44721
|
+
throw new PersonalServerError(`Operation timed out after ${timeout}ms`);
|
|
44722
|
+
}
|
|
44723
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
44724
|
+
}
|
|
44725
|
+
}
|
|
44726
|
+
};
|
|
44727
|
+
|
|
44728
|
+
// src/controllers/server.ts
|
|
44220
44729
|
var ServerController = class {
|
|
44221
44730
|
constructor(context) {
|
|
44222
44731
|
this.context = context;
|
|
@@ -44298,26 +44807,29 @@ var ServerController = class {
|
|
|
44298
44807
|
}
|
|
44299
44808
|
}
|
|
44300
44809
|
/**
|
|
44301
|
-
* Creates
|
|
44810
|
+
* Creates a server operation and returns a handle for lifecycle management.
|
|
44302
44811
|
*
|
|
44303
44812
|
* @remarks
|
|
44304
|
-
* This method submits a computation request to the personal server
|
|
44305
|
-
*
|
|
44306
|
-
*
|
|
44813
|
+
* This method submits a computation request to the personal server and returns
|
|
44814
|
+
* an OperationHandle that provides Promise-based methods for waiting on results.
|
|
44815
|
+
* The handle pattern matches TransactionHandle for consistency across async operations.
|
|
44816
|
+
*
|
|
44817
|
+
* @param params - The operation request parameters
|
|
44307
44818
|
* @param params.permissionId - The permission ID authorizing this operation.
|
|
44308
|
-
* Obtain
|
|
44309
|
-
* @returns
|
|
44310
|
-
* @throws {PersonalServerError} When server request fails or parameters are invalid
|
|
44311
|
-
*
|
|
44312
|
-
* @throws {NetworkError} When personal server API communication fails.
|
|
44313
|
-
* Check server URL configuration and network connectivity.
|
|
44819
|
+
* Obtain via `vana.permissions.getUserPermissionGrantsOnChain()`.
|
|
44820
|
+
* @returns An OperationHandle providing access to the operation ID and result methods
|
|
44821
|
+
* @throws {PersonalServerError} When the server request fails or parameters are invalid
|
|
44822
|
+
* @throws {NetworkError} When personal server API communication fails
|
|
44314
44823
|
* @example
|
|
44315
44824
|
* ```typescript
|
|
44316
|
-
* const
|
|
44317
|
-
* permissionId: 123
|
|
44825
|
+
* const operation = await vana.server.createOperation({
|
|
44826
|
+
* permissionId: 123
|
|
44318
44827
|
* });
|
|
44319
|
-
*
|
|
44320
|
-
*
|
|
44828
|
+
* console.log(`Operation ID: ${operation.id}`);
|
|
44829
|
+
*
|
|
44830
|
+
* // Wait for completion
|
|
44831
|
+
* const result = await operation.waitForResult();
|
|
44832
|
+
* console.log("Result:", result);
|
|
44321
44833
|
* ```
|
|
44322
44834
|
*/
|
|
44323
44835
|
async createOperation(params) {
|
|
@@ -44333,7 +44845,7 @@ var ServerController = class {
|
|
|
44333
44845
|
};
|
|
44334
44846
|
console.debug("\u{1F50D} Debug - createOperation requestBody", requestBody);
|
|
44335
44847
|
const response = await this.makeRequest(requestBody);
|
|
44336
|
-
return response;
|
|
44848
|
+
return new OperationHandle(this, response.id);
|
|
44337
44849
|
} catch (error) {
|
|
44338
44850
|
if (error instanceof Error) {
|
|
44339
44851
|
if (error instanceof NetworkError || error instanceof SerializationError || error instanceof SignatureError || error instanceof PersonalServerError) {
|
|
@@ -44350,30 +44862,20 @@ var ServerController = class {
|
|
|
44350
44862
|
}
|
|
44351
44863
|
}
|
|
44352
44864
|
/**
|
|
44353
|
-
*
|
|
44865
|
+
* Retrieves the current status and result of a server operation.
|
|
44354
44866
|
*
|
|
44355
44867
|
* @remarks
|
|
44356
|
-
*
|
|
44357
|
-
*
|
|
44358
|
-
*
|
|
44359
|
-
*
|
|
44360
|
-
*
|
|
44361
|
-
*
|
|
44362
|
-
* @param operationId - The operation ID returned from the initial request submission
|
|
44363
|
-
* @returns A Promise that resolves to the current operation response with status and results
|
|
44364
|
-
* @throws {NetworkError} When the polling request fails or returns invalid data
|
|
44868
|
+
* Common status values: `starting`, `running`, `succeeded`, `failed`, `canceled`.
|
|
44869
|
+
* When status is `succeeded`, the result field contains the operation output.
|
|
44870
|
+
*
|
|
44871
|
+
* @param operationId - The ID of the operation to query
|
|
44872
|
+
* @returns The operation response containing status, result, and metadata
|
|
44873
|
+
* @throws {NetworkError} When the API request fails or returns invalid data
|
|
44365
44874
|
* @example
|
|
44366
44875
|
* ```typescript
|
|
44367
|
-
*
|
|
44368
|
-
*
|
|
44369
|
-
*
|
|
44370
|
-
* while (result.status === "processing") {
|
|
44371
|
-
* await new Promise(resolve => setTimeout(resolve, 1000));
|
|
44372
|
-
* result = await vana.server.getOperation(response.id);
|
|
44373
|
-
* }
|
|
44374
|
-
*
|
|
44375
|
-
* if (result.status === "succeeded") {
|
|
44376
|
-
* console.log("Computation completed:", result.output);
|
|
44876
|
+
* const status = await vana.server.getOperation(operationId);
|
|
44877
|
+
* if (status.status === 'succeeded') {
|
|
44878
|
+
* console.log('Result:', JSON.parse(status.result));
|
|
44377
44879
|
* }
|
|
44378
44880
|
* ```
|
|
44379
44881
|
*/
|
|
@@ -44564,16 +45066,16 @@ var ServerController = class {
|
|
|
44564
45066
|
init_errors();
|
|
44565
45067
|
|
|
44566
45068
|
// src/contracts/contractController.ts
|
|
44567
|
-
var
|
|
45069
|
+
var import_viem11 = require("viem");
|
|
44568
45070
|
init_abi();
|
|
44569
45071
|
init_addresses();
|
|
44570
45072
|
|
|
44571
45073
|
// src/core/client.ts
|
|
44572
|
-
var
|
|
45074
|
+
var import_viem10 = require("viem");
|
|
44573
45075
|
|
|
44574
45076
|
// src/config/chains.ts
|
|
44575
|
-
var
|
|
44576
|
-
var mokshaTestnet = (0,
|
|
45077
|
+
var import_viem9 = require("viem");
|
|
45078
|
+
var mokshaTestnet = (0, import_viem9.defineChain)({
|
|
44577
45079
|
id: 14800,
|
|
44578
45080
|
caipNetworkId: "eip155:14800",
|
|
44579
45081
|
chainNamespace: "eip155",
|
|
@@ -44601,7 +45103,7 @@ var mokshaTestnet = (0, import_viem6.defineChain)({
|
|
|
44601
45103
|
contracts: {},
|
|
44602
45104
|
abis: {}
|
|
44603
45105
|
});
|
|
44604
|
-
var vanaMainnet = (0,
|
|
45106
|
+
var vanaMainnet = (0, import_viem9.defineChain)({
|
|
44605
45107
|
id: 1480,
|
|
44606
45108
|
caipNetworkId: "eip155:1480",
|
|
44607
45109
|
chainNamespace: "eip155",
|
|
@@ -44648,9 +45150,9 @@ var createClient = (chainId = mokshaTestnet.id) => {
|
|
|
44648
45150
|
if (!chain) {
|
|
44649
45151
|
throw new Error(`Chain ${chainId} not found`);
|
|
44650
45152
|
}
|
|
44651
|
-
_client = (0,
|
|
45153
|
+
_client = (0, import_viem10.createPublicClient)({
|
|
44652
45154
|
chain,
|
|
44653
|
-
transport: (0,
|
|
45155
|
+
transport: (0, import_viem10.http)()
|
|
44654
45156
|
});
|
|
44655
45157
|
}
|
|
44656
45158
|
return _client;
|
|
@@ -44667,7 +45169,7 @@ function getContractController(contract, client = createClient()) {
|
|
|
44667
45169
|
const cacheKey = createCacheKey(contract, chainId);
|
|
44668
45170
|
let controller = contractCache.get(cacheKey);
|
|
44669
45171
|
if (!controller) {
|
|
44670
|
-
controller = (0,
|
|
45172
|
+
controller = (0, import_viem11.getContract)({
|
|
44671
45173
|
address: getContractAddress(chainId, contract),
|
|
44672
45174
|
abi: getAbi(contract),
|
|
44673
45175
|
client
|
|
@@ -46263,7 +46765,7 @@ var StorageManager = class {
|
|
|
46263
46765
|
};
|
|
46264
46766
|
|
|
46265
46767
|
// src/core.ts
|
|
46266
|
-
var
|
|
46768
|
+
var import_viem12 = require("viem");
|
|
46267
46769
|
|
|
46268
46770
|
// src/chains/definitions.ts
|
|
46269
46771
|
var vanaMainnet2 = {
|
|
@@ -46379,6 +46881,7 @@ var VanaCore = class {
|
|
|
46379
46881
|
/** Handles environment-specific operations like encryption and file systems. */
|
|
46380
46882
|
platform;
|
|
46381
46883
|
relayerCallbacks;
|
|
46884
|
+
downloadRelayer;
|
|
46382
46885
|
storageManager;
|
|
46383
46886
|
hasRequiredStorage;
|
|
46384
46887
|
ipfsGateways;
|
|
@@ -46408,6 +46911,7 @@ var VanaCore = class {
|
|
|
46408
46911
|
this.platform = platform;
|
|
46409
46912
|
this.validateConfig(config);
|
|
46410
46913
|
this.relayerCallbacks = config.relayerCallbacks;
|
|
46914
|
+
this.downloadRelayer = config.downloadRelayer;
|
|
46411
46915
|
this.ipfsGateways = config.ipfsGateways;
|
|
46412
46916
|
this.defaultPersonalServerUrl = config.defaultPersonalServerUrl;
|
|
46413
46917
|
this.hasRequiredStorage = hasStorageConfig(config);
|
|
@@ -46441,9 +46945,9 @@ var VanaCore = class {
|
|
|
46441
46945
|
`Unsupported chain ID: ${config.chainId}`
|
|
46442
46946
|
);
|
|
46443
46947
|
}
|
|
46444
|
-
walletClient = (0,
|
|
46948
|
+
walletClient = (0, import_viem12.createWalletClient)({
|
|
46445
46949
|
chain,
|
|
46446
|
-
transport: (0,
|
|
46950
|
+
transport: (0, import_viem12.http)(config.rpcUrl || chain.rpcUrls.default.http[0]),
|
|
46447
46951
|
account: config.account
|
|
46448
46952
|
});
|
|
46449
46953
|
} else {
|
|
@@ -46451,9 +46955,9 @@ var VanaCore = class {
|
|
|
46451
46955
|
"Invalid configuration: must be either WalletConfig or ChainConfig"
|
|
46452
46956
|
);
|
|
46453
46957
|
}
|
|
46454
|
-
const publicClient = (0,
|
|
46958
|
+
const publicClient = (0, import_viem12.createPublicClient)({
|
|
46455
46959
|
chain: walletClient.chain,
|
|
46456
|
-
transport: (0,
|
|
46960
|
+
transport: (0, import_viem12.http)()
|
|
46457
46961
|
});
|
|
46458
46962
|
const chainConfig = getChainConfig(walletClient.chain.id);
|
|
46459
46963
|
const subgraphUrl = config.subgraphUrl || chainConfig?.subgraphUrl;
|
|
@@ -46463,6 +46967,7 @@ var VanaCore = class {
|
|
|
46463
46967
|
applicationClient: walletClient,
|
|
46464
46968
|
// Using same wallet for now
|
|
46465
46969
|
relayerCallbacks: this.relayerCallbacks,
|
|
46970
|
+
downloadRelayer: this.downloadRelayer,
|
|
46466
46971
|
storageManager: this.storageManager,
|
|
46467
46972
|
subgraphUrl,
|
|
46468
46973
|
platform: this.platform,
|
|
@@ -46817,15 +47322,15 @@ init_errors();
|
|
|
46817
47322
|
init_schemas();
|
|
46818
47323
|
|
|
46819
47324
|
// src/utils/formatters.ts
|
|
46820
|
-
var
|
|
47325
|
+
var import_viem13 = require("viem");
|
|
46821
47326
|
function formatNumber(value) {
|
|
46822
47327
|
return Number(value);
|
|
46823
47328
|
}
|
|
46824
47329
|
function formatEth(wei, decimals = 4) {
|
|
46825
|
-
return (0,
|
|
47330
|
+
return (0, import_viem13.formatEther)(BigInt(wei.toString())).slice(0, decimals + 2);
|
|
46826
47331
|
}
|
|
46827
47332
|
function formatToken(amount, decimals = 18, displayDecimals = 4) {
|
|
46828
|
-
const value = (0,
|
|
47333
|
+
const value = (0, import_viem13.formatUnits)(BigInt(amount.toString()), decimals);
|
|
46829
47334
|
const parts = value.split(".");
|
|
46830
47335
|
if (parts.length === 1) {
|
|
46831
47336
|
return parts[0];
|
|
@@ -47260,7 +47765,7 @@ var CircuitBreaker = class {
|
|
|
47260
47765
|
};
|
|
47261
47766
|
|
|
47262
47767
|
// src/server/handler.ts
|
|
47263
|
-
var
|
|
47768
|
+
var import_viem14 = require("viem");
|
|
47264
47769
|
init_errors();
|
|
47265
47770
|
async function handleRelayerRequest(sdk, payload) {
|
|
47266
47771
|
const { typedData, signature, expectedUserAddress } = payload;
|
|
@@ -47271,7 +47776,7 @@ async function handleRelayerRequest(sdk, payload) {
|
|
|
47271
47776
|
message: typedData.message,
|
|
47272
47777
|
signature
|
|
47273
47778
|
});
|
|
47274
|
-
const signerAddress = await (0,
|
|
47779
|
+
const signerAddress = await (0, import_viem14.recoverTypedDataAddress)({
|
|
47275
47780
|
domain: typedData.domain,
|
|
47276
47781
|
types: typedData.types,
|
|
47277
47782
|
primaryType: typedData.primaryType,
|
|
@@ -47284,21 +47789,22 @@ async function handleRelayerRequest(sdk, payload) {
|
|
|
47284
47789
|
);
|
|
47285
47790
|
}
|
|
47286
47791
|
if (expectedUserAddress) {
|
|
47287
|
-
const normalizedSigner =
|
|
47288
|
-
const normalizedExpected =
|
|
47792
|
+
const normalizedSigner = (0, import_viem14.getAddress)(signerAddress);
|
|
47793
|
+
const normalizedExpected = (0, import_viem14.getAddress)(expectedUserAddress);
|
|
47289
47794
|
if (normalizedSigner !== normalizedExpected) {
|
|
47290
47795
|
throw new SignatureError(
|
|
47291
47796
|
`Security verification failed: Recovered signer address (${normalizedSigner}) does not match expected user address (${normalizedExpected}). This may be due to incorrect EIP-712 domain configuration.`
|
|
47292
47797
|
);
|
|
47293
47798
|
}
|
|
47294
47799
|
}
|
|
47295
|
-
|
|
47800
|
+
const primaryType = typedData.primaryType;
|
|
47801
|
+
switch (primaryType) {
|
|
47296
47802
|
case "Permission":
|
|
47297
47803
|
return sdk.permissions.submitSignedGrant(
|
|
47298
47804
|
typedData,
|
|
47299
47805
|
signature
|
|
47300
47806
|
);
|
|
47301
|
-
case "
|
|
47807
|
+
case "RevokePermission":
|
|
47302
47808
|
return sdk.permissions.submitSignedRevoke(
|
|
47303
47809
|
typedData,
|
|
47304
47810
|
signature
|
|
@@ -47854,7 +48360,7 @@ var index_node_default = Vana;
|
|
|
47854
48360
|
storeGrantFile,
|
|
47855
48361
|
summarizeGrant,
|
|
47856
48362
|
validateDataAgainstSchema,
|
|
47857
|
-
|
|
48363
|
+
validateDataSchemaAgainstMetaSchema,
|
|
47858
48364
|
validateGrant,
|
|
47859
48365
|
validateGrantExpiry,
|
|
47860
48366
|
validateGrantFile,
|