@opendatalabs/vana-sdk 0.1.0-alpha.7ee7635 → 0.1.0-alpha.8117ac2

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 (700) hide show
  1. package/dist/__tests__/waitForTransactionEvents.test.d.ts +1 -0
  2. package/dist/browser.cjs.map +1 -1
  3. package/dist/browser.d.ts +36 -2
  4. package/dist/browser.js.map +1 -1
  5. package/dist/chains/definitions.cjs +9 -6
  6. package/dist/chains/definitions.cjs.map +1 -1
  7. package/dist/chains/definitions.d.ts +9 -11
  8. package/dist/chains/definitions.js +9 -6
  9. package/dist/chains/definitions.js.map +1 -1
  10. package/dist/chains/index.cjs.map +1 -1
  11. package/dist/chains/index.d.ts +34 -2
  12. package/dist/chains/index.js.map +1 -1
  13. package/dist/chains.browser.d.ts +8 -2
  14. package/dist/chains.d.ts +8 -2
  15. package/dist/chains.node.d.ts +8 -2
  16. package/dist/config/addresses.d.ts +8 -45
  17. package/dist/config/chains.cjs.map +1 -1
  18. package/dist/config/chains.d.ts +108 -13
  19. package/dist/config/chains.js.map +1 -1
  20. package/dist/config/default-services.cjs +60 -0
  21. package/dist/config/default-services.cjs.map +1 -0
  22. package/dist/config/default-services.d.ts +46 -0
  23. package/dist/config/default-services.js +33 -0
  24. package/dist/config/default-services.js.map +1 -0
  25. package/dist/config/default-services.test.d.ts +1 -0
  26. package/dist/config/features.d.ts +1 -3
  27. package/dist/config/tests/addresses.test.d.ts +1 -0
  28. package/dist/contracts/contractController.cjs +3 -3
  29. package/dist/contracts/contractController.cjs.map +1 -1
  30. package/dist/contracts/contractController.d.ts +77 -59
  31. package/dist/contracts/contractController.js +4 -7
  32. package/dist/contracts/contractController.js.map +1 -1
  33. package/dist/contracts/tests/contractController.test.d.ts +1 -0
  34. package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
  35. package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
  36. package/dist/controllers/base.cjs +116 -0
  37. package/dist/controllers/base.cjs.map +1 -0
  38. package/dist/controllers/base.d.ts +94 -0
  39. package/dist/controllers/base.js +92 -0
  40. package/dist/controllers/base.js.map +1 -0
  41. package/dist/controllers/data-error-handling.test.d.ts +1 -0
  42. package/dist/controllers/data.cjs +699 -373
  43. package/dist/controllers/data.cjs.map +1 -1
  44. package/dist/controllers/data.d.ts +368 -228
  45. package/dist/controllers/data.js +712 -376
  46. package/dist/controllers/data.js.map +1 -1
  47. package/dist/controllers/permissions.cjs +688 -489
  48. package/dist/controllers/permissions.cjs.map +1 -1
  49. package/dist/controllers/permissions.d.ts +98 -165
  50. package/dist/controllers/permissions.js +688 -489
  51. package/dist/controllers/permissions.js.map +1 -1
  52. package/dist/controllers/protocol.cjs +15 -11
  53. package/dist/controllers/protocol.cjs.map +1 -1
  54. package/dist/controllers/protocol.d.ts +34 -84
  55. package/dist/controllers/protocol.js +15 -14
  56. package/dist/controllers/protocol.js.map +1 -1
  57. package/dist/controllers/schemas.cjs +57 -52
  58. package/dist/controllers/schemas.cjs.map +1 -1
  59. package/dist/controllers/schemas.d.ts +55 -61
  60. package/dist/controllers/schemas.js +57 -52
  61. package/dist/controllers/schemas.js.map +1 -1
  62. package/dist/controllers/server-additional.test.d.ts +1 -0
  63. package/dist/controllers/server.cjs +32 -25
  64. package/dist/controllers/server.cjs.map +1 -1
  65. package/dist/controllers/server.d.ts +53 -58
  66. package/dist/controllers/server.js +32 -25
  67. package/dist/controllers/server.js.map +1 -1
  68. package/dist/core/apiClient.cjs +68 -15
  69. package/dist/core/apiClient.cjs.map +1 -1
  70. package/dist/core/apiClient.d.ts +137 -16
  71. package/dist/core/apiClient.js +72 -22
  72. package/dist/core/apiClient.js.map +1 -1
  73. package/dist/core/client.cjs +7 -7
  74. package/dist/core/client.cjs.map +1 -1
  75. package/dist/core/client.d.ts +6 -9
  76. package/dist/core/client.js +7 -7
  77. package/dist/core/client.js.map +1 -1
  78. package/dist/core/core.test.d.ts +1 -0
  79. package/dist/core/generics.cjs +41 -12
  80. package/dist/core/generics.cjs.map +1 -1
  81. package/dist/core/generics.d.ts +104 -19
  82. package/dist/core/generics.js +52 -32
  83. package/dist/core/generics.js.map +1 -1
  84. package/dist/core/tests/apiClient.test.d.ts +1 -0
  85. package/dist/core/tests/client.test.d.ts +1 -0
  86. package/dist/core/tests/generics.test.d.ts +1 -0
  87. package/dist/core.cjs +115 -47
  88. package/dist/core.cjs.map +1 -1
  89. package/dist/core.d.ts +24 -74
  90. package/dist/core.js +137 -72
  91. package/dist/core.js.map +1 -1
  92. package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
  93. package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
  94. package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
  95. package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
  96. package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
  97. package/dist/crypto/ecies/__tests__/test-vectors.d.ts +2 -4
  98. package/dist/crypto/ecies/base.cjs +4 -3
  99. package/dist/crypto/ecies/base.cjs.map +1 -1
  100. package/dist/crypto/ecies/base.d.ts +2 -5
  101. package/dist/crypto/ecies/base.js +12 -15
  102. package/dist/crypto/ecies/base.js.map +1 -1
  103. package/dist/crypto/ecies/browser.cjs +2 -1
  104. package/dist/crypto/ecies/browser.cjs.map +1 -1
  105. package/dist/crypto/ecies/browser.d.ts +2 -7
  106. package/dist/crypto/ecies/browser.js +2 -1
  107. package/dist/crypto/ecies/browser.js.map +1 -1
  108. package/dist/crypto/ecies/constants.d.ts +7 -9
  109. package/dist/crypto/ecies/index.d.ts +8 -1
  110. package/dist/crypto/ecies/interface.cjs +4 -5
  111. package/dist/crypto/ecies/interface.cjs.map +1 -1
  112. package/dist/crypto/ecies/interface.d.ts +9 -11
  113. package/dist/crypto/ecies/interface.js +4 -5
  114. package/dist/crypto/ecies/interface.js.map +1 -1
  115. package/dist/crypto/ecies/node.cjs +3 -2
  116. package/dist/crypto/ecies/node.cjs.map +1 -1
  117. package/dist/crypto/ecies/node.d.ts +2 -7
  118. package/dist/crypto/ecies/node.js +11 -16
  119. package/dist/crypto/ecies/node.js.map +1 -1
  120. package/dist/crypto/ecies/utils.cjs +2 -41
  121. package/dist/crypto/ecies/utils.cjs.map +1 -1
  122. package/dist/crypto/ecies/utils.d.ts +3 -40
  123. package/dist/crypto/ecies/utils.js +1 -35
  124. package/dist/crypto/ecies/utils.js.map +1 -1
  125. package/dist/crypto/services/WalletKeyEncryptionService.cjs +2 -2
  126. package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -1
  127. package/dist/crypto/services/WalletKeyEncryptionService.d.ts +3 -7
  128. package/dist/crypto/services/WalletKeyEncryptionService.js +5 -9
  129. package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -1
  130. package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
  131. package/dist/diagnostics.d.ts +1 -3
  132. package/dist/diagnostics.test.d.ts +1 -0
  133. package/dist/errors.cjs +16 -0
  134. package/dist/errors.cjs.map +1 -1
  135. package/dist/errors.d.ts +53 -15
  136. package/dist/errors.js +18 -6
  137. package/dist/errors.js.map +1 -1
  138. package/dist/generated/abi/ComputeEngineImplementation.d.ts +2 -3
  139. package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -1
  140. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +2 -3
  141. package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -1
  142. package/dist/generated/abi/DATFactoryImplementation.d.ts +2 -3
  143. package/dist/generated/abi/DATImplementation.d.ts +2 -3
  144. package/dist/generated/abi/DATPausableImplementation.d.ts +2 -3
  145. package/dist/generated/abi/DATVotesImplementation.d.ts +2 -3
  146. package/dist/generated/abi/DLPPerformanceImplementation.d.ts +2 -3
  147. package/dist/generated/abi/DLPRegistryImplementation.d.ts +2 -3
  148. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +2 -3
  149. package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +2 -3
  150. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +2 -3
  151. package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +2 -3
  152. package/dist/generated/abi/DLPRootImplementation.d.ts +1 -3
  153. package/dist/generated/abi/DLPTreasuryImplementation.d.ts +2 -3
  154. package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +1 -3
  155. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +2 -3
  156. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -1
  157. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +2 -3
  158. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -1
  159. package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -1
  160. package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +2 -3
  161. package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -1
  162. package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +2 -3
  163. package/dist/generated/abi/DataRegistryImplementation.d.ts +2 -3
  164. package/dist/generated/abi/QueryEngineImplementation.d.ts +2 -3
  165. package/dist/generated/abi/SwapHelperImplementation.d.ts +2 -3
  166. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +2 -3
  167. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +2 -3
  168. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +2 -3
  169. package/dist/generated/abi/TeePoolImplementation.d.ts +2 -3
  170. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +2 -3
  171. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +2 -3
  172. package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +2 -3
  173. package/dist/generated/abi/VanaEpochImplementation.d.ts +2 -3
  174. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +2 -3
  175. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +2 -3
  176. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +2 -3
  177. package/dist/generated/abi/index.d.ts +37 -39
  178. package/dist/generated/event-types.d.ts +9 -10
  179. package/dist/generated/eventRegistry.d.ts +3 -7
  180. package/dist/generated/server/server-exports.d.ts +19 -21
  181. package/dist/generated/server/server.cjs.map +1 -1
  182. package/dist/generated/server/server.d.ts +113 -87
  183. package/dist/generated/subgraph.cjs +797 -32
  184. package/dist/generated/subgraph.cjs.map +1 -1
  185. package/dist/generated/subgraph.d.ts +464 -332
  186. package/dist/generated/subgraph.js +792 -32
  187. package/dist/generated/subgraph.js.map +1 -1
  188. package/dist/index.browser.d.ts +47 -96
  189. package/dist/index.browser.js +12 -0
  190. package/dist/index.browser.js.map +1 -1
  191. package/dist/index.cjs +3 -1
  192. package/dist/index.cjs.map +1 -1
  193. package/dist/index.d.ts +0 -2
  194. package/dist/index.js +3 -1
  195. package/dist/index.js.map +1 -1
  196. package/dist/index.node.cjs +14 -3
  197. package/dist/index.node.cjs.map +1 -1
  198. package/dist/index.node.d.ts +203 -87
  199. package/dist/index.node.js +14 -2
  200. package/dist/index.node.js.map +1 -1
  201. package/dist/node.cjs.map +1 -1
  202. package/dist/node.d.ts +42 -2
  203. package/dist/node.js.map +1 -1
  204. package/dist/platform/browser-only.d.ts +5 -8
  205. package/dist/platform/browser-only.test.d.ts +1 -0
  206. package/dist/platform/browser-safe.d.ts +6 -9
  207. package/dist/platform/browser-safe.test.d.ts +1 -0
  208. package/dist/platform/browser.cjs +167 -8
  209. package/dist/platform/browser.cjs.map +1 -1
  210. package/dist/platform/browser.d.ts +235 -18
  211. package/dist/platform/browser.js +179 -29
  212. package/dist/platform/browser.js.map +1 -1
  213. package/dist/platform/browser.test.d.ts +1 -0
  214. package/dist/platform/index.d.ts +11 -5
  215. package/dist/platform/interface.cjs.map +1 -1
  216. package/dist/platform/interface.d.ts +289 -98
  217. package/dist/platform/node.cjs +163 -2
  218. package/dist/platform/node.cjs.map +1 -1
  219. package/dist/platform/node.d.ts +72 -13
  220. package/dist/platform/node.js +175 -21
  221. package/dist/platform/node.js.map +1 -1
  222. package/dist/platform/ports/openpgp-port.cjs +74 -0
  223. package/dist/platform/ports/openpgp-port.cjs.map +1 -0
  224. package/dist/platform/ports/openpgp-port.d.ts +13 -0
  225. package/dist/platform/ports/openpgp-port.js +59 -0
  226. package/dist/platform/ports/openpgp-port.js.map +1 -0
  227. package/dist/platform/ports/pgp-port.cjs +17 -0
  228. package/dist/platform/ports/pgp-port.cjs.map +1 -0
  229. package/dist/platform/ports/pgp-port.d.ts +35 -0
  230. package/dist/platform/ports/pgp-port.js +1 -0
  231. package/dist/platform/ports/pgp-port.js.map +1 -0
  232. package/dist/platform/shared/error-utils.d.ts +2 -4
  233. package/dist/platform/shared/pgp-utils.cjs +2 -2
  234. package/dist/platform/shared/pgp-utils.cjs.map +1 -1
  235. package/dist/platform/shared/pgp-utils.d.ts +3 -5
  236. package/dist/platform/shared/pgp-utils.js +2 -2
  237. package/dist/platform/shared/pgp-utils.js.map +1 -1
  238. package/dist/platform/shared/stream-utils.d.ts +1 -3
  239. package/dist/platform/utils.d.ts +6 -10
  240. package/dist/platform/utils.test.d.ts +1 -0
  241. package/dist/platform.browser.d.ts +9 -4
  242. package/dist/platform.d.ts +11 -5
  243. package/dist/platform.node.d.ts +10 -5
  244. package/dist/server/relayerHandler.cjs +337 -0
  245. package/dist/server/relayerHandler.cjs.map +1 -0
  246. package/dist/server/relayerHandler.d.ts +38 -0
  247. package/dist/server/relayerHandler.js +313 -0
  248. package/dist/server/relayerHandler.js.map +1 -0
  249. package/dist/storage/index.d.ts +56 -10
  250. package/dist/storage/manager.cjs +110 -27
  251. package/dist/storage/manager.cjs.map +1 -1
  252. package/dist/storage/manager.d.ts +121 -30
  253. package/dist/storage/manager.js +113 -37
  254. package/dist/storage/manager.js.map +1 -1
  255. package/dist/storage/providers/callback-storage.cjs +89 -18
  256. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  257. package/dist/storage/providers/callback-storage.d.ts +111 -28
  258. package/dist/storage/providers/callback-storage.js +89 -18
  259. package/dist/storage/providers/callback-storage.js.map +1 -1
  260. package/dist/storage/providers/google-drive.cjs +2 -2
  261. package/dist/storage/providers/google-drive.cjs.map +1 -1
  262. package/dist/storage/providers/google-drive.d.ts +3 -7
  263. package/dist/storage/providers/google-drive.js +4 -7
  264. package/dist/storage/providers/google-drive.js.map +1 -1
  265. package/dist/storage/providers/google-drive.test.d.ts +1 -0
  266. package/dist/storage/providers/ipfs.cjs +5 -5
  267. package/dist/storage/providers/ipfs.cjs.map +1 -1
  268. package/dist/storage/providers/ipfs.d.ts +3 -6
  269. package/dist/storage/providers/ipfs.js +7 -10
  270. package/dist/storage/providers/ipfs.js.map +1 -1
  271. package/dist/storage/providers/pinata.cjs +6 -6
  272. package/dist/storage/providers/pinata.cjs.map +1 -1
  273. package/dist/storage/providers/pinata.d.ts +17 -22
  274. package/dist/storage/providers/pinata.js +8 -11
  275. package/dist/storage/providers/pinata.js.map +1 -1
  276. package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
  277. package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
  278. package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
  279. package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
  280. package/dist/storage/tests/storageManager.test.d.ts +1 -0
  281. package/dist/tests/abi.test.d.ts +1 -0
  282. package/dist/tests/chains-definitions.test.d.ts +1 -0
  283. package/dist/tests/core-encryption.test.d.ts +1 -0
  284. package/dist/tests/core-extended.test.d.ts +1 -0
  285. package/dist/tests/core-generics-coverage.test.d.ts +1 -0
  286. package/dist/tests/coverage-boost.test.d.ts +1 -0
  287. package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
  288. package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
  289. package/dist/tests/data-additional-methods.test.d.ts +1 -0
  290. package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
  291. package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
  292. package/dist/tests/data-relayer.test.d.ts +1 -0
  293. package/dist/tests/data-schema-validation.test.d.ts +1 -0
  294. package/dist/tests/data-simple-methods.test.d.ts +1 -0
  295. package/dist/tests/data.test.d.ts +1 -0
  296. package/dist/tests/demo-integration.test.d.ts +1 -0
  297. package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
  298. package/dist/tests/download-relayer.test.d.ts +1 -0
  299. package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
  300. package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
  301. package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
  302. package/dist/tests/encryption-coverage.test.d.ts +1 -0
  303. package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
  304. package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
  305. package/dist/tests/errors-coverage.test.d.ts +1 -0
  306. package/dist/tests/errors.test.d.ts +1 -0
  307. package/dist/tests/factories/mockFactory.d.ts +316 -0
  308. package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
  309. package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
  310. package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
  311. package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
  312. package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
  313. package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
  314. package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
  315. package/dist/tests/helper-methods.test.d.ts +1 -0
  316. package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
  317. package/dist/tests/helpers/typedMocks.d.ts +64 -0
  318. package/dist/tests/index-browser.test.d.ts +1 -0
  319. package/dist/tests/index-node.test.d.ts +1 -0
  320. package/dist/tests/index.test.d.ts +1 -0
  321. package/dist/tests/mocks/platformAdapter.d.ts +12 -0
  322. package/dist/tests/new-permissions-methods.test.d.ts +1 -0
  323. package/dist/tests/no-buffer-browser.test.d.ts +1 -0
  324. package/dist/tests/permissions-grantee.test.d.ts +1 -0
  325. package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
  326. package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
  327. package/dist/tests/permissions-server-files.test.d.ts +1 -0
  328. package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
  329. package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
  330. package/dist/tests/permissions.test.d.ts +1 -0
  331. package/dist/tests/personal.test.d.ts +1 -0
  332. package/dist/tests/platform-browser.test.d.ts +1 -0
  333. package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
  334. package/dist/tests/platform-crypto.test.d.ts +1 -0
  335. package/dist/tests/platform-index.test.d.ts +1 -0
  336. package/dist/tests/platform-node.test.d.ts +1 -0
  337. package/dist/tests/platform-shared-utils.test.d.ts +1 -0
  338. package/dist/tests/platform-updated.test.d.ts +1 -0
  339. package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
  340. package/dist/tests/protocol.test.d.ts +1 -0
  341. package/dist/tests/read-only-mode.test.d.ts +1 -0
  342. package/dist/tests/relayer-integration.test.d.ts +1 -0
  343. package/dist/tests/relayer-unified.test.d.ts +1 -0
  344. package/dist/tests/schemas.test.d.ts +1 -0
  345. package/dist/tests/server-relayer-handler.test.d.ts +1 -0
  346. package/dist/tests/setup.d.ts +7 -0
  347. package/dist/tests/signatureFormatter.test.d.ts +1 -0
  348. package/dist/tests/trusted-server-queries.test.d.ts +1 -0
  349. package/dist/tests/typedDataConverter.test.d.ts +1 -0
  350. package/dist/tests/types-contracts.test.d.ts +1 -0
  351. package/dist/tests/types-data.test.d.ts +1 -0
  352. package/dist/tests/types-external-apis.test.d.ts +1 -0
  353. package/dist/tests/types-generics.test.d.ts +1 -0
  354. package/dist/tests/types-permissions.test.d.ts +1 -0
  355. package/dist/tests/types-upload-params.test.d.ts +1 -0
  356. package/dist/tests/types.test.d.ts +1 -0
  357. package/dist/tests/utils-formatters.test.d.ts +1 -0
  358. package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
  359. package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
  360. package/dist/tests/utils-grantFiles.test.d.ts +1 -0
  361. package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
  362. package/dist/tests/utils-grants.test.d.ts +1 -0
  363. package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
  364. package/dist/tests/utils-ipfs.test.d.ts +4 -0
  365. package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
  366. package/dist/tests/vana.test.d.ts +1 -0
  367. package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
  368. package/dist/types/blockchain.cjs.map +1 -1
  369. package/dist/types/blockchain.d.ts +46 -13
  370. package/dist/types/chains-additional.test.d.ts +1 -0
  371. package/dist/types/chains.cjs.map +1 -1
  372. package/dist/types/chains.d.ts +80 -16
  373. package/dist/types/chains.js.map +1 -1
  374. package/dist/types/config.cjs +10 -0
  375. package/dist/types/config.cjs.map +1 -1
  376. package/dist/types/config.d.ts +236 -242
  377. package/dist/types/config.js +8 -0
  378. package/dist/types/config.js.map +1 -1
  379. package/dist/types/contracts.cjs.map +1 -1
  380. package/dist/types/contracts.d.ts +79 -18
  381. package/dist/types/controller-context.cjs.map +1 -1
  382. package/dist/types/controller-context.d.ts +17 -21
  383. package/dist/types/data.cjs.map +1 -1
  384. package/dist/types/data.d.ts +111 -49
  385. package/dist/types/external-apis.d.ts +10 -12
  386. package/dist/types/generics.cjs.map +1 -1
  387. package/dist/types/generics.d.ts +116 -48
  388. package/dist/types/index.cjs +5 -4
  389. package/dist/types/index.cjs.map +1 -1
  390. package/dist/types/index.d.ts +47 -22
  391. package/dist/types/index.js +9 -2
  392. package/dist/types/index.js.map +1 -1
  393. package/dist/types/operations.cjs +2 -2
  394. package/dist/types/operations.cjs.map +1 -1
  395. package/dist/types/operations.d.ts +178 -32
  396. package/dist/types/operations.js +2 -2
  397. package/dist/types/operations.js.map +1 -1
  398. package/dist/types/options.cjs +17 -0
  399. package/dist/types/options.cjs.map +1 -0
  400. package/dist/types/options.d.ts +213 -0
  401. package/dist/types/options.js +1 -0
  402. package/dist/types/options.js.map +1 -0
  403. package/dist/types/permissions.cjs.map +1 -1
  404. package/dist/types/permissions.d.ts +72 -78
  405. package/dist/types/personal.cjs.map +1 -1
  406. package/dist/types/personal.d.ts +137 -22
  407. package/dist/types/relayer.cjs.map +1 -1
  408. package/dist/types/relayer.d.ts +293 -50
  409. package/dist/types/storage.cjs.map +1 -1
  410. package/dist/types/storage.d.ts +15 -29
  411. package/dist/types/storage.js +2 -5
  412. package/dist/types/storage.js.map +1 -1
  413. package/dist/types/transactionResults.d.ts +16 -18
  414. package/dist/types/utils.cjs.map +1 -1
  415. package/dist/types/utils.d.ts +20 -68
  416. package/dist/types.d.ts +4 -28
  417. package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
  418. package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
  419. package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
  420. package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
  421. package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
  422. package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
  423. package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
  424. package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
  425. package/dist/utils/blockchain/registry.cjs +2 -2
  426. package/dist/utils/blockchain/registry.cjs.map +1 -1
  427. package/dist/utils/blockchain/registry.d.ts +6 -8
  428. package/dist/utils/blockchain/registry.js +2 -2
  429. package/dist/utils/blockchain/registry.js.map +1 -1
  430. package/dist/utils/blockchain/registry.test.d.ts +1 -0
  431. package/dist/utils/chainQuery.cjs +107 -0
  432. package/dist/utils/chainQuery.cjs.map +1 -0
  433. package/dist/utils/chainQuery.d.ts +31 -0
  434. package/dist/utils/chainQuery.js +82 -0
  435. package/dist/utils/chainQuery.js.map +1 -0
  436. package/dist/utils/crypto-utils.cjs +0 -12
  437. package/dist/utils/crypto-utils.cjs.map +1 -1
  438. package/dist/utils/crypto-utils.d.ts +9 -27
  439. package/dist/utils/crypto-utils.js +0 -11
  440. package/dist/utils/crypto-utils.js.map +1 -1
  441. package/dist/utils/crypto-utils.test.d.ts +1 -0
  442. package/dist/utils/download.cjs +3 -3
  443. package/dist/utils/download.cjs.map +1 -1
  444. package/dist/utils/download.d.ts +13 -14
  445. package/dist/utils/download.js +2 -2
  446. package/dist/utils/download.js.map +1 -1
  447. package/dist/utils/encoding.cjs +1 -1
  448. package/dist/utils/encoding.cjs.map +1 -1
  449. package/dist/utils/encoding.d.ts +4 -6
  450. package/dist/utils/encoding.js +1 -1
  451. package/dist/utils/encoding.js.map +1 -1
  452. package/dist/utils/encoding.test.d.ts +1 -0
  453. package/dist/utils/encryption.cjs +16 -10
  454. package/dist/utils/encryption.cjs.map +1 -1
  455. package/dist/utils/encryption.d.ts +13 -17
  456. package/dist/utils/encryption.js +16 -10
  457. package/dist/utils/encryption.js.map +1 -1
  458. package/dist/utils/formatters.cjs +4 -2
  459. package/dist/utils/formatters.cjs.map +1 -1
  460. package/dist/utils/formatters.d.ts +4 -6
  461. package/dist/utils/formatters.js +4 -2
  462. package/dist/utils/formatters.js.map +1 -1
  463. package/dist/utils/grantFiles.cjs +7 -4
  464. package/dist/utils/grantFiles.cjs.map +1 -1
  465. package/dist/utils/grantFiles.d.ts +16 -30
  466. package/dist/utils/grantFiles.js +7 -4
  467. package/dist/utils/grantFiles.js.map +1 -1
  468. package/dist/utils/grantValidation.cjs +1 -1
  469. package/dist/utils/grantValidation.cjs.map +1 -1
  470. package/dist/utils/grantValidation.d.ts +109 -33
  471. package/dist/utils/grantValidation.js +1 -1
  472. package/dist/utils/grantValidation.js.map +1 -1
  473. package/dist/utils/grants.cjs +1 -1
  474. package/dist/utils/grants.cjs.map +1 -1
  475. package/dist/utils/grants.d.ts +101 -23
  476. package/dist/utils/grants.js +1 -1
  477. package/dist/utils/grants.js.map +1 -1
  478. package/dist/utils/ipfs.cjs +2 -4
  479. package/dist/utils/ipfs.cjs.map +1 -1
  480. package/dist/utils/ipfs.d.ts +8 -10
  481. package/dist/utils/ipfs.js +2 -4
  482. package/dist/utils/ipfs.js.map +1 -1
  483. package/dist/utils/lazy-import.cjs +4 -6
  484. package/dist/utils/lazy-import.cjs.map +1 -1
  485. package/dist/utils/lazy-import.d.ts +33 -10
  486. package/dist/utils/lazy-import.js +4 -6
  487. package/dist/utils/lazy-import.js.map +1 -1
  488. package/dist/utils/multicall.cjs +4 -2
  489. package/dist/utils/multicall.cjs.map +1 -1
  490. package/dist/utils/multicall.d.ts +5 -8
  491. package/dist/utils/multicall.js +4 -2
  492. package/dist/utils/multicall.js.map +1 -1
  493. package/dist/utils/parseTransactionPojo.cjs.map +1 -1
  494. package/dist/utils/parseTransactionPojo.d.ts +4 -10
  495. package/dist/utils/parseTransactionPojo.js.map +1 -1
  496. package/dist/utils/schemaValidation.cjs +5 -5
  497. package/dist/utils/schemaValidation.cjs.map +1 -1
  498. package/dist/utils/schemaValidation.d.ts +8 -12
  499. package/dist/utils/schemaValidation.js +7 -10
  500. package/dist/utils/schemaValidation.js.map +1 -1
  501. package/dist/utils/signatureCache.cjs +9 -4
  502. package/dist/utils/signatureCache.cjs.map +1 -1
  503. package/dist/utils/signatureCache.d.ts +53 -15
  504. package/dist/utils/signatureCache.js +12 -10
  505. package/dist/utils/signatureCache.js.map +1 -1
  506. package/dist/utils/signatureFormatter.cjs +6 -9
  507. package/dist/utils/signatureFormatter.cjs.map +1 -1
  508. package/dist/utils/signatureFormatter.d.ts +2 -5
  509. package/dist/utils/signatureFormatter.js +6 -9
  510. package/dist/utils/signatureFormatter.js.map +1 -1
  511. package/dist/utils/subgraphConsistency.cjs +184 -0
  512. package/dist/utils/subgraphConsistency.cjs.map +1 -0
  513. package/dist/utils/subgraphConsistency.d.ts +65 -0
  514. package/dist/utils/subgraphConsistency.js +155 -0
  515. package/dist/utils/subgraphConsistency.js.map +1 -0
  516. package/dist/utils/subgraphMetaCache.cjs +101 -0
  517. package/dist/utils/subgraphMetaCache.cjs.map +1 -0
  518. package/dist/utils/subgraphMetaCache.d.ts +56 -0
  519. package/dist/utils/subgraphMetaCache.js +76 -0
  520. package/dist/utils/subgraphMetaCache.js.map +1 -0
  521. package/dist/utils/subgraphPagination.cjs +104 -0
  522. package/dist/utils/subgraphPagination.cjs.map +1 -0
  523. package/dist/utils/subgraphPagination.d.ts +78 -0
  524. package/dist/utils/subgraphPagination.js +78 -0
  525. package/dist/utils/subgraphPagination.js.map +1 -0
  526. package/dist/utils/tests/multicall.test.d.ts +1 -0
  527. package/dist/utils/transactionHelpers.cjs.map +1 -1
  528. package/dist/utils/transactionHelpers.d.ts +17 -23
  529. package/dist/utils/transactionHelpers.js.map +1 -1
  530. package/dist/utils/typeGuards.cjs +109 -0
  531. package/dist/utils/typeGuards.cjs.map +1 -0
  532. package/dist/utils/typeGuards.d.ts +138 -0
  533. package/dist/utils/typeGuards.js +74 -0
  534. package/dist/utils/typeGuards.js.map +1 -0
  535. package/dist/utils/typedDataConverter.cjs.map +1 -1
  536. package/dist/utils/typedDataConverter.d.ts +42 -9
  537. package/dist/utils/typedDataConverter.js.map +1 -1
  538. package/dist/utils/urlResolver.cjs +8 -1
  539. package/dist/utils/urlResolver.cjs.map +1 -1
  540. package/dist/utils/urlResolver.d.ts +24 -8
  541. package/dist/utils/urlResolver.js +9 -2
  542. package/dist/utils/urlResolver.js.map +1 -1
  543. package/dist/utils/wallet.cjs +63 -0
  544. package/dist/utils/wallet.cjs.map +1 -0
  545. package/dist/utils/wallet.d.ts +94 -0
  546. package/dist/utils/wallet.js +37 -0
  547. package/dist/utils/wallet.js.map +1 -0
  548. package/dist/utils/withEvents.cjs.map +1 -1
  549. package/dist/utils/withEvents.d.ts +5 -12
  550. package/dist/utils/withEvents.js.map +1 -1
  551. package/package.json +24 -16
  552. package/dist/browser.d.cts +0 -2
  553. package/dist/chains/definitions.d.cts +0 -53
  554. package/dist/chains/index.d.cts +0 -2
  555. package/dist/chains.browser.cjs +0 -37
  556. package/dist/chains.browser.cjs.map +0 -1
  557. package/dist/chains.browser.d.cts +0 -2
  558. package/dist/chains.d.cts +0 -2
  559. package/dist/chains.node.d.cts +0 -2
  560. package/dist/config/addresses.d.cts +0 -401
  561. package/dist/config/chains.d.cts +0 -85
  562. package/dist/config/features.d.cts +0 -64
  563. package/dist/contracts/contractController.d.cts +0 -117
  564. package/dist/controllers/data.d.cts +0 -915
  565. package/dist/controllers/permissions.d.cts +0 -1383
  566. package/dist/controllers/protocol.d.cts +0 -188
  567. package/dist/controllers/schemas.d.cts +0 -260
  568. package/dist/controllers/server.d.cts +0 -230
  569. package/dist/core/apiClient.d.cts +0 -165
  570. package/dist/core/client.d.cts +0 -92
  571. package/dist/core/generics.d.cts +0 -120
  572. package/dist/core.d.cts +0 -493
  573. package/dist/crypto/ecies/__tests__/test-vectors.d.cts +0 -40
  574. package/dist/crypto/ecies/base.d.cts +0 -143
  575. package/dist/crypto/ecies/browser.d.cts +0 -48
  576. package/dist/crypto/ecies/constants.d.cts +0 -122
  577. package/dist/crypto/ecies/index.d.cts +0 -1
  578. package/dist/crypto/ecies/interface.d.cts +0 -176
  579. package/dist/crypto/ecies/node.d.cts +0 -50
  580. package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.cts +0 -76
  581. package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.ts +0 -76
  582. package/dist/crypto/ecies/utils.d.cts +0 -67
  583. package/dist/crypto/services/WalletKeyEncryptionService.d.cts +0 -92
  584. package/dist/diagnostics.d.cts +0 -26
  585. package/dist/errors.d.cts +0 -350
  586. package/dist/generated/abi/ComputeEngineImplementation.d.cts +0 -996
  587. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +0 -545
  588. package/dist/generated/abi/DATFactoryImplementation.d.cts +0 -661
  589. package/dist/generated/abi/DATImplementation.d.cts +0 -693
  590. package/dist/generated/abi/DATPausableImplementation.d.cts +0 -1145
  591. package/dist/generated/abi/DATVotesImplementation.d.cts +0 -1095
  592. package/dist/generated/abi/DLPPerformanceImplementation.d.cts +0 -883
  593. package/dist/generated/abi/DLPRegistryImplementation.d.cts +0 -1123
  594. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +0 -452
  595. package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +0 -714
  596. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +0 -452
  597. package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +0 -706
  598. package/dist/generated/abi/DLPRootImplementation.d.cts +0 -1248
  599. package/dist/generated/abi/DLPTreasuryImplementation.d.cts +0 -452
  600. package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +0 -737
  601. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +0 -661
  602. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +0 -989
  603. package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +0 -1086
  604. package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +0 -737
  605. package/dist/generated/abi/DataRegistryImplementation.d.cts +0 -1014
  606. package/dist/generated/abi/QueryEngineImplementation.d.cts +0 -1001
  607. package/dist/generated/abi/SwapHelperImplementation.d.cts +0 -764
  608. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +0 -701
  609. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +0 -701
  610. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +0 -701
  611. package/dist/generated/abi/TeePoolImplementation.d.cts +0 -993
  612. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +0 -701
  613. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +0 -701
  614. package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +0 -993
  615. package/dist/generated/abi/VanaEpochImplementation.d.cts +0 -900
  616. package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +0 -934
  617. package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +0 -693
  618. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +0 -394
  619. package/dist/generated/abi/index.d.cts +0 -26547
  620. package/dist/generated/event-types.d.cts +0 -855
  621. package/dist/generated/eventRegistry.d.cts +0 -18
  622. package/dist/generated/server/server-exports.d.cts +0 -21
  623. package/dist/generated/server/server.d.cts +0 -512
  624. package/dist/generated/subgraph.d.cts +0 -5981
  625. package/dist/index.browser.cjs +0 -151
  626. package/dist/index.browser.cjs.map +0 -1
  627. package/dist/index.browser.d.cts +0 -201
  628. package/dist/index.d.cts +0 -2
  629. package/dist/index.node.d.cts +0 -87
  630. package/dist/node.d.cts +0 -2
  631. package/dist/platform/browser-only.d.cts +0 -25
  632. package/dist/platform/browser-safe.d.cts +0 -32
  633. package/dist/platform/browser.d.cts +0 -74
  634. package/dist/platform/index.d.cts +0 -5
  635. package/dist/platform/interface.d.cts +0 -218
  636. package/dist/platform/node.d.cts +0 -27
  637. package/dist/platform/shared/error-utils.d.cts +0 -25
  638. package/dist/platform/shared/pgp-utils.d.cts +0 -61
  639. package/dist/platform/shared/stream-utils.d.cts +0 -16
  640. package/dist/platform/utils.d.cts +0 -53
  641. package/dist/platform.browser.cjs +0 -41
  642. package/dist/platform.browser.cjs.map +0 -1
  643. package/dist/platform.browser.d.cts +0 -4
  644. package/dist/platform.d.cts +0 -5
  645. package/dist/platform.node.d.cts +0 -5
  646. package/dist/schemas/dataSchema.schema.d.cts +0 -88
  647. package/dist/schemas/dataSchema.schema.d.ts +0 -88
  648. package/dist/schemas/grantFile.schema.d.cts +0 -57
  649. package/dist/schemas/grantFile.schema.d.ts +0 -57
  650. package/dist/server/handler.cjs +0 -101
  651. package/dist/server/handler.cjs.map +0 -1
  652. package/dist/server/handler.d.cts +0 -306
  653. package/dist/server/handler.d.ts +0 -306
  654. package/dist/server/handler.js +0 -77
  655. package/dist/server/handler.js.map +0 -1
  656. package/dist/storage/index.d.cts +0 -10
  657. package/dist/storage/manager.d.cts +0 -150
  658. package/dist/storage/providers/callback-storage.d.cts +0 -100
  659. package/dist/storage/providers/google-drive.d.cts +0 -156
  660. package/dist/storage/providers/ipfs.d.cts +0 -163
  661. package/dist/storage/providers/pinata.d.cts +0 -173
  662. package/dist/types/blockchain.d.cts +0 -52
  663. package/dist/types/chains.d.cts +0 -34
  664. package/dist/types/config.d.cts +0 -726
  665. package/dist/types/contracts.d.cts +0 -68
  666. package/dist/types/controller-context.d.cts +0 -71
  667. package/dist/types/data.d.cts +0 -694
  668. package/dist/types/eccrypto-js.d.d.cts +0 -13
  669. package/dist/types/eccrypto-js.d.d.ts +0 -13
  670. package/dist/types/external-apis.d.cts +0 -186
  671. package/dist/types/generics.d.cts +0 -450
  672. package/dist/types/index.d.cts +0 -22
  673. package/dist/types/operations.d.cts +0 -116
  674. package/dist/types/permissions.d.cts +0 -957
  675. package/dist/types/personal.d.cts +0 -40
  676. package/dist/types/relayer.d.cts +0 -284
  677. package/dist/types/storage.d.cts +0 -131
  678. package/dist/types/transactionResults.d.cts +0 -195
  679. package/dist/types/utils.d.cts +0 -819
  680. package/dist/types.d.cts +0 -54
  681. package/dist/utils/blockchain/registry.d.cts +0 -34
  682. package/dist/utils/crypto-utils.d.cts +0 -118
  683. package/dist/utils/download.d.cts +0 -41
  684. package/dist/utils/encoding.d.cts +0 -54
  685. package/dist/utils/encryption.d.cts +0 -275
  686. package/dist/utils/formatters.d.cts +0 -120
  687. package/dist/utils/grantFiles.d.cts +0 -186
  688. package/dist/utils/grantValidation.d.cts +0 -150
  689. package/dist/utils/grants.d.cts +0 -70
  690. package/dist/utils/ipfs.d.cts +0 -90
  691. package/dist/utils/lazy-import.d.cts +0 -20
  692. package/dist/utils/multicall.d.cts +0 -129
  693. package/dist/utils/parseTransactionPojo.d.cts +0 -37
  694. package/dist/utils/schemaValidation.d.cts +0 -172
  695. package/dist/utils/signatureCache.d.cts +0 -134
  696. package/dist/utils/signatureFormatter.d.cts +0 -39
  697. package/dist/utils/transactionHelpers.d.cts +0 -86
  698. package/dist/utils/typedDataConverter.d.cts +0 -13
  699. package/dist/utils/urlResolver.d.cts +0 -40
  700. package/dist/utils/withEvents.d.cts +0 -63
