@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.js
CHANGED
|
@@ -2789,6 +2789,19 @@ var init_DataRegistryImplementation = __esm({
|
|
|
2789
2789
|
name: "Upgraded",
|
|
2790
2790
|
type: "event"
|
|
2791
2791
|
},
|
|
2792
|
+
{
|
|
2793
|
+
inputs: [],
|
|
2794
|
+
name: "DATA_PORTABILITY_ROLE",
|
|
2795
|
+
outputs: [
|
|
2796
|
+
{
|
|
2797
|
+
internalType: "bytes32",
|
|
2798
|
+
name: "",
|
|
2799
|
+
type: "bytes32"
|
|
2800
|
+
}
|
|
2801
|
+
],
|
|
2802
|
+
stateMutability: "view",
|
|
2803
|
+
type: "function"
|
|
2804
|
+
},
|
|
2792
2805
|
{
|
|
2793
2806
|
inputs: [],
|
|
2794
2807
|
name: "DEFAULT_ADMIN_ROLE",
|
|
@@ -2883,6 +2896,41 @@ var init_DataRegistryImplementation = __esm({
|
|
|
2883
2896
|
stateMutability: "nonpayable",
|
|
2884
2897
|
type: "function"
|
|
2885
2898
|
},
|
|
2899
|
+
{
|
|
2900
|
+
inputs: [
|
|
2901
|
+
{
|
|
2902
|
+
internalType: "uint256",
|
|
2903
|
+
name: "fileId",
|
|
2904
|
+
type: "uint256"
|
|
2905
|
+
},
|
|
2906
|
+
{
|
|
2907
|
+
components: [
|
|
2908
|
+
{
|
|
2909
|
+
internalType: "address",
|
|
2910
|
+
name: "account",
|
|
2911
|
+
type: "address"
|
|
2912
|
+
},
|
|
2913
|
+
{
|
|
2914
|
+
internalType: "string",
|
|
2915
|
+
name: "key",
|
|
2916
|
+
type: "string"
|
|
2917
|
+
}
|
|
2918
|
+
],
|
|
2919
|
+
internalType: "struct IDataRegistry.Permission[]",
|
|
2920
|
+
name: "permissions",
|
|
2921
|
+
type: "tuple[]"
|
|
2922
|
+
},
|
|
2923
|
+
{
|
|
2924
|
+
internalType: "uint256",
|
|
2925
|
+
name: "schemaId",
|
|
2926
|
+
type: "uint256"
|
|
2927
|
+
}
|
|
2928
|
+
],
|
|
2929
|
+
name: "addFilePermissionsAndSchema",
|
|
2930
|
+
outputs: [],
|
|
2931
|
+
stateMutability: "nonpayable",
|
|
2932
|
+
type: "function"
|
|
2933
|
+
},
|
|
2886
2934
|
{
|
|
2887
2935
|
inputs: [
|
|
2888
2936
|
{
|
|
@@ -35967,69 +36015,451 @@ var init_ipfs = __esm({
|
|
|
35967
36015
|
}
|
|
35968
36016
|
});
|
|
35969
36017
|
|
|
35970
|
-
// src/utils/blockchain/registry.ts
|
|
35971
|
-
import { getContract } from "viem";
|
|
35972
|
-
async function fetchSchemaFromChain(context, schemaId) {
|
|
35973
|
-
const chainId = context.walletClient.chain?.id;
|
|
35974
|
-
if (!chainId) {
|
|
35975
|
-
throw new Error("Chain ID not available");
|
|
35976
|
-
}
|
|
35977
|
-
const dataRefinerRegistryAddress = getContractAddress(
|
|
35978
|
-
chainId,
|
|
35979
|
-
"DataRefinerRegistry"
|
|
35980
|
-
);
|
|
35981
|
-
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
35982
|
-
const dataRefinerRegistry = getContract({
|
|
35983
|
-
address: dataRefinerRegistryAddress,
|
|
35984
|
-
abi: dataRefinerRegistryAbi,
|
|
35985
|
-
client: context.publicClient
|
|
35986
|
-
});
|
|
35987
|
-
const schemaData = await dataRefinerRegistry.read.schemas([BigInt(schemaId)]);
|
|
35988
|
-
if (!schemaData) {
|
|
35989
|
-
throw new Error(`Schema with ID ${schemaId} not found`);
|
|
35990
|
-
}
|
|
35991
|
-
const schemaObj = schemaData;
|
|
35992
|
-
if (!schemaObj.name || !schemaObj.dialect || !schemaObj.definitionUrl) {
|
|
35993
|
-
throw new Error("Incomplete schema data");
|
|
35994
|
-
}
|
|
35995
|
-
return {
|
|
35996
|
-
id: schemaId,
|
|
35997
|
-
name: schemaObj.name,
|
|
35998
|
-
dialect: schemaObj.dialect,
|
|
35999
|
-
definitionUrl: schemaObj.definitionUrl
|
|
36000
|
-
};
|
|
36001
|
-
}
|
|
36002
|
-
async function fetchSchemaCountFromChain(context) {
|
|
36003
|
-
const chainId = context.walletClient.chain?.id;
|
|
36004
|
-
if (!chainId) {
|
|
36005
|
-
throw new Error("Chain ID not available");
|
|
36006
|
-
}
|
|
36007
|
-
const dataRefinerRegistryAddress = getContractAddress(
|
|
36008
|
-
chainId,
|
|
36009
|
-
"DataRefinerRegistry"
|
|
36010
|
-
);
|
|
36011
|
-
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36012
|
-
const dataRefinerRegistry = getContract({
|
|
36013
|
-
address: dataRefinerRegistryAddress,
|
|
36014
|
-
abi: dataRefinerRegistryAbi,
|
|
36015
|
-
client: context.publicClient
|
|
36016
|
-
});
|
|
36017
|
-
const count = await dataRefinerRegistry.read.schemasCount();
|
|
36018
|
-
return Number(count);
|
|
36019
|
-
}
|
|
36020
|
-
var init_registry = __esm({
|
|
36021
|
-
"src/utils/blockchain/registry.ts"() {
|
|
36022
|
-
"use strict";
|
|
36023
|
-
init_addresses();
|
|
36024
|
-
init_abi();
|
|
36025
|
-
}
|
|
36026
|
-
});
|
|
36027
|
-
|
|
36028
36018
|
// src/generated/subgraph.ts
|
|
36029
|
-
var GetSchemaDocument, ListSchemasDocument, CountSchemasDocument;
|
|
36019
|
+
var GetUserPermissionsDocument, GetUserTrustedServersDocument, GetUserFilesDocument, GetFileProofsDocument, GetDlpDocument, GetSchemaDocument, ListSchemasDocument, CountSchemasDocument;
|
|
36030
36020
|
var init_subgraph = __esm({
|
|
36031
36021
|
"src/generated/subgraph.ts"() {
|
|
36032
36022
|
"use strict";
|
|
36023
|
+
GetUserPermissionsDocument = {
|
|
36024
|
+
kind: "Document",
|
|
36025
|
+
definitions: [
|
|
36026
|
+
{
|
|
36027
|
+
kind: "OperationDefinition",
|
|
36028
|
+
operation: "query",
|
|
36029
|
+
name: { kind: "Name", value: "GetUserPermissions" },
|
|
36030
|
+
variableDefinitions: [
|
|
36031
|
+
{
|
|
36032
|
+
kind: "VariableDefinition",
|
|
36033
|
+
variable: {
|
|
36034
|
+
kind: "Variable",
|
|
36035
|
+
name: { kind: "Name", value: "userId" }
|
|
36036
|
+
},
|
|
36037
|
+
type: {
|
|
36038
|
+
kind: "NonNullType",
|
|
36039
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36040
|
+
}
|
|
36041
|
+
}
|
|
36042
|
+
],
|
|
36043
|
+
selectionSet: {
|
|
36044
|
+
kind: "SelectionSet",
|
|
36045
|
+
selections: [
|
|
36046
|
+
{
|
|
36047
|
+
kind: "Field",
|
|
36048
|
+
name: { kind: "Name", value: "user" },
|
|
36049
|
+
arguments: [
|
|
36050
|
+
{
|
|
36051
|
+
kind: "Argument",
|
|
36052
|
+
name: { kind: "Name", value: "id" },
|
|
36053
|
+
value: {
|
|
36054
|
+
kind: "Variable",
|
|
36055
|
+
name: { kind: "Name", value: "userId" }
|
|
36056
|
+
}
|
|
36057
|
+
}
|
|
36058
|
+
],
|
|
36059
|
+
selectionSet: {
|
|
36060
|
+
kind: "SelectionSet",
|
|
36061
|
+
selections: [
|
|
36062
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36063
|
+
{
|
|
36064
|
+
kind: "Field",
|
|
36065
|
+
name: { kind: "Name", value: "permissions" },
|
|
36066
|
+
selectionSet: {
|
|
36067
|
+
kind: "SelectionSet",
|
|
36068
|
+
selections: [
|
|
36069
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36070
|
+
{ kind: "Field", name: { kind: "Name", value: "grant" } },
|
|
36071
|
+
{ kind: "Field", name: { kind: "Name", value: "nonce" } },
|
|
36072
|
+
{
|
|
36073
|
+
kind: "Field",
|
|
36074
|
+
name: { kind: "Name", value: "signature" }
|
|
36075
|
+
},
|
|
36076
|
+
{
|
|
36077
|
+
kind: "Field",
|
|
36078
|
+
name: { kind: "Name", value: "startBlock" }
|
|
36079
|
+
},
|
|
36080
|
+
{
|
|
36081
|
+
kind: "Field",
|
|
36082
|
+
name: { kind: "Name", value: "endBlock" }
|
|
36083
|
+
},
|
|
36084
|
+
{
|
|
36085
|
+
kind: "Field",
|
|
36086
|
+
name: { kind: "Name", value: "addedAtBlock" }
|
|
36087
|
+
},
|
|
36088
|
+
{
|
|
36089
|
+
kind: "Field",
|
|
36090
|
+
name: { kind: "Name", value: "addedAtTimestamp" }
|
|
36091
|
+
},
|
|
36092
|
+
{
|
|
36093
|
+
kind: "Field",
|
|
36094
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36095
|
+
},
|
|
36096
|
+
{
|
|
36097
|
+
kind: "Field",
|
|
36098
|
+
name: { kind: "Name", value: "grantee" },
|
|
36099
|
+
selectionSet: {
|
|
36100
|
+
kind: "SelectionSet",
|
|
36101
|
+
selections: [
|
|
36102
|
+
{
|
|
36103
|
+
kind: "Field",
|
|
36104
|
+
name: { kind: "Name", value: "id" }
|
|
36105
|
+
},
|
|
36106
|
+
{
|
|
36107
|
+
kind: "Field",
|
|
36108
|
+
name: { kind: "Name", value: "address" }
|
|
36109
|
+
}
|
|
36110
|
+
]
|
|
36111
|
+
}
|
|
36112
|
+
},
|
|
36113
|
+
{
|
|
36114
|
+
kind: "Field",
|
|
36115
|
+
name: { kind: "Name", value: "filePermissions" },
|
|
36116
|
+
selectionSet: {
|
|
36117
|
+
kind: "SelectionSet",
|
|
36118
|
+
selections: [
|
|
36119
|
+
{
|
|
36120
|
+
kind: "Field",
|
|
36121
|
+
name: { kind: "Name", value: "file" },
|
|
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: "url" }
|
|
36132
|
+
}
|
|
36133
|
+
]
|
|
36134
|
+
}
|
|
36135
|
+
}
|
|
36136
|
+
]
|
|
36137
|
+
}
|
|
36138
|
+
}
|
|
36139
|
+
]
|
|
36140
|
+
}
|
|
36141
|
+
}
|
|
36142
|
+
]
|
|
36143
|
+
}
|
|
36144
|
+
}
|
|
36145
|
+
]
|
|
36146
|
+
}
|
|
36147
|
+
}
|
|
36148
|
+
]
|
|
36149
|
+
};
|
|
36150
|
+
GetUserTrustedServersDocument = {
|
|
36151
|
+
kind: "Document",
|
|
36152
|
+
definitions: [
|
|
36153
|
+
{
|
|
36154
|
+
kind: "OperationDefinition",
|
|
36155
|
+
operation: "query",
|
|
36156
|
+
name: { kind: "Name", value: "GetUserTrustedServers" },
|
|
36157
|
+
variableDefinitions: [
|
|
36158
|
+
{
|
|
36159
|
+
kind: "VariableDefinition",
|
|
36160
|
+
variable: {
|
|
36161
|
+
kind: "Variable",
|
|
36162
|
+
name: { kind: "Name", value: "userId" }
|
|
36163
|
+
},
|
|
36164
|
+
type: {
|
|
36165
|
+
kind: "NonNullType",
|
|
36166
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36167
|
+
}
|
|
36168
|
+
}
|
|
36169
|
+
],
|
|
36170
|
+
selectionSet: {
|
|
36171
|
+
kind: "SelectionSet",
|
|
36172
|
+
selections: [
|
|
36173
|
+
{
|
|
36174
|
+
kind: "Field",
|
|
36175
|
+
name: { kind: "Name", value: "user" },
|
|
36176
|
+
arguments: [
|
|
36177
|
+
{
|
|
36178
|
+
kind: "Argument",
|
|
36179
|
+
name: { kind: "Name", value: "id" },
|
|
36180
|
+
value: {
|
|
36181
|
+
kind: "Variable",
|
|
36182
|
+
name: { kind: "Name", value: "userId" }
|
|
36183
|
+
}
|
|
36184
|
+
}
|
|
36185
|
+
],
|
|
36186
|
+
selectionSet: {
|
|
36187
|
+
kind: "SelectionSet",
|
|
36188
|
+
selections: [
|
|
36189
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36190
|
+
{
|
|
36191
|
+
kind: "Field",
|
|
36192
|
+
name: { kind: "Name", value: "serverTrusts" },
|
|
36193
|
+
selectionSet: {
|
|
36194
|
+
kind: "SelectionSet",
|
|
36195
|
+
selections: [
|
|
36196
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36197
|
+
{
|
|
36198
|
+
kind: "Field",
|
|
36199
|
+
name: { kind: "Name", value: "server" },
|
|
36200
|
+
selectionSet: {
|
|
36201
|
+
kind: "SelectionSet",
|
|
36202
|
+
selections: [
|
|
36203
|
+
{
|
|
36204
|
+
kind: "Field",
|
|
36205
|
+
name: { kind: "Name", value: "id" }
|
|
36206
|
+
},
|
|
36207
|
+
{
|
|
36208
|
+
kind: "Field",
|
|
36209
|
+
name: { kind: "Name", value: "serverAddress" }
|
|
36210
|
+
},
|
|
36211
|
+
{
|
|
36212
|
+
kind: "Field",
|
|
36213
|
+
name: { kind: "Name", value: "url" }
|
|
36214
|
+
},
|
|
36215
|
+
{
|
|
36216
|
+
kind: "Field",
|
|
36217
|
+
name: { kind: "Name", value: "publicKey" }
|
|
36218
|
+
}
|
|
36219
|
+
]
|
|
36220
|
+
}
|
|
36221
|
+
},
|
|
36222
|
+
{
|
|
36223
|
+
kind: "Field",
|
|
36224
|
+
name: { kind: "Name", value: "trustedAt" }
|
|
36225
|
+
},
|
|
36226
|
+
{
|
|
36227
|
+
kind: "Field",
|
|
36228
|
+
name: { kind: "Name", value: "trustedAtBlock" }
|
|
36229
|
+
},
|
|
36230
|
+
{
|
|
36231
|
+
kind: "Field",
|
|
36232
|
+
name: { kind: "Name", value: "untrustedAtBlock" }
|
|
36233
|
+
},
|
|
36234
|
+
{
|
|
36235
|
+
kind: "Field",
|
|
36236
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36237
|
+
}
|
|
36238
|
+
]
|
|
36239
|
+
}
|
|
36240
|
+
}
|
|
36241
|
+
]
|
|
36242
|
+
}
|
|
36243
|
+
}
|
|
36244
|
+
]
|
|
36245
|
+
}
|
|
36246
|
+
}
|
|
36247
|
+
]
|
|
36248
|
+
};
|
|
36249
|
+
GetUserFilesDocument = {
|
|
36250
|
+
kind: "Document",
|
|
36251
|
+
definitions: [
|
|
36252
|
+
{
|
|
36253
|
+
kind: "OperationDefinition",
|
|
36254
|
+
operation: "query",
|
|
36255
|
+
name: { kind: "Name", value: "GetUserFiles" },
|
|
36256
|
+
variableDefinitions: [
|
|
36257
|
+
{
|
|
36258
|
+
kind: "VariableDefinition",
|
|
36259
|
+
variable: {
|
|
36260
|
+
kind: "Variable",
|
|
36261
|
+
name: { kind: "Name", value: "userId" }
|
|
36262
|
+
},
|
|
36263
|
+
type: {
|
|
36264
|
+
kind: "NonNullType",
|
|
36265
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36266
|
+
}
|
|
36267
|
+
}
|
|
36268
|
+
],
|
|
36269
|
+
selectionSet: {
|
|
36270
|
+
kind: "SelectionSet",
|
|
36271
|
+
selections: [
|
|
36272
|
+
{
|
|
36273
|
+
kind: "Field",
|
|
36274
|
+
name: { kind: "Name", value: "user" },
|
|
36275
|
+
arguments: [
|
|
36276
|
+
{
|
|
36277
|
+
kind: "Argument",
|
|
36278
|
+
name: { kind: "Name", value: "id" },
|
|
36279
|
+
value: {
|
|
36280
|
+
kind: "Variable",
|
|
36281
|
+
name: { kind: "Name", value: "userId" }
|
|
36282
|
+
}
|
|
36283
|
+
}
|
|
36284
|
+
],
|
|
36285
|
+
selectionSet: {
|
|
36286
|
+
kind: "SelectionSet",
|
|
36287
|
+
selections: [
|
|
36288
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36289
|
+
{
|
|
36290
|
+
kind: "Field",
|
|
36291
|
+
name: { kind: "Name", value: "files" },
|
|
36292
|
+
selectionSet: {
|
|
36293
|
+
kind: "SelectionSet",
|
|
36294
|
+
selections: [
|
|
36295
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36296
|
+
{ kind: "Field", name: { kind: "Name", value: "url" } },
|
|
36297
|
+
{
|
|
36298
|
+
kind: "Field",
|
|
36299
|
+
name: { kind: "Name", value: "schemaId" }
|
|
36300
|
+
},
|
|
36301
|
+
{
|
|
36302
|
+
kind: "Field",
|
|
36303
|
+
name: { kind: "Name", value: "addedAtBlock" }
|
|
36304
|
+
},
|
|
36305
|
+
{
|
|
36306
|
+
kind: "Field",
|
|
36307
|
+
name: { kind: "Name", value: "addedAtTimestamp" }
|
|
36308
|
+
},
|
|
36309
|
+
{
|
|
36310
|
+
kind: "Field",
|
|
36311
|
+
name: { kind: "Name", value: "transactionHash" }
|
|
36312
|
+
},
|
|
36313
|
+
{
|
|
36314
|
+
kind: "Field",
|
|
36315
|
+
name: { kind: "Name", value: "owner" },
|
|
36316
|
+
selectionSet: {
|
|
36317
|
+
kind: "SelectionSet",
|
|
36318
|
+
selections: [
|
|
36319
|
+
{
|
|
36320
|
+
kind: "Field",
|
|
36321
|
+
name: { kind: "Name", value: "id" }
|
|
36322
|
+
}
|
|
36323
|
+
]
|
|
36324
|
+
}
|
|
36325
|
+
}
|
|
36326
|
+
]
|
|
36327
|
+
}
|
|
36328
|
+
}
|
|
36329
|
+
]
|
|
36330
|
+
}
|
|
36331
|
+
}
|
|
36332
|
+
]
|
|
36333
|
+
}
|
|
36334
|
+
}
|
|
36335
|
+
]
|
|
36336
|
+
};
|
|
36337
|
+
GetFileProofsDocument = {
|
|
36338
|
+
kind: "Document",
|
|
36339
|
+
definitions: [
|
|
36340
|
+
{
|
|
36341
|
+
kind: "OperationDefinition",
|
|
36342
|
+
operation: "query",
|
|
36343
|
+
name: { kind: "Name", value: "GetFileProofs" },
|
|
36344
|
+
variableDefinitions: [
|
|
36345
|
+
{
|
|
36346
|
+
kind: "VariableDefinition",
|
|
36347
|
+
variable: {
|
|
36348
|
+
kind: "Variable",
|
|
36349
|
+
name: { kind: "Name", value: "fileIds" }
|
|
36350
|
+
},
|
|
36351
|
+
type: {
|
|
36352
|
+
kind: "NonNullType",
|
|
36353
|
+
type: {
|
|
36354
|
+
kind: "ListType",
|
|
36355
|
+
type: {
|
|
36356
|
+
kind: "NonNullType",
|
|
36357
|
+
type: {
|
|
36358
|
+
kind: "NamedType",
|
|
36359
|
+
name: { kind: "Name", value: "BigInt" }
|
|
36360
|
+
}
|
|
36361
|
+
}
|
|
36362
|
+
}
|
|
36363
|
+
}
|
|
36364
|
+
}
|
|
36365
|
+
],
|
|
36366
|
+
selectionSet: {
|
|
36367
|
+
kind: "SelectionSet",
|
|
36368
|
+
selections: [
|
|
36369
|
+
{
|
|
36370
|
+
kind: "Field",
|
|
36371
|
+
name: { kind: "Name", value: "dataRegistryProofs" },
|
|
36372
|
+
arguments: [
|
|
36373
|
+
{
|
|
36374
|
+
kind: "Argument",
|
|
36375
|
+
name: { kind: "Name", value: "where" },
|
|
36376
|
+
value: {
|
|
36377
|
+
kind: "ObjectValue",
|
|
36378
|
+
fields: [
|
|
36379
|
+
{
|
|
36380
|
+
kind: "ObjectField",
|
|
36381
|
+
name: { kind: "Name", value: "fileId_in" },
|
|
36382
|
+
value: {
|
|
36383
|
+
kind: "Variable",
|
|
36384
|
+
name: { kind: "Name", value: "fileIds" }
|
|
36385
|
+
}
|
|
36386
|
+
}
|
|
36387
|
+
]
|
|
36388
|
+
}
|
|
36389
|
+
}
|
|
36390
|
+
],
|
|
36391
|
+
selectionSet: {
|
|
36392
|
+
kind: "SelectionSet",
|
|
36393
|
+
selections: [
|
|
36394
|
+
{ kind: "Field", name: { kind: "Name", value: "fileId" } },
|
|
36395
|
+
{
|
|
36396
|
+
kind: "Field",
|
|
36397
|
+
name: { kind: "Name", value: "dlp" },
|
|
36398
|
+
selectionSet: {
|
|
36399
|
+
kind: "SelectionSet",
|
|
36400
|
+
selections: [
|
|
36401
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } }
|
|
36402
|
+
]
|
|
36403
|
+
}
|
|
36404
|
+
}
|
|
36405
|
+
]
|
|
36406
|
+
}
|
|
36407
|
+
}
|
|
36408
|
+
]
|
|
36409
|
+
}
|
|
36410
|
+
}
|
|
36411
|
+
]
|
|
36412
|
+
};
|
|
36413
|
+
GetDlpDocument = {
|
|
36414
|
+
kind: "Document",
|
|
36415
|
+
definitions: [
|
|
36416
|
+
{
|
|
36417
|
+
kind: "OperationDefinition",
|
|
36418
|
+
operation: "query",
|
|
36419
|
+
name: { kind: "Name", value: "GetDLP" },
|
|
36420
|
+
variableDefinitions: [
|
|
36421
|
+
{
|
|
36422
|
+
kind: "VariableDefinition",
|
|
36423
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
36424
|
+
type: {
|
|
36425
|
+
kind: "NonNullType",
|
|
36426
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
36427
|
+
}
|
|
36428
|
+
}
|
|
36429
|
+
],
|
|
36430
|
+
selectionSet: {
|
|
36431
|
+
kind: "SelectionSet",
|
|
36432
|
+
selections: [
|
|
36433
|
+
{
|
|
36434
|
+
kind: "Field",
|
|
36435
|
+
name: { kind: "Name", value: "dlp" },
|
|
36436
|
+
arguments: [
|
|
36437
|
+
{
|
|
36438
|
+
kind: "Argument",
|
|
36439
|
+
name: { kind: "Name", value: "id" },
|
|
36440
|
+
value: {
|
|
36441
|
+
kind: "Variable",
|
|
36442
|
+
name: { kind: "Name", value: "id" }
|
|
36443
|
+
}
|
|
36444
|
+
}
|
|
36445
|
+
],
|
|
36446
|
+
selectionSet: {
|
|
36447
|
+
kind: "SelectionSet",
|
|
36448
|
+
selections: [
|
|
36449
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
36450
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
36451
|
+
{ kind: "Field", name: { kind: "Name", value: "metadata" } },
|
|
36452
|
+
{ kind: "Field", name: { kind: "Name", value: "status" } },
|
|
36453
|
+
{ kind: "Field", name: { kind: "Name", value: "address" } },
|
|
36454
|
+
{ kind: "Field", name: { kind: "Name", value: "owner" } }
|
|
36455
|
+
]
|
|
36456
|
+
}
|
|
36457
|
+
}
|
|
36458
|
+
]
|
|
36459
|
+
}
|
|
36460
|
+
}
|
|
36461
|
+
]
|
|
36462
|
+
};
|
|
36033
36463
|
GetSchemaDocument = {
|
|
36034
36464
|
kind: "Document",
|
|
36035
36465
|
definitions: [
|
|
@@ -36226,6 +36656,64 @@ var init_subgraph = __esm({
|
|
|
36226
36656
|
}
|
|
36227
36657
|
});
|
|
36228
36658
|
|
|
36659
|
+
// src/utils/blockchain/registry.ts
|
|
36660
|
+
import { getContract } from "viem";
|
|
36661
|
+
async function fetchSchemaFromChain(context, schemaId) {
|
|
36662
|
+
const chainId = context.walletClient.chain?.id;
|
|
36663
|
+
if (!chainId) {
|
|
36664
|
+
throw new Error("Chain ID not available");
|
|
36665
|
+
}
|
|
36666
|
+
const dataRefinerRegistryAddress = getContractAddress(
|
|
36667
|
+
chainId,
|
|
36668
|
+
"DataRefinerRegistry"
|
|
36669
|
+
);
|
|
36670
|
+
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36671
|
+
const dataRefinerRegistry = getContract({
|
|
36672
|
+
address: dataRefinerRegistryAddress,
|
|
36673
|
+
abi: dataRefinerRegistryAbi,
|
|
36674
|
+
client: context.publicClient
|
|
36675
|
+
});
|
|
36676
|
+
const schemaData = await dataRefinerRegistry.read.schemas([BigInt(schemaId)]);
|
|
36677
|
+
if (!schemaData) {
|
|
36678
|
+
throw new Error(`Schema with ID ${schemaId} not found`);
|
|
36679
|
+
}
|
|
36680
|
+
const schemaObj = schemaData;
|
|
36681
|
+
if (!schemaObj.name || !schemaObj.dialect || !schemaObj.definitionUrl) {
|
|
36682
|
+
throw new Error("Incomplete schema data");
|
|
36683
|
+
}
|
|
36684
|
+
return {
|
|
36685
|
+
id: schemaId,
|
|
36686
|
+
name: schemaObj.name,
|
|
36687
|
+
dialect: schemaObj.dialect,
|
|
36688
|
+
definitionUrl: schemaObj.definitionUrl
|
|
36689
|
+
};
|
|
36690
|
+
}
|
|
36691
|
+
async function fetchSchemaCountFromChain(context) {
|
|
36692
|
+
const chainId = context.walletClient.chain?.id;
|
|
36693
|
+
if (!chainId) {
|
|
36694
|
+
throw new Error("Chain ID not available");
|
|
36695
|
+
}
|
|
36696
|
+
const dataRefinerRegistryAddress = getContractAddress(
|
|
36697
|
+
chainId,
|
|
36698
|
+
"DataRefinerRegistry"
|
|
36699
|
+
);
|
|
36700
|
+
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
36701
|
+
const dataRefinerRegistry = getContract({
|
|
36702
|
+
address: dataRefinerRegistryAddress,
|
|
36703
|
+
abi: dataRefinerRegistryAbi,
|
|
36704
|
+
client: context.publicClient
|
|
36705
|
+
});
|
|
36706
|
+
const count = await dataRefinerRegistry.read.schemasCount();
|
|
36707
|
+
return Number(count);
|
|
36708
|
+
}
|
|
36709
|
+
var init_registry = __esm({
|
|
36710
|
+
"src/utils/blockchain/registry.ts"() {
|
|
36711
|
+
"use strict";
|
|
36712
|
+
init_addresses();
|
|
36713
|
+
init_abi();
|
|
36714
|
+
}
|
|
36715
|
+
});
|
|
36716
|
+
|
|
36229
36717
|
// src/utils/urlResolver.ts
|
|
36230
36718
|
async function fetchFromUrl(url) {
|
|
36231
36719
|
try {
|
|
@@ -37405,6 +37893,7 @@ init_transactionHandle();
|
|
|
37405
37893
|
init_errors();
|
|
37406
37894
|
init_addresses();
|
|
37407
37895
|
init_abi();
|
|
37896
|
+
import { getAddress as getAddress3 } from "viem";
|
|
37408
37897
|
|
|
37409
37898
|
// src/utils/grantFiles.ts
|
|
37410
37899
|
init_errors();
|
|
@@ -37575,6 +38064,7 @@ function validateGrantFile(data) {
|
|
|
37575
38064
|
}
|
|
37576
38065
|
|
|
37577
38066
|
// src/utils/grantValidation.ts
|
|
38067
|
+
import { getAddress } from "viem";
|
|
37578
38068
|
import Ajv2 from "ajv";
|
|
37579
38069
|
import addFormats2 from "ajv-formats";
|
|
37580
38070
|
|
|
@@ -37778,7 +38268,9 @@ function extractFieldFromBusinessError(error) {
|
|
|
37778
38268
|
return void 0;
|
|
37779
38269
|
}
|
|
37780
38270
|
function validateGranteeAccess(grantFile, requestingAddress) {
|
|
37781
|
-
|
|
38271
|
+
const normalizedGrantee = getAddress(grantFile.grantee);
|
|
38272
|
+
const normalizedRequesting = getAddress(requestingAddress);
|
|
38273
|
+
if (normalizedGrantee !== normalizedRequesting) {
|
|
37782
38274
|
throw new GranteeMismatchError(
|
|
37783
38275
|
"Permission denied: requesting address does not match grantee",
|
|
37784
38276
|
grantFile.grantee,
|
|
@@ -37810,6 +38302,7 @@ function validateOperationAccess(grantFile, requestedOperation) {
|
|
|
37810
38302
|
|
|
37811
38303
|
// src/utils/signatureCache.ts
|
|
37812
38304
|
init_crypto_utils();
|
|
38305
|
+
import { getAddress as getAddress2 } from "viem";
|
|
37813
38306
|
var SignatureCache = class {
|
|
37814
38307
|
static PREFIX = "vana_sig_";
|
|
37815
38308
|
static DEFAULT_TTL_HOURS = 2;
|
|
@@ -37902,7 +38395,7 @@ var SignatureCache = class {
|
|
|
37902
38395
|
}
|
|
37903
38396
|
}
|
|
37904
38397
|
static getCacheKey(walletAddress, messageHash) {
|
|
37905
|
-
return `${this.PREFIX}${walletAddress
|
|
38398
|
+
return `${this.PREFIX}${getAddress2(walletAddress)}:${messageHash}`;
|
|
37906
38399
|
}
|
|
37907
38400
|
/**
|
|
37908
38401
|
* Generate a deterministic hash of a message object for cache key generation
|
|
@@ -39175,20 +39668,22 @@ var PermissionsController = class {
|
|
|
39175
39668
|
if (!userData || !userData.permissions?.length) {
|
|
39176
39669
|
return [];
|
|
39177
39670
|
}
|
|
39178
|
-
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
39179
|
-
|
|
39180
|
-
|
|
39181
|
-
|
|
39182
|
-
|
|
39183
|
-
|
|
39184
|
-
|
|
39185
|
-
|
|
39186
|
-
|
|
39187
|
-
|
|
39188
|
-
|
|
39189
|
-
|
|
39190
|
-
|
|
39191
|
-
|
|
39671
|
+
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
39672
|
+
(permission) => ({
|
|
39673
|
+
id: BigInt(permission.id),
|
|
39674
|
+
grantUrl: permission.grant,
|
|
39675
|
+
grantSignature: permission.signature,
|
|
39676
|
+
nonce: BigInt(permission.nonce),
|
|
39677
|
+
startBlock: BigInt(permission.startBlock),
|
|
39678
|
+
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
39679
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
|
|
39680
|
+
transactionHash: permission.transactionHash || "",
|
|
39681
|
+
grantor: userAddress,
|
|
39682
|
+
grantee: permission.grantee,
|
|
39683
|
+
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
39684
|
+
// Active if no end block or end block is 0
|
|
39685
|
+
})
|
|
39686
|
+
);
|
|
39192
39687
|
return onChainGrants.sort((a, b) => {
|
|
39193
39688
|
if (a.id < b.id) return 1;
|
|
39194
39689
|
if (a.id > b.id) return -1;
|
|
@@ -39266,14 +39761,16 @@ var PermissionsController = class {
|
|
|
39266
39761
|
);
|
|
39267
39762
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
39268
39763
|
const userAddress = this.context.walletClient.account?.address || await this.getUserAddress();
|
|
39764
|
+
const normalizedUserAddress = getAddress3(userAddress);
|
|
39765
|
+
const normalizedServerAddress = getAddress3(params.serverAddress);
|
|
39269
39766
|
const txHash = await this.context.walletClient.writeContract({
|
|
39270
39767
|
address: DataPortabilityServersAddress,
|
|
39271
39768
|
abi: DataPortabilityServersAbi,
|
|
39272
39769
|
functionName: "addAndTrustServerByManager",
|
|
39273
39770
|
args: [
|
|
39274
|
-
|
|
39771
|
+
normalizedUserAddress,
|
|
39275
39772
|
{
|
|
39276
|
-
serverAddress:
|
|
39773
|
+
serverAddress: normalizedServerAddress,
|
|
39277
39774
|
serverUrl: params.serverUrl,
|
|
39278
39775
|
publicKey: params.publicKey
|
|
39279
39776
|
}
|
|
@@ -39343,9 +39840,10 @@ var PermissionsController = class {
|
|
|
39343
39840
|
async submitAddAndTrustServerWithSignature(params) {
|
|
39344
39841
|
try {
|
|
39345
39842
|
const nonce = await this.getServersUserNonce();
|
|
39843
|
+
const serverAddress = getAddress3(params.serverAddress);
|
|
39346
39844
|
const addAndTrustServerInput = {
|
|
39347
39845
|
nonce,
|
|
39348
|
-
serverAddress
|
|
39846
|
+
serverAddress,
|
|
39349
39847
|
publicKey: params.publicKey,
|
|
39350
39848
|
serverUrl: params.serverUrl
|
|
39351
39849
|
};
|
|
@@ -40150,11 +40648,13 @@ var PermissionsController = class {
|
|
|
40150
40648
|
"DataPortabilityGrantees"
|
|
40151
40649
|
);
|
|
40152
40650
|
const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
|
|
40651
|
+
const ownerAddress = getAddress3(params.owner);
|
|
40652
|
+
const granteeAddress = getAddress3(params.granteeAddress);
|
|
40153
40653
|
const txHash = await this.context.walletClient.writeContract({
|
|
40154
40654
|
address: DataPortabilityGranteesAddress,
|
|
40155
40655
|
abi: DataPortabilityGranteesAbi,
|
|
40156
40656
|
functionName: "registerGrantee",
|
|
40157
|
-
args: [
|
|
40657
|
+
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
40158
40658
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
40159
40659
|
chain: this.context.walletClient.chain || null
|
|
40160
40660
|
});
|
|
@@ -40181,10 +40681,12 @@ var PermissionsController = class {
|
|
|
40181
40681
|
*/
|
|
40182
40682
|
async submitRegisterGranteeWithSignature(params) {
|
|
40183
40683
|
const nonce = await this.getServersUserNonce();
|
|
40684
|
+
const owner = getAddress3(params.owner);
|
|
40685
|
+
const granteeAddress = getAddress3(params.granteeAddress);
|
|
40184
40686
|
const registerGranteeInput = {
|
|
40185
40687
|
nonce,
|
|
40186
|
-
owner
|
|
40187
|
-
granteeAddress
|
|
40688
|
+
owner,
|
|
40689
|
+
granteeAddress,
|
|
40188
40690
|
publicKey: params.publicKey
|
|
40189
40691
|
};
|
|
40190
40692
|
const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
|
|
@@ -41695,7 +42197,9 @@ var PermissionsController = class {
|
|
|
41695
42197
|
init_transactionHandle();
|
|
41696
42198
|
init_addresses();
|
|
41697
42199
|
init_abi();
|
|
42200
|
+
init_subgraph();
|
|
41698
42201
|
import { getContract as getContract2 } from "viem";
|
|
42202
|
+
import { print as print2 } from "graphql";
|
|
41699
42203
|
|
|
41700
42204
|
// src/utils/encryption.ts
|
|
41701
42205
|
var DEFAULT_ENCRYPTION_SEED = "Please sign to retrieve your encryption key";
|
|
@@ -42119,34 +42623,16 @@ var DataController = class {
|
|
|
42119
42623
|
);
|
|
42120
42624
|
}
|
|
42121
42625
|
try {
|
|
42122
|
-
const query = `
|
|
42123
|
-
query GetUserFiles($userId: ID!) {
|
|
42124
|
-
user(id: $userId) {
|
|
42125
|
-
id
|
|
42126
|
-
files {
|
|
42127
|
-
id
|
|
42128
|
-
url
|
|
42129
|
-
schemaId
|
|
42130
|
-
addedAtBlock
|
|
42131
|
-
addedAtTimestamp
|
|
42132
|
-
transactionHash
|
|
42133
|
-
owner {
|
|
42134
|
-
id
|
|
42135
|
-
}
|
|
42136
|
-
}
|
|
42137
|
-
}
|
|
42138
|
-
}
|
|
42139
|
-
`;
|
|
42140
42626
|
const response = await fetch(endpoint, {
|
|
42141
42627
|
method: "POST",
|
|
42142
42628
|
headers: {
|
|
42143
42629
|
"Content-Type": "application/json"
|
|
42144
42630
|
},
|
|
42145
42631
|
body: JSON.stringify({
|
|
42146
|
-
query,
|
|
42632
|
+
query: print2(GetUserFilesDocument),
|
|
42147
42633
|
variables: {
|
|
42148
42634
|
userId: owner.toLowerCase()
|
|
42149
|
-
// Subgraph
|
|
42635
|
+
// Subgraph requires lowercase addresses
|
|
42150
42636
|
}
|
|
42151
42637
|
})
|
|
42152
42638
|
});
|
|
@@ -42226,23 +42712,13 @@ var DataController = class {
|
|
|
42226
42712
|
* @returns Map of file IDs to their associated DLP IDs
|
|
42227
42713
|
*/
|
|
42228
42714
|
async _fetchProofsFromSubgraph(fileIds, subgraphUrl) {
|
|
42229
|
-
const query = `
|
|
42230
|
-
query GetFileProofs($fileIds: [BigInt!]!) {
|
|
42231
|
-
dataRegistryProofs(where: { fileId_in: $fileIds }) {
|
|
42232
|
-
fileId
|
|
42233
|
-
dlp {
|
|
42234
|
-
id
|
|
42235
|
-
}
|
|
42236
|
-
}
|
|
42237
|
-
}
|
|
42238
|
-
`;
|
|
42239
42715
|
const response = await fetch(subgraphUrl, {
|
|
42240
42716
|
method: "POST",
|
|
42241
42717
|
headers: {
|
|
42242
42718
|
"Content-Type": "application/json"
|
|
42243
42719
|
},
|
|
42244
42720
|
body: JSON.stringify({
|
|
42245
|
-
query,
|
|
42721
|
+
query: print2(GetFileProofsDocument),
|
|
42246
42722
|
variables: {
|
|
42247
42723
|
fileIds: fileIds.map((id) => id.toString())
|
|
42248
42724
|
}
|
|
@@ -42346,25 +42822,13 @@ var DataController = class {
|
|
|
42346
42822
|
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
42347
42823
|
if (subgraphUrl) {
|
|
42348
42824
|
try {
|
|
42349
|
-
const query = `
|
|
42350
|
-
query GetDLP($id: ID!) {
|
|
42351
|
-
dlp(id: $id) {
|
|
42352
|
-
id
|
|
42353
|
-
name
|
|
42354
|
-
metadata
|
|
42355
|
-
status
|
|
42356
|
-
address
|
|
42357
|
-
owner
|
|
42358
|
-
}
|
|
42359
|
-
}
|
|
42360
|
-
`;
|
|
42361
42825
|
const response = await fetch(subgraphUrl, {
|
|
42362
42826
|
method: "POST",
|
|
42363
42827
|
headers: {
|
|
42364
42828
|
"Content-Type": "application/json"
|
|
42365
42829
|
},
|
|
42366
42830
|
body: JSON.stringify({
|
|
42367
|
-
query,
|
|
42831
|
+
query: print2(GetDlpDocument),
|
|
42368
42832
|
variables: {
|
|
42369
42833
|
id: dlpId.toString()
|
|
42370
42834
|
}
|
|
@@ -42387,7 +42851,7 @@ var DataController = class {
|
|
|
42387
42851
|
return {
|
|
42388
42852
|
id: parseInt(result.data.dlp.id),
|
|
42389
42853
|
name: result.data.dlp.name || "",
|
|
42390
|
-
metadata: result.data.dlp.metadata,
|
|
42854
|
+
metadata: result.data.dlp.metadata || void 0,
|
|
42391
42855
|
status: result.data.dlp.status ? parseInt(result.data.dlp.status) : void 0,
|
|
42392
42856
|
address: result.data.dlp.address,
|
|
42393
42857
|
owner: result.data.dlp.owner
|
|
@@ -42601,32 +43065,13 @@ var DataController = class {
|
|
|
42601
43065
|
async _getUserPermissionsViaSubgraph(params) {
|
|
42602
43066
|
const { user, subgraphUrl } = params;
|
|
42603
43067
|
try {
|
|
42604
|
-
const query = `
|
|
42605
|
-
query GetUserPermissions($userId: ID!) {
|
|
42606
|
-
user(id: $userId) {
|
|
42607
|
-
id
|
|
42608
|
-
permissions {
|
|
42609
|
-
id
|
|
42610
|
-
grant
|
|
42611
|
-
nonce
|
|
42612
|
-
signature
|
|
42613
|
-
addedAtBlock
|
|
42614
|
-
addedAtTimestamp
|
|
42615
|
-
transactionHash
|
|
42616
|
-
user {
|
|
42617
|
-
id
|
|
42618
|
-
}
|
|
42619
|
-
}
|
|
42620
|
-
}
|
|
42621
|
-
}
|
|
42622
|
-
`;
|
|
42623
43068
|
const response = await fetch(subgraphUrl, {
|
|
42624
43069
|
method: "POST",
|
|
42625
43070
|
headers: {
|
|
42626
43071
|
"Content-Type": "application/json"
|
|
42627
43072
|
},
|
|
42628
43073
|
body: JSON.stringify({
|
|
42629
|
-
query,
|
|
43074
|
+
query: print2(GetUserPermissionsDocument),
|
|
42630
43075
|
variables: {
|
|
42631
43076
|
userId: user.toLowerCase()
|
|
42632
43077
|
}
|
|
@@ -42655,7 +43100,7 @@ var DataController = class {
|
|
|
42655
43100
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
42656
43101
|
addedAtTimestamp: BigInt(permission.addedAtTimestamp),
|
|
42657
43102
|
transactionHash: permission.transactionHash,
|
|
42658
|
-
user
|
|
43103
|
+
user
|
|
42659
43104
|
})).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
|
|
42660
43105
|
} catch (error) {
|
|
42661
43106
|
console.error("Failed to query user permissions from subgraph:", error);
|
|
@@ -42827,36 +43272,16 @@ var DataController = class {
|
|
|
42827
43272
|
);
|
|
42828
43273
|
}
|
|
42829
43274
|
try {
|
|
42830
|
-
const query = `
|
|
42831
|
-
query GetUserTrustedServers($userId: ID!) {
|
|
42832
|
-
user(id: $userId) {
|
|
42833
|
-
id
|
|
42834
|
-
serverTrusts {
|
|
42835
|
-
id
|
|
42836
|
-
server {
|
|
42837
|
-
id
|
|
42838
|
-
serverAddress
|
|
42839
|
-
url
|
|
42840
|
-
publicKey
|
|
42841
|
-
}
|
|
42842
|
-
trustedAt
|
|
42843
|
-
trustedAtBlock
|
|
42844
|
-
untrustedAtBlock
|
|
42845
|
-
transactionHash
|
|
42846
|
-
}
|
|
42847
|
-
}
|
|
42848
|
-
}
|
|
42849
|
-
`;
|
|
42850
43275
|
const response = await fetch(graphqlEndpoint, {
|
|
42851
43276
|
method: "POST",
|
|
42852
43277
|
headers: {
|
|
42853
43278
|
"Content-Type": "application/json"
|
|
42854
43279
|
},
|
|
42855
43280
|
body: JSON.stringify({
|
|
42856
|
-
query,
|
|
43281
|
+
query: print2(GetUserTrustedServersDocument),
|
|
42857
43282
|
variables: {
|
|
42858
43283
|
userId: user.toLowerCase()
|
|
42859
|
-
// Subgraph
|
|
43284
|
+
// Subgraph requires lowercase addresses
|
|
42860
43285
|
}
|
|
42861
43286
|
})
|
|
42862
43287
|
});
|
|
@@ -43690,19 +44115,31 @@ var DataController = class {
|
|
|
43690
44115
|
return await this.submitFilePermission(fileId, account, publicKey);
|
|
43691
44116
|
}
|
|
43692
44117
|
/**
|
|
43693
|
-
* Submits a file permission transaction
|
|
44118
|
+
* Submits a file permission transaction to the blockchain.
|
|
43694
44119
|
*
|
|
43695
|
-
*
|
|
44120
|
+
* @remarks
|
|
44121
|
+
* This method supports gasless transactions via relayer callbacks when configured.
|
|
44122
|
+
* It encrypts the user's encryption key with the recipient's public key before submission.
|
|
43696
44123
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
43697
44124
|
*
|
|
43698
|
-
* @param fileId - The ID of the file to
|
|
43699
|
-
* @param account - The
|
|
43700
|
-
* @param publicKey - The public key
|
|
43701
|
-
*
|
|
44125
|
+
* @param fileId - The ID of the file to grant permission for
|
|
44126
|
+
* @param account - The recipient's wallet address that will access the file
|
|
44127
|
+
* @param publicKey - The recipient's public key for encryption.
|
|
44128
|
+
* Obtain via `vana.server.getIdentity(account).public_key`
|
|
44129
|
+
* @returns Promise resolving to TransactionHandle for tracking the transaction
|
|
44130
|
+
* @throws {Error} When chain ID is not available
|
|
44131
|
+
* @throws {Error} When encryption key generation fails
|
|
44132
|
+
* @throws {Error} When public key encryption fails
|
|
44133
|
+
*
|
|
43702
44134
|
* @example
|
|
43703
44135
|
* ```typescript
|
|
43704
|
-
* const
|
|
43705
|
-
*
|
|
44136
|
+
* const tx = await vana.data.submitFilePermission(
|
|
44137
|
+
* fileId,
|
|
44138
|
+
* "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
44139
|
+
* recipientPublicKey
|
|
44140
|
+
* );
|
|
44141
|
+
* const result = await tx.waitForEvents();
|
|
44142
|
+
* console.log(`Permission granted with ID: ${result.permissionId}`);
|
|
43706
44143
|
* ```
|
|
43707
44144
|
*/
|
|
43708
44145
|
async submitFilePermission(fileId, account, publicKey) {
|
|
@@ -44070,6 +44507,73 @@ init_schemas();
|
|
|
44070
44507
|
|
|
44071
44508
|
// src/controllers/server.ts
|
|
44072
44509
|
init_errors();
|
|
44510
|
+
|
|
44511
|
+
// src/utils/operationHandle.ts
|
|
44512
|
+
init_errors();
|
|
44513
|
+
var OperationHandle = class {
|
|
44514
|
+
constructor(controller, id) {
|
|
44515
|
+
this.controller = controller;
|
|
44516
|
+
this.id = id;
|
|
44517
|
+
}
|
|
44518
|
+
_resultPromise;
|
|
44519
|
+
/**
|
|
44520
|
+
* Waits for the operation to complete and returns the result.
|
|
44521
|
+
*
|
|
44522
|
+
* @remarks
|
|
44523
|
+
* Results are memoized - multiple calls return the same promise.
|
|
44524
|
+
* The method polls the server at regular intervals until the operation
|
|
44525
|
+
* succeeds, fails, or times out. Returns the raw string result from the
|
|
44526
|
+
* server - callers are responsible for parsing if needed.
|
|
44527
|
+
*
|
|
44528
|
+
* @param options - Optional polling configuration
|
|
44529
|
+
* @returns The operation result as a string when completed
|
|
44530
|
+
* @throws {PersonalServerError} When the operation fails or times out
|
|
44531
|
+
* @example
|
|
44532
|
+
* ```typescript
|
|
44533
|
+
* const result = await handle.waitForResult({
|
|
44534
|
+
* timeout: 60000,
|
|
44535
|
+
* pollingInterval: 500
|
|
44536
|
+
* });
|
|
44537
|
+
* // If expecting JSON, parse it:
|
|
44538
|
+
* const data = JSON.parse(result);
|
|
44539
|
+
* ```
|
|
44540
|
+
*/
|
|
44541
|
+
async waitForResult(options) {
|
|
44542
|
+
if (!this._resultPromise) {
|
|
44543
|
+
this._resultPromise = this.pollForCompletion(options);
|
|
44544
|
+
}
|
|
44545
|
+
return this._resultPromise;
|
|
44546
|
+
}
|
|
44547
|
+
async pollForCompletion(options) {
|
|
44548
|
+
const startTime = Date.now();
|
|
44549
|
+
const timeout = options?.timeout ?? 3e4;
|
|
44550
|
+
const interval = options?.pollingInterval ?? 500;
|
|
44551
|
+
while (true) {
|
|
44552
|
+
const result = await this.controller.getOperation(
|
|
44553
|
+
this.id
|
|
44554
|
+
);
|
|
44555
|
+
if (result.status === "succeeded") {
|
|
44556
|
+
if (result.result) {
|
|
44557
|
+
return result.result;
|
|
44558
|
+
}
|
|
44559
|
+
throw new PersonalServerError(
|
|
44560
|
+
"Operation succeeded but returned no result"
|
|
44561
|
+
);
|
|
44562
|
+
}
|
|
44563
|
+
if (result.status === "failed") {
|
|
44564
|
+
throw new PersonalServerError(
|
|
44565
|
+
`Operation ${result.status}: ${result.result || "Unknown error"}`
|
|
44566
|
+
);
|
|
44567
|
+
}
|
|
44568
|
+
if (Date.now() - startTime > timeout) {
|
|
44569
|
+
throw new PersonalServerError(`Operation timed out after ${timeout}ms`);
|
|
44570
|
+
}
|
|
44571
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
44572
|
+
}
|
|
44573
|
+
}
|
|
44574
|
+
};
|
|
44575
|
+
|
|
44576
|
+
// src/controllers/server.ts
|
|
44073
44577
|
var ServerController = class {
|
|
44074
44578
|
constructor(context) {
|
|
44075
44579
|
this.context = context;
|
|
@@ -44151,26 +44655,29 @@ var ServerController = class {
|
|
|
44151
44655
|
}
|
|
44152
44656
|
}
|
|
44153
44657
|
/**
|
|
44154
|
-
* Creates
|
|
44658
|
+
* Creates a server operation and returns a handle for lifecycle management.
|
|
44155
44659
|
*
|
|
44156
44660
|
* @remarks
|
|
44157
|
-
* This method submits a computation request to the personal server
|
|
44158
|
-
*
|
|
44159
|
-
*
|
|
44661
|
+
* This method submits a computation request to the personal server and returns
|
|
44662
|
+
* an OperationHandle that provides Promise-based methods for waiting on results.
|
|
44663
|
+
* The handle pattern matches TransactionHandle for consistency across async operations.
|
|
44664
|
+
*
|
|
44665
|
+
* @param params - The operation request parameters
|
|
44160
44666
|
* @param params.permissionId - The permission ID authorizing this operation.
|
|
44161
|
-
* Obtain
|
|
44162
|
-
* @returns
|
|
44163
|
-
* @throws {PersonalServerError} When server request fails or parameters are invalid
|
|
44164
|
-
*
|
|
44165
|
-
* @throws {NetworkError} When personal server API communication fails.
|
|
44166
|
-
* Check server URL configuration and network connectivity.
|
|
44667
|
+
* Obtain via `vana.permissions.getUserPermissionGrantsOnChain()`.
|
|
44668
|
+
* @returns An OperationHandle providing access to the operation ID and result methods
|
|
44669
|
+
* @throws {PersonalServerError} When the server request fails or parameters are invalid
|
|
44670
|
+
* @throws {NetworkError} When personal server API communication fails
|
|
44167
44671
|
* @example
|
|
44168
44672
|
* ```typescript
|
|
44169
|
-
* const
|
|
44170
|
-
* permissionId: 123
|
|
44673
|
+
* const operation = await vana.server.createOperation({
|
|
44674
|
+
* permissionId: 123
|
|
44171
44675
|
* });
|
|
44172
|
-
*
|
|
44173
|
-
*
|
|
44676
|
+
* console.log(`Operation ID: ${operation.id}`);
|
|
44677
|
+
*
|
|
44678
|
+
* // Wait for completion
|
|
44679
|
+
* const result = await operation.waitForResult();
|
|
44680
|
+
* console.log("Result:", result);
|
|
44174
44681
|
* ```
|
|
44175
44682
|
*/
|
|
44176
44683
|
async createOperation(params) {
|
|
@@ -44186,7 +44693,7 @@ var ServerController = class {
|
|
|
44186
44693
|
};
|
|
44187
44694
|
console.debug("\u{1F50D} Debug - createOperation requestBody", requestBody);
|
|
44188
44695
|
const response = await this.makeRequest(requestBody);
|
|
44189
|
-
return response;
|
|
44696
|
+
return new OperationHandle(this, response.id);
|
|
44190
44697
|
} catch (error) {
|
|
44191
44698
|
if (error instanceof Error) {
|
|
44192
44699
|
if (error instanceof NetworkError || error instanceof SerializationError || error instanceof SignatureError || error instanceof PersonalServerError) {
|
|
@@ -44203,30 +44710,20 @@ var ServerController = class {
|
|
|
44203
44710
|
}
|
|
44204
44711
|
}
|
|
44205
44712
|
/**
|
|
44206
|
-
*
|
|
44713
|
+
* Retrieves the current status and result of a server operation.
|
|
44207
44714
|
*
|
|
44208
44715
|
* @remarks
|
|
44209
|
-
*
|
|
44210
|
-
*
|
|
44211
|
-
*
|
|
44212
|
-
*
|
|
44213
|
-
*
|
|
44214
|
-
*
|
|
44215
|
-
* @param operationId - The operation ID returned from the initial request submission
|
|
44216
|
-
* @returns A Promise that resolves to the current operation response with status and results
|
|
44217
|
-
* @throws {NetworkError} When the polling request fails or returns invalid data
|
|
44716
|
+
* Common status values: `starting`, `running`, `succeeded`, `failed`, `canceled`.
|
|
44717
|
+
* When status is `succeeded`, the result field contains the operation output.
|
|
44718
|
+
*
|
|
44719
|
+
* @param operationId - The ID of the operation to query
|
|
44720
|
+
* @returns The operation response containing status, result, and metadata
|
|
44721
|
+
* @throws {NetworkError} When the API request fails or returns invalid data
|
|
44218
44722
|
* @example
|
|
44219
44723
|
* ```typescript
|
|
44220
|
-
*
|
|
44221
|
-
*
|
|
44222
|
-
*
|
|
44223
|
-
* while (result.status === "processing") {
|
|
44224
|
-
* await new Promise(resolve => setTimeout(resolve, 1000));
|
|
44225
|
-
* result = await vana.server.getOperation(response.id);
|
|
44226
|
-
* }
|
|
44227
|
-
*
|
|
44228
|
-
* if (result.status === "succeeded") {
|
|
44229
|
-
* console.log("Computation completed:", result.output);
|
|
44724
|
+
* const status = await vana.server.getOperation(operationId);
|
|
44725
|
+
* if (status.status === 'succeeded') {
|
|
44726
|
+
* console.log('Result:', JSON.parse(status.result));
|
|
44230
44727
|
* }
|
|
44231
44728
|
* ```
|
|
44232
44729
|
*/
|
|
@@ -47120,7 +47617,7 @@ var CircuitBreaker = class {
|
|
|
47120
47617
|
|
|
47121
47618
|
// src/server/handler.ts
|
|
47122
47619
|
init_errors();
|
|
47123
|
-
import { recoverTypedDataAddress } from "viem";
|
|
47620
|
+
import { recoverTypedDataAddress, getAddress as getAddress4 } from "viem";
|
|
47124
47621
|
async function handleRelayerRequest(sdk, payload) {
|
|
47125
47622
|
const { typedData, signature, expectedUserAddress } = payload;
|
|
47126
47623
|
console.debug({
|
|
@@ -47143,21 +47640,22 @@ async function handleRelayerRequest(sdk, payload) {
|
|
|
47143
47640
|
);
|
|
47144
47641
|
}
|
|
47145
47642
|
if (expectedUserAddress) {
|
|
47146
|
-
const normalizedSigner = signerAddress
|
|
47147
|
-
const normalizedExpected = expectedUserAddress
|
|
47643
|
+
const normalizedSigner = getAddress4(signerAddress);
|
|
47644
|
+
const normalizedExpected = getAddress4(expectedUserAddress);
|
|
47148
47645
|
if (normalizedSigner !== normalizedExpected) {
|
|
47149
47646
|
throw new SignatureError(
|
|
47150
47647
|
`Security verification failed: Recovered signer address (${normalizedSigner}) does not match expected user address (${normalizedExpected}). This may be due to incorrect EIP-712 domain configuration.`
|
|
47151
47648
|
);
|
|
47152
47649
|
}
|
|
47153
47650
|
}
|
|
47154
|
-
|
|
47651
|
+
const primaryType = typedData.primaryType;
|
|
47652
|
+
switch (primaryType) {
|
|
47155
47653
|
case "Permission":
|
|
47156
47654
|
return sdk.permissions.submitSignedGrant(
|
|
47157
47655
|
typedData,
|
|
47158
47656
|
signature
|
|
47159
47657
|
);
|
|
47160
|
-
case "
|
|
47658
|
+
case "RevokePermission":
|
|
47161
47659
|
return sdk.permissions.submitSignedRevoke(
|
|
47162
47660
|
typedData,
|
|
47163
47661
|
signature
|