@opendatalabs/vana-sdk 0.1.0-alpha.b878f1d → 0.1.0-alpha.bae46ec

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.
Files changed (95) hide show
  1. package/dist/controllers/base.cjs +0 -33
  2. package/dist/controllers/base.cjs.map +1 -1
  3. package/dist/controllers/base.d.ts +0 -10
  4. package/dist/controllers/base.js +0 -33
  5. package/dist/controllers/base.js.map +1 -1
  6. package/dist/controllers/data.cjs +161 -206
  7. package/dist/controllers/data.cjs.map +1 -1
  8. package/dist/controllers/data.d.ts +11 -14
  9. package/dist/controllers/data.js +164 -219
  10. package/dist/controllers/data.js.map +1 -1
  11. package/dist/controllers/permissions.cjs +177 -284
  12. package/dist/controllers/permissions.cjs.map +1 -1
  13. package/dist/controllers/permissions.d.ts +13 -25
  14. package/dist/controllers/permissions.js +177 -284
  15. package/dist/controllers/permissions.js.map +1 -1
  16. package/dist/controllers/schemas.cjs +1 -11
  17. package/dist/controllers/schemas.cjs.map +1 -1
  18. package/dist/controllers/schemas.d.ts +0 -2
  19. package/dist/controllers/schemas.js +1 -11
  20. package/dist/controllers/schemas.js.map +1 -1
  21. package/dist/core.cjs +1 -4
  22. package/dist/core.cjs.map +1 -1
  23. package/dist/core.d.ts +1 -2
  24. package/dist/core.js +1 -4
  25. package/dist/core.js.map +1 -1
  26. package/dist/generated/subgraph.cjs +31 -796
  27. package/dist/generated/subgraph.cjs.map +1 -1
  28. package/dist/generated/subgraph.d.ts +0 -135
  29. package/dist/generated/subgraph.js +31 -791
  30. package/dist/generated/subgraph.js.map +1 -1
  31. package/dist/index.node.cjs +0 -2
  32. package/dist/index.node.cjs.map +1 -1
  33. package/dist/index.node.d.ts +4 -27
  34. package/dist/index.node.js +0 -2
  35. package/dist/index.node.js.map +1 -1
  36. package/dist/server/relayerHandler.cjs +74 -188
  37. package/dist/server/relayerHandler.cjs.map +1 -1
  38. package/dist/server/relayerHandler.d.ts +2 -3
  39. package/dist/server/relayerHandler.js +74 -188
  40. package/dist/server/relayerHandler.js.map +1 -1
  41. package/dist/types/config.cjs.map +1 -1
  42. package/dist/types/config.d.ts +0 -32
  43. package/dist/types/config.js.map +1 -1
  44. package/dist/types/controller-context.cjs.map +1 -1
  45. package/dist/types/controller-context.d.ts +1 -3
  46. package/dist/types/data.cjs.map +1 -1
  47. package/dist/types/data.d.ts +4 -0
  48. package/dist/types/generics.cjs.map +1 -1
  49. package/dist/types/generics.d.ts +1 -1
  50. package/dist/types/index.cjs.map +1 -1
  51. package/dist/types/index.d.ts +2 -4
  52. package/dist/types/index.js.map +1 -1
  53. package/dist/types/operations.cjs.map +1 -1
  54. package/dist/types/operations.d.ts +0 -33
  55. package/dist/types/operations.js.map +1 -1
  56. package/dist/types/permissions.cjs.map +1 -1
  57. package/dist/types/permissions.d.ts +0 -2
  58. package/dist/types/relayer.cjs.map +1 -1
  59. package/dist/types/relayer.d.ts +9 -28
  60. package/dist/types/utils.cjs.map +1 -1
  61. package/dist/types/utils.d.ts +49 -0
  62. package/dist/utils/ipfs.cjs +4 -2
  63. package/dist/utils/ipfs.cjs.map +1 -1
  64. package/dist/utils/ipfs.d.ts +1 -1
  65. package/dist/utils/ipfs.js +4 -2
  66. package/dist/utils/ipfs.js.map +1 -1
  67. package/package.json +1 -3
  68. package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +0 -7
  69. package/dist/types/options.cjs +0 -17
  70. package/dist/types/options.cjs.map +0 -1
  71. package/dist/types/options.d.ts +0 -213
  72. package/dist/types/options.js +0 -1
  73. package/dist/types/options.js.map +0 -1
  74. package/dist/utils/__tests__/subgraphConsistency.test.d.ts +0 -4
  75. package/dist/utils/__tests__/subgraphPagination.test.d.ts +0 -4
  76. package/dist/utils/chainQuery.cjs +0 -107
  77. package/dist/utils/chainQuery.cjs.map +0 -1
  78. package/dist/utils/chainQuery.d.ts +0 -31
  79. package/dist/utils/chainQuery.js +0 -82
  80. package/dist/utils/chainQuery.js.map +0 -1
  81. package/dist/utils/subgraphConsistency.cjs +0 -184
  82. package/dist/utils/subgraphConsistency.cjs.map +0 -1
  83. package/dist/utils/subgraphConsistency.d.ts +0 -65
  84. package/dist/utils/subgraphConsistency.js +0 -155
  85. package/dist/utils/subgraphConsistency.js.map +0 -1
  86. package/dist/utils/subgraphMetaCache.cjs +0 -101
  87. package/dist/utils/subgraphMetaCache.cjs.map +0 -1
  88. package/dist/utils/subgraphMetaCache.d.ts +0 -56
  89. package/dist/utils/subgraphMetaCache.js +0 -76
  90. package/dist/utils/subgraphMetaCache.js.map +0 -1
  91. package/dist/utils/subgraphPagination.cjs +0 -104
  92. package/dist/utils/subgraphPagination.cjs.map +0 -1
  93. package/dist/utils/subgraphPagination.d.ts +0 -78
  94. package/dist/utils/subgraphPagination.js +0 -78
  95. package/dist/utils/subgraphPagination.js.map +0 -1
