@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.node.cjs
CHANGED
|
@@ -2811,6 +2811,19 @@ var init_DataRegistryImplementation = __esm({
|
|
|
2811
2811
|
name: "Upgraded",
|
|
2812
2812
|
type: "event"
|
|
2813
2813
|
},
|
|
2814
|
+
{
|
|
2815
|
+
inputs: [],
|
|
2816
|
+
name: "DATA_PORTABILITY_ROLE",
|
|
2817
|
+
outputs: [
|
|
2818
|
+
{
|
|
2819
|
+
internalType: "bytes32",
|
|
2820
|
+
name: "",
|
|
2821
|
+
type: "bytes32"
|
|
2822
|
+
}
|
|
2823
|
+
],
|
|
2824
|
+
stateMutability: "view",
|
|
2825
|
+
type: "function"
|
|
2826
|
+
},
|
|
2814
2827
|
{
|
|
2815
2828
|
inputs: [],
|
|
2816
2829
|
name: "DEFAULT_ADMIN_ROLE",
|
|
@@ -2905,6 +2918,41 @@ var init_DataRegistryImplementation = __esm({
|
|
|
2905
2918
|
stateMutability: "nonpayable",
|
|
2906
2919
|
type: "function"
|
|
2907
2920
|
},
|
|
2921
|
+
{
|
|
2922
|
+
inputs: [
|
|
2923
|
+
{
|
|
2924
|
+
internalType: "uint256",
|
|
2925
|
+
name: "fileId",
|
|
2926
|
+
type: "uint256"
|
|
2927
|
+
},
|
|
2928
|
+
{
|
|
2929
|
+
components: [
|
|
2930
|
+
{
|
|
2931
|
+
internalType: "address",
|
|
2932
|
+
name: "account",
|
|
2933
|
+
type: "address"
|
|
2934
|
+
},
|
|
2935
|
+
{
|
|
2936
|
+
internalType: "string",
|
|
2937
|
+
name: "key",
|
|
2938
|
+
type: "string"
|
|
2939
|
+
}
|
|
2940
|
+
],
|
|
2941
|
+
internalType: "struct IDataRegistry.Permission[]",
|
|
2942
|
+
name: "permissions",
|
|
2943
|
+
type: "tuple[]"
|
|
2944
|
+
},
|
|
2945
|
+
{
|
|
2946
|
+
internalType: "uint256",
|
|
2947
|
+
name: "schemaId",
|
|
2948
|
+
type: "uint256"
|
|
2949
|
+
}
|
|
2950
|
+
],
|
|
2951
|
+
name: "addFilePermissionsAndSchema",
|
|
2952
|
+
outputs: [],
|
|
2953
|
+
stateMutability: "nonpayable",
|
|
2954
|
+
type: "function"
|
|
2955
|
+
},
|
|
2908
2956
|
{
|
|
2909
2957
|
inputs: [
|
|
2910
2958
|
{
|
|
@@ -35990,70 +36038,451 @@ var init_ipfs = __esm({
|
|
|
35990
36038
|
}
|
|
35991
36039
|
});
|
|
35992
36040
|
|
|
35993
|
-
// src/utils/blockchain/registry.ts
|
|
35994
|
-
async function fetchSchemaFromChain(context, schemaId) {
|
|
35995
|
-
const chainId = context.walletClient.chain?.id;
|
|
35996
|
-
if (!chainId) {
|
|
35997
|
-
throw new Error("Chain ID not available");
|
|
35998
|
-
}
|
|
35999
|
-
const dataRefinerRegistryAddress = getContractAddress(
|
|
36000
|
-
chainId,
|
|
36001
|
-
"DataRefinerRegistry"
|
|
36002
|
-
);
|
|
36003
|
-
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36004
|
-
const dataRefinerRegistry = (0, import_viem4.getContract)({
|
|
36005
|
-
address: dataRefinerRegistryAddress,
|
|
36006
|
-
abi: dataRefinerRegistryAbi,
|
|
36007
|
-
client: context.publicClient
|
|
36008
|
-
});
|
|
36009
|
-
const schemaData = await dataRefinerRegistry.read.schemas([BigInt(schemaId)]);
|
|
36010
|
-
if (!schemaData) {
|
|
36011
|
-
throw new Error(`Schema with ID ${schemaId} not found`);
|
|
36012
|
-
}
|
|
36013
|
-
const schemaObj = schemaData;
|
|
36014
|
-
if (!schemaObj.name || !schemaObj.dialect || !schemaObj.definitionUrl) {
|
|
36015
|
-
throw new Error("Incomplete schema data");
|
|
36016
|
-
}
|
|
36017
|
-
return {
|
|
36018
|
-
id: schemaId,
|
|
36019
|
-
name: schemaObj.name,
|
|
36020
|
-
dialect: schemaObj.dialect,
|
|
36021
|
-
definitionUrl: schemaObj.definitionUrl
|
|
36022
|
-
};
|
|
36023
|
-
}
|
|
36024
|
-
async function fetchSchemaCountFromChain(context) {
|
|
36025
|
-
const chainId = context.walletClient.chain?.id;
|
|
36026
|
-
if (!chainId) {
|
|
36027
|
-
throw new Error("Chain ID not available");
|
|
36028
|
-
}
|
|
36029
|
-
const dataRefinerRegistryAddress = getContractAddress(
|
|
36030
|
-
chainId,
|
|
36031
|
-
"DataRefinerRegistry"
|
|
36032
|
-
);
|
|
36033
|
-
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36034
|
-
const dataRefinerRegistry = (0, import_viem4.getContract)({
|
|
36035
|
-
address: dataRefinerRegistryAddress,
|
|
36036
|
-
abi: dataRefinerRegistryAbi,
|
|
36037
|
-
client: context.publicClient
|
|
36038
|
-
});
|
|
36039
|
-
const count = await dataRefinerRegistry.read.schemasCount();
|
|
36040
|
-
return Number(count);
|
|
36041
|
-
}
|
|
36042
|
-
var import_viem4;
|
|
36043
|
-
var init_registry = __esm({
|
|
36044
|
-
"src/utils/blockchain/registry.ts"() {
|
|
36045
|
-
"use strict";
|
|
36046
|
-
import_viem4 = require("viem");
|
|
36047
|
-
init_addresses();
|
|
36048
|
-
init_abi();
|
|
36049
|
-
}
|
|
36050
|
-
});
|
|
36051
|
-
|
|
36052
36041
|
// src/generated/subgraph.ts
|
|
36053
|
-
var GetSchemaDocument, ListSchemasDocument, CountSchemasDocument;
|
|
36042
|
+
var GetUserPermissionsDocument, GetUserTrustedServersDocument, GetUserFilesDocument, GetFileProofsDocument, GetDlpDocument, GetSchemaDocument, ListSchemasDocument, CountSchemasDocument;
|
|
36054
36043
|
var init_subgraph = __esm({
|
|
36055
36044
|
"src/generated/subgraph.ts"() {
|
|
36056
36045
|
"use strict";
|
|
36046
|
+
GetUserPermissionsDocument = {
|
|
36047
|
+
kind: "Document",
|
|
36048
|
+
definitions: [
|
|
36049
|
+
{
|
|
36050
|
+
kind: "OperationDefinition",
|
|
36051
|
+
operation: "query",
|
|
36052
|
+
name: { kind: "Name", value: "GetUserPermissions" },
|
|
36053
|
+
variableDefinitions: [
|
|
36054
|
+
{
|
|
36055
|
+
kind: "VariableDefinition",
|
|
36056
|
+
variable: {
|
|
36057
|
+
kind: "Variable",
|
|
36058
|
+
name: { kind: "Name", value: "userId" }
|
|
36059
|
+
},
|
|
36060
|
+
type: {
|
|
36061
|
+
kind: "NonNullType",
|
|
36062
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36063
|
+
}
|
|
36064
|
+
}
|
|
36065
|
+
],
|
|
36066
|
+
selectionSet: {
|
|
36067
|
+
kind: "SelectionSet",
|
|
36068
|
+
selections: [
|
|
36069
|
+
{
|
|
36070
|
+
kind: "Field",
|
|
36071
|
+
name: { kind: "Name", value: "user" },
|
|
36072
|
+
arguments: [
|
|
36073
|
+
{
|
|
36074
|
+
kind: "Argument",
|
|
36075
|
+
name: { kind: "Name", value: "id" },
|
|
36076
|
+
value: {
|
|
36077
|
+
kind: "Variable",
|
|
36078
|
+
name: { kind: "Name", value: "userId" }
|
|
36079
|
+
}
|
|
36080
|
+
}
|
|
36081
|
+
],
|
|
36082
|
+
selectionSet: {
|
|
36083
|
+
kind: "SelectionSet",
|
|
36084
|
+
selections: [
|
|
36085
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36086
|
+
{
|
|
36087
|
+
kind: "Field",
|
|
36088
|
+
name: { kind: "Name", value: "permissions" },
|
|
36089
|
+
selectionSet: {
|
|
36090
|
+
kind: "SelectionSet",
|
|
36091
|
+
selections: [
|
|
36092
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36093
|
+
{ kind: "Field", name: { kind: "Name", value: "grant" } },
|
|
36094
|
+
{ kind: "Field", name: { kind: "Name", value: "nonce" } },
|
|
36095
|
+
{
|
|
36096
|
+
kind: "Field",
|
|
36097
|
+
name: { kind: "Name", value: "signature" }
|
|
36098
|
+
},
|
|
36099
|
+
{
|
|
36100
|
+
kind: "Field",
|
|
36101
|
+
name: { kind: "Name", value: "startBlock" }
|
|
36102
|
+
},
|
|
36103
|
+
{
|
|
36104
|
+
kind: "Field",
|
|
36105
|
+
name: { kind: "Name", value: "endBlock" }
|
|
36106
|
+
},
|
|
36107
|
+
{
|
|
36108
|
+
kind: "Field",
|
|
36109
|
+
name: { kind: "Name", value: "addedAtBlock" }
|
|
36110
|
+
},
|
|
36111
|
+
{
|
|
36112
|
+
kind: "Field",
|
|
36113
|
+
name: { kind: "Name", value: "addedAtTimestamp" }
|
|
36114
|
+
},
|
|
36115
|
+
{
|
|
36116
|
+
kind: "Field",
|
|
36117
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36118
|
+
},
|
|
36119
|
+
{
|
|
36120
|
+
kind: "Field",
|
|
36121
|
+
name: { kind: "Name", value: "grantee" },
|
|
36122
|
+
selectionSet: {
|
|
36123
|
+
kind: "SelectionSet",
|
|
36124
|
+
selections: [
|
|
36125
|
+
{
|
|
36126
|
+
kind: "Field",
|
|
36127
|
+
name: { kind: "Name", value: "id" }
|
|
36128
|
+
},
|
|
36129
|
+
{
|
|
36130
|
+
kind: "Field",
|
|
36131
|
+
name: { kind: "Name", value: "address" }
|
|
36132
|
+
}
|
|
36133
|
+
]
|
|
36134
|
+
}
|
|
36135
|
+
},
|
|
36136
|
+
{
|
|
36137
|
+
kind: "Field",
|
|
36138
|
+
name: { kind: "Name", value: "filePermissions" },
|
|
36139
|
+
selectionSet: {
|
|
36140
|
+
kind: "SelectionSet",
|
|
36141
|
+
selections: [
|
|
36142
|
+
{
|
|
36143
|
+
kind: "Field",
|
|
36144
|
+
name: { kind: "Name", value: "file" },
|
|
36145
|
+
selectionSet: {
|
|
36146
|
+
kind: "SelectionSet",
|
|
36147
|
+
selections: [
|
|
36148
|
+
{
|
|
36149
|
+
kind: "Field",
|
|
36150
|
+
name: { kind: "Name", value: "id" }
|
|
36151
|
+
},
|
|
36152
|
+
{
|
|
36153
|
+
kind: "Field",
|
|
36154
|
+
name: { kind: "Name", value: "url" }
|
|
36155
|
+
}
|
|
36156
|
+
]
|
|
36157
|
+
}
|
|
36158
|
+
}
|
|
36159
|
+
]
|
|
36160
|
+
}
|
|
36161
|
+
}
|
|
36162
|
+
]
|
|
36163
|
+
}
|
|
36164
|
+
}
|
|
36165
|
+
]
|
|
36166
|
+
}
|
|
36167
|
+
}
|
|
36168
|
+
]
|
|
36169
|
+
}
|
|
36170
|
+
}
|
|
36171
|
+
]
|
|
36172
|
+
};
|
|
36173
|
+
GetUserTrustedServersDocument = {
|
|
36174
|
+
kind: "Document",
|
|
36175
|
+
definitions: [
|
|
36176
|
+
{
|
|
36177
|
+
kind: "OperationDefinition",
|
|
36178
|
+
operation: "query",
|
|
36179
|
+
name: { kind: "Name", value: "GetUserTrustedServers" },
|
|
36180
|
+
variableDefinitions: [
|
|
36181
|
+
{
|
|
36182
|
+
kind: "VariableDefinition",
|
|
36183
|
+
variable: {
|
|
36184
|
+
kind: "Variable",
|
|
36185
|
+
name: { kind: "Name", value: "userId" }
|
|
36186
|
+
},
|
|
36187
|
+
type: {
|
|
36188
|
+
kind: "NonNullType",
|
|
36189
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36190
|
+
}
|
|
36191
|
+
}
|
|
36192
|
+
],
|
|
36193
|
+
selectionSet: {
|
|
36194
|
+
kind: "SelectionSet",
|
|
36195
|
+
selections: [
|
|
36196
|
+
{
|
|
36197
|
+
kind: "Field",
|
|
36198
|
+
name: { kind: "Name", value: "user" },
|
|
36199
|
+
arguments: [
|
|
36200
|
+
{
|
|
36201
|
+
kind: "Argument",
|
|
36202
|
+
name: { kind: "Name", value: "id" },
|
|
36203
|
+
value: {
|
|
36204
|
+
kind: "Variable",
|
|
36205
|
+
name: { kind: "Name", value: "userId" }
|
|
36206
|
+
}
|
|
36207
|
+
}
|
|
36208
|
+
],
|
|
36209
|
+
selectionSet: {
|
|
36210
|
+
kind: "SelectionSet",
|
|
36211
|
+
selections: [
|
|
36212
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36213
|
+
{
|
|
36214
|
+
kind: "Field",
|
|
36215
|
+
name: { kind: "Name", value: "serverTrusts" },
|
|
36216
|
+
selectionSet: {
|
|
36217
|
+
kind: "SelectionSet",
|
|
36218
|
+
selections: [
|
|
36219
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36220
|
+
{
|
|
36221
|
+
kind: "Field",
|
|
36222
|
+
name: { kind: "Name", value: "server" },
|
|
36223
|
+
selectionSet: {
|
|
36224
|
+
kind: "SelectionSet",
|
|
36225
|
+
selections: [
|
|
36226
|
+
{
|
|
36227
|
+
kind: "Field",
|
|
36228
|
+
name: { kind: "Name", value: "id" }
|
|
36229
|
+
},
|
|
36230
|
+
{
|
|
36231
|
+
kind: "Field",
|
|
36232
|
+
name: { kind: "Name", value: "serverAddress" }
|
|
36233
|
+
},
|
|
36234
|
+
{
|
|
36235
|
+
kind: "Field",
|
|
36236
|
+
name: { kind: "Name", value: "url" }
|
|
36237
|
+
},
|
|
36238
|
+
{
|
|
36239
|
+
kind: "Field",
|
|
36240
|
+
name: { kind: "Name", value: "publicKey" }
|
|
36241
|
+
}
|
|
36242
|
+
]
|
|
36243
|
+
}
|
|
36244
|
+
},
|
|
36245
|
+
{
|
|
36246
|
+
kind: "Field",
|
|
36247
|
+
name: { kind: "Name", value: "trustedAt" }
|
|
36248
|
+
},
|
|
36249
|
+
{
|
|
36250
|
+
kind: "Field",
|
|
36251
|
+
name: { kind: "Name", value: "trustedAtBlock" }
|
|
36252
|
+
},
|
|
36253
|
+
{
|
|
36254
|
+
kind: "Field",
|
|
36255
|
+
name: { kind: "Name", value: "untrustedAtBlock" }
|
|
36256
|
+
},
|
|
36257
|
+
{
|
|
36258
|
+
kind: "Field",
|
|
36259
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36260
|
+
}
|
|
36261
|
+
]
|
|
36262
|
+
}
|
|
36263
|
+
}
|
|
36264
|
+
]
|
|
36265
|
+
}
|
|
36266
|
+
}
|
|
36267
|
+
]
|
|
36268
|
+
}
|
|
36269
|
+
}
|
|
36270
|
+
]
|
|
36271
|
+
};
|
|
36272
|
+
GetUserFilesDocument = {
|
|
36273
|
+
kind: "Document",
|
|
36274
|
+
definitions: [
|
|
36275
|
+
{
|
|
36276
|
+
kind: "OperationDefinition",
|
|
36277
|
+
operation: "query",
|
|
36278
|
+
name: { kind: "Name", value: "GetUserFiles" },
|
|
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: "files" },
|
|
36315
|
+
selectionSet: {
|
|
36316
|
+
kind: "SelectionSet",
|
|
36317
|
+
selections: [
|
|
36318
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36319
|
+
{ kind: "Field", name: { kind: "Name", value: "url" } },
|
|
36320
|
+
{
|
|
36321
|
+
kind: "Field",
|
|
36322
|
+
name: { kind: "Name", value: "schemaId" }
|
|
36323
|
+
},
|
|
36324
|
+
{
|
|
36325
|
+
kind: "Field",
|
|
36326
|
+
name: { kind: "Name", value: "addedAtBlock" }
|
|
36327
|
+
},
|
|
36328
|
+
{
|
|
36329
|
+
kind: "Field",
|
|
36330
|
+
name: { kind: "Name", value: "addedAtTimestamp" }
|
|
36331
|
+
},
|
|
36332
|
+
{
|
|
36333
|
+
kind: "Field",
|
|
36334
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36335
|
+
},
|
|
36336
|
+
{
|
|
36337
|
+
kind: "Field",
|
|
36338
|
+
name: { kind: "Name", value: "owner" },
|
|
36339
|
+
selectionSet: {
|
|
36340
|
+
kind: "SelectionSet",
|
|
36341
|
+
selections: [
|
|
36342
|
+
{
|
|
36343
|
+
kind: "Field",
|
|
36344
|
+
name: { kind: "Name", value: "id" }
|
|
36345
|
+
}
|
|
36346
|
+
]
|
|
36347
|
+
}
|
|
36348
|
+
}
|
|
36349
|
+
]
|
|
36350
|
+
}
|
|
36351
|
+
}
|
|
36352
|
+
]
|
|
36353
|
+
}
|
|
36354
|
+
}
|
|
36355
|
+
]
|
|
36356
|
+
}
|
|
36357
|
+
}
|
|
36358
|
+
]
|
|
36359
|
+
};
|
|
36360
|
+
GetFileProofsDocument = {
|
|
36361
|
+
kind: "Document",
|
|
36362
|
+
definitions: [
|
|
36363
|
+
{
|
|
36364
|
+
kind: "OperationDefinition",
|
|
36365
|
+
operation: "query",
|
|
36366
|
+
name: { kind: "Name", value: "GetFileProofs" },
|
|
36367
|
+
variableDefinitions: [
|
|
36368
|
+
{
|
|
36369
|
+
kind: "VariableDefinition",
|
|
36370
|
+
variable: {
|
|
36371
|
+
kind: "Variable",
|
|
36372
|
+
name: { kind: "Name", value: "fileIds" }
|
|
36373
|
+
},
|
|
36374
|
+
type: {
|
|
36375
|
+
kind: "NonNullType",
|
|
36376
|
+
type: {
|
|
36377
|
+
kind: "ListType",
|
|
36378
|
+
type: {
|
|
36379
|
+
kind: "NonNullType",
|
|
36380
|
+
type: {
|
|
36381
|
+
kind: "NamedType",
|
|
36382
|
+
name: { kind: "Name", value: "BigInt" }
|
|
36383
|
+
}
|
|
36384
|
+
}
|
|
36385
|
+
}
|
|
36386
|
+
}
|
|
36387
|
+
}
|
|
36388
|
+
],
|
|
36389
|
+
selectionSet: {
|
|
36390
|
+
kind: "SelectionSet",
|
|
36391
|
+
selections: [
|
|
36392
|
+
{
|
|
36393
|
+
kind: "Field",
|
|
36394
|
+
name: { kind: "Name", value: "dataRegistryProofs" },
|
|
36395
|
+
arguments: [
|
|
36396
|
+
{
|
|
36397
|
+
kind: "Argument",
|
|
36398
|
+
name: { kind: "Name", value: "where" },
|
|
36399
|
+
value: {
|
|
36400
|
+
kind: "ObjectValue",
|
|
36401
|
+
fields: [
|
|
36402
|
+
{
|
|
36403
|
+
kind: "ObjectField",
|
|
36404
|
+
name: { kind: "Name", value: "fileId_in" },
|
|
36405
|
+
value: {
|
|
36406
|
+
kind: "Variable",
|
|
36407
|
+
name: { kind: "Name", value: "fileIds" }
|
|
36408
|
+
}
|
|
36409
|
+
}
|
|
36410
|
+
]
|
|
36411
|
+
}
|
|
36412
|
+
}
|
|
36413
|
+
],
|
|
36414
|
+
selectionSet: {
|
|
36415
|
+
kind: "SelectionSet",
|
|
36416
|
+
selections: [
|
|
36417
|
+
{ kind: "Field", name: { kind: "Name", value: "fileId" } },
|
|
36418
|
+
{
|
|
36419
|
+
kind: "Field",
|
|
36420
|
+
name: { kind: "Name", value: "dlp" },
|
|
36421
|
+
selectionSet: {
|
|
36422
|
+
kind: "SelectionSet",
|
|
36423
|
+
selections: [
|
|
36424
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } }
|
|
36425
|
+
]
|
|
36426
|
+
}
|
|
36427
|
+
}
|
|
36428
|
+
]
|
|
36429
|
+
}
|
|
36430
|
+
}
|
|
36431
|
+
]
|
|
36432
|
+
}
|
|
36433
|
+
}
|
|
36434
|
+
]
|
|
36435
|
+
};
|
|
36436
|
+
GetDlpDocument = {
|
|
36437
|
+
kind: "Document",
|
|
36438
|
+
definitions: [
|
|
36439
|
+
{
|
|
36440
|
+
kind: "OperationDefinition",
|
|
36441
|
+
operation: "query",
|
|
36442
|
+
name: { kind: "Name", value: "GetDLP" },
|
|
36443
|
+
variableDefinitions: [
|
|
36444
|
+
{
|
|
36445
|
+
kind: "VariableDefinition",
|
|
36446
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
36447
|
+
type: {
|
|
36448
|
+
kind: "NonNullType",
|
|
36449
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36450
|
+
}
|
|
36451
|
+
}
|
|
36452
|
+
],
|
|
36453
|
+
selectionSet: {
|
|
36454
|
+
kind: "SelectionSet",
|
|
36455
|
+
selections: [
|
|
36456
|
+
{
|
|
36457
|
+
kind: "Field",
|
|
36458
|
+
name: { kind: "Name", value: "dlp" },
|
|
36459
|
+
arguments: [
|
|
36460
|
+
{
|
|
36461
|
+
kind: "Argument",
|
|
36462
|
+
name: { kind: "Name", value: "id" },
|
|
36463
|
+
value: {
|
|
36464
|
+
kind: "Variable",
|
|
36465
|
+
name: { kind: "Name", value: "id" }
|
|
36466
|
+
}
|
|
36467
|
+
}
|
|
36468
|
+
],
|
|
36469
|
+
selectionSet: {
|
|
36470
|
+
kind: "SelectionSet",
|
|
36471
|
+
selections: [
|
|
36472
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36473
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36474
|
+
{ kind: "Field", name: { kind: "Name", value: "metadata" } },
|
|
36475
|
+
{ kind: "Field", name: { kind: "Name", value: "status" } },
|
|
36476
|
+
{ kind: "Field", name: { kind: "Name", value: "address" } },
|
|
36477
|
+
{ kind: "Field", name: { kind: "Name", value: "owner" } }
|
|
36478
|
+
]
|
|
36479
|
+
}
|
|
36480
|
+
}
|
|
36481
|
+
]
|
|
36482
|
+
}
|
|
36483
|
+
}
|
|
36484
|
+
]
|
|
36485
|
+
};
|
|
36057
36486
|
GetSchemaDocument = {
|
|
36058
36487
|
kind: "Document",
|
|
36059
36488
|
definitions: [
|
|
@@ -36250,6 +36679,65 @@ var init_subgraph = __esm({
|
|
|
36250
36679
|
}
|
|
36251
36680
|
});
|
|
36252
36681
|
|
|
36682
|
+
// src/utils/blockchain/registry.ts
|
|
36683
|
+
async function fetchSchemaFromChain(context, schemaId) {
|
|
36684
|
+
const chainId = context.walletClient.chain?.id;
|
|
36685
|
+
if (!chainId) {
|
|
36686
|
+
throw new Error("Chain ID not available");
|
|
36687
|
+
}
|
|
36688
|
+
const dataRefinerRegistryAddress = getContractAddress(
|
|
36689
|
+
chainId,
|
|
36690
|
+
"DataRefinerRegistry"
|
|
36691
|
+
);
|
|
36692
|
+
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36693
|
+
const dataRefinerRegistry = (0, import_viem7.getContract)({
|
|
36694
|
+
address: dataRefinerRegistryAddress,
|
|
36695
|
+
abi: dataRefinerRegistryAbi,
|
|
36696
|
+
client: context.publicClient
|
|
36697
|
+
});
|
|
36698
|
+
const schemaData = await dataRefinerRegistry.read.schemas([BigInt(schemaId)]);
|
|
36699
|
+
if (!schemaData) {
|
|
36700
|
+
throw new Error(`Schema with ID ${schemaId} not found`);
|
|
36701
|
+
}
|
|
36702
|
+
const schemaObj = schemaData;
|
|
36703
|
+
if (!schemaObj.name || !schemaObj.dialect || !schemaObj.definitionUrl) {
|
|
36704
|
+
throw new Error("Incomplete schema data");
|
|
36705
|
+
}
|
|
36706
|
+
return {
|
|
36707
|
+
id: schemaId,
|
|
36708
|
+
name: schemaObj.name,
|
|
36709
|
+
dialect: schemaObj.dialect,
|
|
36710
|
+
definitionUrl: schemaObj.definitionUrl
|
|
36711
|
+
};
|
|
36712
|
+
}
|
|
36713
|
+
async function fetchSchemaCountFromChain(context) {
|
|
36714
|
+
const chainId = context.walletClient.chain?.id;
|
|
36715
|
+
if (!chainId) {
|
|
36716
|
+
throw new Error("Chain ID not available");
|
|
36717
|
+
}
|
|
36718
|
+
const dataRefinerRegistryAddress = getContractAddress(
|
|
36719
|
+
chainId,
|
|
36720
|
+
"DataRefinerRegistry"
|
|
36721
|
+
);
|
|
36722
|
+
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36723
|
+
const dataRefinerRegistry = (0, import_viem7.getContract)({
|
|
36724
|
+
address: dataRefinerRegistryAddress,
|
|
36725
|
+
abi: dataRefinerRegistryAbi,
|
|
36726
|
+
client: context.publicClient
|
|
36727
|
+
});
|
|
36728
|
+
const count = await dataRefinerRegistry.read.schemasCount();
|
|
36729
|
+
return Number(count);
|
|
36730
|
+
}
|
|
36731
|
+
var import_viem7;
|
|
36732
|
+
var init_registry = __esm({
|
|
36733
|
+
"src/utils/blockchain/registry.ts"() {
|
|
36734
|
+
"use strict";
|
|
36735
|
+
import_viem7 = require("viem");
|
|
36736
|
+
init_addresses();
|
|
36737
|
+
init_abi();
|
|
36738
|
+
}
|
|
36739
|
+
});
|
|
36740
|
+
|
|
36253
36741
|
// src/utils/urlResolver.ts
|
|
36254
36742
|
async function fetchFromUrl(url) {
|
|
36255
36743
|
try {
|
|
@@ -37549,6 +38037,7 @@ function parseReplicateOutput(response, typeGuard) {
|
|
|
37549
38037
|
init_errors();
|
|
37550
38038
|
|
|
37551
38039
|
// src/controllers/permissions.ts
|
|
38040
|
+
var import_viem6 = require("viem");
|
|
37552
38041
|
init_multicall();
|
|
37553
38042
|
init_transactionHandle();
|
|
37554
38043
|
init_errors();
|
|
@@ -37724,6 +38213,7 @@ function validateGrantFile(data) {
|
|
|
37724
38213
|
}
|
|
37725
38214
|
|
|
37726
38215
|
// src/utils/grantValidation.ts
|
|
38216
|
+
var import_viem4 = require("viem");
|
|
37727
38217
|
var import_ajv2 = __toESM(require("ajv"), 1);
|
|
37728
38218
|
var import_ajv_formats2 = __toESM(require("ajv-formats"), 1);
|
|
37729
38219
|
|
|
@@ -37927,7 +38417,9 @@ function extractFieldFromBusinessError(error) {
|
|
|
37927
38417
|
return void 0;
|
|
37928
38418
|
}
|
|
37929
38419
|
function validateGranteeAccess(grantFile, requestingAddress) {
|
|
37930
|
-
|
|
38420
|
+
const normalizedGrantee = (0, import_viem4.getAddress)(grantFile.grantee);
|
|
38421
|
+
const normalizedRequesting = (0, import_viem4.getAddress)(requestingAddress);
|
|
38422
|
+
if (normalizedGrantee !== normalizedRequesting) {
|
|
37931
38423
|
throw new GranteeMismatchError(
|
|
37932
38424
|
"Permission denied: requesting address does not match grantee",
|
|
37933
38425
|
grantFile.grantee,
|
|
@@ -37958,6 +38450,7 @@ function validateOperationAccess(grantFile, requestedOperation) {
|
|
|
37958
38450
|
}
|
|
37959
38451
|
|
|
37960
38452
|
// src/utils/signatureCache.ts
|
|
38453
|
+
var import_viem5 = require("viem");
|
|
37961
38454
|
init_crypto_utils();
|
|
37962
38455
|
var SignatureCache = class {
|
|
37963
38456
|
static PREFIX = "vana_sig_";
|
|
@@ -38051,7 +38544,7 @@ var SignatureCache = class {
|
|
|
38051
38544
|
}
|
|
38052
38545
|
}
|
|
38053
38546
|
static getCacheKey(walletAddress, messageHash) {
|
|
38054
|
-
return `${this.PREFIX}${
|
|
38547
|
+
return `${this.PREFIX}${(0, import_viem5.getAddress)(walletAddress)}:${messageHash}`;
|
|
38055
38548
|
}
|
|
38056
38549
|
/**
|
|
38057
38550
|
* Generate a deterministic hash of a message object for cache key generation
|
|
@@ -39324,20 +39817,22 @@ var PermissionsController = class {
|
|
|
39324
39817
|
if (!userData || !userData.permissions?.length) {
|
|
39325
39818
|
return [];
|
|
39326
39819
|
}
|
|
39327
|
-
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
39328
|
-
|
|
39329
|
-
|
|
39330
|
-
|
|
39331
|
-
|
|
39332
|
-
|
|
39333
|
-
|
|
39334
|
-
|
|
39335
|
-
|
|
39336
|
-
|
|
39337
|
-
|
|
39338
|
-
|
|
39339
|
-
|
|
39340
|
-
|
|
39820
|
+
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
39821
|
+
(permission) => ({
|
|
39822
|
+
id: BigInt(permission.id),
|
|
39823
|
+
grantUrl: permission.grant,
|
|
39824
|
+
grantSignature: permission.signature,
|
|
39825
|
+
nonce: BigInt(permission.nonce),
|
|
39826
|
+
startBlock: BigInt(permission.startBlock),
|
|
39827
|
+
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
39828
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
|
|
39829
|
+
transactionHash: permission.transactionHash || "",
|
|
39830
|
+
grantor: userAddress,
|
|
39831
|
+
grantee: permission.grantee,
|
|
39832
|
+
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
39833
|
+
// Active if no end block or end block is 0
|
|
39834
|
+
})
|
|
39835
|
+
);
|
|
39341
39836
|
return onChainGrants.sort((a, b) => {
|
|
39342
39837
|
if (a.id < b.id) return 1;
|
|
39343
39838
|
if (a.id > b.id) return -1;
|
|
@@ -39415,14 +39910,16 @@ var PermissionsController = class {
|
|
|
39415
39910
|
);
|
|
39416
39911
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
39417
39912
|
const userAddress = this.context.walletClient.account?.address || await this.getUserAddress();
|
|
39913
|
+
const normalizedUserAddress = (0, import_viem6.getAddress)(userAddress);
|
|
39914
|
+
const normalizedServerAddress = (0, import_viem6.getAddress)(params.serverAddress);
|
|
39418
39915
|
const txHash = await this.context.walletClient.writeContract({
|
|
39419
39916
|
address: DataPortabilityServersAddress,
|
|
39420
39917
|
abi: DataPortabilityServersAbi,
|
|
39421
39918
|
functionName: "addAndTrustServerByManager",
|
|
39422
39919
|
args: [
|
|
39423
|
-
|
|
39920
|
+
normalizedUserAddress,
|
|
39424
39921
|
{
|
|
39425
|
-
serverAddress:
|
|
39922
|
+
serverAddress: normalizedServerAddress,
|
|
39426
39923
|
serverUrl: params.serverUrl,
|
|
39427
39924
|
publicKey: params.publicKey
|
|
39428
39925
|
}
|
|
@@ -39492,9 +39989,10 @@ var PermissionsController = class {
|
|
|
39492
39989
|
async submitAddAndTrustServerWithSignature(params) {
|
|
39493
39990
|
try {
|
|
39494
39991
|
const nonce = await this.getServersUserNonce();
|
|
39992
|
+
const serverAddress = (0, import_viem6.getAddress)(params.serverAddress);
|
|
39495
39993
|
const addAndTrustServerInput = {
|
|
39496
39994
|
nonce,
|
|
39497
|
-
serverAddress
|
|
39995
|
+
serverAddress,
|
|
39498
39996
|
publicKey: params.publicKey,
|
|
39499
39997
|
serverUrl: params.serverUrl
|
|
39500
39998
|
};
|
|
@@ -40299,11 +40797,13 @@ var PermissionsController = class {
|
|
|
40299
40797
|
"DataPortabilityGrantees"
|
|
40300
40798
|
);
|
|
40301
40799
|
const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
|
|
40800
|
+
const ownerAddress = (0, import_viem6.getAddress)(params.owner);
|
|
40801
|
+
const granteeAddress = (0, import_viem6.getAddress)(params.granteeAddress);
|
|
40302
40802
|
const txHash = await this.context.walletClient.writeContract({
|
|
40303
40803
|
address: DataPortabilityGranteesAddress,
|
|
40304
40804
|
abi: DataPortabilityGranteesAbi,
|
|
40305
40805
|
functionName: "registerGrantee",
|
|
40306
|
-
args: [
|
|
40806
|
+
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
40307
40807
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
40308
40808
|
chain: this.context.walletClient.chain || null
|
|
40309
40809
|
});
|
|
@@ -40330,10 +40830,12 @@ var PermissionsController = class {
|
|
|
40330
40830
|
*/
|
|
40331
40831
|
async submitRegisterGranteeWithSignature(params) {
|
|
40332
40832
|
const nonce = await this.getServersUserNonce();
|
|
40833
|
+
const owner = (0, import_viem6.getAddress)(params.owner);
|
|
40834
|
+
const granteeAddress = (0, import_viem6.getAddress)(params.granteeAddress);
|
|
40333
40835
|
const registerGranteeInput = {
|
|
40334
40836
|
nonce,
|
|
40335
|
-
owner
|
|
40336
|
-
granteeAddress
|
|
40837
|
+
owner,
|
|
40838
|
+
granteeAddress,
|
|
40337
40839
|
publicKey: params.publicKey
|
|
40338
40840
|
};
|
|
40339
40841
|
const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
|
|
@@ -41841,10 +42343,12 @@ var PermissionsController = class {
|
|
|
41841
42343
|
};
|
|
41842
42344
|
|
|
41843
42345
|
// src/controllers/data.ts
|
|
41844
|
-
var
|
|
42346
|
+
var import_viem8 = require("viem");
|
|
41845
42347
|
init_transactionHandle();
|
|
41846
42348
|
init_addresses();
|
|
41847
42349
|
init_abi();
|
|
42350
|
+
init_subgraph();
|
|
42351
|
+
var import_graphql2 = require("graphql");
|
|
41848
42352
|
|
|
41849
42353
|
// src/utils/encryption.ts
|
|
41850
42354
|
var DEFAULT_ENCRYPTION_SEED = "Please sign to retrieve your encryption key";
|
|
@@ -42268,34 +42772,16 @@ var DataController = class {
|
|
|
42268
42772
|
);
|
|
42269
42773
|
}
|
|
42270
42774
|
try {
|
|
42271
|
-
const query = `
|
|
42272
|
-
query GetUserFiles($userId: ID!) {
|
|
42273
|
-
user(id: $userId) {
|
|
42274
|
-
id
|
|
42275
|
-
files {
|
|
42276
|
-
id
|
|
42277
|
-
url
|
|
42278
|
-
schemaId
|
|
42279
|
-
addedAtBlock
|
|
42280
|
-
addedAtTimestamp
|
|
42281
|
-
transactionHash
|
|
42282
|
-
owner {
|
|
42283
|
-
id
|
|
42284
|
-
}
|
|
42285
|
-
}
|
|
42286
|
-
}
|
|
42287
|
-
}
|
|
42288
|
-
`;
|
|
42289
42775
|
const response = await fetch(endpoint, {
|
|
42290
42776
|
method: "POST",
|
|
42291
42777
|
headers: {
|
|
42292
42778
|
"Content-Type": "application/json"
|
|
42293
42779
|
},
|
|
42294
42780
|
body: JSON.stringify({
|
|
42295
|
-
query,
|
|
42781
|
+
query: (0, import_graphql2.print)(GetUserFilesDocument),
|
|
42296
42782
|
variables: {
|
|
42297
42783
|
userId: owner.toLowerCase()
|
|
42298
|
-
// Subgraph
|
|
42784
|
+
// Subgraph requires lowercase addresses
|
|
42299
42785
|
}
|
|
42300
42786
|
})
|
|
42301
42787
|
});
|
|
@@ -42375,23 +42861,13 @@ var DataController = class {
|
|
|
42375
42861
|
* @returns Map of file IDs to their associated DLP IDs
|
|
42376
42862
|
*/
|
|
42377
42863
|
async _fetchProofsFromSubgraph(fileIds, subgraphUrl) {
|
|
42378
|
-
const query = `
|
|
42379
|
-
query GetFileProofs($fileIds: [BigInt!]!) {
|
|
42380
|
-
dataRegistryProofs(where: { fileId_in: $fileIds }) {
|
|
42381
|
-
fileId
|
|
42382
|
-
dlp {
|
|
42383
|
-
id
|
|
42384
|
-
}
|
|
42385
|
-
}
|
|
42386
|
-
}
|
|
42387
|
-
`;
|
|
42388
42864
|
const response = await fetch(subgraphUrl, {
|
|
42389
42865
|
method: "POST",
|
|
42390
42866
|
headers: {
|
|
42391
42867
|
"Content-Type": "application/json"
|
|
42392
42868
|
},
|
|
42393
42869
|
body: JSON.stringify({
|
|
42394
|
-
query,
|
|
42870
|
+
query: (0, import_graphql2.print)(GetFileProofsDocument),
|
|
42395
42871
|
variables: {
|
|
42396
42872
|
fileIds: fileIds.map((id) => id.toString())
|
|
42397
42873
|
}
|
|
@@ -42495,25 +42971,13 @@ var DataController = class {
|
|
|
42495
42971
|
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
42496
42972
|
if (subgraphUrl) {
|
|
42497
42973
|
try {
|
|
42498
|
-
const query = `
|
|
42499
|
-
query GetDLP($id: ID!) {
|
|
42500
|
-
dlp(id: $id) {
|
|
42501
|
-
id
|
|
42502
|
-
name
|
|
42503
|
-
metadata
|
|
42504
|
-
status
|
|
42505
|
-
address
|
|
42506
|
-
owner
|
|
42507
|
-
}
|
|
42508
|
-
}
|
|
42509
|
-
`;
|
|
42510
42974
|
const response = await fetch(subgraphUrl, {
|
|
42511
42975
|
method: "POST",
|
|
42512
42976
|
headers: {
|
|
42513
42977
|
"Content-Type": "application/json"
|
|
42514
42978
|
},
|
|
42515
42979
|
body: JSON.stringify({
|
|
42516
|
-
query,
|
|
42980
|
+
query: (0, import_graphql2.print)(GetDlpDocument),
|
|
42517
42981
|
variables: {
|
|
42518
42982
|
id: dlpId.toString()
|
|
42519
42983
|
}
|
|
@@ -42536,7 +43000,7 @@ var DataController = class {
|
|
|
42536
43000
|
return {
|
|
42537
43001
|
id: parseInt(result.data.dlp.id),
|
|
42538
43002
|
name: result.data.dlp.name || "",
|
|
42539
|
-
metadata: result.data.dlp.metadata,
|
|
43003
|
+
metadata: result.data.dlp.metadata || void 0,
|
|
42540
43004
|
status: result.data.dlp.status ? parseInt(result.data.dlp.status) : void 0,
|
|
42541
43005
|
address: result.data.dlp.address,
|
|
42542
43006
|
owner: result.data.dlp.owner
|
|
@@ -42750,32 +43214,13 @@ var DataController = class {
|
|
|
42750
43214
|
async _getUserPermissionsViaSubgraph(params) {
|
|
42751
43215
|
const { user, subgraphUrl } = params;
|
|
42752
43216
|
try {
|
|
42753
|
-
const query = `
|
|
42754
|
-
query GetUserPermissions($userId: ID!) {
|
|
42755
|
-
user(id: $userId) {
|
|
42756
|
-
id
|
|
42757
|
-
permissions {
|
|
42758
|
-
id
|
|
42759
|
-
grant
|
|
42760
|
-
nonce
|
|
42761
|
-
signature
|
|
42762
|
-
addedAtBlock
|
|
42763
|
-
addedAtTimestamp
|
|
42764
|
-
transactionHash
|
|
42765
|
-
user {
|
|
42766
|
-
id
|
|
42767
|
-
}
|
|
42768
|
-
}
|
|
42769
|
-
}
|
|
42770
|
-
}
|
|
42771
|
-
`;
|
|
42772
43217
|
const response = await fetch(subgraphUrl, {
|
|
42773
43218
|
method: "POST",
|
|
42774
43219
|
headers: {
|
|
42775
43220
|
"Content-Type": "application/json"
|
|
42776
43221
|
},
|
|
42777
43222
|
body: JSON.stringify({
|
|
42778
|
-
query,
|
|
43223
|
+
query: (0, import_graphql2.print)(GetUserPermissionsDocument),
|
|
42779
43224
|
variables: {
|
|
42780
43225
|
userId: user.toLowerCase()
|
|
42781
43226
|
}
|
|
@@ -42804,7 +43249,7 @@ var DataController = class {
|
|
|
42804
43249
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
42805
43250
|
addedAtTimestamp: BigInt(permission.addedAtTimestamp),
|
|
42806
43251
|
transactionHash: permission.transactionHash,
|
|
42807
|
-
user
|
|
43252
|
+
user
|
|
42808
43253
|
})).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
|
|
42809
43254
|
} catch (error) {
|
|
42810
43255
|
console.error("Failed to query user permissions from subgraph:", error);
|
|
@@ -42976,36 +43421,16 @@ var DataController = class {
|
|
|
42976
43421
|
);
|
|
42977
43422
|
}
|
|
42978
43423
|
try {
|
|
42979
|
-
const query = `
|
|
42980
|
-
query GetUserTrustedServers($userId: ID!) {
|
|
42981
|
-
user(id: $userId) {
|
|
42982
|
-
id
|
|
42983
|
-
serverTrusts {
|
|
42984
|
-
id
|
|
42985
|
-
server {
|
|
42986
|
-
id
|
|
42987
|
-
serverAddress
|
|
42988
|
-
url
|
|
42989
|
-
publicKey
|
|
42990
|
-
}
|
|
42991
|
-
trustedAt
|
|
42992
|
-
trustedAtBlock
|
|
42993
|
-
untrustedAtBlock
|
|
42994
|
-
transactionHash
|
|
42995
|
-
}
|
|
42996
|
-
}
|
|
42997
|
-
}
|
|
42998
|
-
`;
|
|
42999
43424
|
const response = await fetch(graphqlEndpoint, {
|
|
43000
43425
|
method: "POST",
|
|
43001
43426
|
headers: {
|
|
43002
43427
|
"Content-Type": "application/json"
|
|
43003
43428
|
},
|
|
43004
43429
|
body: JSON.stringify({
|
|
43005
|
-
query,
|
|
43430
|
+
query: (0, import_graphql2.print)(GetUserTrustedServersDocument),
|
|
43006
43431
|
variables: {
|
|
43007
43432
|
userId: user.toLowerCase()
|
|
43008
|
-
// Subgraph
|
|
43433
|
+
// Subgraph requires lowercase addresses
|
|
43009
43434
|
}
|
|
43010
43435
|
})
|
|
43011
43436
|
});
|
|
@@ -43155,7 +43580,7 @@ var DataController = class {
|
|
|
43155
43580
|
}
|
|
43156
43581
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
43157
43582
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
43158
|
-
const dataRegistry = (0,
|
|
43583
|
+
const dataRegistry = (0, import_viem8.getContract)({
|
|
43159
43584
|
address: dataRegistryAddress,
|
|
43160
43585
|
abi: dataRegistryAbi,
|
|
43161
43586
|
client: this.context.walletClient
|
|
@@ -43206,7 +43631,7 @@ var DataController = class {
|
|
|
43206
43631
|
}
|
|
43207
43632
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
43208
43633
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
43209
|
-
const dataRegistry = (0,
|
|
43634
|
+
const dataRegistry = (0, import_viem8.getContract)({
|
|
43210
43635
|
address: dataRegistryAddress,
|
|
43211
43636
|
abi: dataRegistryAbi,
|
|
43212
43637
|
client: this.context.walletClient
|
|
@@ -43513,7 +43938,7 @@ var DataController = class {
|
|
|
43513
43938
|
"DataRefinerRegistry"
|
|
43514
43939
|
);
|
|
43515
43940
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
43516
|
-
const dataRefinerRegistry = (0,
|
|
43941
|
+
const dataRefinerRegistry = (0, import_viem8.getContract)({
|
|
43517
43942
|
address: dataRefinerRegistryAddress,
|
|
43518
43943
|
abi: dataRefinerRegistryAbi,
|
|
43519
43944
|
client: this.context.walletClient
|
|
@@ -43569,7 +43994,7 @@ var DataController = class {
|
|
|
43569
43994
|
"DataRefinerRegistry"
|
|
43570
43995
|
);
|
|
43571
43996
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
43572
|
-
const dataRefinerRegistry = (0,
|
|
43997
|
+
const dataRefinerRegistry = (0, import_viem8.getContract)({
|
|
43573
43998
|
address: dataRefinerRegistryAddress,
|
|
43574
43999
|
abi: dataRefinerRegistryAbi,
|
|
43575
44000
|
client: this.context.walletClient
|
|
@@ -43608,7 +44033,7 @@ var DataController = class {
|
|
|
43608
44033
|
"DataRefinerRegistry"
|
|
43609
44034
|
);
|
|
43610
44035
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
43611
|
-
const dataRefinerRegistry = (0,
|
|
44036
|
+
const dataRefinerRegistry = (0, import_viem8.getContract)({
|
|
43612
44037
|
address: dataRefinerRegistryAddress,
|
|
43613
44038
|
abi: dataRefinerRegistryAbi,
|
|
43614
44039
|
client: this.context.walletClient
|
|
@@ -43839,19 +44264,31 @@ var DataController = class {
|
|
|
43839
44264
|
return await this.submitFilePermission(fileId, account, publicKey);
|
|
43840
44265
|
}
|
|
43841
44266
|
/**
|
|
43842
|
-
* Submits a file permission transaction
|
|
44267
|
+
* Submits a file permission transaction to the blockchain.
|
|
43843
44268
|
*
|
|
43844
|
-
*
|
|
44269
|
+
* @remarks
|
|
44270
|
+
* This method supports gasless transactions via relayer callbacks when configured.
|
|
44271
|
+
* It encrypts the user's encryption key with the recipient's public key before submission.
|
|
43845
44272
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
43846
44273
|
*
|
|
43847
|
-
* @param fileId - The ID of the file to
|
|
43848
|
-
* @param account - The
|
|
43849
|
-
* @param publicKey - The public key
|
|
43850
|
-
*
|
|
44274
|
+
* @param fileId - The ID of the file to grant permission for
|
|
44275
|
+
* @param account - The recipient's wallet address that will access the file
|
|
44276
|
+
* @param publicKey - The recipient's public key for encryption.
|
|
44277
|
+
* Obtain via `vana.server.getIdentity(account).public_key`
|
|
44278
|
+
* @returns Promise resolving to TransactionHandle for tracking the transaction
|
|
44279
|
+
* @throws {Error} When chain ID is not available
|
|
44280
|
+
* @throws {Error} When encryption key generation fails
|
|
44281
|
+
* @throws {Error} When public key encryption fails
|
|
44282
|
+
*
|
|
43851
44283
|
* @example
|
|
43852
44284
|
* ```typescript
|
|
43853
|
-
* const
|
|
43854
|
-
*
|
|
44285
|
+
* const tx = await vana.data.submitFilePermission(
|
|
44286
|
+
* fileId,
|
|
44287
|
+
* "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
44288
|
+
* recipientPublicKey
|
|
44289
|
+
* );
|
|
44290
|
+
* const result = await tx.waitForEvents();
|
|
44291
|
+
* console.log(`Permission granted with ID: ${result.permissionId}`);
|
|
43855
44292
|
* ```
|
|
43856
44293
|
*/
|
|
43857
44294
|
async submitFilePermission(fileId, account, publicKey) {
|
|
@@ -43907,7 +44344,7 @@ var DataController = class {
|
|
|
43907
44344
|
}
|
|
43908
44345
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
43909
44346
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
43910
|
-
const dataRegistry = (0,
|
|
44347
|
+
const dataRegistry = (0, import_viem8.getContract)({
|
|
43911
44348
|
address: dataRegistryAddress,
|
|
43912
44349
|
abi: dataRegistryAbi,
|
|
43913
44350
|
client: this.context.walletClient
|
|
@@ -44219,6 +44656,73 @@ init_schemas();
|
|
|
44219
44656
|
|
|
44220
44657
|
// src/controllers/server.ts
|
|
44221
44658
|
init_errors();
|
|
44659
|
+
|
|
44660
|
+
// src/utils/operationHandle.ts
|
|
44661
|
+
init_errors();
|
|
44662
|
+
var OperationHandle = class {
|
|
44663
|
+
constructor(controller, id) {
|
|
44664
|
+
this.controller = controller;
|
|
44665
|
+
this.id = id;
|
|
44666
|
+
}
|
|
44667
|
+
_resultPromise;
|
|
44668
|
+
/**
|
|
44669
|
+
* Waits for the operation to complete and returns the result.
|
|
44670
|
+
*
|
|
44671
|
+
* @remarks
|
|
44672
|
+
* Results are memoized - multiple calls return the same promise.
|
|
44673
|
+
* The method polls the server at regular intervals until the operation
|
|
44674
|
+
* succeeds, fails, or times out. Returns the raw string result from the
|
|
44675
|
+
* server - callers are responsible for parsing if needed.
|
|
44676
|
+
*
|
|
44677
|
+
* @param options - Optional polling configuration
|
|
44678
|
+
* @returns The operation result as a string when completed
|
|
44679
|
+
* @throws {PersonalServerError} When the operation fails or times out
|
|
44680
|
+
* @example
|
|
44681
|
+
* ```typescript
|
|
44682
|
+
* const result = await handle.waitForResult({
|
|
44683
|
+
* timeout: 60000,
|
|
44684
|
+
* pollingInterval: 500
|
|
44685
|
+
* });
|
|
44686
|
+
* // If expecting JSON, parse it:
|
|
44687
|
+
* const data = JSON.parse(result);
|
|
44688
|
+
* ```
|
|
44689
|
+
*/
|
|
44690
|
+
async waitForResult(options) {
|
|
44691
|
+
if (!this._resultPromise) {
|
|
44692
|
+
this._resultPromise = this.pollForCompletion(options);
|
|
44693
|
+
}
|
|
44694
|
+
return this._resultPromise;
|
|
44695
|
+
}
|
|
44696
|
+
async pollForCompletion(options) {
|
|
44697
|
+
const startTime = Date.now();
|
|
44698
|
+
const timeout = options?.timeout ?? 3e4;
|
|
44699
|
+
const interval = options?.pollingInterval ?? 500;
|
|
44700
|
+
while (true) {
|
|
44701
|
+
const result = await this.controller.getOperation(
|
|
44702
|
+
this.id
|
|
44703
|
+
);
|
|
44704
|
+
if (result.status === "succeeded") {
|
|
44705
|
+
if (result.result) {
|
|
44706
|
+
return result.result;
|
|
44707
|
+
}
|
|
44708
|
+
throw new PersonalServerError(
|
|
44709
|
+
"Operation succeeded but returned no result"
|
|
44710
|
+
);
|
|
44711
|
+
}
|
|
44712
|
+
if (result.status === "failed") {
|
|
44713
|
+
throw new PersonalServerError(
|
|
44714
|
+
`Operation ${result.status}: ${result.result || "Unknown error"}`
|
|
44715
|
+
);
|
|
44716
|
+
}
|
|
44717
|
+
if (Date.now() - startTime > timeout) {
|
|
44718
|
+
throw new PersonalServerError(`Operation timed out after ${timeout}ms`);
|
|
44719
|
+
}
|
|
44720
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
44721
|
+
}
|
|
44722
|
+
}
|
|
44723
|
+
};
|
|
44724
|
+
|
|
44725
|
+
// src/controllers/server.ts
|
|
44222
44726
|
var ServerController = class {
|
|
44223
44727
|
constructor(context) {
|
|
44224
44728
|
this.context = context;
|
|
@@ -44300,26 +44804,29 @@ var ServerController = class {
|
|
|
44300
44804
|
}
|
|
44301
44805
|
}
|
|
44302
44806
|
/**
|
|
44303
|
-
* Creates
|
|
44807
|
+
* Creates a server operation and returns a handle for lifecycle management.
|
|
44304
44808
|
*
|
|
44305
44809
|
* @remarks
|
|
44306
|
-
* This method submits a computation request to the personal server
|
|
44307
|
-
*
|
|
44308
|
-
*
|
|
44810
|
+
* This method submits a computation request to the personal server and returns
|
|
44811
|
+
* an OperationHandle that provides Promise-based methods for waiting on results.
|
|
44812
|
+
* The handle pattern matches TransactionHandle for consistency across async operations.
|
|
44813
|
+
*
|
|
44814
|
+
* @param params - The operation request parameters
|
|
44309
44815
|
* @param params.permissionId - The permission ID authorizing this operation.
|
|
44310
|
-
* Obtain
|
|
44311
|
-
* @returns
|
|
44312
|
-
* @throws {PersonalServerError} When server request fails or parameters are invalid
|
|
44313
|
-
*
|
|
44314
|
-
* @throws {NetworkError} When personal server API communication fails.
|
|
44315
|
-
* Check server URL configuration and network connectivity.
|
|
44816
|
+
* Obtain via `vana.permissions.getUserPermissionGrantsOnChain()`.
|
|
44817
|
+
* @returns An OperationHandle providing access to the operation ID and result methods
|
|
44818
|
+
* @throws {PersonalServerError} When the server request fails or parameters are invalid
|
|
44819
|
+
* @throws {NetworkError} When personal server API communication fails
|
|
44316
44820
|
* @example
|
|
44317
44821
|
* ```typescript
|
|
44318
|
-
* const
|
|
44319
|
-
* permissionId: 123
|
|
44822
|
+
* const operation = await vana.server.createOperation({
|
|
44823
|
+
* permissionId: 123
|
|
44320
44824
|
* });
|
|
44321
|
-
*
|
|
44322
|
-
*
|
|
44825
|
+
* console.log(`Operation ID: ${operation.id}`);
|
|
44826
|
+
*
|
|
44827
|
+
* // Wait for completion
|
|
44828
|
+
* const result = await operation.waitForResult();
|
|
44829
|
+
* console.log("Result:", result);
|
|
44323
44830
|
* ```
|
|
44324
44831
|
*/
|
|
44325
44832
|
async createOperation(params) {
|
|
@@ -44335,7 +44842,7 @@ var ServerController = class {
|
|
|
44335
44842
|
};
|
|
44336
44843
|
console.debug("\u{1F50D} Debug - createOperation requestBody", requestBody);
|
|
44337
44844
|
const response = await this.makeRequest(requestBody);
|
|
44338
|
-
return response;
|
|
44845
|
+
return new OperationHandle(this, response.id);
|
|
44339
44846
|
} catch (error) {
|
|
44340
44847
|
if (error instanceof Error) {
|
|
44341
44848
|
if (error instanceof NetworkError || error instanceof SerializationError || error instanceof SignatureError || error instanceof PersonalServerError) {
|
|
@@ -44352,30 +44859,20 @@ var ServerController = class {
|
|
|
44352
44859
|
}
|
|
44353
44860
|
}
|
|
44354
44861
|
/**
|
|
44355
|
-
*
|
|
44862
|
+
* Retrieves the current status and result of a server operation.
|
|
44356
44863
|
*
|
|
44357
44864
|
* @remarks
|
|
44358
|
-
*
|
|
44359
|
-
*
|
|
44360
|
-
*
|
|
44361
|
-
*
|
|
44362
|
-
*
|
|
44363
|
-
*
|
|
44364
|
-
* @param operationId - The operation ID returned from the initial request submission
|
|
44365
|
-
* @returns A Promise that resolves to the current operation response with status and results
|
|
44366
|
-
* @throws {NetworkError} When the polling request fails or returns invalid data
|
|
44865
|
+
* Common status values: `starting`, `running`, `succeeded`, `failed`, `canceled`.
|
|
44866
|
+
* When status is `succeeded`, the result field contains the operation output.
|
|
44867
|
+
*
|
|
44868
|
+
* @param operationId - The ID of the operation to query
|
|
44869
|
+
* @returns The operation response containing status, result, and metadata
|
|
44870
|
+
* @throws {NetworkError} When the API request fails or returns invalid data
|
|
44367
44871
|
* @example
|
|
44368
44872
|
* ```typescript
|
|
44369
|
-
*
|
|
44370
|
-
*
|
|
44371
|
-
*
|
|
44372
|
-
* while (result.status === "processing") {
|
|
44373
|
-
* await new Promise(resolve => setTimeout(resolve, 1000));
|
|
44374
|
-
* result = await vana.server.getOperation(response.id);
|
|
44375
|
-
* }
|
|
44376
|
-
*
|
|
44377
|
-
* if (result.status === "succeeded") {
|
|
44378
|
-
* console.log("Computation completed:", result.output);
|
|
44873
|
+
* const status = await vana.server.getOperation(operationId);
|
|
44874
|
+
* if (status.status === 'succeeded') {
|
|
44875
|
+
* console.log('Result:', JSON.parse(status.result));
|
|
44379
44876
|
* }
|
|
44380
44877
|
* ```
|
|
44381
44878
|
*/
|
|
@@ -44566,16 +45063,16 @@ var ServerController = class {
|
|
|
44566
45063
|
init_errors();
|
|
44567
45064
|
|
|
44568
45065
|
// src/contracts/contractController.ts
|
|
44569
|
-
var
|
|
45066
|
+
var import_viem11 = require("viem");
|
|
44570
45067
|
init_abi();
|
|
44571
45068
|
init_addresses();
|
|
44572
45069
|
|
|
44573
45070
|
// src/core/client.ts
|
|
44574
|
-
var
|
|
45071
|
+
var import_viem10 = require("viem");
|
|
44575
45072
|
|
|
44576
45073
|
// src/config/chains.ts
|
|
44577
|
-
var
|
|
44578
|
-
var mokshaTestnet = (0,
|
|
45074
|
+
var import_viem9 = require("viem");
|
|
45075
|
+
var mokshaTestnet = (0, import_viem9.defineChain)({
|
|
44579
45076
|
id: 14800,
|
|
44580
45077
|
caipNetworkId: "eip155:14800",
|
|
44581
45078
|
chainNamespace: "eip155",
|
|
@@ -44603,7 +45100,7 @@ var mokshaTestnet = (0, import_viem6.defineChain)({
|
|
|
44603
45100
|
contracts: {},
|
|
44604
45101
|
abis: {}
|
|
44605
45102
|
});
|
|
44606
|
-
var vanaMainnet = (0,
|
|
45103
|
+
var vanaMainnet = (0, import_viem9.defineChain)({
|
|
44607
45104
|
id: 1480,
|
|
44608
45105
|
caipNetworkId: "eip155:1480",
|
|
44609
45106
|
chainNamespace: "eip155",
|
|
@@ -44650,9 +45147,9 @@ var createClient = (chainId = mokshaTestnet.id) => {
|
|
|
44650
45147
|
if (!chain) {
|
|
44651
45148
|
throw new Error(`Chain ${chainId} not found`);
|
|
44652
45149
|
}
|
|
44653
|
-
_client = (0,
|
|
45150
|
+
_client = (0, import_viem10.createPublicClient)({
|
|
44654
45151
|
chain,
|
|
44655
|
-
transport: (0,
|
|
45152
|
+
transport: (0, import_viem10.http)()
|
|
44656
45153
|
});
|
|
44657
45154
|
}
|
|
44658
45155
|
return _client;
|
|
@@ -44669,7 +45166,7 @@ function getContractController(contract, client = createClient()) {
|
|
|
44669
45166
|
const cacheKey = createCacheKey(contract, chainId);
|
|
44670
45167
|
let controller = contractCache.get(cacheKey);
|
|
44671
45168
|
if (!controller) {
|
|
44672
|
-
controller = (0,
|
|
45169
|
+
controller = (0, import_viem11.getContract)({
|
|
44673
45170
|
address: getContractAddress(chainId, contract),
|
|
44674
45171
|
abi: getAbi(contract),
|
|
44675
45172
|
client
|
|
@@ -46265,7 +46762,7 @@ var StorageManager = class {
|
|
|
46265
46762
|
};
|
|
46266
46763
|
|
|
46267
46764
|
// src/core.ts
|
|
46268
|
-
var
|
|
46765
|
+
var import_viem12 = require("viem");
|
|
46269
46766
|
|
|
46270
46767
|
// src/chains/definitions.ts
|
|
46271
46768
|
var vanaMainnet2 = {
|
|
@@ -46443,9 +46940,9 @@ var VanaCore = class {
|
|
|
46443
46940
|
`Unsupported chain ID: ${config.chainId}`
|
|
46444
46941
|
);
|
|
46445
46942
|
}
|
|
46446
|
-
walletClient = (0,
|
|
46943
|
+
walletClient = (0, import_viem12.createWalletClient)({
|
|
46447
46944
|
chain,
|
|
46448
|
-
transport: (0,
|
|
46945
|
+
transport: (0, import_viem12.http)(config.rpcUrl || chain.rpcUrls.default.http[0]),
|
|
46449
46946
|
account: config.account
|
|
46450
46947
|
});
|
|
46451
46948
|
} else {
|
|
@@ -46453,9 +46950,9 @@ var VanaCore = class {
|
|
|
46453
46950
|
"Invalid configuration: must be either WalletConfig or ChainConfig"
|
|
46454
46951
|
);
|
|
46455
46952
|
}
|
|
46456
|
-
const publicClient = (0,
|
|
46953
|
+
const publicClient = (0, import_viem12.createPublicClient)({
|
|
46457
46954
|
chain: walletClient.chain,
|
|
46458
|
-
transport: (0,
|
|
46955
|
+
transport: (0, import_viem12.http)()
|
|
46459
46956
|
});
|
|
46460
46957
|
const chainConfig = getChainConfig(walletClient.chain.id);
|
|
46461
46958
|
const subgraphUrl = config.subgraphUrl || chainConfig?.subgraphUrl;
|
|
@@ -46819,15 +47316,15 @@ init_errors();
|
|
|
46819
47316
|
init_schemas();
|
|
46820
47317
|
|
|
46821
47318
|
// src/utils/formatters.ts
|
|
46822
|
-
var
|
|
47319
|
+
var import_viem13 = require("viem");
|
|
46823
47320
|
function formatNumber(value) {
|
|
46824
47321
|
return Number(value);
|
|
46825
47322
|
}
|
|
46826
47323
|
function formatEth(wei, decimals = 4) {
|
|
46827
|
-
return (0,
|
|
47324
|
+
return (0, import_viem13.formatEther)(BigInt(wei.toString())).slice(0, decimals + 2);
|
|
46828
47325
|
}
|
|
46829
47326
|
function formatToken(amount, decimals = 18, displayDecimals = 4) {
|
|
46830
|
-
const value = (0,
|
|
47327
|
+
const value = (0, import_viem13.formatUnits)(BigInt(amount.toString()), decimals);
|
|
46831
47328
|
const parts = value.split(".");
|
|
46832
47329
|
if (parts.length === 1) {
|
|
46833
47330
|
return parts[0];
|
|
@@ -47262,7 +47759,7 @@ var CircuitBreaker = class {
|
|
|
47262
47759
|
};
|
|
47263
47760
|
|
|
47264
47761
|
// src/server/handler.ts
|
|
47265
|
-
var
|
|
47762
|
+
var import_viem14 = require("viem");
|
|
47266
47763
|
init_errors();
|
|
47267
47764
|
async function handleRelayerRequest(sdk, payload) {
|
|
47268
47765
|
const { typedData, signature, expectedUserAddress } = payload;
|
|
@@ -47273,7 +47770,7 @@ async function handleRelayerRequest(sdk, payload) {
|
|
|
47273
47770
|
message: typedData.message,
|
|
47274
47771
|
signature
|
|
47275
47772
|
});
|
|
47276
|
-
const signerAddress = await (0,
|
|
47773
|
+
const signerAddress = await (0, import_viem14.recoverTypedDataAddress)({
|
|
47277
47774
|
domain: typedData.domain,
|
|
47278
47775
|
types: typedData.types,
|
|
47279
47776
|
primaryType: typedData.primaryType,
|
|
@@ -47286,21 +47783,22 @@ async function handleRelayerRequest(sdk, payload) {
|
|
|
47286
47783
|
);
|
|
47287
47784
|
}
|
|
47288
47785
|
if (expectedUserAddress) {
|
|
47289
|
-
const normalizedSigner =
|
|
47290
|
-
const normalizedExpected =
|
|
47786
|
+
const normalizedSigner = (0, import_viem14.getAddress)(signerAddress);
|
|
47787
|
+
const normalizedExpected = (0, import_viem14.getAddress)(expectedUserAddress);
|
|
47291
47788
|
if (normalizedSigner !== normalizedExpected) {
|
|
47292
47789
|
throw new SignatureError(
|
|
47293
47790
|
`Security verification failed: Recovered signer address (${normalizedSigner}) does not match expected user address (${normalizedExpected}). This may be due to incorrect EIP-712 domain configuration.`
|
|
47294
47791
|
);
|
|
47295
47792
|
}
|
|
47296
47793
|
}
|
|
47297
|
-
|
|
47794
|
+
const primaryType = typedData.primaryType;
|
|
47795
|
+
switch (primaryType) {
|
|
47298
47796
|
case "Permission":
|
|
47299
47797
|
return sdk.permissions.submitSignedGrant(
|
|
47300
47798
|
typedData,
|
|
47301
47799
|
signature
|
|
47302
47800
|
);
|
|
47303
|
-
case "
|
|
47801
|
+
case "RevokePermission":
|
|
47304
47802
|
return sdk.permissions.submitSignedRevoke(
|
|
47305
47803
|
typedData,
|
|
47306
47804
|
signature
|