@@ -1,14 +1,28 @@
1
1
  import { getContract } from "viem";
2
+ import { BaseController } from "./base";
2
3
  import { getContractAddress } from "../config/addresses";
3
4
  import { getAbi } from "../generated/abi";
4
5
  import {
5
- GetUserFilesDocument,
6
+ GetUserFilesPaginatedDocument,
6
7
  GetFileProofsDocument,
7
8
  GetDlpDocument,
8
- GetUserPermissionsDocument,
9
- GetUserTrustedServersDocument
9
+ GetUserPermissionsPaginatedDocument,
10
+ GetUserTrustedServersPaginatedDocument
10
11
  } from "../generated/subgraph";
11
12
  import { print } from "graphql";
13
+ import {
14
+ checkSubgraphConsistency,
15
+ fetchSubgraphMeta
16
+ } from "../utils/subgraphConsistency";
17
+ import {
18
+ executePaginatedQuery,
19
+ mapOrderByToEnum,
20
+ mapOrderDirection
21
+ } from "../utils/subgraphPagination";
22
+ import {
23
+ getUserFilesFromChain,
24
+ determineDataSource
25
+ } from "../utils/chainQuery";
12
26
  import {
13
27
  generateEncryptionKey,
14
28
  decryptBlobWithSignedKey,
@@ -23,11 +37,12 @@ import {
23
37
  fetchAndValidateSchema
24
38
  } from "../utils/schemaValidation";
25
39
  import { gasAwareMulticall } from "../utils/multicall";
26
- class DataController {
40
+ class DataController extends BaseController {
27
41
  constructor(context) {
28
- this.context = context;
42
+ super(context);
29
43
  }
30
44
  async upload(params) {
45
+ this.assertWallet();
31
46
  const {
32
47
  content,
33
48
  filename,
@@ -52,15 +67,28 @@ class DataController {
52
67
  } catch {
53
68
  parsedContent = content;
54
69
  }
70
+ } else if (content instanceof Blob) {
71
+ const text = await content.text();
72
+ try {
73
+ parsedContent = JSON.parse(text);
74
+ } catch {
75
+ parsedContent = text;
76
+ }
55
77
  } else {
56
78
  parsedContent = content;
57
79
  }
58
80
  validateDataAgainstSchema(parsedContent, schema);
59
81
  } catch (error) {
60
82
  isValid = false;
61
- validationErrors = [
62
- error instanceof Error ? error.message : "Schema validation failed"
63
- ];
83
+ if (error instanceof Error) {
84
+ if (typeof error === "object" && "errors" in error && Array.isArray(error.errors)) {
85
+ validationErrors = error.errors;
86
+ } else {
87
+ validationErrors = [error.message];
88
+ }
89
+ } else {
90
+ validationErrors = ["Schema validation failed"];
91
+ }
64
92
  }
65
93
  }
66
94
  const uploadResult = await this.uploadToStorage(
@@ -69,9 +97,10 @@ class DataController {
69
97
  encrypt,
70
98
  providerName
71
99
  );
72
- const userAddress = owner || await this.getUserAddress();
100
+ const userAddress = owner ?? this.context.userAddress;
73
101
  let encryptedPermissions = [];
74
102
  if (permissions.length > 0 && encrypt) {
103
+ this.assertWallet();
75
104
  const userEncryptionKey = await generateEncryptionKey(
76
105
  this.context.walletClient,
77
106
  this.context.platform,
@@ -92,37 +121,45 @@ class DataController {
92
121
  );
93
122
  }
94
123
  let result;
95
- if (this.context.relayerCallbacks?.submitFileAdditionComplete) {
96
- result = await this.context.relayerCallbacks.submitFileAdditionComplete(
97
- {
124
+ if (this.context.relayer) {
125
+ const request = {
126
+ type: "direct",
127
+ operation: "submitFileAdditionComplete",
128
+ params: {
98
129
  url: uploadResult.url,
99
130
  userAddress,
100
131
  permissions: encryptedPermissions,
101
- schemaId: schemaId || 0,
132
+ schemaId: schemaId ?? 0,
102
133
  ownerAddress: owner
103
134
  }
104
- );
105
- } else if (this.context.relayerCallbacks?.submitFileAddition) {
106
- const needsComplexRegistration = schemaId !== void 0 || encryptedPermissions.length > 0;
107
- if (needsComplexRegistration) {
108
- throw new Error(
109
- "The configured relay callback does not support schemas or permissions. Please update your relay server implementation to provide the `submitFileAdditionComplete` callback."
110
- );
135
+ };
136
+ const response = await this.context.relayer(request);
137
+ if (response.type === "error") {
138
+ throw new Error(response.error);
111
139
  }
112
- result = await this.context.relayerCallbacks.submitFileAddition(
113
- uploadResult.url,
114
- userAddress
115
- );
140
+ if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
141
+ throw new Error("Invalid response from relayer");
142
+ }
143
+ result = response.result;
116
144
  } else {
117
- const txResult = await this.addFileWithPermissionsAndSchema(
145
+ const txResult = await this.addFileWithEncryptedPermissionsAndSchema(
118
146
  uploadResult.url,
119
147
  userAddress,
120
148
  encryptedPermissions,
121
- schemaId || 0
149
+ schemaId ?? 0
122
150
  );
151
+ if (!this.context.waitForTransactionEvents) {
152
+ throw new Error(
153
+ "Cannot upload without relay: waitForTransactionEvents not configured"
154
+ );
155
+ }
156
+ const eventResult = await this.context.waitForTransactionEvents(txResult);
157
+ const fileAddedEvent = eventResult.expectedEvents.FileAdded;
158
+ if (!fileAddedEvent) {
159
+ throw new Error("FileAdded event not found in transaction");
160
+ }
123
161
  result = {
124
- fileId: 0,
125
- // Placeholder - actual fileId available after waiting for events
162
+ fileId: Number(fileAddedEvent.fileId),
126
163
  transactionHash: txResult.hash
127
164
  };
128
165
  }
@@ -141,35 +178,110 @@ class DataController {
141
178
  }
142
179
  }
143
180
  /**
144
- * Decrypts a file owned by the user using their wallet signature.
181
+ * Encrypts data using wallet-derived encryption.
145
182
  *
146
183
  * @remarks
147
- * This is the high-level convenience method for decrypting user files, serving as the
148
- * symmetrical counterpart to the `upload` method. It handles the complete decryption
149
- * workflow including key generation, URL protocol detection, content fetching, and
150
- * decryption.
184
+ * This method provides secure, wallet-based encryption for data before uploading
185
+ * to the Vana network. It's the counterpart to decryptFile for preparing data
186
+ * for secure storage.
151
187
  *
152
188
  * The method automatically:
153
- * - Generates the decryption key from the user's wallet signature
154
- * - Determines the appropriate fetch method based on the file URL protocol
155
- * - Fetches the encrypted content from IPFS or standard HTTP URLs
156
- * - Decrypts the content using the generated key
157
- *
158
- * For IPFS URLs, the method uses gateway fallback for improved reliability. For
159
- * standard HTTP URLs, it uses a simple fetch. If you need custom authentication
160
- * headers or specific gateway configurations, use the low-level primitives directly.
161
- *
162
- * @param file - The user file to decrypt (typically from getUserFiles)
163
- * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
164
- * @returns Promise resolving to the decrypted file content as a Blob
165
- * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
166
- * @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
167
- * @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
168
- * @throws {Error} "Access denied" - When file returns 403 (no permission)
169
- * @throws {Error} "File is empty or could not be retrieved" - When file has no content
170
- * @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
171
- * @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
172
- * @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
189
+ * - Generates an encryption key from the user's wallet signature
190
+ * - Converts the input data to a Blob if necessary
191
+ * - Encrypts the data using the generated key
192
+ * - Returns both the encrypted data and the encryption key
193
+ *
194
+ * The encryption key returned can be stored and later used for decryption,
195
+ * or shared with others to grant them decryption access.
196
+ *
197
+ * @param data - The data to encrypt (Blob, string, or object)
198
+ * @param options - Optional encryption configuration
199
+ * @returns Promise resolving to encrypted data and the encryption key used
200
+ * @throws {Error} When wallet is not connected or encryption fails
201
+ * @example
202
+ * ```typescript
203
+ * // Encrypt a string
204
+ * const { encryptedData, encryptionKey } = await vana.data.encryptFile(
205
+ * "My secret data"
206
+ * );
207
+ *
208
+ * // Encrypt JSON with custom MIME type
209
+ * const { encryptedData, encryptionKey } = await vana.data.encryptFile(
210
+ * { name: "Alice", age: 30 },
211
+ * { mimeType: "application/json" }
212
+ * );
213
+ *
214
+ * // With custom encryption seed
215
+ * const { encryptedData, encryptionKey } = await vana.data.encryptFile(
216
+ * "Secret message",
217
+ * { seed: "My custom encryption seed" }
218
+ * );
219
+ *
220
+ * // Upload the encrypted data
221
+ * const result = await vana.data.uploadToStorage(encryptedData);
222
+ * ```
223
+ */
224
+ async encryptFile(data, options) {
225
+ this.assertWallet();
226
+ try {
227
+ const encryptionKey = await generateEncryptionKey(
228
+ this.context.walletClient,
229
+ this.context.platform,
230
+ options?.seed ?? DEFAULT_ENCRYPTION_SEED
231
+ );
232
+ let blob;
233
+ if (data instanceof Blob) {
234
+ blob = data;
235
+ } else if (typeof data === "string") {
236
+ blob = new Blob([data], { type: options?.mimeType ?? "text/plain" });
237
+ } else {
238
+ blob = new Blob([JSON.stringify(data)], {
239
+ type: options?.mimeType ?? "application/json"
240
+ });
241
+ }
242
+ const encryptedData = await encryptBlobWithSignedKey(
243
+ blob,
244
+ encryptionKey,
245
+ this.context.platform
246
+ );
247
+ return {
248
+ encryptedData,
249
+ encryptionKey
250
+ };
251
+ } catch (error) {
252
+ throw new Error(
253
+ `Failed to encrypt file: ${error instanceof Error ? error.message : "Unknown error"}`
254
+ );
255
+ }
256
+ }
257
+ /**
258
+ * Decrypts a file using wallet-derived decryption key.
259
+ *
260
+ * @remarks
261
+ * Counterpart to `upload()` for decrypting user files. Automatically
262
+ * generates decryption key from wallet, fetches encrypted content,
263
+ * and decrypts. Supports IPFS (with gateway fallback) and HTTP URLs.
264
+ *
265
+ * @param file - UserFile object from `getUserFiles()`
266
+ * @param options - Decryption options
267
+ * @param options.seed - Custom encryption seed.
268
+ * Defaults to standard Vana seed.
269
+ *
270
+ * @returns Decrypted content as Blob
271
+ *
272
+ * @throws {Error} No wallet connected.
273
+ * Connect wallet before decrypting.
274
+ * @throws {Error} Network error accessing file.
275
+ * Check CORS settings or server availability.
276
+ * @throws {Error} File not found (404).
277
+ * File no longer available at stored URL.
278
+ * @throws {Error} Access denied (403).
279
+ * No permission to access file.
280
+ * @throws {Error} Invalid file format.
281
+ * File not encrypted with Vana protocol.
282
+ * @throws {Error} Wrong encryption key.
283
+ * Verify seed matches upload or use default.
284
+ *
173
285
  * @example
174
286
  * ```typescript
175
287
  * // Basic file decryption
@@ -195,12 +307,14 @@ class DataController {
195
307
  * fs.writeFileSync('decrypted-file.txt', Buffer.from(buffer));
196
308
  * ```
197
309
  */
198
- async decryptFile(file, encryptionSeed) {
310
+ async decryptFile(file, options) {
311
+ this.assertWallet();
199
312
  try {
313
+ this.assertWallet();
200
314
  const encryptionKey = await generateEncryptionKey(
201
315
  this.context.walletClient,
202
316
  this.context.platform,
203
- encryptionSeed || DEFAULT_ENCRYPTION_SEED
317
+ options?.seed ?? DEFAULT_ENCRYPTION_SEED
204
318
  );
205
319
  let encryptedBlob;
206
320
  try {
@@ -283,99 +397,126 @@ class DataController {
283
397
  }
284
398
  }
285
399
  /**
286
- * Retrieves all data files owned by a specific user address.
400
+ * Retrieves all files owned by a specific user address.
287
401
  *
288
402
  * @remarks
289
- * This method queries the Vana subgraph to find files directly owned by the user.
290
- * It efficiently handles large datasets by using the File entity's owner field
291
- * and returns complete file metadata without additional contract calls.
292
- *
293
- * **Deduplication Behavior:**
294
- * The method automatically deduplicates files by ID, keeping only the latest version
295
- * (highest timestamp) when duplicate file IDs are found. This handles cases where
296
- * the subgraph may contain multiple entries for the same file due to re-indexing
297
- * or blockchain reorganizations.
298
- * @param params - The query parameters object
299
- * @param params.owner - The wallet address of the file owner to query
300
- * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
301
- * @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
302
- * @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
303
- * @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
304
- * @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
305
- * @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
403
+ * Queries the Vana subgraph for files owned by the specified address.
404
+ * Automatically deduplicates by file ID, keeping the latest version
405
+ * when duplicates exist from re-indexing or chain reorganizations.
406
+ * Enriches results with DLP proof data when available.
407
+ *
408
+ * @param params - Query configuration
409
+ * @param params.owner - Wallet address of the file owner
410
+ * @param params.subgraphUrl - Subgraph endpoint override.
411
+ * Defaults to context configuration.
412
+ *
413
+ * @returns Array of UserFile objects sorted by timestamp (newest first)
414
+ *
415
+ * @throws {Error} Subgraph URL not configured.
416
+ * Provide `subgraphUrl` parameter or configure in Vana constructor.
417
+ * @throws {Error} Subgraph request failed.
418
+ * Check network connectivity and subgraph availability.
419
+ * @throws {Error} Subgraph returned errors.
420
+ * Review query parameters and subgraph logs.
421
+ *
306
422
  * @example
307
423
  * ```typescript
308
- * // Query files for a specific user
309
424
  * const files = await vana.data.getUserFiles({
310
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
425
+ * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
311
426
  * });
312
427
  *
313
428
  * files.forEach(file => {
314
- * console.log(`File ${file.id}: ${file.url} (Schema: ${file.schemaId})`);
429
+ * console.log(`File ${file.id}: ${file.url}`);
430
+ * console.log(` Schema: ${file.schemaId}`);
431
+ * console.log(` DLPs: ${file.dlpIds?.join(", ") || "none"}`);
315
432
  * });
316
433
  * ```
317
434
  */
318
- async getUserFiles(params) {
435
+ async getUserFiles(params, options) {
319
436
  const { owner, subgraphUrl } = params;
320
- const endpoint = subgraphUrl || this.context.subgraphUrl;
437
+ let dataSource = options?.source === "chain" ? "chain" : "subgraph";
438
+ if (options?.source === "auto" || !options?.source && options?.minBlock) {
439
+ const endpoint2 = subgraphUrl ?? this.context.subgraphUrl;
440
+ const currentBlock = await this.context.publicClient.getBlockNumber();
441
+ let subgraphBlock;
442
+ if (endpoint2) {
443
+ try {
444
+ const meta = await fetchSubgraphMeta(endpoint2);
445
+ subgraphBlock = meta.blockNumber;
446
+ } catch {
447
+ subgraphBlock = void 0;
448
+ }
449
+ }
450
+ dataSource = determineDataSource(
451
+ options?.source,
452
+ options?.minBlock,
453
+ currentBlock,
454
+ subgraphBlock
455
+ );
456
+ }
457
+ if (dataSource === "chain") {
458
+ const publicClient = this.context.publicClient;
459
+ const chainId = await publicClient.getChainId();
460
+ const contractAddress = getContractAddress(chainId, "DataRegistry");
461
+ const files = await getUserFilesFromChain(
462
+ publicClient,
463
+ contractAddress,
464
+ owner,
465
+ options?.minBlock ? BigInt(options.minBlock) : void 0
466
+ );
467
+ const limit = options?.fetchAll ? files.length : options?.limit ?? 100;
468
+ const offset = options?.offset ?? 0;
469
+ return files.slice(offset, offset + limit);
470
+ }
471
+ const endpoint = subgraphUrl ?? this.context.subgraphUrl;
321
472
  if (!endpoint) {
322
473
  throw new Error(
323
474
  "subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
324
475
  );
325
476
  }
477
+ if (options?.minBlock || options?.waitForSync) {
478
+ await checkSubgraphConsistency(endpoint, options);
479
+ }
326
480
  try {
327
- const response = await fetch(endpoint, {
328
- method: "POST",
329
- headers: {
330
- "Content-Type": "application/json"
481
+ const orderByMap = {
482
+ id: "id",
483
+ addedAtBlock: "addedAtBlock",
484
+ addedAtTimestamp: "addedAtTimestamp",
485
+ url: "url",
486
+ schemaId: "schemaId"
487
+ };
488
+ const allFiles = await executePaginatedQuery({
489
+ endpoint,
490
+ document: GetUserFilesPaginatedDocument,
491
+ baseVariables: {
492
+ userId: owner.toLowerCase(),
493
+ // Subgraph requires lowercase addresses
494
+ orderBy: mapOrderByToEnum(
495
+ options?.orderBy,
496
+ orderByMap,
497
+ "addedAtBlock"
498
+ ),
499
+ orderDirection: mapOrderDirection(
500
+ options?.orderDirection,
501
+ "asc",
502
+ "desc"
503
+ )
331
504
  },
332
- body: JSON.stringify({
333
- query: print(GetUserFilesDocument),
334
- variables: {
335
- userId: owner.toLowerCase()
336
- // Subgraph requires lowercase addresses
337
- }
338
- })
339
- });
340
- if (!response.ok) {
341
- throw new Error(
342
- `Subgraph request failed: ${response.status} ${response.statusText}`
343
- );
344
- }
345
- const result = await response.json();
346
- if (result.errors) {
347
- throw new Error(
348
- `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
349
- );
350
- }
351
- const user = result.data?.user;
352
- if (!user || !user.files?.length) {
353
- console.warn("No files found for user:", owner);
354
- return [];
355
- }
356
- const fileMap = /* @__PURE__ */ new Map();
357
- user.files.forEach((file) => {
358
- const fileId = parseInt(file.id);
359
- const userFile = {
360
- id: fileId,
505
+ options,
506
+ extractItems: (data) => data?.user?.files,
507
+ transformItem: (file) => ({
508
+ id: parseInt(file.id),
361
509
  url: file.url,
362
510
  ownerAddress: file.owner.id,
363
511
  addedAtBlock: BigInt(file.addedAtBlock),
364
512
  schemaId: parseInt(file.schemaId),
365
513
  addedAtTimestamp: BigInt(file.addedAtTimestamp),
366
514
  transactionHash: file.transactionHash
367
- };
368
- const existing = fileMap.get(fileId);
369
- if (!existing || userFile.addedAtTimestamp && existing.addedAtTimestamp && userFile.addedAtTimestamp > existing.addedAtTimestamp) {
370
- fileMap.set(fileId, userFile);
371
- }
515
+ })
372
516
  });
373
- const userFiles = Array.from(fileMap.values()).sort(
374
- (a, b) => Number((b.addedAtTimestamp || 0n) - (a.addedAtTimestamp || 0n))
375
- );
376
- if (userFiles.length > 0) {
517
+ if (allFiles.length > 0) {
377
518
  try {
378
- const fileIds = userFiles.map((f) => f.id);
519
+ const fileIds = allFiles.map((f) => f.id);
379
520
  let proofMap;
380
521
  try {
381
522
  proofMap = await this._fetchProofsFromSubgraph(fileIds, endpoint);
@@ -386,7 +527,7 @@ class DataController {
386
527
  );
387
528
  proofMap = await this._fetchProofsFromChain(fileIds);
388
529
  }
389
- for (const file of userFiles) {
530
+ for (const file of allFiles) {
390
531
  const dlpIds = proofMap.get(file.id);
391
532
  if (dlpIds && dlpIds.length > 0) {
392
533
  file.dlpIds = dlpIds;
@@ -396,7 +537,7 @@ class DataController {
396
537
  console.warn("Failed to fetch proof data for files:", error);
397
538
  }
398
539
  }
399
- return userFiles;
540
+ return allFiles;
400
541
  } catch (error) {
401
542
  console.error("Failed to fetch user files from subgraph:", error);
402
543
  throw new Error(
@@ -442,10 +583,11 @@ class DataController {
442
583
  if (proof.dlp?.id) {
443
584
  const fileId = parseInt(proof.fileId);
444
585
  const dlpId = parseInt(proof.dlp.id);
445
- if (!proofMap.has(fileId)) {
446
- proofMap.set(fileId, []);
586
+ let dlpIds = proofMap.get(fileId);
587
+ if (!dlpIds) {
588
+ dlpIds = [];
589
+ proofMap.set(fileId, dlpIds);
447
590
  }
448
- const dlpIds = proofMap.get(fileId);
449
591
  if (!dlpIds.includes(dlpId)) {
450
592
  dlpIds.push(dlpId);
451
593
  }
@@ -463,7 +605,7 @@ class DataController {
463
605
  * @returns Map of file IDs to their associated DLP IDs
464
606
  */
465
607
  async _fetchProofsFromChain(fileIds) {
466
- const chainId = this.context.walletClient.chain?.id;
608
+ const chainId = this.context.publicClient.chain?.id;
467
609
  if (!chainId) {
468
610
  throw new Error("Chain ID not available");
469
611
  }
@@ -520,7 +662,10 @@ class DataController {
520
662
  * ```
521
663
  */
522
664
  async getDLP(dlpId, options = {}) {
523
- const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
665
+ const subgraphUrl = options.subgraphUrl ?? this.context.subgraphUrl;
666
+ if (subgraphUrl && (options.minBlock || options.waitForSync)) {
667
+ await checkSubgraphConsistency(subgraphUrl, options);
668
+ }
524
669
  if (subgraphUrl) {
525
670
  try {
526
671
  const response = await fetch(subgraphUrl, {
@@ -551,18 +696,18 @@ class DataController {
551
696
  }
552
697
  return {
553
698
  id: parseInt(result.data.dlp.id),
554
- name: result.data.dlp.name || "",
555
- metadata: result.data.dlp.metadata || void 0,
699
+ name: result.data.dlp.name ?? "",
700
+ metadata: result.data.dlp.metadata ?? void 0,
556
701
  status: result.data.dlp.status ? parseInt(result.data.dlp.status) : void 0,
557
- address: result.data.dlp.address,
558
- owner: result.data.dlp.owner
702
+ address: result.data.dlp.address ? result.data.dlp.address : void 0,
703
+ owner: result.data.dlp.owner ? result.data.dlp.owner : void 0
559
704
  };
560
705
  } catch (error) {
561
706
  console.debug("Subgraph query failed, falling back to chain:", error);
562
707
  }
563
708
  }
564
709
  try {
565
- const chainId = this.context.walletClient.chain?.id;
710
+ const chainId = this.context.publicClient.chain?.id;
566
711
  if (!chainId) {
567
712
  throw new Error("Chain ID not available");
568
713
  }
@@ -574,7 +719,7 @@ class DataController {
574
719
  functionName: "dlps",
575
720
  args: [BigInt(dlpId)]
576
721
  });
577
- if (!dlpData || !dlpData.name) {
722
+ if (!dlpData?.name) {
578
723
  throw new Error(`DLP not found: ${dlpId}`);
579
724
  }
580
725
  return {
@@ -616,7 +761,7 @@ class DataController {
616
761
  */
617
762
  async listDLPs(options = {}) {
618
763
  const { limit = 100, offset = 0 } = options;
619
- const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
764
+ const subgraphUrl = options.subgraphUrl ?? this.context.subgraphUrl;
620
765
  if (subgraphUrl) {
621
766
  try {
622
767
  const query = `
@@ -655,21 +800,21 @@ class DataController {
655
800
  `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
656
801
  );
657
802
  }
658
- const dlps = result.data?.dlps || [];
803
+ const dlps = result.data?.dlps ?? [];
659
804
  return dlps.map((dlp) => ({
660
805
  id: parseInt(dlp.id),
661
- name: dlp.name || "",
806
+ name: dlp.name ?? "",
662
807
  metadata: dlp.metadata,
663
808
  status: dlp.status ? parseInt(dlp.status) : void 0,
664
- address: dlp.address,
665
- owner: dlp.owner
809
+ address: dlp.address ? dlp.address : void 0,
810
+ owner: dlp.owner ? dlp.owner : void 0
666
811
  }));
667
812
  } catch (error) {
668
813
  console.debug("Subgraph query failed, falling back to chain:", error);
669
814
  }
670
815
  }
671
816
  try {
672
- const chainId = this.context.walletClient.chain?.id;
817
+ const chainId = this.context.publicClient.chain?.id;
673
818
  if (!chainId) {
674
819
  throw new Error("Chain ID not available");
675
820
  }
@@ -739,21 +884,33 @@ class DataController {
739
884
  * @returns Promise resolving to an array of permission objects
740
885
  * @throws Error if both subgraph and RPC queries fail
741
886
  */
742
- async getUserPermissions(params) {
887
+ async getUserPermissions(params, options) {
743
888
  const { user, subgraphUrl } = params;
744
- const endpoint = subgraphUrl || this.context.subgraphUrl;
889
+ const endpoint = subgraphUrl ?? this.context.subgraphUrl;
890
+ if (endpoint && (options?.minBlock || options?.waitForSync)) {
891
+ await checkSubgraphConsistency(endpoint, options);
892
+ }
745
893
  if (endpoint) {
746
894
  try {
747
- const permissions = await this._getUserPermissionsViaSubgraph({
748
- user,
749
- subgraphUrl: endpoint
750
- });
895
+ const permissions = await this._getUserPermissionsViaSubgraph(
896
+ {
897
+ user,
898
+ subgraphUrl: endpoint
899
+ },
900
+ options
901
+ );
751
902
  return permissions;
752
903
  } catch (error) {
753
904
  console.warn("Subgraph query failed, falling back to RPC:", error);
754
905
  }
755
906
  }
756
- return await this._getUserPermissionsViaRpc({ user });
907
+ const allPermissions = await this._getUserPermissionsViaRpc({ user });
908
+ if (options && !options.fetchAll) {
909
+ const limit = options.limit ?? 100;
910
+ const offset = options.offset ?? 0;
911
+ return allPermissions.slice(offset, offset + limit);
912
+ }
913
+ return allPermissions;
757
914
  }
758
915
  /**
759
916
  * Internal method: Query user permissions via subgraph
@@ -763,46 +920,48 @@ class DataController {
763
920
  * @param params.subgraphUrl - The subgraph URL endpoint to query
764
921
  * @returns Promise resolving to an array of permission objects
765
922
  */
766
- async _getUserPermissionsViaSubgraph(params) {
923
+ async _getUserPermissionsViaSubgraph(params, options) {
767
924
  const { user, subgraphUrl } = params;
768
925
  try {
769
- const response = await fetch(subgraphUrl, {
770
- method: "POST",
771
- headers: {
772
- "Content-Type": "application/json"
926
+ const orderByMap = {
927
+ id: "id",
928
+ addedAtBlock: "addedAtBlock",
929
+ addedAtTimestamp: "addedAtTimestamp",
930
+ grant: "grant",
931
+ nonce: "nonce",
932
+ startBlock: "startBlock",
933
+ endBlock: "endBlock"
934
+ };
935
+ const permissions = await executePaginatedQuery({
936
+ endpoint: subgraphUrl,
937
+ document: GetUserPermissionsPaginatedDocument,
938
+ baseVariables: {
939
+ userId: user.toLowerCase(),
940
+ orderBy: mapOrderByToEnum(
941
+ options?.orderBy,
942
+ orderByMap,
943
+ "addedAtTimestamp"
944
+ ),
945
+ orderDirection: mapOrderDirection(
946
+ options?.orderDirection,
947
+ "desc",
948
+ "asc"
949
+ )
773
950
  },
774
- body: JSON.stringify({
775
- query: print(GetUserPermissionsDocument),
776
- variables: {
777
- userId: user.toLowerCase()
778
- }
951
+ options,
952
+ extractItems: (data) => data?.user?.permissions,
953
+ transformItem: (permission) => ({
954
+ id: permission.id,
955
+ grant: permission.grant,
956
+ nonce: BigInt(permission.nonce),
957
+ signature: permission.signature,
958
+ addedAtBlock: BigInt(permission.addedAtBlock),
959
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp),
960
+ transactionHash: permission.transactionHash,
961
+ user
779
962
  })
780
963
  });
781
- if (!response.ok) {
782
- throw new Error(
783
- `Subgraph request failed: ${response.status} ${response.statusText}`
784
- );
785
- }
786
- const result = await response.json();
787
- if (result.errors) {
788
- throw new Error(
789
- `Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
790
- );
791
- }
792
- const userData = result.data?.user;
793
- if (!userData || !userData.permissions?.length) {
794
- return [];
795
- }
796
- return userData.permissions.map((permission) => ({
797
- id: permission.id,
798
- grant: permission.grant,
799
- nonce: BigInt(permission.nonce),
800
- signature: permission.signature,
801
- addedAtBlock: BigInt(permission.addedAtBlock),
802
- addedAtTimestamp: BigInt(permission.addedAtTimestamp),
803
- transactionHash: permission.transactionHash,
804
- user
805
- })).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
964
+ return permissions;
806
965
  } catch (error) {
807
966
  console.error("Failed to query user permissions from subgraph:", error);
808
967
  throw error;
@@ -818,7 +977,7 @@ class DataController {
818
977
  async _getUserPermissionsViaRpc(params) {
819
978
  const { user } = params;
820
979
  try {
821
- const chainId = this.context.walletClient.chain?.id;
980
+ const chainId = this.context.publicClient.chain?.id;
822
981
  if (!chainId) {
823
982
  throw new Error("Chain ID not available");
824
983
  }
@@ -935,20 +1094,28 @@ class DataController {
935
1094
  * });
936
1095
  * ```
937
1096
  */
938
- async getUserTrustedServers(params) {
939
- const { user, limit = 50, offset = 0 } = params;
940
- const subgraphUrl = params.subgraphUrl || this.context.subgraphUrl;
1097
+ async getUserTrustedServers(params, options) {
1098
+ const { user } = params;
1099
+ const subgraphUrl = params.subgraphUrl ?? this.context.subgraphUrl;
1100
+ if (subgraphUrl && (options?.minBlock || options?.waitForSync)) {
1101
+ await checkSubgraphConsistency(subgraphUrl, options);
1102
+ }
941
1103
  if (subgraphUrl) {
942
1104
  try {
943
- const servers = await this._getUserTrustedServersViaSubgraph({
944
- user,
945
- subgraphUrl
946
- });
947
- return limit ? servers.slice(offset, offset + limit) : servers;
1105
+ const servers = await this._getUserTrustedServersViaSubgraph(
1106
+ {
1107
+ user,
1108
+ subgraphUrl
1109
+ },
1110
+ options
1111
+ );
1112
+ return servers;
948
1113
  } catch (error) {
949
1114
  console.warn("Subgraph query failed, falling back to RPC:", error);
950
1115
  }
951
1116
  }
1117
+ const limit = options?.fetchAll ? Number.MAX_SAFE_INTEGER : options?.limit ?? 100;
1118
+ const offset = options?.offset ?? 0;
952
1119
  const rpcResult = await this._getUserTrustedServersViaRpc({
953
1120
  user,
954
1121
  limit,
@@ -964,7 +1131,7 @@ class DataController {
964
1131
  * @param params.subgraphUrl - The subgraph URL endpoint to query
965
1132
  * @returns Promise resolving to an array of trusted server objects
966
1133
  */
967
- async _getUserTrustedServersViaSubgraph(params) {
1134
+ async _getUserTrustedServersViaSubgraph(params, options) {
968
1135
  const { user, subgraphUrl } = params;
969
1136
  const graphqlEndpoint = subgraphUrl;
970
1137
  if (!graphqlEndpoint) {
@@ -973,42 +1140,46 @@ class DataController {
973
1140
  );
974
1141
  }
975
1142
  try {
976
- const response = await fetch(graphqlEndpoint, {
977
- method: "POST",
978
- headers: {
979
- "Content-Type": "application/json"
1143
+ const orderByMap = {
1144
+ id: "id",
1145
+ trustedAt: "trustedAt",
1146
+ trustedAtBlock: "trustedAtBlock",
1147
+ server: "server",
1148
+ user: "user"
1149
+ };
1150
+ const serverTrusts = await executePaginatedQuery({
1151
+ endpoint: graphqlEndpoint,
1152
+ document: GetUserTrustedServersPaginatedDocument,
1153
+ baseVariables: {
1154
+ userId: user.toLowerCase(),
1155
+ // Subgraph requires lowercase addresses
1156
+ orderBy: mapOrderByToEnum(
1157
+ options?.orderBy,
1158
+ orderByMap,
1159
+ "trustedAtBlock"
1160
+ ),
1161
+ orderDirection: mapOrderDirection(
1162
+ options?.orderDirection,
1163
+ "desc",
1164
+ "asc"
1165
+ )
980
1166
  },
981
- body: JSON.stringify({
982
- query: print(GetUserTrustedServersDocument),
983
- variables: {
984
- userId: user.toLowerCase()
985
- // Subgraph requires lowercase addresses
986
- }
1167
+ options,
1168
+ extractItems: (data) => {
1169
+ const trusts = data?.user?.serverTrusts ?? [];
1170
+ return trusts.filter((trust) => !trust.untrustedAtBlock);
1171
+ },
1172
+ transformItem: (trust) => ({
1173
+ id: trust.server.id,
1174
+ serverAddress: trust.server.serverAddress,
1175
+ serverUrl: trust.server.url,
1176
+ trustedAt: BigInt(trust.trustedAt),
1177
+ user,
1178
+ name: ""
1179
+ // Not available in new schema, will be empty
987
1180
  })
988
1181
  });
989
- if (!response.ok) {
990
- throw new Error(
991
- `Subgraph request failed: ${response.status} ${response.statusText}`
992
- );
993
- }
994
- const result = await response.json();
995
- if (result.errors) {
996
- throw new Error(
997
- `Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
998
- );
999
- }
1000
- if (!result.data?.user) {
1001
- return [];
1002
- }
1003
- return (result.data.user.serverTrusts || []).filter((trust) => !trust.untrustedAtBlock).map((trust) => ({
1004
- id: trust.server.id,
1005
- serverAddress: trust.server.serverAddress,
1006
- serverUrl: trust.server.url,
1007
- trustedAt: BigInt(trust.trustedAt),
1008
- user,
1009
- name: ""
1010
- // Not available in new schema, will be empty
1011
- }));
1182
+ return serverTrusts;
1012
1183
  } catch (error) {
1013
1184
  console.error("Failed to query trusted servers from subgraph:", error);
1014
1185
  throw error;
@@ -1026,7 +1197,7 @@ class DataController {
1026
1197
  async _getUserTrustedServersViaRpc(params) {
1027
1198
  const { user, limit, offset } = params;
1028
1199
  try {
1029
- const chainId = this.context.walletClient.chain?.id;
1200
+ const chainId = this.context.publicClient.chain?.id;
1030
1201
  if (!chainId) {
1031
1202
  throw new Error("Chain ID not available");
1032
1203
  }
@@ -1110,23 +1281,31 @@ class DataController {
1110
1281
  }
1111
1282
  }
1112
1283
  /**
1113
- * Gets the total number of files in the registry from the contract.
1284
+ * Retrieves total file count from Data Registry.
1285
+ *
1286
+ * @remarks
1287
+ * Queries blockchain for complete file count across all users.
1288
+ * Useful for pagination and network statistics.
1289
+ *
1290
+ * @returns Total number of registered files
1291
+ *
1292
+ * @throws {Error} Chain ID not available.
1293
+ * Ensure network connection.
1294
+ * @throws {Error} Contract read failed.
1295
+ * Check RPC availability.
1114
1296
  *
1115
- * @returns Promise resolving to the total file count
1116
1297
  * @example
1117
1298
  * ```typescript
1118
- * const totalFiles = await vana.data.getTotalFilesCount();
1119
- * console.log(`Total files in registry: ${totalFiles}`);
1299
+ * const total = await vana.data.getTotalFilesCount();
1300
+ * console.log(`Total files: ${total}`);
1120
1301
  *
1121
- * // Use for pagination calculations
1122
- * const filesPerPage = 20;
1123
- * const totalPages = Math.ceil(totalFiles / filesPerPage);
1124
- * console.log(`Total pages: ${totalPages}`);
1302
+ * // Calculate pagination
1303
+ * const pages = Math.ceil(total / 20);
1125
1304
  * ```
1126
1305
  */
1127
1306
  async getTotalFilesCount() {
1128
1307
  try {
1129
- const chainId = this.context.walletClient.chain?.id;
1308
+ const chainId = this.context.publicClient.chain?.id;
1130
1309
  if (!chainId) {
1131
1310
  throw new Error("Chain ID not available");
1132
1311
  }
@@ -1135,7 +1314,7 @@ class DataController {
1135
1314
  const dataRegistry = getContract({
1136
1315
  address: dataRegistryAddress,
1137
1316
  abi: dataRegistryAbi,
1138
- client: this.context.walletClient
1317
+ client: this.context.publicClient
1139
1318
  });
1140
1319
  const count = await dataRegistry.read.filesCount();
1141
1320
  return Number(count);
@@ -1148,36 +1327,36 @@ class DataController {
1148
1327
  }
1149
1328
  }
1150
1329
  /**
1151
- * Retrieves details for a specific file by its ID.
1330
+ * Retrieves file metadata by ID from the blockchain.
1331
+ *
1332
+ * @remarks
1333
+ * Queries DataRegistry contract directly for file details.
1334
+ * Works for any file ID regardless of ownership, enabling
1335
+ * cross-user file discovery and verification.
1336
+ *
1337
+ * @param fileId - Numeric file ID to retrieve
1338
+ *
1339
+ * @returns UserFile object with metadata
1340
+ *
1341
+ * @throws {Error} Chain ID not available.
1342
+ * Ensure proper network connection.
1343
+ * @throws {Error} File not found.
1344
+ * Verify file ID exists on-chain.
1345
+ * @throws {Error} Contract call failed.
1346
+ * Check network and RPC availability.
1152
1347
  *
1153
- * @param fileId - The file ID to look up
1154
- * @returns Promise resolving to UserFile object
1155
- * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1156
- * @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
1157
- * @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
1158
1348
  * @example
1159
1349
  * ```typescript
1160
- * try {
1161
- * const file = await vana.data.getFileById(123);
1162
- * console.log('File details:', {
1163
- * id: file.id,
1164
- * url: file.url,
1165
- * owner: file.ownerAddress,
1166
- * addedAt: file.addedAtBlock
1167
- * });
1168
- * } catch (error) {
1169
- * console.error('File not found or error retrieving file:', error);
1170
- * }
1350
+ * const file = await vana.data.getFileById(123);
1351
+ * console.log(`File ${file.id}:`);
1352
+ * console.log(` URL: ${file.url}`);
1353
+ * console.log(` Owner: ${file.ownerAddress}`);
1354
+ * console.log(` Block: ${file.addedAtBlock}`);
1171
1355
  * ```
1172
- *
1173
- * This method queries the DataRegistry contract directly
1174
- * to get file details for any file ID, regardless of user ownership.
1175
- * This is useful for file lookup functionality where users can search
1176
- * for specific files by ID.
1177
1356
  */
1178
1357
  async getFileById(fileId) {
1179
1358
  try {
1180
- const chainId = this.context.walletClient.chain?.id;
1359
+ const chainId = this.context.publicClient.chain?.id;
1181
1360
  if (!chainId) {
1182
1361
  throw new Error("Chain ID not available");
1183
1362
  }
@@ -1186,7 +1365,7 @@ class DataController {
1186
1365
  const dataRegistry = getContract({
1187
1366
  address: dataRegistryAddress,
1188
1367
  abi: dataRegistryAbi,
1189
- client: this.context.walletClient
1368
+ client: this.context.publicClient
1190
1369
  });
1191
1370
  const fileDetails = await dataRegistry.read.files([BigInt(fileId)]);
1192
1371
  if (!fileDetails) {
@@ -1244,15 +1423,17 @@ class DataController {
1244
1423
  * console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
1245
1424
  * ```
1246
1425
  */
1247
- async registerFileWithSchema(url, schemaId) {
1426
+ async registerFileWithSchema(url, schemaId, options) {
1427
+ this.assertWallet();
1248
1428
  try {
1249
- const chainId = this.context.walletClient.chain?.id;
1429
+ const chainId = this.context.publicClient.chain?.id;
1250
1430
  if (!chainId) {
1251
1431
  throw new Error("Chain ID not available");
1252
1432
  }
1433
+ this.assertWallet();
1253
1434
  const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
1254
1435
  const dataRegistryAbi = getAbi("DataRegistry");
1255
- const account = this.context.walletClient.account || await this.getUserAddress();
1436
+ const account = this.context.walletClient.account ?? this.context.userAddress;
1256
1437
  const from = typeof account === "string" ? account : account.address;
1257
1438
  const hash = await this.context.walletClient.writeContract({
1258
1439
  address: dataRegistryAddress,
@@ -1260,7 +1441,8 @@ class DataController {
1260
1441
  functionName: "addFileWithSchema",
1261
1442
  args: [url, BigInt(schemaId)],
1262
1443
  account,
1263
- chain: this.context.walletClient.chain || null
1444
+ chain: this.context.walletClient.chain ?? null,
1445
+ ...this.spreadTransactionOptions(options)
1264
1446
  });
1265
1447
  const { tx } = await import("../utils/transactionHelpers");
1266
1448
  return tx({
@@ -1282,13 +1464,6 @@ class DataController {
1282
1464
  * @returns Promise resolving to the user's wallet address
1283
1465
  * @throws {Error} When no addresses are available in wallet client
1284
1466
  */
1285
- async getUserAddress() {
1286
- const addresses = await this.context.walletClient.getAddresses();
1287
- if (addresses.length === 0) {
1288
- throw new Error("No addresses available in wallet client");
1289
- }
1290
- return addresses[0];
1291
- }
1292
1467
  /**
1293
1468
  * Adds a file with permissions to the DataRegistry contract.
1294
1469
  *
@@ -1305,15 +1480,17 @@ class DataController {
1305
1480
  * with specific permissions on the DataRegistry contract. It can be used
1306
1481
  * by both direct transactions and relayer services.
1307
1482
  */
1308
- async addFileWithPermissions(url, ownerAddress, permissions = []) {
1483
+ async addFileWithPermissions(url, ownerAddress, permissions = [], options) {
1484
+ this.assertWallet();
1309
1485
  try {
1310
- const chainId = this.context.walletClient.chain?.id;
1486
+ const chainId = this.context.publicClient.chain?.id;
1311
1487
  if (!chainId) {
1312
1488
  throw new Error("Chain ID not available");
1313
1489
  }
1490
+ this.assertWallet();
1314
1491
  const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
1315
1492
  const dataRegistryAbi = getAbi("DataRegistry");
1316
- const account = this.context.walletClient.account || ownerAddress;
1493
+ const account = this.context.walletClient.account ?? ownerAddress;
1317
1494
  const from = typeof account === "string" ? account : account.address;
1318
1495
  const hash = await this.context.walletClient.writeContract({
1319
1496
  address: dataRegistryAddress,
@@ -1321,7 +1498,8 @@ class DataController {
1321
1498
  functionName: "addFileWithPermissions",
1322
1499
  args: [url, ownerAddress, permissions],
1323
1500
  account,
1324
- chain: this.context.walletClient.chain || null
1501
+ chain: this.context.walletClient.chain ?? null,
1502
+ ...this.spreadTransactionOptions(options)
1325
1503
  });
1326
1504
  const { tx } = await import("../utils/transactionHelpers");
1327
1505
  return tx({
@@ -1341,25 +1519,133 @@ class DataController {
1341
1519
  * Adds a file to the registry with permissions and schema.
1342
1520
  * This combines the functionality of addFileWithPermissions and schema validation.
1343
1521
  *
1522
+ * @remarks
1523
+ * This method automatically encrypts permissions when a publicKey is provided.
1524
+ * It generates the user's encryption key and encrypts it with each recipient's
1525
+ * public key before registering on the blockchain.
1526
+ *
1344
1527
  * @param url - The URL of the file to register
1345
1528
  * @param ownerAddress - The address of the file owner
1346
- * @param permissions - Array of permissions to grant (account and encrypted key)
1529
+ * @param permissions - Array of permissions to grant, each with account and publicKey properties
1347
1530
  * @param schemaId - The schema ID to associate with the file (0 for no schema)
1348
- * @returns Promise resolving to object with fileId and transactionHash
1531
+ * @returns Promise resolving to TransactionResult with fileId and transactionHash
1532
+ * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1533
+ * @throws {Error} "Failed to generate encryption key" - When encryption key generation fails
1534
+ * @throws {Error} "Permission for {account} must include 'publicKey'" - When publicKey is missing
1535
+ * @throws {Error} "Failed to add file with permissions and schema: {error}" - When transaction fails
1536
+ * @example
1537
+ * ```typescript
1538
+ * // Get server's public key
1539
+ * const serverIdentity = await vana.server.getIdentity({
1540
+ * userAddress: "0x..."
1541
+ * });
1542
+ *
1543
+ * // Add file with permissions and schema
1544
+ * const result = await vana.data.addFileWithPermissionsAndSchema(
1545
+ * "ipfs://QmXxx...",
1546
+ * ownerAddress,
1547
+ * [{
1548
+ * account: serverIdentity.address,
1549
+ * publicKey: serverIdentity.publicKey
1550
+ * }],
1551
+ * schemaId
1552
+ * );
1553
+ *
1554
+ * console.log(`File ${result.fileId} registered in tx ${result.hash}`);
1555
+ * ```
1556
+ */
1557
+ async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1558
+ this.assertWallet();
1559
+ try {
1560
+ let encryptedPermissions = [];
1561
+ if (permissions.length > 0) {
1562
+ this.assertWallet();
1563
+ const userEncryptionKey = await generateEncryptionKey(
1564
+ this.context.walletClient,
1565
+ this.context.platform,
1566
+ DEFAULT_ENCRYPTION_SEED
1567
+ );
1568
+ encryptedPermissions = await Promise.all(
1569
+ permissions.map(async (permission) => {
1570
+ if (!permission.publicKey) {
1571
+ throw new Error(
1572
+ `Permission for ${permission.account} must include 'publicKey'`
1573
+ );
1574
+ }
1575
+ const encryptedKey = await encryptWithWalletPublicKey(
1576
+ userEncryptionKey,
1577
+ permission.publicKey,
1578
+ this.context.platform
1579
+ );
1580
+ return {
1581
+ account: permission.account,
1582
+ key: encryptedKey
1583
+ };
1584
+ })
1585
+ );
1586
+ }
1587
+ return await this.addFileWithEncryptedPermissionsAndSchema(
1588
+ url,
1589
+ ownerAddress,
1590
+ encryptedPermissions,
1591
+ schemaId,
1592
+ options
1593
+ );
1594
+ } catch (error) {
1595
+ console.error("Failed to add file with permissions and schema:", error);
1596
+ throw new Error(
1597
+ `Failed to add file with permissions and schema: ${error instanceof Error ? error.message : "Unknown error"}`
1598
+ );
1599
+ }
1600
+ }
1601
+ /**
1602
+ * Adds a file with pre-encrypted permissions and schema to the DataRegistry.
1603
+ *
1604
+ * @remarks
1605
+ * This method is designed for relay services and advanced use cases where permissions
1606
+ * have already been encrypted client-side. Unlike `addFileWithPermissionsAndSchema()`,
1607
+ * this method expects permissions in the encrypted format with a 'key' field instead
1608
+ * of 'publicKey'.
1609
+ *
1610
+ * This is typically used by relay endpoints that receive pre-encrypted data from
1611
+ * the client SDK's `upload()` method, avoiding double encryption.
1612
+ *
1613
+ * @param url - The storage URL of the file (e.g., IPFS URL)
1614
+ * @param ownerAddress - The address that will own this file
1615
+ * @param permissions - Array of pre-encrypted permissions with 'account' and 'key' fields
1616
+ * @param schemaId - Optional schema ID for data validation (defaults to 0)
1617
+ * @returns Promise resolving to transaction result with hash and contract details
1349
1618
  * @throws {Error} When chain ID is not available
1350
- * @throws {ContractError} When contract execution fails
1351
- * @throws {Error} When transaction receipt is not available
1352
- * @throws {Error} When FileAdded event cannot be parsed
1619
+ * @throws {Error} When wallet is not connected
1620
+ * @throws {Error} When transaction fails
1621
+ * @example
1622
+ * ```typescript
1623
+ * // In a relay endpoint that receives pre-encrypted permissions
1624
+ * const result = await vana.data.addFileWithEncryptedPermissionsAndSchema(
1625
+ * "ipfs://QmXxx...",
1626
+ * ownerAddress,
1627
+ * [
1628
+ * {
1629
+ * account: "0xServerAddress...",
1630
+ * key: "encrypted_key_string" // Already encrypted by client
1631
+ * }
1632
+ * ],
1633
+ * schemaId
1634
+ * );
1635
+ *
1636
+ * console.log(`File registered in tx ${result.hash}`);
1637
+ * ```
1353
1638
  */
1354
- async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1639
+ async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1355
1640
  try {
1356
- const chainId = this.context.walletClient.chain?.id;
1641
+ const chainId = this.context.publicClient.chain?.id;
1357
1642
  if (!chainId) {
1358
1643
  throw new Error("Chain ID not available");
1359
1644
  }
1645
+ this.assertWallet();
1360
1646
  const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
1361
1647
  const dataRegistryAbi = getAbi("DataRegistry");
1362
- const account = this.context.walletClient.account || ownerAddress;
1648
+ const account = this.context.walletClient.account ?? ownerAddress;
1363
1649
  const from = typeof account === "string" ? account : account.address;
1364
1650
  const hash = await this.context.walletClient.writeContract({
1365
1651
  address: dataRegistryAddress,
@@ -1367,7 +1653,8 @@ class DataController {
1367
1653
  functionName: "addFileWithPermissionsAndSchema",
1368
1654
  args: [url, ownerAddress, permissions, BigInt(schemaId)],
1369
1655
  account,
1370
- chain: this.context.walletClient.chain || null
1656
+ chain: this.context.walletClient.chain ?? null,
1657
+ ...this.spreadTransactionOptions(options)
1371
1658
  });
1372
1659
  const { tx } = await import("../utils/transactionHelpers");
1373
1660
  return tx({
@@ -1384,36 +1671,41 @@ class DataController {
1384
1671
  }
1385
1672
  }
1386
1673
  /**
1387
- * Adds a new refiner to the DataRefinerRegistry.
1674
+ * Registers a data refiner for processing templates.
1388
1675
  *
1389
1676
  * @remarks
1390
- * Refiners are data processing templates that define how raw data should be
1391
- * transformed into structured formats. Each refiner is associated with a DLP
1392
- * (Data Liquidity Pool), has a specific schema for output, and includes
1393
- * instructions for the refinement process.
1394
- *
1395
- * @param params - Refiner configuration parameters
1396
- * @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
1397
- * @param params.name - Human-readable name for the refiner
1398
- * @param params.schemaId - Schema ID that defines the output format
1399
- * @param params.refinementInstructionUrl - URL containing processing instructions
1400
- * @returns Promise resolving to the new refiner ID and transaction hash
1401
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1402
- * @throws {Error} When transaction fails - "Failed to add refiner: {error}"
1677
+ * Refiners define data transformation rules for DLPs.
1678
+ * Associates schema, instructions, and processing logic.
1679
+ *
1680
+ * @param params - Refiner configuration
1681
+ * @param params.dlpId - Data Liquidity Pool ID
1682
+ * @param params.name - Refiner display name
1683
+ * @param params.schemaId - Output schema ID.
1684
+ * Obtain via `vana.schemas.list()`.
1685
+ * @param params.refinementInstructionUrl - Processing instructions URL
1686
+ *
1687
+ * @returns Refiner ID and transaction hash
1688
+ *
1689
+ * @throws {Error} Chain ID not available.
1690
+ * Ensure network connection.
1691
+ * @throws {Error} Transaction failed.
1692
+ * Check wallet balance and network status.
1693
+ *
1403
1694
  * @example
1404
1695
  * ```typescript
1405
1696
  * const result = await vana.data.addRefiner({
1406
1697
  * dlpId: 1,
1407
- * name: "Social Media Sentiment Analyzer",
1698
+ * name: "Sentiment Analyzer",
1408
1699
  * schemaId: 42,
1409
1700
  * refinementInstructionUrl: "ipfs://QmXxx..."
1410
1701
  * });
1411
- * console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
1702
+ * console.log(`Refiner ${result.refinerId} created`);
1412
1703
  * ```
1413
1704
  */
1414
- async addRefiner(params) {
1705
+ async addRefiner(params, options) {
1706
+ this.assertWallet();
1415
1707
  try {
1416
- const chainId = this.context.walletClient.chain?.id;
1708
+ const chainId = this.context.publicClient.chain?.id;
1417
1709
  if (!chainId) {
1418
1710
  throw new Error("Chain ID not available");
1419
1711
  }
@@ -1422,7 +1714,8 @@ class DataController {
1422
1714
  "DataRefinerRegistry"
1423
1715
  );
1424
1716
  const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
1425
- const account = this.context.walletClient.account || await this.getUserAddress();
1717
+ this.assertWallet();
1718
+ const account = this.context.walletClient.account ?? this.context.userAddress;
1426
1719
  const from = typeof account === "string" ? account : account.address;
1427
1720
  const hash = await this.context.walletClient.writeContract({
1428
1721
  address: dataRefinerRegistryAddress,
@@ -1435,7 +1728,8 @@ class DataController {
1435
1728
  params.refinementInstructionUrl
1436
1729
  ],
1437
1730
  account,
1438
- chain: this.context.walletClient.chain || null
1731
+ chain: this.context.walletClient.chain ?? null,
1732
+ ...this.spreadTransactionOptions(options)
1439
1733
  });
1440
1734
  const { tx } = await import("../utils/transactionHelpers");
1441
1735
  const txResult = tx({
@@ -1464,31 +1758,34 @@ class DataController {
1464
1758
  }
1465
1759
  }
1466
1760
  /**
1467
- * Retrieves a refiner by its ID.
1761
+ * Retrieves refiner configuration by ID.
1468
1762
  *
1469
1763
  * @remarks
1470
- * Queries the DataRefinerRegistry contract to get complete information about
1471
- * a specific refiner including its DLP association, schema, and instructions.
1764
+ * Queries DataRefinerRegistry for refiner details.
1765
+ * Returns DLP association, schema, and processing instructions.
1766
+ *
1767
+ * @param refinerId - Numeric refiner ID
1768
+ *
1769
+ * @returns Refiner configuration object
1770
+ *
1771
+ * @throws {Error} Chain ID not available.
1772
+ * Ensure network connection.
1773
+ * @throws {Error} Refiner not found.
1774
+ * Verify refiner ID exists.
1775
+ * @throws {Error} Contract read failed.
1776
+ * Check network and RPC status.
1472
1777
  *
1473
- * @param refinerId - The numeric refiner ID to retrieve
1474
- * @returns Promise resolving to the refiner information object
1475
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1476
- * @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
1477
- * @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
1478
1778
  * @example
1479
1779
  * ```typescript
1480
1780
  * const refiner = await vana.data.getRefiner(1);
1481
- * console.log({
1482
- * name: refiner.name,
1483
- * dlp: refiner.dlpId,
1484
- * schema: refiner.schemaId,
1485
- * instructions: refiner.refinementInstructionUrl
1486
- * });
1781
+ * console.log(`Refiner: ${refiner.name}`);
1782
+ * console.log(`DLP: ${refiner.dlpId}`);
1783
+ * console.log(`Schema: ${refiner.schemaId}`);
1487
1784
  * ```
1488
1785
  */
1489
1786
  async getRefiner(refinerId) {
1490
1787
  try {
1491
- const chainId = this.context.walletClient.chain?.id;
1788
+ const chainId = this.context.publicClient.chain?.id;
1492
1789
  if (!chainId) {
1493
1790
  throw new Error("Chain ID not available");
1494
1791
  }
@@ -1500,7 +1797,7 @@ class DataController {
1500
1797
  const dataRefinerRegistry = getContract({
1501
1798
  address: dataRefinerRegistryAddress,
1502
1799
  abi: dataRefinerRegistryAbi,
1503
- client: this.context.walletClient
1800
+ client: this.context.publicClient
1504
1801
  });
1505
1802
  const refinerData = await dataRefinerRegistry.read.refiners([
1506
1803
  BigInt(refinerId)
@@ -1524,27 +1821,33 @@ class DataController {
1524
1821
  }
1525
1822
  }
1526
1823
  /**
1527
- * Validates if a schema ID exists in the registry.
1824
+ * Validates schema ID existence.
1528
1825
  *
1529
1826
  * @remarks
1530
- * Checks the DataRefinerRegistry contract to determine if a given schema ID
1531
- * has been registered and is available for use.
1827
+ * Verifies schema registration in DataRegistry.
1828
+ * Check before using schemas for uploads.
1829
+ *
1830
+ * @param schemaId - Numeric schema ID to validate
1831
+ *
1832
+ * @returns True if schema exists, false otherwise
1833
+ *
1834
+ * @throws {Error} Chain ID not available.
1835
+ * Ensure network connection.
1836
+ * @throws {Error} Contract read failed.
1837
+ * Check RPC availability.
1532
1838
  *
1533
- * @param schemaId - The numeric schema ID to validate
1534
- * @returns Promise resolving to true if schema exists, false otherwise
1535
1839
  * @example
1536
1840
  * ```typescript
1537
- * const isValid = await vana.data.isValidSchemaId(42);
1538
- * if (isValid) {
1539
- * console.log('Schema 42 is available for use');
1540
- * } else {
1541
- * console.log('Schema 42 does not exist');
1841
+ * const valid = await vana.data.isValidSchemaId(42);
1842
+ * if (valid) {
1843
+ * // Safe to use schema 42
1844
+ * await vana.data.upload({ schemaId: 42, ... });
1542
1845
  * }
1543
1846
  * ```
1544
1847
  */
1545
1848
  async isValidSchemaId(schemaId) {
1546
1849
  try {
1547
- const chainId = this.context.walletClient.chain?.id;
1850
+ const chainId = this.context.publicClient.chain?.id;
1548
1851
  if (!chainId) {
1549
1852
  throw new Error("Chain ID not available");
1550
1853
  }
@@ -1556,7 +1859,7 @@ class DataController {
1556
1859
  const dataRefinerRegistry = getContract({
1557
1860
  address: dataRefinerRegistryAddress,
1558
1861
  abi: dataRefinerRegistryAbi,
1559
- client: this.context.walletClient
1862
+ client: this.context.publicClient
1560
1863
  });
1561
1864
  const isValid = await dataRefinerRegistry.read.isValidSchemaId([
1562
1865
  BigInt(schemaId)
@@ -1583,7 +1886,7 @@ class DataController {
1583
1886
  */
1584
1887
  async getRefinersCount() {
1585
1888
  try {
1586
- const chainId = this.context.walletClient.chain?.id;
1889
+ const chainId = this.context.publicClient.chain?.id;
1587
1890
  if (!chainId) {
1588
1891
  throw new Error("Chain ID not available");
1589
1892
  }
@@ -1595,7 +1898,7 @@ class DataController {
1595
1898
  const dataRefinerRegistry = getContract({
1596
1899
  address: dataRefinerRegistryAddress,
1597
1900
  abi: dataRefinerRegistryAbi,
1598
- client: this.context.walletClient
1901
+ client: this.context.publicClient
1599
1902
  });
1600
1903
  const count = await dataRefinerRegistry.read.refinersCount();
1601
1904
  return Number(count);
@@ -1626,9 +1929,10 @@ class DataController {
1626
1929
  * console.log(`Schema updated in tx ${result.transactionHash}`);
1627
1930
  * ```
1628
1931
  */
1629
- async updateSchemaId(params) {
1932
+ async updateSchemaId(params, options) {
1933
+ this.assertWallet();
1630
1934
  try {
1631
- const chainId = this.context.walletClient.chain?.id;
1935
+ const chainId = this.context.publicClient.chain?.id;
1632
1936
  if (!chainId) {
1633
1937
  throw new Error("Chain ID not available");
1634
1938
  }
@@ -1637,14 +1941,16 @@ class DataController {
1637
1941
  "DataRefinerRegistry"
1638
1942
  );
1639
1943
  const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
1640
- const account = this.context.walletClient.account || await this.getUserAddress();
1944
+ this.assertWallet();
1945
+ const account = this.context.walletClient.account ?? this.context.userAddress;
1641
1946
  const hash = await this.context.walletClient.writeContract({
1642
1947
  address: dataRefinerRegistryAddress,
1643
1948
  abi: dataRefinerRegistryAbi,
1644
1949
  functionName: "updateSchemaId",
1645
1950
  args: [BigInt(params.refinerId), BigInt(params.newSchemaId)],
1646
1951
  account,
1647
- chain: this.context.walletClient.chain || null
1952
+ chain: this.context.walletClient.chain ?? null,
1953
+ ...this.spreadTransactionOptions(options)
1648
1954
  });
1649
1955
  await this.context.publicClient.waitForTransactionReceipt({ hash });
1650
1956
  return {
@@ -1666,13 +1972,12 @@ class DataController {
1666
1972
  * 3. Encrypts the user's encryption key with the provided public key
1667
1973
  * 4. Registers the file with permissions
1668
1974
  *
1669
- * @param data - The file data to encrypt and upload
1670
- * @param permissions - Array of permissions to grant, each with account address and public key
1671
- * @param filename - Optional filename for the upload
1672
- * @param providerName - Optional storage provider to use
1975
+ * @param params - Upload parameters including data, permissions, and options
1673
1976
  * @returns Promise resolving to upload result with file ID and storage URL
1674
1977
  */
1675
- async uploadFileWithPermissions(data, permissions, filename, providerName) {
1978
+ async uploadFileWithPermissions(params) {
1979
+ this.assertWallet();
1980
+ const { data, permissions, filename, providerName } = params;
1676
1981
  try {
1677
1982
  const uploadResult = await this.uploadToStorage(
1678
1983
  data,
@@ -1681,7 +1986,7 @@ class DataController {
1681
1986
  // Always encrypt for uploadFileWithPermissions
1682
1987
  providerName
1683
1988
  );
1684
- const userAddress = await this.getUserAddress();
1989
+ const userAddress = this.context.userAddress;
1685
1990
  const userEncryptionKey = await generateEncryptionKey(
1686
1991
  this.context.walletClient,
1687
1992
  this.context.platform,
@@ -1700,12 +2005,24 @@ class DataController {
1700
2005
  };
1701
2006
  })
1702
2007
  );
1703
- if (this.context.relayerCallbacks?.submitFileAdditionWithPermissions) {
1704
- const result = await this.context.relayerCallbacks.submitFileAdditionWithPermissions(
1705
- uploadResult.url,
1706
- userAddress,
1707
- encryptedPermissions
1708
- );
2008
+ if (this.context.relayer) {
2009
+ const request = {
2010
+ type: "direct",
2011
+ operation: "submitFileAdditionWithPermissions",
2012
+ params: {
2013
+ url: uploadResult.url,
2014
+ userAddress,
2015
+ permissions: encryptedPermissions
2016
+ }
2017
+ };
2018
+ const response = await this.context.relayer(request);
2019
+ if (response.type === "error") {
2020
+ throw new Error(response.error);
2021
+ }
2022
+ if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
2023
+ throw new Error("Invalid response from relayer");
2024
+ }
2025
+ const result = response.result;
1709
2026
  return {
1710
2027
  fileId: result.fileId,
1711
2028
  url: uploadResult.url,
@@ -1718,9 +2035,18 @@ class DataController {
1718
2035
  userAddress,
1719
2036
  encryptedPermissions
1720
2037
  );
2038
+ if (!this.context.waitForTransactionEvents) {
2039
+ throw new Error(
2040
+ "Cannot upload without relay: waitForTransactionEvents not configured"
2041
+ );
2042
+ }
2043
+ const eventResult = await this.context.waitForTransactionEvents(txResult);
2044
+ const fileAddedEvent = eventResult.expectedEvents.FileAdded;
2045
+ if (!fileAddedEvent) {
2046
+ throw new Error("FileAdded event not found in transaction");
2047
+ }
1721
2048
  return {
1722
- fileId: 0,
1723
- // Placeholder - user must wait for events to get actual fileId
2049
+ fileId: Number(fileAddedEvent.fileId),
1724
2050
  url: uploadResult.url,
1725
2051
  size: uploadResult.size,
1726
2052
  transactionHash: txResult.hash
@@ -1763,6 +2089,7 @@ class DataController {
1763
2089
  }
1764
2090
  let finalBlob = blob;
1765
2091
  if (encrypt) {
2092
+ this.assertWallet();
1766
2093
  const encryptionKey = await generateEncryptionKey(
1767
2094
  this.context.walletClient,
1768
2095
  this.context.platform,
@@ -1784,7 +2111,7 @@ class DataController {
1784
2111
  );
1785
2112
  }
1786
2113
  }
1787
- const finalFilename = filename || `upload-${Date.now()}.dat`;
2114
+ const finalFilename = filename ?? (encrypt ? `upload-${Date.now()}.enc` : `upload-${Date.now()}.dat`);
1788
2115
  const uploadResult = await this.context.storageManager.upload(
1789
2116
  finalBlob,
1790
2117
  finalFilename,
@@ -1809,22 +2136,30 @@ class DataController {
1809
2136
  * For advanced users who need more control over transaction timing,
1810
2137
  * use `submitFilePermission()` instead.
1811
2138
  *
1812
- * @param fileId - The ID of the file to add permissions for
1813
- * @param account - The address of the account to grant permission to
1814
- * @param publicKey - The public key to encrypt the user's encryption key with (hex string with 0x prefix)
2139
+ * @param params - Parameters for adding file permission
2140
+ * @param params.fileId - The ID of the file to grant permission for
2141
+ * @param params.account - The recipient's wallet address that will access the file
2142
+ * @param params.publicKey - The recipient's public key for encryption.
2143
+ * Obtain via `vana.server.getIdentity(account).publicKey`
1815
2144
  * @returns Promise resolving to permission data from PermissionGranted event
1816
2145
  * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
1817
2146
  * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1818
2147
  * @throws {Error} "Failed to add permission to file: {error}" - When transaction fails or user doesn't own file
1819
2148
  * @example
1820
2149
  * ```typescript
1821
- * const result = await vana.data.addPermissionToFile(fileId, account, publicKey);
2150
+ * const result = await vana.data.addPermissionToFile({
2151
+ * fileId: 123,
2152
+ * account: "0xRecipientAddress...",
2153
+ * publicKey: "0xRecipientPublicKey..."
2154
+ * });
1822
2155
  * console.log(`Permission granted to ${result.account} for file ${result.fileId}`);
1823
2156
  * console.log(`Transaction: ${result.transactionHash}`);
1824
2157
  * ```
1825
2158
  */
1826
- async addPermissionToFile(fileId, account, publicKey) {
1827
- return await this.submitFilePermission(fileId, account, publicKey);
2159
+ async addPermissionToFile(params, options) {
2160
+ this.assertWallet();
2161
+ const { fileId, account, publicKey } = params;
2162
+ return await this.submitFilePermission(fileId, account, publicKey, options);
1828
2163
  }
1829
2164
  /**
1830
2165
  * Submits a file permission transaction to the blockchain.
@@ -1837,7 +2172,7 @@ class DataController {
1837
2172
  * @param fileId - The ID of the file to grant permission for
1838
2173
  * @param account - The recipient's wallet address that will access the file
1839
2174
  * @param publicKey - The recipient's public key for encryption.
1840
- * Obtain via `vana.server.getIdentity(account).public_key`
2175
+ * Obtain via `vana.server.getIdentity(account).publicKey`
1841
2176
  * @returns Promise resolving to TransactionResult for tracking the transaction
1842
2177
  * @throws {Error} When chain ID is not available
1843
2178
  * @throws {Error} When encryption key generation fails
@@ -1854,7 +2189,8 @@ class DataController {
1854
2189
  * console.log(`Permission granted with ID: ${result.permissionId}`);
1855
2190
  * ```
1856
2191
  */
1857
- async submitFilePermission(fileId, account, publicKey) {
2192
+ async submitFilePermission(fileId, account, publicKey, options) {
2193
+ this.assertWallet();
1858
2194
  try {
1859
2195
  const userEncryptionKey = await generateEncryptionKey(
1860
2196
  this.context.walletClient,
@@ -1866,20 +2202,22 @@ class DataController {
1866
2202
  publicKey,
1867
2203
  this.context.platform
1868
2204
  );
1869
- const chainId = this.context.walletClient.chain?.id;
2205
+ const chainId = this.context.publicClient.chain?.id;
1870
2206
  if (!chainId) {
1871
2207
  throw new Error("Chain ID not available");
1872
2208
  }
1873
2209
  const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
1874
2210
  const dataRegistryAbi = getAbi("DataRegistry");
1875
- const walletAccount = this.context.walletClient.account || await this.getUserAddress();
2211
+ this.assertWallet();
2212
+ const walletAccount = this.context.walletClient.account ?? this.context.userAddress;
1876
2213
  const txHash = await this.context.walletClient.writeContract({
1877
2214
  address: dataRegistryAddress,
1878
2215
  abi: dataRegistryAbi,
1879
2216
  functionName: "addFilePermission",
1880
2217
  args: [BigInt(fileId), account, encryptedKey],
1881
2218
  account: walletAccount,
1882
- chain: this.context.walletClient.chain || null
2219
+ chain: this.context.walletClient.chain ?? null,
2220
+ ...this.spreadTransactionOptions(options)
1883
2221
  });
1884
2222
  const { tx } = await import("../utils/transactionHelpers");
1885
2223
  return tx({
@@ -1904,7 +2242,7 @@ class DataController {
1904
2242
  */
1905
2243
  async getFilePermission(fileId, account) {
1906
2244
  try {
1907
- const chainId = this.context.walletClient.chain?.id;
2245
+ const chainId = this.context.publicClient.chain?.id;
1908
2246
  if (!chainId) {
1909
2247
  throw new Error("Chain ID not available");
1910
2248
  }
@@ -1913,7 +2251,7 @@ class DataController {
1913
2251
  const dataRegistry = getContract({
1914
2252
  address: dataRegistryAddress,
1915
2253
  abi: dataRegistryAbi,
1916
- client: this.context.walletClient
2254
+ client: this.context.publicClient
1917
2255
  });
1918
2256
  const encryptedKey = await dataRegistry.read.filePermissions([
1919
2257
  BigInt(fileId),
@@ -1937,12 +2275,13 @@ class DataController {
1937
2275
  *
1938
2276
  * @param file - The file to decrypt
1939
2277
  * @param privateKey - The private key to decrypt the user's encryption key
1940
- * @param account - The account address that has permission (defaults to current wallet account)
2278
+ * @param options - Optional decryption configuration
2279
+ * @param options.account - The account address that has permission (defaults to current wallet account)
1941
2280
  * @returns Promise resolving to the decrypted file data
1942
2281
  */
1943
- async decryptFileWithPermission(file, privateKey, account) {
2282
+ async decryptFileWithPermission(file, privateKey, options) {
1944
2283
  try {
1945
- const permissionAccount = account || await this.getUserAddress();
2284
+ const permissionAccount = options?.account ?? this.context.userAddress;
1946
2285
  const encryptedKey = await this.getFilePermission(
1947
2286
  file.id,
1948
2287
  permissionAccount
@@ -2006,11 +2345,8 @@ class DataController {
2006
2345
  */
2007
2346
  async fetch(url) {
2008
2347
  try {
2009
- const { fetchWithRelayer } = await import("../utils/download");
2010
- const response = await fetchWithRelayer(
2011
- url,
2012
- this.context.downloadRelayer
2013
- );
2348
+ const { universalFetch } = await import("../utils/download");
2349
+ const response = await universalFetch(url, this.context.downloadRelayer);
2014
2350
  if (!response.ok) {
2015
2351
  throw new Error(
2016
2352
  `HTTP error! status: ${response.status} ${response.statusText}`
@@ -2075,7 +2411,7 @@ class DataController {
2075
2411
  "https://dweb.link/ipfs/",
2076
2412
  "https://ipfs.io/ipfs/"
2077
2413
  ];
2078
- const gateways = options?.gateways || this.context.ipfsGateways || defaultGateways;
2414
+ const gateways = options?.gateways ?? this.context.ipfsGateways ?? defaultGateways;
2079
2415
  const { extractIpfsHash } = await import("../utils/ipfs");
2080
2416
  const cid = extractIpfsHash(url);
2081
2417
  if (!cid) {
@@ -2204,7 +2540,7 @@ class DataController {
2204
2540
  * ```
2205
2541
  */
2206
2542
  validateDataAgainstSchema(data, schema) {
2207
- return validateDataAgainstSchema(data, schema);
2543
+ validateDataAgainstSchema(data, schema);
2208
2544
  }
2209
2545
  /**
2210
2546
  * Fetches and validates a data schema from a URL, then returns the parsed data schema.