@@ -37,9 +37,6 @@ var import_addresses = require("../config/addresses");
37
37
  var import_abi = require("../generated/abi");
38
38
  var import_subgraph = require("../generated/subgraph");
39
39
  var import_graphql = require("graphql");
40
- var import_subgraphConsistency = require("../utils/subgraphConsistency");
41
- var import_subgraphPagination = require("../utils/subgraphPagination");
42
- var import_chainQuery = require("../utils/chainQuery");
43
40
  var import_encryption = require("../utils/encryption");
44
41
  var import_schemaValidation = require("../utils/schemaValidation");
45
42
  var import_multicall = require("../utils/multicall");
@@ -143,7 +140,7 @@ class DataController extends import_base.BaseController {
143
140
  if (response.type === "error") {
144
141
  throw new Error(response.error);
145
142
  }
146
- if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
143
+ if (response.type !== "direct" || !("fileId" in response.result)) {
147
144
  throw new Error("Invalid response from relayer");
148
145
  }
149
146
  result = response.result;
@@ -438,91 +435,67 @@ class DataController extends import_base.BaseController {
438
435
  * });
439
436
  * ```
440
437
  */
441
- async getUserFiles(params, options) {
438
+ async getUserFiles(params) {
442
439
  const { owner, subgraphUrl } = params;
443
- let dataSource = options?.source === "chain" ? "chain" : "subgraph";
444
- if (options?.source === "auto" || !options?.source && options?.minBlock) {
445
- const endpoint2 = subgraphUrl ?? this.context.subgraphUrl;
446
- const currentBlock = await this.context.publicClient.getBlockNumber();
447
- let subgraphBlock;
448
- if (endpoint2) {
449
- try {
450
- const meta = await (0, import_subgraphConsistency.fetchSubgraphMeta)(endpoint2);
451
- subgraphBlock = meta.blockNumber;
452
- } catch {
453
- subgraphBlock = void 0;
454
- }
455
- }
456
- dataSource = (0, import_chainQuery.determineDataSource)(
457
- options?.source,
458
- options?.minBlock,
459
- currentBlock,
460
- subgraphBlock
461
- );
462
- }
463
- if (dataSource === "chain") {
464
- const publicClient = this.context.publicClient;
465
- const chainId = await publicClient.getChainId();
466
- const contractAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
467
- const files = await (0, import_chainQuery.getUserFilesFromChain)(
468
- publicClient,
469
- contractAddress,
470
- owner,
471
- options?.minBlock ? BigInt(options.minBlock) : void 0
472
- );
473
- const limit = options?.fetchAll ? files.length : options?.limit ?? 100;
474
- const offset = options?.offset ?? 0;
475
- return files.slice(offset, offset + limit);
476
- }
477
440
  const endpoint = subgraphUrl ?? this.context.subgraphUrl;
478
441
  if (!endpoint) {
479
442
  throw new Error(
480
443
  "subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
481
444
  );
482
445
  }
483
- if (options?.minBlock || options?.waitForSync) {
484
- await (0, import_subgraphConsistency.checkSubgraphConsistency)(endpoint, options);
485
- }
486
446
  try {
487
- const orderByMap = {
488
- id: "id",
489
- addedAtBlock: "addedAtBlock",
490
- addedAtTimestamp: "addedAtTimestamp",
491
- url: "url",
492
- schemaId: "schemaId"
493
- };
494
- const allFiles = await (0, import_subgraphPagination.executePaginatedQuery)({
495
- endpoint,
496
- document: import_subgraph.GetUserFilesPaginatedDocument,
497
- baseVariables: {
498
- userId: owner.toLowerCase(),
499
- // Subgraph requires lowercase addresses
500
- orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
501
- options?.orderBy,
502
- orderByMap,
503
- "addedAtBlock"
504
- ),
505
- orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
506
- options?.orderDirection,
507
- "asc",
508
- "desc"
509
- )
447
+ const response = await fetch(endpoint, {
448
+ method: "POST",
449
+ headers: {
450
+ "Content-Type": "application/json"
510
451
  },
511
- options,
512
- extractItems: (data) => data?.user?.files,
513
- transformItem: (file) => ({
514
- id: parseInt(file.id),
452
+ body: JSON.stringify({
453
+ query: (0, import_graphql.print)(import_subgraph.GetUserFilesDocument),
454
+ variables: {
455
+ userId: owner.toLowerCase()
456
+ // Subgraph requires lowercase addresses
457
+ }
458
+ })
459
+ });
460
+ if (!response.ok) {
461
+ throw new Error(
462
+ `Subgraph request failed: ${response.status} ${response.statusText}`
463
+ );
464
+ }
465
+ const result = await response.json();
466
+ if (result.errors) {
467
+ throw new Error(
468
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
469
+ );
470
+ }
471
+ const user = result.data?.user;
472
+ if (!user?.files?.length) {
473
+ console.warn("No files found for user:", owner);
474
+ return [];
475
+ }
476
+ const fileMap = /* @__PURE__ */ new Map();
477
+ user.files.forEach((file) => {
478
+ const fileId = parseInt(file.id);
479
+ const userFile = {
480
+ id: fileId,
515
481
  url: file.url,
516
482
  ownerAddress: file.owner.id,
517
483
  addedAtBlock: BigInt(file.addedAtBlock),
518
484
  schemaId: parseInt(file.schemaId),
519
485
  addedAtTimestamp: BigInt(file.addedAtTimestamp),
520
486
  transactionHash: file.transactionHash
521
- })
487
+ };
488
+ const existing = fileMap.get(fileId);
489
+ if (!existing || userFile.addedAtTimestamp && existing.addedAtTimestamp && userFile.addedAtTimestamp > existing.addedAtTimestamp) {
490
+ fileMap.set(fileId, userFile);
491
+ }
522
492
  });
523
- if (allFiles.length > 0) {
493
+ const userFiles = Array.from(fileMap.values()).sort(
494
+ (a, b) => Number((b.addedAtTimestamp ?? 0n) - (a.addedAtTimestamp ?? 0n))
495
+ );
496
+ if (userFiles.length > 0) {
524
497
  try {
525
- const fileIds = allFiles.map((f) => f.id);
498
+ const fileIds = userFiles.map((f) => f.id);
526
499
  let proofMap;
527
500
  try {
528
501
  proofMap = await this._fetchProofsFromSubgraph(fileIds, endpoint);
@@ -533,7 +506,7 @@ class DataController extends import_base.BaseController {
533
506
  );
534
507
  proofMap = await this._fetchProofsFromChain(fileIds);
535
508
  }
536
- for (const file of allFiles) {
509
+ for (const file of userFiles) {
537
510
  const dlpIds = proofMap.get(file.id);
538
511
  if (dlpIds && dlpIds.length > 0) {
539
512
  file.dlpIds = dlpIds;
@@ -543,7 +516,7 @@ class DataController extends import_base.BaseController {
543
516
  console.warn("Failed to fetch proof data for files:", error);
544
517
  }
545
518
  }
546
- return allFiles;
519
+ return userFiles;
547
520
  } catch (error) {
548
521
  console.error("Failed to fetch user files from subgraph:", error);
549
522
  throw new Error(
@@ -669,9 +642,6 @@ class DataController extends import_base.BaseController {
669
642
  */
670
643
  async getDLP(dlpId, options = {}) {
671
644
  const subgraphUrl = options.subgraphUrl ?? this.context.subgraphUrl;
672
- if (subgraphUrl && (options.minBlock || options.waitForSync)) {
673
- await (0, import_subgraphConsistency.checkSubgraphConsistency)(subgraphUrl, options);
674
- }
675
645
  if (subgraphUrl) {
676
646
  try {
677
647
  const response = await fetch(subgraphUrl, {
@@ -890,33 +860,21 @@ class DataController extends import_base.BaseController {
890
860
  * @returns Promise resolving to an array of permission objects
891
861
  * @throws Error if both subgraph and RPC queries fail
892
862
  */
893
- async getUserPermissions(params, options) {
863
+ async getUserPermissions(params) {
894
864
  const { user, subgraphUrl } = params;
895
865
  const endpoint = subgraphUrl ?? this.context.subgraphUrl;
896
- if (endpoint && (options?.minBlock || options?.waitForSync)) {
897
- await (0, import_subgraphConsistency.checkSubgraphConsistency)(endpoint, options);
898
- }
899
866
  if (endpoint) {
900
867
  try {
901
- const permissions = await this._getUserPermissionsViaSubgraph(
902
- {
903
- user,
904
- subgraphUrl: endpoint
905
- },
906
- options
907
- );
868
+ const permissions = await this._getUserPermissionsViaSubgraph({
869
+ user,
870
+ subgraphUrl: endpoint
871
+ });
908
872
  return permissions;
909
873
  } catch (error) {
910
874
  console.warn("Subgraph query failed, falling back to RPC:", error);
911
875
  }
912
876
  }
913
- const allPermissions = await this._getUserPermissionsViaRpc({ user });
914
- if (options && !options.fetchAll) {
915
- const limit = options.limit ?? 100;
916
- const offset = options.offset ?? 0;
917
- return allPermissions.slice(offset, offset + limit);
918
- }
919
- return allPermissions;
877
+ return await this._getUserPermissionsViaRpc({ user });
920
878
  }
921
879
  /**
922
880
  * Internal method: Query user permissions via subgraph
@@ -926,48 +884,46 @@ class DataController extends import_base.BaseController {
926
884
  * @param params.subgraphUrl - The subgraph URL endpoint to query
927
885
  * @returns Promise resolving to an array of permission objects
928
886
  */
929
- async _getUserPermissionsViaSubgraph(params, options) {
887
+ async _getUserPermissionsViaSubgraph(params) {
930
888
  const { user, subgraphUrl } = params;
931
889
  try {
932
- const orderByMap = {
933
- id: "id",
934
- addedAtBlock: "addedAtBlock",
935
- addedAtTimestamp: "addedAtTimestamp",
936
- grant: "grant",
937
- nonce: "nonce",
938
- startBlock: "startBlock",
939
- endBlock: "endBlock"
940
- };
941
- const permissions = await (0, import_subgraphPagination.executePaginatedQuery)({
942
- endpoint: subgraphUrl,
943
- document: import_subgraph.GetUserPermissionsPaginatedDocument,
944
- baseVariables: {
945
- userId: user.toLowerCase(),
946
- orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
947
- options?.orderBy,
948
- orderByMap,
949
- "addedAtTimestamp"
950
- ),
951
- orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
952
- options?.orderDirection,
953
- "desc",
954
- "asc"
955
- )
890
+ const response = await fetch(subgraphUrl, {
891
+ method: "POST",
892
+ headers: {
893
+ "Content-Type": "application/json"
956
894
  },
957
- options,
958
- extractItems: (data) => data?.user?.permissions,
959
- transformItem: (permission) => ({
960
- id: permission.id,
961
- grant: permission.grant,
962
- nonce: BigInt(permission.nonce),
963
- signature: permission.signature,
964
- addedAtBlock: BigInt(permission.addedAtBlock),
965
- addedAtTimestamp: BigInt(permission.addedAtTimestamp),
966
- transactionHash: permission.transactionHash,
967
- user
895
+ body: JSON.stringify({
896
+ query: (0, import_graphql.print)(import_subgraph.GetUserPermissionsDocument),
897
+ variables: {
898
+ userId: user.toLowerCase()
899
+ }
968
900
  })
969
901
  });
970
- return permissions;
902
+ if (!response.ok) {
903
+ throw new Error(
904
+ `Subgraph request failed: ${response.status} ${response.statusText}`
905
+ );
906
+ }
907
+ const result = await response.json();
908
+ if (result.errors) {
909
+ throw new Error(
910
+ `Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
911
+ );
912
+ }
913
+ const userData = result.data?.user;
914
+ if (!userData?.permissions?.length) {
915
+ return [];
916
+ }
917
+ return userData.permissions.map((permission) => ({
918
+ id: permission.id,
919
+ grant: permission.grant,
920
+ nonce: BigInt(permission.nonce),
921
+ signature: permission.signature,
922
+ addedAtBlock: BigInt(permission.addedAtBlock),
923
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp),
924
+ transactionHash: permission.transactionHash,
925
+ user
926
+ })).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
971
927
  } catch (error) {
972
928
  console.error("Failed to query user permissions from subgraph:", error);
973
929
  throw error;
@@ -1100,28 +1056,20 @@ class DataController extends import_base.BaseController {
1100
1056
  * });
