@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
@@ -32,18 +32,23 @@ __export(data_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(data_exports);
34
34
  var import_viem = require("viem");
35
+ var import_base = require("./base");
35
36
  var import_addresses = require("../config/addresses");
36
37
  var import_abi = require("../generated/abi");
37
38
  var import_subgraph = require("../generated/subgraph");
38
39
  var import_graphql = require("graphql");
40
+ var import_subgraphConsistency = require("../utils/subgraphConsistency");
41
+ var import_subgraphPagination = require("../utils/subgraphPagination");
42
+ var import_chainQuery = require("../utils/chainQuery");
39
43
  var import_encryption = require("../utils/encryption");
40
44
  var import_schemaValidation = require("../utils/schemaValidation");
41
45
  var import_multicall = require("../utils/multicall");
42
- class DataController {
46
+ class DataController extends import_base.BaseController {
43
47
  constructor(context) {
44
- this.context = context;
48
+ super(context);
45
49
  }
46
50
  async upload(params) {
51
+ this.assertWallet();
47
52
  const {
48
53
  content,
49
54
  filename,
@@ -68,15 +73,28 @@ class DataController {
68
73
  } catch {
69
74
  parsedContent = content;
70
75
  }
76
+ } else if (content instanceof Blob) {
77
+ const text = await content.text();
78
+ try {
79
+ parsedContent = JSON.parse(text);
80
+ } catch {
81
+ parsedContent = text;
82
+ }
71
83
  } else {
72
84
  parsedContent = content;
73
85
  }
74
86
  (0, import_schemaValidation.validateDataAgainstSchema)(parsedContent, schema);
75
87
  } catch (error) {
76
88
  isValid = false;
77
- validationErrors = [
78
- error instanceof Error ? error.message : "Schema validation failed"
79
- ];
89
+ if (error instanceof Error) {
90
+ if (typeof error === "object" && "errors" in error && Array.isArray(error.errors)) {
91
+ validationErrors = error.errors;
92
+ } else {
93
+ validationErrors = [error.message];
94
+ }
95
+ } else {
96
+ validationErrors = ["Schema validation failed"];
97
+ }
80
98
  }
81
99
  }
82
100
  const uploadResult = await this.uploadToStorage(
@@ -85,9 +103,10 @@ class DataController {
85
103
  encrypt,
86
104
  providerName
87
105
  );
88
- const userAddress = owner || await this.getUserAddress();
106
+ const userAddress = owner ?? this.context.userAddress;
89
107
  let encryptedPermissions = [];
90
108
  if (permissions.length > 0 && encrypt) {
109
+ this.assertWallet();
91
110
  const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
92
111
  this.context.walletClient,
93
112
  this.context.platform,
@@ -108,37 +127,45 @@ class DataController {
108
127
  );
109
128
  }
110
129
  let result;
111
- if (this.context.relayerCallbacks?.submitFileAdditionComplete) {
112
- result = await this.context.relayerCallbacks.submitFileAdditionComplete(
113
- {
130
+ if (this.context.relayer) {
131
+ const request = {
132
+ type: "direct",
133
+ operation: "submitFileAdditionComplete",
134
+ params: {
114
135
  url: uploadResult.url,
115
136
  userAddress,
116
137
  permissions: encryptedPermissions,
117
- schemaId: schemaId || 0,
138
+ schemaId: schemaId ?? 0,
118
139
  ownerAddress: owner
119
140
  }
120
- );
121
- } else if (this.context.relayerCallbacks?.submitFileAddition) {
122
- const needsComplexRegistration = schemaId !== void 0 || encryptedPermissions.length > 0;
123
- if (needsComplexRegistration) {
124
- throw new Error(
125
- "The configured relay callback does not support schemas or permissions. Please update your relay server implementation to provide the `submitFileAdditionComplete` callback."
126
- );
141
+ };
142
+ const response = await this.context.relayer(request);
143
+ if (response.type === "error") {
144
+ throw new Error(response.error);
127
145
  }
128
- result = await this.context.relayerCallbacks.submitFileAddition(
129
- uploadResult.url,
130
- userAddress
131
- );
146
+ if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
147
+ throw new Error("Invalid response from relayer");
148
+ }
149
+ result = response.result;
132
150
  } else {
133
- const txResult = await this.addFileWithPermissionsAndSchema(
151
+ const txResult = await this.addFileWithEncryptedPermissionsAndSchema(
134
152
  uploadResult.url,
135
153
  userAddress,
136
154
  encryptedPermissions,
137
- schemaId || 0
155
+ schemaId ?? 0
138
156
  );
157
+ if (!this.context.waitForTransactionEvents) {
158
+ throw new Error(
159
+ "Cannot upload without relay: waitForTransactionEvents not configured"
160
+ );
161
+ }
162
+ const eventResult = await this.context.waitForTransactionEvents(txResult);
163
+ const fileAddedEvent = eventResult.expectedEvents.FileAdded;
164
+ if (!fileAddedEvent) {
165
+ throw new Error("FileAdded event not found in transaction");
166
+ }
139
167
  result = {
140
- fileId: 0,
141
- // Placeholder - actual fileId available after waiting for events
168
+ fileId: Number(fileAddedEvent.fileId),
142
169
  transactionHash: txResult.hash
143
170
  };
144
171
  }
@@ -157,35 +184,110 @@ class DataController {
157
184
  }
158
185
  }
159
186
  /**
160
- * Decrypts a file owned by the user using their wallet signature.
187
+ * Encrypts data using wallet-derived encryption.
161
188
  *
162
189
  * @remarks
163
- * This is the high-level convenience method for decrypting user files, serving as the
164
- * symmetrical counterpart to the `upload` method. It handles the complete decryption
165
- * workflow including key generation, URL protocol detection, content fetching, and
166
- * decryption.
190
+ * This method provides secure, wallet-based encryption for data before uploading
191
+ * to the Vana network. It's the counterpart to decryptFile for preparing data
192
+ * for secure storage.
167
193
  *
168
194
  * The method automatically:
169
- * - Generates the decryption key from the user's wallet signature
170
- * - Determines the appropriate fetch method based on the file URL protocol
171
- * - Fetches the encrypted content from IPFS or standard HTTP URLs
172
- * - Decrypts the content using the generated key
173
- *
174
- * For IPFS URLs, the method uses gateway fallback for improved reliability. For
175
- * standard HTTP URLs, it uses a simple fetch. If you need custom authentication
176
- * headers or specific gateway configurations, use the low-level primitives directly.
177
- *
178
- * @param file - The user file to decrypt (typically from getUserFiles)
179
- * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
180
- * @returns Promise resolving to the decrypted file content as a Blob
181
- * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
182
- * @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
183
- * @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
184
- * @throws {Error} "Access denied" - When file returns 403 (no permission)
185
- * @throws {Error} "File is empty or could not be retrieved" - When file has no content
186
- * @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
187
- * @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
188
- * @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
195
+ * - Generates an encryption key from the user's wallet signature
196
+ * - Converts the input data to a Blob if necessary
197
+ * - Encrypts the data using the generated key
198
+ * - Returns both the encrypted data and the encryption key
199
+ *
200
+ * The encryption key returned can be stored and later used for decryption,
201
+ * or shared with others to grant them decryption access.
202
+ *
203
+ * @param data - The data to encrypt (Blob, string, or object)
204
+ * @param options - Optional encryption configuration
205
+ * @returns Promise resolving to encrypted data and the encryption key used
206
+ * @throws {Error} When wallet is not connected or encryption fails
207
+ * @example
208
+ * ```typescript
209
+ * // Encrypt a string
210
+ * const { encryptedData, encryptionKey } = await vana.data.encryptFile(
211
+ * "My secret data"
212
+ * );
213
+ *
214
+ * // Encrypt JSON with custom MIME type
215
+ * const { encryptedData, encryptionKey } = await vana.data.encryptFile(
216
+ * { name: "Alice", age: 30 },
217
+ * { mimeType: "application/json" }
218
+ * );
219
+ *
220
+ * // With custom encryption seed
221
+ * const { encryptedData, encryptionKey } = await vana.data.encryptFile(
222
+ * "Secret message",
223
+ * { seed: "My custom encryption seed" }
224
+ * );
225
+ *
226
+ * // Upload the encrypted data
227
+ * const result = await vana.data.uploadToStorage(encryptedData);
228
+ * ```
229
+ */
230
+ async encryptFile(data, options) {
231
+ this.assertWallet();
232
+ try {
233
+ const encryptionKey = await (0, import_encryption.generateEncryptionKey)(
234
+ this.context.walletClient,
235
+ this.context.platform,
236
+ options?.seed ?? import_encryption.DEFAULT_ENCRYPTION_SEED
237
+ );
238
+ let blob;
239
+ if (data instanceof Blob) {
240
+ blob = data;
241
+ } else if (typeof data === "string") {
242
+ blob = new Blob([data], { type: options?.mimeType ?? "text/plain" });
243
+ } else {
244
+ blob = new Blob([JSON.stringify(data)], {
245
+ type: options?.mimeType ?? "application/json"
246
+ });
247
+ }
248
+ const encryptedData = await (0, import_encryption.encryptBlobWithSignedKey)(
249
+ blob,
250
+ encryptionKey,
251
+ this.context.platform
252
+ );
253
+ return {
254
+ encryptedData,
255
+ encryptionKey
256
+ };
257
+ } catch (error) {
258
+ throw new Error(
259
+ `Failed to encrypt file: ${error instanceof Error ? error.message : "Unknown error"}`
260
+ );
261
+ }
262
+ }
263
+ /**
264
+ * Decrypts a file using wallet-derived decryption key.
265
+ *
266
+ * @remarks
267
+ * Counterpart to `upload()` for decrypting user files. Automatically
268
+ * generates decryption key from wallet, fetches encrypted content,
269
+ * and decrypts. Supports IPFS (with gateway fallback) and HTTP URLs.
270
+ *
271
+ * @param file - UserFile object from `getUserFiles()`
272
+ * @param options - Decryption options
273
+ * @param options.seed - Custom encryption seed.
274
+ * Defaults to standard Vana seed.
275
+ *
276
+ * @returns Decrypted content as Blob
277
+ *
278
+ * @throws {Error} No wallet connected.
279
+ * Connect wallet before decrypting.
280
+ * @throws {Error} Network error accessing file.
281
+ * Check CORS settings or server availability.
282
+ * @throws {Error} File not found (404).
283
+ * File no longer available at stored URL.
284
+ * @throws {Error} Access denied (403).
285
+ * No permission to access file.
286
+ * @throws {Error} Invalid file format.
287
+ * File not encrypted with Vana protocol.
288
+ * @throws {Error} Wrong encryption key.
289
+ * Verify seed matches upload or use default.
290
+ *
189
291
  * @example
190
292
  * ```typescript
191
293
  * // Basic file decryption
@@ -211,12 +313,14 @@ class DataController {
211
313
  * fs.writeFileSync('decrypted-file.txt', Buffer.from(buffer));
212
314
  * ```
213
315
  */
214
- async decryptFile(file, encryptionSeed) {
316
+ async decryptFile(file, options) {
317
+ this.assertWallet();
215
318
  try {
319
+ this.assertWallet();
216
320
  const encryptionKey = await (0, import_encryption.generateEncryptionKey)(
217
321
  this.context.walletClient,
218
322
  this.context.platform,
219
- encryptionSeed || import_encryption.DEFAULT_ENCRYPTION_SEED
323
+ options?.seed ?? import_encryption.DEFAULT_ENCRYPTION_SEED
220
324
  );
221
325
  let encryptedBlob;
222
326
  try {
@@ -299,99 +403,126 @@ class DataController {
299
403
  }
300
404
  }
301
405
  /**
302
- * Retrieves all data files owned by a specific user address.
406
+ * Retrieves all files owned by a specific user address.
303
407
  *
304
408
  * @remarks
305
- * This method queries the Vana subgraph to find files directly owned by the user.
306
- * It efficiently handles large datasets by using the File entity's owner field
307
- * and returns complete file metadata without additional contract calls.
308
- *
309
- * **Deduplication Behavior:**
310
- * The method automatically deduplicates files by ID, keeping only the latest version
311
- * (highest timestamp) when duplicate file IDs are found. This handles cases where
312
- * the subgraph may contain multiple entries for the same file due to re-indexing
313
- * or blockchain reorganizations.
314
- * @param params - The query parameters object
315
- * @param params.owner - The wallet address of the file owner to query
316
- * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
317
- * @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
318
- * @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
319
- * @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
320
- * @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
321
- * @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
409
+ * Queries the Vana subgraph for files owned by the specified address.
410
+ * Automatically deduplicates by file ID, keeping the latest version
411
+ * when duplicates exist from re-indexing or chain reorganizations.
412
+ * Enriches results with DLP proof data when available.
413
+ *
414
+ * @param params - Query configuration
415
+ * @param params.owner - Wallet address of the file owner
416
+ * @param params.subgraphUrl - Subgraph endpoint override.
417
+ * Defaults to context configuration.
418
+ *
419
+ * @returns Array of UserFile objects sorted by timestamp (newest first)
420
+ *
421
+ * @throws {Error} Subgraph URL not configured.
422
+ * Provide `subgraphUrl` parameter or configure in Vana constructor.
423
+ * @throws {Error} Subgraph request failed.
424
+ * Check network connectivity and subgraph availability.
425
+ * @throws {Error} Subgraph returned errors.
426
+ * Review query parameters and subgraph logs.
427
+ *
322
428
  * @example
323
429
  * ```typescript
324
- * // Query files for a specific user
325
430
  * const files = await vana.data.getUserFiles({
326
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
431
+ * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
327
432
  * });
328
433
  *
329
434
  * files.forEach(file => {
330
- * console.log(`File ${file.id}: ${file.url} (Schema: ${file.schemaId})`);
435
+ * console.log(`File ${file.id}: ${file.url}`);
436
+ * console.log(` Schema: ${file.schemaId}`);
437
+ * console.log(` DLPs: ${file.dlpIds?.join(", ") || "none"}`);
331
438
  * });
332
439
  * ```
333
440
  */
334
- async getUserFiles(params) {
441
+ async getUserFiles(params, options) {
335
442
  const { owner, subgraphUrl } = params;
336
- const endpoint = subgraphUrl || this.context.subgraphUrl;
443
+ let dataSource = options?.source === "chain" ? "chain" : "subgraph";
444
+ if (options?.source === "auto" || !options?.source && options?.minBlock) {
445
+ const endpoint2 = subgraphUrl ?? this.context.subgraphUrl;
446
+ const currentBlock = await this.context.publicClient.getBlockNumber();
447
+ let subgraphBlock;
448
+ if (endpoint2) {
449
+ try {
450
+ const meta = await (0, import_subgraphConsistency.fetchSubgraphMeta)(endpoint2);
451
+ subgraphBlock = meta.blockNumber;
452
+ } catch {
453
+ subgraphBlock = void 0;
454
+ }
455
+ }
456
+ dataSource = (0, import_chainQuery.determineDataSource)(
457
+ options?.source,
458
+ options?.minBlock,
459
+ currentBlock,
460
+ subgraphBlock
461
+ );
462
+ }
463
+ if (dataSource === "chain") {
464
+ const publicClient = this.context.publicClient;
465
+ const chainId = await publicClient.getChainId();
466
+ const contractAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
467
+ const files = await (0, import_chainQuery.getUserFilesFromChain)(
468
+ publicClient,
469
+ contractAddress,
470
+ owner,
471
+ options?.minBlock ? BigInt(options.minBlock) : void 0
472
+ );
473
+ const limit = options?.fetchAll ? files.length : options?.limit ?? 100;
474
+ const offset = options?.offset ?? 0;
475
+ return files.slice(offset, offset + limit);
476
+ }
477
+ const endpoint = subgraphUrl ?? this.context.subgraphUrl;
337
478
  if (!endpoint) {
338
479
  throw new Error(
339
480
  "subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
340
481
  );
341
482
  }
483
+ if (options?.minBlock || options?.waitForSync) {
484
+ await (0, import_subgraphConsistency.checkSubgraphConsistency)(endpoint, options);
485
+ }
342
486
  try {
343
- const response = await fetch(endpoint, {
344
- method: "POST",
345
- headers: {
346
- "Content-Type": "application/json"
487
+ const orderByMap = {
488
+ id: "id",
489
+ addedAtBlock: "addedAtBlock",
490
+ addedAtTimestamp: "addedAtTimestamp",
491
+ url: "url",
492
+ schemaId: "schemaId"
493
+ };
494
+ const allFiles = await (0, import_subgraphPagination.executePaginatedQuery)({
495
+ endpoint,
496
+ document: import_subgraph.GetUserFilesPaginatedDocument,
497
+ baseVariables: {
498
+ userId: owner.toLowerCase(),
499
+ // Subgraph requires lowercase addresses
500
+ orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
501
+ options?.orderBy,
502
+ orderByMap,
503
+ "addedAtBlock"
504
+ ),
505
+ orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
506
+ options?.orderDirection,
507
+ "asc",
508
+ "desc"
509
+ )
347
510
  },
348
- body: JSON.stringify({
349
- query: (0, import_graphql.print)(import_subgraph.GetUserFilesDocument),
350
- variables: {
351
- userId: owner.toLowerCase()
352
- // Subgraph requires lowercase addresses
353
- }
354
- })
355
- });
356
- if (!response.ok) {
357
- throw new Error(
358
- `Subgraph request failed: ${response.status} ${response.statusText}`
359
- );
360
- }
361
- const result = await response.json();
362
- if (result.errors) {
363
- throw new Error(
364
- `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
365
- );
366
- }
367
- const user = result.data?.user;
368
- if (!user || !user.files?.length) {
369
- console.warn("No files found for user:", owner);
370
- return [];
371
- }
372
- const fileMap = /* @__PURE__ */ new Map();
373
- user.files.forEach((file) => {
374
- const fileId = parseInt(file.id);
375
- const userFile = {
376
- id: fileId,
511
+ options,
512
+ extractItems: (data) => data?.user?.files,
513
+ transformItem: (file) => ({
514
+ id: parseInt(file.id),
377
515
  url: file.url,
378
516
  ownerAddress: file.owner.id,
379
517
  addedAtBlock: BigInt(file.addedAtBlock),
380
518
  schemaId: parseInt(file.schemaId),
381
519
  addedAtTimestamp: BigInt(file.addedAtTimestamp),
382
520
  transactionHash: file.transactionHash
383
- };
384
- const existing = fileMap.get(fileId);
385
- if (!existing || userFile.addedAtTimestamp && existing.addedAtTimestamp && userFile.addedAtTimestamp > existing.addedAtTimestamp) {
386
- fileMap.set(fileId, userFile);
387
- }
521
+ })
388
522
  });
389
- const userFiles = Array.from(fileMap.values()).sort(
390
- (a, b) => Number((b.addedAtTimestamp || 0n) - (a.addedAtTimestamp || 0n))
391
- );
392
- if (userFiles.length > 0) {
523
+ if (allFiles.length > 0) {
393
524
  try {
394
- const fileIds = userFiles.map((f) => f.id);
525
+ const fileIds = allFiles.map((f) => f.id);
395
526
  let proofMap;
396
527
  try {
397
528
  proofMap = await this._fetchProofsFromSubgraph(fileIds, endpoint);
@@ -402,7 +533,7 @@ class DataController {
402
533
  );
403
534
  proofMap = await this._fetchProofsFromChain(fileIds);
404
535
  }
405
- for (const file of userFiles) {
536
+ for (const file of allFiles) {
406
537
  const dlpIds = proofMap.get(file.id);
407
538
  if (dlpIds && dlpIds.length > 0) {
408
539
  file.dlpIds = dlpIds;
@@ -412,7 +543,7 @@ class DataController {
412
543
  console.warn("Failed to fetch proof data for files:", error);
413
544
  }
414
545
  }
415
- return userFiles;
546
+ return allFiles;
416
547
  } catch (error) {
417
548
  console.error("Failed to fetch user files from subgraph:", error);
418
549
  throw new Error(
@@ -458,10 +589,11 @@ class DataController {
458
589
  if (proof.dlp?.id) {
459
590
  const fileId = parseInt(proof.fileId);
460
591
  const dlpId = parseInt(proof.dlp.id);
461
- if (!proofMap.has(fileId)) {
462
- proofMap.set(fileId, []);
592
+ let dlpIds = proofMap.get(fileId);
593
+ if (!dlpIds) {
594
+ dlpIds = [];
595
+ proofMap.set(fileId, dlpIds);
463
596
  }
464
- const dlpIds = proofMap.get(fileId);
465
597
  if (!dlpIds.includes(dlpId)) {
466
598
  dlpIds.push(dlpId);
467
599
  }
@@ -479,7 +611,7 @@ class DataController {
479
611
  * @returns Map of file IDs to their associated DLP IDs
480
612
  */
481
613
  async _fetchProofsFromChain(fileIds) {
482
- const chainId = this.context.walletClient.chain?.id;
614
+ const chainId = this.context.publicClient.chain?.id;
483
615
  if (!chainId) {
484
616
  throw new Error("Chain ID not available");
485
617
  }
@@ -536,7 +668,10 @@ class DataController {
536
668
  * ```
537
669
  */
538
670
  async getDLP(dlpId, options = {}) {
539
- const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
671
+ const subgraphUrl = options.subgraphUrl ?? this.context.subgraphUrl;
672
+ if (subgraphUrl && (options.minBlock || options.waitForSync)) {
673
+ await (0, import_subgraphConsistency.checkSubgraphConsistency)(subgraphUrl, options);
674
+ }
540
675
  if (subgraphUrl) {
541
676
  try {
542
677
  const response = await fetch(subgraphUrl, {
@@ -567,18 +702,18 @@ class DataController {
567
702
  }
568
703
  return {
569
704
  id: parseInt(result.data.dlp.id),
570
- name: result.data.dlp.name || "",
571
- metadata: result.data.dlp.metadata || void 0,
705
+ name: result.data.dlp.name ?? "",
706
+ metadata: result.data.dlp.metadata ?? void 0,
572
707
  status: result.data.dlp.status ? parseInt(result.data.dlp.status) : void 0,
573
- address: result.data.dlp.address,
574
- owner: result.data.dlp.owner
708
+ address: result.data.dlp.address ? result.data.dlp.address : void 0,
709
+ owner: result.data.dlp.owner ? result.data.dlp.owner : void 0
575
710
  };
576
711
  } catch (error) {
577
712
  console.debug("Subgraph query failed, falling back to chain:", error);
578
713
  }
579
714
  }
580
715
  try {
581
- const chainId = this.context.walletClient.chain?.id;
716
+ const chainId = this.context.publicClient.chain?.id;
582
717
  if (!chainId) {
583
718
  throw new Error("Chain ID not available");
584
719
  }
@@ -590,7 +725,7 @@ class DataController {
590
725
  functionName: "dlps",
591
726
  args: [BigInt(dlpId)]
592
727
  });
593
- if (!dlpData || !dlpData.name) {
728
+ if (!dlpData?.name) {
594
729
  throw new Error(`DLP not found: ${dlpId}`);
595
730
  }
596
731
  return {
@@ -632,7 +767,7 @@ class DataController {
632
767
  */
633
768
  async listDLPs(options = {}) {
634
769
  const { limit = 100, offset = 0 } = options;
635
- const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
770
+ const subgraphUrl = options.subgraphUrl ?? this.context.subgraphUrl;
636
771
  if (subgraphUrl) {
637
772
  try {
638
773
  const query = `
@@ -671,21 +806,21 @@ class DataController {
671
806
  `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
672
807
  );
673
808
  }
674
- const dlps = result.data?.dlps || [];
809
+ const dlps = result.data?.dlps ?? [];
675
810
  return dlps.map((dlp) => ({
676
811
  id: parseInt(dlp.id),
677
- name: dlp.name || "",
812
+ name: dlp.name ?? "",
678
813
  metadata: dlp.metadata,
679
814
  status: dlp.status ? parseInt(dlp.status) : void 0,
680
- address: dlp.address,
681
- owner: dlp.owner
815
+ address: dlp.address ? dlp.address : void 0,
816
+ owner: dlp.owner ? dlp.owner : void 0
682
817
  }));
683
818
  } catch (error) {
684
819
  console.debug("Subgraph query failed, falling back to chain:", error);
685
820
  }
686
821
  }
687
822
  try {
688
- const chainId = this.context.walletClient.chain?.id;
823
+ const chainId = this.context.publicClient.chain?.id;
689
824
  if (!chainId) {
690
825
  throw new Error("Chain ID not available");
691
826
  }
@@ -755,21 +890,33 @@ class DataController {
755
890
  * @returns Promise resolving to an array of permission objects
756
891
  * @throws Error if both subgraph and RPC queries fail
757
892
  */
758
- async getUserPermissions(params) {
893
+ async getUserPermissions(params, options) {
759
894
  const { user, subgraphUrl } = params;
760
- const endpoint = subgraphUrl || this.context.subgraphUrl;
895
+ const endpoint = subgraphUrl ?? this.context.subgraphUrl;
896
+ if (endpoint && (options?.minBlock || options?.waitForSync)) {
897
+ await (0, import_subgraphConsistency.checkSubgraphConsistency)(endpoint, options);
898
+ }
761
899
  if (endpoint) {
762
900
  try {
763
- const permissions = await this._getUserPermissionsViaSubgraph({
764
- user,
765
- subgraphUrl: endpoint
766
- });
901
+ const permissions = await this._getUserPermissionsViaSubgraph(
902
+ {
903
+ user,
904
+ subgraphUrl: endpoint
905
+ },
906
+ options
907
+ );
767
908
  return permissions;
768
909
  } catch (error) {
769
910
  console.warn("Subgraph query failed, falling back to RPC:", error);
770
911
  }
771
912
  }
772
- return await this._getUserPermissionsViaRpc({ user });
913
+ const allPermissions = await this._getUserPermissionsViaRpc({ user });
914
+ if (options && !options.fetchAll) {
915
+ const limit = options.limit ?? 100;
916
+ const offset = options.offset ?? 0;
917
+ return allPermissions.slice(offset, offset + limit);
918
+ }
919
+ return allPermissions;
773
920
  }
774
921
  /**
775
922
  * Internal method: Query user permissions via subgraph
@@ -779,46 +926,48 @@ class DataController {
779
926
  * @param params.subgraphUrl - The subgraph URL endpoint to query
780
927
  * @returns Promise resolving to an array of permission objects
781
928
  */
782
- async _getUserPermissionsViaSubgraph(params) {
929
+ async _getUserPermissionsViaSubgraph(params, options) {
783
930
  const { user, subgraphUrl } = params;
784
931
  try {
785
- const response = await fetch(subgraphUrl, {
786
- method: "POST",
787
- headers: {
788
- "Content-Type": "application/json"
932
+ const orderByMap = {
933
+ id: "id",
934
+ addedAtBlock: "addedAtBlock",
935
+ addedAtTimestamp: "addedAtTimestamp",
936
+ grant: "grant",
937
+ nonce: "nonce",
938
+ startBlock: "startBlock",
939
+ endBlock: "endBlock"
940
+ };
941
+ const permissions = await (0, import_subgraphPagination.executePaginatedQuery)({
942
+ endpoint: subgraphUrl,
943
+ document: import_subgraph.GetUserPermissionsPaginatedDocument,
944
+ baseVariables: {
945
+ userId: user.toLowerCase(),
946
+ orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
947
+ options?.orderBy,
948
+ orderByMap,
949
+ "addedAtTimestamp"
950
+ ),
951
+ orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
952
+ options?.orderDirection,
953
+ "desc",
954
+ "asc"
955
+ )
789
956
  },
790
- body: JSON.stringify({
791
- query: (0, import_graphql.print)(import_subgraph.GetUserPermissionsDocument),
792
- variables: {
793
- userId: user.toLowerCase()
794
- }
957
+ options,
958
+ extractItems: (data) => data?.user?.permissions,
959
+ transformItem: (permission) => ({
960
+ id: permission.id,
961
+ grant: permission.grant,
962
+ nonce: BigInt(permission.nonce),
963
+ signature: permission.signature,
964
+ addedAtBlock: BigInt(permission.addedAtBlock),
965
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp),
966
+ transactionHash: permission.transactionHash,
967
+ user
795
968
  })
796
969
  });
797
- if (!response.ok) {
798
- throw new Error(
799
- `Subgraph request failed: ${response.status} ${response.statusText}`
800
- );
801
- }
802
- const result = await response.json();
803
- if (result.errors) {
804
- throw new Error(
805
- `Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
806
- );
807
- }
808
- const userData = result.data?.user;
809
- if (!userData || !userData.permissions?.length) {
810
- return [];
811
- }
812
- return userData.permissions.map((permission) => ({
813
- id: permission.id,
814
- grant: permission.grant,
815
- nonce: BigInt(permission.nonce),
816
- signature: permission.signature,
817
- addedAtBlock: BigInt(permission.addedAtBlock),
818
- addedAtTimestamp: BigInt(permission.addedAtTimestamp),
819
- transactionHash: permission.transactionHash,
820
- user
821
- })).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
970
+ return permissions;
822
971
  } catch (error) {
823
972
  console.error("Failed to query user permissions from subgraph:", error);
824
973
  throw error;
@@ -834,7 +983,7 @@ class DataController {
834
983
  async _getUserPermissionsViaRpc(params) {
835
984
  const { user } = params;
836
985
  try {
837
- const chainId = this.context.walletClient.chain?.id;
986
+ const chainId = this.context.publicClient.chain?.id;
838
987
  if (!chainId) {
839
988
  throw new Error("Chain ID not available");
840
989
  }
@@ -951,20 +1100,28 @@ class DataController {
951
1100
  * });
952
1101
  * ```
953
1102
  */
954
- async getUserTrustedServers(params) {
955
- const { user, limit = 50, offset = 0 } = params;
956
- const subgraphUrl = params.subgraphUrl || this.context.subgraphUrl;
1103
+ async getUserTrustedServers(params, options) {
1104
+ const { user } = params;
1105
+ const subgraphUrl = params.subgraphUrl ?? this.context.subgraphUrl;
1106
+ if (subgraphUrl && (options?.minBlock || options?.waitForSync)) {
1107
+ await (0, import_subgraphConsistency.checkSubgraphConsistency)(subgraphUrl, options);
1108
+ }
957
1109
  if (subgraphUrl) {
958
1110
  try {
959
- const servers = await this._getUserTrustedServersViaSubgraph({
960
- user,
961
- subgraphUrl
962
- });
963
- return limit ? servers.slice(offset, offset + limit) : servers;
1111
+ const servers = await this._getUserTrustedServersViaSubgraph(
1112
+ {
1113
+ user,
1114
+ subgraphUrl
1115
+ },
1116
+ options
1117
+ );
1118
+ return servers;
964
1119
  } catch (error) {
965
1120
  console.warn("Subgraph query failed, falling back to RPC:", error);
966
1121
  }
967
1122
  }
1123
+ const limit = options?.fetchAll ? Number.MAX_SAFE_INTEGER : options?.limit ?? 100;
1124
+ const offset = options?.offset ?? 0;
968
1125
  const rpcResult = await this._getUserTrustedServersViaRpc({
969
1126
  user,
970
1127
  limit,
@@ -980,7 +1137,7 @@ class DataController {
980
1137
  * @param params.subgraphUrl - The subgraph URL endpoint to query
981
1138
  * @returns Promise resolving to an array of trusted server objects
982
1139
  */
983
- async _getUserTrustedServersViaSubgraph(params) {
1140
+ async _getUserTrustedServersViaSubgraph(params, options) {
984
1141
  const { user, subgraphUrl } = params;
985
1142
  const graphqlEndpoint = subgraphUrl;
986
1143
  if (!graphqlEndpoint) {
@@ -989,42 +1146,46 @@ class DataController {
989
1146
  );
990
1147
  }
991
1148
  try {
992
- const response = await fetch(graphqlEndpoint, {
993
- method: "POST",
994
- headers: {
995
- "Content-Type": "application/json"
1149
+ const orderByMap = {
1150
+ id: "id",
1151
+ trustedAt: "trustedAt",
1152
+ trustedAtBlock: "trustedAtBlock",
1153
+ server: "server",
1154
+ user: "user"
1155
+ };
1156
+ const serverTrusts = await (0, import_subgraphPagination.executePaginatedQuery)({
1157
+ endpoint: graphqlEndpoint,
1158
+ document: import_subgraph.GetUserTrustedServersPaginatedDocument,
1159
+ baseVariables: {
1160
+ userId: user.toLowerCase(),
1161
+ // Subgraph requires lowercase addresses
1162
+ orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
1163
+ options?.orderBy,
1164
+ orderByMap,
1165
+ "trustedAtBlock"
1166
+ ),
1167
+ orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
1168
+ options?.orderDirection,
1169
+ "desc",
1170
+ "asc"
1171
+ )
996
1172
  },
997
- body: JSON.stringify({
998
- query: (0, import_graphql.print)(import_subgraph.GetUserTrustedServersDocument),
999
- variables: {
1000
- userId: user.toLowerCase()
1001
- // Subgraph requires lowercase addresses
1002
- }
1173
+ options,
1174
+ extractItems: (data) => {
1175
+ const trusts = data?.user?.serverTrusts ?? [];
1176
+ return trusts.filter((trust) => !trust.untrustedAtBlock);
1177
+ },
1178
+ transformItem: (trust) => ({
1179
+ id: trust.server.id,
1180
+ serverAddress: trust.server.serverAddress,
1181
+ serverUrl: trust.server.url,
1182
+ trustedAt: BigInt(trust.trustedAt),
1183
+ user,
1184
+ name: ""
1185
+ // Not available in new schema, will be empty
1003
1186
  })
1004
1187
  });
1005
- if (!response.ok) {
1006
- throw new Error(
1007
- `Subgraph request failed: ${response.status} ${response.statusText}`
1008
- );
1009
- }
1010
- const result = await response.json();
1011
- if (result.errors) {
1012
- throw new Error(
1013
- `Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
1014
- );
1015
- }
1016
- if (!result.data?.user) {
1017
- return [];
1018
- }
1019
- return (result.data.user.serverTrusts || []).filter((trust) => !trust.untrustedAtBlock).map((trust) => ({
1020
- id: trust.server.id,
1021
- serverAddress: trust.server.serverAddress,
1022
- serverUrl: trust.server.url,
1023
- trustedAt: BigInt(trust.trustedAt),
1024
- user,
1025
- name: ""
1026
- // Not available in new schema, will be empty
1027
- }));
1188
+ return serverTrusts;
1028
1189
  } catch (error) {
1029
1190
  console.error("Failed to query trusted servers from subgraph:", error);
1030
1191
  throw error;
@@ -1042,7 +1203,7 @@ class DataController {
1042
1203
  async _getUserTrustedServersViaRpc(params) {
1043
1204
  const { user, limit, offset } = params;
1044
1205
  try {
1045
- const chainId = this.context.walletClient.chain?.id;
1206
+ const chainId = this.context.publicClient.chain?.id;
1046
1207
  if (!chainId) {
1047
1208
  throw new Error("Chain ID not available");
1048
1209
  }
@@ -1126,23 +1287,31 @@ class DataController {
1126
1287
  }
1127
1288
  }
1128
1289
  /**
1129
- * Gets the total number of files in the registry from the contract.
1290
+ * Retrieves total file count from Data Registry.
1291
+ *
1292
+ * @remarks
1293
+ * Queries blockchain for complete file count across all users.
1294
+ * Useful for pagination and network statistics.
1295
+ *
1296
+ * @returns Total number of registered files
1297
+ *
1298
+ * @throws {Error} Chain ID not available.
1299
+ * Ensure network connection.
1300
+ * @throws {Error} Contract read failed.
1301
+ * Check RPC availability.
1130
1302
  *
1131
- * @returns Promise resolving to the total file count
1132
1303
  * @example
1133
1304
  * ```typescript
1134
- * const totalFiles = await vana.data.getTotalFilesCount();
1135
- * console.log(`Total files in registry: ${totalFiles}`);
1305
+ * const total = await vana.data.getTotalFilesCount();
1306
+ * console.log(`Total files: ${total}`);
1136
1307
  *
1137
- * // Use for pagination calculations
1138
- * const filesPerPage = 20;
1139
- * const totalPages = Math.ceil(totalFiles / filesPerPage);
1140
- * console.log(`Total pages: ${totalPages}`);
1308
+ * // Calculate pagination
1309
+ * const pages = Math.ceil(total / 20);
1141
1310
  * ```
1142
1311
  */
1143
1312
  async getTotalFilesCount() {
1144
1313
  try {
1145
- const chainId = this.context.walletClient.chain?.id;
1314
+ const chainId = this.context.publicClient.chain?.id;
1146
1315
  if (!chainId) {
1147
1316
  throw new Error("Chain ID not available");
1148
1317
  }
@@ -1151,7 +1320,7 @@ class DataController {
1151
1320
  const dataRegistry = (0, import_viem.getContract)({
1152
1321
  address: dataRegistryAddress,
1153
1322
  abi: dataRegistryAbi,
1154
- client: this.context.walletClient
1323
+ client: this.context.publicClient
1155
1324
  });
1156
1325
  const count = await dataRegistry.read.filesCount();
1157
1326
  return Number(count);
@@ -1164,36 +1333,36 @@ class DataController {
1164
1333
  }
1165
1334
  }
1166
1335
  /**
1167
- * Retrieves details for a specific file by its ID.
1336
+ * Retrieves file metadata by ID from the blockchain.
1337
+ *
1338
+ * @remarks
1339
+ * Queries DataRegistry contract directly for file details.
1340
+ * Works for any file ID regardless of ownership, enabling
1341
+ * cross-user file discovery and verification.
1342
+ *
1343
+ * @param fileId - Numeric file ID to retrieve
1344
+ *
1345
+ * @returns UserFile object with metadata
1346
+ *
1347
+ * @throws {Error} Chain ID not available.
1348
+ * Ensure proper network connection.
1349
+ * @throws {Error} File not found.
1350
+ * Verify file ID exists on-chain.
1351
+ * @throws {Error} Contract call failed.
1352
+ * Check network and RPC availability.
1168
1353
  *
1169
- * @param fileId - The file ID to look up
1170
- * @returns Promise resolving to UserFile object
1171
- * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1172
- * @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
1173
- * @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
1174
1354
  * @example
1175
1355
  * ```typescript
1176
- * try {
1177
- * const file = await vana.data.getFileById(123);
1178
- * console.log('File details:', {
1179
- * id: file.id,
1180
- * url: file.url,
1181
- * owner: file.ownerAddress,
1182
- * addedAt: file.addedAtBlock
1183
- * });
1184
- * } catch (error) {
1185
- * console.error('File not found or error retrieving file:', error);
1186
- * }
1356
+ * const file = await vana.data.getFileById(123);
1357
+ * console.log(`File ${file.id}:`);
1358
+ * console.log(` URL: ${file.url}`);
1359
+ * console.log(` Owner: ${file.ownerAddress}`);
1360
+ * console.log(` Block: ${file.addedAtBlock}`);
1187
1361
  * ```
1188
- *
1189
- * This method queries the DataRegistry contract directly
1190
- * to get file details for any file ID, regardless of user ownership.
1191
- * This is useful for file lookup functionality where users can search
1192
- * for specific files by ID.
1193
1362
  */
1194
1363
  async getFileById(fileId) {
1195
1364
  try {
1196
- const chainId = this.context.walletClient.chain?.id;
1365
+ const chainId = this.context.publicClient.chain?.id;
1197
1366
  if (!chainId) {
1198
1367
  throw new Error("Chain ID not available");
1199
1368
  }
@@ -1202,7 +1371,7 @@ class DataController {
1202
1371
  const dataRegistry = (0, import_viem.getContract)({
1203
1372
  address: dataRegistryAddress,
1204
1373
  abi: dataRegistryAbi,
1205
- client: this.context.walletClient
1374
+ client: this.context.publicClient
1206
1375
  });
1207
1376
  const fileDetails = await dataRegistry.read.files([BigInt(fileId)]);
1208
1377
  if (!fileDetails) {
@@ -1260,15 +1429,17 @@ class DataController {
1260
1429
  * console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
1261
1430
  * ```
1262
1431
  */
1263
- async registerFileWithSchema(url, schemaId) {
1432
+ async registerFileWithSchema(url, schemaId, options) {
1433
+ this.assertWallet();
1264
1434
  try {
1265
- const chainId = this.context.walletClient.chain?.id;
1435
+ const chainId = this.context.publicClient.chain?.id;
1266
1436
  if (!chainId) {
1267
1437
  throw new Error("Chain ID not available");
1268
1438
  }
1439
+ this.assertWallet();
1269
1440
  const dataRegistryAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
1270
1441
  const dataRegistryAbi = (0, import_abi.getAbi)("DataRegistry");
1271
- const account = this.context.walletClient.account || await this.getUserAddress();
1442
+ const account = this.context.walletClient.account ?? this.context.userAddress;
1272
1443
  const from = typeof account === "string" ? account : account.address;
1273
1444
  const hash = await this.context.walletClient.writeContract({
1274
1445
  address: dataRegistryAddress,
@@ -1276,7 +1447,8 @@ class DataController {
1276
1447
  functionName: "addFileWithSchema",
1277
1448
  args: [url, BigInt(schemaId)],
1278
1449
  account,
1279
- chain: this.context.walletClient.chain || null
1450
+ chain: this.context.walletClient.chain ?? null,
1451
+ ...this.spreadTransactionOptions(options)
1280
1452
  });
1281
1453
  const { tx } = await import("../utils/transactionHelpers");
1282
1454
  return tx({
@@ -1298,13 +1470,6 @@ class DataController {
1298
1470
  * @returns Promise resolving to the user's wallet address
1299
1471
  * @throws {Error} When no addresses are available in wallet client
1300
1472
  */
1301
- async getUserAddress() {
1302
- const addresses = await this.context.walletClient.getAddresses();
1303
- if (addresses.length === 0) {
1304
- throw new Error("No addresses available in wallet client");
1305
- }
1306
- return addresses[0];
1307
- }
1308
1473
  /**
1309
1474
  * Adds a file with permissions to the DataRegistry contract.
1310
1475
  *
@@ -1321,15 +1486,17 @@ class DataController {
1321
1486
  * with specific permissions on the DataRegistry contract. It can be used
1322
1487
  * by both direct transactions and relayer services.
1323
1488
  */
1324
- async addFileWithPermissions(url, ownerAddress, permissions = []) {
1489
+ async addFileWithPermissions(url, ownerAddress, permissions = [], options) {
1490
+ this.assertWallet();
1325
1491
  try {
1326
- const chainId = this.context.walletClient.chain?.id;
1492
+ const chainId = this.context.publicClient.chain?.id;
1327
1493
  if (!chainId) {
1328
1494
  throw new Error("Chain ID not available");
1329
1495
  }
1496
+ this.assertWallet();
1330
1497
  const dataRegistryAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
1331
1498
  const dataRegistryAbi = (0, import_abi.getAbi)("DataRegistry");
1332
- const account = this.context.walletClient.account || ownerAddress;
1499
+ const account = this.context.walletClient.account ?? ownerAddress;
1333
1500
  const from = typeof account === "string" ? account : account.address;
1334
1501
  const hash = await this.context.walletClient.writeContract({
1335
1502
  address: dataRegistryAddress,
@@ -1337,7 +1504,8 @@ class DataController {
1337
1504
  functionName: "addFileWithPermissions",
1338
1505
  args: [url, ownerAddress, permissions],
1339
1506
  account,
1340
- chain: this.context.walletClient.chain || null
1507
+ chain: this.context.walletClient.chain ?? null,
1508
+ ...this.spreadTransactionOptions(options)
1341
1509
  });
1342
1510
  const { tx } = await import("../utils/transactionHelpers");
1343
1511
  return tx({
@@ -1357,25 +1525,133 @@ class DataController {
1357
1525
  * Adds a file to the registry with permissions and schema.
1358
1526
  * This combines the functionality of addFileWithPermissions and schema validation.
1359
1527
  *
1528
+ * @remarks
1529
+ * This method automatically encrypts permissions when a publicKey is provided.
1530
+ * It generates the user's encryption key and encrypts it with each recipient's
1531
+ * public key before registering on the blockchain.
1532
+ *
1360
1533
  * @param url - The URL of the file to register
1361
1534
  * @param ownerAddress - The address of the file owner
1362
- * @param permissions - Array of permissions to grant (account and encrypted key)
1535
+ * @param permissions - Array of permissions to grant, each with account and publicKey properties
1363
1536
  * @param schemaId - The schema ID to associate with the file (0 for no schema)
1364
- * @returns Promise resolving to object with fileId and transactionHash
1537
+ * @returns Promise resolving to TransactionResult with fileId and transactionHash
1538
+ * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1539
+ * @throws {Error} "Failed to generate encryption key" - When encryption key generation fails
1540
+ * @throws {Error} "Permission for {account} must include 'publicKey'" - When publicKey is missing
1541
+ * @throws {Error} "Failed to add file with permissions and schema: {error}" - When transaction fails
1542
+ * @example
1543
+ * ```typescript
1544
+ * // Get server's public key
1545
+ * const serverIdentity = await vana.server.getIdentity({
1546
+ * userAddress: "0x..."
1547
+ * });
1548
+ *
1549
+ * // Add file with permissions and schema
1550
+ * const result = await vana.data.addFileWithPermissionsAndSchema(
1551
+ * "ipfs://QmXxx...",
1552
+ * ownerAddress,
1553
+ * [{
1554
+ * account: serverIdentity.address,
1555
+ * publicKey: serverIdentity.publicKey
1556
+ * }],
1557
+ * schemaId
1558
+ * );
1559
+ *
1560
+ * console.log(`File ${result.fileId} registered in tx ${result.hash}`);
1561
+ * ```
1562
+ */
1563
+ async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1564
+ this.assertWallet();
1565
+ try {
1566
+ let encryptedPermissions = [];
1567
+ if (permissions.length > 0) {
1568
+ this.assertWallet();
1569
+ const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
1570
+ this.context.walletClient,
1571
+ this.context.platform,
1572
+ import_encryption.DEFAULT_ENCRYPTION_SEED
1573
+ );
1574
+ encryptedPermissions = await Promise.all(
1575
+ permissions.map(async (permission) => {
1576
+ if (!permission.publicKey) {
1577
+ throw new Error(
1578
+ `Permission for ${permission.account} must include 'publicKey'`
1579
+ );
1580
+ }
1581
+ const encryptedKey = await (0, import_encryption.encryptWithWalletPublicKey)(
1582
+ userEncryptionKey,
1583
+ permission.publicKey,
1584
+ this.context.platform
1585
+ );
1586
+ return {
1587
+ account: permission.account,
1588
+ key: encryptedKey
1589
+ };
1590
+ })
1591
+ );
1592
+ }
1593
+ return await this.addFileWithEncryptedPermissionsAndSchema(
1594
+ url,
1595
+ ownerAddress,
1596
+ encryptedPermissions,
1597
+ schemaId,
1598
+ options
1599
+ );
1600
+ } catch (error) {
1601
+ console.error("Failed to add file with permissions and schema:", error);
1602
+ throw new Error(
1603
+ `Failed to add file with permissions and schema: ${error instanceof Error ? error.message : "Unknown error"}`
1604
+ );
1605
+ }
1606
+ }
1607
+ /**
1608
+ * Adds a file with pre-encrypted permissions and schema to the DataRegistry.
1609
+ *
1610
+ * @remarks
1611
+ * This method is designed for relay services and advanced use cases where permissions
1612
+ * have already been encrypted client-side. Unlike `addFileWithPermissionsAndSchema()`,
1613
+ * this method expects permissions in the encrypted format with a 'key' field instead
1614
+ * of 'publicKey'.
1615
+ *
1616
+ * This is typically used by relay endpoints that receive pre-encrypted data from
1617
+ * the client SDK's `upload()` method, avoiding double encryption.
1618
+ *
1619
+ * @param url - The storage URL of the file (e.g., IPFS URL)
1620
+ * @param ownerAddress - The address that will own this file
1621
+ * @param permissions - Array of pre-encrypted permissions with 'account' and 'key' fields
1622
+ * @param schemaId - Optional schema ID for data validation (defaults to 0)
1623
+ * @returns Promise resolving to transaction result with hash and contract details
1365
1624
  * @throws {Error} When chain ID is not available
1366
- * @throws {ContractError} When contract execution fails
1367
- * @throws {Error} When transaction receipt is not available
1368
- * @throws {Error} When FileAdded event cannot be parsed
1625
+ * @throws {Error} When wallet is not connected
1626
+ * @throws {Error} When transaction fails
1627
+ * @example
1628
+ * ```typescript
1629
+ * // In a relay endpoint that receives pre-encrypted permissions
1630
+ * const result = await vana.data.addFileWithEncryptedPermissionsAndSchema(
1631
+ * "ipfs://QmXxx...",
1632
+ * ownerAddress,
1633
+ * [
1634
+ * {
1635
+ * account: "0xServerAddress...",
1636
+ * key: "encrypted_key_string" // Already encrypted by client
1637
+ * }
1638
+ * ],
1639
+ * schemaId
1640
+ * );
1641
+ *
1642
+ * console.log(`File registered in tx ${result.hash}`);
1643
+ * ```
1369
1644
  */
1370
- async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1645
+ async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1371
1646
  try {
1372
- const chainId = this.context.walletClient.chain?.id;
1647
+ const chainId = this.context.publicClient.chain?.id;
1373
1648
  if (!chainId) {
1374
1649
  throw new Error("Chain ID not available");
1375
1650
  }
1651
+ this.assertWallet();
1376
1652
  const dataRegistryAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
1377
1653
  const dataRegistryAbi = (0, import_abi.getAbi)("DataRegistry");
1378
- const account = this.context.walletClient.account || ownerAddress;
1654
+ const account = this.context.walletClient.account ?? ownerAddress;
1379
1655
  const from = typeof account === "string" ? account : account.address;
1380
1656
  const hash = await this.context.walletClient.writeContract({
1381
1657
  address: dataRegistryAddress,
@@ -1383,7 +1659,8 @@ class DataController {
1383
1659
  functionName: "addFileWithPermissionsAndSchema",
1384
1660
  args: [url, ownerAddress, permissions, BigInt(schemaId)],
1385
1661
  account,
1386
- chain: this.context.walletClient.chain || null
1662
+ chain: this.context.walletClient.chain ?? null,
1663
+ ...this.spreadTransactionOptions(options)
1387
1664
  });
1388
1665
  const { tx } = await import("../utils/transactionHelpers");
1389
1666
  return tx({
@@ -1400,36 +1677,41 @@ class DataController {
1400
1677
  }
1401
1678
  }
1402
1679
  /**
1403
- * Adds a new refiner to the DataRefinerRegistry.
1680
+ * Registers a data refiner for processing templates.
1404
1681
  *
1405
1682
  * @remarks
1406
- * Refiners are data processing templates that define how raw data should be
1407
- * transformed into structured formats. Each refiner is associated with a DLP
1408
- * (Data Liquidity Pool), has a specific schema for output, and includes
1409
- * instructions for the refinement process.
1410
- *
1411
- * @param params - Refiner configuration parameters
1412
- * @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
1413
- * @param params.name - Human-readable name for the refiner
1414
- * @param params.schemaId - Schema ID that defines the output format
1415
- * @param params.refinementInstructionUrl - URL containing processing instructions
1416
- * @returns Promise resolving to the new refiner ID and transaction hash
1417
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1418
- * @throws {Error} When transaction fails - "Failed to add refiner: {error}"
1683
+ * Refiners define data transformation rules for DLPs.
1684
+ * Associates schema, instructions, and processing logic.
1685
+ *
1686
+ * @param params - Refiner configuration
1687
+ * @param params.dlpId - Data Liquidity Pool ID
1688
+ * @param params.name - Refiner display name
1689
+ * @param params.schemaId - Output schema ID.
1690
+ * Obtain via `vana.schemas.list()`.
1691
+ * @param params.refinementInstructionUrl - Processing instructions URL
1692
+ *
1693
+ * @returns Refiner ID and transaction hash
1694
+ *
1695
+ * @throws {Error} Chain ID not available.
1696
+ * Ensure network connection.
1697
+ * @throws {Error} Transaction failed.
1698
+ * Check wallet balance and network status.
1699
+ *
1419
1700
  * @example
1420
1701
  * ```typescript
1421
1702
  * const result = await vana.data.addRefiner({
1422
1703
  * dlpId: 1,
1423
- * name: "Social Media Sentiment Analyzer",
1704
+ * name: "Sentiment Analyzer",
1424
1705
  * schemaId: 42,
1425
1706
  * refinementInstructionUrl: "ipfs://QmXxx..."
1426
1707
  * });
1427
- * console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
1708
+ * console.log(`Refiner ${result.refinerId} created`);
1428
1709
  * ```
1429
1710
  */
1430
- async addRefiner(params) {
1711
+ async addRefiner(params, options) {
1712
+ this.assertWallet();
1431
1713
  try {
1432
- const chainId = this.context.walletClient.chain?.id;
1714
+ const chainId = this.context.publicClient.chain?.id;
1433
1715
  if (!chainId) {
1434
1716
  throw new Error("Chain ID not available");
1435
1717
  }
@@ -1438,7 +1720,8 @@ class DataController {
1438
1720
  "DataRefinerRegistry"
1439
1721
  );
1440
1722
  const dataRefinerRegistryAbi = (0, import_abi.getAbi)("DataRefinerRegistry");
1441
- const account = this.context.walletClient.account || await this.getUserAddress();
1723
+ this.assertWallet();
1724
+ const account = this.context.walletClient.account ?? this.context.userAddress;
1442
1725
  const from = typeof account === "string" ? account : account.address;
1443
1726
  const hash = await this.context.walletClient.writeContract({
1444
1727
  address: dataRefinerRegistryAddress,
@@ -1451,7 +1734,8 @@ class DataController {
1451
1734
  params.refinementInstructionUrl
1452
1735
  ],
1453
1736
  account,
1454
- chain: this.context.walletClient.chain || null
1737
+ chain: this.context.walletClient.chain ?? null,
1738
+ ...this.spreadTransactionOptions(options)
1455
1739
  });
1456
1740
  const { tx } = await import("../utils/transactionHelpers");
1457
1741
  const txResult = tx({
@@ -1480,31 +1764,34 @@ class DataController {
1480
1764
  }
1481
1765
  }
1482
1766
  /**
1483
- * Retrieves a refiner by its ID.
1767
+ * Retrieves refiner configuration by ID.
1484
1768
  *
1485
1769
  * @remarks
1486
- * Queries the DataRefinerRegistry contract to get complete information about
1487
- * a specific refiner including its DLP association, schema, and instructions.
1770
+ * Queries DataRefinerRegistry for refiner details.
1771
+ * Returns DLP association, schema, and processing instructions.
1772
+ *
1773
+ * @param refinerId - Numeric refiner ID
1774
+ *
1775
+ * @returns Refiner configuration object
1776
+ *
1777
+ * @throws {Error} Chain ID not available.
1778
+ * Ensure network connection.
1779
+ * @throws {Error} Refiner not found.
1780
+ * Verify refiner ID exists.
1781
+ * @throws {Error} Contract read failed.
1782
+ * Check network and RPC status.
1488
1783
  *
1489
- * @param refinerId - The numeric refiner ID to retrieve
1490
- * @returns Promise resolving to the refiner information object
1491
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1492
- * @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
1493
- * @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
1494
1784
  * @example
1495
1785
  * ```typescript
1496
1786
  * const refiner = await vana.data.getRefiner(1);
1497
- * console.log({
1498
- * name: refiner.name,
1499
- * dlp: refiner.dlpId,
1500
- * schema: refiner.schemaId,
1501
- * instructions: refiner.refinementInstructionUrl
1502
- * });
1787
+ * console.log(`Refiner: ${refiner.name}`);
1788
+ * console.log(`DLP: ${refiner.dlpId}`);
1789
+ * console.log(`Schema: ${refiner.schemaId}`);
1503
1790
  * ```
1504
1791
  */
1505
1792
  async getRefiner(refinerId) {
1506
1793
  try {
1507
- const chainId = this.context.walletClient.chain?.id;
1794
+ const chainId = this.context.publicClient.chain?.id;
1508
1795
  if (!chainId) {
1509
1796
  throw new Error("Chain ID not available");
1510
1797
  }
@@ -1516,7 +1803,7 @@ class DataController {
1516
1803
  const dataRefinerRegistry = (0, import_viem.getContract)({
1517
1804
  address: dataRefinerRegistryAddress,
1518
1805
  abi: dataRefinerRegistryAbi,
1519
- client: this.context.walletClient
1806
+ client: this.context.publicClient
1520
1807
  });
1521
1808
  const refinerData = await dataRefinerRegistry.read.refiners([
1522
1809
  BigInt(refinerId)
@@ -1540,27 +1827,33 @@ class DataController {
1540
1827
  }
1541
1828
  }
1542
1829
  /**
1543
- * Validates if a schema ID exists in the registry.
1830
+ * Validates schema ID existence.
1544
1831
  *
1545
1832
  * @remarks
1546
- * Checks the DataRefinerRegistry contract to determine if a given schema ID
1547
- * has been registered and is available for use.
1833
+ * Verifies schema registration in DataRegistry.
1834
+ * Check before using schemas for uploads.
1835
+ *
1836
+ * @param schemaId - Numeric schema ID to validate
1837
+ *
1838
+ * @returns True if schema exists, false otherwise
1839
+ *
1840
+ * @throws {Error} Chain ID not available.
1841
+ * Ensure network connection.
1842
+ * @throws {Error} Contract read failed.
1843
+ * Check RPC availability.
1548
1844
  *
1549
- * @param schemaId - The numeric schema ID to validate
1550
- * @returns Promise resolving to true if schema exists, false otherwise
1551
1845
  * @example
1552
1846
  * ```typescript
1553
- * const isValid = await vana.data.isValidSchemaId(42);
1554
- * if (isValid) {
1555
- * console.log('Schema 42 is available for use');
1556
- * } else {
1557
- * console.log('Schema 42 does not exist');
1847
+ * const valid = await vana.data.isValidSchemaId(42);
1848
+ * if (valid) {
1849
+ * // Safe to use schema 42
1850
+ * await vana.data.upload({ schemaId: 42, ... });
1558
1851
  * }
1559
1852
  * ```
1560
1853
  */
1561
1854
  async isValidSchemaId(schemaId) {
1562
1855
  try {
1563
- const chainId = this.context.walletClient.chain?.id;
1856
+ const chainId = this.context.publicClient.chain?.id;
1564
1857
  if (!chainId) {
1565
1858
  throw new Error("Chain ID not available");
1566
1859
  }
@@ -1572,7 +1865,7 @@ class DataController {
1572
1865
  const dataRefinerRegistry = (0, import_viem.getContract)({
1573
1866
  address: dataRefinerRegistryAddress,
1574
1867
  abi: dataRefinerRegistryAbi,
1575
- client: this.context.walletClient
1868
+ client: this.context.publicClient
1576
1869
  });
1577
1870
  const isValid = await dataRefinerRegistry.read.isValidSchemaId([
1578
1871
  BigInt(schemaId)
@@ -1599,7 +1892,7 @@ class DataController {
1599
1892
  */
1600
1893
  async getRefinersCount() {
1601
1894
  try {
1602
- const chainId = this.context.walletClient.chain?.id;
1895
+ const chainId = this.context.publicClient.chain?.id;
1603
1896
  if (!chainId) {
1604
1897
  throw new Error("Chain ID not available");
1605
1898
  }
@@ -1611,7 +1904,7 @@ class DataController {
1611
1904
  const dataRefinerRegistry = (0, import_viem.getContract)({
1612
1905
  address: dataRefinerRegistryAddress,
1613
1906
  abi: dataRefinerRegistryAbi,
1614
- client: this.context.walletClient
1907
+ client: this.context.publicClient
1615
1908
  });
1616
1909
  const count = await dataRefinerRegistry.read.refinersCount();
1617
1910
  return Number(count);
@@ -1642,9 +1935,10 @@ class DataController {
1642
1935
  * console.log(`Schema updated in tx ${result.transactionHash}`);
1643
1936
  * ```
1644
1937
  */
1645
- async updateSchemaId(params) {
1938
+ async updateSchemaId(params, options) {
1939
+ this.assertWallet();
1646
1940
  try {
1647
- const chainId = this.context.walletClient.chain?.id;
1941
+ const chainId = this.context.publicClient.chain?.id;
1648
1942
  if (!chainId) {
1649
1943
  throw new Error("Chain ID not available");
1650
1944
  }
@@ -1653,14 +1947,16 @@ class DataController {
1653
1947
  "DataRefinerRegistry"
1654
1948
  );
1655
1949
  const dataRefinerRegistryAbi = (0, import_abi.getAbi)("DataRefinerRegistry");
1656
- const account = this.context.walletClient.account || await this.getUserAddress();
1950
+ this.assertWallet();
1951
+ const account = this.context.walletClient.account ?? this.context.userAddress;
1657
1952
  const hash = await this.context.walletClient.writeContract({
1658
1953
  address: dataRefinerRegistryAddress,
1659
1954
  abi: dataRefinerRegistryAbi,
1660
1955
  functionName: "updateSchemaId",
1661
1956
  args: [BigInt(params.refinerId), BigInt(params.newSchemaId)],
1662
1957
  account,
1663
- chain: this.context.walletClient.chain || null
1958
+ chain: this.context.walletClient.chain ?? null,
1959
+ ...this.spreadTransactionOptions(options)
1664
1960
  });
1665
1961
  await this.context.publicClient.waitForTransactionReceipt({ hash });
1666
1962
  return {
@@ -1682,13 +1978,12 @@ class DataController {
1682
1978
  * 3. Encrypts the user's encryption key with the provided public key
1683
1979
  * 4. Registers the file with permissions
1684
1980
  *
1685
- * @param data - The file data to encrypt and upload
1686
- * @param permissions - Array of permissions to grant, each with account address and public key
1687
- * @param filename - Optional filename for the upload
1688
- * @param providerName - Optional storage provider to use
1981
+ * @param params - Upload parameters including data, permissions, and options
1689
1982
  * @returns Promise resolving to upload result with file ID and storage URL
1690
1983
  */
1691
- async uploadFileWithPermissions(data, permissions, filename, providerName) {
1984
+ async uploadFileWithPermissions(params) {
1985
+ this.assertWallet();
1986
+ const { data, permissions, filename, providerName } = params;
1692
1987
  try {
1693
1988
  const uploadResult = await this.uploadToStorage(
1694
1989
  data,
@@ -1697,7 +1992,7 @@ class DataController {
1697
1992
  // Always encrypt for uploadFileWithPermissions
1698
1993
  providerName
1699
1994
  );
1700
- const userAddress = await this.getUserAddress();
1995
+ const userAddress = this.context.userAddress;
1701
1996
  const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
1702
1997
  this.context.walletClient,
1703
1998
  this.context.platform,
@@ -1716,12 +2011,24 @@ class DataController {
1716
2011
  };
1717
2012
  })
1718
2013
  );
1719
- if (this.context.relayerCallbacks?.submitFileAdditionWithPermissions) {
1720
- const result = await this.context.relayerCallbacks.submitFileAdditionWithPermissions(
1721
- uploadResult.url,
1722
- userAddress,
1723
- encryptedPermissions
1724
- );
2014
+ if (this.context.relayer) {
2015
+ const request = {
2016
+ type: "direct",
2017
+ operation: "submitFileAdditionWithPermissions",
2018
+ params: {
2019
+ url: uploadResult.url,
2020
+ userAddress,
2021
+ permissions: encryptedPermissions
2022
+ }
2023
+ };
2024
+ const response = await this.context.relayer(request);
2025
+ if (response.type === "error") {
2026
+ throw new Error(response.error);
2027
+ }
2028
+ if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
2029
+ throw new Error("Invalid response from relayer");
2030
+ }
2031
+ const result = response.result;
1725
2032
  return {
1726
2033
  fileId: result.fileId,
1727
2034
  url: uploadResult.url,
@@ -1734,9 +2041,18 @@ class DataController {
1734
2041
  userAddress,
1735
2042
  encryptedPermissions
1736
2043
  );
2044
+ if (!this.context.waitForTransactionEvents) {
2045
+ throw new Error(
2046
+ "Cannot upload without relay: waitForTransactionEvents not configured"
2047
+ );
2048
+ }
2049
+ const eventResult = await this.context.waitForTransactionEvents(txResult);
2050
+ const fileAddedEvent = eventResult.expectedEvents.FileAdded;
2051
+ if (!fileAddedEvent) {
2052
+ throw new Error("FileAdded event not found in transaction");
2053
+ }
1737
2054
  return {
1738
- fileId: 0,
1739
- // Placeholder - user must wait for events to get actual fileId
2055
+ fileId: Number(fileAddedEvent.fileId),
1740
2056
  url: uploadResult.url,
1741
2057
  size: uploadResult.size,
1742
2058
  transactionHash: txResult.hash
@@ -1779,6 +2095,7 @@ class DataController {
1779
2095
  }
1780
2096
  let finalBlob = blob;
1781
2097
  if (encrypt) {
2098
+ this.assertWallet();
1782
2099
  const encryptionKey = await (0, import_encryption.generateEncryptionKey)(
1783
2100
  this.context.walletClient,
1784
2101
  this.context.platform,
@@ -1800,7 +2117,7 @@ class DataController {
1800
2117
  );
1801
2118
  }
1802
2119
  }
1803
- const finalFilename = filename || `upload-${Date.now()}.dat`;
2120
+ const finalFilename = filename ?? (encrypt ? `upload-${Date.now()}.enc` : `upload-${Date.now()}.dat`);
1804
2121
  const uploadResult = await this.context.storageManager.upload(
1805
2122
  finalBlob,
1806
2123
  finalFilename,
@@ -1825,22 +2142,30 @@ class DataController {
1825
2142
  * For advanced users who need more control over transaction timing,
1826
2143
  * use `submitFilePermission()` instead.
1827
2144
  *
1828
- * @param fileId - The ID of the file to add permissions for
1829
- * @param account - The address of the account to grant permission to
1830
- * @param publicKey - The public key to encrypt the user's encryption key with (hex string with 0x prefix)
2145
+ * @param params - Parameters for adding file permission
2146
+ * @param params.fileId - The ID of the file to grant permission for
2147
+ * @param params.account - The recipient's wallet address that will access the file
2148
+ * @param params.publicKey - The recipient's public key for encryption.
2149
+ * Obtain via `vana.server.getIdentity(account).publicKey`
1831
2150
  * @returns Promise resolving to permission data from PermissionGranted event
1832
2151
  * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
1833
2152
  * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1834
2153
  * @throws {Error} "Failed to add permission to file: {error}" - When transaction fails or user doesn't own file
1835
2154
  * @example
1836
2155
  * ```typescript
1837
- * const result = await vana.data.addPermissionToFile(fileId, account, publicKey);
2156
+ * const result = await vana.data.addPermissionToFile({
2157
+ * fileId: 123,
2158
+ * account: "0xRecipientAddress...",
2159
+ * publicKey: "0xRecipientPublicKey..."
2160
+ * });
1838
2161
  * console.log(`Permission granted to ${result.account} for file ${result.fileId}`);
1839
2162
  * console.log(`Transaction: ${result.transactionHash}`);
1840
2163
  * ```
1841
2164
  */
1842
- async addPermissionToFile(fileId, account, publicKey) {
1843
- return await this.submitFilePermission(fileId, account, publicKey);
2165
+ async addPermissionToFile(params, options) {
2166
+ this.assertWallet();
2167
+ const { fileId, account, publicKey } = params;
2168
+ return await this.submitFilePermission(fileId, account, publicKey, options);
1844
2169
  }
1845
2170
  /**
1846
2171
  * Submits a file permission transaction to the blockchain.
@@ -1853,7 +2178,7 @@ class DataController {
1853
2178
  * @param fileId - The ID of the file to grant permission for
1854
2179
  * @param account - The recipient's wallet address that will access the file
1855
2180
  * @param publicKey - The recipient's public key for encryption.
1856
- * Obtain via `vana.server.getIdentity(account).public_key`
2181
+ * Obtain via `vana.server.getIdentity(account).publicKey`
1857
2182
  * @returns Promise resolving to TransactionResult for tracking the transaction
1858
2183
  * @throws {Error} When chain ID is not available
1859
2184
  * @throws {Error} When encryption key generation fails
@@ -1870,7 +2195,8 @@ class DataController {
1870
2195
  * console.log(`Permission granted with ID: ${result.permissionId}`);
1871
2196
  * ```
1872
2197
  */
1873
- async submitFilePermission(fileId, account, publicKey) {
2198
+ async submitFilePermission(fileId, account, publicKey, options) {
2199
+ this.assertWallet();
1874
2200
  try {
1875
2201
  const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
1876
2202
  this.context.walletClient,
@@ -1882,20 +2208,22 @@ class DataController {
1882
2208
  publicKey,
1883
2209
  this.context.platform
1884
2210
  );
1885
- const chainId = this.context.walletClient.chain?.id;
2211
+ const chainId = this.context.publicClient.chain?.id;
1886
2212
  if (!chainId) {
1887
2213
  throw new Error("Chain ID not available");
1888
2214
  }
1889
2215
  const dataRegistryAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
1890
2216
  const dataRegistryAbi = (0, import_abi.getAbi)("DataRegistry");
1891
- const walletAccount = this.context.walletClient.account || await this.getUserAddress();
2217
+ this.assertWallet();
2218
+ const walletAccount = this.context.walletClient.account ?? this.context.userAddress;
1892
2219
  const txHash = await this.context.walletClient.writeContract({
1893
2220
  address: dataRegistryAddress,
1894
2221
  abi: dataRegistryAbi,
1895
2222
  functionName: "addFilePermission",
1896
2223
  args: [BigInt(fileId), account, encryptedKey],
1897
2224
  account: walletAccount,
1898
- chain: this.context.walletClient.chain || null
2225
+ chain: this.context.walletClient.chain ?? null,
2226
+ ...this.spreadTransactionOptions(options)
1899
2227
  });
1900
2228
  const { tx } = await import("../utils/transactionHelpers");
1901
2229
  return tx({
@@ -1920,7 +2248,7 @@ class DataController {
1920
2248
  */
1921
2249
  async getFilePermission(fileId, account) {
1922
2250
  try {
1923
- const chainId = this.context.walletClient.chain?.id;
2251
+ const chainId = this.context.publicClient.chain?.id;
1924
2252
  if (!chainId) {
1925
2253
  throw new Error("Chain ID not available");
1926
2254
  }
@@ -1929,7 +2257,7 @@ class DataController {
1929
2257
  const dataRegistry = (0, import_viem.getContract)({
1930
2258
  address: dataRegistryAddress,
1931
2259
  abi: dataRegistryAbi,
1932
- client: this.context.walletClient
2260
+ client: this.context.publicClient
1933
2261
  });
1934
2262
  const encryptedKey = await dataRegistry.read.filePermissions([
1935
2263
  BigInt(fileId),
@@ -1953,12 +2281,13 @@ class DataController {
1953
2281
  *
1954
2282
  * @param file - The file to decrypt
1955
2283
  * @param privateKey - The private key to decrypt the user's encryption key
1956
- * @param account - The account address that has permission (defaults to current wallet account)
2284
+ * @param options - Optional decryption configuration
2285
+ * @param options.account - The account address that has permission (defaults to current wallet account)
1957
2286
  * @returns Promise resolving to the decrypted file data
1958
2287
  */
1959
- async decryptFileWithPermission(file, privateKey, account) {
2288
+ async decryptFileWithPermission(file, privateKey, options) {
1960
2289
  try {
1961
- const permissionAccount = account || await this.getUserAddress();
2290
+ const permissionAccount = options?.account ?? this.context.userAddress;
1962
2291
  const encryptedKey = await this.getFilePermission(
1963
2292
  file.id,
1964
2293
  permissionAccount
@@ -2022,11 +2351,8 @@ class DataController {
2022
2351
  */
2023
2352
  async fetch(url) {
2024
2353
  try {
2025
- const { fetchWithRelayer } = await import("../utils/download");
2026
- const response = await fetchWithRelayer(
2027
- url,
2028
- this.context.downloadRelayer
2029
- );
2354
+ const { universalFetch } = await import("../utils/download");
2355
+ const response = await universalFetch(url, this.context.downloadRelayer);
2030
2356
  if (!response.ok) {
2031
2357
  throw new Error(
2032
2358
  `HTTP error! status: ${response.status} ${response.statusText}`
@@ -2091,7 +2417,7 @@ class DataController {
2091
2417
  "https://dweb.link/ipfs/",
2092
2418
  "https://ipfs.io/ipfs/"
2093
2419
  ];
2094
- const gateways = options?.gateways || this.context.ipfsGateways || defaultGateways;
2420
+ const gateways = options?.gateways ?? this.context.ipfsGateways ?? defaultGateways;
2095
2421
  const { extractIpfsHash } = await import("../utils/ipfs");
2096
2422
  const cid = extractIpfsHash(url);
2097
2423
  if (!cid) {
@@ -2220,7 +2546,7 @@ class DataController {
2220
2546
  * ```
2221
2547
  */
2222
2548
  validateDataAgainstSchema(data, schema) {
2223
- return (0, import_schemaValidation.validateDataAgainstSchema)(data, schema);
2549
+ (0, import_schemaValidation.validateDataAgainstSchema)(data, schema);
2224
2550
  }
2225
2551
  /**
2226
2552
  * Fetches and validates a data schema from a URL, then returns the parsed data schema.