@opendatalabs/vana-sdk 0.1.0-alpha.4584bee → 0.1.0-alpha.47bbd13

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 (808) hide show
  1. package/dist/__tests__/waitForTransactionEvents.test.d.ts +1 -0
  2. package/dist/browser.cjs +29 -0
  3. package/dist/browser.cjs.map +1 -0
  4. package/dist/browser.d.ts +36 -0
  5. package/dist/browser.js +5 -0
  6. package/dist/browser.js.map +1 -0
  7. package/dist/chains/definitions.cjs +95 -0
  8. package/dist/chains/definitions.cjs.map +1 -0
  9. package/dist/chains/definitions.d.ts +51 -0
  10. package/dist/chains/definitions.js +67 -0
  11. package/dist/chains/definitions.js.map +1 -0
  12. package/dist/chains/index.cjs +37 -0
  13. package/dist/chains/index.cjs.map +1 -0
  14. package/dist/chains/index.d.ts +34 -0
  15. package/dist/chains/index.js +15 -0
  16. package/dist/chains/index.js.map +1 -0
  17. package/dist/chains.browser.d.ts +8 -0
  18. package/dist/chains.browser.js +15 -0
  19. package/dist/chains.browser.js.map +1 -0
  20. package/dist/chains.cjs +37 -0
  21. package/dist/chains.cjs.map +1 -0
  22. package/dist/chains.d.ts +8 -0
  23. package/dist/chains.js +15 -0
  24. package/dist/chains.js.map +1 -0
  25. package/dist/chains.node.cjs +37 -0
  26. package/dist/chains.node.cjs.map +1 -0
  27. package/dist/chains.node.d.ts +8 -0
  28. package/dist/chains.node.js +15 -0
  29. package/dist/chains.node.js.map +1 -0
  30. package/dist/config/addresses.cjs +325 -0
  31. package/dist/config/addresses.cjs.map +1 -0
  32. package/dist/config/addresses.d.ts +364 -0
  33. package/dist/config/addresses.js +295 -0
  34. package/dist/config/addresses.js.map +1 -0
  35. package/dist/config/chains.cjs +93 -0
  36. package/dist/config/chains.cjs.map +1 -0
  37. package/dist/config/chains.d.ts +180 -0
  38. package/dist/config/chains.js +67 -0
  39. package/dist/config/chains.js.map +1 -0
  40. package/dist/config/default-services.cjs +60 -0
  41. package/dist/config/default-services.cjs.map +1 -0
  42. package/dist/config/default-services.d.ts +46 -0
  43. package/dist/config/default-services.js +33 -0
  44. package/dist/config/default-services.js.map +1 -0
  45. package/dist/config/default-services.test.d.ts +1 -0
  46. package/dist/config/features.cjs +52 -0
  47. package/dist/config/features.cjs.map +1 -0
  48. package/dist/config/features.d.ts +62 -0
  49. package/dist/config/features.js +28 -0
  50. package/dist/config/features.js.map +1 -0
  51. package/dist/config/tests/addresses.test.d.ts +1 -0
  52. package/dist/contracts/contractController.cjs +126 -0
  53. package/dist/contracts/contractController.cjs.map +1 -0
  54. package/dist/contracts/contractController.d.ts +135 -0
  55. package/dist/contracts/contractController.js +100 -0
  56. package/dist/contracts/contractController.js.map +1 -0
  57. package/dist/contracts/tests/contractController.test.d.ts +1 -0
  58. package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
  59. package/dist/controllers/base.cjs +83 -0
  60. package/dist/controllers/base.cjs.map +1 -0
  61. package/dist/controllers/base.d.ts +84 -0
  62. package/dist/controllers/base.js +59 -0
  63. package/dist/controllers/base.js.map +1 -0
  64. package/dist/controllers/data-error-handling.test.d.ts +1 -0
  65. package/dist/controllers/data.cjs +2514 -0
  66. package/dist/controllers/data.cjs.map +1 -0
  67. package/dist/controllers/data.d.ts +1052 -0
  68. package/dist/controllers/data.js +2497 -0
  69. package/dist/controllers/data.js.map +1 -0
  70. package/dist/controllers/permissions.cjs +3971 -0
  71. package/dist/controllers/permissions.cjs.map +1 -0
  72. package/dist/controllers/permissions.d.ts +1304 -0
  73. package/dist/controllers/permissions.js +3947 -0
  74. package/dist/controllers/permissions.js.map +1 -0
  75. package/dist/controllers/protocol.cjs +183 -0
  76. package/dist/controllers/protocol.cjs.map +1 -0
  77. package/dist/controllers/protocol.d.ts +138 -0
  78. package/dist/controllers/protocol.js +163 -0
  79. package/dist/controllers/protocol.js.map +1 -0
  80. package/dist/controllers/schemas.cjs +601 -0
  81. package/dist/controllers/schemas.cjs.map +1 -0
  82. package/dist/controllers/schemas.d.ts +252 -0
  83. package/dist/controllers/schemas.js +577 -0
  84. package/dist/controllers/schemas.js.map +1 -0
  85. package/dist/controllers/server-additional.test.d.ts +1 -0
  86. package/dist/controllers/server.cjs +434 -0
  87. package/dist/controllers/server.cjs.map +1 -0
  88. package/dist/controllers/server.d.ts +225 -0
  89. package/dist/controllers/server.js +415 -0
  90. package/dist/controllers/server.js.map +1 -0
  91. package/dist/core/apiClient.cjs +378 -0
  92. package/dist/core/apiClient.cjs.map +1 -0
  93. package/dist/core/apiClient.d.ts +286 -0
  94. package/dist/core/apiClient.js +359 -0
  95. package/dist/core/apiClient.js.map +1 -0
  96. package/dist/core/client.cjs +70 -0
  97. package/dist/core/client.cjs.map +1 -0
  98. package/dist/core/client.d.ts +89 -0
  99. package/dist/core/client.js +47 -0
  100. package/dist/core/client.js.map +1 -0
  101. package/dist/core/core.test.d.ts +1 -0
  102. package/dist/core/generics.cjs +417 -0
  103. package/dist/core/generics.cjs.map +1 -0
  104. package/dist/core/generics.d.ts +205 -0
  105. package/dist/core/generics.js +386 -0
  106. package/dist/core/generics.js.map +1 -0
  107. package/dist/core/tests/apiClient.test.d.ts +1 -0
  108. package/dist/core/tests/client.test.d.ts +1 -0
  109. package/dist/core/tests/generics.test.d.ts +1 -0
  110. package/dist/core.cjs +723 -0
  111. package/dist/core.cjs.map +1 -0
  112. package/dist/core.d.ts +442 -0
  113. package/dist/core.js +698 -0
  114. package/dist/core.js.map +1 -0
  115. package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
  116. package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
  117. package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
  118. package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
  119. package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
  120. package/dist/crypto/ecies/__tests__/test-vectors.cjs +102 -0
  121. package/dist/crypto/ecies/__tests__/test-vectors.cjs.map +1 -0
  122. package/dist/crypto/ecies/__tests__/test-vectors.d.ts +38 -0
  123. package/dist/crypto/ecies/__tests__/test-vectors.js +77 -0
  124. package/dist/crypto/ecies/__tests__/test-vectors.js.map +1 -0
  125. package/dist/crypto/ecies/base.cjs +232 -0
  126. package/dist/crypto/ecies/base.cjs.map +1 -0
  127. package/dist/crypto/ecies/base.d.ts +140 -0
  128. package/dist/crypto/ecies/base.js +208 -0
  129. package/dist/crypto/ecies/base.js.map +1 -0
  130. package/dist/crypto/ecies/browser.cjs +165 -0
  131. package/dist/crypto/ecies/browser.cjs.map +1 -0
  132. package/dist/crypto/ecies/browser.d.ts +43 -0
  133. package/dist/crypto/ecies/browser.js +131 -0
  134. package/dist/crypto/ecies/browser.js.map +1 -0
  135. package/dist/crypto/ecies/constants.cjs +131 -0
  136. package/dist/crypto/ecies/constants.cjs.map +1 -0
  137. package/dist/crypto/ecies/constants.d.ts +120 -0
  138. package/dist/crypto/ecies/constants.js +101 -0
  139. package/dist/crypto/ecies/constants.js.map +1 -0
  140. package/dist/crypto/ecies/index.cjs +35 -0
  141. package/dist/crypto/ecies/index.cjs.map +1 -0
  142. package/dist/crypto/ecies/index.d.ts +8 -0
  143. package/dist/crypto/ecies/index.js +13 -0
  144. package/dist/crypto/ecies/index.js.map +1 -0
  145. package/dist/crypto/ecies/interface.cjs +87 -0
  146. package/dist/crypto/ecies/interface.cjs.map +1 -0
  147. package/dist/crypto/ecies/interface.d.ts +174 -0
  148. package/dist/crypto/ecies/interface.js +60 -0
  149. package/dist/crypto/ecies/interface.js.map +1 -0
  150. package/dist/crypto/ecies/node.cjs +167 -0
  151. package/dist/crypto/ecies/node.cjs.map +1 -0
  152. package/dist/crypto/ecies/node.d.ts +45 -0
  153. package/dist/crypto/ecies/node.js +139 -0
  154. package/dist/crypto/ecies/node.js.map +1 -0
  155. package/dist/crypto/ecies/test-vectors/eccrypto-vectors.json +72 -0
  156. package/dist/crypto/ecies/utils.cjs +52 -0
  157. package/dist/crypto/ecies/utils.cjs.map +1 -0
  158. package/dist/crypto/ecies/utils.d.ts +30 -0
  159. package/dist/crypto/ecies/utils.js +26 -0
  160. package/dist/crypto/ecies/utils.js.map +1 -0
  161. package/dist/crypto/services/WalletKeyEncryptionService.cjs +128 -0
  162. package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -0
  163. package/dist/crypto/services/WalletKeyEncryptionService.d.ts +88 -0
  164. package/dist/crypto/services/WalletKeyEncryptionService.js +108 -0
  165. package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -0
  166. package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
  167. package/dist/diagnostics.cjs +37 -0
  168. package/dist/diagnostics.cjs.map +1 -0
  169. package/dist/diagnostics.d.ts +24 -0
  170. package/dist/diagnostics.js +13 -0
  171. package/dist/diagnostics.js.map +1 -0
  172. package/dist/diagnostics.test.d.ts +1 -0
  173. package/dist/errors.cjs +157 -0
  174. package/dist/errors.cjs.map +1 -0
  175. package/dist/errors.d.ts +388 -0
  176. package/dist/errors.js +120 -0
  177. package/dist/errors.js.map +1 -0
  178. package/dist/generated/abi/ComputeEngineImplementation.cjs +1313 -0
  179. package/dist/generated/abi/ComputeEngineImplementation.cjs.map +1 -0
  180. package/dist/generated/abi/ComputeEngineImplementation.d.ts +995 -0
  181. package/dist/generated/abi/ComputeEngineImplementation.js +1289 -0
  182. package/dist/generated/abi/ComputeEngineImplementation.js.map +1 -0
  183. package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs +734 -0
  184. package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -0
  185. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +544 -0
  186. package/dist/generated/abi/ComputeInstructionRegistryImplementation.js +710 -0
  187. package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -0
  188. package/dist/generated/abi/DATFactoryImplementation.cjs +882 -0
  189. package/dist/generated/abi/DATFactoryImplementation.cjs.map +1 -0
  190. package/dist/generated/abi/DATFactoryImplementation.d.ts +660 -0
  191. package/dist/generated/abi/DATFactoryImplementation.js +858 -0
  192. package/dist/generated/abi/DATFactoryImplementation.js.map +1 -0
  193. package/dist/generated/abi/DATImplementation.cjs +934 -0
  194. package/dist/generated/abi/DATImplementation.cjs.map +1 -0
  195. package/dist/generated/abi/DATImplementation.d.ts +692 -0
  196. package/dist/generated/abi/DATImplementation.js +910 -0
  197. package/dist/generated/abi/DATImplementation.js.map +1 -0
  198. package/dist/generated/abi/DATPausableImplementation.cjs +1523 -0
  199. package/dist/generated/abi/DATPausableImplementation.cjs.map +1 -0
  200. package/dist/generated/abi/DATPausableImplementation.d.ts +1144 -0
  201. package/dist/generated/abi/DATPausableImplementation.js +1499 -0
  202. package/dist/generated/abi/DATPausableImplementation.js.map +1 -0
  203. package/dist/generated/abi/DATVotesImplementation.cjs +1460 -0
  204. package/dist/generated/abi/DATVotesImplementation.cjs.map +1 -0
  205. package/dist/generated/abi/DATVotesImplementation.d.ts +1094 -0
  206. package/dist/generated/abi/DATVotesImplementation.js +1436 -0
  207. package/dist/generated/abi/DATVotesImplementation.js.map +1 -0
  208. package/dist/generated/abi/DLPPerformanceImplementation.cjs +1160 -0
  209. package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -0
  210. package/dist/generated/abi/DLPPerformanceImplementation.d.ts +882 -0
  211. package/dist/generated/abi/DLPPerformanceImplementation.js +1136 -0
  212. package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -0
  213. package/dist/generated/abi/DLPRegistryImplementation.cjs +1469 -0
  214. package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -0
  215. package/dist/generated/abi/DLPRegistryImplementation.d.ts +1122 -0
  216. package/dist/generated/abi/DLPRegistryImplementation.js +1445 -0
  217. package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -0
  218. package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs +612 -0
  219. package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs.map +1 -0
  220. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +451 -0
  221. package/dist/generated/abi/DLPRegistryTreasuryImplementation.js +588 -0
  222. package/dist/generated/abi/DLPRegistryTreasuryImplementation.js.map +1 -0
  223. package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +948 -0
  224. package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -0
  225. package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +713 -0
  226. package/dist/generated/abi/DLPRewardDeployerImplementation.js +924 -0
  227. package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -0
  228. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs +612 -0
  229. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs.map +1 -0
  230. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +451 -0
  231. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js +588 -0
  232. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js.map +1 -0
  233. package/dist/generated/abi/DLPRewardSwapImplementation.cjs +939 -0
  234. package/dist/generated/abi/DLPRewardSwapImplementation.cjs.map +1 -0
  235. package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +705 -0
  236. package/dist/generated/abi/DLPRewardSwapImplementation.js +915 -0
  237. package/dist/generated/abi/DLPRewardSwapImplementation.js.map +1 -0
  238. package/dist/generated/abi/DLPRootImplementation.cjs +1644 -0
  239. package/dist/generated/abi/DLPRootImplementation.cjs.map +1 -0
  240. package/dist/generated/abi/DLPRootImplementation.d.ts +1246 -0
  241. package/dist/generated/abi/DLPRootImplementation.js +1620 -0
  242. package/dist/generated/abi/DLPRootImplementation.js.map +1 -0
  243. package/dist/generated/abi/DLPTreasuryImplementation.cjs +612 -0
  244. package/dist/generated/abi/DLPTreasuryImplementation.cjs.map +1 -0
  245. package/dist/generated/abi/DLPTreasuryImplementation.d.ts +451 -0
  246. package/dist/generated/abi/DLPTreasuryImplementation.js +588 -0
  247. package/dist/generated/abi/DLPTreasuryImplementation.js.map +1 -0
  248. package/dist/generated/abi/DataLiquidityPoolImplementation.cjs +985 -0
  249. package/dist/generated/abi/DataLiquidityPoolImplementation.cjs.map +1 -0
  250. package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +735 -0
  251. package/dist/generated/abi/DataLiquidityPoolImplementation.js +961 -0
  252. package/dist/generated/abi/DataLiquidityPoolImplementation.js.map +1 -0
  253. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +888 -0
  254. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -0
  255. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +660 -0
  256. package/dist/generated/abi/DataPortabilityGranteesImplementation.js +864 -0
  257. package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -0
  258. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +1317 -0
  259. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -0
  260. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +988 -0
  261. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +1293 -0
  262. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -0
  263. package/dist/generated/abi/DataPortabilityServersImplementation.cjs +1438 -0
  264. package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -0
  265. package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +1085 -0
  266. package/dist/generated/abi/DataPortabilityServersImplementation.js +1414 -0
  267. package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -0
  268. package/dist/generated/abi/DataRefinerRegistryImplementation.cjs +984 -0
  269. package/dist/generated/abi/DataRefinerRegistryImplementation.cjs.map +1 -0
  270. package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +736 -0
  271. package/dist/generated/abi/DataRefinerRegistryImplementation.js +960 -0
  272. package/dist/generated/abi/DataRefinerRegistryImplementation.js.map +1 -0
  273. package/dist/generated/abi/DataRegistryImplementation.cjs +1341 -0
  274. package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -0
  275. package/dist/generated/abi/DataRegistryImplementation.d.ts +1013 -0
  276. package/dist/generated/abi/DataRegistryImplementation.js +1317 -0
  277. package/dist/generated/abi/DataRegistryImplementation.js.map +1 -0
  278. package/dist/generated/abi/QueryEngineImplementation.cjs +1319 -0
  279. package/dist/generated/abi/QueryEngineImplementation.cjs.map +1 -0
  280. package/dist/generated/abi/QueryEngineImplementation.d.ts +1000 -0
  281. package/dist/generated/abi/QueryEngineImplementation.js +1295 -0
  282. package/dist/generated/abi/QueryEngineImplementation.js.map +1 -0
  283. package/dist/generated/abi/SwapHelperImplementation.cjs +1019 -0
  284. package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -0
  285. package/dist/generated/abi/SwapHelperImplementation.d.ts +763 -0
  286. package/dist/generated/abi/SwapHelperImplementation.js +995 -0
  287. package/dist/generated/abi/SwapHelperImplementation.js.map +1 -0
  288. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs +936 -0
  289. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs.map +1 -0
  290. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +700 -0
  291. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js +912 -0
  292. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js.map +1 -0
  293. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs +936 -0
  294. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs.map +1 -0
  295. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +700 -0
  296. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js +912 -0
  297. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js.map +1 -0
  298. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs +936 -0
  299. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs.map +1 -0
  300. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +700 -0
  301. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js +912 -0
  302. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js.map +1 -0
  303. package/dist/generated/abi/TeePoolImplementation.cjs +1313 -0
  304. package/dist/generated/abi/TeePoolImplementation.cjs.map +1 -0
  305. package/dist/generated/abi/TeePoolImplementation.d.ts +992 -0
  306. package/dist/generated/abi/TeePoolImplementation.js +1289 -0
  307. package/dist/generated/abi/TeePoolImplementation.js.map +1 -0
  308. package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs +936 -0
  309. package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs.map +1 -0
  310. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +700 -0
  311. package/dist/generated/abi/TeePoolPersistentGpuImplementation.js +912 -0
  312. package/dist/generated/abi/TeePoolPersistentGpuImplementation.js.map +1 -0
  313. package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs +936 -0
  314. package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs.map +1 -0
  315. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +700 -0
  316. package/dist/generated/abi/TeePoolPersistentStandardImplementation.js +912 -0
  317. package/dist/generated/abi/TeePoolPersistentStandardImplementation.js.map +1 -0
  318. package/dist/generated/abi/TeePoolPhalaImplementation.cjs +1313 -0
  319. package/dist/generated/abi/TeePoolPhalaImplementation.cjs.map +1 -0
  320. package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +992 -0
  321. package/dist/generated/abi/TeePoolPhalaImplementation.js +1289 -0
  322. package/dist/generated/abi/TeePoolPhalaImplementation.js.map +1 -0
  323. package/dist/generated/abi/VanaEpochImplementation.cjs +1188 -0
  324. package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -0
  325. package/dist/generated/abi/VanaEpochImplementation.d.ts +899 -0
  326. package/dist/generated/abi/VanaEpochImplementation.js +1164 -0
  327. package/dist/generated/abi/VanaEpochImplementation.js.map +1 -0
  328. package/dist/generated/abi/VanaPoolEntityImplementation.cjs +1234 -0
  329. package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -0
  330. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +933 -0
  331. package/dist/generated/abi/VanaPoolEntityImplementation.js +1210 -0
  332. package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -0
  333. package/dist/generated/abi/VanaPoolStakingImplementation.cjs +921 -0
  334. package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -0
  335. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +692 -0
  336. package/dist/generated/abi/VanaPoolStakingImplementation.js +897 -0
  337. package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -0
  338. package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs +538 -0
  339. package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs.map +1 -0
  340. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +393 -0
  341. package/dist/generated/abi/VanaPoolTreasuryImplementation.js +514 -0
  342. package/dist/generated/abi/VanaPoolTreasuryImplementation.js.map +1 -0
  343. package/dist/generated/abi/index.cjs +177 -0
  344. package/dist/generated/abi/index.cjs.map +1 -0
  345. package/dist/generated/abi/index.d.ts +26545 -0
  346. package/dist/generated/abi/index.js +120 -0
  347. package/dist/generated/abi/index.js.map +1 -0
  348. package/dist/generated/event-types.cjs +17 -0
  349. package/dist/generated/event-types.cjs.map +1 -0
  350. package/dist/generated/event-types.d.ts +854 -0
  351. package/dist/generated/event-types.js +1 -0
  352. package/dist/generated/event-types.js.map +1 -0
  353. package/dist/generated/eventRegistry.cjs +3351 -0
  354. package/dist/generated/eventRegistry.cjs.map +1 -0
  355. package/dist/generated/eventRegistry.d.ts +14 -0
  356. package/dist/generated/eventRegistry.js +3326 -0
  357. package/dist/generated/eventRegistry.js.map +1 -0
  358. package/dist/generated/server/server-exports.cjs +23 -0
  359. package/dist/generated/server/server-exports.cjs.map +1 -0
  360. package/dist/generated/server/server-exports.d.ts +19 -0
  361. package/dist/generated/server/server-exports.js +2 -0
  362. package/dist/generated/server/server-exports.js.map +1 -0
  363. package/dist/generated/server/server.cjs +17 -0
  364. package/dist/generated/server/server.cjs.map +1 -0
  365. package/dist/generated/server/server.d.ts +538 -0
  366. package/dist/generated/server/server.js +1 -0
  367. package/dist/generated/server/server.js.map +1 -0
  368. package/dist/generated/subgraph.cjs +675 -0
  369. package/dist/generated/subgraph.cjs.map +1 -0
  370. package/dist/generated/subgraph.d.ts +5978 -0
  371. package/dist/generated/subgraph.js +644 -0
  372. package/dist/generated/subgraph.js.map +1 -0
  373. package/dist/index.browser.d.ts +152 -0
  374. package/dist/index.browser.js +118 -0
  375. package/dist/index.browser.js.map +1 -0
  376. package/dist/index.cjs +5 -0
  377. package/dist/index.cjs.map +1 -0
  378. package/dist/index.d.ts +0 -0
  379. package/dist/index.js +4 -0
  380. package/dist/index.js.map +1 -0
  381. package/dist/index.node.cjs +172 -0
  382. package/dist/index.node.cjs.map +1 -0
  383. package/dist/index.node.d.ts +180 -0
  384. package/dist/index.node.js +126 -0
  385. package/dist/index.node.js.map +1 -0
  386. package/dist/node.cjs +29 -0
  387. package/dist/node.cjs.map +1 -0
  388. package/dist/node.d.ts +42 -0
  389. package/dist/node.js +5 -0
  390. package/dist/node.js.map +1 -0
  391. package/dist/platform/browser-only.cjs +37 -0
  392. package/dist/platform/browser-only.cjs.map +1 -0
  393. package/dist/platform/browser-only.d.ts +22 -0
  394. package/dist/platform/browser-only.js +12 -0
  395. package/dist/platform/browser-only.js.map +1 -0
  396. package/dist/platform/browser-only.test.d.ts +1 -0
  397. package/dist/platform/browser-safe.cjs +57 -0
  398. package/dist/platform/browser-safe.cjs.map +1 -0
  399. package/dist/platform/browser-safe.d.ts +29 -0
  400. package/dist/platform/browser-safe.js +31 -0
  401. package/dist/platform/browser-safe.js.map +1 -0
  402. package/dist/platform/browser-safe.test.d.ts +1 -0
  403. package/dist/platform/browser.cjs +488 -0
  404. package/dist/platform/browser.cjs.map +1 -0
  405. package/dist/platform/browser.d.ts +291 -0
  406. package/dist/platform/browser.js +454 -0
  407. package/dist/platform/browser.js.map +1 -0
  408. package/dist/platform/browser.test.d.ts +1 -0
  409. package/dist/platform/index.cjs +50 -0
  410. package/dist/platform/index.cjs.map +1 -0
  411. package/dist/platform/index.d.ts +11 -0
  412. package/dist/platform/index.js +27 -0
  413. package/dist/platform/index.js.map +1 -0
  414. package/dist/platform/interface.cjs +17 -0
  415. package/dist/platform/interface.cjs.map +1 -0
  416. package/dist/platform/interface.d.ts +409 -0
  417. package/dist/platform/interface.js +1 -0
  418. package/dist/platform/interface.js.map +1 -0
  419. package/dist/platform/node.cjs +512 -0
  420. package/dist/platform/node.cjs.map +1 -0
  421. package/dist/platform/node.d.ts +86 -0
  422. package/dist/platform/node.js +481 -0
  423. package/dist/platform/node.js.map +1 -0
  424. package/dist/platform/ports/openpgp-port.cjs +74 -0
  425. package/dist/platform/ports/openpgp-port.cjs.map +1 -0
  426. package/dist/platform/ports/openpgp-port.d.ts +13 -0
  427. package/dist/platform/ports/openpgp-port.js +59 -0
  428. package/dist/platform/ports/openpgp-port.js.map +1 -0
  429. package/dist/platform/ports/pgp-port.cjs +17 -0
  430. package/dist/platform/ports/pgp-port.cjs.map +1 -0
  431. package/dist/platform/ports/pgp-port.d.ts +35 -0
  432. package/dist/platform/ports/pgp-port.js +1 -0
  433. package/dist/platform/ports/pgp-port.js.map +1 -0
  434. package/dist/platform/shared/error-utils.cjs +43 -0
  435. package/dist/platform/shared/error-utils.cjs.map +1 -0
  436. package/dist/platform/shared/error-utils.d.ts +23 -0
  437. package/dist/platform/shared/error-utils.js +18 -0
  438. package/dist/platform/shared/error-utils.js.map +1 -0
  439. package/dist/platform/shared/pgp-utils.cjs +55 -0
  440. package/dist/platform/shared/pgp-utils.cjs.map +1 -0
  441. package/dist/platform/shared/pgp-utils.d.ts +59 -0
  442. package/dist/platform/shared/pgp-utils.js +29 -0
  443. package/dist/platform/shared/pgp-utils.js.map +1 -0
  444. package/dist/platform/shared/stream-utils.cjs +49 -0
  445. package/dist/platform/shared/stream-utils.cjs.map +1 -0
  446. package/dist/platform/shared/stream-utils.d.ts +14 -0
  447. package/dist/platform/shared/stream-utils.js +25 -0
  448. package/dist/platform/shared/stream-utils.js.map +1 -0
  449. package/dist/platform/utils.cjs +114 -0
  450. package/dist/platform/utils.cjs.map +1 -0
  451. package/dist/platform/utils.d.ts +49 -0
  452. package/dist/platform/utils.js +76 -0
  453. package/dist/platform/utils.js.map +1 -0
  454. package/dist/platform/utils.test.d.ts +1 -0
  455. package/dist/platform.browser.d.ts +9 -0
  456. package/dist/platform.browser.js +19 -0
  457. package/dist/platform.browser.js.map +1 -0
  458. package/dist/platform.cjs +50 -0
  459. package/dist/platform.cjs.map +1 -0
  460. package/dist/platform.d.ts +11 -0
  461. package/dist/platform.js +27 -0
  462. package/dist/platform.js.map +1 -0
  463. package/dist/platform.node.cjs +50 -0
  464. package/dist/platform.node.cjs.map +1 -0
  465. package/dist/platform.node.d.ts +10 -0
  466. package/dist/platform.node.js +27 -0
  467. package/dist/platform.node.js.map +1 -0
  468. package/dist/schemas/dataSchema.schema.json +53 -0
  469. package/dist/schemas/grantFile.schema.json +43 -0
  470. package/dist/server/relayerHandler.cjs +214 -0
  471. package/dist/server/relayerHandler.cjs.map +1 -0
  472. package/dist/server/relayerHandler.d.ts +36 -0
  473. package/dist/server/relayerHandler.js +190 -0
  474. package/dist/server/relayerHandler.js.map +1 -0
  475. package/dist/storage/index.cjs +44 -0
  476. package/dist/storage/index.cjs.map +1 -0
  477. package/dist/storage/index.d.ts +56 -0
  478. package/dist/storage/index.js +15 -0
  479. package/dist/storage/index.js.map +1 -0
  480. package/dist/storage/manager.cjs +272 -0
  481. package/dist/storage/manager.cjs.map +1 -0
  482. package/dist/storage/manager.d.ts +241 -0
  483. package/dist/storage/manager.js +248 -0
  484. package/dist/storage/manager.js.map +1 -0
  485. package/dist/storage/providers/callback-storage.cjs +248 -0
  486. package/dist/storage/providers/callback-storage.cjs.map +1 -0
  487. package/dist/storage/providers/callback-storage.d.ts +183 -0
  488. package/dist/storage/providers/callback-storage.js +226 -0
  489. package/dist/storage/providers/callback-storage.js.map +1 -0
  490. package/dist/storage/providers/google-drive.cjs +516 -0
  491. package/dist/storage/providers/google-drive.cjs.map +1 -0
  492. package/dist/storage/providers/google-drive.d.ts +152 -0
  493. package/dist/storage/providers/google-drive.js +494 -0
  494. package/dist/storage/providers/google-drive.js.map +1 -0
  495. package/dist/storage/providers/google-drive.test.d.ts +1 -0
  496. package/dist/storage/providers/ipfs.cjs +283 -0
  497. package/dist/storage/providers/ipfs.cjs.map +1 -0
  498. package/dist/storage/providers/ipfs.d.ts +160 -0
  499. package/dist/storage/providers/ipfs.js +261 -0
  500. package/dist/storage/providers/ipfs.js.map +1 -0
  501. package/dist/storage/providers/pinata.cjs +339 -0
  502. package/dist/storage/providers/pinata.cjs.map +1 -0
  503. package/dist/storage/providers/pinata.d.ts +168 -0
  504. package/dist/storage/providers/pinata.js +317 -0
  505. package/dist/storage/providers/pinata.js.map +1 -0
  506. package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
  507. package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
  508. package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
  509. package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
  510. package/dist/storage/tests/storageManager.test.d.ts +1 -0
  511. package/dist/tests/abi.test.d.ts +1 -0
  512. package/dist/tests/chains-definitions.test.d.ts +1 -0
  513. package/dist/tests/core-encryption.test.d.ts +1 -0
  514. package/dist/tests/core-extended.test.d.ts +1 -0
  515. package/dist/tests/core-generics-coverage.test.d.ts +1 -0
  516. package/dist/tests/coverage-boost.test.d.ts +1 -0
  517. package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
  518. package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
  519. package/dist/tests/data-additional-methods.test.d.ts +1 -0
  520. package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
  521. package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
  522. package/dist/tests/data-relayer.test.d.ts +1 -0
  523. package/dist/tests/data-schema-validation.test.d.ts +1 -0
  524. package/dist/tests/data-simple-methods.test.d.ts +1 -0
  525. package/dist/tests/data.test.d.ts +1 -0
  526. package/dist/tests/demo-integration.test.d.ts +1 -0
  527. package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
  528. package/dist/tests/download-relayer.test.d.ts +1 -0
  529. package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
  530. package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
  531. package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
  532. package/dist/tests/encryption-coverage.test.d.ts +1 -0
  533. package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
  534. package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
  535. package/dist/tests/errors-coverage.test.d.ts +1 -0
  536. package/dist/tests/errors.test.d.ts +1 -0
  537. package/dist/tests/factories/mockFactory.d.ts +316 -0
  538. package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
  539. package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
  540. package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
  541. package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
  542. package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
  543. package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
  544. package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
  545. package/dist/tests/helper-methods.test.d.ts +1 -0
  546. package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
  547. package/dist/tests/helpers/typedMocks.d.ts +64 -0
  548. package/dist/tests/index-browser.test.d.ts +1 -0
  549. package/dist/tests/index-node.test.d.ts +1 -0
  550. package/dist/tests/index.test.d.ts +1 -0
  551. package/dist/tests/mocks/platformAdapter.d.ts +12 -0
  552. package/dist/tests/new-permissions-methods.test.d.ts +1 -0
  553. package/dist/tests/no-buffer-browser.test.d.ts +1 -0
  554. package/dist/tests/permissions-grantee.test.d.ts +1 -0
  555. package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
  556. package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
  557. package/dist/tests/permissions-server-files.test.d.ts +1 -0
  558. package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
  559. package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
  560. package/dist/tests/permissions.test.d.ts +1 -0
  561. package/dist/tests/personal.test.d.ts +1 -0
  562. package/dist/tests/platform-browser.test.d.ts +1 -0
  563. package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
  564. package/dist/tests/platform-crypto.test.d.ts +1 -0
  565. package/dist/tests/platform-index.test.d.ts +1 -0
  566. package/dist/tests/platform-node.test.d.ts +1 -0
  567. package/dist/tests/platform-shared-utils.test.d.ts +1 -0
  568. package/dist/tests/platform-updated.test.d.ts +1 -0
  569. package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
  570. package/dist/tests/protocol.test.d.ts +1 -0
  571. package/dist/tests/read-only-mode.test.d.ts +1 -0
  572. package/dist/tests/relayer-integration.test.d.ts +1 -0
  573. package/dist/tests/relayer-unified.test.d.ts +1 -0
  574. package/dist/tests/schemas.test.d.ts +1 -0
  575. package/dist/tests/server-relayer-handler.test.d.ts +1 -0
  576. package/dist/tests/setup.d.ts +7 -0
  577. package/dist/tests/signatureFormatter.test.d.ts +1 -0
  578. package/dist/tests/trusted-server-queries.test.d.ts +1 -0
  579. package/dist/tests/typedDataConverter.test.d.ts +1 -0
  580. package/dist/tests/types-contracts.test.d.ts +1 -0
  581. package/dist/tests/types-data.test.d.ts +1 -0
  582. package/dist/tests/types-external-apis.test.d.ts +1 -0
  583. package/dist/tests/types-generics.test.d.ts +1 -0
  584. package/dist/tests/types-permissions.test.d.ts +1 -0
  585. package/dist/tests/types-upload-params.test.d.ts +1 -0
  586. package/dist/tests/types.test.d.ts +1 -0
  587. package/dist/tests/utils-formatters.test.d.ts +1 -0
  588. package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
  589. package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
  590. package/dist/tests/utils-grantFiles.test.d.ts +1 -0
  591. package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
  592. package/dist/tests/utils-grants.test.d.ts +1 -0
  593. package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
  594. package/dist/tests/utils-ipfs.test.d.ts +4 -0
  595. package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
  596. package/dist/tests/vana.test.d.ts +1 -0
  597. package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
  598. package/dist/types/blockchain.cjs +17 -0
  599. package/dist/types/blockchain.cjs.map +1 -0
  600. package/dist/types/blockchain.d.ts +85 -0
  601. package/dist/types/blockchain.js +1 -0
  602. package/dist/types/blockchain.js.map +1 -0
  603. package/dist/types/chains-additional.test.d.ts +1 -0
  604. package/dist/types/chains.cjs +36 -0
  605. package/dist/types/chains.cjs.map +1 -0
  606. package/dist/types/chains.d.ts +98 -0
  607. package/dist/types/chains.js +11 -0
  608. package/dist/types/chains.js.map +1 -0
  609. package/dist/types/config.cjs +51 -0
  610. package/dist/types/config.cjs.map +1 -0
  611. package/dist/types/config.d.ts +688 -0
  612. package/dist/types/config.js +23 -0
  613. package/dist/types/config.js.map +1 -0
  614. package/dist/types/contracts.cjs +17 -0
  615. package/dist/types/contracts.cjs.map +1 -0
  616. package/dist/types/contracts.d.ts +129 -0
  617. package/dist/types/contracts.js +1 -0
  618. package/dist/types/contracts.js.map +1 -0
  619. package/dist/types/controller-context.cjs +17 -0
  620. package/dist/types/controller-context.cjs.map +1 -0
  621. package/dist/types/controller-context.d.ts +65 -0
  622. package/dist/types/controller-context.js +1 -0
  623. package/dist/types/controller-context.js.map +1 -0
  624. package/dist/types/data.cjs +17 -0
  625. package/dist/types/data.cjs.map +1 -0
  626. package/dist/types/data.d.ts +760 -0
  627. package/dist/types/data.js +1 -0
  628. package/dist/types/data.js.map +1 -0
  629. package/dist/types/eccrypto-js.d.cjs +2 -0
  630. package/dist/types/eccrypto-js.d.cjs.map +1 -0
  631. package/dist/types/eccrypto-js.d.js +1 -0
  632. package/dist/types/eccrypto-js.d.js.map +1 -0
  633. package/dist/types/external-apis.cjs +61 -0
  634. package/dist/types/external-apis.cjs.map +1 -0
  635. package/dist/types/external-apis.d.ts +184 -0
  636. package/dist/types/external-apis.js +34 -0
  637. package/dist/types/external-apis.js.map +1 -0
  638. package/dist/types/generics.cjs +17 -0
  639. package/dist/types/generics.cjs.map +1 -0
  640. package/dist/types/generics.d.ts +518 -0
  641. package/dist/types/generics.js +1 -0
  642. package/dist/types/generics.js.map +1 -0
  643. package/dist/types/index.cjs +65 -0
  644. package/dist/types/index.cjs.map +1 -0
  645. package/dist/types/index.d.ts +45 -0
  646. package/dist/types/index.js +42 -0
  647. package/dist/types/index.js.map +1 -0
  648. package/dist/types/operations.cjs +65 -0
  649. package/dist/types/operations.cjs.map +1 -0
  650. package/dist/types/operations.d.ts +229 -0
  651. package/dist/types/operations.js +37 -0
  652. package/dist/types/operations.js.map +1 -0
  653. package/dist/types/permissions.cjs +17 -0
  654. package/dist/types/permissions.cjs.map +1 -0
  655. package/dist/types/permissions.d.ts +949 -0
  656. package/dist/types/permissions.js +1 -0
  657. package/dist/types/permissions.js.map +1 -0
  658. package/dist/types/personal.cjs +17 -0
  659. package/dist/types/personal.cjs.map +1 -0
  660. package/dist/types/personal.d.ts +155 -0
  661. package/dist/types/personal.js +1 -0
  662. package/dist/types/personal.js.map +1 -0
  663. package/dist/types/relayer.cjs +17 -0
  664. package/dist/types/relayer.cjs.map +1 -0
  665. package/dist/types/relayer.d.ts +508 -0
  666. package/dist/types/relayer.js +1 -0
  667. package/dist/types/relayer.js.map +1 -0
  668. package/dist/types/storage.cjs +39 -0
  669. package/dist/types/storage.cjs.map +1 -0
  670. package/dist/types/storage.d.ts +117 -0
  671. package/dist/types/storage.js +15 -0
  672. package/dist/types/storage.js.map +1 -0
  673. package/dist/types/transactionResults.cjs +17 -0
  674. package/dist/types/transactionResults.cjs.map +1 -0
  675. package/dist/types/transactionResults.d.ts +193 -0
  676. package/dist/types/transactionResults.js +1 -0
  677. package/dist/types/transactionResults.js.map +1 -0
  678. package/dist/types/utils.cjs +17 -0
  679. package/dist/types/utils.cjs.map +1 -0
  680. package/dist/types/utils.d.ts +820 -0
  681. package/dist/types/utils.js +1 -0
  682. package/dist/types/utils.js.map +1 -0
  683. package/dist/types.cjs +23 -0
  684. package/dist/types.cjs.map +1 -0
  685. package/dist/types.d.ts +30 -0
  686. package/dist/types.js +2 -0
  687. package/dist/types.js.map +1 -0
  688. package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
  689. package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
  690. package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
  691. package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
  692. package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
  693. package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
  694. package/dist/utils/blockchain/registry.cjs +81 -0
  695. package/dist/utils/blockchain/registry.cjs.map +1 -0
  696. package/dist/utils/blockchain/registry.d.ts +32 -0
  697. package/dist/utils/blockchain/registry.js +56 -0
  698. package/dist/utils/blockchain/registry.js.map +1 -0
  699. package/dist/utils/blockchain/registry.test.d.ts +1 -0
  700. package/dist/utils/crypto-utils.cjs +108 -0
  701. package/dist/utils/crypto-utils.cjs.map +1 -0
  702. package/dist/utils/crypto-utils.d.ts +100 -0
  703. package/dist/utils/crypto-utils.js +76 -0
  704. package/dist/utils/crypto-utils.js.map +1 -0
  705. package/dist/utils/crypto-utils.test.d.ts +1 -0
  706. package/dist/utils/download.cjs +69 -0
  707. package/dist/utils/download.cjs.map +1 -0
  708. package/dist/utils/download.d.ts +40 -0
  709. package/dist/utils/download.js +45 -0
  710. package/dist/utils/download.js.map +1 -0
  711. package/dist/utils/encoding.cjs +66 -0
  712. package/dist/utils/encoding.cjs.map +1 -0
  713. package/dist/utils/encoding.d.ts +52 -0
  714. package/dist/utils/encoding.js +39 -0
  715. package/dist/utils/encoding.js.map +1 -0
  716. package/dist/utils/encoding.test.d.ts +1 -0
  717. package/dist/utils/encryption.cjs +176 -0
  718. package/dist/utils/encryption.cjs.map +1 -0
  719. package/dist/utils/encryption.d.ts +271 -0
  720. package/dist/utils/encryption.js +142 -0
  721. package/dist/utils/encryption.js.map +1 -0
  722. package/dist/utils/formatters.cjs +55 -0
  723. package/dist/utils/formatters.cjs.map +1 -0
  724. package/dist/utils/formatters.d.ts +118 -0
  725. package/dist/utils/formatters.js +28 -0
  726. package/dist/utils/formatters.js.map +1 -0
  727. package/dist/utils/grantFiles.cjs +178 -0
  728. package/dist/utils/grantFiles.cjs.map +1 -0
  729. package/dist/utils/grantFiles.d.ts +172 -0
  730. package/dist/utils/grantFiles.js +140 -0
  731. package/dist/utils/grantFiles.js.map +1 -0
  732. package/dist/utils/grantValidation.cjs +243 -0
  733. package/dist/utils/grantValidation.cjs.map +1 -0
  734. package/dist/utils/grantValidation.d.ts +226 -0
  735. package/dist/utils/grantValidation.js +201 -0
  736. package/dist/utils/grantValidation.js.map +1 -0
  737. package/dist/utils/grants.cjs +108 -0
  738. package/dist/utils/grants.cjs.map +1 -0
  739. package/dist/utils/grants.d.ts +148 -0
  740. package/dist/utils/grants.js +82 -0
  741. package/dist/utils/grants.js.map +1 -0
  742. package/dist/utils/ipfs.cjs +130 -0
  743. package/dist/utils/ipfs.cjs.map +1 -0
  744. package/dist/utils/ipfs.d.ts +88 -0
  745. package/dist/utils/ipfs.js +99 -0
  746. package/dist/utils/ipfs.js.map +1 -0
  747. package/dist/utils/lazy-import.cjs +38 -0
  748. package/dist/utils/lazy-import.cjs.map +1 -0
  749. package/dist/utils/lazy-import.d.ts +43 -0
  750. package/dist/utils/lazy-import.js +14 -0
  751. package/dist/utils/lazy-import.js.map +1 -0
  752. package/dist/utils/multicall.cjs +233 -0
  753. package/dist/utils/multicall.cjs.map +1 -0
  754. package/dist/utils/multicall.d.ts +126 -0
  755. package/dist/utils/multicall.js +208 -0
  756. package/dist/utils/multicall.js.map +1 -0
  757. package/dist/utils/parseTransactionPojo.cjs +87 -0
  758. package/dist/utils/parseTransactionPojo.cjs.map +1 -0
  759. package/dist/utils/parseTransactionPojo.d.ts +31 -0
  760. package/dist/utils/parseTransactionPojo.js +63 -0
  761. package/dist/utils/parseTransactionPojo.js.map +1 -0
  762. package/dist/utils/schemaValidation.cjs +258 -0
  763. package/dist/utils/schemaValidation.cjs.map +1 -0
  764. package/dist/utils/schemaValidation.d.ts +168 -0
  765. package/dist/utils/schemaValidation.js +219 -0
  766. package/dist/utils/schemaValidation.js.map +1 -0
  767. package/dist/utils/signatureCache.cjs +192 -0
  768. package/dist/utils/signatureCache.cjs.map +1 -0
  769. package/dist/utils/signatureCache.d.ts +172 -0
  770. package/dist/utils/signatureCache.js +167 -0
  771. package/dist/utils/signatureCache.js.map +1 -0
  772. package/dist/utils/signatureFormatter.cjs +42 -0
  773. package/dist/utils/signatureFormatter.cjs.map +1 -0
  774. package/dist/utils/signatureFormatter.d.ts +36 -0
  775. package/dist/utils/signatureFormatter.js +18 -0
  776. package/dist/utils/signatureFormatter.js.map +1 -0
  777. package/dist/utils/tests/multicall.test.d.ts +1 -0
  778. package/dist/utils/transactionHelpers.cjs +54 -0
  779. package/dist/utils/transactionHelpers.cjs.map +1 -0
  780. package/dist/utils/transactionHelpers.d.ts +80 -0
  781. package/dist/utils/transactionHelpers.js +29 -0
  782. package/dist/utils/transactionHelpers.js.map +1 -0
  783. package/dist/utils/typeGuards.cjs +109 -0
  784. package/dist/utils/typeGuards.cjs.map +1 -0
  785. package/dist/utils/typeGuards.d.ts +138 -0
  786. package/dist/utils/typeGuards.js +74 -0
  787. package/dist/utils/typeGuards.js.map +1 -0
  788. package/dist/utils/typedDataConverter.cjs +43 -0
  789. package/dist/utils/typedDataConverter.cjs.map +1 -0
  790. package/dist/utils/typedDataConverter.d.ts +46 -0
  791. package/dist/utils/typedDataConverter.js +19 -0
  792. package/dist/utils/typedDataConverter.js.map +1 -0
  793. package/dist/utils/urlResolver.cjs +62 -0
  794. package/dist/utils/urlResolver.cjs.map +1 -0
  795. package/dist/utils/urlResolver.d.ts +56 -0
  796. package/dist/utils/urlResolver.js +37 -0
  797. package/dist/utils/urlResolver.js.map +1 -0
  798. package/dist/utils/wallet.cjs +63 -0
  799. package/dist/utils/wallet.cjs.map +1 -0
  800. package/dist/utils/wallet.d.ts +94 -0
  801. package/dist/utils/wallet.js +37 -0
  802. package/dist/utils/wallet.js.map +1 -0
  803. package/dist/utils/withEvents.cjs +44 -0
  804. package/dist/utils/withEvents.cjs.map +1 -0
  805. package/dist/utils/withEvents.d.ts +56 -0
  806. package/dist/utils/withEvents.js +18 -0
  807. package/dist/utils/withEvents.js.map +1 -0
  808. package/package.json +32 -16
