@opendatalabs/vana-sdk 0.1.0-alpha.376e2fd → 0.1.0-alpha.52b50da

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.
@@ -27,6 +27,28 @@ function parseEncryptedDataBuffer(encryptedBuffer) {
27
27
  mac: encryptedBuffer.slice(-32)
28
28
  };
29
29
  }
30
+ function toBase64(str) {
31
+ if (typeof Buffer !== "undefined") {
32
+ return Buffer.from(str, "utf8").toString("base64");
33
+ } else if (typeof btoa !== "undefined") {
34
+ return btoa(str);
35
+ } else {
36
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
37
+ let result = "";
38
+ let i = 0;
39
+ while (i < str.length) {
40
+ const a = str.charCodeAt(i++);
41
+ const b = i < str.length ? str.charCodeAt(i++) : 0;
42
+ const c = i < str.length ? str.charCodeAt(i++) : 0;
43
+ const bitmap = a << 16 | b << 8 | c;
44
+ result += chars.charAt(bitmap >> 18 & 63);
45
+ result += chars.charAt(bitmap >> 12 & 63);
46
+ result += i - 2 < str.length ? chars.charAt(bitmap >> 6 & 63) : "=";
47
+ result += i - 1 < str.length ? chars.charAt(bitmap & 63) : "=";
48
+ }
49
+ return result;
50
+ }
51
+ }
30
52
  var init_crypto_utils = __esm({
31
53
  "src/platform/shared/crypto-utils.ts"() {
32
54
  "use strict";
@@ -189,7 +211,7 @@ __export(browser_exports, {
189
211
  browserPlatformAdapter: () => browserPlatformAdapter
190
212
  });
191
213
  import * as openpgp2 from "openpgp";
192
- var BrowserCryptoAdapter, BrowserPGPAdapter, BrowserHttpAdapter, BrowserPlatformAdapter, browserPlatformAdapter;
214
+ var BrowserCryptoAdapter, BrowserPGPAdapter, BrowserHttpAdapter, BrowserCacheAdapter, BrowserPlatformAdapter, browserPlatformAdapter;
193
215
  var init_browser = __esm({
194
216
  "src/platform/browser.ts"() {
195
217
  "use strict";
@@ -368,15 +390,60 @@ var init_browser = __esm({
368
390
  return fetch(url, options);
369
391
  }
370
392
  };
393
+ BrowserCacheAdapter = class {
394
+ prefix = "vana_cache_";
395
+ get(key) {
396
+ try {
397
+ if (typeof sessionStorage === "undefined") {
398
+ return null;
399
+ }
400
+ return sessionStorage.getItem(this.prefix + key);
401
+ } catch {
402
+ return null;
403
+ }
404
+ }
405
+ set(key, value) {
406
+ try {
407
+ if (typeof sessionStorage !== "undefined") {
408
+ sessionStorage.setItem(this.prefix + key, value);
409
+ }
410
+ } catch {
411
+ }
412
+ }
413
+ delete(key) {
414
+ try {
415
+ if (typeof sessionStorage !== "undefined") {
416
+ sessionStorage.removeItem(this.prefix + key);
417
+ }
418
+ } catch {
419
+ }
420
+ }
421
+ clear() {
422
+ try {
423
+ if (typeof sessionStorage === "undefined") {
424
+ return;
425
+ }
426
+ const keys = Object.keys(sessionStorage);
427
+ for (const key of keys) {
428
+ if (key.startsWith(this.prefix)) {
429
+ sessionStorage.removeItem(key);
430
+ }
431
+ }
432
+ } catch {
433
+ }
434
+ }
435
+ };
371
436
  BrowserPlatformAdapter = class {
372
437
  crypto;
373
438
  pgp;
374
439
  http;
440
+ cache;
375
441
  platform = "browser";
376
442
  constructor() {
377
443
  this.crypto = new BrowserCryptoAdapter();
378
444
  this.pgp = new BrowserPGPAdapter();
379
445
  this.http = new BrowserHttpAdapter();
446
+ this.cache = new BrowserCacheAdapter();
380
447
  }
381
448
  };
382
449
  browserPlatformAdapter = new BrowserPlatformAdapter();
@@ -602,15 +669,45 @@ var NodeHttpAdapter = class {
602
669
  throw new Error("No fetch implementation available in Node.js environment");
603
670
  }
604
671
  };
672
+ var NodeCacheAdapter = class {
673
+ cache = /* @__PURE__ */ new Map();
674
+ defaultTtl = 2 * 60 * 60 * 1e3;
675
+ // 2 hours in milliseconds
676
+ get(key) {
677
+ const entry = this.cache.get(key);
678
+ if (!entry) {
679
+ return null;
680
+ }
681
+ if (Date.now() > entry.expires) {
682
+ this.cache.delete(key);
683
+ return null;
684
+ }
685
+ return entry.value;
686
+ }
687
+ set(key, value) {
688
+ this.cache.set(key, {
689
+ value,
690
+ expires: Date.now() + this.defaultTtl
691
+ });
692
+ }
693
+ delete(key) {
694
+ this.cache.delete(key);
695
+ }
696
+ clear() {
697
+ this.cache.clear();
698
+ }
699
+ };
605
700
  var NodePlatformAdapter = class {
606
701
  crypto;
607
702
  pgp;
608
703
  http;
704
+ cache;
609
705
  platform = "node";
610
706
  constructor() {
611
707
  this.crypto = new NodeCryptoAdapter();
612
708
  this.pgp = new NodePGPAdapter();
613
709
  this.http = new NodeHttpAdapter();
710
+ this.cache = new NodeCacheAdapter();
614
711
  }
615
712
  };
616
713
  var nodePlatformAdapter = new NodePlatformAdapter();
@@ -1032,276 +1129,45 @@ var PermissionError = class extends VanaError {
1032
1129
  }
1033
1130
  };
1034
1131
 
1035
- // src/config/addresses.ts
1036
- var CONTRACTS = {
1037
- // Core Platform Contracts
1038
- DataPermissions: {
1039
- addresses: {
1040
- 14800: "0x31fb1D48f6B2265A4cAD516BC39E96a18fb7c8de",
1041
- 1480: "0x31fb1D48f6B2265A4cAD516BC39E96a18fb7c8de"
1042
- }
1043
- },
1044
- DataRegistry: {
1045
- addresses: {
1046
- 14800: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C",
1047
- 1480: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C"
1048
- }
1049
- },
1050
- TeePoolPhala: {
1051
- addresses: {
1052
- 14800: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A",
1053
- 1480: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A"
1054
- }
1055
- },
1056
- ComputeEngine: {
1057
- addresses: {
1058
- 14800: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd",
1059
- 1480: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd"
1060
- }
1061
- },
1062
- // Data Access Infrastructure
1063
- DataRefinerRegistry: {
1064
- addresses: {
1065
- 14800: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c",
1066
- 1480: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c"
1067
- }
1068
- },
1069
- QueryEngine: {
1070
- addresses: {
1071
- 14800: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490",
1072
- 1480: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490"
1073
- }
1074
- },
1075
- VanaTreasury: {
1076
- addresses: {
1077
- 14800: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD",
1078
- 1480: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD"
1079
- }
1080
- },
1081
- ComputeInstructionRegistry: {
1082
- addresses: {
1083
- 14800: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5",
1084
- 1480: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5"
1085
- }
1086
- },
1087
- // TEE Pool Variants
1088
- TeePoolEphemeralStandard: {
1089
- addresses: {
1090
- 14800: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A",
1091
- 1480: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A"
1092
- }
1093
- },
1094
- TeePoolPersistentStandard: {
1095
- addresses: {
1096
- 14800: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76",
1097
- 1480: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76"
1098
- }
1099
- },
1100
- TeePoolPersistentGpu: {
1101
- addresses: {
1102
- 14800: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9",
1103
- 1480: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9"
1104
- }
1105
- },
1106
- TeePoolDedicatedStandard: {
1107
- addresses: {
1108
- 14800: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d",
1109
- 1480: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d"
1110
- }
1111
- },
1112
- TeePoolDedicatedGpu: {
1113
- addresses: {
1114
- 14800: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E",
1115
- 1480: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E"
1116
- }
1117
- },
1118
- // DLP Reward System
1119
- VanaEpoch: {
1120
- addresses: {
1121
- 14800: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0",
1122
- 1480: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0"
1123
- }
1124
- },
1125
- DLPRegistry: {
1126
- addresses: {
1127
- 14800: "0x4D59880a924526d1dD33260552Ff4328b1E18a43",
1128
- 1480: "0x4D59880a924526d1dD33260552Ff4328b1E18a43"
1129
- }
1130
- },
1131
- DLPRegistryTreasury: {
1132
- addresses: {
1133
- 14800: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a",
1134
- 1480: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a"
1135
- }
1136
- },
1137
- DLPPerformance: {
1138
- addresses: {
1139
- 14800: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1",
1140
- 1480: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1"
1141
- }
1142
- },
1143
- DLPRewardDeployer: {
1144
- addresses: {
1145
- 14800: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04",
1146
- 1480: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04"
1147
- }
1148
- },
1149
- DLPRewardDeployerTreasury: {
1150
- addresses: {
1151
- 14800: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8",
1152
- 1480: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8"
1153
- }
1154
- },
1155
- DLPRewardSwap: {
1156
- addresses: {
1157
- 14800: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0",
1158
- 1480: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0"
1159
- }
1160
- },
1161
- SwapHelper: {
1162
- addresses: {
1163
- 14800: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2",
1164
- 1480: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2"
1165
- }
1166
- },
1167
- // VanaPool (Staking)
1168
- VanaPoolStaking: {
1169
- addresses: {
1170
- 14800: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e",
1171
- 1480: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e"
1172
- }
1173
- },
1174
- VanaPoolEntity: {
1175
- addresses: {
1176
- 14800: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30",
1177
- 1480: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30"
1178
- }
1179
- },
1180
- VanaPoolTreasury: {
1181
- addresses: {
1182
- 14800: "0x143BE72CF2541604A7691933CAccd6D9cC17c003",
1183
- 1480: "0x143BE72CF2541604A7691933CAccd6D9cC17c003"
1184
- }
1185
- },
1186
- // DLP Deployment Contracts
1187
- DAT: {
1188
- addresses: {
1189
- 14800: "0xA706b93ccED89f13340673889e29F0a5cd84212d",
1190
- 1480: "0xA706b93ccED89f13340673889e29F0a5cd84212d"
1191
- }
1192
- },
1193
- DATFactory: {
1194
- addresses: {
1195
- 14800: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644",
1196
- 1480: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644"
1197
- }
1198
- },
1199
- DATPausable: {
1200
- addresses: {
1201
- 14800: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e",
1202
- 1480: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e"
1203
- }
1204
- },
1205
- DATVotes: {
1206
- addresses: {
1207
- 14800: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831",
1208
- 1480: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831"
1209
- }
1210
- },
1211
- // Utility Contracts (no ABIs in SDK)
1212
- Multicall3: {
1213
- addresses: {
1214
- 14800: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",
1215
- 1480: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E"
1216
- }
1217
- },
1218
- Multisend: {
1219
- addresses: {
1220
- 14800: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d",
1221
- 1480: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d"
1222
- }
1223
- }
1224
- };
1225
- var LEGACY_CONTRACTS = {
1226
- // DEPRECATED: Original Intel SGX TeePool (PRO-347)
1227
- TeePool: {
1228
- addresses: {
1229
- 14800: "0x3c92fD91639b41f13338CE62f19131e7d19eaa0D",
1230
- 1480: "0x3c92fD91639b41f13338CE62f19131e7d19eaa0D"
1231
- }
1232
- },
1233
- // DEPRECATED: DLPRoot system (replaced by VanaPool + DLPRewards)
1234
- DLPRootEpoch: {
1235
- addresses: {
1236
- 14800: "0xc3d176cF6BccFCB9225b53B87a95147218e1537F",
1237
- 1480: "0xc3d176cF6BccFCB9225b53B87a95147218e1537F"
1238
- }
1239
- },
1240
- DLPRootCore: {
1241
- addresses: {
1242
- 14800: "0x0aBa5e28228c323A67712101d61a54d4ff5720FD",
1243
- 1480: "0x0aBa5e28228c323A67712101d61a54d4ff5720FD"
1244
- }
1245
- },
1246
- DLPRoot: {
1247
- addresses: {
1248
- 14800: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5",
1249
- 1480: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5"
1250
- }
1251
- },
1252
- DLPRootMetrics: {
1253
- addresses: {
1254
- 14800: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662",
1255
- 1480: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662"
1256
- }
1257
- },
1258
- DLPRootStakesTreasury: {
1259
- addresses: {
1260
- 14800: "0x52c3260ED5C235fcA43524CF508e29c897318775",
1261
- 1480: "0x52c3260ED5C235fcA43524CF508e29c897318775"
1262
- }
1263
- },
1264
- DLPRootRewardsTreasury: {
1265
- addresses: {
1266
- 14800: "0xDBFb6B8b9E2eCAEbdE64d665cD553dB81e524479",
1267
- 1480: "0xDBFb6B8b9E2eCAEbdE64d665cD553dB81e524479"
1268
- }
1269
- }
1270
- };
1271
- var CONTRACT_ADDRESSES = {
1272
- 14800: Object.fromEntries(
1273
- Object.entries(CONTRACTS).map(([name, info]) => [name, info.addresses[14800]]).filter(([, addr]) => addr)
1274
- ),
1275
- 1480: Object.fromEntries(
1276
- Object.entries(CONTRACTS).map(([name, info]) => [name, info.addresses[1480]]).filter(([, addr]) => addr)
1277
- )
1278
- };
1279
- var UTILITY_ADDRESSES = {
1280
- 14800: {
1281
- Multicall3: CONTRACTS.Multicall3.addresses[14800],
1282
- Multisend: CONTRACTS.Multisend.addresses[14800]
1283
- },
1284
- 1480: {
1285
- Multicall3: CONTRACTS.Multicall3.addresses[1480],
1286
- Multisend: CONTRACTS.Multisend.addresses[1480]
1287
- }
1288
- };
1289
- var LEGACY_ADDRESSES = {
1290
- 14800: Object.fromEntries(
1291
- Object.entries(LEGACY_CONTRACTS).map(([name, info]) => [name, info.addresses[14800]]).filter(([, addr]) => addr)
1292
- ),
1293
- 1480: Object.fromEntries(
1294
- Object.entries(LEGACY_CONTRACTS).map(([name, info]) => [name, info.addresses[1480]]).filter(([, addr]) => addr)
1295
- )
1296
- };
1297
- var getContractAddress = (chainId, contract) => {
1298
- const contractAddress = CONTRACT_ADDRESSES[chainId]?.[contract];
1299
- if (!contractAddress) {
1300
- throw new Error(
1301
- `Contract address not found for ${contract} on chain ${chainId}`
1302
- );
1132
+ // src/utils/transactionParsing.ts
1133
+ import { parseEventLogs } from "viem";
1134
+
1135
+ // src/config/eventMappings.ts
1136
+ var EVENT_MAPPINGS = {
1137
+ // Permission operations
1138
+ grant: {
1139
+ contract: "DataPermissions",
1140
+ event: "PermissionAdded"
1141
+ },
1142
+ revoke: {
1143
+ contract: "DataPermissions",
1144
+ event: "PermissionRevoked"
1145
+ },
1146
+ trustServer: {
1147
+ contract: "DataPermissions",
1148
+ event: "ServerTrusted"
1149
+ },
1150
+ untrustServer: {
1151
+ contract: "DataPermissions",
1152
+ event: "ServerUntrusted"
1153
+ },
1154
+ // Data registry operations
1155
+ addFile: {
1156
+ contract: "DataRegistry",
1157
+ event: "FileAdded"
1158
+ },
1159
+ addRefinement: {
1160
+ contract: "DataRegistry",
1161
+ event: "RefinementAdded"
1162
+ },
1163
+ updateRefinement: {
1164
+ contract: "DataRegistry",
1165
+ event: "RefinementUpdated"
1166
+ },
1167
+ addFilePermission: {
1168
+ contract: "DataRegistry",
1169
+ event: "PermissionGranted"
1303
1170
  }
1304
- return contractAddress;
1305
1171
  };
1306
1172
 
1307
1173
  // src/abi/ComputeEngineImplementation.ts
@@ -33508,6 +33374,332 @@ function getAbi(contract) {
33508
33374
  return abi;
33509
33375
  }
33510
33376
 
33377
+ // src/utils/transactionParsing.ts
33378
+ async function parseTransactionResult(context, hash, operation) {
33379
+ const mapping = EVENT_MAPPINGS[operation];
33380
+ try {
33381
+ console.debug(`\u{1F50D} Parsing ${operation} transaction: ${hash}`);
33382
+ const receipt = await context.publicClient.waitForTransactionReceipt({
33383
+ hash,
33384
+ timeout: 3e4
33385
+ // 30 second timeout
33386
+ });
33387
+ console.debug(`\u2705 Transaction confirmed in block ${receipt.blockNumber}`);
33388
+ const abi = getAbi(mapping.contract);
33389
+ const events = parseEventLogs({
33390
+ logs: receipt.logs,
33391
+ abi,
33392
+ eventName: mapping.event,
33393
+ strict: true
33394
+ // Only return logs that conform to the ABI
33395
+ });
33396
+ if (events.length === 0) {
33397
+ throw new BlockchainError(
33398
+ `No ${mapping.event} event found in transaction ${hash}. Transaction may have failed or reverted.`
33399
+ );
33400
+ }
33401
+ if (events.length > 1) {
33402
+ console.warn(
33403
+ `\u26A0\uFE0F Multiple ${mapping.event} events found in transaction ${hash}. Using the first one.`
33404
+ );
33405
+ }
33406
+ const event = events[0];
33407
+ console.debug(`\u{1F389} Found ${mapping.event} event with args:`, event.args);
33408
+ return {
33409
+ ...event.args,
33410
+ transactionHash: hash,
33411
+ blockNumber: receipt.blockNumber,
33412
+ gasUsed: receipt.gasUsed
33413
+ };
33414
+ } catch (error) {
33415
+ if (error instanceof BlockchainError || error instanceof NetworkError) {
33416
+ throw error;
33417
+ }
33418
+ if (error instanceof Error && error.message.includes("timeout")) {
33419
+ throw new NetworkError(
33420
+ `Transaction ${hash} confirmation timeout after 30 seconds. The transaction may still be pending.`,
33421
+ error
33422
+ );
33423
+ }
33424
+ throw new BlockchainError(
33425
+ `Failed to parse ${operation} transaction ${hash}: ${error instanceof Error ? error.message : "Unknown error"}`,
33426
+ error
33427
+ );
33428
+ }
33429
+ }
33430
+
33431
+ // src/config/addresses.ts
33432
+ var CONTRACTS = {
33433
+ // Core Platform Contracts
33434
+ DataPermissions: {
33435
+ addresses: {
33436
+ 14800: "0x31fb1D48f6B2265A4cAD516BC39E96a18fb7c8de",
33437
+ 1480: "0x31fb1D48f6B2265A4cAD516BC39E96a18fb7c8de"
33438
+ }
33439
+ },
33440
+ DataRegistry: {
33441
+ addresses: {
33442
+ 14800: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C",
33443
+ 1480: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C"
33444
+ }
33445
+ },
33446
+ TeePoolPhala: {
33447
+ addresses: {
33448
+ 14800: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A",
33449
+ 1480: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A"
33450
+ }
33451
+ },
33452
+ ComputeEngine: {
33453
+ addresses: {
33454
+ 14800: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd",
33455
+ 1480: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd"
33456
+ }
33457
+ },
33458
+ // Data Access Infrastructure
33459
+ DataRefinerRegistry: {
33460
+ addresses: {
33461
+ 14800: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c",
33462
+ 1480: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c"
33463
+ }
33464
+ },
33465
+ QueryEngine: {
33466
+ addresses: {
33467
+ 14800: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490",
33468
+ 1480: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490"
33469
+ }
33470
+ },
33471
+ VanaTreasury: {
33472
+ addresses: {
33473
+ 14800: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD",
33474
+ 1480: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD"
33475
+ }
33476
+ },
33477
+ ComputeInstructionRegistry: {
33478
+ addresses: {
33479
+ 14800: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5",
33480
+ 1480: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5"
33481
+ }
33482
+ },
33483
+ // TEE Pool Variants
33484
+ TeePoolEphemeralStandard: {
33485
+ addresses: {
33486
+ 14800: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A",
33487
+ 1480: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A"
33488
+ }
33489
+ },
33490
+ TeePoolPersistentStandard: {
33491
+ addresses: {
33492
+ 14800: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76",
33493
+ 1480: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76"
33494
+ }
33495
+ },
33496
+ TeePoolPersistentGpu: {
33497
+ addresses: {
33498
+ 14800: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9",
33499
+ 1480: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9"
33500
+ }
33501
+ },
33502
+ TeePoolDedicatedStandard: {
33503
+ addresses: {
33504
+ 14800: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d",
33505
+ 1480: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d"
33506
+ }
33507
+ },
33508
+ TeePoolDedicatedGpu: {
33509
+ addresses: {
33510
+ 14800: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E",
33511
+ 1480: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E"
33512
+ }
33513
+ },
33514
+ // DLP Reward System
33515
+ VanaEpoch: {
33516
+ addresses: {
33517
+ 14800: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0",
33518
+ 1480: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0"
33519
+ }
33520
+ },
33521
+ DLPRegistry: {
33522
+ addresses: {
33523
+ 14800: "0x4D59880a924526d1dD33260552Ff4328b1E18a43",
33524
+ 1480: "0x4D59880a924526d1dD33260552Ff4328b1E18a43"
33525
+ }
33526
+ },
33527
+ DLPRegistryTreasury: {
33528
+ addresses: {
33529
+ 14800: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a",
33530
+ 1480: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a"
33531
+ }
33532
+ },
33533
+ DLPPerformance: {
33534
+ addresses: {
33535
+ 14800: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1",
33536
+ 1480: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1"
33537
+ }
33538
+ },
33539
+ DLPRewardDeployer: {
33540
+ addresses: {
33541
+ 14800: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04",
33542
+ 1480: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04"
33543
+ }
33544
+ },
33545
+ DLPRewardDeployerTreasury: {
33546
+ addresses: {
33547
+ 14800: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8",
33548
+ 1480: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8"
33549
+ }
33550
+ },
33551
+ DLPRewardSwap: {
33552
+ addresses: {
33553
+ 14800: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0",
33554
+ 1480: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0"
33555
+ }
33556
+ },
33557
+ SwapHelper: {
33558
+ addresses: {
33559
+ 14800: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2",
33560
+ 1480: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2"
33561
+ }
33562
+ },
33563
+ // VanaPool (Staking)
33564
+ VanaPoolStaking: {
33565
+ addresses: {
33566
+ 14800: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e",
33567
+ 1480: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e"
33568
+ }
33569
+ },
33570
+ VanaPoolEntity: {
33571
+ addresses: {
33572
+ 14800: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30",
33573
+ 1480: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30"
33574
+ }
33575
+ },
33576
+ VanaPoolTreasury: {
33577
+ addresses: {
33578
+ 14800: "0x143BE72CF2541604A7691933CAccd6D9cC17c003",
33579
+ 1480: "0x143BE72CF2541604A7691933CAccd6D9cC17c003"
33580
+ }
33581
+ },
33582
+ // DLP Deployment Contracts
33583
+ DAT: {
33584
+ addresses: {
33585
+ 14800: "0xA706b93ccED89f13340673889e29F0a5cd84212d",
33586
+ 1480: "0xA706b93ccED89f13340673889e29F0a5cd84212d"
33587
+ }
33588
+ },
33589
+ DATFactory: {
33590
+ addresses: {
33591
+ 14800: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644",
33592
+ 1480: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644"
33593
+ }
33594
+ },
33595
+ DATPausable: {
33596
+ addresses: {
33597
+ 14800: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e",
33598
+ 1480: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e"
33599
+ }
33600
+ },
33601
+ DATVotes: {
33602
+ addresses: {
33603
+ 14800: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831",
33604
+ 1480: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831"
33605
+ }
33606
+ },
33607
+ // Utility Contracts (no ABIs in SDK)
33608
+ Multicall3: {
33609
+ addresses: {
33610
+ 14800: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",
33611
+ 1480: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E"
33612
+ }
33613
+ },
33614
+ Multisend: {
33615
+ addresses: {
33616
+ 14800: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d",
33617
+ 1480: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d"
33618
+ }
33619
+ }
33620
+ };
33621
+ var LEGACY_CONTRACTS = {
33622
+ // DEPRECATED: Original Intel SGX TeePool (PRO-347)
33623
+ TeePool: {
33624
+ addresses: {
33625
+ 14800: "0x3c92fD91639b41f13338CE62f19131e7d19eaa0D",
33626
+ 1480: "0x3c92fD91639b41f13338CE62f19131e7d19eaa0D"
33627
+ }
33628
+ },
33629
+ // DEPRECATED: DLPRoot system (replaced by VanaPool + DLPRewards)
33630
+ DLPRootEpoch: {
33631
+ addresses: {
33632
+ 14800: "0xc3d176cF6BccFCB9225b53B87a95147218e1537F",
33633
+ 1480: "0xc3d176cF6BccFCB9225b53B87a95147218e1537F"
33634
+ }
33635
+ },
33636
+ DLPRootCore: {
33637
+ addresses: {
33638
+ 14800: "0x0aBa5e28228c323A67712101d61a54d4ff5720FD",
33639
+ 1480: "0x0aBa5e28228c323A67712101d61a54d4ff5720FD"
33640
+ }
33641
+ },
33642
+ DLPRoot: {
33643
+ addresses: {
33644
+ 14800: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5",
33645
+ 1480: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5"
33646
+ }
33647
+ },
33648
+ DLPRootMetrics: {
33649
+ addresses: {
33650
+ 14800: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662",
33651
+ 1480: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662"
33652
+ }
33653
+ },
33654
+ DLPRootStakesTreasury: {
33655
+ addresses: {
33656
+ 14800: "0x52c3260ED5C235fcA43524CF508e29c897318775",
33657
+ 1480: "0x52c3260ED5C235fcA43524CF508e29c897318775"
33658
+ }
33659
+ },
33660
+ DLPRootRewardsTreasury: {
33661
+ addresses: {
33662
+ 14800: "0xDBFb6B8b9E2eCAEbdE64d665cD553dB81e524479",
33663
+ 1480: "0xDBFb6B8b9E2eCAEbdE64d665cD553dB81e524479"
33664
+ }
33665
+ }
33666
+ };
33667
+ var CONTRACT_ADDRESSES = {
33668
+ 14800: Object.fromEntries(
33669
+ Object.entries(CONTRACTS).map(([name, info]) => [name, info.addresses[14800]]).filter(([, addr]) => addr)
33670
+ ),
33671
+ 1480: Object.fromEntries(
33672
+ Object.entries(CONTRACTS).map(([name, info]) => [name, info.addresses[1480]]).filter(([, addr]) => addr)
33673
+ )
33674
+ };
33675
+ var UTILITY_ADDRESSES = {
33676
+ 14800: {
33677
+ Multicall3: CONTRACTS.Multicall3.addresses[14800],
33678
+ Multisend: CONTRACTS.Multisend.addresses[14800]
33679
+ },
33680
+ 1480: {
33681
+ Multicall3: CONTRACTS.Multicall3.addresses[1480],
33682
+ Multisend: CONTRACTS.Multisend.addresses[1480]
33683
+ }
33684
+ };
33685
+ var LEGACY_ADDRESSES = {
33686
+ 14800: Object.fromEntries(
33687
+ Object.entries(LEGACY_CONTRACTS).map(([name, info]) => [name, info.addresses[14800]]).filter(([, addr]) => addr)
33688
+ ),
33689
+ 1480: Object.fromEntries(
33690
+ Object.entries(LEGACY_CONTRACTS).map(([name, info]) => [name, info.addresses[1480]]).filter(([, addr]) => addr)
33691
+ )
33692
+ };
33693
+ var getContractAddress = (chainId, contract) => {
33694
+ const contractAddress = CONTRACT_ADDRESSES[chainId]?.[contract];
33695
+ if (!contractAddress) {
33696
+ throw new Error(
33697
+ `Contract address not found for ${contract} on chain ${chainId}`
33698
+ );
33699
+ }
33700
+ return contractAddress;
33701
+ };
33702
+
33511
33703
  // src/utils/grantFiles.ts
33512
33704
  import { keccak256, toHex } from "viem";
33513
33705
  function createGrantFile(params) {
@@ -33909,6 +34101,91 @@ function validateOperationAccess(grantFile, requestedOperation) {
33909
34101
  }
33910
34102
  }
33911
34103
 
34104
+ // src/utils/signatureCache.ts
34105
+ init_crypto_utils();
34106
+ var SignatureCache = class {
34107
+ static PREFIX = "vana_sig_";
34108
+ static DEFAULT_TTL_HOURS = 2;
34109
+ /**
34110
+ * Get a cached signature if it exists and hasn't expired
34111
+ */
34112
+ static get(cache, walletAddress, messageHash) {
34113
+ const key = this.getCacheKey(walletAddress, messageHash);
34114
+ try {
34115
+ const stored = cache.get(key);
34116
+ if (!stored) return null;
34117
+ const cached = JSON.parse(stored);
34118
+ if (Date.now() > cached.expires) {
34119
+ cache.delete(key);
34120
+ return null;
34121
+ }
34122
+ return cached.signature;
34123
+ } catch {
34124
+ try {
34125
+ cache.delete(key);
34126
+ } catch {
34127
+ }
34128
+ return null;
34129
+ }
34130
+ }
34131
+ /**
34132
+ * Store a signature in the cache
34133
+ */
34134
+ static set(cache, walletAddress, messageHash, signature, ttlHours = this.DEFAULT_TTL_HOURS) {
34135
+ const key = this.getCacheKey(walletAddress, messageHash);
34136
+ const cached = {
34137
+ signature,
34138
+ expires: Date.now() + ttlHours * 36e5
34139
+ // Convert hours to milliseconds
34140
+ };
34141
+ try {
34142
+ cache.set(key, JSON.stringify(cached));
34143
+ } catch {
34144
+ }
34145
+ }
34146
+ /**
34147
+ * Clear all cached signatures (useful for testing or explicit cleanup)
34148
+ */
34149
+ static clear(cache) {
34150
+ try {
34151
+ cache.clear();
34152
+ } catch {
34153
+ }
34154
+ }
34155
+ static getCacheKey(walletAddress, messageHash) {
34156
+ return `${this.PREFIX}${walletAddress.toLowerCase()}:${messageHash}`;
34157
+ }
34158
+ static hashMessage(message) {
34159
+ const jsonString = JSON.stringify(message, this.bigIntReplacer);
34160
+ const base64Hash = toBase64(jsonString);
34161
+ const cleaned = base64Hash.replace(/[^a-zA-Z0-9]/g, "");
34162
+ if (cleaned.length > 32) {
34163
+ return cleaned.substring(0, 16) + cleaned.substring(cleaned.length - 16);
34164
+ }
34165
+ return cleaned.substring(0, 32);
34166
+ }
34167
+ /**
34168
+ * Custom JSON replacer that converts BigInt values to strings for serialization
34169
+ * This ensures deterministic cache key generation for EIP-712 typed data
34170
+ */
34171
+ static bigIntReplacer(key, value) {
34172
+ if (typeof value === "bigint") {
34173
+ return `__BIGINT__${value.toString()}`;
34174
+ }
34175
+ return value;
34176
+ }
34177
+ };
34178
+ async function withSignatureCache(cache, walletAddress, typedData, signFn, ttlHours) {
34179
+ const messageHash = SignatureCache.hashMessage(typedData);
34180
+ const cached = SignatureCache.get(cache, walletAddress, messageHash);
34181
+ if (cached) {
34182
+ return cached;
34183
+ }
34184
+ const signature = await signFn();
34185
+ SignatureCache.set(cache, walletAddress, messageHash, signature, ttlHours);
34186
+ return signature;
34187
+ }
34188
+
33912
34189
  // src/controllers/permissions.ts
33913
34190
  var PermissionsController = class {
33914
34191
  constructor(context) {
@@ -33916,22 +34193,22 @@ var PermissionsController = class {
33916
34193
  }
33917
34194
  /**
33918
34195
  * Grants permission for an application to access user data with gasless transactions.
34196
+ *
34197
+ * This method provides a complete end-to-end permission grant flow that returns
34198
+ * the permission ID and other relevant data immediately after successful submission.
34199
+ * For advanced users who need more control over the transaction lifecycle, use
34200
+ * `submitPermissionGrant()` instead.
33919
34201
  *
33920
- * @remarks
33921
- * This method combines signature creation and gasless submission for a complete
33922
- * end-to-end permission grant flow. It creates the grant file, stores it on IPFS,
33923
- * generates an EIP-712 signature, and submits via relayer. The grant file contains
33924
- * detailed parameters while the blockchain stores only a reference to enable
33925
- * efficient permission queries.
33926
34202
  * @param params - The permission grant configuration object
33927
- * @returns A Promise that resolves to the transaction hash when successfully submitted
34203
+ * @returns Promise resolving to permission data from the PermissionAdded event
33928
34204
  * @throws {RelayerError} When gasless transaction submission fails
33929
34205
  * @throws {SignatureError} When user rejects the signature request
33930
34206
  * @throws {SerializationError} When grant data cannot be serialized
33931
- * @throws {BlockchainError} When permission grant preparation fails
34207
+ * @throws {BlockchainError} When permission grant fails or event parsing fails
34208
+ * @throws {NetworkError} When transaction confirmation times out
33932
34209
  * @example
33933
34210
  * ```typescript
33934
- * const txHash = await vana.permissions.grant({
34211
+ * const result = await vana.permissions.grant({
33935
34212
  * grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
33936
34213
  * operation: "llm_inference",
33937
34214
  * parameters: {
@@ -33941,10 +34218,42 @@ var PermissionsController = class {
33941
34218
  * },
33942
34219
  * });
33943
34220
  *
33944
- * console.log(`Permission granted: ${txHash}`);
34221
+ * console.log(`Permission ${result.permissionId} granted to ${result.user}`);
34222
+ * console.log(`Transaction: ${result.transactionHash}`);
34223
+ *
34224
+ * // Can immediately use the permission ID for other operations
34225
+ * await vana.permissions.revoke({ permissionId: result.permissionId });
33945
34226
  * ```
33946
34227
  */
33947
34228
  async grant(params) {
34229
+ const txHash = await this.submitPermissionGrant(params);
34230
+ return parseTransactionResult(this.context, txHash, "grant");
34231
+ }
34232
+ /**
34233
+ * Submits a permission grant transaction and returns the transaction hash immediately.
34234
+ *
34235
+ * This is the lower-level method that provides maximum control over transaction timing.
34236
+ * Use this when you want to handle transaction confirmation and event parsing separately,
34237
+ * or when submitting multiple transactions in batch.
34238
+ *
34239
+ * @param params - The permission grant configuration object
34240
+ * @returns Promise that resolves to the transaction hash when successfully submitted
34241
+ * @throws {RelayerError} When gasless transaction submission fails
34242
+ * @throws {SignatureError} When user rejects the signature request
34243
+ * @throws {SerializationError} When grant data cannot be serialized
34244
+ * @throws {BlockchainError} When permission grant preparation fails
34245
+ * @example
34246
+ * ```typescript
34247
+ * // Submit transaction and handle confirmation later
34248
+ * const txHash = await vana.permissions.submitPermissionGrant(params);
34249
+ * console.log(`Transaction submitted: ${txHash}`);
34250
+ *
34251
+ * // Later, when you need the permission data:
34252
+ * const result = await parseTransactionResult(context, txHash, 'grant');
34253
+ * console.log(`Permission ID: ${result.permissionId}`);
34254
+ * ```
34255
+ */
34256
+ async submitPermissionGrant(params) {
33948
34257
  const { typedData, signature } = await this.createAndSign(params);
33949
34258
  return await this.submitSignedGrant(typedData, signature);
33950
34259
  }
@@ -34361,23 +34670,52 @@ var PermissionsController = class {
34361
34670
  }
34362
34671
  /**
34363
34672
  * Revokes a previously granted permission.
34673
+ *
34674
+ * This method provides complete revocation with automatic event parsing to confirm
34675
+ * the permission was successfully revoked. For advanced users who need more control,
34676
+ * use `submitPermissionRevoke()` instead.
34364
34677
  *
34365
34678
  * @param params - Parameters for revoking the permission
34366
- * @returns Promise resolving to transaction hash
34679
+ * @param params.permissionId - Permission identifier as bigint for contract compatibility.
34680
+ * Obtain from permission grants via `getUserPermissionGrantsOnChain()`.
34681
+ * @returns Promise resolving to revocation data from PermissionRevoked event
34682
+ * @throws {BlockchainError} When revocation fails or event parsing fails
34683
+ * @throws {UserRejectedRequestError} When user rejects the transaction
34684
+ * @throws {NetworkError} When transaction confirmation times out
34367
34685
  * @example
34368
34686
  * ```typescript
34369
- * // Revoke a permission by its ID
34370
- * const txHash = await vana.permissions.revoke({
34687
+ * // Revoke a permission and get confirmation
34688
+ * const result = await vana.permissions.revoke({
34371
34689
  * permissionId: 123n
34372
34690
  * });
34373
- * console.log('Permission revoked in transaction:', txHash);
34374
- *
34375
- * // Wait for confirmation if needed
34376
- * const receipt = await vana.core.waitForTransaction(txHash);
34377
- * console.log('Revocation confirmed in block:', receipt.blockNumber);
34691
+ * console.log(`Permission ${result.permissionId} revoked in transaction ${result.transactionHash}`);
34692
+ * console.log(`Revoked in block ${result.blockNumber}`);
34378
34693
  * ```
34379
34694
  */
34380
34695
  async revoke(params) {
34696
+ const txHash = await this.submitPermissionRevoke(params);
34697
+ return parseTransactionResult(this.context, txHash, "revoke");
34698
+ }
34699
+ /**
34700
+ * Submits a permission revocation transaction and returns the transaction hash immediately.
34701
+ *
34702
+ * This is the lower-level method that provides maximum control over transaction timing.
34703
+ * Use this when you want to handle transaction confirmation and event parsing separately.
34704
+ *
34705
+ * @param params - Parameters for revoking the permission
34706
+ * @returns Promise resolving to the transaction hash when successfully submitted
34707
+ * @throws {BlockchainError} When revocation transaction fails
34708
+ * @throws {UserRejectedRequestError} When user rejects the transaction
34709
+ * @example
34710
+ * ```typescript
34711
+ * // Submit revocation and handle confirmation later
34712
+ * const txHash = await vana.permissions.submitPermissionRevoke({
34713
+ * permissionId: 123n
34714
+ * });
34715
+ * console.log(`Revocation submitted: ${txHash}`);
34716
+ * ```
34717
+ */
34718
+ async submitPermissionRevoke(params) {
34381
34719
  try {
34382
34720
  if (!this.context.walletClient.chain?.id) {
34383
34721
  throw new BlockchainError("Chain ID not available");
@@ -34543,17 +34881,24 @@ var PermissionsController = class {
34543
34881
  };
34544
34882
  }
34545
34883
  /**
34546
- * Signs typed data using the wallet client.
34884
+ * Signs typed data using the wallet client with signature caching.
34547
34885
  *
34548
34886
  * @param typedData - The EIP-712 typed data structure to sign
34549
34887
  * @returns Promise resolving to the cryptographic signature
34550
34888
  */
34551
34889
  async signTypedData(typedData) {
34552
34890
  try {
34553
- const signature = await this.context.walletClient.signTypedData(
34554
- typedData
34891
+ const walletAddress = this.context.walletClient.account?.address || await this.getUserAddress();
34892
+ return await withSignatureCache(
34893
+ this.context.platform.cache,
34894
+ walletAddress,
34895
+ typedData,
34896
+ async () => {
34897
+ return await this.context.walletClient.signTypedData(
34898
+ typedData
34899
+ );
34900
+ }
34555
34901
  );
34556
- return signature;
34557
34902
  } catch (error) {
34558
34903
  if (error instanceof Error && error.message.includes("rejected")) {
34559
34904
  throw new UserRejectedRequestError();
@@ -35387,15 +35732,22 @@ import { getContract, decodeEventLog } from "viem";
35387
35732
 
35388
35733
  // src/utils/encryption.ts
35389
35734
  var DEFAULT_ENCRYPTION_SEED = "Please sign to retrieve your encryption key";
35390
- async function generateEncryptionKey(wallet, seed = DEFAULT_ENCRYPTION_SEED) {
35735
+ async function generateEncryptionKey(wallet, platformAdapter, seed = DEFAULT_ENCRYPTION_SEED) {
35391
35736
  if (!wallet.account) {
35392
35737
  throw new Error("Wallet account is required for encryption key generation");
35393
35738
  }
35394
- const signature = await wallet.signMessage({
35395
- account: wallet.account,
35396
- message: seed
35397
- });
35398
- return signature;
35739
+ const messageData = { message: seed };
35740
+ return await withSignatureCache(
35741
+ platformAdapter.cache,
35742
+ wallet.account.address,
35743
+ messageData,
35744
+ async () => {
35745
+ return await wallet.signMessage({
35746
+ account: wallet.account,
35747
+ message: seed
35748
+ });
35749
+ }
35750
+ );
35399
35751
  }
35400
35752
  async function encryptWithWalletPublicKey(data, publicKey, platformAdapter) {
35401
35753
  try {
@@ -35504,7 +35856,8 @@ var DataController = class {
35504
35856
  schemaId,
35505
35857
  permissions = [],
35506
35858
  encrypt: encrypt3 = true,
35507
- providerName
35859
+ providerName,
35860
+ owner
35508
35861
  } = params;
35509
35862
  try {
35510
35863
  let blob;
@@ -35559,6 +35912,7 @@ var DataController = class {
35559
35912
  if (encrypt3) {
35560
35913
  const encryptionKey = await generateEncryptionKey(
35561
35914
  this.context.walletClient,
35915
+ this.context.platform,
35562
35916
  DEFAULT_ENCRYPTION_SEED
35563
35917
  );
35564
35918
  finalBlob = await encryptBlobWithSignedKey(
@@ -35582,28 +35936,23 @@ var DataController = class {
35582
35936
  filename,
35583
35937
  providerName
35584
35938
  );
35585
- const userAddress = await this.getUserAddress();
35939
+ const userAddress = owner || await this.getUserAddress();
35586
35940
  let encryptedPermissions = [];
35587
35941
  if (permissions.length > 0 && encrypt3) {
35588
35942
  const userEncryptionKey = await generateEncryptionKey(
35589
35943
  this.context.walletClient,
35944
+ this.context.platform,
35590
35945
  DEFAULT_ENCRYPTION_SEED
35591
35946
  );
35592
35947
  encryptedPermissions = await Promise.all(
35593
35948
  permissions.map(async (permission) => {
35594
- const publicKey = permission.publicKey;
35595
- if (!publicKey) {
35596
- throw new Error(
35597
- `Public key required for permission to ${permission.grantee} when encryption is enabled`
35598
- );
35599
- }
35600
35949
  const encryptedKey = await encryptWithWalletPublicKey(
35601
35950
  userEncryptionKey,
35602
- publicKey,
35951
+ permission.publicKey,
35603
35952
  this.context.platform
35604
35953
  );
35605
35954
  return {
35606
- account: permission.grantee,
35955
+ account: permission.account,
35607
35956
  key: encryptedKey
35608
35957
  };
35609
35958
  })
@@ -35616,7 +35965,8 @@ var DataController = class {
35616
35965
  url: uploadResult.url,
35617
35966
  userAddress,
35618
35967
  permissions: encryptedPermissions,
35619
- schemaId: schemaId || 0
35968
+ schemaId: schemaId || 0,
35969
+ ownerAddress: owner
35620
35970
  }
35621
35971
  );
35622
35972
  } else if (this.context.relayerCallbacks?.submitFileAddition) {
@@ -35706,6 +36056,7 @@ var DataController = class {
35706
36056
  try {
35707
36057
  const encryptionKey = await generateEncryptionKey(
35708
36058
  this.context.walletClient,
36059
+ this.context.platform,
35709
36060
  encryptionSeed || DEFAULT_ENCRYPTION_SEED
35710
36061
  );
35711
36062
  let encryptedBlob;
@@ -37089,6 +37440,7 @@ var DataController = class {
37089
37440
  try {
37090
37441
  const userEncryptionKey = await generateEncryptionKey(
37091
37442
  this.context.walletClient,
37443
+ this.context.platform,
37092
37444
  DEFAULT_ENCRYPTION_SEED
37093
37445
  );
37094
37446
  const encryptedData = await encryptBlobWithSignedKey(
@@ -37154,16 +37506,47 @@ var DataController = class {
37154
37506
  * 1. Gets the user's encryption key
37155
37507
  * 2. Encrypts the user's encryption key with the provided public key
37156
37508
  * 3. Adds the permission to the file
37509
+ * 4. Returns the permission data from the blockchain event
37510
+ *
37511
+ * For advanced users who need more control over transaction timing,
37512
+ * use `submitFilePermission()` instead.
37157
37513
  *
37158
37514
  * @param fileId - The ID of the file to add permissions for
37159
37515
  * @param account - The address of the account to grant permission to
37160
37516
  * @param publicKey - The public key to encrypt the user's encryption key with
37161
- * @returns Promise resolving to the transaction hash
37517
+ * @returns Promise resolving to permission data from PermissionGranted event
37518
+ * @example
37519
+ * ```typescript
37520
+ * const result = await vana.data.addPermissionToFile(fileId, account, publicKey);
37521
+ * console.log(`Permission granted to ${result.account} for file ${result.fileId}`);
37522
+ * console.log(`Transaction: ${result.transactionHash}`);
37523
+ * ```
37162
37524
  */
37163
37525
  async addPermissionToFile(fileId, account, publicKey) {
37526
+ const txHash = await this.submitFilePermission(fileId, account, publicKey);
37527
+ return parseTransactionResult(this.context, txHash, "addFilePermission");
37528
+ }
37529
+ /**
37530
+ * Submits a file permission transaction and returns the transaction hash immediately.
37531
+ *
37532
+ * This is the lower-level method that provides maximum control over transaction timing.
37533
+ * Use this when you want to handle transaction confirmation and event parsing separately.
37534
+ *
37535
+ * @param fileId - The ID of the file to add permissions for
37536
+ * @param account - The address of the account to grant permission to
37537
+ * @param publicKey - The public key to encrypt the user's encryption key with
37538
+ * @returns Promise resolving to the transaction hash
37539
+ * @example
37540
+ * ```typescript
37541
+ * const txHash = await vana.data.submitFilePermission(fileId, account, publicKey);
37542
+ * console.log(`Transaction submitted: ${txHash}`);
37543
+ * ```
37544
+ */
37545
+ async submitFilePermission(fileId, account, publicKey) {
37164
37546
  try {
37165
37547
  const userEncryptionKey = await generateEncryptionKey(
37166
37548
  this.context.walletClient,
37549
+ this.context.platform,
37167
37550
  DEFAULT_ENCRYPTION_SEED
37168
37551
  );
37169
37552
  const encryptedKey = await encryptWithWalletPublicKey(
@@ -37877,6 +38260,39 @@ var ServerController = class {
37877
38260
  this.context = context;
37878
38261
  }
37879
38262
  PERSONAL_SERVER_BASE_URL = process.env.NEXT_PUBLIC_PERSONAL_SERVER_BASE_URL;
38263
+ /**
38264
+ * Retrieves the cryptographic identity of a personal server.
38265
+ *
38266
+ * @remarks
38267
+ * This method fetches the public key and metadata for a personal server,
38268
+ * which is required for encrypting data before sharing with the server.
38269
+ * The identity includes the server's public key, address, and operational
38270
+ * details needed for secure communication. This information is cached
38271
+ * by identity servers to enable offline key retrieval.
38272
+ *
38273
+ * @param request - Parameters containing the user address
38274
+ * @param request.userAddress - The wallet address associated with the personal server
38275
+ * @returns Promise resolving to the server's identity information
38276
+ * @throws {NetworkError} When the identity service is unavailable or returns invalid data
38277
+ * @throws {PersonalServerError} When server identity cannot be retrieved
38278
+ * @example
38279
+ * ```typescript
38280
+ * // Get server identity for data encryption
38281
+ * const identity = await vana.server.getIdentity({
38282
+ * userAddress: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
38283
+ * });
38284
+ *
38285
+ * console.log(`Server: ${identity.name}`);
38286
+ * console.log(`Address: ${identity.address}`);
38287
+ * console.log(`Public Key: ${identity.public_key}`);
38288
+ *
38289
+ * // Use the public key for encrypting data to share with this server
38290
+ * const encryptedData = await encryptWithWalletPublicKey(
38291
+ * userData,
38292
+ * identity.public_key
38293
+ * );
38294
+ * ```
38295
+ */
37880
38296
  async getIdentity(request) {
37881
38297
  try {
37882
38298
  const response = await fetch(
@@ -37919,10 +38335,13 @@ var ServerController = class {
37919
38335
  * This method submits a computation request to the personal server API.
37920
38336
  * The response includes the operation ID.
37921
38337
  * @param params - The request parameters object
37922
- * @param params.permissionId - The permission ID authorizing this operation
38338
+ * @param params.permissionId - The permission ID authorizing this operation.
38339
+ * Obtain from granted permissions via `vana.permissions.getUserPermissionGrantsOnChain()`.
37923
38340
  * @returns A Promise that resolves to an operation response with status and control URLs
37924
- * @throws {PersonalServerError} When server request fails or parameters are invalid
37925
- * @throws {NetworkError} When personal server API communication fails
38341
+ * @throws {PersonalServerError} When server request fails or parameters are invalid.
38342
+ * Verify permissionId exists and is active for the target server.
38343
+ * @throws {NetworkError} When personal server API communication fails.
38344
+ * Check server URL configuration and network connectivity.
37926
38345
  * @example
37927
38346
  * ```typescript
37928
38347
  * const response = await vana.server.createOperation({
@@ -38024,6 +38443,50 @@ var ServerController = class {
38024
38443
  );
38025
38444
  }
38026
38445
  }
38446
+ /**
38447
+ * Cancels a running operation on the personal server.
38448
+ *
38449
+ * @remarks
38450
+ * This method attempts to cancel an operation that is currently processing
38451
+ * on the personal server. The operation must be in a cancellable state
38452
+ * (typically `starting` or `processing`). Not all operations support
38453
+ * cancellation, and cancellation may not be immediate. The server will
38454
+ * attempt to stop the operation and update its status to `canceled`.
38455
+ *
38456
+ * **Cancellation Behavior:**
38457
+ * - Operations in `succeeded` or `failed` states cannot be canceled
38458
+ * - Some long-running operations may take time to respond to cancellation
38459
+ * - Always verify cancellation by polling the operation status afterward
38460
+ *
38461
+ * @param operationId - The unique identifier of the operation to cancel,
38462
+ * obtained from `createOperation()` response
38463
+ * @returns Promise that resolves when the cancellation request is accepted
38464
+ * @throws {PersonalServerError} When the operation cannot be canceled or doesn't exist.
38465
+ * Check operation status - it may already be completed or failed.
38466
+ * @throws {NetworkError} When unable to reach the personal server API.
38467
+ * Verify server URL and network connectivity.
38468
+ * @example
38469
+ * ```typescript
38470
+ * // Start a long-running operation
38471
+ * const operation = await vana.server.createOperation({
38472
+ * permissionId: 123
38473
+ * });
38474
+ *
38475
+ * // Cancel if needed
38476
+ * try {
38477
+ * await vana.server.cancelOperation(operation.id);
38478
+ * console.log("Cancellation requested");
38479
+ *
38480
+ * // Verify cancellation
38481
+ * const status = await vana.server.getOperation(operation.id);
38482
+ * if (status.status === "canceled") {
38483
+ * console.log("Operation successfully canceled");
38484
+ * }
38485
+ * } catch (error) {
38486
+ * console.error("Failed to cancel:", error);
38487
+ * }
38488
+ * ```
38489
+ */
38027
38490
  async cancelOperation(operationId) {
38028
38491
  try {
38029
38492
  const response = await fetch(
@@ -38327,7 +38790,8 @@ var ProtocolController = class {
38327
38790
  * are actually deployed on the current network.
38328
38791
  * @param contractName - The name of the Vana contract to retrieve (use const assertion for full typing)
38329
38792
  * @returns An object containing the contract's address and fully typed ABI
38330
- * @throws {ContractNotFoundError} When the contract is not deployed on the current chain
38793
+ * @throws {ContractNotFoundError} When the contract is not deployed on the current chain.
38794
+ * Verify contract name spelling and check current network with `getChainId()`.
38331
38795
  * @example
38332
38796
  * ```typescript
38333
38797
  * // Get contract info with full type inference
@@ -38948,6 +39412,7 @@ var GoogleDriveStorage = class {
38948
39412
  };
38949
39413
 
38950
39414
  // src/storage/providers/ipfs.ts
39415
+ init_crypto_utils();
38951
39416
  var IpfsStorage = class _IpfsStorage {
38952
39417
  constructor(config) {
38953
39418
  this.config = config;
@@ -38987,7 +39452,7 @@ var IpfsStorage = class _IpfsStorage {
38987
39452
  * ```
38988
39453
  */
38989
39454
  static forInfura(credentials) {
38990
- const auth = btoa(`${credentials.projectId}:${credentials.projectSecret}`);
39455
+ const auth = toBase64(`${credentials.projectId}:${credentials.projectSecret}`);
38991
39456
  return new _IpfsStorage({
38992
39457
  apiEndpoint: "https://ipfs.infura.io:5001/api/v0/add",
38993
39458
  gatewayUrl: "https://ipfs.infura.io/ipfs",
@@ -39511,175 +39976,151 @@ var PinataStorage = class {
39511
39976
  }
39512
39977
  };
39513
39978
 
39514
- // src/storage/providers/server-proxy.ts
39515
- var ServerProxyStorage = class {
39516
- constructor(config) {
39517
- this.config = config;
39518
- if (!config.uploadUrl) {
39519
- throw new StorageError(
39520
- "Upload URL is required",
39521
- "MISSING_UPLOAD_URL",
39522
- "server-proxy"
39523
- );
39524
- }
39525
- if (!config.downloadUrl) {
39526
- throw new StorageError(
39527
- "Download URL is required",
39528
- "MISSING_DOWNLOAD_URL",
39529
- "server-proxy"
39979
+ // src/storage/providers/callback-storage.ts
39980
+ var CallbackStorage = class {
39981
+ constructor(callbacks) {
39982
+ this.callbacks = callbacks;
39983
+ if (!callbacks.upload || !callbacks.download) {
39984
+ throw new Error(
39985
+ "CallbackStorage requires both upload and download callbacks"
39530
39986
  );
39531
39987
  }
39532
39988
  }
39533
39989
  /**
39534
- * Uploads a file through your server endpoint
39535
- *
39536
- * @remarks
39537
- * This method sends the file to your configured upload endpoint via FormData.
39538
- * Your server is responsible for handling the actual storage implementation
39539
- * and must return a JSON response with `success: true` and an `identifier` field.
39540
- *
39541
- * @param file - The file to upload
39542
- * @param filename - Optional custom filename
39543
- * @returns Promise that resolves to the server-provided identifier
39544
- * @throws {StorageError} When the upload fails or server returns an error
39990
+ * Upload a file using the provided callback
39545
39991
  *
39546
- * @example
39547
- * ```typescript
39548
- * const identifier = await serverStorage.upload(fileBlob, { name: "report.pdf" });
39549
- * console.log("File uploaded with identifier:", identifier);
39550
- * ```
39992
+ * @param file - The blob to upload
39993
+ * @param filename - Optional filename for the upload
39994
+ * @returns The upload result with URL and metadata
39551
39995
  */
39552
39996
  async upload(file, filename) {
39553
39997
  try {
39554
- const formData = new FormData();
39555
- formData.append("file", file);
39556
- if (filename) {
39557
- formData.append("name", filename);
39558
- }
39559
- const response = await fetch(this.config.uploadUrl, {
39560
- method: "POST",
39561
- body: formData
39562
- });
39563
- if (!response.ok) {
39564
- const _errorText = await response.text();
39565
- throw new StorageError(
39566
- `Server upload failed: ${response.status} ${response.statusText}`,
39567
- "UPLOAD_FAILED",
39568
- "server-proxy"
39569
- );
39570
- }
39571
- const result = await response.json();
39572
- if (!result.success) {
39573
- throw new StorageError(
39574
- `Upload failed: ${result.error || "Unknown server error"}`,
39575
- "UPLOAD_FAILED",
39576
- "server-proxy"
39577
- );
39578
- }
39579
- if (!result.identifier) {
39998
+ const result = await this.callbacks.upload(file, filename);
39999
+ if (!result.url || result.url.trim() === "") {
39580
40000
  throw new StorageError(
39581
- "Server upload succeeded but no identifier returned",
39582
- "NO_IDENTIFIER_RETURNED",
39583
- "server-proxy"
40001
+ "Upload callback returned invalid result: missing or empty url",
40002
+ "INVALID_UPLOAD_RESULT",
40003
+ "callback-storage"
39584
40004
  );
39585
40005
  }
39586
- return {
39587
- url: result.url || result.identifier,
39588
- size: file.size,
39589
- contentType: file.type || "application/octet-stream"
39590
- };
40006
+ return result;
39591
40007
  } catch (error) {
39592
40008
  if (error instanceof StorageError) {
39593
40009
  throw error;
39594
40010
  }
39595
40011
  throw new StorageError(
39596
- `Server proxy upload error: ${error instanceof Error ? error.message : "Unknown error"}`,
40012
+ `Upload failed: ${error instanceof Error ? error.message : String(error)}`,
39597
40013
  "UPLOAD_ERROR",
39598
- "server-proxy"
40014
+ "callback-storage",
40015
+ { cause: error instanceof Error ? error : void 0 }
39599
40016
  );
39600
40017
  }
39601
40018
  }
39602
40019
  /**
39603
- * Downloads a file through your server endpoint
40020
+ * Download a file using the provided callback
39604
40021
  *
39605
- * @remarks
39606
- * This method sends the identifier to your configured download endpoint via POST request.
39607
- * Your server is responsible for retrieving the file from your storage backend
39608
- * and returning the file content as a blob response.
39609
- *
39610
- * @param url - The server-provided URL or identifier from upload
39611
- * @returns Promise that resolves to the downloaded file content
39612
- * @throws {StorageError} When the download fails or file is not found
39613
- *
39614
- * @example
39615
- * ```typescript
39616
- * const fileBlob = await serverStorage.download("file-123");
39617
- * const url = URL.createObjectURL(fileBlob);
39618
- * ```
40022
+ * @param url - The URL or identifier to download
40023
+ * @returns The downloaded blob
39619
40024
  */
39620
40025
  async download(url) {
39621
40026
  try {
39622
- const identifier = this.extractIdentifierFromUrl(url);
39623
- const response = await fetch(this.config.downloadUrl, {
39624
- method: "POST",
39625
- headers: {
39626
- "Content-Type": "application/json"
39627
- },
39628
- body: JSON.stringify({ identifier })
39629
- });
39630
- if (!response.ok) {
39631
- const _errorText = await response.text();
40027
+ const identifier = this.callbacks.extractIdentifier ? this.callbacks.extractIdentifier(url) : url;
40028
+ const blob = await this.callbacks.download(identifier);
40029
+ if (!(blob instanceof Blob)) {
39632
40030
  throw new StorageError(
39633
- `Server download failed: ${response.status} ${response.statusText}`,
39634
- "DOWNLOAD_FAILED",
39635
- "server-proxy"
40031
+ "Download callback returned invalid result: expected Blob",
40032
+ "INVALID_DOWNLOAD_RESULT",
40033
+ "callback-storage"
39636
40034
  );
39637
40035
  }
39638
- return await response.blob();
40036
+ return blob;
39639
40037
  } catch (error) {
39640
40038
  if (error instanceof StorageError) {
39641
40039
  throw error;
39642
40040
  }
39643
40041
  throw new StorageError(
39644
- `Server proxy download error: ${error instanceof Error ? error.message : "Unknown error"}`,
40042
+ `Download failed: ${error instanceof Error ? error.message : String(error)}`,
39645
40043
  "DOWNLOAD_ERROR",
39646
- "server-proxy"
40044
+ "callback-storage",
40045
+ { cause: error instanceof Error ? error : void 0 }
39647
40046
  );
39648
40047
  }
39649
40048
  }
39650
- async list(_options) {
39651
- throw new StorageError(
39652
- "List operation is not supported by server proxy storage",
39653
- "LIST_NOT_SUPPORTED",
39654
- "server-proxy"
39655
- );
39656
- }
39657
- async delete(_url) {
39658
- throw new StorageError(
39659
- "Delete operation is not supported by server proxy storage",
39660
- "DELETE_NOT_SUPPORTED",
39661
- "server-proxy"
39662
- );
40049
+ /**
40050
+ * List files using the provided callback (if available)
40051
+ *
40052
+ * @param options - Optional list options including filters and pagination
40053
+ * @returns Array of storage files
40054
+ */
40055
+ async list(options) {
40056
+ if (!this.callbacks.list) {
40057
+ throw new StorageError(
40058
+ "List operation not supported - no list callback provided",
40059
+ "NOT_SUPPORTED",
40060
+ "callback-storage"
40061
+ );
40062
+ }
40063
+ try {
40064
+ const result = await this.callbacks.list(options?.namePattern, options);
40065
+ return result.items.map((item, index) => ({
40066
+ id: item.identifier,
40067
+ name: item.identifier.split("/").pop() || `file-${index}`,
40068
+ url: item.identifier,
40069
+ size: item.size || 0,
40070
+ contentType: "application/octet-stream",
40071
+ createdAt: item.lastModified || /* @__PURE__ */ new Date(),
40072
+ metadata: item.metadata
40073
+ }));
40074
+ } catch (error) {
40075
+ throw new StorageError(
40076
+ `List failed: ${error instanceof Error ? error.message : String(error)}`,
40077
+ "LIST_ERROR",
40078
+ "callback-storage",
40079
+ { cause: error instanceof Error ? error : void 0 }
40080
+ );
40081
+ }
39663
40082
  }
39664
40083
  /**
39665
- * Extract identifier from URL or return as-is
40084
+ * Delete a file using the provided callback (if available)
39666
40085
  *
39667
- * @param url - URL or identifier string
39668
- * @returns identifier string
40086
+ * @param url - The URL or identifier to delete
40087
+ * @returns True if deletion succeeded
39669
40088
  */
39670
- extractIdentifierFromUrl(url) {
39671
- return url;
40089
+ async delete(url) {
40090
+ if (!this.callbacks.delete) {
40091
+ throw new StorageError(
40092
+ "Delete operation not supported - no delete callback provided",
40093
+ "NOT_SUPPORTED",
40094
+ "callback-storage"
40095
+ );
40096
+ }
40097
+ try {
40098
+ const identifier = this.callbacks.extractIdentifier ? this.callbacks.extractIdentifier(url) : url;
40099
+ return await this.callbacks.delete(identifier);
40100
+ } catch (error) {
40101
+ throw new StorageError(
40102
+ `Delete failed: ${error instanceof Error ? error.message : String(error)}`,
40103
+ "DELETE_ERROR",
40104
+ "callback-storage",
40105
+ { cause: error instanceof Error ? error : void 0 }
40106
+ );
40107
+ }
39672
40108
  }
40109
+ /**
40110
+ * Get provider configuration
40111
+ *
40112
+ * @returns Provider configuration metadata
40113
+ */
39673
40114
  getConfig() {
39674
40115
  return {
39675
- name: "Server Proxy",
39676
- type: "server-proxy",
40116
+ name: "callback-storage",
40117
+ type: "callback",
39677
40118
  requiresAuth: false,
39678
40119
  features: {
39679
40120
  upload: true,
39680
40121
  download: true,
39681
- list: false,
39682
- delete: false
40122
+ list: !!this.callbacks.list,
40123
+ delete: !!this.callbacks.delete
39683
40124
  }
39684
40125
  };
39685
40126
  }
@@ -40301,15 +40742,35 @@ var VanaCore = class {
40301
40742
  }
40302
40743
  /**
40303
40744
  * Encrypts data using the Vana protocol standard encryption.
40304
- * This method automatically uses the correct platform adapter for the current environment.
40745
+ *
40746
+ * @remarks
40747
+ * This method implements the Vana network's standard encryption protocol using
40748
+ * platform-appropriate cryptographic libraries. It automatically handles different
40749
+ * input types (string or Blob) and produces encrypted output suitable for secure
40750
+ * storage or transmission. The encryption is compatible with the network's
40751
+ * decryption protocols and can be decrypted by authorized parties.
40305
40752
  *
40306
- * @param data The data to encrypt (string or Blob)
40307
- * @param key The key to use as encryption key
40308
- * @returns The encrypted data as Blob
40753
+ * @param data - The data to encrypt (string or Blob)
40754
+ * @param key - The encryption key (typically generated via `generateEncryptionKey`)
40755
+ * @returns The encrypted data as a Blob
40756
+ * @throws {Error} When encryption fails due to invalid key or data format
40309
40757
  * @example
40310
40758
  * ```typescript
40311
- * const encryptionKey = await generateEncryptionKey(walletClient);
40312
- * const encrypted = await vana.encryptBlob("sensitive data", encryptionKey);
40759
+ * import { generateEncryptionKey } from '@opendatalabs/vana-sdk/node';
40760
+ *
40761
+ * // Generate encryption key from wallet signature
40762
+ * const encryptionKey = await generateEncryptionKey(vana.walletClient);
40763
+ *
40764
+ * // Encrypt string data
40765
+ * const sensitiveData = "User's private information";
40766
+ * const encrypted = await vana.encryptBlob(sensitiveData, encryptionKey);
40767
+ *
40768
+ * // Encrypt file data
40769
+ * const fileBlob = new Blob([fileContent], { type: 'application/json' });
40770
+ * const encryptedFile = await vana.encryptBlob(fileBlob, encryptionKey);
40771
+ *
40772
+ * // Store encrypted data safely
40773
+ * await storageProvider.upload(encrypted, 'encrypted-data.bin');
40313
40774
  * ```
40314
40775
  */
40315
40776
  async encryptBlob(data, key) {
@@ -40317,16 +40778,52 @@ var VanaCore = class {
40317
40778
  }
40318
40779
  /**
40319
40780
  * Decrypts data that was encrypted using the Vana protocol.
40320
- * This method automatically uses the correct platform adapter for the current environment.
40781
+ *
40782
+ * @remarks
40783
+ * This method decrypts data that was previously encrypted using the Vana network's
40784
+ * standard encryption protocol. It requires the same wallet signature that was used
40785
+ * for encryption and automatically uses the appropriate platform adapter for
40786
+ * cryptographic operations. The decrypted output maintains the original data format.
40321
40787
  *
40322
- * @param encryptedData The encrypted data (string or Blob)
40323
- * @param walletSignature The wallet signature to use as decryption key
40324
- * @returns The decrypted data as Blob
40788
+ * @param encryptedData - The encrypted data (string or Blob)
40789
+ * @param walletSignature - The wallet signature used as decryption key
40790
+ * @returns The decrypted data as a Blob
40791
+ * @throws {Error} When decryption fails due to invalid signature or corrupted data
40325
40792
  * @example
40326
40793
  * ```typescript
40327
- * const encryptionKey = await generateEncryptionKey(walletClient);
40328
- * const decrypted = await vana.decryptBlob(encryptedData, encryptionKey);
40329
- * const text = await decrypted.text();
40794
+ * import { generateEncryptionKey } from '@opendatalabs/vana-sdk/node';
40795
+ *
40796
+ * // Retrieve encrypted data from storage
40797
+ * const encryptedBlob = await storageProvider.download('encrypted-data.bin');
40798
+ *
40799
+ * // Generate the same key used for encryption
40800
+ * const decryptionKey = await generateEncryptionKey(vana.walletClient);
40801
+ *
40802
+ * // Decrypt the data
40803
+ * const decrypted = await vana.decryptBlob(encryptedBlob, decryptionKey);
40804
+ *
40805
+ * // Convert back to original format
40806
+ * const originalText = await decrypted.text();
40807
+ * const originalJson = JSON.parse(originalText);
40808
+ *
40809
+ * console.log('Decrypted data:', originalJson);
40810
+ * ```
40811
+ *
40812
+ * @example
40813
+ * ```typescript
40814
+ * // Decrypt file downloaded from Vana network
40815
+ * const userFiles = await vana.data.getUserFiles();
40816
+ * const file = userFiles[0];
40817
+ *
40818
+ * // Download encrypted content
40819
+ * const encrypted = await fetch(file.url).then(r => r.blob());
40820
+ *
40821
+ * // Decrypt with user's key
40822
+ * const decryptionKey = await generateEncryptionKey(vana.walletClient);
40823
+ * const decrypted = await vana.decryptBlob(encrypted, decryptionKey);
40824
+ *
40825
+ * // Process original data
40826
+ * const fileContent = await decrypted.arrayBuffer();
40330
40827
  * ```
40331
40828
  */
40332
40829
  async decryptBlob(encryptedData, walletSignature) {
@@ -41243,6 +41740,7 @@ export {
41243
41740
  BaseController,
41244
41741
  BlockchainError,
41245
41742
  BrowserPlatformAdapter,
41743
+ CallbackStorage,
41246
41744
  CircuitBreaker,
41247
41745
  ContractFactory,
41248
41746
  ContractNotFoundError,
@@ -41277,8 +41775,8 @@ export {
41277
41775
  SchemaValidator,
41278
41776
  SerializationError,
41279
41777
  ServerController,
41280
- ServerProxyStorage,
41281
41778
  ServerUrlMismatchError,
41779
+ SignatureCache,
41282
41780
  SignatureError,
41283
41781
  StorageError,
41284
41782
  StorageManager,
@@ -41353,6 +41851,7 @@ export {
41353
41851
  validateGrantFile,
41354
41852
  validateGranteeAccess,
41355
41853
  validateOperationAccess,
41356
- vanaMainnet2 as vanaMainnet
41854
+ vanaMainnet2 as vanaMainnet,
41855
+ withSignatureCache
41357
41856
  };
41358
41857
  //# sourceMappingURL=index.node.js.map