1101
1057
  * ```
1102
1058
  */
1103
- async getUserTrustedServers(params, options) {
1104
- const { user } = params;
1059
+ async getUserTrustedServers(params) {
1060
+ const { user, limit = 50, offset = 0 } = params;
1105
1061
  const subgraphUrl = params.subgraphUrl ?? this.context.subgraphUrl;
1106
- if (subgraphUrl && (options?.minBlock || options?.waitForSync)) {
1107
- await (0, import_subgraphConsistency.checkSubgraphConsistency)(subgraphUrl, options);
1108
- }
1109
1062
  if (subgraphUrl) {
1110
1063
  try {
1111
- const servers = await this._getUserTrustedServersViaSubgraph(
1112
- {
1113
- user,
1114
- subgraphUrl
1115
- },
1116
- options
1117
- );
1118
- return servers;
1064
+ const servers = await this._getUserTrustedServersViaSubgraph({
1065
+ user,
1066
+ subgraphUrl
1067
+ });
1068
+ return limit ? servers.slice(offset, offset + limit) : servers;
1119
1069
  } catch (error) {
1120
1070
  console.warn("Subgraph query failed, falling back to RPC:", error);
1121
1071
  }
1122
1072
  }
1123
- const limit = options?.fetchAll ? Number.MAX_SAFE_INTEGER : options?.limit ?? 100;
1124
- const offset = options?.offset ?? 0;
1125
1073
  const rpcResult = await this._getUserTrustedServersViaRpc({
1126
1074
  user,
1127
1075
  limit,
@@ -1137,7 +1085,7 @@ class DataController extends import_base.BaseController {
1137
1085
  * @param params.subgraphUrl - The subgraph URL endpoint to query
1138
1086
  * @returns Promise resolving to an array of trusted server objects
1139
1087
  */
1140
- async _getUserTrustedServersViaSubgraph(params, options) {
1088
+ async _getUserTrustedServersViaSubgraph(params) {
1141
1089
  const { user, subgraphUrl } = params;
1142
1090
  const graphqlEndpoint = subgraphUrl;
1143
1091
  if (!graphqlEndpoint) {
@@ -1146,46 +1094,42 @@ class DataController extends import_base.BaseController {
1146
1094
  );
1147
1095
  }
1148
1096
  try {
1149
- const orderByMap = {
1150
- id: "id",
1151
- trustedAt: "trustedAt",
1152
- trustedAtBlock: "trustedAtBlock",
1153
- server: "server",
1154
- user: "user"
1155
- };
1156
- const serverTrusts = await (0, import_subgraphPagination.executePaginatedQuery)({
1157
- endpoint: graphqlEndpoint,
1158
- document: import_subgraph.GetUserTrustedServersPaginatedDocument,
1159
- baseVariables: {
1160
- userId: user.toLowerCase(),
1161
- // Subgraph requires lowercase addresses
1162
- orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
1163
- options?.orderBy,
1164
- orderByMap,
1165
- "trustedAtBlock"
1166
- ),
1167
- orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
1168
- options?.orderDirection,
1169
- "desc",
1170
- "asc"
1171
- )
1097
+ const response = await fetch(graphqlEndpoint, {
1098
+ method: "POST",
1099
+ headers: {
1100
+ "Content-Type": "application/json"
1172
1101
  },
1173
- options,
1174
- extractItems: (data) => {
1175
- const trusts = data?.user?.serverTrusts ?? [];
1176
- return trusts.filter((trust) => !trust.untrustedAtBlock);
1177
- },
1178
- transformItem: (trust) => ({
1179
- id: trust.server.id,
1180
- serverAddress: trust.server.serverAddress,
1181
- serverUrl: trust.server.url,
1182
- trustedAt: BigInt(trust.trustedAt),
1183
- user,
1184
- name: ""
1185
- // Not available in new schema, will be empty
1102
+ body: JSON.stringify({
1103
+ query: (0, import_graphql.print)(import_subgraph.GetUserTrustedServersDocument),
1104
+ variables: {
1105
+ userId: user.toLowerCase()
1106
+ // Subgraph requires lowercase addresses
1107
+ }
1186
1108
  })
1187
1109
  });
1188
- return serverTrusts;
1110
+ if (!response.ok) {
1111
+ throw new Error(
1112
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1113
+ );
1114
+ }
1115
+ const result = await response.json();
1116
+ if (result.errors) {
1117
+ throw new Error(
1118
+ `Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
1119
+ );
1120
+ }
1121
+ if (!result.data?.user) {
1122
+ return [];
1123
+ }
1124
+ return (result.data.user.serverTrusts ?? []).filter((trust) => !trust.untrustedAtBlock).map((trust) => ({
1125
+ id: trust.server.id,
1126
+ serverAddress: trust.server.serverAddress,
1127
+ serverUrl: trust.server.url,
1128
+ trustedAt: BigInt(trust.trustedAt),
1129
+ user,
1130
+ name: ""
1131
+ // Not available in new schema, will be empty
1132
+ }));
1189
1133
  } catch (error) {
1190
1134
  console.error("Failed to query trusted servers from subgraph:", error);
1191
1135
  throw error;
@@ -1429,7 +1373,7 @@ class DataController extends import_base.BaseController {
1429
1373
  * console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
1430
1374
  * ```
1431
1375
  */
1432
- async registerFileWithSchema(url, schemaId, options) {
1376
+ async registerFileWithSchema(url, schemaId) {
1433
1377
  this.assertWallet();
1434
1378
  try {
1435
1379
  const chainId = this.context.publicClient.chain?.id;
@@ -1447,8 +1391,7 @@ class DataController extends import_base.BaseController {
1447
1391
  functionName: "addFileWithSchema",
1448
1392
  args: [url, BigInt(schemaId)],
1449
1393
  account,
1450
- chain: this.context.walletClient.chain ?? null,
1451
- ...this.spreadTransactionOptions(options)
1394
+ chain: this.context.walletClient.chain ?? null
1452
1395
  });
1453
1396
  const { tx } = await import("../utils/transactionHelpers");
1454
1397
  return tx({
@@ -1505,7 +1448,15 @@ class DataController extends import_base.BaseController {
1505
1448
  args: [url, ownerAddress, permissions],
1506
1449
  account,
1507
1450
  chain: this.context.walletClient.chain ?? null,
1508
- ...this.spreadTransactionOptions(options)
1451
+ ...options && {
1452
+ gas: options.gasLimit,
1453
+ nonce: options.nonce,
1454
+ // Use EIP-1559 gas pricing if available, otherwise legacy
1455
+ ...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
1456
+ maxFeePerGas: options.maxFeePerGas,
1457
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
1458
+ } : options.gasPrice ? { gasPrice: options.gasPrice } : {}
1459
+ }
1509
1460
  });
1510
1461
  const { tx } = await import("../utils/transactionHelpers");
1511
1462
  return tx({
@@ -1560,7 +1511,7 @@ class DataController extends import_base.BaseController {
1560
1511
  * console.log(`File ${result.fileId} registered in tx ${result.hash}`);
1561
1512
  * ```
1562
1513
  */
1563
- async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1514
+ async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1564
1515
  this.assertWallet();
1565
1516
  try {
1566
1517
  let encryptedPermissions = [];
@@ -1594,8 +1545,7 @@ class DataController extends import_base.BaseController {
1594
1545
  url,
1595
1546
  ownerAddress,
1596
1547
  encryptedPermissions,
1597
- schemaId,
1598
- options
1548
+ schemaId
1599
1549
  );
1600
1550
  } catch (error) {
1601
1551
  console.error("Failed to add file with permissions and schema:", error);
@@ -1660,7 +1610,15 @@ class DataController extends import_base.BaseController {
1660
1610
  args: [url, ownerAddress, permissions, BigInt(schemaId)],
1661
1611
  account,
1662
1612
  chain: this.context.walletClient.chain ?? null,
1663
- ...this.spreadTransactionOptions(options)
1613
+ ...options && {
1614
+ gas: options.gasLimit,
1615
+ nonce: options.nonce,
1616
+ // Use EIP-1559 gas pricing if available, otherwise legacy
1617
+ ...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
1618
+ maxFeePerGas: options.maxFeePerGas,
1619
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
1620
+ } : options.gasPrice ? { gasPrice: options.gasPrice } : {}
1621
+ }
1664
1622
  });
1665
1623
  const { tx } = await import("../utils/transactionHelpers");
1666
1624
  return tx({
@@ -1708,7 +1666,7 @@ class DataController extends import_base.BaseController {
1708
1666
  * console.log(`Refiner ${result.refinerId} created`);
1709
1667
  * ```
1710
1668
  */
1711
- async addRefiner(params, options) {
1669
+ async addRefiner(params) {
1712
1670
  this.assertWallet();
1713
1671
  try {
1714
1672
  const chainId = this.context.publicClient.chain?.id;
@@ -1734,8 +1692,7 @@ class DataController extends import_base.BaseController {
1734
1692
  params.refinementInstructionUrl
1735
1693
  ],
1736
1694
  account,
1737
- chain: this.context.walletClient.chain ?? null,
1738
- ...this.spreadTransactionOptions(options)
1695
+ chain: this.context.walletClient.chain ?? null
1739
1696
  });
1740
1697
  const { tx } = await import("../utils/transactionHelpers");
1741
1698
  const txResult = tx({
@@ -1935,7 +1892,7 @@ class DataController extends import_base.BaseController {
1935
1892
  * console.log(`Schema updated in tx ${result.transactionHash}`);
1936
1893
  * ```
1937
1894
  */
1938
- async updateSchemaId(params, options) {
1895
+ async updateSchemaId(params) {
1939
1896
  this.assertWallet();
1940
1897
  try {
1941
1898
  const chainId = this.context.publicClient.chain?.id;
@@ -1955,8 +1912,7 @@ class DataController extends import_base.BaseController {
1955
1912
  functionName: "updateSchemaId",
1956
1913
  args: [BigInt(params.refinerId), BigInt(params.newSchemaId)],
1957
1914
  account,
1958
- chain: this.context.walletClient.chain ?? null,
1959
- ...this.spreadTransactionOptions(options)
1915
+ chain: this.context.walletClient.chain ?? null
1960
1916
  });
1961
1917
  await this.context.publicClient.waitForTransactionReceipt({ hash });
1962
1918
  return {
@@ -2025,7 +1981,7 @@ class DataController extends import_base.BaseController {
2025
1981
  if (response.type === "error") {
2026
1982
  throw new Error(response.error);
2027
1983
  }
2028
- if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
1984
+ if (response.type !== "direct" || !("fileId" in response.result)) {
2029
1985
  throw new Error("Invalid response from relayer");
2030
1986
  }
2031
1987
  const result = response.result;
@@ -2117,7 +2073,7 @@ class DataController extends import_base.BaseController {
2117
2073
  );
2118
2074
  }
2119
2075
  }
2120
- const finalFilename = filename ?? (encrypt ? `upload-${Date.now()}.enc` : `upload-${Date.now()}.dat`);
2076
+ const finalFilename = filename ?? `upload-${Date.now()}.dat`;
2121
2077
  const uploadResult = await this.context.storageManager.upload(
2122
2078
  finalBlob,
2123
2079
  finalFilename,
@@ -2162,10 +2118,10 @@ class DataController extends import_base.BaseController {
2162
2118
  * console.log(`Transaction: ${result.transactionHash}`);
2163
2119
  * ```
2164
2120
  */
2165
- async addPermissionToFile(params, options) {
2121
+ async addPermissionToFile(params) {
2166
2122
  this.assertWallet();
2167
2123
  const { fileId, account, publicKey } = params;
2168
- return await this.submitFilePermission(fileId, account, publicKey, options);
2124
+ return await this.submitFilePermission(fileId, account, publicKey);
2169
2125
  }
2170
2126
  /**
2171
2127
  * Submits a file permission transaction to the blockchain.
@@ -2195,7 +2151,7 @@ class DataController extends import_base.BaseController {
2195
2151
  * console.log(`Permission granted with ID: ${result.permissionId}`);
2196
2152
  * ```
2197
2153
  */
2198
- async submitFilePermission(fileId, account, publicKey, options) {
2154
+ async submitFilePermission(fileId, account, publicKey) {
2199
2155
  this.assertWallet();
2200
2156
  try {
2201
2157
  const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
@@ -2222,8 +2178,7 @@ class DataController extends import_base.BaseController {
2222
2178
  functionName: "addFilePermission",
2223
2179
  args: [BigInt(fileId), account, encryptedKey],
2224
2180
  account: walletAccount,
2225
- chain: this.context.walletClient.chain ?? null,
2226
- ...this.spreadTransactionOptions(options)
2181
+ chain: this.context.walletClient.chain ?? null
2227
2182
  });
2228
2183
  const { tx } = await import("../utils/transactionHelpers");
2229
2184
  return tx({