@@ -0,0 +1,3947 @@
1
+ import { getAddress } from "viem";
2
+ import { gasAwareMulticall } from "../utils/multicall";
3
+ import {
4
+ RelayerError,
5
+ UserRejectedRequestError,
6
+ SerializationError,
7
+ SignatureError,
8
+ NetworkError,
9
+ NonceError,
10
+ BlockchainError,
11
+ ServerUrlMismatchError,
12
+ PermissionError
13
+ } from "../errors";
14
+ import { getContractAddress } from "../config/addresses";
15
+ import { getAbi } from "../generated/abi";
16
+ import { createGrantFile, getGrantFileHash } from "../utils/grantFiles";
17
+ import { validateGrant } from "../utils/grantValidation";
18
+ import { withSignatureCache } from "../utils/signatureCache";
19
+ import { formatSignatureForContract } from "../utils/signatureFormatter";
20
+ import { toViemTypedDataDefinition } from "../utils/typedDataConverter";
21
+ import { BaseController } from "./base";
22
+ class PermissionsController extends BaseController {
23
+ constructor(context) {
24
+ super(context);
25
+ }
26
+ /**
27
+ * Grants permission for an application to access user data with gasless transactions.
28
+ *
29
+ * This method provides a complete end-to-end permission grant flow that returns
30
+ * the permission ID and other relevant data immediately after successful submission.
31
+ * For advanced users who need more control over the transaction lifecycle, use
32
+ * `submitPermissionGrant()` instead.
33
+ *
34
+ * @param params - The permission grant configuration object
35
+ * @returns Promise resolving to permission data from the PermissionAdded event
36
+ * @throws {RelayerError} When gasless transaction submission fails
37
+ * @throws {SignatureError} When user rejects the signature request
38
+ * @throws {SerializationError} When grant data cannot be serialized
39
+ * @throws {BlockchainError} When permission grant fails or event parsing fails
40
+ * @throws {NetworkError} When transaction confirmation times out
41
+ * @example
42
+ * ```typescript
43
+ * const result = await vana.permissions.grant({
44
+ * grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
45
+ * operation: "llm_inference",
46
+ * parameters: {
47
+ * model: "gpt-4",
48
+ * maxTokens: 1000,
49
+ * temperature: 0.7,
50
+ * },
51
+ * });
52
+ *
53
+ * console.log(`Permission ${result.permissionId} granted to ${result.user}`);
54
+ * console.log(`Transaction: ${result.transactionHash}`);
55
+ *
56
+ * // Can immediately use the permission ID for other operations
57
+ * await vana.permissions.revoke({ permissionId: result.permissionId });
58
+ * ```
59
+ */
60
+ async grant(params) {
61
+ this.assertWallet();
62
+ const { typedData, signature } = await this.createAndSign(params);
63
+ const result = await this.submitSignedGrantWithEvents(typedData, signature);
64
+ return result;
65
+ }
66
+ /**
67
+ * Submits a permission grant transaction and returns a handle for flexible result access.
68
+ *
69
+ * @remarks
70
+ * This lower-level method provides maximum control over transaction timing.
71
+ * Returns a TransactionResult that can be serialized and passed across API boundaries.
72
+ * Use this when handling multiple transactions or when you need granular control.
73
+ *
74
+ * @param params - The permission grant configuration object
75
+ * @returns Promise resolving to TransactionResult with hash and event parsing capabilities
76
+ * @throws {RelayerError} When gasless transaction submission fails
77
+ * @throws {SignatureError} When user rejects the signature request
78
+ * @throws {SerializationError} When grant data cannot be serialized
79
+ * @throws {BlockchainError} When permission grant preparation fails
80
+ * @example
81
+ * ```typescript
82
+ * // Submit transaction and get immediate hash access
83
+ * const tx = await vana.permissions.submitPermissionGrant(params);
84
+ * console.log(`Transaction submitted: ${tx.hash}`);
85
+ *
86
+ * // To wait for events, use SDK's waitForTransactionEvents
87
+ * const eventData = await vana.waitForTransactionEvents(tx.hash);
88
+ * console.log(`Permission ID: ${eventData.permissionId}`);
89
+ * ```
90
+ */
91
+ async submitPermissionGrant(params) {
92
+ this.assertWallet();
93
+ const { typedData, signature } = await this.createAndSign(params);
94
+ return await this.submitSignedGrant(typedData, signature);
95
+ }
96
+ /**
97
+ * Prepares a permission grant with preview before signing.
98
+ *
99
+ * @remarks
100
+ * This method implements a two-phase commit workflow that allows applications
101
+ * to show users a preview of what they're authorizing before requesting a signature.
102
+ * Unlike `createAndSign()`, this method does NOT upload to IPFS or prompt for signatures
103
+ * until the returned `confirm()` function is called.
104
+ * @param params - The permission grant parameters
105
+ * @returns A promise resolving to a preview object and confirm function
106
+ * @throws {SerializationError} When grant parameters are invalid or cannot be serialized
107
+ * @throws {BlockchainError} When grant validation fails or preparation encounters an error
108
+ * @example
109
+ * ```typescript
110
+ * const { preview, confirm } = await vana.permissions.prepareGrant({
111
+ * grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
112
+ * operation: "llm_inference",
113
+ * files: [1, 2, 3],
114
+ * parameters: { model: "gpt-4", prompt: "Analyze my social media data" }
115
+ * });
116
+ *
117
+ * console.log(`Granting ${preview.operation} access to ${preview.files?.length} files`);
118
+ * const transactionHash = await confirm();
119
+ * ```
120
+ */
121
+ async prepareGrant(params) {
122
+ this.assertWallet();
123
+ try {
124
+ const grantFile = createGrantFile(params);
125
+ validateGrant(grantFile);
126
+ return {
127
+ preview: grantFile,
128
+ confirm: async () => {
129
+ return await this.confirmGrantInternalWithEvents(params, grantFile);
130
+ }
131
+ };
132
+ } catch (error) {
133
+ if (error instanceof Error) {
134
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
135
+ throw error;
136
+ }
137
+ throw new BlockchainError(
138
+ `Permission grant preparation failed: ${error.message}`,
139
+ error
140
+ );
141
+ }
142
+ throw new BlockchainError(
143
+ "Permission grant preparation failed with unknown error"
144
+ );
145
+ }
146
+ }
147
+ /**
148
+ * Completes the grant process after user confirmation.
149
+ *
150
+ * @remarks
151
+ * This internal method is called by the confirm() function returned from prepareGrant().
152
+ * It handles IPFS upload, signature creation, and transaction submission.
153
+ *
154
+ * @param params - The permission grant parameters containing user and operation details
155
+ * @param grantFile - The prepared grant file with permissions and metadata
156
+ * @returns Promise resolving to TransactionResult for flexible result access
157
+ * @throws {BlockchainError} When permission grant confirmation fails
158
+ * @throws {NetworkError} When IPFS upload fails
159
+ * @throws {SignatureError} When user rejects the signature
160
+ */
161
+ async confirmGrantInternal(params, grantFile) {
162
+ try {
163
+ let { grantUrl } = params;
164
+ console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
165
+ if (!grantUrl) {
166
+ const canStoreViaRelayer = this.context.relayer !== void 0;
167
+ if (!canStoreViaRelayer && !this.context.storageManager) {
168
+ if (this.context.validateStorageRequired) {
169
+ this.context.validateStorageRequired();
170
+ } else {
171
+ throw new Error(
172
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
173
+ );
174
+ }
175
+ }
176
+ if (canStoreViaRelayer && this.context.relayer) {
177
+ const request = {
178
+ type: "direct",
179
+ operation: "storeGrantFile",
180
+ params: grantFile
181
+ };
182
+ const response = await this.context.relayer(request);
183
+ if (response.type === "error") {
184
+ throw new Error(response.error);
185
+ }
186
+ if (response.type === "direct" && typeof response.result === "object" && "url" in response.result) {
187
+ grantUrl = response.result.url;
188
+ } else {
189
+ throw new Error("Invalid response from relayer for grant storage");
190
+ }
191
+ } else if (this.context.storageManager) {
192
+ const blob = new Blob([JSON.stringify(grantFile)], {
193
+ type: "application/json"
194
+ });
195
+ const result = await this.context.storageManager.upload(
196
+ blob,
197
+ `grant-${Date.now()}.json`
198
+ );
199
+ grantUrl = result.url;
200
+ }
201
+ if (!grantUrl) {
202
+ throw new Error("Failed to store grant file - no URL returned");
203
+ }
204
+ }
205
+ const nonce = await this.getPermissionsUserNonce();
206
+ console.debug(
207
+ "\u{1F50D} Debug - Final grant URL being passed to compose:",
208
+ grantUrl
209
+ );
210
+ const typedData = await this.composePermissionGrantMessage({
211
+ grantee: params.grantee,
212
+ operation: params.operation,
213
+ // Placeholder - real data is in IPFS
214
+ files: params.files,
215
+ // Placeholder - real data is in IPFS
216
+ grantUrl,
217
+ serializedParameters: getGrantFileHash(grantFile),
218
+ // Hash as placeholder
219
+ nonce
220
+ });
221
+ const signature = await this.signTypedData(typedData);
222
+ return await this.submitSignedGrant(typedData, signature);
223
+ } catch (error) {
224
+ if (error instanceof Error) {
225
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
226
+ throw error;
227
+ }
228
+ throw new BlockchainError(
229
+ `Permission grant confirmation failed: ${error.message}`,
230
+ error
231
+ );
232
+ }
233
+ throw new BlockchainError(
234
+ "Permission grant confirmation failed with unknown error"
235
+ );
236
+ }
237
+ }
238
+ /**
239
+ * Creates typed data and signature for a permission grant without submitting.
240
+ *
241
+ * @remarks
242
+ * This method handles the first phase of permission granting: creating the grant file,
243
+ * storing it on IPFS, and generating the user's EIP-712 signature. Use this when you
244
+ * want to handle submission separately or batch multiple operations. The method validates
245
+ * the grant file against the JSON schema before creating the signature.
246
+ *
247
+ * For interactive user flows, consider using `prepareGrant()` instead,
248
+ * which allows showing a preview before signing.
249
+ * @param params - The permission grant configuration object
250
+ * @returns A promise resolving to the typed data structure and signature for gasless submission
251
+ * @throws {SignatureError} When the user rejects the signature request
252
+ * @throws {SerializationError} When grant data cannot be properly formatted
253
+ * @throws {BlockchainError} When permission grant preparation fails
254
+ * @throws {NetworkError} When storage operations fail
255
+ * @example
256
+ * ```typescript
257
+ * const { typedData, signature } = await vana.permissions.createAndSign({
258
+ * grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
259
+ * operation: "data_analysis",
260
+ * parameters: { analysisType: "sentiment" },
261
+ * });
262
+ *
263
+ * const transactionHash = await vana.permissions.submitSignedGrant(typedData, signature);
264
+ * ```
265
+ */
266
+ async createAndSign(params) {
267
+ this.assertWallet();
268
+ try {
269
+ const grantFile = createGrantFile(params);
270
+ validateGrant(grantFile);
271
+ let { grantUrl } = params;
272
+ console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
273
+ if (!grantUrl) {
274
+ const canStoreViaRelayer = this.context.relayer !== void 0;
275
+ if (!canStoreViaRelayer && !this.context.storageManager) {
276
+ if (this.context.validateStorageRequired) {
277
+ this.context.validateStorageRequired();
278
+ } else {
279
+ throw new Error(
280
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
281
+ );
282
+ }
283
+ }
284
+ if (canStoreViaRelayer && this.context.relayer) {
285
+ const request = {
286
+ type: "direct",
287
+ operation: "storeGrantFile",
288
+ params: grantFile
289
+ };
290
+ const response = await this.context.relayer(request);
291
+ if (response.type === "error") {
292
+ throw new Error(response.error);
293
+ }
294
+ if (response.type === "direct" && typeof response.result === "object" && "url" in response.result) {
295
+ grantUrl = response.result.url;
296
+ } else {
297
+ throw new Error("Invalid response from relayer for grant storage");
298
+ }
299
+ } else if (this.context.storageManager) {
300
+ const blob = new Blob([JSON.stringify(grantFile)], {
301
+ type: "application/json"
302
+ });
303
+ const result = await this.context.storageManager.upload(
304
+ blob,
305
+ `grant-${Date.now()}.json`
306
+ );
307
+ grantUrl = result.url;
308
+ }
309
+ if (!grantUrl) {
310
+ throw new Error("Failed to store grant file - no URL returned");
311
+ }
312
+ }
313
+ const nonce = await this.getPermissionsUserNonce();
314
+ console.debug(
315
+ "\u{1F50D} Debug - Final grant URL being passed to compose:",
316
+ grantUrl
317
+ );
318
+ const typedData = await this.composePermissionGrantMessage({
319
+ grantee: params.grantee,
320
+ operation: params.operation,
321
+ // Placeholder - real data is in IPFS
322
+ files: params.files,
323
+ // Placeholder - real data is in IPFS
324
+ grantUrl,
325
+ serializedParameters: getGrantFileHash(grantFile),
326
+ // Hash as placeholder
327
+ nonce
328
+ });
329
+ const signature = await this.signTypedData(typedData);
330
+ return { typedData, signature };
331
+ } catch (error) {
332
+ if (error instanceof Error) {
333
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
334
+ throw error;
335
+ }
336
+ throw new BlockchainError(
337
+ `Permission grant preparation failed: ${error.message}`,
338
+ error
339
+ );
340
+ }
341
+ throw new BlockchainError(
342
+ "Permission grant preparation failed with unknown error"
343
+ );
344
+ }
345
+ }
346
+ /**
347
+ * Submits an already-signed permission grant to the blockchain.
348
+ *
349
+ * @remarks
350
+ * This method supports both relayer-based gasless transactions and direct transactions.
351
+ * It automatically converts `bigint` values to JSON-safe strings when using relayer
352
+ * callbacks and handles transaction submission with proper error handling and retry logic.
353
+ * @param typedData - The EIP-712 typed data structure for the permission grant
354
+ * @param signature - The user's signature as a hex string
355
+ * @returns A Promise that resolves to the transaction hash
356
+ * @throws {RelayerError} When gasless transaction submission fails
357
+ * @throws {BlockchainError} When permission submission fails
358
+ * @throws {NetworkError} When network communication fails
359
+ * @example
360
+ * ```typescript
361
+ * const txHash = await vana.permissions.submitSignedGrant(
362
+ * typedData,
363
+ * "0x1234..."
364
+ * );
365
+ * ```
366
+ */
367
+ async submitSignedGrant(typedData, signature) {
368
+ try {
369
+ console.debug(
370
+ "\u{1F50D} Debug - submitSignedGrant called with typed data:",
371
+ JSON.stringify(
372
+ typedData,
373
+ (_key, value) => typeof value === "bigint" ? value.toString() : value,
374
+ 2
375
+ )
376
+ );
377
+ if (this.context.relayer) {
378
+ const response = await this.context.relayer({
379
+ type: "signed",
380
+ operation: "submitAddPermission",
381
+ typedData,
382
+ signature,
383
+ expectedUserAddress: this.context.userAddress
384
+ });
385
+ let hash;
386
+ if (response.type === "signed") {
387
+ hash = response.hash;
388
+ } else if (response.type === "error") {
389
+ throw new Error(`Relayer error: ${response.error}`);
390
+ } else {
391
+ throw new Error(
392
+ "Invalid response from relayer: expected signed transaction"
393
+ );
394
+ }
395
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
396
+ const { tx } = await import("../utils/transactionHelpers");
397
+ return tx({
398
+ hash,
399
+ from: typeof account === "string" ? account : account.address,
400
+ contract: "DataPortabilityPermissions",
401
+ fn: "addPermission"
402
+ });
403
+ } else {
404
+ return await this.submitDirectTransaction(typedData, signature);
405
+ }
406
+ } catch (error) {
407
+ if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
408
+ throw error;
409
+ }
410
+ throw new BlockchainError(
411
+ `Permission submission failed: ${error instanceof Error ? error.message : "Unknown error"}`,
412
+ error
413
+ );
414
+ }
415
+ }
416
+ /**
417
+ * Submits an already-signed trust server transaction to the blockchain.
418
+ *
419
+ * @remarks
420
+ * This method extracts the trust server input from typed data and submits it directly.
421
+ * Used internally by trust server methods after signature collection.
422
+ *
423
+ * @param typedData - The EIP-712 typed data for TrustServer
424
+ * @param signature - The user's signature obtained via `signTypedData()`
425
+ * @returns Promise resolving to TransactionResult for transaction tracking
426
+ * @throws {BlockchainError} When contract submission fails
427
+ * @throws {NetworkError} When blockchain communication fails
428
+ * @example
429
+ * ```typescript
430
+ * const txHandle = await vana.permissions.submitSignedTrustServer(
431
+ * typedData,
432
+ * "0x1234..."
433
+ * );
434
+ * const result = await txHandle.waitForEvents();
435
+ * ```
436
+ */
437
+ async submitSignedTrustServer(typedData, signature) {
438
+ try {
439
+ const trustServerInput = {
440
+ nonce: BigInt(typedData.message.nonce),
441
+ serverId: typedData.message.serverId
442
+ };
443
+ const hash = await this.submitTrustServerTransaction(
444
+ trustServerInput,
445
+ signature
446
+ );
447
+ const account = this.context.userAddress;
448
+ const { tx } = await import("../utils/transactionHelpers");
449
+ return tx({
450
+ hash,
451
+ from: account,
452
+ contract: "DataPortabilityServers",
453
+ fn: "trustServerWithSignature"
454
+ });
455
+ } catch (error) {
456
+ if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
457
+ throw error;
458
+ }
459
+ if (error instanceof Error && error.message.includes("ServerUrlMismatch")) {
460
+ const match = error.message.match(
461
+ /ServerUrlMismatch\(string existingUrl, string providedUrl\)\s+\(([^,]+),\s*([^)]+)\)/
462
+ );
463
+ if (match) {
464
+ const existingUrl = match[1].trim();
465
+ const providedUrl = match[2].trim();
466
+ throw new ServerUrlMismatchError(
467
+ existingUrl,
468
+ providedUrl,
469
+ typedData.message.serverId.toString()
470
+ );
471
+ }
472
+ }
473
+ throw new BlockchainError(
474
+ `Trust server submission failed: ${error instanceof Error ? error.message : "Unknown error"}`,
475
+ error
476
+ );
477
+ }
478
+ }
479
+ /**
480
+ * Submits an already-signed add and trust server transaction to the blockchain.
481
+ *
482
+ * @remarks
483
+ * This method extracts the add and trust server input from typed data and submits it directly.
484
+ * Combines server registration and trust operations in a single transaction.
485
+ *
486
+ * @param typedData - The EIP-712 typed data for AddAndTrustServer
487
+ * @param signature - The user's signature obtained via `signTypedData()`
488
+ * @returns Promise resolving to TransactionResult for transaction tracking
489
+ * @throws {BlockchainError} When contract submission fails
490
+ * @throws {NetworkError} When blockchain communication fails
491
+ * @example
492
+ * ```typescript
493
+ * const txHandle = await vana.permissions.submitSignedAddAndTrustServer(
494
+ * typedData,
495
+ * "0x1234..."
496
+ * );
497
+ * const result = await txHandle.waitForEvents();
498
+ * ```
499
+ */
500
+ async submitSignedAddAndTrustServer(typedData, signature) {
501
+ try {
502
+ const addAndTrustServerInput = {
503
+ nonce: BigInt(typedData.message.nonce),
504
+ serverAddress: typedData.message.serverAddress,
505
+ serverUrl: typedData.message.serverUrl,
506
+ publicKey: typedData.message.publicKey
507
+ };
508
+ const hash = await this.submitAddAndTrustServerTransaction(
509
+ addAndTrustServerInput,
510
+ signature
511
+ );
512
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
513
+ const { tx } = await import("../utils/transactionHelpers");
514
+ return tx({
515
+ hash,
516
+ from: typeof account === "string" ? account : account.address,
517
+ contract: "DataPortabilityServers",
518
+ fn: "addAndTrustServerWithSignature"
519
+ });
520
+ } catch (error) {
521
+ if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
522
+ throw error;
523
+ }
524
+ throw new BlockchainError(
525
+ `Add and trust server submission failed444444: ${error instanceof Error ? error.message : "Unknown error"}`,
526
+ error
527
+ );
528
+ }
529
+ }
530
+ /**
531
+ * Internal method to submit a signed grant and wait for events.
532
+ *
533
+ * @internal
534
+ * @param typedData - The EIP-712 typed data for the permission grant
535
+ * @param signature - The user's signature authorizing the transaction
536
+ * @returns Promise resolving to PermissionGrantResult with parsed events
537
+ */
538
+ async submitSignedGrantWithEvents(typedData, signature) {
539
+ const txResult = await this.submitSignedGrant(typedData, signature);
540
+ if (!this.context.waitForTransactionEvents) {
541
+ throw new BlockchainError("waitForTransactionEvents not configured");
542
+ }
543
+ const result = await this.context.waitForTransactionEvents(txResult);
544
+ const event = result.expectedEvents.PermissionAdded;
545
+ if (!event) {
546
+ throw new BlockchainError(
547
+ "PermissionAdded event not found in transaction"
548
+ );
549
+ }
550
+ const receipt = await this.context.publicClient.getTransactionReceipt({
551
+ hash: result.hash
552
+ });
553
+ return {
554
+ transactionHash: result.hash,
555
+ blockNumber: receipt.blockNumber,
556
+ gasUsed: receipt.gasUsed,
557
+ permissionId: event.permissionId,
558
+ user: event.user,
559
+ grant: event.grant,
560
+ fileIds: event.fileIds
561
+ };
562
+ }
563
+ /**
564
+ * Internal method for confirm grant with events.
565
+ *
566
+ * @internal
567
+ * @param params - The permission grant parameters
568
+ * @param grantFile - The pre-created grant file object
569
+ * @returns Promise resolving to PermissionGrantResult with parsed events
570
+ */
571
+ async confirmGrantInternalWithEvents(params, grantFile) {
572
+ const txResult = await this.confirmGrantInternal(params, grantFile);
573
+ if (!this.context.waitForTransactionEvents) {
574
+ throw new BlockchainError("waitForTransactionEvents not configured");
575
+ }
576
+ const result = await this.context.waitForTransactionEvents(txResult);
577
+ const event = result.expectedEvents.PermissionAdded;
578
+ if (!event) {
579
+ throw new BlockchainError(
580
+ "PermissionAdded event not found in transaction"
581
+ );
582
+ }
583
+ const receipt = await this.context.publicClient.getTransactionReceipt({
584
+ hash: result.hash
585
+ });
586
+ return {
587
+ transactionHash: result.hash,
588
+ blockNumber: receipt.blockNumber,
589
+ gasUsed: receipt.gasUsed,
590
+ permissionId: event.permissionId,
591
+ user: event.user,
592
+ grant: event.grant,
593
+ fileIds: event.fileIds
594
+ };
595
+ }
596
+ /**
597
+ * Submits an already-signed permission revoke transaction to the blockchain.
598
+ *
599
+ * @remarks
600
+ * This method handles the revocation of previously granted permissions.
601
+ * Used internally by revocation methods after signature collection.
602
+ *
603
+ * @param typedData - The EIP-712 typed data for PermissionRevoke
604
+ * @param signature - The user's signature obtained via `signTypedData()`
605
+ * @returns Promise resolving to TransactionResult for transaction tracking
606
+ * @throws {BlockchainError} When contract submission fails
607
+ * @throws {NetworkError} When blockchain communication fails
608
+ * @example
609
+ * ```typescript
610
+ * const txHandle = await vana.permissions.submitSignedRevoke(
611
+ * typedData,
612
+ * "0x1234..."
613
+ * );
614
+ * const result = await txHandle.waitForEvents();
615
+ * ```
616
+ */
617
+ async submitSignedRevoke(typedData, signature) {
618
+ try {
619
+ let hash;
620
+ if (this.context.relayer) {
621
+ const response = await this.context.relayer({
622
+ type: "signed",
623
+ operation: "submitPermissionRevoke",
624
+ typedData,
625
+ signature,
626
+ expectedUserAddress: this.context.userAddress
627
+ });
628
+ if (response.type === "signed") {
629
+ hash = response.hash;
630
+ } else if (response.type === "error") {
631
+ throw new Error(`Relayer error: ${response.error}`);
632
+ } else {
633
+ throw new Error(
634
+ "Invalid response from relayer: expected signed transaction"
635
+ );
636
+ }
637
+ } else {
638
+ hash = await this.submitDirectRevokeTransaction(
639
+ typedData,
640
+ signature
641
+ );
642
+ }
643
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
644
+ const { tx } = await import("../utils/transactionHelpers");
645
+ return tx({
646
+ hash,
647
+ from: typeof account === "string" ? account : account.address,
648
+ contract: "DataPortabilityPermissions",
649
+ fn: "revokePermissionWithSignature"
650
+ });
651
+ } catch (error) {
652
+ if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
653
+ throw error;
654
+ }
655
+ throw new BlockchainError(
656
+ `Permission revoke submission failed: ${error instanceof Error ? error.message : "Unknown error"}`,
657
+ error
658
+ );
659
+ }
660
+ }
661
+ /**
662
+ * Submits an already-signed untrust server transaction to the blockchain.
663
+ *
664
+ * @remarks
665
+ * This method handles the removal of trusted servers.
666
+ * Used internally by untrust server methods after signature collection.
667
+ *
668
+ * @param typedData - The EIP-712 typed data for UntrustServer
669
+ * @param signature - The user's signature obtained via `signTypedData()`
670
+ * @returns Promise resolving to TransactionResult for transaction tracking
671
+ * @throws {BlockchainError} When contract submission fails
672
+ * @throws {NetworkError} When blockchain communication fails
673
+ * @example
674
+ * ```typescript
675
+ * const txHandle = await vana.permissions.submitSignedUntrustServer(
676
+ * typedData,
677
+ * "0x1234..."
678
+ * );
679
+ * const result = await txHandle.waitForEvents();
680
+ * ```
681
+ */
682
+ async submitSignedUntrustServer(typedData, signature) {
683
+ try {
684
+ let hash;
685
+ if (this.context.relayer) {
686
+ const response = await this.context.relayer({
687
+ type: "signed",
688
+ operation: "submitUntrustServer",
689
+ typedData,
690
+ signature,
691
+ expectedUserAddress: this.context.userAddress
692
+ });
693
+ if (response.type === "signed") {
694
+ hash = response.hash;
695
+ } else if (response.type === "error") {
696
+ throw new Error(`Relayer error: ${response.error}`);
697
+ } else {
698
+ throw new Error(
699
+ "Invalid response from relayer: expected signed transaction"
700
+ );
701
+ }
702
+ } else {
703
+ hash = await this.submitSignedUntrustTransaction(
704
+ typedData,
705
+ signature
706
+ );
707
+ }
708
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
709
+ const { tx } = await import("../utils/transactionHelpers");
710
+ return tx({
711
+ hash,
712
+ from: typeof account === "string" ? account : account.address,
713
+ contract: "DataPortabilityServers",
714
+ fn: "untrustServerWithSignature"
715
+ });
716
+ } catch (error) {
717
+ if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
718
+ throw error;
719
+ }
720
+ throw new BlockchainError(
721
+ `Untrust server submission failed: ${error instanceof Error ? error.message : "Unknown error"}`,
722
+ error
723
+ );
724
+ }
725
+ }
726
+ /**
727
+ * Submits a signed transaction directly to the blockchain.
728
+ *
729
+ * @remarks
730
+ * Internal method used when relayer callbacks are not available. Formats the signature
731
+ * and submits the permission grant directly to the smart contract.
732
+ *
733
+ * @param typedData - The typed data structure for the permission grant
734
+ * @param signature - The cryptographic signature authorizing the transaction
735
+ * @returns Promise resolving to the transaction hash
736
+ * @throws {BlockchainError} When contract submission fails
737
+ */
738
+ async submitDirectTransaction(typedData, signature) {
739
+ this.assertWallet();
740
+ const chainId = await this.context.publicClient.getChainId();
741
+ const DataPortabilityPermissionsAddress = getContractAddress(
742
+ chainId,
743
+ "DataPortabilityPermissions"
744
+ );
745
+ const DataPortabilityPermissionsAbi = getAbi("DataPortabilityPermissions");
746
+ const permissionInput = {
747
+ nonce: typedData.message.nonce,
748
+ granteeId: typedData.message.granteeId,
749
+ grant: typedData.message.grant,
750
+ fileIds: typedData.message.fileIds
751
+ };
752
+ console.debug("\u{1F50D} Debug - Permission input being sent to contract:", {
753
+ nonce: permissionInput.nonce.toString(),
754
+ grant: permissionInput.grant,
755
+ fileIds: permissionInput.fileIds.map((id) => id.toString())
756
+ });
757
+ console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
758
+ console.debug(
759
+ "\u{1F50D} Debug - Grant field length:",
760
+ typedData.message.grant?.length ?? 0
761
+ );
762
+ const formattedSignature = formatSignatureForContract(signature);
763
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
764
+ const txHash = await this.context.walletClient.writeContract({
765
+ address: DataPortabilityPermissionsAddress,
766
+ abi: DataPortabilityPermissionsAbi,
767
+ functionName: "addPermission",
768
+ args: [permissionInput, formattedSignature],
769
+ account,
770
+ chain: this.context.walletClient?.chain ?? null
771
+ });
772
+ const { tx } = await import("../utils/transactionHelpers");
773
+ return tx({
774
+ hash: txHash,
775
+ from: typeof account === "string" ? account : account.address,
776
+ contract: "DataPortabilityPermissions",
777
+ fn: "addPermission"
778
+ });
779
+ }
780
+ /**
781
+ * Revokes a previously granted permission.
782
+ *
783
+ * This method provides complete revocation with automatic event parsing to confirm
784
+ * the permission was successfully revoked. For advanced users who need more control,
785
+ * use `submitPermissionRevoke()` instead.
786
+ *
787
+ * @param params - Parameters for revoking the permission
788
+ * @param params.permissionId - Permission identifier (accepts bigint, number, or string).
789
+ * Obtain from permission grants via `getUserPermissionGrantsOnChain()`.
790
+ * @returns Promise resolving to revocation data from PermissionRevoked event
791
+ * @throws {BlockchainError} When revocation fails or event parsing fails
792
+ * @throws {UserRejectedRequestError} When user rejects the transaction
793
+ * @throws {NetworkError} When transaction confirmation times out
794
+ * @example
795
+ * ```typescript
796
+ * // Revoke a permission and get confirmation
797
+ * const result = await vana.permissions.revoke({
798
+ * permissionId: 123n
799
+ * });
800
+ * console.log(`Permission ${result.permissionId} revoked in transaction ${result.transactionHash}`);
801
+ * console.log(`Revoked in block ${result.blockNumber}`);
802
+ * ```
803
+ */
804
+ async revoke(params) {
805
+ this.assertWallet();
806
+ const txResult = await this.submitPermissionRevoke(params);
807
+ if (!this.context.waitForTransactionEvents) {
808
+ throw new BlockchainError("waitForTransactionEvents not configured");
809
+ }
810
+ const result = await this.context.waitForTransactionEvents(txResult);
811
+ const event = result.expectedEvents.PermissionRevoked;
812
+ if (!event) {
813
+ throw new BlockchainError(
814
+ "PermissionRevoked event not found in transaction"
815
+ );
816
+ }
817
+ const receipt = await this.context.publicClient.getTransactionReceipt({
818
+ hash: result.hash
819
+ });
820
+ return {
821
+ transactionHash: result.hash,
822
+ blockNumber: receipt.blockNumber,
823
+ gasUsed: receipt.gasUsed,
824
+ permissionId: event.permissionId
825
+ };
826
+ }
827
+ /**
828
+ * Submits a permission revocation transaction and returns the transaction hash immediately.
829
+ *
830
+ * This is the lower-level method that provides maximum control over transaction timing.
831
+ * Use this when you want to handle transaction confirmation and event parsing separately.
832
+ *
833
+ * @param params - Parameters for revoking the permission
834
+ * @param options - Optional transaction options for gas parameters and timeout
835
+ * @returns Promise resolving to the transaction hash when successfully submitted
836
+ * @throws {BlockchainError} When revocation transaction fails
837
+ * @throws {UserRejectedRequestError} When user rejects the transaction
838
+ * @example
839
+ * ```typescript
840
+ * // Submit revocation and handle confirmation later
841
+ * const txHash = await vana.permissions.submitPermissionRevoke({
842
+ * permissionId: 123n
843
+ * });
844
+ * console.log(`Revocation submitted: ${txHash}`);
845
+ * ```
846
+ */
847
+ async submitPermissionRevoke(params, options) {
848
+ this.assertWallet();
849
+ try {
850
+ if (!this.context.walletClient?.chain?.id) {
851
+ throw new BlockchainError("Chain ID not available");
852
+ }
853
+ const chainId = await this.context.publicClient.getChainId();
854
+ const DataPortabilityPermissionsAddress = getContractAddress(
855
+ chainId,
856
+ "DataPortabilityPermissions"
857
+ );
858
+ const DataPortabilityPermissionsAbi = getAbi(
859
+ "DataPortabilityPermissions"
860
+ );
861
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
862
+ const txHash = await this.context.walletClient.writeContract({
863
+ address: DataPortabilityPermissionsAddress,
864
+ abi: DataPortabilityPermissionsAbi,
865
+ functionName: "revokePermission",
866
+ args: [params.permissionId],
867
+ account,
868
+ chain: this.context.walletClient?.chain ?? null,
869
+ ...options?.gasLimit && { gas: options.gasLimit },
870
+ ...options?.nonce && { nonce: options.nonce },
871
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
872
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
873
+ ...options.maxFeePerGas && {
874
+ maxFeePerGas: options.maxFeePerGas
875
+ },
876
+ ...options.maxPriorityFeePerGas && {
877
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
878
+ }
879
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
880
+ });
881
+ const { tx } = await import("../utils/transactionHelpers");
882
+ return tx({
883
+ hash: txHash,
884
+ from: typeof account === "string" ? account : account.address,
885
+ contract: "DataPortabilityPermissions",
886
+ fn: "revokePermission"
887
+ });
888
+ } catch (error) {
889
+ if (error instanceof Error) {
890
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
891
+ throw error;
892
+ }
893
+ throw new BlockchainError(
894
+ `Permission revoke failed: ${error.message}`,
895
+ error
896
+ );
897
+ }
898
+ throw new BlockchainError("Permission revoke failed with unknown error");
899
+ }
900
+ }
901
+ /**
902
+ * Revokes a permission with a signature for gasless transactions.
903
+ *
904
+ * @remarks
905
+ * This method creates an EIP-712 signature for permission revocation and submits
906
+ * it either through relayer callbacks or directly to the blockchain. Provides
907
+ * gasless revocation when relayer is configured.
908
+ *
909
+ * @param params - Parameters for revoking the permission
910
+ * @param params.permissionId - Permission identifier to revoke (accepts bigint, number, or string)
911
+ * @returns Promise resolving to TransactionResult for transaction tracking
912
+ * @throws {BlockchainError} When chain ID is not available
913
+ * @throws {NonceError} When retrieving user nonce fails
914
+ * @throws {SignatureError} When user rejects the signature request
915
+ * @throws {RelayerError} When gasless submission fails
916
+ * @throws {PermissionError} When revocation fails for any other reason
917
+ * @example
918
+ * ```typescript
919
+ * const txHandle = await vana.permissions.submitRevokeWithSignature({
920
+ * permissionId: 123n
921
+ * });
922
+ * const result = await txHandle.waitForEvents();
923
+ * console.log(`Permission ${result.permissionId} revoked`);
924
+ * ```
925
+ */
926
+ async submitRevokeWithSignature(params) {
927
+ this.assertWallet();
928
+ try {
929
+ if (!this.context.walletClient?.chain?.id) {
930
+ throw new BlockchainError("Chain ID not available");
931
+ }
932
+ const nonce = await this.getPermissionsUserNonce();
933
+ const revokePermissionInput = {
934
+ nonce,
935
+ permissionId: params.permissionId
936
+ };
937
+ const typedData = {
938
+ domain: await this.getPermissionDomain(),
939
+ types: {
940
+ RevokePermission: [
941
+ { name: "nonce", type: "uint256" },
942
+ { name: "permissionId", type: "uint256" }
943
+ ]
944
+ },
945
+ primaryType: "RevokePermission",
946
+ message: revokePermissionInput
947
+ };
948
+ const signature = await this.signTypedData(typedData);
949
+ let hash;
950
+ if (this.context.relayer) {
951
+ const response = await this.context.relayer({
952
+ type: "signed",
953
+ operation: "submitPermissionRevoke",
954
+ typedData,
955
+ signature,
956
+ expectedUserAddress: this.context.userAddress
957
+ });
958
+ if (response.type === "signed") {
959
+ hash = response.hash;
960
+ } else if (response.type === "error") {
961
+ throw new Error(`Relayer error: ${response.error}`);
962
+ } else {
963
+ throw new Error(
964
+ "Invalid response from relayer: expected signed transaction"
965
+ );
966
+ }
967
+ } else {
968
+ hash = await this.submitDirectRevokeTransaction(
969
+ typedData,
970
+ signature
971
+ );
972
+ }
973
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
974
+ const { tx } = await import("../utils/transactionHelpers");
975
+ return tx({
976
+ hash,
977
+ from: typeof account === "string" ? account : account.address,
978
+ contract: "DataPortabilityPermissions",
979
+ fn: "revokePermissionWithSignature"
980
+ });
981
+ } catch (error) {
982
+ throw new PermissionError(
983
+ `Failed to revoke permission with signature: ${error instanceof Error ? error.message : "Unknown error"}`,
984
+ error
985
+ );
986
+ }
987
+ }
988
+ /**
989
+ * Retrieves the user's current nonce from the DataPortabilityServers contract.
990
+ * This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
991
+ *
992
+ * @returns Promise resolving to the current servers nonce
993
+ * @throws {NonceError} When reading nonce from contract fails
994
+ * @private
995
+ *
996
+ * @example
997
+ * ```typescript
998
+ * const nonce = await this.getServersUserNonce();
999
+ * console.log(`Current servers nonce: ${nonce}`);
1000
+ * ```
1001
+ */
1002
+ /**
1003
+ * Retrieves the user's current nonce from the DataPortabilityServers contract.
1004
+ *
1005
+ * @remarks
1006
+ * Used for server-related operations (trust/untrust) to prevent replay attacks.
1007
+ * The nonce must be incremented with each server operation.
1008
+ *
1009
+ * @returns Promise resolving to the user's current nonce as a bigint
1010
+ * @throws {NonceError} When retrieving the nonce fails
1011
+ */
1012
+ async getServersUserNonce() {
1013
+ try {
1014
+ const userAddress = this.context.userAddress;
1015
+ const chainId = await this.context.publicClient.getChainId();
1016
+ const DataPortabilityServersAddress = getContractAddress(
1017
+ chainId,
1018
+ "DataPortabilityServers"
1019
+ );
1020
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1021
+ const [nonce] = await this.context.publicClient.readContract({
1022
+ address: DataPortabilityServersAddress,
1023
+ abi: DataPortabilityServersAbi,
1024
+ functionName: "users",
1025
+ args: [userAddress]
1026
+ });
1027
+ return nonce;
1028
+ } catch (error) {
1029
+ throw new NonceError(
1030
+ `Failed to retrieve server nonce: ${error instanceof Error ? error.message : "Unknown error"}`
1031
+ );
1032
+ }
1033
+ }
1034
+ /**
1035
+ * Retrieves the user's current nonce from the DataPortabilityPermissions contract.
1036
+ * This nonce is used for permission-related operations (addPermission, addServerFilesAndPermissions).
1037
+ *
1038
+ * @returns Promise resolving to the current permissions nonce
1039
+ * @throws {NonceError} When reading nonce from contract fails
1040
+ * @private
1041
+ *
1042
+ * @example
1043
+ * ```typescript
1044
+ * const nonce = await this.getPermissionsUserNonce();
1045
+ * console.log(`Current permissions nonce: ${nonce}`);
1046
+ * ```
1047
+ */
1048
+ /**
1049
+ * Retrieves the user's current nonce from the DataPortabilityPermissions contract.
1050
+ *
1051
+ * @remarks
1052
+ * Used for permission-related operations (grant/revoke) to prevent replay attacks.
1053
+ * The nonce must be incremented with each permission operation.
1054
+ *
1055
+ * @returns Promise resolving to the user's current nonce as a bigint
1056
+ * @throws {NonceError} When retrieving the nonce fails
1057
+ */
1058
+ async getPermissionsUserNonce() {
1059
+ try {
1060
+ const userAddress = this.context.userAddress;
1061
+ const chainId = await this.context.publicClient.getChainId();
1062
+ const DataPortabilityPermissionsAddress = getContractAddress(
1063
+ chainId,
1064
+ "DataPortabilityPermissions"
1065
+ );
1066
+ const DataPortabilityPermissionsAbi = getAbi(
1067
+ "DataPortabilityPermissions"
1068
+ );
1069
+ const nonce = await this.context.publicClient.readContract({
1070
+ address: DataPortabilityPermissionsAddress,
1071
+ abi: DataPortabilityPermissionsAbi,
1072
+ functionName: "userNonce",
1073
+ args: [userAddress]
1074
+ });
1075
+ return nonce;
1076
+ } catch (error) {
1077
+ throw new NonceError(
1078
+ `Failed to retrieve permissions nonce: ${error instanceof Error ? error.message : "Unknown error"}`
1079
+ );
1080
+ }
1081
+ }
1082
+ /**
1083
+ * Composes the EIP-712 typed data for PermissionGrant (new simplified format).
1084
+ *
1085
+ * @param params - The parameters for composing the permission grant message
1086
+ * @param params.grantee - The recipient address for the permission grant
1087
+ * @param params.operation - The type of operation being granted permission for
1088
+ * @param params.files - Array of file IDs that the permission applies to
1089
+ * @param params.grantUrl - URL where the grant details are stored
1090
+ * @param params.serializedParameters - Serialized parameters for the operation
1091
+ * @param params.nonce - Unique number to prevent replay attacks
1092
+ * @returns Promise resolving to the typed data structure
1093
+ */
1094
+ async composePermissionGrantMessage(params) {
1095
+ const domain = await this.getPermissionDomain();
1096
+ console.debug(
1097
+ "\u{1F50D} Debug - Composing permission message with grantUrl:",
1098
+ params.grantUrl
1099
+ );
1100
+ const chainId = await this.context.publicClient.getChainId();
1101
+ const DataPortabilityGranteesAddress = getContractAddress(
1102
+ chainId,
1103
+ "DataPortabilityGrantees"
1104
+ );
1105
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
1106
+ const granteeId = await this.context.publicClient.readContract({
1107
+ address: DataPortabilityGranteesAddress,
1108
+ abi: DataPortabilityGranteesAbi,
1109
+ functionName: "granteeAddressToId",
1110
+ args: [params.grantee]
1111
+ });
1112
+ if (!params.grantUrl.startsWith("ipfs://") && params.grantUrl.includes("/ipfs/")) {
1113
+ const { extractIpfsHash } = await import("../utils/ipfs");
1114
+ const hash = extractIpfsHash(params.grantUrl);
1115
+ if (hash) {
1116
+ console.warn(
1117
+ `\u26A0\uFE0F Storing HTTP gateway URL on-chain instead of ipfs:// protocol. Found: ${params.grantUrl}. Consider using ipfs://${hash} for better protocol-agnostic on-chain storage.`
1118
+ );
1119
+ }
1120
+ }
1121
+ return {
1122
+ domain,
1123
+ types: {
1124
+ Permission: [
1125
+ { name: "nonce", type: "uint256" },
1126
+ { name: "granteeId", type: "uint256" },
1127
+ { name: "grant", type: "string" },
1128
+ { name: "fileIds", type: "uint256[]" }
1129
+ ]
1130
+ },
1131
+ primaryType: "Permission",
1132
+ message: {
1133
+ nonce: params.nonce,
1134
+ granteeId,
1135
+ grant: params.grantUrl,
1136
+ fileIds: params.files.map((fileId) => BigInt(fileId))
1137
+ }
1138
+ };
1139
+ }
1140
+ /**
1141
+ * Creates EIP-712 typed data structure for server files and permissions.
1142
+ *
1143
+ * @param params - Parameters for the server files and permissions message
1144
+ * @param params.granteeId - Grantee ID
1145
+ * @param params.grant - Grant URL or grant data
1146
+ * @param params.fileUrls - Array of file URLs
1147
+ * @param params.schemaIds - Schema IDs for each file
1148
+ * @param params.serverAddress - Server address
1149
+ * @param params.serverUrl - Server URL
1150
+ * @param params.serverPublicKey - Server public key
1151
+ * @param params.filePermissions - File permissions array
1152
+ * @param params.nonce - Unique number to prevent replay attacks
1153
+ * @returns Promise resolving to the typed data structure
1154
+ */
1155
+ async composeServerFilesAndPermissionMessage(params) {
1156
+ const domain = await this.getPermissionDomain();
1157
+ console.debug(
1158
+ "\u{1F50D} Debug - Composing server files and permission message with grant:",
1159
+ params.grant
1160
+ );
1161
+ if (!params.grant.startsWith("ipfs://") && params.grant.includes("/ipfs/")) {
1162
+ const { extractIpfsHash } = await import("../utils/ipfs");
1163
+ const hash = extractIpfsHash(params.grant);
1164
+ if (hash) {
1165
+ console.warn(
1166
+ `\u26A0\uFE0F Storing HTTP gateway URL on-chain instead of ipfs:// protocol. Found: ${params.grant}. Consider using ipfs://${hash} for better protocol-agnostic on-chain storage.`
1167
+ );
1168
+ }
1169
+ }
1170
+ return {
1171
+ domain,
1172
+ types: {
1173
+ Permission: [
1174
+ { name: "account", type: "address" },
1175
+ { name: "key", type: "string" }
1176
+ ],
1177
+ ServerFilesAndPermission: [
1178
+ { name: "nonce", type: "uint256" },
1179
+ { name: "granteeId", type: "uint256" },
1180
+ { name: "grant", type: "string" },
1181
+ { name: "fileUrls", type: "string[]" },
1182
+ { name: "schemaIds", type: "uint256[]" },
1183
+ { name: "serverAddress", type: "address" },
1184
+ { name: "serverUrl", type: "string" },
1185
+ { name: "serverPublicKey", type: "string" },
1186
+ { name: "filePermissions", type: "Permission[][]" }
1187
+ ]
1188
+ },
1189
+ primaryType: "ServerFilesAndPermission",
1190
+ message: {
1191
+ nonce: params.nonce,
1192
+ granteeId: params.granteeId,
1193
+ grant: params.grant,
1194
+ fileUrls: params.fileUrls,
1195
+ schemaIds: params.schemaIds.map((id) => BigInt(id)),
1196
+ serverAddress: params.serverAddress,
1197
+ serverUrl: params.serverUrl,
1198
+ serverPublicKey: params.serverPublicKey,
1199
+ filePermissions: params.filePermissions
1200
+ }
1201
+ };
1202
+ }
1203
+ /**
1204
+ * Gets the EIP-712 domain for PermissionGrant signatures.
1205
+ *
1206
+ * @returns Promise resolving to the EIP-712 domain configuration
1207
+ */
1208
+ async getPermissionDomain() {
1209
+ const chainId = await this.context.publicClient.getChainId();
1210
+ const DataPortabilityPermissionsAddress = getContractAddress(
1211
+ chainId,
1212
+ "DataPortabilityPermissions"
1213
+ );
1214
+ return {
1215
+ name: "VanaDataPortabilityPermissions",
1216
+ version: "1",
1217
+ chainId,
1218
+ verifyingContract: DataPortabilityPermissionsAddress
1219
+ };
1220
+ }
1221
+ /**
1222
+ * Signs typed data using the wallet client with signature caching.
1223
+ *
1224
+ * @param typedData - The EIP-712 typed data structure to sign
1225
+ * @returns Promise resolving to the cryptographic signature
1226
+ */
1227
+ async signTypedData(typedData) {
1228
+ this.assertWallet();
1229
+ try {
1230
+ const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
1231
+ return await withSignatureCache(
1232
+ this.context.platform.cache,
1233
+ walletAddress,
1234
+ typedData,
1235
+ async () => {
1236
+ const viemCompatibleTypedData = toViemTypedDataDefinition(typedData);
1237
+ return await this.context.walletClient.signTypedData({
1238
+ ...viemCompatibleTypedData,
1239
+ // Use the account if available, otherwise use the wallet address
1240
+ // This follows the same pattern used throughout this file
1241
+ account: this.context.walletClient.account ?? walletAddress
1242
+ });
1243
+ }
1244
+ );
1245
+ } catch (error) {
1246
+ if (error instanceof Error && error.message.includes("rejected")) {
1247
+ throw new UserRejectedRequestError();
1248
+ }
1249
+ throw new SignatureError(
1250
+ `Failed to sign typed data: ${error instanceof Error ? error.message : "Unknown error"}`,
1251
+ error
1252
+ );
1253
+ }
1254
+ }
1255
+ /**
1256
+ * Gets the user's address from the context.
1257
+ *
1258
+ * @returns The user's address
1259
+ */
1260
+ /**
1261
+ * Gets on-chain permission grant data without expensive off-chain resolution.
1262
+ *
1263
+ * @remarks
1264
+ * This method provides a fast, performance-focused way to retrieve permission grants
1265
+ * by querying only the subgraph without making expensive IPFS or individual contract calls.
1266
+ * It eliminates the N+1 query problem of the legacy `getUserPermissions()` method.
1267
+ *
1268
+ * The returned data contains all on-chain information but does NOT include resolved
1269
+ * operation details, parameters, or file IDs. Use `retrieveGrantFile()` separately
1270
+ * for specific grants when detailed data is needed.
1271
+ *
1272
+ * **Performance**: Completes in ~100-500ms regardless of permission count.
1273
+ * **Reliability**: Single point of failure (subgraph) with clear RPC fallback path.
1274
+ *
1275
+ * @param options - Options for retrieving permissions (limit, subgraph URL)
1276
+ * @returns A Promise that resolves to an array of `OnChainPermissionGrant` objects
1277
+ * @throws {BlockchainError} When subgraph query fails
1278
+ * @throws {NetworkError} When network requests fail
1279
+ * @example
1280
+ * ```typescript
1281
+ * // Fast: Get all on-chain permission data
1282
+ * const grants = await vana.permissions.getUserPermissionGrantsOnChain({ limit: 20 });
1283
+ *
1284
+ * // Display in UI immediately
1285
+ * grants.forEach(grant => {
1286
+ * console.log(`Permission ${grant.id}: ${grant.grantUrl}`);
1287
+ * });
1288
+ *
1289
+ * // Lazy load detailed data for specific permission when user clicks
1290
+ * const grantFile = await retrieveGrantFile(grants[0].grantUrl);
1291
+ * console.log(`Operation: ${grantFile.operation}`);
1292
+ * console.log(`Parameters:`, grantFile.parameters);
1293
+ * ```
1294
+ */
1295
+ async getUserPermissionGrantsOnChain(options = {}) {
1296
+ const { limit = 50, subgraphUrl } = options;
1297
+ try {
1298
+ const userAddress = this.context.userAddress;
1299
+ const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
1300
+ if (!graphqlEndpoint) {
1301
+ throw new BlockchainError(
1302
+ "subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
1303
+ );
1304
+ }
1305
+ const query = `
1306
+ query GetUserPermissions($userId: ID!) {
1307
+ user(id: $userId) {
1308
+ id
1309
+ permissions {
1310
+ id
1311
+ grant
1312
+ nonce
1313
+ signature
1314
+ startBlock
1315
+ endBlock
1316
+ addedAtBlock
1317
+ addedAtTimestamp
1318
+ transactionHash
1319
+ grantee {
1320
+ id
1321
+ address
1322
+ }
1323
+ }
1324
+ }
1325
+ }
1326
+ `;
1327
+ const response = await fetch(graphqlEndpoint, {
1328
+ method: "POST",
1329
+ headers: {
1330
+ "Content-Type": "application/json"
1331
+ },
1332
+ body: JSON.stringify({
1333
+ query,
1334
+ variables: {
1335
+ userId: userAddress.toLowerCase()
1336
+ }
1337
+ })
1338
+ });
1339
+ if (!response.ok) {
1340
+ throw new BlockchainError(
1341
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1342
+ );
1343
+ }
1344
+ const result = await response.json();
1345
+ if (result.errors) {
1346
+ throw new BlockchainError(
1347
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1348
+ );
1349
+ }
1350
+ const userData = result.data?.user;
1351
+ if (!userData?.permissions?.length) {
1352
+ return [];
1353
+ }
1354
+ const onChainGrants = userData.permissions.slice(0, limit).map(
1355
+ (permission) => ({
1356
+ id: BigInt(permission.id),
1357
+ grantUrl: permission.grant,
1358
+ grantSignature: permission.signature,
1359
+ nonce: BigInt(permission.nonce),
1360
+ startBlock: BigInt(permission.startBlock),
1361
+ addedAtBlock: BigInt(permission.addedAtBlock),
1362
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
1363
+ transactionHash: permission.transactionHash ?? "",
1364
+ grantor: userAddress,
1365
+ grantee: permission.grantee,
1366
+ active: !permission.endBlock || BigInt(permission.endBlock) === 0n
1367
+ // Active if no end block or end block is 0
1368
+ })
1369
+ );
1370
+ return onChainGrants.sort((a, b) => {
1371
+ if (a.id < b.id) return 1;
1372
+ if (a.id > b.id) return -1;
1373
+ return 0;
1374
+ });
1375
+ } catch (error) {
1376
+ if (error instanceof BlockchainError || error instanceof NetworkError) {
1377
+ throw error;
1378
+ }
1379
+ throw new BlockchainError(
1380
+ `Failed to fetch user permission grants: ${error instanceof Error ? error.message : "Unknown error"}`
1381
+ );
1382
+ }
1383
+ }
1384
+ /**
1385
+ * Registers a new server and immediately trusts it in the DataPortabilityServers contract.
1386
+ *
1387
+ * This is a combined operation that both registers a new data portability server
1388
+ * and adds it to the user's trusted servers list in a single transaction.
1389
+ * Trusted servers can handle data export and portability requests from the user.
1390
+ *
1391
+ * @param params - Parameters for adding and trusting the server
1392
+ * @param params.serverAddress - Ethereum address of the server
1393
+ * @param params.serverUrl - HTTPS URL where the server can be reached
1394
+ * @param params.publicKey - Server's public key for encryption (hex string)
1395
+ * @returns Promise resolving to transaction hash
1396
+ * @throws {UserRejectedRequestError} When user rejects the transaction
1397
+ * @throws {BlockchainError} When chain ID is unavailable or transaction fails
1398
+ * @throws {ServerAlreadyRegisteredError} When server address is already registered
1399
+ * @throws {Error} When wallet account is not available
1400
+ *
1401
+ * @example
1402
+ * ```typescript
1403
+ * // Add and trust a server by providing all required details
1404
+ * const txHash = await vana.permissions.addAndTrustServer({
1405
+ * owner: '0x1234567890abcdef1234567890abcdef12345678',
1406
+ * serverAddress: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
1407
+ * serverUrl: 'https://myserver.example.com',
1408
+ * publicKey: '0x456789abcdef456789abcdef456789abcdef456789abcdef'
1409
+ * });
1410
+ * console.log('Server added and trusted in transaction:', txHash);
1411
+ *
1412
+ * // Verify the server is now trusted
1413
+ * const trustedServers = await vana.permissions.getTrustedServers();
1414
+ * console.log('Now trusting servers:', trustedServers);
1415
+ * ```
1416
+ */
1417
+ async addAndTrustServer(params) {
1418
+ this.assertWallet();
1419
+ try {
1420
+ const chainId = await this.context.walletClient.getChainId();
1421
+ const DataPortabilityServersAddress = getContractAddress(
1422
+ chainId,
1423
+ "DataPortabilityServers"
1424
+ );
1425
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1426
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1427
+ const userAddress = typeof account === "string" ? account : account.address;
1428
+ const normalizedUserAddress = getAddress(userAddress);
1429
+ const normalizedServerAddress = getAddress(params.serverAddress);
1430
+ const txHash = await this.context.walletClient.writeContract({
1431
+ address: DataPortabilityServersAddress,
1432
+ abi: DataPortabilityServersAbi,
1433
+ functionName: "addAndTrustServerByManager",
1434
+ args: [
1435
+ normalizedUserAddress,
1436
+ {
1437
+ serverAddress: normalizedServerAddress,
1438
+ serverUrl: params.serverUrl,
1439
+ publicKey: params.publicKey
1440
+ }
1441
+ ],
1442
+ account,
1443
+ chain: this.context.walletClient?.chain ?? null
1444
+ });
1445
+ const { tx } = await import("../utils/transactionHelpers");
1446
+ const txResult = tx({
1447
+ hash: txHash,
1448
+ from: userAddress,
1449
+ contract: "DataPortabilityServers",
1450
+ fn: "addAndTrustServerByManager"
1451
+ });
1452
+ if (!this.context.waitForTransactionEvents) {
1453
+ throw new BlockchainError("waitForTransactionEvents not configured");
1454
+ }
1455
+ const result = await this.context.waitForTransactionEvents(txResult);
1456
+ const event = result.expectedEvents.ServerTrusted;
1457
+ if (!event) {
1458
+ throw new BlockchainError(
1459
+ "ServerTrusted event not found in transaction"
1460
+ );
1461
+ }
1462
+ const receipt = await this.context.publicClient.getTransactionReceipt({
1463
+ hash: txHash
1464
+ });
1465
+ return {
1466
+ transactionHash: txHash,
1467
+ blockNumber: receipt.blockNumber,
1468
+ gasUsed: receipt.gasUsed,
1469
+ user: event.user,
1470
+ serverId: event.serverId,
1471
+ // bigint from event
1472
+ serverAddress: normalizedServerAddress,
1473
+ // derived from params
1474
+ serverUrl: params.serverUrl
1475
+ // provided in params
1476
+ };
1477
+ } catch (error) {
1478
+ if (error instanceof Error && error.message.includes("rejected")) {
1479
+ throw new UserRejectedRequestError();
1480
+ }
1481
+ throw new BlockchainError(
1482
+ `Failed to add and trust server: ${error instanceof Error ? error.message : "Unknown error"}`,
1483
+ error
1484
+ );
1485
+ }
1486
+ }
1487
+ /**
1488
+ * Trusts a server for data processing (legacy method).
1489
+ *
1490
+ * @param params - Parameters for trusting the server
1491
+ * @returns Promise resolving to transaction hash
1492
+ * @deprecated Use addAndTrustServer instead
1493
+ */
1494
+ async submitTrustServer(params) {
1495
+ this.assertWallet();
1496
+ try {
1497
+ const chainId = await this.context.walletClient.getChainId();
1498
+ const DataPortabilityServersAddress = getContractAddress(
1499
+ chainId,
1500
+ "DataPortabilityServers"
1501
+ );
1502
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1503
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1504
+ const txHash = await this.context.walletClient.writeContract({
1505
+ address: DataPortabilityServersAddress,
1506
+ abi: DataPortabilityServersAbi,
1507
+ functionName: "trustServer",
1508
+ args: [BigInt(params.serverId)],
1509
+ account,
1510
+ chain: this.context.walletClient?.chain ?? null
1511
+ });
1512
+ const { tx } = await import("../utils/transactionHelpers");
1513
+ return tx({
1514
+ hash: txHash,
1515
+ from: typeof account === "string" ? account : account.address,
1516
+ contract: "DataPortabilityServers",
1517
+ fn: "trustServer"
1518
+ });
1519
+ } catch (error) {
1520
+ if (error instanceof Error && error.message.includes("rejected")) {
1521
+ throw new UserRejectedRequestError();
1522
+ }
1523
+ throw new BlockchainError(
1524
+ `Failed to trust server: ${error instanceof Error ? error.message : "Unknown error"}`,
1525
+ error
1526
+ );
1527
+ }
1528
+ }
1529
+ /**
1530
+ * Adds and trusts a server using a signature (gasless transaction).
1531
+ *
1532
+ * @param params - Parameters for adding and trusting the server
1533
+ * @returns Promise resolving to TransactionResult with ServerTrustResult event data
1534
+ */
1535
+ async submitAddAndTrustServerWithSignature(params) {
1536
+ this.assertWallet();
1537
+ try {
1538
+ const nonce = await this.getServersUserNonce();
1539
+ const serverAddress = getAddress(params.serverAddress);
1540
+ const addAndTrustServerInput = {
1541
+ nonce,
1542
+ serverAddress,
1543
+ publicKey: params.publicKey,
1544
+ serverUrl: params.serverUrl
1545
+ };
1546
+ const typedData = await this.composeAddAndTrustServerMessage(
1547
+ addAndTrustServerInput
1548
+ );
1549
+ console.debug("\u{1F50D} AddAndTrustServer Debug Info:", {
1550
+ nonce: nonce.toString(),
1551
+ serverAddress: params.serverAddress,
1552
+ publicKey: params.publicKey,
1553
+ serverUrl: params.serverUrl,
1554
+ domain: typedData.domain,
1555
+ typedDataMessage: typedData.message
1556
+ });
1557
+ const signature = await this.signTypedData(typedData);
1558
+ console.debug("\u{1F50D} Generated signature:", signature);
1559
+ let hash;
1560
+ if (this.context.relayer) {
1561
+ const request = {
1562
+ type: "signed",
1563
+ operation: "submitAddAndTrustServer",
1564
+ typedData,
1565
+ signature
1566
+ };
1567
+ const response = await this.context.relayer(request);
1568
+ if (response.type === "error") {
1569
+ throw new RelayerError(response.error);
1570
+ }
1571
+ if (response.type === "signed") {
1572
+ hash = response.hash;
1573
+ } else {
1574
+ throw new Error("Unexpected response type from relayer");
1575
+ }
1576
+ } else {
1577
+ hash = await this.submitAddAndTrustServerTransaction(
1578
+ addAndTrustServerInput,
1579
+ signature
1580
+ );
1581
+ }
1582
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1583
+ const { tx } = await import("../utils/transactionHelpers");
1584
+ return tx({
1585
+ hash,
1586
+ from: typeof account === "string" ? account : account.address,
1587
+ contract: "DataPortabilityServers",
1588
+ fn: "addAndTrustServerWithSignature"
1589
+ });
1590
+ } catch (error) {
1591
+ if (error instanceof Error) {
1592
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
1593
+ throw error;
1594
+ }
1595
+ throw new BlockchainError(
1596
+ `Add and trust server failed: ${error.message}`,
1597
+ error
1598
+ );
1599
+ }
1600
+ throw new BlockchainError(
1601
+ "Add and trust server failed with unknown error"
1602
+ );
1603
+ }
1604
+ }
1605
+ /**
1606
+ * Trusts a server using a signature (gasless transaction - legacy method).
1607
+ *
1608
+ * @param params - Parameters for trusting the server
1609
+ * @returns Promise resolving to transaction hash
1610
+ * @deprecated Use addAndTrustServerWithSignature instead
1611
+ * @throws {BlockchainError} When chain ID is not available
1612
+ * @throws {NonceError} When retrieving user nonce fails
1613
+ * @throws {SignatureError} When user rejects the signature request
1614
+ * @throws {RelayerError} When gasless submission fails
1615
+ * @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
1616
+ * @throws {BlockchainError} When trust operation fails for any other reason
1617
+ */
1618
+ async submitTrustServerWithSignature(params) {
1619
+ this.assertWallet();
1620
+ try {
1621
+ const nonce = await this.getServersUserNonce();
1622
+ const trustServerInput = {
1623
+ nonce,
1624
+ serverId: params.serverId
1625
+ };
1626
+ const typedData = await this.composeTrustServerMessage(trustServerInput);
1627
+ const signature = await this.signTypedData(typedData);
1628
+ let hash;
1629
+ if (this.context.relayer) {
1630
+ const request = {
1631
+ type: "signed",
1632
+ operation: "submitTrustServer",
1633
+ typedData,
1634
+ signature
1635
+ };
1636
+ const response = await this.context.relayer(request);
1637
+ if (response.type === "error") {
1638
+ throw new RelayerError(response.error);
1639
+ }
1640
+ if (response.type === "signed") {
1641
+ hash = response.hash;
1642
+ } else {
1643
+ throw new Error("Unexpected response type from relayer");
1644
+ }
1645
+ } else {
1646
+ hash = await this.submitTrustServerTransaction(
1647
+ trustServerInput,
1648
+ signature
1649
+ );
1650
+ }
1651
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1652
+ const { tx } = await import("../utils/transactionHelpers");
1653
+ return tx({
1654
+ hash,
1655
+ from: typeof account === "string" ? account : account.address,
1656
+ contract: "DataPortabilityServers",
1657
+ fn: "trustServerWithSignature"
1658
+ });
1659
+ } catch (error) {
1660
+ if (error instanceof Error) {
1661
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
1662
+ throw error;
1663
+ }
1664
+ throw new BlockchainError(
1665
+ `Trust server failed: ${error.message}`,
1666
+ error
1667
+ );
1668
+ }
1669
+ throw new BlockchainError("Trust server failed with unknown error");
1670
+ }
1671
+ }
1672
+ /**
1673
+ * Submits a direct untrust server transaction (without signature).
1674
+ *
1675
+ * @param params - The untrust server parameters containing server details
1676
+ * @returns Promise resolving to the transaction hash
1677
+ */
1678
+ /**
1679
+ * Submits an untrust server transaction directly to the blockchain.
1680
+ *
1681
+ * @remarks
1682
+ * Internal method used for direct blockchain submission of untrust server operations
1683
+ * when relayer callbacks are not available.
1684
+ *
1685
+ * @param params - The untrust server parameters
1686
+ * @returns Promise resolving to TransactionResult for transaction tracking
1687
+ * @throws {BlockchainError} When contract submission fails
1688
+ */
1689
+ async submitDirectUntrustTransaction(params, options) {
1690
+ this.assertWallet();
1691
+ try {
1692
+ const chainId = await this.context.walletClient.getChainId();
1693
+ const DataPortabilityServersAddress = getContractAddress(
1694
+ chainId,
1695
+ "DataPortabilityServers"
1696
+ );
1697
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1698
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1699
+ const txHash = await this.context.walletClient.writeContract({
1700
+ address: DataPortabilityServersAddress,
1701
+ abi: DataPortabilityServersAbi,
1702
+ functionName: "untrustServer",
1703
+ args: [BigInt(params.serverId)],
1704
+ account,
1705
+ chain: this.context.walletClient?.chain ?? null,
1706
+ ...options?.gasLimit && { gas: options.gasLimit },
1707
+ ...options?.nonce && { nonce: options.nonce },
1708
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
1709
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
1710
+ ...options.maxFeePerGas && {
1711
+ maxFeePerGas: options.maxFeePerGas
1712
+ },
1713
+ ...options.maxPriorityFeePerGas && {
1714
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
1715
+ }
1716
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
1717
+ });
1718
+ const { tx } = await import("../utils/transactionHelpers");
1719
+ return tx({
1720
+ hash: txHash,
1721
+ from: typeof account === "string" ? account : account.address,
1722
+ contract: "DataPortabilityServers",
1723
+ fn: "untrustServer"
1724
+ });
1725
+ } catch (error) {
1726
+ if (error instanceof Error && error.message.includes("rejected")) {
1727
+ throw new UserRejectedRequestError();
1728
+ }
1729
+ throw new BlockchainError(
1730
+ `Failed to untrust server: ${error instanceof Error ? error.message : "Unknown error"}`,
1731
+ error
1732
+ );
1733
+ }
1734
+ }
1735
+ /**
1736
+ * Removes a server from the user's trusted servers list in the DataPortabilityServers contract.
1737
+ *
1738
+ * This revokes the server's authorization to handle data portability requests for the user.
1739
+ * The server remains registered in the system but will no longer be trusted by this user.
1740
+ *
1741
+ * @param params - Parameters for untrusting the server
1742
+ * @param params.serverId - The numeric ID of the server to untrust
1743
+ * @param options - Optional transaction options for gas parameters and timeout
1744
+ * @returns Promise resolving to transaction hash
1745
+ * @throws {Error} When wallet account is not available
1746
+ * @throws {NonceError} When retrieving user nonce fails
1747
+ * @throws {UserRejectedRequestError} When user rejects the transaction
1748
+ * @throws {ServerNotTrustedError} When the server is not currently trusted
1749
+ * @throws {BlockchainError} When untrust transaction fails
1750
+ *
1751
+ * @example
1752
+ * ```typescript
1753
+ * // Untrust a specific server
1754
+ * const txHash = await vana.permissions.untrustServer({
1755
+ * serverId: 1
1756
+ * });
1757
+ * console.log('Server untrusted in transaction:', txHash);
1758
+ *
1759
+ * // Verify the server is no longer trusted
1760
+ * const trustedServers = await vana.permissions.getTrustedServers();
1761
+ * console.log('Still trusting servers:', trustedServers);
1762
+ * ```
1763
+ */
1764
+ async submitUntrustServer(params, options) {
1765
+ this.assertWallet();
1766
+ const nonce = await this.getServersUserNonce();
1767
+ const untrustServerInput = {
1768
+ nonce,
1769
+ serverId: params.serverId
1770
+ };
1771
+ return await this.submitDirectUntrustTransaction(
1772
+ untrustServerInput,
1773
+ options
1774
+ );
1775
+ }
1776
+ /**
1777
+ * Untrusts a server using a signature (gasless transaction).
1778
+ *
1779
+ * @param params - Parameters for untrusting the server
1780
+ * @param params.serverId - The server's Ethereum address to untrust
1781
+ * @returns Promise resolving to transaction hash
1782
+ * @throws {Error} When wallet account is not available
1783
+ * @throws {NonceError} When retrieving user nonce fails
1784
+ * @throws {SignatureError} When user rejects the signature request
1785
+ * @throws {RelayerError} When gasless submission fails
1786
+ * @throws {BlockchainError} When untrust transaction fails
1787
+ */
1788
+ async submitUntrustServerWithSignature(params) {
1789
+ this.assertWallet();
1790
+ try {
1791
+ const nonce = await this.getServersUserNonce();
1792
+ const untrustServerInput = {
1793
+ nonce,
1794
+ serverId: params.serverId
1795
+ };
1796
+ const typedData = await this.composeUntrustServerMessage(untrustServerInput);
1797
+ const signature = await this.signTypedData(typedData);
1798
+ let hash;
1799
+ if (this.context.relayer) {
1800
+ const request = {
1801
+ type: "signed",
1802
+ operation: "submitUntrustServer",
1803
+ typedData,
1804
+ signature
1805
+ };
1806
+ const response = await this.context.relayer(request);
1807
+ if (response.type === "error") {
1808
+ throw new RelayerError(response.error);
1809
+ }
1810
+ if (response.type === "signed") {
1811
+ hash = response.hash;
1812
+ } else {
1813
+ throw new Error("Unexpected response type from relayer");
1814
+ }
1815
+ } else {
1816
+ hash = await this.submitSignedUntrustTransaction(typedData, signature);
1817
+ }
1818
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1819
+ const { tx } = await import("../utils/transactionHelpers");
1820
+ return tx({
1821
+ hash,
1822
+ from: typeof account === "string" ? account : account.address,
1823
+ contract: "DataPortabilityServers",
1824
+ fn: "untrustServerWithSignature"
1825
+ });
1826
+ } catch (error) {
1827
+ if (error instanceof Error) {
1828
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
1829
+ throw error;
1830
+ }
1831
+ throw new BlockchainError(
1832
+ `Untrust server failed: ${error.message}`,
1833
+ error
1834
+ );
1835
+ }
1836
+ throw new BlockchainError("Untrust server failed with unknown error");
1837
+ }
1838
+ }
1839
+ /**
1840
+ * Retrieves all servers trusted by a user from the DataPortabilityServers contract.
1841
+ *
1842
+ * Returns an array of server IDs that the specified user has explicitly trusted.
1843
+ * Trusted servers are those that users have authorized to handle their data portability requests.
1844
+ *
1845
+ * @param userAddress - Optional user address to query (defaults to current wallet user)
1846
+ * @returns Promise resolving to array of trusted server IDs (numeric)
1847
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
1848
+ * @throws {NetworkError} When unable to connect to the blockchain network
1849
+ *
1850
+ * @example
1851
+ * ```typescript
1852
+ * // Get trusted servers for current user
1853
+ * const myServers = await vana.permissions.getTrustedServers();
1854
+ * console.log(`I trust ${myServers.length} servers: ${myServers.join(', ')}`);
1855
+ *
1856
+ * // Get trusted servers for another user
1857
+ * const userServers = await vana.permissions.getTrustedServers("0x1234...");
1858
+ * console.log(`User trusts servers: ${userServers.join(', ')}`);
1859
+ * ```
1860
+ */
1861
+ async getTrustedServers(userAddress) {
1862
+ try {
1863
+ const user = userAddress ?? this.context.userAddress;
1864
+ const chainId = await this.context.publicClient.getChainId();
1865
+ const DataPortabilityServersAddress = getContractAddress(
1866
+ chainId,
1867
+ "DataPortabilityServers"
1868
+ );
1869
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1870
+ const serverIds = await this.context.publicClient.readContract({
1871
+ address: DataPortabilityServersAddress,
1872
+ abi: DataPortabilityServersAbi,
1873
+ functionName: "userServerIdsValues",
1874
+ args: [user]
1875
+ });
1876
+ return serverIds.map((id) => Number(id));
1877
+ } catch (error) {
1878
+ throw new BlockchainError(
1879
+ `Failed to get trusted servers: ${error instanceof Error ? error.message : "Unknown error"}`,
1880
+ error
1881
+ );
1882
+ }
1883
+ }
1884
+ /**
1885
+ * Gets the total count of trusted servers for a user.
1886
+ *
1887
+ * @param userAddress - Optional user address (defaults to current user)
1888
+ * @returns Promise resolving to the number of trusted servers
1889
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
1890
+ */
1891
+ async getTrustedServersCount(userAddress) {
1892
+ try {
1893
+ const user = userAddress ?? this.context.userAddress;
1894
+ const chainId = await this.context.publicClient.getChainId();
1895
+ const DataPortabilityServersAddress = getContractAddress(
1896
+ chainId,
1897
+ "DataPortabilityServers"
1898
+ );
1899
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1900
+ const count = await this.context.publicClient.readContract({
1901
+ address: DataPortabilityServersAddress,
1902
+ abi: DataPortabilityServersAbi,
1903
+ functionName: "userServerIdsLength",
1904
+ args: [user]
1905
+ });
1906
+ return Number(count);
1907
+ } catch (error) {
1908
+ throw new BlockchainError(
1909
+ `Failed to get trusted servers count: ${error instanceof Error ? error.message : "Unknown error"}`,
1910
+ error
1911
+ );
1912
+ }
1913
+ }
1914
+ /**
1915
+ * Gets trusted servers with pagination support.
1916
+ *
1917
+ * @param options - Query options including pagination parameters
1918
+ * @returns Promise resolving to paginated trusted servers
1919
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
1920
+ */
1921
+ async getTrustedServersPaginated(options = {}) {
1922
+ try {
1923
+ const user = options.userAddress ?? this.context.userAddress;
1924
+ const limit = options.limit ?? 50;
1925
+ const offset = options.offset ?? 0;
1926
+ const chainId = await this.context.publicClient.getChainId();
1927
+ const DataPortabilityServersAddress = getContractAddress(
1928
+ chainId,
1929
+ "DataPortabilityServers"
1930
+ );
1931
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1932
+ const totalCount = await this.context.publicClient.readContract({
1933
+ address: DataPortabilityServersAddress,
1934
+ abi: DataPortabilityServersAbi,
1935
+ functionName: "userServerIdsLength",
1936
+ args: [user]
1937
+ });
1938
+ const total = Number(totalCount);
1939
+ if (offset >= total) {
1940
+ return {
1941
+ servers: [],
1942
+ total,
1943
+ offset,
1944
+ limit,
1945
+ hasMore: false
1946
+ };
1947
+ }
1948
+ const endIndex = Math.min(offset + limit, total);
1949
+ const serverIdCalls = [];
1950
+ for (let i = offset; i < endIndex; i++) {
1951
+ serverIdCalls.push({
1952
+ address: DataPortabilityServersAddress,
1953
+ abi: DataPortabilityServersAbi,
1954
+ functionName: "userServerIdsAt",
1955
+ args: [user, BigInt(i)]
1956
+ });
1957
+ }
1958
+ const serverIdResults = await gasAwareMulticall(this.context.publicClient, {
1959
+ contracts: serverIdCalls
1960
+ });
1961
+ const servers = serverIdResults.map((result) => Number(result)).filter((id) => id > 0);
1962
+ return {
1963
+ servers,
1964
+ total,
1965
+ offset,
1966
+ limit,
1967
+ hasMore: offset + limit < total
1968
+ };
1969
+ } catch (error) {
1970
+ throw new BlockchainError(
1971
+ `Failed to get paginated trusted servers: ${error instanceof Error ? error.message : "Unknown error"}`,
1972
+ error
1973
+ );
1974
+ }
1975
+ }
1976
+ /**
1977
+ * Gets trusted servers with their complete information.
1978
+ *
1979
+ * @param options - Query options
1980
+ * @returns Promise resolving to array of trusted server info
1981
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
1982
+ */
1983
+ async getTrustedServersWithInfo(options = {}) {
1984
+ try {
1985
+ const paginatedResult = await this.getTrustedServersPaginated(options);
1986
+ const chainId = await this.context.publicClient.getChainId();
1987
+ const DataPortabilityServersAddress = getContractAddress(
1988
+ chainId,
1989
+ "DataPortabilityServers"
1990
+ );
1991
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1992
+ const serverInfoCalls = paginatedResult.servers.map(
1993
+ (serverId) => ({
1994
+ address: DataPortabilityServersAddress,
1995
+ abi: DataPortabilityServersAbi,
1996
+ functionName: "servers",
1997
+ args: [BigInt(serverId)]
1998
+ })
1999
+ );
2000
+ const serverInfoResults = await gasAwareMulticall(this.context.publicClient, {
2001
+ contracts: serverInfoCalls,
2002
+ allowFailure: true
2003
+ });
2004
+ return serverInfoResults.map((result, index) => {
2005
+ const serverId = paginatedResult.servers[index];
2006
+ if (result.status === "success" && result.result) {
2007
+ const serverInfo = result.result;
2008
+ return {
2009
+ id: BigInt(serverId),
2010
+ owner: serverInfo.owner,
2011
+ serverAddress: serverInfo.serverAddress,
2012
+ publicKey: serverInfo.publicKey,
2013
+ url: serverInfo.url,
2014
+ startBlock: 0n,
2015
+ // We don't have this info from the old method structure
2016
+ endBlock: 0n
2017
+ // 0 means still active
2018
+ };
2019
+ } else {
2020
+ return {
2021
+ id: BigInt(serverId),
2022
+ owner: "0x0000000000000000000000000000000000000000",
2023
+ serverAddress: "0x0000000000000000000000000000000000000000",
2024
+ publicKey: "",
2025
+ url: "",
2026
+ startBlock: 0n,
2027
+ endBlock: 0n
2028
+ };
2029
+ }
2030
+ });
2031
+ } catch (error) {
2032
+ throw new BlockchainError(
2033
+ `Failed to get trusted servers with info: ${error instanceof Error ? error.message : "Unknown error"}`,
2034
+ error
2035
+ );
2036
+ }
2037
+ }
2038
+ /**
2039
+ * Gets server information for multiple servers efficiently.
2040
+ *
2041
+ * @remarks
2042
+ * This method uses multicall to fetch information for multiple servers in a single
2043
+ * blockchain call, improving performance when querying many servers. Failed lookups
2044
+ * are returned separately for error handling.
2045
+ *
2046
+ * @param serverIds - Array of numeric server IDs to query
2047
+ * @returns Promise resolving to batch result containing successful lookups and failed IDs
2048
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
2049
+ * @example
2050
+ * ```typescript
2051
+ * const result = await vana.permissions.getServerInfoBatch([1, 2, 3, 999]);
2052
+ *
2053
+ * // Process successful lookups
2054
+ * result.servers.forEach((server, id) => {
2055
+ * console.log(`Server ${id}: ${server.url}`);
2056
+ * });
2057
+ *
2058
+ * // Handle failed lookups
2059
+ * if (result.failed.length > 0) {
2060
+ * console.log(`Failed to fetch: ${result.failed.join(', ')}`);
2061
+ * }
2062
+ * ```
2063
+ */
2064
+ async getServerInfoBatch(serverIds) {
2065
+ if (serverIds.length === 0) {
2066
+ return {
2067
+ servers: /* @__PURE__ */ new Map(),
2068
+ failed: []
2069
+ };
2070
+ }
2071
+ try {
2072
+ const chainId = await this.context.publicClient.getChainId();
2073
+ const DataPortabilityServersAddress = getContractAddress(
2074
+ chainId,
2075
+ "DataPortabilityServers"
2076
+ );
2077
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2078
+ const serverInfoCalls = serverIds.map(
2079
+ (serverId) => ({
2080
+ address: DataPortabilityServersAddress,
2081
+ abi: DataPortabilityServersAbi,
2082
+ functionName: "servers",
2083
+ args: [BigInt(serverId)]
2084
+ })
2085
+ );
2086
+ const serverInfoResults = await gasAwareMulticall(this.context.publicClient, {
2087
+ contracts: serverInfoCalls,
2088
+ allowFailure: true
2089
+ });
2090
+ const results = serverInfoResults.map((result, index) => {
2091
+ const serverId = serverIds[index];
2092
+ if (result.status === "success" && result.result) {
2093
+ const serverInfo = result.result;
2094
+ const server = {
2095
+ id: Number(serverInfo.id),
2096
+ owner: serverInfo.owner,
2097
+ url: serverInfo.url,
2098
+ serverAddress: serverInfo.serverAddress,
2099
+ publicKey: serverInfo.publicKey
2100
+ };
2101
+ return { serverId, server, success: true };
2102
+ } else {
2103
+ return { serverId, server: null, success: false };
2104
+ }
2105
+ });
2106
+ const servers = /* @__PURE__ */ new Map();
2107
+ const failed = [];
2108
+ for (const result of results) {
2109
+ if (result.success && result.server) {
2110
+ servers.set(result.serverId, result.server);
2111
+ } else {
2112
+ failed.push(result.serverId);
2113
+ }
2114
+ }
2115
+ return { servers, failed };
2116
+ } catch (error) {
2117
+ throw new BlockchainError(
2118
+ `Failed to batch get server info: ${error instanceof Error ? error.message : "Unknown error"}`,
2119
+ error
2120
+ );
2121
+ }
2122
+ }
2123
+ /**
2124
+ * Checks whether a specific server is trusted by a user.
2125
+ *
2126
+ * @remarks
2127
+ * This method queries the user's trusted server list and checks if the specified
2128
+ * server is present. Returns both the trust status and the index in the trust list
2129
+ * if trusted.
2130
+ *
2131
+ * @param serverId - Numeric server ID to check
2132
+ * @param userAddress - Optional user address (defaults to current user)
2133
+ * @returns Promise resolving to server trust status with trust index if applicable
2134
+ * @throws {BlockchainError} When reading from contract fails
2135
+ * @example
2136
+ * ```typescript
2137
+ * const status = await vana.permissions.checkServerTrustStatus(1);
2138
+ * if (status.isTrusted) {
2139
+ * console.log(`Server is trusted at index ${status.trustIndex}`);
2140
+ * } else {
2141
+ * console.log('Server is not trusted');
2142
+ * }
2143
+ * ```
2144
+ */
2145
+ async checkServerTrustStatus(serverId, userAddress) {
2146
+ try {
2147
+ const user = userAddress ?? this.context.userAddress;
2148
+ const trustedServers = await this.getTrustedServers(user);
2149
+ const trustIndex = trustedServers.findIndex(
2150
+ (server) => server === serverId
2151
+ );
2152
+ return {
2153
+ serverId,
2154
+ isTrusted: trustIndex !== -1,
2155
+ trustIndex: trustIndex !== -1 ? trustIndex : void 0
2156
+ };
2157
+ } catch (error) {
2158
+ throw new BlockchainError(
2159
+ `Failed to check server trust status: ${error instanceof Error ? error.message : "Unknown error"}`,
2160
+ error
2161
+ );
2162
+ }
2163
+ }
2164
+ /**
2165
+ * Composes EIP-712 typed data for AddAndTrustServer.
2166
+ *
2167
+ * @remarks
2168
+ * Creates the complete typed data structure required for EIP-712 signature generation
2169
+ * when adding and trusting a new server in a single transaction.
2170
+ *
2171
+ * @param input - The add and trust server input data containing server details
2172
+ * @returns Promise resolving to the typed data structure for server add and trust
2173
+ */
2174
+ async composeAddAndTrustServerMessage(input) {
2175
+ const domain = await this.getServersDomain();
2176
+ console.debug(domain);
2177
+ return {
2178
+ domain,
2179
+ types: {
2180
+ AddServer: [
2181
+ { name: "nonce", type: "uint256" },
2182
+ { name: "serverAddress", type: "address" },
2183
+ { name: "publicKey", type: "string" },
2184
+ { name: "serverUrl", type: "string" }
2185
+ ]
2186
+ },
2187
+ primaryType: "AddServer",
2188
+ message: input
2189
+ };
2190
+ }
2191
+ /**
2192
+ * Composes EIP-712 typed data for TrustServer.
2193
+ *
2194
+ * @param input - The trust server input data containing server details
2195
+ * @returns Promise resolving to the typed data structure for server trust
2196
+ */
2197
+ async composeTrustServerMessage(input) {
2198
+ const domain = await this.getServersDomain();
2199
+ return {
2200
+ domain,
2201
+ types: {
2202
+ TrustServer: [
2203
+ { name: "nonce", type: "uint256" },
2204
+ { name: "serverId", type: "uint256" }
2205
+ ]
2206
+ },
2207
+ primaryType: "TrustServer",
2208
+ message: input
2209
+ };
2210
+ }
2211
+ /**
2212
+ * Composes EIP-712 typed data for UntrustServer.
2213
+ *
2214
+ * @param input - The untrust server input data containing server details
2215
+ * @returns Promise resolving to the typed data structure for server untrust
2216
+ */
2217
+ async composeUntrustServerMessage(input) {
2218
+ const domain = await this.getServersDomain();
2219
+ return {
2220
+ domain,
2221
+ types: {
2222
+ UntrustServer: [
2223
+ { name: "nonce", type: "uint256" },
2224
+ { name: "serverId", type: "uint256" }
2225
+ ]
2226
+ },
2227
+ primaryType: "UntrustServer",
2228
+ message: input
2229
+ };
2230
+ }
2231
+ /**
2232
+ * Gets the EIP-712 domain for DataPortabilityServers signatures.
2233
+ *
2234
+ * @returns Promise resolving to the EIP-712 domain configuration
2235
+ */
2236
+ async getServersDomain() {
2237
+ const chainId = await this.context.publicClient.getChainId();
2238
+ const DataPortabilityServersAddress = getContractAddress(
2239
+ chainId,
2240
+ "DataPortabilityServers"
2241
+ );
2242
+ return {
2243
+ name: "VanaDataPortabilityServers",
2244
+ version: "1",
2245
+ chainId,
2246
+ verifyingContract: DataPortabilityServersAddress
2247
+ };
2248
+ }
2249
+ /**
2250
+ * Submits an add and trust server transaction directly to the blockchain.
2251
+ *
2252
+ * @param addAndTrustServerInput - The add and trust server input data containing server details
2253
+ * @param signature - The cryptographic signature for the transaction
2254
+ * @returns Promise resolving to the transaction hash
2255
+ */
2256
+ async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
2257
+ this.assertWallet();
2258
+ const chainId = await this.context.walletClient.getChainId();
2259
+ const DataPortabilityServersAddress = getContractAddress(
2260
+ chainId,
2261
+ "DataPortabilityServers"
2262
+ );
2263
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2264
+ console.debug("\u{1F50D} Transaction Debug Info:", {
2265
+ chainId,
2266
+ contractAddress: DataPortabilityServersAddress,
2267
+ input: {
2268
+ nonce: addAndTrustServerInput.nonce.toString(),
2269
+ serverAddress: addAndTrustServerInput.serverAddress,
2270
+ publicKey: addAndTrustServerInput.publicKey,
2271
+ serverUrl: addAndTrustServerInput.serverUrl
2272
+ },
2273
+ signature
2274
+ });
2275
+ const formattedSignature = formatSignatureForContract(signature);
2276
+ const txHash = await this.context.walletClient.writeContract({
2277
+ address: DataPortabilityServersAddress,
2278
+ abi: DataPortabilityServersAbi,
2279
+ functionName: "addAndTrustServerWithSignature",
2280
+ args: [
2281
+ {
2282
+ nonce: addAndTrustServerInput.nonce,
2283
+ serverAddress: addAndTrustServerInput.serverAddress,
2284
+ publicKey: addAndTrustServerInput.publicKey,
2285
+ serverUrl: addAndTrustServerInput.serverUrl
2286
+ },
2287
+ formattedSignature
2288
+ ],
2289
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2290
+ chain: this.context.walletClient?.chain ?? null
2291
+ });
2292
+ return txHash;
2293
+ }
2294
+ /**
2295
+ * Submits a trust server transaction directly to the blockchain.
2296
+ *
2297
+ * @param trustServerInput - The trust server input data containing server details
2298
+ * @param signature - The cryptographic signature for the transaction
2299
+ * @returns Promise resolving to the transaction hash
2300
+ */
2301
+ async submitTrustServerTransaction(trustServerInput, signature) {
2302
+ this.assertWallet();
2303
+ const chainId = await this.context.walletClient.getChainId();
2304
+ const DataPortabilityServersAddress = getContractAddress(
2305
+ chainId,
2306
+ "DataPortabilityServers"
2307
+ );
2308
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2309
+ const formattedSignature = formatSignatureForContract(signature);
2310
+ const txHash = await this.context.walletClient.writeContract({
2311
+ address: DataPortabilityServersAddress,
2312
+ abi: DataPortabilityServersAbi,
2313
+ functionName: "trustServerWithSignature",
2314
+ args: [
2315
+ {
2316
+ nonce: trustServerInput.nonce,
2317
+ serverId: BigInt(trustServerInput.serverId)
2318
+ },
2319
+ formattedSignature
2320
+ ],
2321
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2322
+ chain: this.context.walletClient?.chain ?? null
2323
+ });
2324
+ return txHash;
2325
+ }
2326
+ /**
2327
+ * Submits a revoke transaction directly to the blockchain with signature.
2328
+ *
2329
+ * @param typedData - The EIP-712 typed data structure for the revoke operation
2330
+ * @param signature - The cryptographic signature authorizing the revoke
2331
+ * @returns Promise resolving to the transaction hash
2332
+ */
2333
+ async submitDirectRevokeTransaction(typedData, signature) {
2334
+ this.assertWallet();
2335
+ const chainId = await this.context.walletClient.getChainId();
2336
+ const DataPortabilityPermissionsAddress = getContractAddress(
2337
+ chainId,
2338
+ "DataPortabilityPermissions"
2339
+ );
2340
+ const DataPortabilityPermissionsAbi = getAbi("DataPortabilityPermissions");
2341
+ const formattedSignature = formatSignatureForContract(signature);
2342
+ const txHash = await this.context.walletClient.writeContract({
2343
+ address: DataPortabilityPermissionsAddress,
2344
+ abi: DataPortabilityPermissionsAbi,
2345
+ functionName: "revokePermissionWithSignature",
2346
+ args: [typedData.message, formattedSignature],
2347
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2348
+ chain: this.context.walletClient?.chain ?? null
2349
+ });
2350
+ return txHash;
2351
+ }
2352
+ /**
2353
+ * Submits an untrust server transaction with signature.
2354
+ *
2355
+ * @param typedData - The EIP-712 typed data structure for the untrust operation
2356
+ * @param signature - The cryptographic signature authorizing the untrust
2357
+ * @returns Promise resolving to the transaction hash
2358
+ */
2359
+ async submitSignedUntrustTransaction(typedData, signature) {
2360
+ this.assertWallet();
2361
+ const chainId = await this.context.walletClient.getChainId();
2362
+ const DataPortabilityServersAddress = getContractAddress(
2363
+ chainId,
2364
+ "DataPortabilityServers"
2365
+ );
2366
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2367
+ const formattedSignature = formatSignatureForContract(signature);
2368
+ const contractMessage = {
2369
+ nonce: typedData.message.nonce,
2370
+ serverId: BigInt(typedData.message.serverId)
2371
+ };
2372
+ const txHash = await this.context.walletClient.writeContract({
2373
+ address: DataPortabilityServersAddress,
2374
+ abi: DataPortabilityServersAbi,
2375
+ functionName: "untrustServerWithSignature",
2376
+ args: [contractMessage, formattedSignature],
2377
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2378
+ chain: this.context.walletClient?.chain ?? null
2379
+ });
2380
+ return txHash;
2381
+ }
2382
+ // ===========================
2383
+ // GRANTEE METHODS
2384
+ // ===========================
2385
+ /**
2386
+ * Registers a new grantee in the DataPortabilityGrantees contract.
2387
+ *
2388
+ * A grantee is an entity (like an application) that can receive data permissions
2389
+ * from users. Once registered, users can grant the grantee access to their data.
2390
+ *
2391
+ * @param params - Parameters for registering the grantee
2392
+ * @param params.owner - The Ethereum address that will own this grantee registration
2393
+ * @param params.granteeAddress - The Ethereum address of the grantee (application)
2394
+ * @param params.publicKey - The public key used for data encryption/decryption (hex string)
2395
+ * @param options - Optional transaction options for gas parameters and timeout
2396
+ * @returns Promise resolving to the transaction hash
2397
+ * @throws {BlockchainError} When the grantee registration transaction fails
2398
+ * @throws {UserRejectedRequestError} When user rejects the transaction
2399
+ * @throws {ContractError} When grantee is already registered
2400
+ *
2401
+ * @example
2402
+ * ```typescript
2403
+ * const txHash = await vana.permissions.registerGrantee({
2404
+ * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2405
+ * granteeAddress: "0xApp1234567890123456789012345678901234567890",
2406
+ * publicKey: "0x1234567890abcdef..."
2407
+ * });
2408
+ * console.log(`Grantee registered in transaction: ${txHash}`);
2409
+ * ```
2410
+ */
2411
+ async submitRegisterGrantee(params, options) {
2412
+ this.assertWallet();
2413
+ const chainId = await this.context.walletClient.getChainId();
2414
+ const DataPortabilityGranteesAddress = getContractAddress(
2415
+ chainId,
2416
+ "DataPortabilityGrantees"
2417
+ );
2418
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2419
+ const ownerAddress = getAddress(params.owner);
2420
+ const granteeAddress = getAddress(params.granteeAddress);
2421
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
2422
+ const txHash = await this.context.walletClient.writeContract({
2423
+ address: DataPortabilityGranteesAddress,
2424
+ abi: DataPortabilityGranteesAbi,
2425
+ functionName: "registerGrantee",
2426
+ args: [ownerAddress, granteeAddress, params.publicKey],
2427
+ account,
2428
+ chain: this.context.walletClient?.chain ?? null,
2429
+ ...options?.gasLimit && { gas: options.gasLimit },
2430
+ ...options?.nonce && { nonce: options.nonce },
2431
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
2432
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
2433
+ ...options.maxFeePerGas && { maxFeePerGas: options.maxFeePerGas },
2434
+ ...options.maxPriorityFeePerGas && {
2435
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
2436
+ }
2437
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
2438
+ });
2439
+ const { tx } = await import("../utils/transactionHelpers");
2440
+ return tx({
2441
+ hash: txHash,
2442
+ from: typeof account === "string" ? account : account.address,
2443
+ contract: "DataPortabilityGrantees",
2444
+ fn: "registerGrantee"
2445
+ });
2446
+ }
2447
+ // TODO: When DataPortabilityGrantees contract adds registerGranteeWithSignature function,
2448
+ // implement submitRegisterGranteeWithSignature and submitSignedRegisterGrantee methods
2449
+ // to support gasless transactions via relayer
2450
+ /**
2451
+ * Retrieves all registered grantees from the DataPortabilityGrantees contract.
2452
+ *
2453
+ * Returns a paginated list of all grantees (applications) that have been registered
2454
+ * in the system and can receive data permissions from users.
2455
+ *
2456
+ * @param options - Query options for pagination and filtering
2457
+ * @param options.limit - Maximum number of grantees to return (default: 50)
2458
+ * @param options.offset - Number of grantees to skip for pagination (default: 0)
2459
+ * @returns Promise resolving to paginated grantees with metadata
2460
+ * @throws {BlockchainError} When contract read operation fails
2461
+ * @throws {NetworkError} When unable to connect to the blockchain network
2462
+ *
2463
+ * @example
2464
+ * ```typescript
2465
+ * // Get first 10 grantees
2466
+ * const result = await vana.permissions.getGrantees({
2467
+ * limit: 10,
2468
+ * offset: 0
2469
+ * });
2470
+ *
2471
+ * console.log(`Found ${result.total} total grantees`);
2472
+ * result.grantees.forEach(grantee => {
2473
+ * console.log(`Grantee ${grantee.id}: ${grantee.granteeAddress}`);
2474
+ * });
2475
+ *
2476
+ * // Check if there are more results
2477
+ * if (result.hasMore) {
2478
+ * console.log('More grantees available');
2479
+ * }
2480
+ * ```
2481
+ */
2482
+ async getGrantees(options = {}) {
2483
+ const chainId = await this.context.publicClient.getChainId();
2484
+ const DataPortabilityGranteesAddress = getContractAddress(
2485
+ chainId,
2486
+ "DataPortabilityGrantees"
2487
+ );
2488
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2489
+ const totalCount = await this.context.publicClient.readContract({
2490
+ address: DataPortabilityGranteesAddress,
2491
+ abi: DataPortabilityGranteesAbi,
2492
+ functionName: "granteesCount"
2493
+ });
2494
+ const total = Number(totalCount);
2495
+ const limit = options.limit ?? 50;
2496
+ const offset = options.offset ?? 0;
2497
+ const grantees = [];
2498
+ const endIndex = Math.min(offset + limit, total);
2499
+ for (let i = offset; i < endIndex; i++) {
2500
+ try {
2501
+ const granteeInfo = await this.context.publicClient.readContract({
2502
+ address: DataPortabilityGranteesAddress,
2503
+ abi: DataPortabilityGranteesAbi,
2504
+ functionName: "grantees",
2505
+ args: [BigInt(i + 1)]
2506
+ // Grantee IDs are 1-indexed
2507
+ });
2508
+ grantees.push({
2509
+ id: i + 1,
2510
+ owner: granteeInfo.owner,
2511
+ address: granteeInfo.granteeAddress,
2512
+ publicKey: granteeInfo.publicKey,
2513
+ permissionIds: granteeInfo.permissionIds.map((id) => Number(id))
2514
+ });
2515
+ } catch (error) {
2516
+ console.warn(`Failed to fetch grantee ${i + 1}:`, error);
2517
+ }
2518
+ }
2519
+ return {
2520
+ grantees,
2521
+ total,
2522
+ offset,
2523
+ limit,
2524
+ hasMore: offset + limit < total
2525
+ };
2526
+ }
2527
+ /**
2528
+ * Retrieves a specific grantee by their Ethereum address from the DataPortabilityGrantees contract.
2529
+ *
2530
+ * Looks up a registered grantee (application) using their Ethereum address
2531
+ * and returns their complete registration information including permissions.
2532
+ *
2533
+ * @param granteeAddress - The Ethereum address of the grantee to look up
2534
+ * @returns Promise resolving to the grantee information, or null if not found
2535
+ * @throws {BlockchainError} When contract read operation fails
2536
+ * @throws {NetworkError} When unable to connect to the blockchain network
2537
+ *
2538
+ * @example
2539
+ * ```typescript
2540
+ * const granteeAddress = "0xApp1234567890123456789012345678901234567890";
2541
+ * const grantee = await vana.permissions.getGranteeByAddress(granteeAddress);
2542
+ *
2543
+ * if (grantee) {
2544
+ * console.log(`Found grantee ${grantee.id}`);
2545
+ * console.log(`Owner: ${grantee.owner}`);
2546
+ * console.log(`Public Key: ${grantee.publicKey}`);
2547
+ * console.log(`Permissions: ${grantee.permissionIds.join(', ')}`);
2548
+ * } else {
2549
+ * console.log('Grantee not found');
2550
+ * }
2551
+ * ```
2552
+ */
2553
+ async getGranteeByAddress(granteeAddress) {
2554
+ const chainId = await this.context.publicClient.getChainId();
2555
+ const DataPortabilityGranteesAddress = getContractAddress(
2556
+ chainId,
2557
+ "DataPortabilityGrantees"
2558
+ );
2559
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2560
+ try {
2561
+ const granteeInfo = await this.context.publicClient.readContract({
2562
+ address: DataPortabilityGranteesAddress,
2563
+ abi: DataPortabilityGranteesAbi,
2564
+ functionName: "granteeByAddress",
2565
+ args: [granteeAddress]
2566
+ });
2567
+ const granteeId = await this.context.publicClient.readContract({
2568
+ address: DataPortabilityGranteesAddress,
2569
+ abi: DataPortabilityGranteesAbi,
2570
+ functionName: "granteeAddressToId",
2571
+ args: [granteeAddress]
2572
+ });
2573
+ return {
2574
+ id: Number(granteeId),
2575
+ owner: granteeInfo.owner,
2576
+ address: granteeInfo.granteeAddress,
2577
+ publicKey: granteeInfo.publicKey,
2578
+ permissionIds: granteeInfo.permissionIds.map((id) => Number(id))
2579
+ };
2580
+ } catch (error) {
2581
+ console.warn(`Failed to fetch grantee ${granteeAddress}:`, error);
2582
+ return null;
2583
+ }
2584
+ }
2585
+ /**
2586
+ * Retrieves a specific grantee by their unique ID from the DataPortabilityGrantees contract.
2587
+ *
2588
+ * Looks up a registered grantee (application) using their numeric ID assigned during
2589
+ * registration and returns their complete information including permissions.
2590
+ *
2591
+ * @param granteeId - The unique numeric ID of the grantee (1-indexed)
2592
+ * @returns Promise resolving to the grantee information, or null if not found
2593
+ * @throws {BlockchainError} When contract read operation fails
2594
+ * @throws {NetworkError} When unable to connect to the blockchain network
2595
+ *
2596
+ * @example
2597
+ * ```typescript
2598
+ * const grantee = await vana.permissions.getGranteeById(1);
2599
+ *
2600
+ * if (grantee) {
2601
+ * console.log(`Grantee ID: ${grantee.id}`);
2602
+ * console.log(`Address: ${grantee.granteeAddress}`);
2603
+ * console.log(`Owner: ${grantee.owner}`);
2604
+ * console.log(`Total permissions: ${grantee.permissionIds.length}`);
2605
+ * } else {
2606
+ * console.log('Grantee with ID 1 not found');
2607
+ * }
2608
+ * ```
2609
+ */
2610
+ async getGranteeById(granteeId) {
2611
+ const chainId = await this.context.publicClient.getChainId();
2612
+ const DataPortabilityGranteesAddress = getContractAddress(
2613
+ chainId,
2614
+ "DataPortabilityGrantees"
2615
+ );
2616
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2617
+ try {
2618
+ const granteeInfo = await this.context.publicClient.readContract({
2619
+ address: DataPortabilityGranteesAddress,
2620
+ abi: DataPortabilityGranteesAbi,
2621
+ functionName: "grantees",
2622
+ args: [BigInt(granteeId)]
2623
+ });
2624
+ return {
2625
+ id: granteeId,
2626
+ owner: granteeInfo.owner,
2627
+ address: granteeInfo.granteeAddress,
2628
+ publicKey: granteeInfo.publicKey,
2629
+ permissionIds: granteeInfo.permissionIds.map((id) => Number(id))
2630
+ };
2631
+ } catch (error) {
2632
+ console.warn(`Failed to fetch grantee ${granteeId}:`, error);
2633
+ return null;
2634
+ }
2635
+ }
2636
+ // ===========================
2637
+ // DATA PORTABILITY SERVERS HELPER METHODS
2638
+ // ===========================
2639
+ /**
2640
+ * Get all trusted server IDs for a user
2641
+ *
2642
+ * @param userAddress - User address to query (defaults to current user)
2643
+ * @returns Promise resolving to array of server IDs
2644
+ */
2645
+ async getUserServerIds(userAddress) {
2646
+ try {
2647
+ const targetAddress = userAddress ?? this.context.userAddress;
2648
+ const chainId = await this.context.publicClient.getChainId();
2649
+ const DataPortabilityServersAddress = getContractAddress(
2650
+ chainId,
2651
+ "DataPortabilityServers"
2652
+ );
2653
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2654
+ const serverIds = await this.context.publicClient.readContract({
2655
+ address: DataPortabilityServersAddress,
2656
+ abi: DataPortabilityServersAbi,
2657
+ functionName: "userServerIdsValues",
2658
+ args: [targetAddress]
2659
+ });
2660
+ return [...serverIds];
2661
+ } catch (error) {
2662
+ throw new BlockchainError(
2663
+ `Failed to get user server IDs: ${error instanceof Error ? error.message : "Unknown error"}`,
2664
+ error
2665
+ );
2666
+ }
2667
+ }
2668
+ /**
2669
+ * Get server ID at specific index for a user
2670
+ *
2671
+ * @param userAddress - User address to query
2672
+ * @param serverIndex - Index in the user's server list
2673
+ * @returns Promise resolving to server ID
2674
+ */
2675
+ async getUserServerIdAt(userAddress, serverIndex) {
2676
+ try {
2677
+ const chainId = await this.context.publicClient.getChainId();
2678
+ const DataPortabilityServersAddress = getContractAddress(
2679
+ chainId,
2680
+ "DataPortabilityServers"
2681
+ );
2682
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2683
+ const serverId = await this.context.publicClient.readContract({
2684
+ address: DataPortabilityServersAddress,
2685
+ abi: DataPortabilityServersAbi,
2686
+ functionName: "userServerIdsAt",
2687
+ args: [userAddress, serverIndex]
2688
+ });
2689
+ return serverId;
2690
+ } catch (error) {
2691
+ throw new BlockchainError(
2692
+ `Failed to get user server ID at index: ${error instanceof Error ? error.message : "Unknown error"}`,
2693
+ error
2694
+ );
2695
+ }
2696
+ }
2697
+ /**
2698
+ * Get the number of trusted servers for a user
2699
+ *
2700
+ * @param userAddress - User address to query (defaults to current user)
2701
+ * @returns Promise resolving to number of trusted servers
2702
+ */
2703
+ async getUserServerCount(userAddress) {
2704
+ try {
2705
+ const targetAddress = userAddress ?? this.context.userAddress;
2706
+ const chainId = await this.context.publicClient.getChainId();
2707
+ const DataPortabilityServersAddress = getContractAddress(
2708
+ chainId,
2709
+ "DataPortabilityServers"
2710
+ );
2711
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2712
+ const count = await this.context.publicClient.readContract({
2713
+ address: DataPortabilityServersAddress,
2714
+ abi: DataPortabilityServersAbi,
2715
+ functionName: "userServerIdsLength",
2716
+ args: [targetAddress]
2717
+ });
2718
+ return count;
2719
+ } catch (error) {
2720
+ throw new BlockchainError(
2721
+ `Failed to get user server count: ${error instanceof Error ? error.message : "Unknown error"}`,
2722
+ error
2723
+ );
2724
+ }
2725
+ }
2726
+ /**
2727
+ * Get detailed information about trusted servers for a user
2728
+ *
2729
+ * @param userAddress - User address to query (defaults to current user)
2730
+ * @returns Promise resolving to array of trusted server info
2731
+ */
2732
+ async getUserTrustedServers(userAddress) {
2733
+ try {
2734
+ const targetAddress = userAddress ?? this.context.userAddress;
2735
+ const chainId = await this.context.publicClient.getChainId();
2736
+ const DataPortabilityServersAddress = getContractAddress(
2737
+ chainId,
2738
+ "DataPortabilityServers"
2739
+ );
2740
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2741
+ const servers = await this.context.publicClient.readContract({
2742
+ address: DataPortabilityServersAddress,
2743
+ abi: DataPortabilityServersAbi,
2744
+ functionName: "userServerValues",
2745
+ args: [targetAddress]
2746
+ });
2747
+ return [...servers];
2748
+ } catch (error) {
2749
+ throw new BlockchainError(
2750
+ `Failed to get user trusted servers: ${error instanceof Error ? error.message : "Unknown error"}`,
2751
+ error
2752
+ );
2753
+ }
2754
+ }
2755
+ /**
2756
+ * Get trusted server info for a specific server ID and user
2757
+ *
2758
+ * @param userAddress - User address to query
2759
+ * @param serverId - Server ID to get info for
2760
+ * @returns Promise resolving to trusted server info
2761
+ */
2762
+ async getUserTrustedServer(userAddress, serverId) {
2763
+ try {
2764
+ const chainId = await this.context.publicClient.getChainId();
2765
+ const DataPortabilityServersAddress = getContractAddress(
2766
+ chainId,
2767
+ "DataPortabilityServers"
2768
+ );
2769
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2770
+ const serverInfo = await this.context.publicClient.readContract({
2771
+ address: DataPortabilityServersAddress,
2772
+ abi: DataPortabilityServersAbi,
2773
+ functionName: "userServers",
2774
+ args: [userAddress, serverId]
2775
+ });
2776
+ return serverInfo;
2777
+ } catch (error) {
2778
+ throw new BlockchainError(
2779
+ `Failed to get user trusted server: ${error instanceof Error ? error.message : "Unknown error"}`,
2780
+ error
2781
+ );
2782
+ }
2783
+ }
2784
+ /**
2785
+ * Get server information by server ID
2786
+ *
2787
+ * @param serverId - Server ID to get info for
2788
+ * @returns Promise resolving to server info
2789
+ */
2790
+ async getServerInfo(serverId) {
2791
+ try {
2792
+ const chainId = await this.context.publicClient.getChainId();
2793
+ const DataPortabilityServersAddress = getContractAddress(
2794
+ chainId,
2795
+ "DataPortabilityServers"
2796
+ );
2797
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2798
+ const serverInfo = await this.context.publicClient.readContract({
2799
+ address: DataPortabilityServersAddress,
2800
+ abi: DataPortabilityServersAbi,
2801
+ functionName: "servers",
2802
+ args: [serverId]
2803
+ });
2804
+ return serverInfo;
2805
+ } catch (error) {
2806
+ throw new BlockchainError(
2807
+ `Failed to get server info: ${error instanceof Error ? error.message : "Unknown error"}`,
2808
+ error
2809
+ );
2810
+ }
2811
+ }
2812
+ /**
2813
+ * Get server information by server address
2814
+ *
2815
+ * @param serverAddress - Server address to get info for
2816
+ * @returns Promise resolving to server info
2817
+ */
2818
+ async getServerInfoByAddress(serverAddress) {
2819
+ try {
2820
+ const chainId = await this.context.publicClient.getChainId();
2821
+ const DataPortabilityServersAddress = getContractAddress(
2822
+ chainId,
2823
+ "DataPortabilityServers"
2824
+ );
2825
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2826
+ const serverInfo = await this.context.publicClient.readContract({
2827
+ address: DataPortabilityServersAddress,
2828
+ abi: DataPortabilityServersAbi,
2829
+ functionName: "serverByAddress",
2830
+ args: [serverAddress]
2831
+ });
2832
+ return serverInfo;
2833
+ } catch (error) {
2834
+ throw new BlockchainError(
2835
+ `Failed to get server info by address: ${error instanceof Error ? error.message : "Unknown error"}`,
2836
+ error
2837
+ );
2838
+ }
2839
+ }
2840
+ // ===========================
2841
+ // DATA PORTABILITY PERMISSIONS HELPER METHODS
2842
+ // ===========================
2843
+ /**
2844
+ * Get all permission IDs for a user
2845
+ *
2846
+ * @param userAddress - User address to query (defaults to current user)
2847
+ * @returns Promise resolving to array of permission IDs
2848
+ */
2849
+ async getUserPermissionIds(userAddress) {
2850
+ try {
2851
+ const targetAddress = userAddress ?? this.context.userAddress;
2852
+ const chainId = await this.context.publicClient.getChainId();
2853
+ const DataPortabilityPermissionsAddress = getContractAddress(
2854
+ chainId,
2855
+ "DataPortabilityPermissions"
2856
+ );
2857
+ const DataPortabilityPermissionsAbi = getAbi(
2858
+ "DataPortabilityPermissions"
2859
+ );
2860
+ const permissionIds = await this.context.publicClient.readContract({
2861
+ address: DataPortabilityPermissionsAddress,
2862
+ abi: DataPortabilityPermissionsAbi,
2863
+ functionName: "userPermissionIdsValues",
2864
+ args: [targetAddress]
2865
+ });
2866
+ return [...permissionIds];
2867
+ } catch (error) {
2868
+ throw new BlockchainError(
2869
+ `Failed to get user permission IDs: ${error instanceof Error ? error.message : "Unknown error"}`,
2870
+ error
2871
+ );
2872
+ }
2873
+ }
2874
+ /**
2875
+ * Get permission ID at specific index for a user
2876
+ *
2877
+ * @param userAddress - User address to query
2878
+ * @param permissionIndex - Index in the user's permission list
2879
+ * @returns Promise resolving to permission ID
2880
+ */
2881
+ async getUserPermissionIdAt(userAddress, permissionIndex) {
2882
+ try {
2883
+ const chainId = await this.context.publicClient.getChainId();
2884
+ const DataPortabilityPermissionsAddress = getContractAddress(
2885
+ chainId,
2886
+ "DataPortabilityPermissions"
2887
+ );
2888
+ const DataPortabilityPermissionsAbi = getAbi(
2889
+ "DataPortabilityPermissions"
2890
+ );
2891
+ const permissionId = await this.context.publicClient.readContract({
2892
+ address: DataPortabilityPermissionsAddress,
2893
+ abi: DataPortabilityPermissionsAbi,
2894
+ functionName: "userPermissionIdsAt",
2895
+ args: [userAddress, permissionIndex]
2896
+ });
2897
+ return permissionId;
2898
+ } catch (error) {
2899
+ throw new BlockchainError(
2900
+ `Failed to get user permission ID at index: ${error instanceof Error ? error.message : "Unknown error"}`,
2901
+ error
2902
+ );
2903
+ }
2904
+ }
2905
+ /**
2906
+ * Get the number of permissions for a user
2907
+ *
2908
+ * @param userAddress - User address to query (defaults to current user)
2909
+ * @returns Promise resolving to number of permissions
2910
+ */
2911
+ async getUserPermissionCount(userAddress) {
2912
+ try {
2913
+ const targetAddress = userAddress ?? this.context.userAddress;
2914
+ const chainId = await this.context.publicClient.getChainId();
2915
+ const DataPortabilityPermissionsAddress = getContractAddress(
2916
+ chainId,
2917
+ "DataPortabilityPermissions"
2918
+ );
2919
+ const DataPortabilityPermissionsAbi = getAbi(
2920
+ "DataPortabilityPermissions"
2921
+ );
2922
+ const count = await this.context.publicClient.readContract({
2923
+ address: DataPortabilityPermissionsAddress,
2924
+ abi: DataPortabilityPermissionsAbi,
2925
+ functionName: "userPermissionIdsLength",
2926
+ args: [targetAddress]
2927
+ });
2928
+ return count;
2929
+ } catch (error) {
2930
+ throw new BlockchainError(
2931
+ `Failed to get user permission count: ${error instanceof Error ? error.message : "Unknown error"}`,
2932
+ error
2933
+ );
2934
+ }
2935
+ }
2936
+ /**
2937
+ * Get detailed permission information by permission ID
2938
+ *
2939
+ * @param permissionId - Permission ID to get info for
2940
+ * @returns Promise resolving to permission info
2941
+ */
2942
+ async getPermissionInfo(permissionId) {
2943
+ try {
2944
+ const chainId = await this.context.publicClient.getChainId();
2945
+ const DataPortabilityPermissionsAddress = getContractAddress(
2946
+ chainId,
2947
+ "DataPortabilityPermissions"
2948
+ );
2949
+ const DataPortabilityPermissionsAbi = getAbi(
2950
+ "DataPortabilityPermissions"
2951
+ );
2952
+ const permissionInfo = await this.context.publicClient.readContract({
2953
+ address: DataPortabilityPermissionsAddress,
2954
+ abi: DataPortabilityPermissionsAbi,
2955
+ functionName: "permissions",
2956
+ args: [permissionId]
2957
+ });
2958
+ return permissionInfo;
2959
+ } catch (error) {
2960
+ throw new BlockchainError(
2961
+ `Failed to get permission info: ${error instanceof Error ? error.message : "Unknown error"}`,
2962
+ error
2963
+ );
2964
+ }
2965
+ }
2966
+ /**
2967
+ * Get all permission IDs for a specific file
2968
+ *
2969
+ * @param fileId - File ID to get permissions for
2970
+ * @returns Promise resolving to array of permission IDs
2971
+ */
2972
+ async getFilePermissionIds(fileId) {
2973
+ try {
2974
+ const chainId = await this.context.publicClient.getChainId();
2975
+ const DataPortabilityPermissionsAddress = getContractAddress(
2976
+ chainId,
2977
+ "DataPortabilityPermissions"
2978
+ );
2979
+ const DataPortabilityPermissionsAbi = getAbi(
2980
+ "DataPortabilityPermissions"
2981
+ );
2982
+ const permissionIds = await this.context.publicClient.readContract({
2983
+ address: DataPortabilityPermissionsAddress,
2984
+ abi: DataPortabilityPermissionsAbi,
2985
+ functionName: "filePermissionIds",
2986
+ args: [fileId]
2987
+ });
2988
+ return [...permissionIds];
2989
+ } catch (error) {
2990
+ throw new BlockchainError(
2991
+ `Failed to get file permission IDs: ${error instanceof Error ? error.message : "Unknown error"}`,
2992
+ error
2993
+ );
2994
+ }
2995
+ }
2996
+ /**
2997
+ * Get all file IDs for a specific permission
2998
+ *
2999
+ * @param permissionId - Permission ID to get files for
3000
+ * @returns Promise resolving to array of file IDs
3001
+ */
3002
+ async getPermissionFileIds(permissionId) {
3003
+ try {
3004
+ const chainId = await this.context.publicClient.getChainId();
3005
+ const DataPortabilityPermissionsAddress = getContractAddress(
3006
+ chainId,
3007
+ "DataPortabilityPermissions"
3008
+ );
3009
+ const DataPortabilityPermissionsAbi = getAbi(
3010
+ "DataPortabilityPermissions"
3011
+ );
3012
+ const fileIds = await this.context.publicClient.readContract({
3013
+ address: DataPortabilityPermissionsAddress,
3014
+ abi: DataPortabilityPermissionsAbi,
3015
+ functionName: "permissionFileIds",
3016
+ args: [permissionId]
3017
+ });
3018
+ return [...fileIds];
3019
+ } catch (error) {
3020
+ throw new BlockchainError(
3021
+ `Failed to get permission file IDs: ${error instanceof Error ? error.message : "Unknown error"}`,
3022
+ error
3023
+ );
3024
+ }
3025
+ }
3026
+ /**
3027
+ * Get all permissions for a specific file (alias for getFilePermissionIds)
3028
+ *
3029
+ * @param fileId - File ID to get permissions for
3030
+ * @returns Promise resolving to array of permission IDs
3031
+ */
3032
+ async getFilePermissions(fileId) {
3033
+ const chainId = await this.context.publicClient.getChainId();
3034
+ const DataPortabilityPermissionsAddress = getContractAddress(
3035
+ chainId,
3036
+ "DataPortabilityPermissions"
3037
+ );
3038
+ const DataPortabilityPermissionsAbi = getAbi("DataPortabilityPermissions");
3039
+ const permissions = await this.context.publicClient.readContract({
3040
+ address: DataPortabilityPermissionsAddress,
3041
+ abi: DataPortabilityPermissionsAbi,
3042
+ functionName: "filePermissions",
3043
+ args: [fileId]
3044
+ });
3045
+ return [...permissions];
3046
+ }
3047
+ // ===========================
3048
+ // DATA PORTABILITY GRANTEES HELPER METHODS
3049
+ // ===========================
3050
+ /**
3051
+ * Get grantee information by grantee ID
3052
+ *
3053
+ * @param granteeId - Grantee ID to get info for
3054
+ * @returns Promise resolving to grantee info
3055
+ */
3056
+ async getGranteeInfo(granteeId) {
3057
+ try {
3058
+ const chainId = await this.context.publicClient.getChainId();
3059
+ const DataPortabilityGranteesAddress = getContractAddress(
3060
+ chainId,
3061
+ "DataPortabilityGrantees"
3062
+ );
3063
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
3064
+ const granteeInfo = await this.context.publicClient.readContract({
3065
+ address: DataPortabilityGranteesAddress,
3066
+ abi: DataPortabilityGranteesAbi,
3067
+ functionName: "granteeInfo",
3068
+ args: [granteeId]
3069
+ });
3070
+ return granteeInfo;
3071
+ } catch (error) {
3072
+ throw new BlockchainError(
3073
+ `Failed to get grantee info: ${error instanceof Error ? error.message : "Unknown error"}`,
3074
+ error
3075
+ );
3076
+ }
3077
+ }
3078
+ /**
3079
+ * Get grantee information by grantee address
3080
+ *
3081
+ * @param granteeAddress - Grantee address to get info for
3082
+ * @returns Promise resolving to grantee info
3083
+ */
3084
+ async getGranteeInfoByAddress(granteeAddress) {
3085
+ try {
3086
+ const chainId = await this.context.publicClient.getChainId();
3087
+ const DataPortabilityGranteesAddress = getContractAddress(
3088
+ chainId,
3089
+ "DataPortabilityGrantees"
3090
+ );
3091
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
3092
+ const granteeInfo = await this.context.publicClient.readContract({
3093
+ address: DataPortabilityGranteesAddress,
3094
+ abi: DataPortabilityGranteesAbi,
3095
+ functionName: "granteeByAddress",
3096
+ args: [granteeAddress]
3097
+ });
3098
+ return granteeInfo;
3099
+ } catch (error) {
3100
+ throw new BlockchainError(
3101
+ `Failed to get grantee info by address: ${error instanceof Error ? error.message : "Unknown error"}`,
3102
+ error
3103
+ );
3104
+ }
3105
+ }
3106
+ /**
3107
+ * Get all permission IDs for a specific grantee
3108
+ *
3109
+ * @param granteeId - Grantee ID to get permissions for
3110
+ * @returns Promise resolving to array of permission IDs
3111
+ */
3112
+ async getGranteePermissionIds(granteeId) {
3113
+ try {
3114
+ const chainId = await this.context.publicClient.getChainId();
3115
+ const DataPortabilityGranteesAddress = getContractAddress(
3116
+ chainId,
3117
+ "DataPortabilityGrantees"
3118
+ );
3119
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
3120
+ const permissionIds = await this.context.publicClient.readContract({
3121
+ address: DataPortabilityGranteesAddress,
3122
+ abi: DataPortabilityGranteesAbi,
3123
+ functionName: "granteePermissionIds",
3124
+ args: [granteeId]
3125
+ });
3126
+ return [...permissionIds];
3127
+ } catch (error) {
3128
+ throw new BlockchainError(
3129
+ `Failed to get grantee permission IDs: ${error instanceof Error ? error.message : "Unknown error"}`,
3130
+ error
3131
+ );
3132
+ }
3133
+ }
3134
+ /**
3135
+ * Get all permissions for a specific grantee (alias for getGranteePermissionIds)
3136
+ *
3137
+ * @param granteeId - Grantee ID to get permissions for
3138
+ * @returns Promise resolving to array of permission IDs
3139
+ */
3140
+ async getGranteePermissions(granteeId) {
3141
+ try {
3142
+ const chainId = await this.context.publicClient.getChainId();
3143
+ const DataPortabilityGranteesAddress = getContractAddress(
3144
+ chainId,
3145
+ "DataPortabilityGrantees"
3146
+ );
3147
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
3148
+ const permissions = await this.context.publicClient.readContract({
3149
+ address: DataPortabilityGranteesAddress,
3150
+ abi: DataPortabilityGranteesAbi,
3151
+ functionName: "granteePermissions",
3152
+ args: [granteeId]
3153
+ });
3154
+ return [...permissions];
3155
+ } catch (error) {
3156
+ throw new BlockchainError(
3157
+ `Failed to get grantee permissions: ${error instanceof Error ? error.message : "Unknown error"}`,
3158
+ error
3159
+ );
3160
+ }
3161
+ }
3162
+ // ===== DataPortabilityServersImplementation Methods =====
3163
+ /**
3164
+ * Get all server IDs for a user
3165
+ *
3166
+ * @param userAddress - User address to get server IDs for
3167
+ * @returns Promise resolving to array of server IDs
3168
+ */
3169
+ async getUserServerIdsValues(userAddress) {
3170
+ try {
3171
+ const chainId = await this.context.publicClient.getChainId();
3172
+ const DataPortabilityServersAddress = getContractAddress(
3173
+ chainId,
3174
+ "DataPortabilityServers"
3175
+ );
3176
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3177
+ const serverIds = await this.context.publicClient.readContract({
3178
+ address: DataPortabilityServersAddress,
3179
+ abi: DataPortabilityServersAbi,
3180
+ functionName: "userServerIdsValues",
3181
+ args: [userAddress]
3182
+ });
3183
+ return [...serverIds];
3184
+ } catch (error) {
3185
+ throw new BlockchainError(
3186
+ `Failed to get user server IDs: ${error instanceof Error ? error.message : "Unknown error"}`,
3187
+ error
3188
+ );
3189
+ }
3190
+ }
3191
+ /**
3192
+ * Get server ID at specific index for a user
3193
+ *
3194
+ * @param userAddress - User address
3195
+ * @param serverIndex - Index of the server ID
3196
+ * @returns Promise resolving to server ID
3197
+ */
3198
+ async getUserServerIdsAt(userAddress, serverIndex) {
3199
+ try {
3200
+ const chainId = await this.context.publicClient.getChainId();
3201
+ const DataPortabilityServersAddress = getContractAddress(
3202
+ chainId,
3203
+ "DataPortabilityServers"
3204
+ );
3205
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3206
+ const serverId = await this.context.publicClient.readContract({
3207
+ address: DataPortabilityServersAddress,
3208
+ abi: DataPortabilityServersAbi,
3209
+ functionName: "userServerIdsAt",
3210
+ args: [userAddress, serverIndex]
3211
+ });
3212
+ return serverId;
3213
+ } catch (error) {
3214
+ throw new BlockchainError(
3215
+ `Failed to get user server ID at index: ${error instanceof Error ? error.message : "Unknown error"}`,
3216
+ error
3217
+ );
3218
+ }
3219
+ }
3220
+ /**
3221
+ * Get the number of servers a user has
3222
+ *
3223
+ * @param userAddress - User address
3224
+ * @returns Promise resolving to number of servers
3225
+ */
3226
+ async getUserServerIdsLength(userAddress) {
3227
+ try {
3228
+ const chainId = await this.context.publicClient.getChainId();
3229
+ const DataPortabilityServersAddress = getContractAddress(
3230
+ chainId,
3231
+ "DataPortabilityServers"
3232
+ );
3233
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3234
+ const length = await this.context.publicClient.readContract({
3235
+ address: DataPortabilityServersAddress,
3236
+ abi: DataPortabilityServersAbi,
3237
+ functionName: "userServerIdsLength",
3238
+ args: [userAddress]
3239
+ });
3240
+ return length;
3241
+ } catch (error) {
3242
+ throw new BlockchainError(
3243
+ `Failed to get user server IDs length: ${error instanceof Error ? error.message : "Unknown error"}`,
3244
+ error
3245
+ );
3246
+ }
3247
+ }
3248
+ /**
3249
+ * Get trusted server info for a specific user and server ID
3250
+ *
3251
+ * @param userAddress - User address
3252
+ * @param serverId - Server ID
3253
+ * @returns Promise resolving to trusted server info
3254
+ */
3255
+ async getUserServers(userAddress, serverId) {
3256
+ try {
3257
+ const chainId = await this.context.publicClient.getChainId();
3258
+ const DataPortabilityServersAddress = getContractAddress(
3259
+ chainId,
3260
+ "DataPortabilityServers"
3261
+ );
3262
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3263
+ const serverInfo = await this.context.publicClient.readContract({
3264
+ address: DataPortabilityServersAddress,
3265
+ abi: DataPortabilityServersAbi,
3266
+ functionName: "userServers",
3267
+ args: [userAddress, serverId]
3268
+ });
3269
+ return {
3270
+ id: serverInfo.id,
3271
+ owner: serverInfo.owner,
3272
+ serverAddress: serverInfo.serverAddress,
3273
+ publicKey: serverInfo.publicKey,
3274
+ url: serverInfo.url,
3275
+ startBlock: serverInfo.startBlock,
3276
+ endBlock: serverInfo.endBlock
3277
+ };
3278
+ } catch (error) {
3279
+ throw new BlockchainError(
3280
+ `Failed to get user server info: ${error instanceof Error ? error.message : "Unknown error"}`,
3281
+ error
3282
+ );
3283
+ }
3284
+ }
3285
+ /**
3286
+ * Get server info by server ID
3287
+ *
3288
+ * @param serverId - Server ID
3289
+ * @returns Promise resolving to server info
3290
+ */
3291
+ async getServers(serverId) {
3292
+ try {
3293
+ const chainId = await this.context.publicClient.getChainId();
3294
+ const DataPortabilityServersAddress = getContractAddress(
3295
+ chainId,
3296
+ "DataPortabilityServers"
3297
+ );
3298
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3299
+ const serverInfo = await this.context.publicClient.readContract({
3300
+ address: DataPortabilityServersAddress,
3301
+ abi: DataPortabilityServersAbi,
3302
+ functionName: "servers",
3303
+ args: [serverId]
3304
+ });
3305
+ return {
3306
+ id: serverInfo.id,
3307
+ owner: serverInfo.owner,
3308
+ serverAddress: serverInfo.serverAddress,
3309
+ publicKey: serverInfo.publicKey,
3310
+ url: serverInfo.url
3311
+ };
3312
+ } catch (error) {
3313
+ throw new BlockchainError(
3314
+ `Failed to get server info: ${error instanceof Error ? error.message : "Unknown error"}`,
3315
+ error
3316
+ );
3317
+ }
3318
+ }
3319
+ /**
3320
+ * Get user info including nonce and trusted server IDs
3321
+ *
3322
+ * @param userAddress - User address
3323
+ * @returns Promise resolving to user info
3324
+ */
3325
+ async getUsers(userAddress) {
3326
+ try {
3327
+ const chainId = await this.context.publicClient.getChainId();
3328
+ const DataPortabilityServersAddress = getContractAddress(
3329
+ chainId,
3330
+ "DataPortabilityServers"
3331
+ );
3332
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3333
+ const userInfo = await this.context.publicClient.readContract({
3334
+ address: DataPortabilityServersAddress,
3335
+ abi: DataPortabilityServersAbi,
3336
+ functionName: "users",
3337
+ args: [userAddress]
3338
+ });
3339
+ return {
3340
+ nonce: userInfo[0],
3341
+ trustedServerIds: [...userInfo[1]]
3342
+ };
3343
+ } catch (error) {
3344
+ throw new BlockchainError(
3345
+ `Failed to get user info: ${error instanceof Error ? error.message : "Unknown error"}`,
3346
+ error
3347
+ );
3348
+ }
3349
+ }
3350
+ /**
3351
+ * Update server URL
3352
+ *
3353
+ * @param serverId - Server ID to update
3354
+ * @param url - New URL for the server
3355
+ * @param options - Optional transaction options for gas parameters and timeout
3356
+ * @returns Promise resolving to transaction hash
3357
+ */
3358
+ async submitUpdateServer(serverId, url, options) {
3359
+ this.assertWallet();
3360
+ try {
3361
+ const chainId = await this.context.walletClient.getChainId();
3362
+ const DataPortabilityServersAddress = getContractAddress(
3363
+ chainId,
3364
+ "DataPortabilityServers"
3365
+ );
3366
+ const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3367
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3368
+ const hash = await this.context.walletClient.writeContract({
3369
+ address: DataPortabilityServersAddress,
3370
+ abi: DataPortabilityServersAbi,
3371
+ functionName: "updateServer",
3372
+ args: [serverId, url],
3373
+ chain: this.context.walletClient?.chain,
3374
+ account,
3375
+ ...options?.gasLimit && { gas: options.gasLimit },
3376
+ ...options?.nonce && { nonce: options.nonce },
3377
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3378
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3379
+ ...options.maxFeePerGas && {
3380
+ maxFeePerGas: options.maxFeePerGas
3381
+ },
3382
+ ...options.maxPriorityFeePerGas && {
3383
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3384
+ }
3385
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3386
+ });
3387
+ const { tx } = await import("../utils/transactionHelpers");
3388
+ return tx({
3389
+ hash,
3390
+ from: typeof account === "string" ? account : account.address,
3391
+ contract: "DataPortabilityServers",
3392
+ fn: "updateServer"
3393
+ });
3394
+ } catch (error) {
3395
+ throw new BlockchainError(
3396
+ `Failed to update server: ${error instanceof Error ? error.message : "Unknown error"}`,
3397
+ error
3398
+ );
3399
+ }
3400
+ }
3401
+ // ===== DataPortabilityPermissionsImplementation Methods =====
3402
+ /**
3403
+ * Get all permission IDs for a user
3404
+ *
3405
+ * @param userAddress - User address to get permission IDs for
3406
+ * @returns Promise resolving to array of permission IDs
3407
+ */
3408
+ async getUserPermissionIdsValues(userAddress) {
3409
+ try {
3410
+ const chainId = await this.context.publicClient.getChainId();
3411
+ const DataPortabilityPermissionsAddress = getContractAddress(
3412
+ chainId,
3413
+ "DataPortabilityPermissions"
3414
+ );
3415
+ const DataPortabilityPermissionsAbi = getAbi(
3416
+ "DataPortabilityPermissions"
3417
+ );
3418
+ const permissionIds = await this.context.publicClient.readContract({
3419
+ address: DataPortabilityPermissionsAddress,
3420
+ abi: DataPortabilityPermissionsAbi,
3421
+ functionName: "userPermissionIdsValues",
3422
+ args: [userAddress]
3423
+ });
3424
+ return [...permissionIds];
3425
+ } catch (error) {
3426
+ throw new BlockchainError(
3427
+ `Failed to get user permission IDs: ${error instanceof Error ? error.message : "Unknown error"}`,
3428
+ error
3429
+ );
3430
+ }
3431
+ }
3432
+ /**
3433
+ * Get permission ID at specific index for a user
3434
+ *
3435
+ * @param userAddress - User address
3436
+ * @param permissionIndex - Index of the permission ID
3437
+ * @returns Promise resolving to permission ID
3438
+ */
3439
+ async getUserPermissionIdsAt(userAddress, permissionIndex) {
3440
+ try {
3441
+ const chainId = await this.context.publicClient.getChainId();
3442
+ const DataPortabilityPermissionsAddress = getContractAddress(
3443
+ chainId,
3444
+ "DataPortabilityPermissions"
3445
+ );
3446
+ const DataPortabilityPermissionsAbi = getAbi(
3447
+ "DataPortabilityPermissions"
3448
+ );
3449
+ const permissionId = await this.context.publicClient.readContract({
3450
+ address: DataPortabilityPermissionsAddress,
3451
+ abi: DataPortabilityPermissionsAbi,
3452
+ functionName: "userPermissionIdsAt",
3453
+ args: [userAddress, permissionIndex]
3454
+ });
3455
+ return permissionId;
3456
+ } catch (error) {
3457
+ throw new BlockchainError(
3458
+ `Failed to get user permission ID at index: ${error instanceof Error ? error.message : "Unknown error"}`,
3459
+ error
3460
+ );
3461
+ }
3462
+ }
3463
+ /**
3464
+ * Get the number of permissions a user has
3465
+ *
3466
+ * @param userAddress - User address
3467
+ * @returns Promise resolving to number of permissions
3468
+ */
3469
+ async getUserPermissionIdsLength(userAddress) {
3470
+ try {
3471
+ const chainId = await this.context.publicClient.getChainId();
3472
+ const DataPortabilityPermissionsAddress = getContractAddress(
3473
+ chainId,
3474
+ "DataPortabilityPermissions"
3475
+ );
3476
+ const DataPortabilityPermissionsAbi = getAbi(
3477
+ "DataPortabilityPermissions"
3478
+ );
3479
+ const length = await this.context.publicClient.readContract({
3480
+ address: DataPortabilityPermissionsAddress,
3481
+ abi: DataPortabilityPermissionsAbi,
3482
+ functionName: "userPermissionIdsLength",
3483
+ args: [userAddress]
3484
+ });
3485
+ return length;
3486
+ } catch (error) {
3487
+ throw new BlockchainError(
3488
+ `Failed to get user permission IDs length: ${error instanceof Error ? error.message : "Unknown error"}`,
3489
+ error
3490
+ );
3491
+ }
3492
+ }
3493
+ /**
3494
+ * Get permission info by permission ID
3495
+ *
3496
+ * @param permissionId - Permission ID
3497
+ * @returns Promise resolving to permission info
3498
+ */
3499
+ async getPermissions(permissionId) {
3500
+ try {
3501
+ const chainId = await this.context.publicClient.getChainId();
3502
+ const DataPortabilityPermissionsAddress = getContractAddress(
3503
+ chainId,
3504
+ "DataPortabilityPermissions"
3505
+ );
3506
+ const DataPortabilityPermissionsAbi = getAbi(
3507
+ "DataPortabilityPermissions"
3508
+ );
3509
+ const permissionInfo = await this.context.publicClient.readContract({
3510
+ address: DataPortabilityPermissionsAddress,
3511
+ abi: DataPortabilityPermissionsAbi,
3512
+ functionName: "permissions",
3513
+ args: [permissionId]
3514
+ });
3515
+ return {
3516
+ id: permissionInfo.id,
3517
+ grantor: permissionInfo.grantor,
3518
+ nonce: permissionInfo.nonce,
3519
+ granteeId: permissionInfo.granteeId,
3520
+ grant: permissionInfo.grant,
3521
+ startBlock: permissionInfo.startBlock,
3522
+ endBlock: permissionInfo.endBlock,
3523
+ fileIds: [...permissionInfo.fileIds]
3524
+ };
3525
+ } catch (error) {
3526
+ throw new BlockchainError(
3527
+ `Failed to get permission info: ${error instanceof Error ? error.message : "Unknown error"}`,
3528
+ error
3529
+ );
3530
+ }
3531
+ }
3532
+ /**
3533
+ * Submit permission with signature to the blockchain (supports gasless transactions)
3534
+ *
3535
+ * @param params - Parameters for adding permission
3536
+ * @returns Promise resolving to transaction hash
3537
+ * @throws {RelayerError} When gasless transaction submission fails
3538
+ * @throws {SignatureError} When user rejects the signature request
3539
+ * @throws {BlockchainError} When permission addition fails
3540
+ * @throws {NetworkError} When network communication fails
3541
+ */
3542
+ async submitAddPermission(params) {
3543
+ this.assertWallet();
3544
+ try {
3545
+ const nonce = await this.getPermissionsUserNonce();
3546
+ const addPermissionInput = {
3547
+ nonce,
3548
+ granteeId: params.granteeId,
3549
+ grant: params.grant,
3550
+ fileUrls: params.fileUrls,
3551
+ schemaIds: params.schemaIds,
3552
+ serverAddress: params.serverAddress,
3553
+ serverUrl: params.serverUrl,
3554
+ serverPublicKey: params.serverPublicKey,
3555
+ filePermissions: params.filePermissions
3556
+ };
3557
+ const typedData = await this.composeServerFilesAndPermissionMessage(addPermissionInput);
3558
+ const signature = await this.signTypedData(typedData);
3559
+ return await this.submitSignedAddPermission(typedData, signature);
3560
+ } catch (error) {
3561
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
3562
+ throw error;
3563
+ }
3564
+ throw new BlockchainError(
3565
+ `Failed to add permission: ${error instanceof Error ? error.message : "Unknown error"}`,
3566
+ error
3567
+ );
3568
+ }
3569
+ }
3570
+ /**
3571
+ * Submits an already-signed add permission transaction to the blockchain.
3572
+ * This method supports both relayer-based gasless transactions and direct transactions.
3573
+ *
3574
+ * @param typedData - The EIP-712 typed data for AddPermission
3575
+ * @param signature - The user's signature
3576
+ * @returns Promise resolving to TransactionResult with PermissionGrantResult event data
3577
+ * @throws {RelayerError} When gasless transaction submission fails
3578
+ * @throws {BlockchainError} When permission addition fails
3579
+ * @throws {NetworkError} When network communication fails
3580
+ */
3581
+ async submitSignedAddPermission(typedData, signature) {
3582
+ this.assertWallet();
3583
+ try {
3584
+ let hash;
3585
+ if (this.context.relayer) {
3586
+ const request = {
3587
+ type: "signed",
3588
+ operation: "submitAddPermission",
3589
+ typedData,
3590
+ signature
3591
+ };
3592
+ const response = await this.context.relayer(request);
3593
+ if (response.type === "error") {
3594
+ throw new RelayerError(response.error);
3595
+ }
3596
+ if (response.type === "signed") {
3597
+ hash = response.hash;
3598
+ } else {
3599
+ throw new Error("Unexpected response type from relayer");
3600
+ }
3601
+ } else {
3602
+ hash = await this.submitDirectAddPermissionTransaction(
3603
+ typedData,
3604
+ signature
3605
+ );
3606
+ }
3607
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3608
+ const { tx } = await import("../utils/transactionHelpers");
3609
+ return tx({
3610
+ hash,
3611
+ from: typeof account === "string" ? account : account.address,
3612
+ contract: "DataPortabilityPermissions",
3613
+ fn: "addPermission"
3614
+ });
3615
+ } catch (error) {
3616
+ if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
3617
+ throw error;
3618
+ }
3619
+ throw new BlockchainError(
3620
+ `Add permission submission failed: ${error instanceof Error ? error.message : "Unknown error"}`,
3621
+ error
3622
+ );
3623
+ }
3624
+ }
3625
+ /**
3626
+ * Submits server files and permissions with signature to the blockchain, supporting schema validation and gasless transactions.
3627
+ *
3628
+ * @remarks
3629
+ * This method validates files against their specified schemas before submission.
3630
+ * Schema validation ensures data conforms to expected formats before on-chain registration.
3631
+ * Files with schemaId = 0 bypass validation. The method supports atomic batch operations
3632
+ * where all files and permissions are registered in a single transaction.
3633
+ *
3634
+ * @param params - Parameters for adding server files and permissions
3635
+ * @param params.granteeId - The ID of the permission grantee
3636
+ * @param params.grant - Grant URL containing permission parameters (typically IPFS)
3637
+ * @param params.fileUrls - Array of file URLs to register
3638
+ * @param params.schemaIds - Schema IDs for each file. Use 0 for files without schema validation.
3639
+ * Array length must match fileUrls length.
3640
+ * @param params.serverAddress - Server wallet address for decryption permissions
3641
+ * @param params.serverUrl - Server endpoint URL
3642
+ * @param params.serverPublicKey - Server's public key for encryption.
3643
+ * Obtain via `vana.server.getIdentity(userAddress).publicKey`.
3644
+ * @param params.filePermissions - Nested array of permissions for each file
3645
+ * @param options - Optional transaction options for gas parameters and timeout.
3646
+ * Note: These options are only applied for direct blockchain transactions.
3647
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3648
+ * @returns TransactionResult with immediate hash access and optional event data
3649
+ * @throws {Error} When schemaIds array length doesn't match fileUrls array length
3650
+ * @throws {SchemaValidationError} When file data doesn't match the specified schema.
3651
+ * Verify data structure matches schema definition from `vana.schemas.get(schemaId)`.
3652
+ * @throws {RelayerError} When gasless transaction submission fails.
3653
+ * Retry without relayer configuration to submit direct transaction.
3654
+ * @throws {SignatureError} When user rejects the signature request
3655
+ * @throws {BlockchainError} When server files and permissions addition fails
3656
+ * @throws {NetworkError} When network communication fails.
3657
+ * Check network connection or configure alternative gateways.
3658
+ *
3659
+ * @example
3660
+ * ```typescript
3661
+ * // Submit with custom gas parameters and timeout
3662
+ * const result = await vana.permissions.submitAddServerFilesAndPermissions({
3663
+ * granteeId: BigInt(1),
3664
+ * grant: "ipfs://QmXxx...",
3665
+ * fileUrls: ["https://storage.example.com/data.json"],
3666
+ * schemaIds: [123], // LinkedIn profile schema ID
3667
+ * serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3668
+ * serverUrl: "https://server.example.com",
3669
+ * serverPublicKey: serverInfo.publicKey,
3670
+ * filePermissions: [[{
3671
+ * account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3672
+ * key: encryptedKey
3673
+ * }]]
3674
+ * }, {
3675
+ * maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
3676
+ * maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
3677
+ * });
3678
+ *
3679
+ * // Wait for confirmation with custom timeout
3680
+ * const receipt = await vana.waitForTransactionReceipt(result, {
3681
+ * timeout: 180000 // 3 minutes
3682
+ * });
3683
+ * console.log(`Transaction confirmed: ${receipt.transactionHash}`);
3684
+ * ```
3685
+ */
3686
+ async submitAddServerFilesAndPermissions(params, options) {
3687
+ this.assertWallet();
3688
+ try {
3689
+ if (params.schemaIds.length !== params.fileUrls.length) {
3690
+ throw new Error(
3691
+ `schemaIds array length (${params.schemaIds.length}) must match fileUrls array length (${params.fileUrls.length})`
3692
+ );
3693
+ }
3694
+ const nonce = await this.getPermissionsUserNonce();
3695
+ const serverFilesAndPermissionInput = {
3696
+ nonce,
3697
+ granteeId: params.granteeId,
3698
+ grant: params.grant,
3699
+ fileUrls: params.fileUrls,
3700
+ schemaIds: params.schemaIds,
3701
+ serverAddress: params.serverAddress,
3702
+ serverUrl: params.serverUrl,
3703
+ serverPublicKey: params.serverPublicKey,
3704
+ filePermissions: params.filePermissions
3705
+ };
3706
+ const typedData = await this.composeServerFilesAndPermissionMessage(
3707
+ serverFilesAndPermissionInput
3708
+ );
3709
+ const signature = await this.signTypedData(typedData);
3710
+ return await this.submitSignedAddServerFilesAndPermissions(
3711
+ typedData,
3712
+ signature,
3713
+ options
3714
+ );
3715
+ } catch (error) {
3716
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
3717
+ throw error;
3718
+ }
3719
+ throw new BlockchainError(
3720
+ `Failed to add server files and permissions: ${error instanceof Error ? error.message : "Unknown error"}`,
3721
+ error
3722
+ );
3723
+ }
3724
+ }
3725
+ /**
3726
+ * Submits an already-signed add server files and permissions transaction to the blockchain.
3727
+ *
3728
+ * @remarks
3729
+ * This method returns a TransactionResult that provides immediate access to the transaction hash.
3730
+ * The eventData field may contain parsed event details after transaction confirmation.
3731
+ *
3732
+ * @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
3733
+ * @param signature - The user's signature
3734
+ * @param options - Optional transaction options for gas parameters and timeout.
3735
+ * Note: These options are only applied for direct blockchain transactions.
3736
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3737
+ * @returns TransactionResult with immediate hash access and optional event data
3738
+ * @throws {RelayerError} When gasless transaction submission fails
3739
+ * @throws {BlockchainError} When server files and permissions addition fails
3740
+ * @throws {NetworkError} When network communication fails
3741
+ *
3742
+ * @example
3743
+ * ```typescript
3744
+ * const tx = await vana.permissions.submitSignedAddServerFilesAndPermissions(
3745
+ * typedData,
3746
+ * signature
3747
+ * );
3748
+ * console.log(`Transaction submitted: ${tx.hash}`);
3749
+ *
3750
+ * // Wait for confirmation and get the permission ID
3751
+ * const { permissionId } = await tx.waitForEvents();
3752
+ * console.log(`Permission created with ID: ${permissionId}`);
3753
+ * ```
3754
+ */
3755
+ async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
3756
+ this.assertWallet();
3757
+ try {
3758
+ let hash;
3759
+ if (this.context.relayer) {
3760
+ console.debug(
3761
+ "\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
3762
+ );
3763
+ const request = {
3764
+ type: "signed",
3765
+ operation: "submitAddServerFilesAndPermissions",
3766
+ typedData,
3767
+ signature
3768
+ };
3769
+ const response = await this.context.relayer(request);
3770
+ if (response.type === "error") {
3771
+ throw new RelayerError(response.error);
3772
+ }
3773
+ if (response.type === "signed") {
3774
+ hash = response.hash;
3775
+ } else {
3776
+ throw new Error("Unexpected response type from relayer");
3777
+ }
3778
+ } else {
3779
+ console.debug(
3780
+ "\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
3781
+ );
3782
+ hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3783
+ typedData,
3784
+ signature,
3785
+ options
3786
+ );
3787
+ }
3788
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3789
+ const { tx } = await import("../utils/transactionHelpers");
3790
+ return tx({
3791
+ hash,
3792
+ from: typeof account === "string" ? account : account.address,
3793
+ contract: "DataPortabilityPermissions",
3794
+ fn: "addServerFilesAndPermissions"
3795
+ });
3796
+ } catch (error) {
3797
+ if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
3798
+ throw error;
3799
+ }
3800
+ throw new BlockchainError(
3801
+ `Add server files and permissions submission failed: ${error instanceof Error ? error.message : "Unknown error"}`,
3802
+ error
3803
+ );
3804
+ }
3805
+ }
3806
+ /**
3807
+ * Submit permission revocation with signature to the blockchain
3808
+ *
3809
+ * @param permissionId - Permission ID to revoke
3810
+ * @param options - Optional transaction options for gas parameters and timeout
3811
+ * @returns Promise resolving to transaction hash
3812
+ */
3813
+ async submitRevokePermission(permissionId, options) {
3814
+ this.assertWallet();
3815
+ try {
3816
+ const chainId = await this.context.walletClient.getChainId();
3817
+ const DataPortabilityPermissionsAddress = getContractAddress(
3818
+ chainId,
3819
+ "DataPortabilityPermissions"
3820
+ );
3821
+ const DataPortabilityPermissionsAbi = getAbi(
3822
+ "DataPortabilityPermissions"
3823
+ );
3824
+ const { account } = this.context.walletClient;
3825
+ if (!account) {
3826
+ throw new Error("No wallet account connected");
3827
+ }
3828
+ const hash = await this.context.walletClient.writeContract({
3829
+ address: DataPortabilityPermissionsAddress,
3830
+ abi: DataPortabilityPermissionsAbi,
3831
+ functionName: "revokePermission",
3832
+ args: [permissionId],
3833
+ chain: this.context.walletClient?.chain,
3834
+ account,
3835
+ ...options?.gasLimit && { gas: options.gasLimit },
3836
+ ...options?.nonce && { nonce: options.nonce },
3837
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3838
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3839
+ ...options.maxFeePerGas && {
3840
+ maxFeePerGas: options.maxFeePerGas
3841
+ },
3842
+ ...options.maxPriorityFeePerGas && {
3843
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3844
+ }
3845
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3846
+ });
3847
+ const { tx } = await import("../utils/transactionHelpers");
3848
+ return tx({
3849
+ hash,
3850
+ from: typeof account === "string" ? account : account.address,
3851
+ contract: "DataPortabilityPermissions",
3852
+ fn: "revokePermission"
3853
+ });
3854
+ } catch (error) {
3855
+ throw new BlockchainError(
3856
+ `Failed to revoke permission: ${error instanceof Error ? error.message : "Unknown error"}`,
3857
+ error
3858
+ );
3859
+ }
3860
+ }
3861
+ /**
3862
+ * Submits a signed add permission transaction directly to the blockchain.
3863
+ *
3864
+ * @param typedData - The typed data structure for the permission addition
3865
+ * @param signature - The cryptographic signature authorizing the transaction
3866
+ * @returns Promise resolving to the transaction hash
3867
+ */
3868
+ async submitDirectAddPermissionTransaction(typedData, signature) {
3869
+ this.assertWallet();
3870
+ const chainId = await this.context.walletClient.getChainId();
3871
+ const DataPortabilityPermissionsAddress = getContractAddress(
3872
+ chainId,
3873
+ "DataPortabilityPermissions"
3874
+ );
3875
+ const DataPortabilityPermissionsAbi = getAbi("DataPortabilityPermissions");
3876
+ const permissionInput = {
3877
+ nonce: typedData.message.nonce,
3878
+ granteeId: typedData.message.granteeId,
3879
+ grant: typedData.message.grant,
3880
+ fileIds: typedData.message.fileIds ?? []
3881
+ };
3882
+ const formattedSignature = formatSignatureForContract(signature);
3883
+ const hash = await this.context.walletClient.writeContract({
3884
+ address: DataPortabilityPermissionsAddress,
3885
+ abi: DataPortabilityPermissionsAbi,
3886
+ functionName: "addPermission",
3887
+ args: [permissionInput, formattedSignature],
3888
+ account: this.context.walletClient?.account ?? this.context.userAddress,
3889
+ chain: this.context.walletClient?.chain ?? null
3890
+ });
3891
+ return hash;
3892
+ }
3893
+ /**
3894
+ * Submits a signed add server files and permissions transaction directly to the blockchain.
3895
+ *
3896
+ * @param typedData - The typed data structure for the server files and permissions addition
3897
+ * @param signature - The cryptographic signature authorizing the transaction
3898
+ * @returns Promise resolving to the transaction hash
3899
+ */
3900
+ async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
3901
+ this.assertWallet();
3902
+ const chainId = await this.context.publicClient.getChainId();
3903
+ const DataPortabilityPermissionsAddress = getContractAddress(
3904
+ chainId,
3905
+ "DataPortabilityPermissions"
3906
+ );
3907
+ const DataPortabilityPermissionsAbi = getAbi("DataPortabilityPermissions");
3908
+ const serverFilesAndPermissionInput = {
3909
+ nonce: typedData.message.nonce,
3910
+ granteeId: typedData.message.granteeId,
3911
+ grant: typedData.message.grant,
3912
+ fileUrls: typedData.message.fileUrls,
3913
+ schemaIds: typedData.message.schemaIds,
3914
+ serverAddress: typedData.message.serverAddress,
3915
+ serverUrl: typedData.message.serverUrl,
3916
+ serverPublicKey: typedData.message.serverPublicKey,
3917
+ filePermissions: typedData.message.filePermissions
3918
+ };
3919
+ const formattedSignature = formatSignatureForContract(signature);
3920
+ const hash = await this.context.walletClient.writeContract({
3921
+ address: DataPortabilityPermissionsAddress,
3922
+ abi: DataPortabilityPermissionsAbi,
3923
+ functionName: "addServerFilesAndPermissions",
3924
+ // @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
3925
+ args: [serverFilesAndPermissionInput, formattedSignature],
3926
+ account: this.context.walletClient?.account ?? this.context.userAddress,
3927
+ chain: this.context.walletClient?.chain ?? null,
3928
+ ...options?.gasLimit && { gas: options.gasLimit },
3929
+ ...options?.nonce && { nonce: options.nonce },
3930
+ ...options?.value && { value: options.value },
3931
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3932
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3933
+ ...options.maxFeePerGas && {
3934
+ maxFeePerGas: options.maxFeePerGas
3935
+ },
3936
+ ...options.maxPriorityFeePerGas && {
3937
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3938
+ }
3939
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3940
+ });
3941
+ return hash;
3942
+ }
3943
+ }
3944
+ export {
3945
+ PermissionsController
3946
+ };
3947
+ //# sourceMappingURL=permissions.js.map