@opendatalabs/vana-sdk 0.1.0-alpha.2fd4542 → 0.1.0-alpha.321a1fe
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 +186 -45
- package/dist/index.browser.js +709 -212
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +740 -242
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +186 -45
- package/dist/index.node.d.ts +186 -45
- package/dist/index.node.js +715 -217
- package/dist/index.node.js.map +1 -1
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -3038,6 +3038,19 @@ var init_DataRegistryImplementation = __esm({
|
|
|
3038
3038
|
name: "Upgraded",
|
|
3039
3039
|
type: "event"
|
|
3040
3040
|
},
|
|
3041
|
+
{
|
|
3042
|
+
inputs: [],
|
|
3043
|
+
name: "DATA_PORTABILITY_ROLE",
|
|
3044
|
+
outputs: [
|
|
3045
|
+
{
|
|
3046
|
+
internalType: "bytes32",
|
|
3047
|
+
name: "",
|
|
3048
|
+
type: "bytes32"
|
|
3049
|
+
}
|
|
3050
|
+
],
|
|
3051
|
+
stateMutability: "view",
|
|
3052
|
+
type: "function"
|
|
3053
|
+
},
|
|
3041
3054
|
{
|
|
3042
3055
|
inputs: [],
|
|
3043
3056
|
name: "DEFAULT_ADMIN_ROLE",
|
|
@@ -3132,6 +3145,41 @@ var init_DataRegistryImplementation = __esm({
|
|
|
3132
3145
|
stateMutability: "nonpayable",
|
|
3133
3146
|
type: "function"
|
|
3134
3147
|
},
|
|
3148
|
+
{
|
|
3149
|
+
inputs: [
|
|
3150
|
+
{
|
|
3151
|
+
internalType: "uint256",
|
|
3152
|
+
name: "fileId",
|
|
3153
|
+
type: "uint256"
|
|
3154
|
+
},
|
|
3155
|
+
{
|
|
3156
|
+
components: [
|
|
3157
|
+
{
|
|
3158
|
+
internalType: "address",
|
|
3159
|
+
name: "account",
|
|
3160
|
+
type: "address"
|
|
3161
|
+
},
|
|
3162
|
+
{
|
|
3163
|
+
internalType: "string",
|
|
3164
|
+
name: "key",
|
|
3165
|
+
type: "string"
|
|
3166
|
+
}
|
|
3167
|
+
],
|
|
3168
|
+
internalType: "struct IDataRegistry.Permission[]",
|
|
3169
|
+
name: "permissions",
|
|
3170
|
+
type: "tuple[]"
|
|
3171
|
+
},
|
|
3172
|
+
{
|
|
3173
|
+
internalType: "uint256",
|
|
3174
|
+
name: "schemaId",
|
|
3175
|
+
type: "uint256"
|
|
3176
|
+
}
|
|
3177
|
+
],
|
|
3178
|
+
name: "addFilePermissionsAndSchema",
|
|
3179
|
+
outputs: [],
|
|
3180
|
+
stateMutability: "nonpayable",
|
|
3181
|
+
type: "function"
|
|
3182
|
+
},
|
|
3135
3183
|
{
|
|
3136
3184
|
inputs: [
|
|
3137
3185
|
{
|
|
@@ -36216,69 +36264,451 @@ var init_ipfs = __esm({
|
|
|
36216
36264
|
}
|
|
36217
36265
|
});
|
|
36218
36266
|
|
|
36219
|
-
// src/utils/blockchain/registry.ts
|
|
36220
|
-
import { getContract } from "viem";
|
|
36221
|
-
async function fetchSchemaFromChain(context, schemaId) {
|
|
36222
|
-
const chainId = context.walletClient.chain?.id;
|
|
36223
|
-
if (!chainId) {
|
|
36224
|
-
throw new Error("Chain ID not available");
|
|
36225
|
-
}
|
|
36226
|
-
const dataRefinerRegistryAddress = getContractAddress(
|
|
36227
|
-
chainId,
|
|
36228
|
-
"DataRefinerRegistry"
|
|
36229
|
-
);
|
|
36230
|
-
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36231
|
-
const dataRefinerRegistry = getContract({
|
|
36232
|
-
address: dataRefinerRegistryAddress,
|
|
36233
|
-
abi: dataRefinerRegistryAbi,
|
|
36234
|
-
client: context.publicClient
|
|
36235
|
-
});
|
|
36236
|
-
const schemaData = await dataRefinerRegistry.read.schemas([BigInt(schemaId)]);
|
|
36237
|
-
if (!schemaData) {
|
|
36238
|
-
throw new Error(`Schema with ID ${schemaId} not found`);
|
|
36239
|
-
}
|
|
36240
|
-
const schemaObj = schemaData;
|
|
36241
|
-
if (!schemaObj.name || !schemaObj.dialect || !schemaObj.definitionUrl) {
|
|
36242
|
-
throw new Error("Incomplete schema data");
|
|
36243
|
-
}
|
|
36244
|
-
return {
|
|
36245
|
-
id: schemaId,
|
|
36246
|
-
name: schemaObj.name,
|
|
36247
|
-
dialect: schemaObj.dialect,
|
|
36248
|
-
definitionUrl: schemaObj.definitionUrl
|
|
36249
|
-
};
|
|
36250
|
-
}
|
|
36251
|
-
async function fetchSchemaCountFromChain(context) {
|
|
36252
|
-
const chainId = context.walletClient.chain?.id;
|
|
36253
|
-
if (!chainId) {
|
|
36254
|
-
throw new Error("Chain ID not available");
|
|
36255
|
-
}
|
|
36256
|
-
const dataRefinerRegistryAddress = getContractAddress(
|
|
36257
|
-
chainId,
|
|
36258
|
-
"DataRefinerRegistry"
|
|
36259
|
-
);
|
|
36260
|
-
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36261
|
-
const dataRefinerRegistry = getContract({
|
|
36262
|
-
address: dataRefinerRegistryAddress,
|
|
36263
|
-
abi: dataRefinerRegistryAbi,
|
|
36264
|
-
client: context.publicClient
|
|
36265
|
-
});
|
|
36266
|
-
const count = await dataRefinerRegistry.read.schemasCount();
|
|
36267
|
-
return Number(count);
|
|
36268
|
-
}
|
|
36269
|
-
var init_registry = __esm({
|
|
36270
|
-
"src/utils/blockchain/registry.ts"() {
|
|
36271
|
-
"use strict";
|
|
36272
|
-
init_addresses();
|
|
36273
|
-
init_abi();
|
|
36274
|
-
}
|
|
36275
|
-
});
|
|
36276
|
-
|
|
36277
36267
|
// src/generated/subgraph.ts
|
|
36278
|
-
var GetSchemaDocument, ListSchemasDocument, CountSchemasDocument;
|
|
36268
|
+
var GetUserPermissionsDocument, GetUserTrustedServersDocument, GetUserFilesDocument, GetFileProofsDocument, GetDlpDocument, GetSchemaDocument, ListSchemasDocument, CountSchemasDocument;
|
|
36279
36269
|
var init_subgraph = __esm({
|
|
36280
36270
|
"src/generated/subgraph.ts"() {
|
|
36281
36271
|
"use strict";
|
|
36272
|
+
GetUserPermissionsDocument = {
|
|
36273
|
+
kind: "Document",
|
|
36274
|
+
definitions: [
|
|
36275
|
+
{
|
|
36276
|
+
kind: "OperationDefinition",
|
|
36277
|
+
operation: "query",
|
|
36278
|
+
name: { kind: "Name", value: "GetUserPermissions" },
|
|
36279
|
+
variableDefinitions: [
|
|
36280
|
+
{
|
|
36281
|
+
kind: "VariableDefinition",
|
|
36282
|
+
variable: {
|
|
36283
|
+
kind: "Variable",
|
|
36284
|
+
name: { kind: "Name", value: "userId" }
|
|
36285
|
+
},
|
|
36286
|
+
type: {
|
|
36287
|
+
kind: "NonNullType",
|
|
36288
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36289
|
+
}
|
|
36290
|
+
}
|
|
36291
|
+
],
|
|
36292
|
+
selectionSet: {
|
|
36293
|
+
kind: "SelectionSet",
|
|
36294
|
+
selections: [
|
|
36295
|
+
{
|
|
36296
|
+
kind: "Field",
|
|
36297
|
+
name: { kind: "Name", value: "user" },
|
|
36298
|
+
arguments: [
|
|
36299
|
+
{
|
|
36300
|
+
kind: "Argument",
|
|
36301
|
+
name: { kind: "Name", value: "id" },
|
|
36302
|
+
value: {
|
|
36303
|
+
kind: "Variable",
|
|
36304
|
+
name: { kind: "Name", value: "userId" }
|
|
36305
|
+
}
|
|
36306
|
+
}
|
|
36307
|
+
],
|
|
36308
|
+
selectionSet: {
|
|
36309
|
+
kind: "SelectionSet",
|
|
36310
|
+
selections: [
|
|
36311
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36312
|
+
{
|
|
36313
|
+
kind: "Field",
|
|
36314
|
+
name: { kind: "Name", value: "permissions" },
|
|
36315
|
+
selectionSet: {
|
|
36316
|
+
kind: "SelectionSet",
|
|
36317
|
+
selections: [
|
|
36318
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36319
|
+
{ kind: "Field", name: { kind: "Name", value: "grant" } },
|
|
36320
|
+
{ kind: "Field", name: { kind: "Name", value: "nonce" } },
|
|
36321
|
+
{
|
|
36322
|
+
kind: "Field",
|
|
36323
|
+
name: { kind: "Name", value: "signature" }
|
|
36324
|
+
},
|
|
36325
|
+
{
|
|
36326
|
+
kind: "Field",
|
|
36327
|
+
name: { kind: "Name", value: "startBlock" }
|
|
36328
|
+
},
|
|
36329
|
+
{
|
|
36330
|
+
kind: "Field",
|
|
36331
|
+
name: { kind: "Name", value: "endBlock" }
|
|
36332
|
+
},
|
|
36333
|
+
{
|
|
36334
|
+
kind: "Field",
|
|
36335
|
+
name: { kind: "Name", value: "addedAtBlock" }
|
|
36336
|
+
},
|
|
36337
|
+
{
|
|
36338
|
+
kind: "Field",
|
|
36339
|
+
name: { kind: "Name", value: "addedAtTimestamp" }
|
|
36340
|
+
},
|
|
36341
|
+
{
|
|
36342
|
+
kind: "Field",
|
|
36343
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36344
|
+
},
|
|
36345
|
+
{
|
|
36346
|
+
kind: "Field",
|
|
36347
|
+
name: { kind: "Name", value: "grantee" },
|
|
36348
|
+
selectionSet: {
|
|
36349
|
+
kind: "SelectionSet",
|
|
36350
|
+
selections: [
|
|
36351
|
+
{
|
|
36352
|
+
kind: "Field",
|
|
36353
|
+
name: { kind: "Name", value: "id" }
|
|
36354
|
+
},
|
|
36355
|
+
{
|
|
36356
|
+
kind: "Field",
|
|
36357
|
+
name: { kind: "Name", value: "address" }
|
|
36358
|
+
}
|
|
36359
|
+
]
|
|
36360
|
+
}
|
|
36361
|
+
},
|
|
36362
|
+
{
|
|
36363
|
+
kind: "Field",
|
|
36364
|
+
name: { kind: "Name", value: "filePermissions" },
|
|
36365
|
+
selectionSet: {
|
|
36366
|
+
kind: "SelectionSet",
|
|
36367
|
+
selections: [
|
|
36368
|
+
{
|
|
36369
|
+
kind: "Field",
|
|
36370
|
+
name: { kind: "Name", value: "file" },
|
|
36371
|
+
selectionSet: {
|
|
36372
|
+
kind: "SelectionSet",
|
|
36373
|
+
selections: [
|
|
36374
|
+
{
|
|
36375
|
+
kind: "Field",
|
|
36376
|
+
name: { kind: "Name", value: "id" }
|
|
36377
|
+
},
|
|
36378
|
+
{
|
|
36379
|
+
kind: "Field",
|
|
36380
|
+
name: { kind: "Name", value: "url" }
|
|
36381
|
+
}
|
|
36382
|
+
]
|
|
36383
|
+
}
|
|
36384
|
+
}
|
|
36385
|
+
]
|
|
36386
|
+
}
|
|
36387
|
+
}
|
|
36388
|
+
]
|
|
36389
|
+
}
|
|
36390
|
+
}
|
|
36391
|
+
]
|
|
36392
|
+
}
|
|
36393
|
+
}
|
|
36394
|
+
]
|
|
36395
|
+
}
|
|
36396
|
+
}
|
|
36397
|
+
]
|
|
36398
|
+
};
|
|
36399
|
+
GetUserTrustedServersDocument = {
|
|
36400
|
+
kind: "Document",
|
|
36401
|
+
definitions: [
|
|
36402
|
+
{
|
|
36403
|
+
kind: "OperationDefinition",
|
|
36404
|
+
operation: "query",
|
|
36405
|
+
name: { kind: "Name", value: "GetUserTrustedServers" },
|
|
36406
|
+
variableDefinitions: [
|
|
36407
|
+
{
|
|
36408
|
+
kind: "VariableDefinition",
|
|
36409
|
+
variable: {
|
|
36410
|
+
kind: "Variable",
|
|
36411
|
+
name: { kind: "Name", value: "userId" }
|
|
36412
|
+
},
|
|
36413
|
+
type: {
|
|
36414
|
+
kind: "NonNullType",
|
|
36415
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36416
|
+
}
|
|
36417
|
+
}
|
|
36418
|
+
],
|
|
36419
|
+
selectionSet: {
|
|
36420
|
+
kind: "SelectionSet",
|
|
36421
|
+
selections: [
|
|
36422
|
+
{
|
|
36423
|
+
kind: "Field",
|
|
36424
|
+
name: { kind: "Name", value: "user" },
|
|
36425
|
+
arguments: [
|
|
36426
|
+
{
|
|
36427
|
+
kind: "Argument",
|
|
36428
|
+
name: { kind: "Name", value: "id" },
|
|
36429
|
+
value: {
|
|
36430
|
+
kind: "Variable",
|
|
36431
|
+
name: { kind: "Name", value: "userId" }
|
|
36432
|
+
}
|
|
36433
|
+
}
|
|
36434
|
+
],
|
|
36435
|
+
selectionSet: {
|
|
36436
|
+
kind: "SelectionSet",
|
|
36437
|
+
selections: [
|
|
36438
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36439
|
+
{
|
|
36440
|
+
kind: "Field",
|
|
36441
|
+
name: { kind: "Name", value: "serverTrusts" },
|
|
36442
|
+
selectionSet: {
|
|
36443
|
+
kind: "SelectionSet",
|
|
36444
|
+
selections: [
|
|
36445
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36446
|
+
{
|
|
36447
|
+
kind: "Field",
|
|
36448
|
+
name: { kind: "Name", value: "server" },
|
|
36449
|
+
selectionSet: {
|
|
36450
|
+
kind: "SelectionSet",
|
|
36451
|
+
selections: [
|
|
36452
|
+
{
|
|
36453
|
+
kind: "Field",
|
|
36454
|
+
name: { kind: "Name", value: "id" }
|
|
36455
|
+
},
|
|
36456
|
+
{
|
|
36457
|
+
kind: "Field",
|
|
36458
|
+
name: { kind: "Name", value: "serverAddress" }
|
|
36459
|
+
},
|
|
36460
|
+
{
|
|
36461
|
+
kind: "Field",
|
|
36462
|
+
name: { kind: "Name", value: "url" }
|
|
36463
|
+
},
|
|
36464
|
+
{
|
|
36465
|
+
kind: "Field",
|
|
36466
|
+
name: { kind: "Name", value: "publicKey" }
|
|
36467
|
+
}
|
|
36468
|
+
]
|
|
36469
|
+
}
|
|
36470
|
+
},
|
|
36471
|
+
{
|
|
36472
|
+
kind: "Field",
|
|
36473
|
+
name: { kind: "Name", value: "trustedAt" }
|
|
36474
|
+
},
|
|
36475
|
+
{
|
|
36476
|
+
kind: "Field",
|
|
36477
|
+
name: { kind: "Name", value: "trustedAtBlock" }
|
|
36478
|
+
},
|
|
36479
|
+
{
|
|
36480
|
+
kind: "Field",
|
|
36481
|
+
name: { kind: "Name", value: "untrustedAtBlock" }
|
|
36482
|
+
},
|
|
36483
|
+
{
|
|
36484
|
+
kind: "Field",
|
|
36485
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36486
|
+
}
|
|
36487
|
+
]
|
|
36488
|
+
}
|
|
36489
|
+
}
|
|
36490
|
+
]
|
|
36491
|
+
}
|
|
36492
|
+
}
|
|
36493
|
+
]
|
|
36494
|
+
}
|
|
36495
|
+
}
|
|
36496
|
+
]
|
|
36497
|
+
};
|
|
36498
|
+
GetUserFilesDocument = {
|
|
36499
|
+
kind: "Document",
|
|
36500
|
+
definitions: [
|
|
36501
|
+
{
|
|
36502
|
+
kind: "OperationDefinition",
|
|
36503
|
+
operation: "query",
|
|
36504
|
+
name: { kind: "Name", value: "GetUserFiles" },
|
|
36505
|
+
variableDefinitions: [
|
|
36506
|
+
{
|
|
36507
|
+
kind: "VariableDefinition",
|
|
36508
|
+
variable: {
|
|
36509
|
+
kind: "Variable",
|
|
36510
|
+
name: { kind: "Name", value: "userId" }
|
|
36511
|
+
},
|
|
36512
|
+
type: {
|
|
36513
|
+
kind: "NonNullType",
|
|
36514
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36515
|
+
}
|
|
36516
|
+
}
|
|
36517
|
+
],
|
|
36518
|
+
selectionSet: {
|
|
36519
|
+
kind: "SelectionSet",
|
|
36520
|
+
selections: [
|
|
36521
|
+
{
|
|
36522
|
+
kind: "Field",
|
|
36523
|
+
name: { kind: "Name", value: "user" },
|
|
36524
|
+
arguments: [
|
|
36525
|
+
{
|
|
36526
|
+
kind: "Argument",
|
|
36527
|
+
name: { kind: "Name", value: "id" },
|
|
36528
|
+
value: {
|
|
36529
|
+
kind: "Variable",
|
|
36530
|
+
name: { kind: "Name", value: "userId" }
|
|
36531
|
+
}
|
|
36532
|
+
}
|
|
36533
|
+
],
|
|
36534
|
+
selectionSet: {
|
|
36535
|
+
kind: "SelectionSet",
|
|
36536
|
+
selections: [
|
|
36537
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36538
|
+
{
|
|
36539
|
+
kind: "Field",
|
|
36540
|
+
name: { kind: "Name", value: "files" },
|
|
36541
|
+
selectionSet: {
|
|
36542
|
+
kind: "SelectionSet",
|
|
36543
|
+
selections: [
|
|
36544
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36545
|
+
{ kind: "Field", name: { kind: "Name", value: "url" } },
|
|
36546
|
+
{
|
|
36547
|
+
kind: "Field",
|
|
36548
|
+
name: { kind: "Name", value: "schemaId" }
|
|
36549
|
+
},
|
|
36550
|
+
{
|
|
36551
|
+
kind: "Field",
|
|
36552
|
+
name: { kind: "Name", value: "addedAtBlock" }
|
|
36553
|
+
},
|
|
36554
|
+
{
|
|
36555
|
+
kind: "Field",
|
|
36556
|
+
name: { kind: "Name", value: "addedAtTimestamp" }
|
|
36557
|
+
},
|
|
36558
|
+
{
|
|
36559
|
+
kind: "Field",
|
|
36560
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36561
|
+
},
|
|
36562
|
+
{
|
|
36563
|
+
kind: "Field",
|
|
36564
|
+
name: { kind: "Name", value: "owner" },
|
|
36565
|
+
selectionSet: {
|
|
36566
|
+
kind: "SelectionSet",
|
|
36567
|
+
selections: [
|
|
36568
|
+
{
|
|
36569
|
+
kind: "Field",
|
|
36570
|
+
name: { kind: "Name", value: "id" }
|
|
36571
|
+
}
|
|
36572
|
+
]
|
|
36573
|
+
}
|
|
36574
|
+
}
|
|
36575
|
+
]
|
|
36576
|
+
}
|
|
36577
|
+
}
|
|
36578
|
+
]
|
|
36579
|
+
}
|
|
36580
|
+
}
|
|
36581
|
+
]
|
|
36582
|
+
}
|
|
36583
|
+
}
|
|
36584
|
+
]
|
|
36585
|
+
};
|
|
36586
|
+
GetFileProofsDocument = {
|
|
36587
|
+
kind: "Document",
|
|
36588
|
+
definitions: [
|
|
36589
|
+
{
|
|
36590
|
+
kind: "OperationDefinition",
|
|
36591
|
+
operation: "query",
|
|
36592
|
+
name: { kind: "Name", value: "GetFileProofs" },
|
|
36593
|
+
variableDefinitions: [
|
|
36594
|
+
{
|
|
36595
|
+
kind: "VariableDefinition",
|
|
36596
|
+
variable: {
|
|
36597
|
+
kind: "Variable",
|
|
36598
|
+
name: { kind: "Name", value: "fileIds" }
|
|
36599
|
+
},
|
|
36600
|
+
type: {
|
|
36601
|
+
kind: "NonNullType",
|
|
36602
|
+
type: {
|
|
36603
|
+
kind: "ListType",
|
|
36604
|
+
type: {
|
|
36605
|
+
kind: "NonNullType",
|
|
36606
|
+
type: {
|
|
36607
|
+
kind: "NamedType",
|
|
36608
|
+
name: { kind: "Name", value: "BigInt" }
|
|
36609
|
+
}
|
|
36610
|
+
}
|
|
36611
|
+
}
|
|
36612
|
+
}
|
|
36613
|
+
}
|
|
36614
|
+
],
|
|
36615
|
+
selectionSet: {
|
|
36616
|
+
kind: "SelectionSet",
|
|
36617
|
+
selections: [
|
|
36618
|
+
{
|
|
36619
|
+
kind: "Field",
|
|
36620
|
+
name: { kind: "Name", value: "dataRegistryProofs" },
|
|
36621
|
+
arguments: [
|
|
36622
|
+
{
|
|
36623
|
+
kind: "Argument",
|
|
36624
|
+
name: { kind: "Name", value: "where" },
|
|
36625
|
+
value: {
|
|
36626
|
+
kind: "ObjectValue",
|
|
36627
|
+
fields: [
|
|
36628
|
+
{
|
|
36629
|
+
kind: "ObjectField",
|
|
36630
|
+
name: { kind: "Name", value: "fileId_in" },
|
|
36631
|
+
value: {
|
|
36632
|
+
kind: "Variable",
|
|
36633
|
+
name: { kind: "Name", value: "fileIds" }
|
|
36634
|
+
}
|
|
36635
|
+
}
|
|
36636
|
+
]
|
|
36637
|
+
}
|
|
36638
|
+
}
|
|
36639
|
+
],
|
|
36640
|
+
selectionSet: {
|
|
36641
|
+
kind: "SelectionSet",
|
|
36642
|
+
selections: [
|
|
36643
|
+
{ kind: "Field", name: { kind: "Name", value: "fileId" } },
|
|
36644
|
+
{
|
|
36645
|
+
kind: "Field",
|
|
36646
|
+
name: { kind: "Name", value: "dlp" },
|
|
36647
|
+
selectionSet: {
|
|
36648
|
+
kind: "SelectionSet",
|
|
36649
|
+
selections: [
|
|
36650
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } }
|
|
36651
|
+
]
|
|
36652
|
+
}
|
|
36653
|
+
}
|
|
36654
|
+
]
|
|
36655
|
+
}
|
|
36656
|
+
}
|
|
36657
|
+
]
|
|
36658
|
+
}
|
|
36659
|
+
}
|
|
36660
|
+
]
|
|
36661
|
+
};
|
|
36662
|
+
GetDlpDocument = {
|
|
36663
|
+
kind: "Document",
|
|
36664
|
+
definitions: [
|
|
36665
|
+
{
|
|
36666
|
+
kind: "OperationDefinition",
|
|
36667
|
+
operation: "query",
|
|
36668
|
+
name: { kind: "Name", value: "GetDLP" },
|
|
36669
|
+
variableDefinitions: [
|
|
36670
|
+
{
|
|
36671
|
+
kind: "VariableDefinition",
|
|
36672
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
36673
|
+
type: {
|
|
36674
|
+
kind: "NonNullType",
|
|
36675
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36676
|
+
}
|
|
36677
|
+
}
|
|
36678
|
+
],
|
|
36679
|
+
selectionSet: {
|
|
36680
|
+
kind: "SelectionSet",
|
|
36681
|
+
selections: [
|
|
36682
|
+
{
|
|
36683
|
+
kind: "Field",
|
|
36684
|
+
name: { kind: "Name", value: "dlp" },
|
|
36685
|
+
arguments: [
|
|
36686
|
+
{
|
|
36687
|
+
kind: "Argument",
|
|
36688
|
+
name: { kind: "Name", value: "id" },
|
|
36689
|
+
value: {
|
|
36690
|
+
kind: "Variable",
|
|
36691
|
+
name: { kind: "Name", value: "id" }
|
|
36692
|
+
}
|
|
36693
|
+
}
|
|
36694
|
+
],
|
|
36695
|
+
selectionSet: {
|
|
36696
|
+
kind: "SelectionSet",
|
|
36697
|
+
selections: [
|
|
36698
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36699
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36700
|
+
{ kind: "Field", name: { kind: "Name", value: "metadata" } },
|
|
36701
|
+
{ kind: "Field", name: { kind: "Name", value: "status" } },
|
|
36702
|
+
{ kind: "Field", name: { kind: "Name", value: "address" } },
|
|
36703
|
+
{ kind: "Field", name: { kind: "Name", value: "owner" } }
|
|
36704
|
+
]
|
|
36705
|
+
}
|
|
36706
|
+
}
|
|
36707
|
+
]
|
|
36708
|
+
}
|
|
36709
|
+
}
|
|
36710
|
+
]
|
|
36711
|
+
};
|
|
36282
36712
|
GetSchemaDocument = {
|
|
36283
36713
|
kind: "Document",
|
|
36284
36714
|
definitions: [
|
|
@@ -36475,6 +36905,64 @@ var init_subgraph = __esm({
|
|
|
36475
36905
|
}
|
|
36476
36906
|
});
|
|
36477
36907
|
|
|
36908
|
+
// src/utils/blockchain/registry.ts
|
|
36909
|
+
import { getContract } from "viem";
|
|
36910
|
+
async function fetchSchemaFromChain(context, schemaId) {
|
|
36911
|
+
const chainId = context.walletClient.chain?.id;
|
|
36912
|
+
if (!chainId) {
|
|
36913
|
+
throw new Error("Chain ID not available");
|
|
36914
|
+
}
|
|
36915
|
+
const dataRefinerRegistryAddress = getContractAddress(
|
|
36916
|
+
chainId,
|
|
36917
|
+
"DataRefinerRegistry"
|
|
36918
|
+
);
|
|
36919
|
+
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36920
|
+
const dataRefinerRegistry = getContract({
|
|
36921
|
+
address: dataRefinerRegistryAddress,
|
|
36922
|
+
abi: dataRefinerRegistryAbi,
|
|
36923
|
+
client: context.publicClient
|
|
36924
|
+
});
|
|
36925
|
+
const schemaData = await dataRefinerRegistry.read.schemas([BigInt(schemaId)]);
|
|
36926
|
+
if (!schemaData) {
|
|
36927
|
+
throw new Error(`Schema with ID ${schemaId} not found`);
|
|
36928
|
+
}
|
|
36929
|
+
const schemaObj = schemaData;
|
|
36930
|
+
if (!schemaObj.name || !schemaObj.dialect || !schemaObj.definitionUrl) {
|
|
36931
|
+
throw new Error("Incomplete schema data");
|
|
36932
|
+
}
|
|
36933
|
+
return {
|
|
36934
|
+
id: schemaId,
|
|
36935
|
+
name: schemaObj.name,
|
|
36936
|
+
dialect: schemaObj.dialect,
|
|
36937
|
+
definitionUrl: schemaObj.definitionUrl
|
|
36938
|
+
};
|
|
36939
|
+
}
|
|
36940
|
+
async function fetchSchemaCountFromChain(context) {
|
|
36941
|
+
const chainId = context.walletClient.chain?.id;
|
|
36942
|
+
if (!chainId) {
|
|
36943
|
+
throw new Error("Chain ID not available");
|
|
36944
|
+
}
|
|
36945
|
+
const dataRefinerRegistryAddress = getContractAddress(
|
|
36946
|
+
chainId,
|
|
36947
|
+
"DataRefinerRegistry"
|
|
36948
|
+
);
|
|
36949
|
+
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36950
|
+
const dataRefinerRegistry = getContract({
|
|
36951
|
+
address: dataRefinerRegistryAddress,
|
|
36952
|
+
abi: dataRefinerRegistryAbi,
|
|
36953
|
+
client: context.publicClient
|
|
36954
|
+
});
|
|
36955
|
+
const count = await dataRefinerRegistry.read.schemasCount();
|
|
36956
|
+
return Number(count);
|
|
36957
|
+
}
|
|
36958
|
+
var init_registry = __esm({
|
|
36959
|
+
"src/utils/blockchain/registry.ts"() {
|
|
36960
|
+
"use strict";
|
|
36961
|
+
init_addresses();
|
|
36962
|
+
init_abi();
|
|
36963
|
+
}
|
|
36964
|
+
});
|
|
36965
|
+
|
|
36478
36966
|
// src/utils/urlResolver.ts
|
|
36479
36967
|
async function fetchFromUrl(url) {
|
|
36480
36968
|
try {
|
|
@@ -37158,6 +37646,7 @@ init_transactionHandle();
|
|
|
37158
37646
|
init_errors();
|
|
37159
37647
|
init_addresses();
|
|
37160
37648
|
init_abi();
|
|
37649
|
+
import { getAddress as getAddress3 } from "viem";
|
|
37161
37650
|
|
|
37162
37651
|
// src/utils/grantFiles.ts
|
|
37163
37652
|
init_errors();
|
|
@@ -37328,6 +37817,7 @@ function validateGrantFile(data) {
|
|
|
37328
37817
|
}
|
|
37329
37818
|
|
|
37330
37819
|
// src/utils/grantValidation.ts
|
|
37820
|
+
import { getAddress } from "viem";
|
|
37331
37821
|
import Ajv2 from "ajv";
|
|
37332
37822
|
import addFormats2 from "ajv-formats";
|
|
37333
37823
|
|
|
@@ -37531,7 +38021,9 @@ function extractFieldFromBusinessError(error) {
|
|
|
37531
38021
|
return void 0;
|
|
37532
38022
|
}
|
|
37533
38023
|
function validateGranteeAccess(grantFile, requestingAddress) {
|
|
37534
|
-
|
|
38024
|
+
const normalizedGrantee = getAddress(grantFile.grantee);
|
|
38025
|
+
const normalizedRequesting = getAddress(requestingAddress);
|
|
38026
|
+
if (normalizedGrantee !== normalizedRequesting) {
|
|
37535
38027
|
throw new GranteeMismatchError(
|
|
37536
38028
|
"Permission denied: requesting address does not match grantee",
|
|
37537
38029
|
grantFile.grantee,
|
|
@@ -37563,6 +38055,7 @@ function validateOperationAccess(grantFile, requestedOperation) {
|
|
|
37563
38055
|
|
|
37564
38056
|
// src/utils/signatureCache.ts
|
|
37565
38057
|
init_crypto_utils();
|
|
38058
|
+
import { getAddress as getAddress2 } from "viem";
|
|
37566
38059
|
var SignatureCache = class {
|
|
37567
38060
|
/**
|
|
37568
38061
|
* Get a cached signature if it exists and hasn't expired
|
|
@@ -37653,7 +38146,7 @@ var SignatureCache = class {
|
|
|
37653
38146
|
}
|
|
37654
38147
|
}
|
|
37655
38148
|
static getCacheKey(walletAddress, messageHash) {
|
|
37656
|
-
return `${this.PREFIX}${walletAddress
|
|
38149
|
+
return `${this.PREFIX}${getAddress2(walletAddress)}:${messageHash}`;
|
|
37657
38150
|
}
|
|
37658
38151
|
/**
|
|
37659
38152
|
* Generate a deterministic hash of a message object for cache key generation
|
|
@@ -38928,20 +39421,22 @@ var PermissionsController = class {
|
|
|
38928
39421
|
if (!userData || !userData.permissions?.length) {
|
|
38929
39422
|
return [];
|
|
38930
39423
|
}
|
|
38931
|
-
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
38932
|
-
|
|
38933
|
-
|
|
38934
|
-
|
|
38935
|
-
|
|
38936
|
-
|
|
38937
|
-
|
|
38938
|
-
|
|
38939
|
-
|
|
38940
|
-
|
|
38941
|
-
|
|
38942
|
-
|
|
38943
|
-
|
|
38944
|
-
|
|
39424
|
+
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
39425
|
+
(permission) => ({
|
|
39426
|
+
id: BigInt(permission.id),
|
|
39427
|
+
grantUrl: permission.grant,
|
|
39428
|
+
grantSignature: permission.signature,
|
|
39429
|
+
nonce: BigInt(permission.nonce),
|
|
39430
|
+
startBlock: BigInt(permission.startBlock),
|
|
39431
|
+
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
39432
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
|
|
39433
|
+
transactionHash: permission.transactionHash || "",
|
|
39434
|
+
grantor: userAddress,
|
|
39435
|
+
grantee: permission.grantee,
|
|
39436
|
+
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
39437
|
+
// Active if no end block or end block is 0
|
|
39438
|
+
})
|
|
39439
|
+
);
|
|
38945
39440
|
return onChainGrants.sort((a, b) => {
|
|
38946
39441
|
if (a.id < b.id) return 1;
|
|
38947
39442
|
if (a.id > b.id) return -1;
|
|
@@ -39019,14 +39514,16 @@ var PermissionsController = class {
|
|
|
39019
39514
|
);
|
|
39020
39515
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
39021
39516
|
const userAddress = this.context.walletClient.account?.address || await this.getUserAddress();
|
|
39517
|
+
const normalizedUserAddress = getAddress3(userAddress);
|
|
39518
|
+
const normalizedServerAddress = getAddress3(params.serverAddress);
|
|
39022
39519
|
const txHash = await this.context.walletClient.writeContract({
|
|
39023
39520
|
address: DataPortabilityServersAddress,
|
|
39024
39521
|
abi: DataPortabilityServersAbi,
|
|
39025
39522
|
functionName: "addAndTrustServerByManager",
|
|
39026
39523
|
args: [
|
|
39027
|
-
|
|
39524
|
+
normalizedUserAddress,
|
|
39028
39525
|
{
|
|
39029
|
-
serverAddress:
|
|
39526
|
+
serverAddress: normalizedServerAddress,
|
|
39030
39527
|
serverUrl: params.serverUrl,
|
|
39031
39528
|
publicKey: params.publicKey
|
|
39032
39529
|
}
|
|
@@ -39096,9 +39593,10 @@ var PermissionsController = class {
|
|
|
39096
39593
|
async submitAddAndTrustServerWithSignature(params) {
|
|
39097
39594
|
try {
|
|
39098
39595
|
const nonce = await this.getServersUserNonce();
|
|
39596
|
+
const serverAddress = getAddress3(params.serverAddress);
|
|
39099
39597
|
const addAndTrustServerInput = {
|
|
39100
39598
|
nonce,
|
|
39101
|
-
serverAddress
|
|
39599
|
+
serverAddress,
|
|
39102
39600
|
publicKey: params.publicKey,
|
|
39103
39601
|
serverUrl: params.serverUrl
|
|
39104
39602
|
};
|
|
@@ -39903,11 +40401,13 @@ var PermissionsController = class {
|
|
|
39903
40401
|
"DataPortabilityGrantees"
|
|
39904
40402
|
);
|
|
39905
40403
|
const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
|
|
40404
|
+
const ownerAddress = getAddress3(params.owner);
|
|
40405
|
+
const granteeAddress = getAddress3(params.granteeAddress);
|
|
39906
40406
|
const txHash = await this.context.walletClient.writeContract({
|
|
39907
40407
|
address: DataPortabilityGranteesAddress,
|
|
39908
40408
|
abi: DataPortabilityGranteesAbi,
|
|
39909
40409
|
functionName: "registerGrantee",
|
|
39910
|
-
args: [
|
|
40410
|
+
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
39911
40411
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
39912
40412
|
chain: this.context.walletClient.chain || null
|
|
39913
40413
|
});
|
|
@@ -39934,10 +40434,12 @@ var PermissionsController = class {
|
|
|
39934
40434
|
*/
|
|
39935
40435
|
async submitRegisterGranteeWithSignature(params) {
|
|
39936
40436
|
const nonce = await this.getServersUserNonce();
|
|
40437
|
+
const owner = getAddress3(params.owner);
|
|
40438
|
+
const granteeAddress = getAddress3(params.granteeAddress);
|
|
39937
40439
|
const registerGranteeInput = {
|
|
39938
40440
|
nonce,
|
|
39939
|
-
owner
|
|
39940
|
-
granteeAddress
|
|
40441
|
+
owner,
|
|
40442
|
+
granteeAddress,
|
|
39941
40443
|
publicKey: params.publicKey
|
|
39942
40444
|
};
|
|
39943
40445
|
const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
|
|
@@ -41448,7 +41950,9 @@ var PermissionsController = class {
|
|
|
41448
41950
|
init_transactionHandle();
|
|
41449
41951
|
init_addresses();
|
|
41450
41952
|
init_abi();
|
|
41953
|
+
init_subgraph();
|
|
41451
41954
|
import { getContract as getContract2 } from "viem";
|
|
41955
|
+
import { print as print2 } from "graphql";
|
|
41452
41956
|
|
|
41453
41957
|
// src/utils/encryption.ts
|
|
41454
41958
|
var DEFAULT_ENCRYPTION_SEED = "Please sign to retrieve your encryption key";
|
|
@@ -41872,34 +42376,16 @@ var DataController = class {
|
|
|
41872
42376
|
);
|
|
41873
42377
|
}
|
|
41874
42378
|
try {
|
|
41875
|
-
const query = `
|
|
41876
|
-
query GetUserFiles($userId: ID!) {
|
|
41877
|
-
user(id: $userId) {
|
|
41878
|
-
id
|
|
41879
|
-
files {
|
|
41880
|
-
id
|
|
41881
|
-
url
|
|
41882
|
-
schemaId
|
|
41883
|
-
addedAtBlock
|
|
41884
|
-
addedAtTimestamp
|
|
41885
|
-
transactionHash
|
|
41886
|
-
owner {
|
|
41887
|
-
id
|
|
41888
|
-
}
|
|
41889
|
-
}
|
|
41890
|
-
}
|
|
41891
|
-
}
|
|
41892
|
-
`;
|
|
41893
42379
|
const response = await fetch(endpoint, {
|
|
41894
42380
|
method: "POST",
|
|
41895
42381
|
headers: {
|
|
41896
42382
|
"Content-Type": "application/json"
|
|
41897
42383
|
},
|
|
41898
42384
|
body: JSON.stringify({
|
|
41899
|
-
query,
|
|
42385
|
+
query: print2(GetUserFilesDocument),
|
|
41900
42386
|
variables: {
|
|
41901
42387
|
userId: owner.toLowerCase()
|
|
41902
|
-
// Subgraph
|
|
42388
|
+
// Subgraph requires lowercase addresses
|
|
41903
42389
|
}
|
|
41904
42390
|
})
|
|
41905
42391
|
});
|
|
@@ -41979,23 +42465,13 @@ var DataController = class {
|
|
|
41979
42465
|
* @returns Map of file IDs to their associated DLP IDs
|
|
41980
42466
|
*/
|
|
41981
42467
|
async _fetchProofsFromSubgraph(fileIds, subgraphUrl) {
|
|
41982
|
-
const query = `
|
|
41983
|
-
query GetFileProofs($fileIds: [BigInt!]!) {
|
|
41984
|
-
dataRegistryProofs(where: { fileId_in: $fileIds }) {
|
|
41985
|
-
fileId
|
|
41986
|
-
dlp {
|
|
41987
|
-
id
|
|
41988
|
-
}
|
|
41989
|
-
}
|
|
41990
|
-
}
|
|
41991
|
-
`;
|
|
41992
42468
|
const response = await fetch(subgraphUrl, {
|
|
41993
42469
|
method: "POST",
|
|
41994
42470
|
headers: {
|
|
41995
42471
|
"Content-Type": "application/json"
|
|
41996
42472
|
},
|
|
41997
42473
|
body: JSON.stringify({
|
|
41998
|
-
query,
|
|
42474
|
+
query: print2(GetFileProofsDocument),
|
|
41999
42475
|
variables: {
|
|
42000
42476
|
fileIds: fileIds.map((id) => id.toString())
|
|
42001
42477
|
}
|
|
@@ -42099,25 +42575,13 @@ var DataController = class {
|
|
|
42099
42575
|
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
42100
42576
|
if (subgraphUrl) {
|
|
42101
42577
|
try {
|
|
42102
|
-
const query = `
|
|
42103
|
-
query GetDLP($id: ID!) {
|
|
42104
|
-
dlp(id: $id) {
|
|
42105
|
-
id
|
|
42106
|
-
name
|
|
42107
|
-
metadata
|
|
42108
|
-
status
|
|
42109
|
-
address
|
|
42110
|
-
owner
|
|
42111
|
-
}
|
|
42112
|
-
}
|
|
42113
|
-
`;
|
|
42114
42578
|
const response = await fetch(subgraphUrl, {
|
|
42115
42579
|
method: "POST",
|
|
42116
42580
|
headers: {
|
|
42117
42581
|
"Content-Type": "application/json"
|
|
42118
42582
|
},
|
|
42119
42583
|
body: JSON.stringify({
|
|
42120
|
-
query,
|
|
42584
|
+
query: print2(GetDlpDocument),
|
|
42121
42585
|
variables: {
|
|
42122
42586
|
id: dlpId.toString()
|
|
42123
42587
|
}
|
|
@@ -42140,7 +42604,7 @@ var DataController = class {
|
|
|
42140
42604
|
return {
|
|
42141
42605
|
id: parseInt(result.data.dlp.id),
|
|
42142
42606
|
name: result.data.dlp.name || "",
|
|
42143
|
-
metadata: result.data.dlp.metadata,
|
|
42607
|
+
metadata: result.data.dlp.metadata || void 0,
|
|
42144
42608
|
status: result.data.dlp.status ? parseInt(result.data.dlp.status) : void 0,
|
|
42145
42609
|
address: result.data.dlp.address,
|
|
42146
42610
|
owner: result.data.dlp.owner
|
|
@@ -42354,32 +42818,13 @@ var DataController = class {
|
|
|
42354
42818
|
async _getUserPermissionsViaSubgraph(params) {
|
|
42355
42819
|
const { user, subgraphUrl } = params;
|
|
42356
42820
|
try {
|
|
42357
|
-
const query = `
|
|
42358
|
-
query GetUserPermissions($userId: ID!) {
|
|
42359
|
-
user(id: $userId) {
|
|
42360
|
-
id
|
|
42361
|
-
permissions {
|
|
42362
|
-
id
|
|
42363
|
-
grant
|
|
42364
|
-
nonce
|
|
42365
|
-
signature
|
|
42366
|
-
addedAtBlock
|
|
42367
|
-
addedAtTimestamp
|
|
42368
|
-
transactionHash
|
|
42369
|
-
user {
|
|
42370
|
-
id
|
|
42371
|
-
}
|
|
42372
|
-
}
|
|
42373
|
-
}
|
|
42374
|
-
}
|
|
42375
|
-
`;
|
|
42376
42821
|
const response = await fetch(subgraphUrl, {
|
|
42377
42822
|
method: "POST",
|
|
42378
42823
|
headers: {
|
|
42379
42824
|
"Content-Type": "application/json"
|
|
42380
42825
|
},
|
|
42381
42826
|
body: JSON.stringify({
|
|
42382
|
-
query,
|
|
42827
|
+
query: print2(GetUserPermissionsDocument),
|
|
42383
42828
|
variables: {
|
|
42384
42829
|
userId: user.toLowerCase()
|
|
42385
42830
|
}
|
|
@@ -42408,7 +42853,7 @@ var DataController = class {
|
|
|
42408
42853
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
42409
42854
|
addedAtTimestamp: BigInt(permission.addedAtTimestamp),
|
|
42410
42855
|
transactionHash: permission.transactionHash,
|
|
42411
|
-
user
|
|
42856
|
+
user
|
|
42412
42857
|
})).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
|
|
42413
42858
|
} catch (error) {
|
|
42414
42859
|
console.error("Failed to query user permissions from subgraph:", error);
|
|
@@ -42580,36 +43025,16 @@ var DataController = class {
|
|
|
42580
43025
|
);
|
|
42581
43026
|
}
|
|
42582
43027
|
try {
|
|
42583
|
-
const query = `
|
|
42584
|
-
query GetUserTrustedServers($userId: ID!) {
|
|
42585
|
-
user(id: $userId) {
|
|
42586
|
-
id
|
|
42587
|
-
serverTrusts {
|
|
42588
|
-
id
|
|
42589
|
-
server {
|
|
42590
|
-
id
|
|
42591
|
-
serverAddress
|
|
42592
|
-
url
|
|
42593
|
-
publicKey
|
|
42594
|
-
}
|
|
42595
|
-
trustedAt
|
|
42596
|
-
trustedAtBlock
|
|
42597
|
-
untrustedAtBlock
|
|
42598
|
-
transactionHash
|
|
42599
|
-
}
|
|
42600
|
-
}
|
|
42601
|
-
}
|
|
42602
|
-
`;
|
|
42603
43028
|
const response = await fetch(graphqlEndpoint, {
|
|
42604
43029
|
method: "POST",
|
|
42605
43030
|
headers: {
|
|
42606
43031
|
"Content-Type": "application/json"
|
|
42607
43032
|
},
|
|
42608
43033
|
body: JSON.stringify({
|
|
42609
|
-
query,
|
|
43034
|
+
query: print2(GetUserTrustedServersDocument),
|
|
42610
43035
|
variables: {
|
|
42611
43036
|
userId: user.toLowerCase()
|
|
42612
|
-
// Subgraph
|
|
43037
|
+
// Subgraph requires lowercase addresses
|
|
42613
43038
|
}
|
|
42614
43039
|
})
|
|
42615
43040
|
});
|
|
@@ -43443,19 +43868,31 @@ var DataController = class {
|
|
|
43443
43868
|
return await this.submitFilePermission(fileId, account, publicKey);
|
|
43444
43869
|
}
|
|
43445
43870
|
/**
|
|
43446
|
-
* Submits a file permission transaction
|
|
43871
|
+
* Submits a file permission transaction to the blockchain.
|
|
43447
43872
|
*
|
|
43448
|
-
*
|
|
43873
|
+
* @remarks
|
|
43874
|
+
* This method supports gasless transactions via relayer callbacks when configured.
|
|
43875
|
+
* It encrypts the user's encryption key with the recipient's public key before submission.
|
|
43449
43876
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
43450
43877
|
*
|
|
43451
|
-
* @param fileId - The ID of the file to
|
|
43452
|
-
* @param account - The
|
|
43453
|
-
* @param publicKey - The public key
|
|
43454
|
-
*
|
|
43878
|
+
* @param fileId - The ID of the file to grant permission for
|
|
43879
|
+
* @param account - The recipient's wallet address that will access the file
|
|
43880
|
+
* @param publicKey - The recipient's public key for encryption.
|
|
43881
|
+
* Obtain via `vana.server.getIdentity(account).public_key`
|
|
43882
|
+
* @returns Promise resolving to TransactionHandle for tracking the transaction
|
|
43883
|
+
* @throws {Error} When chain ID is not available
|
|
43884
|
+
* @throws {Error} When encryption key generation fails
|
|
43885
|
+
* @throws {Error} When public key encryption fails
|
|
43886
|
+
*
|
|
43455
43887
|
* @example
|
|
43456
43888
|
* ```typescript
|
|
43457
|
-
* const
|
|
43458
|
-
*
|
|
43889
|
+
* const tx = await vana.data.submitFilePermission(
|
|
43890
|
+
* fileId,
|
|
43891
|
+
* "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
43892
|
+
* recipientPublicKey
|
|
43893
|
+
* );
|
|
43894
|
+
* const result = await tx.waitForEvents();
|
|
43895
|
+
* console.log(`Permission granted with ID: ${result.permissionId}`);
|
|
43459
43896
|
* ```
|
|
43460
43897
|
*/
|
|
43461
43898
|
async submitFilePermission(fileId, account, publicKey) {
|
|
@@ -43823,6 +44260,73 @@ init_schemas();
|
|
|
43823
44260
|
|
|
43824
44261
|
// src/controllers/server.ts
|
|
43825
44262
|
init_errors();
|
|
44263
|
+
|
|
44264
|
+
// src/utils/operationHandle.ts
|
|
44265
|
+
init_errors();
|
|
44266
|
+
var OperationHandle = class {
|
|
44267
|
+
constructor(controller, id) {
|
|
44268
|
+
this.controller = controller;
|
|
44269
|
+
this.id = id;
|
|
44270
|
+
__publicField(this, "_resultPromise");
|
|
44271
|
+
}
|
|
44272
|
+
/**
|
|
44273
|
+
* Waits for the operation to complete and returns the result.
|
|
44274
|
+
*
|
|
44275
|
+
* @remarks
|
|
44276
|
+
* Results are memoized - multiple calls return the same promise.
|
|
44277
|
+
* The method polls the server at regular intervals until the operation
|
|
44278
|
+
* succeeds, fails, or times out. Returns the raw string result from the
|
|
44279
|
+
* server - callers are responsible for parsing if needed.
|
|
44280
|
+
*
|
|
44281
|
+
* @param options - Optional polling configuration
|
|
44282
|
+
* @returns The operation result as a string when completed
|
|
44283
|
+
* @throws {PersonalServerError} When the operation fails or times out
|
|
44284
|
+
* @example
|
|
44285
|
+
* ```typescript
|
|
44286
|
+
* const result = await handle.waitForResult({
|
|
44287
|
+
* timeout: 60000,
|
|
44288
|
+
* pollingInterval: 500
|
|
44289
|
+
* });
|
|
44290
|
+
* // If expecting JSON, parse it:
|
|
44291
|
+
* const data = JSON.parse(result);
|
|
44292
|
+
* ```
|
|
44293
|
+
*/
|
|
44294
|
+
async waitForResult(options) {
|
|
44295
|
+
if (!this._resultPromise) {
|
|
44296
|
+
this._resultPromise = this.pollForCompletion(options);
|
|
44297
|
+
}
|
|
44298
|
+
return this._resultPromise;
|
|
44299
|
+
}
|
|
44300
|
+
async pollForCompletion(options) {
|
|
44301
|
+
const startTime = Date.now();
|
|
44302
|
+
const timeout = options?.timeout ?? 3e4;
|
|
44303
|
+
const interval = options?.pollingInterval ?? 500;
|
|
44304
|
+
while (true) {
|
|
44305
|
+
const result = await this.controller.getOperation(
|
|
44306
|
+
this.id
|
|
44307
|
+
);
|
|
44308
|
+
if (result.status === "succeeded") {
|
|
44309
|
+
if (result.result) {
|
|
44310
|
+
return result.result;
|
|
44311
|
+
}
|
|
44312
|
+
throw new PersonalServerError(
|
|
44313
|
+
"Operation succeeded but returned no result"
|
|
44314
|
+
);
|
|
44315
|
+
}
|
|
44316
|
+
if (result.status === "failed") {
|
|
44317
|
+
throw new PersonalServerError(
|
|
44318
|
+
`Operation ${result.status}: ${result.result || "Unknown error"}`
|
|
44319
|
+
);
|
|
44320
|
+
}
|
|
44321
|
+
if (Date.now() - startTime > timeout) {
|
|
44322
|
+
throw new PersonalServerError(`Operation timed out after ${timeout}ms`);
|
|
44323
|
+
}
|
|
44324
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
44325
|
+
}
|
|
44326
|
+
}
|
|
44327
|
+
};
|
|
44328
|
+
|
|
44329
|
+
// src/controllers/server.ts
|
|
43826
44330
|
var ServerController = class {
|
|
43827
44331
|
constructor(context) {
|
|
43828
44332
|
this.context = context;
|
|
@@ -43904,26 +44408,29 @@ var ServerController = class {
|
|
|
43904
44408
|
}
|
|
43905
44409
|
}
|
|
43906
44410
|
/**
|
|
43907
|
-
* Creates
|
|
44411
|
+
* Creates a server operation and returns a handle for lifecycle management.
|
|
43908
44412
|
*
|
|
43909
44413
|
* @remarks
|
|
43910
|
-
* This method submits a computation request to the personal server
|
|
43911
|
-
*
|
|
43912
|
-
*
|
|
44414
|
+
* This method submits a computation request to the personal server and returns
|
|
44415
|
+
* an OperationHandle that provides Promise-based methods for waiting on results.
|
|
44416
|
+
* The handle pattern matches TransactionHandle for consistency across async operations.
|
|
44417
|
+
*
|
|
44418
|
+
* @param params - The operation request parameters
|
|
43913
44419
|
* @param params.permissionId - The permission ID authorizing this operation.
|
|
43914
|
-
* Obtain
|
|
43915
|
-
* @returns
|
|
43916
|
-
* @throws {PersonalServerError} When server request fails or parameters are invalid
|
|
43917
|
-
*
|
|
43918
|
-
* @throws {NetworkError} When personal server API communication fails.
|
|
43919
|
-
* Check server URL configuration and network connectivity.
|
|
44420
|
+
* Obtain via `vana.permissions.getUserPermissionGrantsOnChain()`.
|
|
44421
|
+
* @returns An OperationHandle providing access to the operation ID and result methods
|
|
44422
|
+
* @throws {PersonalServerError} When the server request fails or parameters are invalid
|
|
44423
|
+
* @throws {NetworkError} When personal server API communication fails
|
|
43920
44424
|
* @example
|
|
43921
44425
|
* ```typescript
|
|
43922
|
-
* const
|
|
43923
|
-
* permissionId: 123
|
|
44426
|
+
* const operation = await vana.server.createOperation({
|
|
44427
|
+
* permissionId: 123
|
|
43924
44428
|
* });
|
|
43925
|
-
*
|
|
43926
|
-
*
|
|
44429
|
+
* console.log(`Operation ID: ${operation.id}`);
|
|
44430
|
+
*
|
|
44431
|
+
* // Wait for completion
|
|
44432
|
+
* const result = await operation.waitForResult();
|
|
44433
|
+
* console.log("Result:", result);
|
|
43927
44434
|
* ```
|
|
43928
44435
|
*/
|
|
43929
44436
|
async createOperation(params) {
|
|
@@ -43939,7 +44446,7 @@ var ServerController = class {
|
|
|
43939
44446
|
};
|
|
43940
44447
|
console.debug("\u{1F50D} Debug - createOperation requestBody", requestBody);
|
|
43941
44448
|
const response = await this.makeRequest(requestBody);
|
|
43942
|
-
return response;
|
|
44449
|
+
return new OperationHandle(this, response.id);
|
|
43943
44450
|
} catch (error) {
|
|
43944
44451
|
if (error instanceof Error) {
|
|
43945
44452
|
if (error instanceof NetworkError || error instanceof SerializationError || error instanceof SignatureError || error instanceof PersonalServerError) {
|
|
@@ -43956,30 +44463,20 @@ var ServerController = class {
|
|
|
43956
44463
|
}
|
|
43957
44464
|
}
|
|
43958
44465
|
/**
|
|
43959
|
-
*
|
|
44466
|
+
* Retrieves the current status and result of a server operation.
|
|
43960
44467
|
*
|
|
43961
44468
|
* @remarks
|
|
43962
|
-
*
|
|
43963
|
-
*
|
|
43964
|
-
*
|
|
43965
|
-
*
|
|
43966
|
-
*
|
|
43967
|
-
*
|
|
43968
|
-
* @param operationId - The operation ID returned from the initial request submission
|
|
43969
|
-
* @returns A Promise that resolves to the current operation response with status and results
|
|
43970
|
-
* @throws {NetworkError} When the polling request fails or returns invalid data
|
|
44469
|
+
* Common status values: `starting`, `running`, `succeeded`, `failed`, `canceled`.
|
|
44470
|
+
* When status is `succeeded`, the result field contains the operation output.
|
|
44471
|
+
*
|
|
44472
|
+
* @param operationId - The ID of the operation to query
|
|
44473
|
+
* @returns The operation response containing status, result, and metadata
|
|
44474
|
+
* @throws {NetworkError} When the API request fails or returns invalid data
|
|
43971
44475
|
* @example
|
|
43972
44476
|
* ```typescript
|
|
43973
|
-
*
|
|
43974
|
-
*
|
|
43975
|
-
*
|
|
43976
|
-
* while (result.status === "processing") {
|
|
43977
|
-
* await new Promise(resolve => setTimeout(resolve, 1000));
|
|
43978
|
-
* result = await vana.server.getOperation(response.id);
|
|
43979
|
-
* }
|
|
43980
|
-
*
|
|
43981
|
-
* if (result.status === "succeeded") {
|
|
43982
|
-
* console.log("Computation completed:", result.output);
|
|
44477
|
+
* const status = await vana.server.getOperation(operationId);
|
|
44478
|
+
* if (status.status === 'succeeded') {
|
|
44479
|
+
* console.log('Result:', JSON.parse(status.result));
|
|
43983
44480
|
* }
|
|
43984
44481
|
* ```
|
|
43985
44482
|
*/
|