@opendatalabs/vana-sdk 0.1.0-alpha.276ea01 → 0.1.0-alpha.2b6935d

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 (680) hide show
  1. package/dist/__tests__/waitForTransactionEvents.test.d.ts +1 -0
  2. package/dist/browser.d.ts +4 -2
  3. package/dist/chains/definitions.cjs +9 -6
  4. package/dist/chains/definitions.cjs.map +1 -1
  5. package/dist/chains/definitions.d.ts +9 -11
  6. package/dist/chains/definitions.js +9 -6
  7. package/dist/chains/definitions.js.map +1 -1
  8. package/dist/chains/index.d.ts +5 -2
  9. package/dist/chains.browser.d.ts +8 -2
  10. package/dist/chains.d.ts +8 -2
  11. package/dist/chains.node.d.ts +8 -2
  12. package/dist/config/addresses.d.ts +8 -24
  13. package/dist/config/chains.d.ts +9 -13
  14. package/dist/config/default-services.cjs +60 -0
  15. package/dist/config/default-services.cjs.map +1 -0
  16. package/dist/config/default-services.d.ts +46 -0
  17. package/dist/config/default-services.js +33 -0
  18. package/dist/config/default-services.js.map +1 -0
  19. package/dist/config/default-services.test.d.ts +1 -0
  20. package/dist/config/features.d.ts +1 -3
  21. package/dist/config/tests/addresses.test.d.ts +1 -0
  22. package/dist/contracts/contractController.cjs +3 -3
  23. package/dist/contracts/contractController.cjs.map +1 -1
  24. package/dist/contracts/contractController.d.ts +11 -28
  25. package/dist/contracts/contractController.js +4 -7
  26. package/dist/contracts/contractController.js.map +1 -1
  27. package/dist/contracts/tests/contractController.test.d.ts +1 -0
  28. package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
  29. package/dist/controllers/base.cjs +83 -0
  30. package/dist/controllers/base.cjs.map +1 -0
  31. package/dist/controllers/base.d.ts +84 -0
  32. package/dist/controllers/base.js +59 -0
  33. package/dist/controllers/base.js.map +1 -0
  34. package/dist/controllers/data-error-handling.test.d.ts +1 -0
  35. package/dist/controllers/data.cjs +444 -191
  36. package/dist/controllers/data.cjs.map +1 -1
  37. package/dist/controllers/data.d.ts +149 -76
  38. package/dist/controllers/data.js +444 -191
  39. package/dist/controllers/data.js.map +1 -1
  40. package/dist/controllers/permissions.cjs +551 -395
  41. package/dist/controllers/permissions.cjs.map +1 -1
  42. package/dist/controllers/permissions.d.ts +1283 -25
  43. package/dist/controllers/permissions.js +551 -395
  44. package/dist/controllers/permissions.js.map +1 -1
  45. package/dist/controllers/protocol.cjs +15 -11
  46. package/dist/controllers/protocol.cjs.map +1 -1
  47. package/dist/controllers/protocol.d.ts +7 -35
  48. package/dist/controllers/protocol.js +15 -14
  49. package/dist/controllers/protocol.js.map +1 -1
  50. package/dist/controllers/schemas.cjs +69 -54
  51. package/dist/controllers/schemas.cjs.map +1 -1
  52. package/dist/controllers/schemas.d.ts +9 -36
  53. package/dist/controllers/schemas.js +69 -54
  54. package/dist/controllers/schemas.js.map +1 -1
  55. package/dist/controllers/server-additional.test.d.ts +1 -0
  56. package/dist/controllers/server.cjs +15 -10
  57. package/dist/controllers/server.cjs.map +1 -1
  58. package/dist/controllers/server.d.ts +7 -33
  59. package/dist/controllers/server.js +15 -10
  60. package/dist/controllers/server.js.map +1 -1
  61. package/dist/core/apiClient.cjs +15 -12
  62. package/dist/core/apiClient.cjs.map +1 -1
  63. package/dist/core/apiClient.d.ts +5 -9
  64. package/dist/core/apiClient.js +19 -19
  65. package/dist/core/apiClient.js.map +1 -1
  66. package/dist/core/client.cjs +7 -7
  67. package/dist/core/client.cjs.map +1 -1
  68. package/dist/core/client.d.ts +6 -9
  69. package/dist/core/client.js +7 -7
  70. package/dist/core/client.js.map +1 -1
  71. package/dist/core/core.test.d.ts +1 -0
  72. package/dist/core/generics.cjs +11 -9
  73. package/dist/core/generics.cjs.map +1 -1
  74. package/dist/core/generics.d.ts +9 -13
  75. package/dist/core/generics.js +22 -29
  76. package/dist/core/generics.js.map +1 -1
  77. package/dist/core/tests/apiClient.test.d.ts +1 -0
  78. package/dist/core/tests/client.test.d.ts +1 -0
  79. package/dist/core/tests/generics.test.d.ts +1 -0
  80. package/dist/core.cjs +143 -60
  81. package/dist/core.cjs.map +1 -1
  82. package/dist/core.d.ts +42 -66
  83. package/dist/core.js +155 -85
  84. package/dist/core.js.map +1 -1
  85. package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
  86. package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
  87. package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
  88. package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
  89. package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
  90. package/dist/crypto/ecies/__tests__/test-vectors.d.ts +2 -4
  91. package/dist/crypto/ecies/base.cjs +4 -3
  92. package/dist/crypto/ecies/base.cjs.map +1 -1
  93. package/dist/crypto/ecies/base.d.ts +2 -5
  94. package/dist/crypto/ecies/base.js +12 -15
  95. package/dist/crypto/ecies/base.js.map +1 -1
  96. package/dist/crypto/ecies/browser.cjs +2 -1
  97. package/dist/crypto/ecies/browser.cjs.map +1 -1
  98. package/dist/crypto/ecies/browser.d.ts +2 -7
  99. package/dist/crypto/ecies/browser.js +2 -1
  100. package/dist/crypto/ecies/browser.js.map +1 -1
  101. package/dist/crypto/ecies/constants.d.ts +7 -9
  102. package/dist/crypto/ecies/index.d.ts +8 -1
  103. package/dist/crypto/ecies/interface.cjs +4 -5
  104. package/dist/crypto/ecies/interface.cjs.map +1 -1
  105. package/dist/crypto/ecies/interface.d.ts +9 -11
  106. package/dist/crypto/ecies/interface.js +4 -5
  107. package/dist/crypto/ecies/interface.js.map +1 -1
  108. package/dist/crypto/ecies/node.cjs +3 -2
  109. package/dist/crypto/ecies/node.cjs.map +1 -1
  110. package/dist/crypto/ecies/node.d.ts +2 -7
  111. package/dist/crypto/ecies/node.js +11 -16
  112. package/dist/crypto/ecies/node.js.map +1 -1
  113. package/dist/crypto/ecies/utils.cjs +2 -41
  114. package/dist/crypto/ecies/utils.cjs.map +1 -1
  115. package/dist/crypto/ecies/utils.d.ts +3 -40
  116. package/dist/crypto/ecies/utils.js +1 -35
  117. package/dist/crypto/ecies/utils.js.map +1 -1
  118. package/dist/crypto/services/WalletKeyEncryptionService.cjs +2 -2
  119. package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -1
  120. package/dist/crypto/services/WalletKeyEncryptionService.d.ts +3 -7
  121. package/dist/crypto/services/WalletKeyEncryptionService.js +5 -9
  122. package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -1
  123. package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
  124. package/dist/diagnostics.d.ts +1 -3
  125. package/dist/diagnostics.test.d.ts +1 -0
  126. package/dist/errors.cjs +16 -0
  127. package/dist/errors.cjs.map +1 -1
  128. package/dist/errors.d.ts +53 -15
  129. package/dist/errors.js +18 -6
  130. package/dist/errors.js.map +1 -1
  131. package/dist/generated/abi/ComputeEngineImplementation.d.ts +2 -3
  132. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +2 -3
  133. package/dist/generated/abi/DATFactoryImplementation.d.ts +2 -3
  134. package/dist/generated/abi/DATImplementation.d.ts +2 -3
  135. package/dist/generated/abi/DATPausableImplementation.d.ts +2 -3
  136. package/dist/generated/abi/DATVotesImplementation.d.ts +2 -3
  137. package/dist/generated/abi/DLPPerformanceImplementation.d.ts +2 -3
  138. package/dist/generated/abi/DLPRegistryImplementation.d.ts +2 -3
  139. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +2 -3
  140. package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +2 -3
  141. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +2 -3
  142. package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +2 -3
  143. package/dist/generated/abi/DLPRootImplementation.d.ts +1 -3
  144. package/dist/generated/abi/DLPTreasuryImplementation.d.ts +2 -3
  145. package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +1 -3
  146. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +2 -3
  147. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +2 -3
  148. package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +2 -3
  149. package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +2 -3
  150. package/dist/generated/abi/DataRegistryImplementation.cjs +13 -0
  151. package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
  152. package/dist/generated/abi/DataRegistryImplementation.d.ts +12 -3
  153. package/dist/generated/abi/DataRegistryImplementation.js +13 -0
  154. package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
  155. package/dist/generated/abi/QueryEngineImplementation.d.ts +2 -3
  156. package/dist/generated/abi/SwapHelperImplementation.d.ts +2 -3
  157. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +2 -3
  158. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +2 -3
  159. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +2 -3
  160. package/dist/generated/abi/TeePoolImplementation.d.ts +2 -3
  161. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +2 -3
  162. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +2 -3
  163. package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +2 -3
  164. package/dist/generated/abi/VanaEpochImplementation.d.ts +2 -3
  165. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +2 -3
  166. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +2 -3
  167. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +2 -3
  168. package/dist/generated/abi/index.cjs +42 -0
  169. package/dist/generated/abi/index.cjs.map +1 -1
  170. package/dist/generated/abi/index.d.ts +47 -18
  171. package/dist/generated/abi/index.js +21 -0
  172. package/dist/generated/abi/index.js.map +1 -1
  173. package/dist/generated/event-types.cjs +17 -0
  174. package/dist/generated/event-types.cjs.map +1 -0
  175. package/dist/generated/event-types.d.ts +854 -0
  176. package/dist/generated/event-types.js +1 -0
  177. package/dist/generated/event-types.js.map +1 -0
  178. package/dist/generated/eventRegistry.cjs +3351 -0
  179. package/dist/generated/eventRegistry.cjs.map +1 -0
  180. package/dist/generated/eventRegistry.d.ts +14 -0
  181. package/dist/generated/eventRegistry.js +3326 -0
  182. package/dist/generated/eventRegistry.js.map +1 -0
  183. package/dist/generated/server/server-exports.d.ts +19 -21
  184. package/dist/generated/server/server.cjs.map +1 -1
  185. package/dist/generated/server/server.d.ts +113 -87
  186. package/dist/generated/subgraph.d.ts +329 -332
  187. package/dist/index.browser.d.ts +48 -73
  188. package/dist/index.browser.js +12 -0
  189. package/dist/index.browser.js.map +1 -1
  190. package/dist/index.cjs +3 -1
  191. package/dist/index.cjs.map +1 -1
  192. package/dist/index.d.ts +0 -2
  193. package/dist/index.js +3 -1
  194. package/dist/index.js.map +1 -1
  195. package/dist/index.node.cjs +12 -0
  196. package/dist/index.node.cjs.map +1 -1
  197. package/dist/index.node.d.ts +183 -64
  198. package/dist/index.node.js +12 -0
  199. package/dist/index.node.js.map +1 -1
  200. package/dist/node.d.ts +4 -2
  201. package/dist/platform/browser-only.d.ts +5 -8
  202. package/dist/platform/browser-only.test.d.ts +1 -0
  203. package/dist/platform/browser-safe.d.ts +6 -9
  204. package/dist/platform/browser-safe.test.d.ts +1 -0
  205. package/dist/platform/browser.cjs +7 -6
  206. package/dist/platform/browser.cjs.map +1 -1
  207. package/dist/platform/browser.d.ts +3 -6
  208. package/dist/platform/browser.js +19 -27
  209. package/dist/platform/browser.js.map +1 -1
  210. package/dist/platform/browser.test.d.ts +1 -0
  211. package/dist/platform/index.d.ts +11 -5
  212. package/dist/platform/interface.d.ts +6 -8
  213. package/dist/platform/node.d.ts +3 -7
  214. package/dist/platform/node.js +12 -19
  215. package/dist/platform/node.js.map +1 -1
  216. package/dist/platform/ports/openpgp-port.cjs +74 -0
  217. package/dist/platform/ports/openpgp-port.cjs.map +1 -0
  218. package/dist/platform/ports/openpgp-port.d.ts +13 -0
  219. package/dist/platform/ports/openpgp-port.js +59 -0
  220. package/dist/platform/ports/openpgp-port.js.map +1 -0
  221. package/dist/platform/ports/pgp-port.cjs +17 -0
  222. package/dist/platform/ports/pgp-port.cjs.map +1 -0
  223. package/dist/platform/ports/pgp-port.d.ts +35 -0
  224. package/dist/platform/ports/pgp-port.js +1 -0
  225. package/dist/platform/ports/pgp-port.js.map +1 -0
  226. package/dist/platform/shared/error-utils.d.ts +2 -4
  227. package/dist/platform/shared/pgp-utils.cjs +2 -2
  228. package/dist/platform/shared/pgp-utils.cjs.map +1 -1
  229. package/dist/platform/shared/pgp-utils.d.ts +3 -5
  230. package/dist/platform/shared/pgp-utils.js +2 -2
  231. package/dist/platform/shared/pgp-utils.js.map +1 -1
  232. package/dist/platform/shared/stream-utils.d.ts +1 -3
  233. package/dist/platform/utils.d.ts +6 -10
  234. package/dist/platform/utils.test.d.ts +1 -0
  235. package/dist/platform.browser.d.ts +9 -4
  236. package/dist/platform.d.ts +11 -5
  237. package/dist/platform.node.d.ts +10 -5
  238. package/dist/server/handler.cjs +7 -5
  239. package/dist/server/handler.cjs.map +1 -1
  240. package/dist/server/handler.d.ts +17 -204
  241. package/dist/server/handler.js +7 -5
  242. package/dist/server/handler.js.map +1 -1
  243. package/dist/server/relayerHandler.cjs +220 -0
  244. package/dist/server/relayerHandler.cjs.map +1 -0
  245. package/dist/server/relayerHandler.d.ts +37 -0
  246. package/dist/server/relayerHandler.js +195 -0
  247. package/dist/server/relayerHandler.js.map +1 -0
  248. package/dist/storage/index.d.ts +56 -10
  249. package/dist/storage/manager.cjs +2 -2
  250. package/dist/storage/manager.cjs.map +1 -1
  251. package/dist/storage/manager.d.ts +2 -5
  252. package/dist/storage/manager.js +5 -12
  253. package/dist/storage/manager.js.map +1 -1
  254. package/dist/storage/providers/callback-storage.cjs +3 -3
  255. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  256. package/dist/storage/providers/callback-storage.d.ts +3 -9
  257. package/dist/storage/providers/callback-storage.js +3 -3
  258. package/dist/storage/providers/callback-storage.js.map +1 -1
  259. package/dist/storage/providers/google-drive.cjs +2 -2
  260. package/dist/storage/providers/google-drive.cjs.map +1 -1
  261. package/dist/storage/providers/google-drive.d.ts +3 -7
  262. package/dist/storage/providers/google-drive.js +4 -7
  263. package/dist/storage/providers/google-drive.js.map +1 -1
  264. package/dist/storage/providers/google-drive.test.d.ts +1 -0
  265. package/dist/storage/providers/ipfs.cjs +5 -5
  266. package/dist/storage/providers/ipfs.cjs.map +1 -1
  267. package/dist/storage/providers/ipfs.d.ts +3 -6
  268. package/dist/storage/providers/ipfs.js +7 -10
  269. package/dist/storage/providers/ipfs.js.map +1 -1
  270. package/dist/storage/providers/pinata.cjs +6 -6
  271. package/dist/storage/providers/pinata.cjs.map +1 -1
  272. package/dist/storage/providers/pinata.d.ts +5 -8
  273. package/dist/storage/providers/pinata.js +8 -11
  274. package/dist/storage/providers/pinata.js.map +1 -1
  275. package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
  276. package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
  277. package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
  278. package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
  279. package/dist/storage/tests/storageManager.test.d.ts +1 -0
  280. package/dist/tests/abi.test.d.ts +1 -0
  281. package/dist/tests/chains-definitions.test.d.ts +1 -0
  282. package/dist/tests/core-encryption.test.d.ts +1 -0
  283. package/dist/tests/core-extended.test.d.ts +1 -0
  284. package/dist/tests/core-generics-coverage.test.d.ts +1 -0
  285. package/dist/tests/coverage-boost.test.d.ts +1 -0
  286. package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
  287. package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
  288. package/dist/tests/data-additional-methods.test.d.ts +1 -0
  289. package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
  290. package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
  291. package/dist/tests/data-relayer.test.d.ts +1 -0
  292. package/dist/tests/data-schema-validation.test.d.ts +1 -0
  293. package/dist/tests/data-simple-methods.test.d.ts +1 -0
  294. package/dist/tests/data.test.d.ts +1 -0
  295. package/dist/tests/demo-integration.test.d.ts +1 -0
  296. package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
  297. package/dist/tests/download-relayer.test.d.ts +1 -0
  298. package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
  299. package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
  300. package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
  301. package/dist/tests/encryption-coverage.test.d.ts +1 -0
  302. package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
  303. package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
  304. package/dist/tests/errors-coverage.test.d.ts +1 -0
  305. package/dist/tests/errors.test.d.ts +1 -0
  306. package/dist/tests/factories/mockFactory.d.ts +316 -0
  307. package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
  308. package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
  309. package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
  310. package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
  311. package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
  312. package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
  313. package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
  314. package/dist/tests/helper-methods.test.d.ts +1 -0
  315. package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
  316. package/dist/tests/helpers/typedMocks.d.ts +64 -0
  317. package/dist/tests/index-browser.test.d.ts +1 -0
  318. package/dist/tests/index-node.test.d.ts +1 -0
  319. package/dist/tests/index.test.d.ts +1 -0
  320. package/dist/tests/mocks/platformAdapter.d.ts +12 -0
  321. package/dist/tests/new-permissions-methods.test.d.ts +1 -0
  322. package/dist/tests/no-buffer-browser.test.d.ts +1 -0
  323. package/dist/tests/permissions-grantee.test.d.ts +1 -0
  324. package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
  325. package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
  326. package/dist/tests/permissions-server-files.test.d.ts +1 -0
  327. package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
  328. package/dist/tests/permissions.test.d.ts +1 -0
  329. package/dist/tests/personal.test.d.ts +1 -0
  330. package/dist/tests/platform-browser.test.d.ts +1 -0
  331. package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
  332. package/dist/tests/platform-crypto.test.d.ts +1 -0
  333. package/dist/tests/platform-index.test.d.ts +1 -0
  334. package/dist/tests/platform-node.test.d.ts +1 -0
  335. package/dist/tests/platform-shared-utils.test.d.ts +1 -0
  336. package/dist/tests/platform-updated.test.d.ts +1 -0
  337. package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
  338. package/dist/tests/protocol.test.d.ts +1 -0
  339. package/dist/tests/read-only-mode.test.d.ts +1 -0
  340. package/dist/tests/relayer-integration.test.d.ts +1 -0
  341. package/dist/tests/relayer-unified.test.d.ts +1 -0
  342. package/dist/tests/schemas.test.d.ts +1 -0
  343. package/dist/tests/server-handler.test.d.ts +1 -0
  344. package/dist/tests/server-relayer-handler.test.d.ts +1 -0
  345. package/dist/tests/setup.d.ts +7 -0
  346. package/dist/tests/signatureFormatter.test.d.ts +1 -0
  347. package/dist/tests/trusted-server-queries.test.d.ts +1 -0
  348. package/dist/tests/typedDataConverter.test.d.ts +1 -0
  349. package/dist/tests/types-contracts.test.d.ts +1 -0
  350. package/dist/tests/types-data.test.d.ts +1 -0
  351. package/dist/tests/types-external-apis.test.d.ts +1 -0
  352. package/dist/tests/types-generics.test.d.ts +1 -0
  353. package/dist/tests/types-permissions.test.d.ts +1 -0
  354. package/dist/tests/types-upload-params.test.d.ts +1 -0
  355. package/dist/tests/types.test.d.ts +1 -0
  356. package/dist/tests/utils-formatters.test.d.ts +1 -0
  357. package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
  358. package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
  359. package/dist/tests/utils-grantFiles.test.d.ts +1 -0
  360. package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
  361. package/dist/tests/utils-grants.test.d.ts +1 -0
  362. package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
  363. package/dist/tests/utils-ipfs.test.d.ts +4 -0
  364. package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
  365. package/dist/tests/vana.test.d.ts +1 -0
  366. package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
  367. package/dist/types/blockchain.cjs +17 -0
  368. package/dist/types/blockchain.cjs.map +1 -0
  369. package/dist/types/blockchain.d.ts +57 -0
  370. package/dist/types/blockchain.js +1 -0
  371. package/dist/types/blockchain.js.map +1 -0
  372. package/dist/types/chains-additional.test.d.ts +1 -0
  373. package/dist/types/chains.d.ts +6 -9
  374. package/dist/types/config.cjs +10 -0
  375. package/dist/types/config.cjs.map +1 -1
  376. package/dist/types/config.d.ts +198 -238
  377. package/dist/types/config.js +8 -0
  378. package/dist/types/config.js.map +1 -1
  379. package/dist/types/contracts.cjs.map +1 -1
  380. package/dist/types/contracts.d.ts +8 -11
  381. package/dist/types/controller-context.cjs +17 -0
  382. package/dist/types/controller-context.cjs.map +1 -0
  383. package/dist/types/controller-context.d.ts +65 -0
  384. package/dist/types/controller-context.js +1 -0
  385. package/dist/types/controller-context.js.map +1 -0
  386. package/dist/types/data.cjs.map +1 -1
  387. package/dist/types/data.d.ts +107 -39
  388. package/dist/types/external-apis.d.ts +10 -12
  389. package/dist/types/generics.d.ts +35 -38
  390. package/dist/types/index.cjs +5 -4
  391. package/dist/types/index.cjs.map +1 -1
  392. package/dist/types/index.d.ts +20 -34
  393. package/dist/types/index.js +9 -2
  394. package/dist/types/index.js.map +1 -1
  395. package/dist/types/operations.cjs +2 -2
  396. package/dist/types/operations.cjs.map +1 -1
  397. package/dist/types/operations.d.ts +32 -28
  398. package/dist/types/operations.js +2 -2
  399. package/dist/types/operations.js.map +1 -1
  400. package/dist/types/permissions.d.ts +55 -58
  401. package/dist/types/personal.cjs.map +1 -1
  402. package/dist/types/personal.d.ts +6 -8
  403. package/dist/types/relayer.cjs.map +1 -1
  404. package/dist/types/relayer.d.ts +186 -39
  405. package/dist/types/storage.d.ts +6 -8
  406. package/dist/types/storage.js +2 -5
  407. package/dist/types/storage.js.map +1 -1
  408. package/dist/types/transactionResults.cjs.map +1 -1
  409. package/dist/types/transactionResults.d.ts +193 -25
  410. package/dist/types/utils.d.ts +21 -24
  411. package/dist/types.d.ts +4 -40
  412. package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
  413. package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
  414. package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
  415. package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
  416. package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
  417. package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
  418. package/dist/utils/blockchain/registry.cjs +2 -2
  419. package/dist/utils/blockchain/registry.cjs.map +1 -1
  420. package/dist/utils/blockchain/registry.d.ts +6 -8
  421. package/dist/utils/blockchain/registry.js +2 -2
  422. package/dist/utils/blockchain/registry.js.map +1 -1
  423. package/dist/utils/blockchain/registry.test.d.ts +1 -0
  424. package/dist/utils/crypto-utils.cjs +0 -12
  425. package/dist/utils/crypto-utils.cjs.map +1 -1
  426. package/dist/utils/crypto-utils.d.ts +9 -27
  427. package/dist/utils/crypto-utils.js +0 -11
  428. package/dist/utils/crypto-utils.js.map +1 -1
  429. package/dist/utils/crypto-utils.test.d.ts +1 -0
  430. package/dist/utils/download.cjs +3 -3
  431. package/dist/utils/download.cjs.map +1 -1
  432. package/dist/utils/download.d.ts +13 -14
  433. package/dist/utils/download.js +2 -2
  434. package/dist/utils/download.js.map +1 -1
  435. package/dist/utils/encoding.cjs +1 -1
  436. package/dist/utils/encoding.cjs.map +1 -1
  437. package/dist/utils/encoding.d.ts +4 -6
  438. package/dist/utils/encoding.js +1 -1
  439. package/dist/utils/encoding.js.map +1 -1
  440. package/dist/utils/encoding.test.d.ts +1 -0
  441. package/dist/utils/encryption.cjs +16 -10
  442. package/dist/utils/encryption.cjs.map +1 -1
  443. package/dist/utils/encryption.d.ts +13 -17
  444. package/dist/utils/encryption.js +16 -10
  445. package/dist/utils/encryption.js.map +1 -1
  446. package/dist/utils/formatters.cjs +4 -2
  447. package/dist/utils/formatters.cjs.map +1 -1
  448. package/dist/utils/formatters.d.ts +4 -6
  449. package/dist/utils/formatters.js +4 -2
  450. package/dist/utils/formatters.js.map +1 -1
  451. package/dist/utils/grantFiles.cjs +7 -4
  452. package/dist/utils/grantFiles.cjs.map +1 -1
  453. package/dist/utils/grantFiles.d.ts +6 -10
  454. package/dist/utils/grantFiles.js +7 -4
  455. package/dist/utils/grantFiles.js.map +1 -1
  456. package/dist/utils/grantValidation.cjs +1 -1
  457. package/dist/utils/grantValidation.cjs.map +1 -1
  458. package/dist/utils/grantValidation.d.ts +14 -17
  459. package/dist/utils/grantValidation.js +1 -1
  460. package/dist/utils/grantValidation.js.map +1 -1
  461. package/dist/utils/grants.cjs +1 -1
  462. package/dist/utils/grants.cjs.map +1 -1
  463. package/dist/utils/grants.d.ts +10 -13
  464. package/dist/utils/grants.js +1 -1
  465. package/dist/utils/grants.js.map +1 -1
  466. package/dist/utils/ipfs.d.ts +8 -10
  467. package/dist/utils/lazy-import.cjs +4 -6
  468. package/dist/utils/lazy-import.cjs.map +1 -1
  469. package/dist/utils/lazy-import.d.ts +1 -3
  470. package/dist/utils/lazy-import.js +4 -6
  471. package/dist/utils/lazy-import.js.map +1 -1
  472. package/dist/utils/multicall.cjs +4 -2
  473. package/dist/utils/multicall.cjs.map +1 -1
  474. package/dist/utils/multicall.d.ts +5 -8
  475. package/dist/utils/multicall.js +4 -2
  476. package/dist/utils/multicall.js.map +1 -1
  477. package/dist/utils/parseTransactionPojo.cjs +87 -0
  478. package/dist/utils/parseTransactionPojo.cjs.map +1 -0
  479. package/dist/utils/parseTransactionPojo.d.ts +31 -0
  480. package/dist/utils/parseTransactionPojo.js +63 -0
  481. package/dist/utils/parseTransactionPojo.js.map +1 -0
  482. package/dist/utils/schemaValidation.cjs +5 -5
  483. package/dist/utils/schemaValidation.cjs.map +1 -1
  484. package/dist/utils/schemaValidation.d.ts +8 -12
  485. package/dist/utils/schemaValidation.js +7 -10
  486. package/dist/utils/schemaValidation.js.map +1 -1
  487. package/dist/utils/signatureCache.cjs +1 -2
  488. package/dist/utils/signatureCache.cjs.map +1 -1
  489. package/dist/utils/signatureCache.d.ts +4 -7
  490. package/dist/utils/signatureCache.js +4 -8
  491. package/dist/utils/signatureCache.js.map +1 -1
  492. package/dist/utils/signatureFormatter.cjs +6 -9
  493. package/dist/utils/signatureFormatter.cjs.map +1 -1
  494. package/dist/utils/signatureFormatter.d.ts +2 -5
  495. package/dist/utils/signatureFormatter.js +6 -9
  496. package/dist/utils/signatureFormatter.js.map +1 -1
  497. package/dist/utils/tests/multicall.test.d.ts +1 -0
  498. package/dist/utils/transactionHelpers.cjs +54 -0
  499. package/dist/utils/transactionHelpers.cjs.map +1 -0
  500. package/dist/utils/transactionHelpers.d.ts +80 -0
  501. package/dist/utils/transactionHelpers.js +29 -0
  502. package/dist/utils/transactionHelpers.js.map +1 -0
  503. package/dist/utils/typeGuards.cjs +109 -0
  504. package/dist/utils/typeGuards.cjs.map +1 -0
  505. package/dist/utils/typeGuards.d.ts +138 -0
  506. package/dist/utils/typeGuards.js +74 -0
  507. package/dist/utils/typeGuards.js.map +1 -0
  508. package/dist/utils/typedDataConverter.d.ts +3 -6
  509. package/dist/utils/urlResolver.cjs +1 -1
  510. package/dist/utils/urlResolver.cjs.map +1 -1
  511. package/dist/utils/urlResolver.d.ts +2 -4
  512. package/dist/utils/urlResolver.js +2 -2
  513. package/dist/utils/urlResolver.js.map +1 -1
  514. package/dist/utils/wallet.cjs +63 -0
  515. package/dist/utils/wallet.cjs.map +1 -0
  516. package/dist/utils/wallet.d.ts +32 -0
  517. package/dist/utils/wallet.js +37 -0
  518. package/dist/utils/wallet.js.map +1 -0
  519. package/dist/{chains.browser.cjs → utils/withEvents.cjs} +22 -15
  520. package/dist/utils/withEvents.cjs.map +1 -0
  521. package/dist/utils/withEvents.d.ts +56 -0
  522. package/dist/utils/withEvents.js +18 -0
  523. package/dist/utils/withEvents.js.map +1 -0
  524. package/package.json +23 -14
  525. package/dist/browser.d.cts +0 -2
  526. package/dist/chains/definitions.d.cts +0 -53
  527. package/dist/chains/index.d.cts +0 -2
  528. package/dist/chains.browser.cjs.map +0 -1
  529. package/dist/chains.browser.d.cts +0 -2
  530. package/dist/chains.d.cts +0 -2
  531. package/dist/chains.node.d.cts +0 -2
  532. package/dist/config/addresses.d.cts +0 -380
  533. package/dist/config/chains.d.cts +0 -85
  534. package/dist/config/eventMappings.cjs +0 -114
  535. package/dist/config/eventMappings.cjs.map +0 -1
  536. package/dist/config/eventMappings.d.cts +0 -108
  537. package/dist/config/eventMappings.d.ts +0 -108
  538. package/dist/config/eventMappings.js +0 -90
  539. package/dist/config/eventMappings.js.map +0 -1
  540. package/dist/config/features.d.cts +0 -64
  541. package/dist/contracts/contractController.d.cts +0 -96
  542. package/dist/controllers/data.d.cts +0 -941
  543. package/dist/controllers/permissions.d.cts +0 -25
  544. package/dist/controllers/protocol.d.cts +0 -167
  545. package/dist/controllers/schemas.d.cts +0 -272
  546. package/dist/controllers/server.d.cts +0 -243
  547. package/dist/core/apiClient.d.cts +0 -165
  548. package/dist/core/client.d.cts +0 -92
  549. package/dist/core/generics.d.cts +0 -120
  550. package/dist/core.d.cts +0 -466
  551. package/dist/crypto/ecies/__tests__/test-vectors.d.cts +0 -40
  552. package/dist/crypto/ecies/base.d.cts +0 -143
  553. package/dist/crypto/ecies/browser.d.cts +0 -48
  554. package/dist/crypto/ecies/constants.d.cts +0 -122
  555. package/dist/crypto/ecies/index.d.cts +0 -1
  556. package/dist/crypto/ecies/interface.d.cts +0 -176
  557. package/dist/crypto/ecies/node.d.cts +0 -50
  558. package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.cts +0 -76
  559. package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.ts +0 -76
  560. package/dist/crypto/ecies/utils.d.cts +0 -67
  561. package/dist/crypto/services/WalletKeyEncryptionService.d.cts +0 -92
  562. package/dist/diagnostics.d.cts +0 -26
  563. package/dist/errors.d.cts +0 -350
  564. package/dist/generated/abi/ComputeEngineImplementation.d.cts +0 -996
  565. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +0 -545
  566. package/dist/generated/abi/DATFactoryImplementation.d.cts +0 -661
  567. package/dist/generated/abi/DATImplementation.d.cts +0 -693
  568. package/dist/generated/abi/DATPausableImplementation.d.cts +0 -1145
  569. package/dist/generated/abi/DATVotesImplementation.d.cts +0 -1095
  570. package/dist/generated/abi/DLPPerformanceImplementation.d.cts +0 -883
  571. package/dist/generated/abi/DLPRegistryImplementation.d.cts +0 -1123
  572. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +0 -452
  573. package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +0 -714
  574. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +0 -452
  575. package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +0 -706
  576. package/dist/generated/abi/DLPRootImplementation.d.cts +0 -1248
  577. package/dist/generated/abi/DLPTreasuryImplementation.d.cts +0 -452
  578. package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +0 -737
  579. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +0 -661
  580. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +0 -989
  581. package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +0 -1086
  582. package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +0 -737
  583. package/dist/generated/abi/DataRegistryImplementation.d.cts +0 -1004
  584. package/dist/generated/abi/QueryEngineImplementation.d.cts +0 -1001
  585. package/dist/generated/abi/SwapHelperImplementation.d.cts +0 -764
  586. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +0 -701
  587. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +0 -701
  588. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +0 -701
  589. package/dist/generated/abi/TeePoolImplementation.d.cts +0 -993
  590. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +0 -701
  591. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +0 -701
  592. package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +0 -993
  593. package/dist/generated/abi/VanaEpochImplementation.d.cts +0 -900
  594. package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +0 -934
  595. package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +0 -693
  596. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +0 -394
  597. package/dist/generated/abi/index.d.cts +0 -26516
  598. package/dist/generated/server/server-exports.d.cts +0 -21
  599. package/dist/generated/server/server.d.cts +0 -512
  600. package/dist/generated/subgraph.d.cts +0 -5981
  601. package/dist/index.browser.cjs +0 -151
  602. package/dist/index.browser.cjs.map +0 -1
  603. package/dist/index.browser.d.cts +0 -177
  604. package/dist/index.d.cts +0 -2
  605. package/dist/index.node.d.cts +0 -64
  606. package/dist/node.d.cts +0 -2
  607. package/dist/permissions-DNKPu_G0.d.cts +0 -1666
  608. package/dist/permissions-eo8YeLGf.d.ts +0 -1666
  609. package/dist/platform/browser-only.d.cts +0 -25
  610. package/dist/platform/browser-safe.d.cts +0 -32
  611. package/dist/platform/browser.d.cts +0 -74
  612. package/dist/platform/index.d.cts +0 -5
  613. package/dist/platform/interface.d.cts +0 -218
  614. package/dist/platform/node.d.cts +0 -27
  615. package/dist/platform/shared/error-utils.d.cts +0 -25
  616. package/dist/platform/shared/pgp-utils.d.cts +0 -61
  617. package/dist/platform/shared/stream-utils.d.cts +0 -16
  618. package/dist/platform/utils.d.cts +0 -53
  619. package/dist/platform.browser.cjs +0 -41
  620. package/dist/platform.browser.cjs.map +0 -1
  621. package/dist/platform.browser.d.cts +0 -4
  622. package/dist/platform.d.cts +0 -5
  623. package/dist/platform.node.d.cts +0 -5
  624. package/dist/schemas/dataSchema.schema.d.cts +0 -88
  625. package/dist/schemas/dataSchema.schema.d.ts +0 -88
  626. package/dist/schemas/grantFile.schema.d.cts +0 -57
  627. package/dist/schemas/grantFile.schema.d.ts +0 -57
  628. package/dist/server/handler.d.cts +0 -282
  629. package/dist/storage/index.d.cts +0 -10
  630. package/dist/storage/manager.d.cts +0 -150
  631. package/dist/storage/providers/callback-storage.d.cts +0 -100
  632. package/dist/storage/providers/google-drive.d.cts +0 -156
  633. package/dist/storage/providers/ipfs.d.cts +0 -163
  634. package/dist/storage/providers/pinata.d.cts +0 -173
  635. package/dist/types/chains.d.cts +0 -34
  636. package/dist/types/config.d.cts +0 -726
  637. package/dist/types/contracts.d.cts +0 -68
  638. package/dist/types/data.d.cts +0 -694
  639. package/dist/types/eccrypto-js.d.d.cts +0 -13
  640. package/dist/types/eccrypto-js.d.d.ts +0 -13
  641. package/dist/types/external-apis.d.cts +0 -186
  642. package/dist/types/generics.d.cts +0 -450
  643. package/dist/types/index.d.cts +0 -34
  644. package/dist/types/operations.d.cts +0 -108
  645. package/dist/types/permissions.d.cts +0 -957
  646. package/dist/types/personal.d.cts +0 -40
  647. package/dist/types/relayer.d.cts +0 -284
  648. package/dist/types/storage.d.cts +0 -131
  649. package/dist/types/transactionResults.d.cts +0 -25
  650. package/dist/types/utils.d.cts +0 -819
  651. package/dist/types.d.cts +0 -66
  652. package/dist/utils/blockchain/registry.d.cts +0 -34
  653. package/dist/utils/crypto-utils.d.cts +0 -118
  654. package/dist/utils/download.d.cts +0 -41
  655. package/dist/utils/encoding.d.cts +0 -54
  656. package/dist/utils/encryption.d.cts +0 -275
  657. package/dist/utils/eventParsing.cjs +0 -111
  658. package/dist/utils/eventParsing.cjs.map +0 -1
  659. package/dist/utils/eventParsing.d.cts +0 -60
  660. package/dist/utils/eventParsing.d.ts +0 -60
  661. package/dist/utils/eventParsing.js +0 -86
  662. package/dist/utils/eventParsing.js.map +0 -1
  663. package/dist/utils/formatters.d.cts +0 -120
  664. package/dist/utils/grantFiles.d.cts +0 -186
  665. package/dist/utils/grantValidation.d.cts +0 -150
  666. package/dist/utils/grants.d.cts +0 -70
  667. package/dist/utils/ipfs.d.cts +0 -90
  668. package/dist/utils/lazy-import.d.cts +0 -20
  669. package/dist/utils/multicall.d.cts +0 -129
  670. package/dist/utils/schemaValidation.d.cts +0 -172
  671. package/dist/utils/signatureCache.d.cts +0 -134
  672. package/dist/utils/signatureFormatter.d.cts +0 -39
  673. package/dist/utils/transactionParsing.cjs +0 -84
  674. package/dist/utils/transactionParsing.cjs.map +0 -1
  675. package/dist/utils/transactionParsing.d.cts +0 -25
  676. package/dist/utils/transactionParsing.d.ts +0 -25
  677. package/dist/utils/transactionParsing.js +0 -62
  678. package/dist/utils/transactionParsing.js.map +0 -1
  679. package/dist/utils/typedDataConverter.d.cts +0 -13
  680. package/dist/utils/urlResolver.d.cts +0 -40
@@ -41,9 +41,10 @@ var import_grantValidation = require("../utils/grantValidation");
41
41
  var import_signatureCache = require("../utils/signatureCache");
42
42
  var import_signatureFormatter = require("../utils/signatureFormatter");
43
43
  var import_typedDataConverter = require("../utils/typedDataConverter");
44
- class PermissionsController {
44
+ var import_base = require("./base");
45
+ class PermissionsController extends import_base.BaseController {
45
46
  constructor(context) {
46
- this.context = context;
47
+ super(context);
47
48
  }
48
49
  /**
49
50
  * Grants permission for an application to access user data with gasless transactions.
@@ -80,7 +81,10 @@ class PermissionsController {
80
81
  * ```
81
82
  */
82
83
  async grant(params) {
83
- return await this.submitPermissionGrant(params);
84
+ this.assertWallet();
85
+ const { typedData, signature } = await this.createAndSign(params);
86
+ const result = await this.submitSignedGrantWithEvents(typedData, signature);
87
+ return result;
84
88
  }
85
89
  /**
86
90
  * Submits a permission grant transaction and returns a handle for flexible result access.
@@ -108,6 +112,7 @@ class PermissionsController {
108
112
  * ```
109
113
  */
110
114
  async submitPermissionGrant(params) {
115
+ this.assertWallet();
111
116
  const { typedData, signature } = await this.createAndSign(params);
112
117
  return await this.submitSignedGrant(typedData, signature);
113
118
  }
@@ -137,13 +142,14 @@ class PermissionsController {
137
142
  * ```
138
143
  */
139
144
  async prepareGrant(params) {
145
+ this.assertWallet();
140
146
  try {
141
147
  const grantFile = (0, import_grantFiles.createGrantFile)(params);
142
148
  (0, import_grantValidation.validateGrant)(grantFile);
143
149
  return {
144
150
  preview: grantFile,
145
151
  confirm: async () => {
146
- return await this.confirmGrantInternal(params, grantFile);
152
+ return await this.confirmGrantInternalWithEvents(params, grantFile);
147
153
  }
148
154
  };
149
155
  } catch (error) {
@@ -177,20 +183,34 @@ class PermissionsController {
177
183
  */
178
184
  async confirmGrantInternal(params, grantFile) {
179
185
  try {
180
- let grantUrl = params.grantUrl;
186
+ let { grantUrl } = params;
181
187
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
182
188
  if (!grantUrl) {
183
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
189
+ const canStoreViaRelayer = this.context.relayer !== void 0;
190
+ if (!canStoreViaRelayer && !this.context.storageManager) {
184
191
  if (this.context.validateStorageRequired) {
185
192
  this.context.validateStorageRequired();
186
193
  } else {
187
194
  throw new Error(
188
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
195
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
189
196
  );
190
197
  }
191
198
  }
192
- if (this.context.relayerCallbacks?.storeGrantFile) {
193
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
199
+ if (canStoreViaRelayer && this.context.relayer) {
200
+ const request = {
201
+ type: "direct",
202
+ operation: "storeGrantFile",
203
+ params: grantFile
204
+ };
205
+ const response = await this.context.relayer(request);
206
+ if (response.type === "error") {
207
+ throw new Error(response.error);
208
+ }
209
+ if (response.type === "direct" && typeof response.result === "object" && "url" in response.result) {
210
+ grantUrl = response.result.url;
211
+ } else {
212
+ throw new Error("Invalid response from relayer for grant storage");
213
+ }
194
214
  } else if (this.context.storageManager) {
195
215
  const blob = new Blob([JSON.stringify(grantFile)], {
196
216
  type: "application/json"
@@ -267,23 +287,38 @@ class PermissionsController {
267
287
  * ```
268
288
  */
269
289
  async createAndSign(params) {
290
+ this.assertWallet();
270
291
  try {
271
292
  const grantFile = (0, import_grantFiles.createGrantFile)(params);
272
293
  (0, import_grantValidation.validateGrant)(grantFile);
273
- let grantUrl = params.grantUrl;
294
+ let { grantUrl } = params;
274
295
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
275
296
  if (!grantUrl) {
276
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
297
+ const canStoreViaRelayer = this.context.relayer !== void 0;
298
+ if (!canStoreViaRelayer && !this.context.storageManager) {
277
299
  if (this.context.validateStorageRequired) {
278
300
  this.context.validateStorageRequired();
279
301
  } else {
280
302
  throw new Error(
281
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
303
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
282
304
  );
283
305
  }
284
306
  }
285
- if (this.context.relayerCallbacks?.storeGrantFile) {
286
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
307
+ if (canStoreViaRelayer && this.context.relayer) {
308
+ const request = {
309
+ type: "direct",
310
+ operation: "storeGrantFile",
311
+ params: grantFile
312
+ };
313
+ const response = await this.context.relayer(request);
314
+ if (response.type === "error") {
315
+ throw new Error(response.error);
316
+ }
317
+ if (response.type === "direct" && typeof response.result === "object" && "url" in response.result) {
318
+ grantUrl = response.result.url;
319
+ } else {
320
+ throw new Error("Invalid response from relayer for grant storage");
321
+ }
287
322
  } else if (this.context.storageManager) {
288
323
  const blob = new Blob([JSON.stringify(grantFile)], {
289
324
  type: "application/json"
@@ -358,23 +393,39 @@ class PermissionsController {
358
393
  "\u{1F50D} Debug - submitSignedGrant called with typed data:",
359
394
  JSON.stringify(
360
395
  typedData,
361
- (key, value) => typeof value === "bigint" ? value.toString() : value,
396
+ (_key, value) => typeof value === "bigint" ? value.toString() : value,
362
397
  2
363
398
  )
364
399
  );
365
- let hash;
366
- if (this.context.relayerCallbacks?.submitPermissionGrant) {
367
- hash = await this.context.relayerCallbacks.submitPermissionGrant(
400
+ if (this.context.relayer) {
401
+ const response = await this.context.relayer({
402
+ type: "signed",
403
+ operation: "submitAddPermission",
368
404
  typedData,
369
- signature
370
- );
405
+ signature,
406
+ expectedUserAddress: this.context.userAddress
407
+ });
408
+ let hash;
409
+ if (response.type === "signed") {
410
+ hash = response.hash;
411
+ } else if (response.type === "error") {
412
+ throw new Error(`Relayer error: ${response.error}`);
413
+ } else {
414
+ throw new Error(
415
+ "Invalid response from relayer: expected signed transaction"
416
+ );
417
+ }
418
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
419
+ const { tx } = await import("../utils/transactionHelpers");
420
+ return tx({
421
+ hash,
422
+ from: typeof account === "string" ? account : account.address,
423
+ contract: "DataPortabilityPermissions",
424
+ fn: "addPermission"
425
+ });
371
426
  } else {
372
- hash = await this.submitDirectTransaction(typedData, signature);
427
+ return await this.submitDirectTransaction(typedData, signature);
373
428
  }
374
- return {
375
- hash,
376
- from: this.context.walletClient.account?.address
377
- };
378
429
  } catch (error) {
379
430
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
380
431
  throw error;
@@ -416,10 +467,14 @@ class PermissionsController {
416
467
  trustServerInput,
417
468
  signature
418
469
  );
419
- return {
470
+ const account = this.context.userAddress;
471
+ const { tx } = await import("../utils/transactionHelpers");
472
+ return tx({
420
473
  hash,
421
- from: this.context.walletClient.account?.address
422
- };
474
+ from: account,
475
+ contract: "DataPortabilityServers",
476
+ fn: "trustServerWithSignature"
477
+ });
423
478
  } catch (error) {
424
479
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
425
480
  throw error;
@@ -477,10 +532,14 @@ class PermissionsController {
477
532
  addAndTrustServerInput,
478
533
  signature
479
534
  );
480
- return {
535
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
536
+ const { tx } = await import("../utils/transactionHelpers");
537
+ return tx({
481
538
  hash,
482
- from: this.context.walletClient.account?.address
483
- };
539
+ from: typeof account === "string" ? account : account.address,
540
+ contract: "DataPortabilityServers",
541
+ fn: "addAndTrustServerWithSignature"
542
+ });
484
543
  } catch (error) {
485
544
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
486
545
  throw error;
@@ -491,6 +550,72 @@ class PermissionsController {
491
550
  );
492
551
  }
493
552
  }
553
+ /**
554
+ * Internal method to submit a signed grant and wait for events.
555
+ *
556
+ * @internal
557
+ * @param typedData - The EIP-712 typed data for the permission grant
558
+ * @param signature - The user's signature authorizing the transaction
559
+ * @returns Promise resolving to PermissionGrantResult with parsed events
560
+ */
561
+ async submitSignedGrantWithEvents(typedData, signature) {
562
+ const txResult = await this.submitSignedGrant(typedData, signature);
563
+ if (!this.context.waitForTransactionEvents) {
564
+ throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
565
+ }
566
+ const result = await this.context.waitForTransactionEvents(txResult);
567
+ const event = result.expectedEvents.PermissionAdded;
568
+ if (!event) {
569
+ throw new import_errors.BlockchainError(
570
+ "PermissionAdded event not found in transaction"
571
+ );
572
+ }
573
+ const receipt = await this.context.publicClient.getTransactionReceipt({
574
+ hash: result.hash
575
+ });
576
+ return {
577
+ transactionHash: result.hash,
578
+ blockNumber: receipt.blockNumber,
579
+ gasUsed: receipt.gasUsed,
580
+ permissionId: event.permissionId,
581
+ user: event.user,
582
+ grant: event.grant,
583
+ fileIds: event.fileIds
584
+ };
585
+ }
586
+ /**
587
+ * Internal method for confirm grant with events.
588
+ *
589
+ * @internal
590
+ * @param params - The permission grant parameters
591
+ * @param grantFile - The pre-created grant file object
592
+ * @returns Promise resolving to PermissionGrantResult with parsed events
593
+ */
594
+ async confirmGrantInternalWithEvents(params, grantFile) {
595
+ const txResult = await this.confirmGrantInternal(params, grantFile);
596
+ if (!this.context.waitForTransactionEvents) {
597
+ throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
598
+ }
599
+ const result = await this.context.waitForTransactionEvents(txResult);
600
+ const event = result.expectedEvents.PermissionAdded;
601
+ if (!event) {
602
+ throw new import_errors.BlockchainError(
603
+ "PermissionAdded event not found in transaction"
604
+ );
605
+ }
606
+ const receipt = await this.context.publicClient.getTransactionReceipt({
607
+ hash: result.hash
608
+ });
609
+ return {
610
+ transactionHash: result.hash,
611
+ blockNumber: receipt.blockNumber,
612
+ gasUsed: receipt.gasUsed,
613
+ permissionId: event.permissionId,
614
+ user: event.user,
615
+ grant: event.grant,
616
+ fileIds: event.fileIds
617
+ };
618
+ }
494
619
  /**
495
620
  * Submits an already-signed permission revoke transaction to the blockchain.
496
621
  *
@@ -515,18 +640,37 @@ class PermissionsController {
515
640
  async submitSignedRevoke(typedData, signature) {
516
641
  try {
517
642
  let hash;
518
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
519
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
643
+ if (this.context.relayer) {
644
+ const response = await this.context.relayer({
645
+ type: "signed",
646
+ operation: "submitPermissionRevoke",
647
+ typedData,
648
+ signature,
649
+ expectedUserAddress: this.context.userAddress
650
+ });
651
+ if (response.type === "signed") {
652
+ hash = response.hash;
653
+ } else if (response.type === "error") {
654
+ throw new Error(`Relayer error: ${response.error}`);
655
+ } else {
656
+ throw new Error(
657
+ "Invalid response from relayer: expected signed transaction"
658
+ );
659
+ }
660
+ } else {
661
+ hash = await this.submitDirectRevokeTransaction(
520
662
  typedData,
521
663
  signature
522
664
  );
523
- } else {
524
- hash = await this.submitDirectRevokeTransaction(typedData, signature);
525
665
  }
526
- return {
666
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
667
+ const { tx } = await import("../utils/transactionHelpers");
668
+ return tx({
527
669
  hash,
528
- from: this.context.walletClient.account?.address
529
- };
670
+ from: typeof account === "string" ? account : account.address,
671
+ contract: "DataPortabilityPermissions",
672
+ fn: "revokePermissionWithSignature"
673
+ });
530
674
  } catch (error) {
531
675
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
532
676
  throw error;
@@ -561,18 +705,37 @@ class PermissionsController {
561
705
  async submitSignedUntrustServer(typedData, signature) {
562
706
  try {
563
707
  let hash;
564
- if (this.context.relayerCallbacks?.submitUntrustServer) {
565
- hash = await this.context.relayerCallbacks.submitUntrustServer(
708
+ if (this.context.relayer) {
709
+ const response = await this.context.relayer({
710
+ type: "signed",
711
+ operation: "submitUntrustServer",
712
+ typedData,
713
+ signature,
714
+ expectedUserAddress: this.context.userAddress
715
+ });
716
+ if (response.type === "signed") {
717
+ hash = response.hash;
718
+ } else if (response.type === "error") {
719
+ throw new Error(`Relayer error: ${response.error}`);
720
+ } else {
721
+ throw new Error(
722
+ "Invalid response from relayer: expected signed transaction"
723
+ );
724
+ }
725
+ } else {
726
+ hash = await this.submitSignedUntrustTransaction(
566
727
  typedData,
567
728
  signature
568
729
  );
569
- } else {
570
- hash = await this.submitSignedUntrustTransaction(typedData, signature);
571
730
  }
572
- return {
731
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
732
+ const { tx } = await import("../utils/transactionHelpers");
733
+ return tx({
573
734
  hash,
574
- from: this.context.walletClient.account?.address
575
- };
735
+ from: typeof account === "string" ? account : account.address,
736
+ contract: "DataPortabilityServers",
737
+ fn: "untrustServerWithSignature"
738
+ });
576
739
  } catch (error) {
577
740
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
578
741
  throw error;
@@ -596,7 +759,8 @@ class PermissionsController {
596
759
  * @throws {BlockchainError} When contract submission fails
597
760
  */
598
761
  async submitDirectTransaction(typedData, signature) {
599
- const chainId = await this.context.walletClient.getChainId();
762
+ this.assertWallet();
763
+ const chainId = await this.context.publicClient.getChainId();
600
764
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
601
765
  chainId,
602
766
  "DataPortabilityPermissions"
@@ -616,18 +780,25 @@ class PermissionsController {
616
780
  console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
617
781
  console.debug(
618
782
  "\u{1F50D} Debug - Grant field length:",
619
- typedData.message.grant?.length || 0
783
+ typedData.message.grant?.length ?? 0
620
784
  );
621
785
  const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
786
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
622
787
  const txHash = await this.context.walletClient.writeContract({
623
788
  address: DataPortabilityPermissionsAddress,
624
789
  abi: DataPortabilityPermissionsAbi,
625
790
  functionName: "addPermission",
626
791
  args: [permissionInput, formattedSignature],
627
- account: this.context.walletClient.account || await this.getUserAddress(),
628
- chain: this.context.walletClient.chain || null
792
+ account,
793
+ chain: this.context.walletClient?.chain ?? null
794
+ });
795
+ const { tx } = await import("../utils/transactionHelpers");
796
+ return tx({
797
+ hash: txHash,
798
+ from: typeof account === "string" ? account : account.address,
799
+ contract: "DataPortabilityPermissions",
800
+ fn: "addPermission"
629
801
  });
630
- return txHash;
631
802
  }
632
803
  /**
633
804
  * Revokes a previously granted permission.
@@ -654,7 +825,27 @@ class PermissionsController {
654
825
  * ```
655
826
  */
656
827
  async revoke(params) {
657
- return await this.submitPermissionRevoke(params);
828
+ this.assertWallet();
829
+ const txResult = await this.submitPermissionRevoke(params);
830
+ if (!this.context.waitForTransactionEvents) {
831
+ throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
832
+ }
833
+ const result = await this.context.waitForTransactionEvents(txResult);
834
+ const event = result.expectedEvents.PermissionRevoked;
835
+ if (!event) {
836
+ throw new import_errors.BlockchainError(
837
+ "PermissionRevoked event not found in transaction"
838
+ );
839
+ }
840
+ const receipt = await this.context.publicClient.getTransactionReceipt({
841
+ hash: result.hash
842
+ });
843
+ return {
844
+ transactionHash: result.hash,
845
+ blockNumber: receipt.blockNumber,
846
+ gasUsed: receipt.gasUsed,
847
+ permissionId: event.permissionId
848
+ };
658
849
  }
659
850
  /**
660
851
  * Submits a permission revocation transaction and returns the transaction hash immediately.
@@ -676,11 +867,12 @@ class PermissionsController {
676
867
  * ```
677
868
  */
678
869
  async submitPermissionRevoke(params) {
870
+ this.assertWallet();
679
871
  try {
680
- if (!this.context.walletClient.chain?.id) {
872
+ if (!this.context.walletClient?.chain?.id) {
681
873
  throw new import_errors.BlockchainError("Chain ID not available");
682
874
  }
683
- const chainId = await this.context.walletClient.getChainId();
875
+ const chainId = await this.context.publicClient.getChainId();
684
876
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
685
877
  chainId,
686
878
  "DataPortabilityPermissions"
@@ -688,18 +880,22 @@ class PermissionsController {
688
880
  const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
689
881
  "DataPortabilityPermissions"
690
882
  );
883
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
691
884
  const txHash = await this.context.walletClient.writeContract({
692
885
  address: DataPortabilityPermissionsAddress,
693
886
  abi: DataPortabilityPermissionsAbi,
694
887
  functionName: "revokePermission",
695
888
  args: [params.permissionId],
696
- account: this.context.walletClient.account || await this.getUserAddress(),
697
- chain: this.context.walletClient.chain || null
889
+ account,
890
+ chain: this.context.walletClient?.chain ?? null
698
891
  });
699
- return {
892
+ const { tx } = await import("../utils/transactionHelpers");
893
+ return tx({
700
894
  hash: txHash,
701
- from: this.context.walletClient.account?.address
702
- };
895
+ from: typeof account === "string" ? account : account.address,
896
+ contract: "DataPortabilityPermissions",
897
+ fn: "revokePermission"
898
+ });
703
899
  } catch (error) {
704
900
  if (error instanceof Error) {
705
901
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
@@ -739,8 +935,9 @@ class PermissionsController {
739
935
  * ```
740
936
  */
741
937
  async submitRevokeWithSignature(params) {
938
+ this.assertWallet();
742
939
  try {
743
- if (!this.context.walletClient.chain?.id) {
940
+ if (!this.context.walletClient?.chain?.id) {
744
941
  throw new import_errors.BlockchainError("Chain ID not available");
745
942
  }
746
943
  const nonce = await this.getPermissionsUserNonce();
@@ -761,18 +958,37 @@ class PermissionsController {
761
958
  };
762
959
  const signature = await this.signTypedData(typedData);
763
960
  let hash;
764
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
765
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
961
+ if (this.context.relayer) {
962
+ const response = await this.context.relayer({
963
+ type: "signed",
964
+ operation: "submitPermissionRevoke",
965
+ typedData,
966
+ signature,
967
+ expectedUserAddress: this.context.userAddress
968
+ });
969
+ if (response.type === "signed") {
970
+ hash = response.hash;
971
+ } else if (response.type === "error") {
972
+ throw new Error(`Relayer error: ${response.error}`);
973
+ } else {
974
+ throw new Error(
975
+ "Invalid response from relayer: expected signed transaction"
976
+ );
977
+ }
978
+ } else {
979
+ hash = await this.submitDirectRevokeTransaction(
766
980
  typedData,
767
981
  signature
768
982
  );
769
- } else {
770
- hash = await this.submitDirectRevokeTransaction(typedData, signature);
771
983
  }
772
- return {
984
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
985
+ const { tx } = await import("../utils/transactionHelpers");
986
+ return tx({
773
987
  hash,
774
- from: this.context.walletClient.account?.address
775
- };
988
+ from: typeof account === "string" ? account : account.address,
989
+ contract: "DataPortabilityPermissions",
990
+ fn: "revokePermissionWithSignature"
991
+ });
776
992
  } catch (error) {
777
993
  throw new import_errors.PermissionError(
778
994
  `Failed to revoke permission with signature: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -780,64 +996,6 @@ class PermissionsController {
780
996
  );
781
997
  }
782
998
  }
783
- /**
784
- * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
785
- *
786
- * Retrieves the user's current nonce from the DataPortabilityServers contract.
787
- * This method is deprecated in favor of more specific nonce methods.
788
- *
789
- * The nonce is used to prevent replay attacks in signed transactions and must
790
- * be incremented with each transaction to maintain security.
791
- *
792
- * @returns Promise resolving to the user's current nonce value as a bigint
793
- * @throws {Error} When wallet account is not available
794
- * @throws {Error} When chain ID is not available
795
- * @throws {NonceError} When reading nonce from contract fails
796
- * @private
797
- * @example
798
- * ```typescript
799
- * // Deprecated - use specific methods instead
800
- * const nonce = await this.getUserNonce();
801
- *
802
- * // Use these instead:
803
- * const permissionsNonce = await this.getPermissionsUserNonce();
804
- * const serversNonce = await this.getServersUserNonce();
805
- * ```
806
- */
807
- /**
808
- * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
809
- *
810
- * Retrieves the user's current nonce from the DataPortabilityServers contract.
811
- *
812
- * @remarks
813
- * This method is deprecated in favor of more specific nonce methods that target
814
- * the appropriate contract for the operation being performed.
815
- *
816
- * @returns Promise resolving to the user's current nonce as a bigint
817
- * @throws {NonceError} When retrieving the nonce fails
818
- */
819
- async getUserNonce() {
820
- try {
821
- const userAddress = await this.getUserAddress();
822
- const chainId = await this.context.walletClient.getChainId();
823
- const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
824
- chainId,
825
- "DataPortabilityServers"
826
- );
827
- const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
828
- const nonce = await this.context.publicClient.readContract({
829
- address: DataPortabilityServersAddress,
830
- abi: DataPortabilityServersAbi,
831
- functionName: "userNonce",
832
- args: [userAddress]
833
- });
834
- return nonce;
835
- } catch (error) {
836
- throw new import_errors.NonceError(
837
- `Failed to retrieve user nonce: ${error instanceof Error ? error.message : "Unknown error"}`
838
- );
839
- }
840
- }
841
999
  /**
842
1000
  * Retrieves the user's current nonce from the DataPortabilityServers contract.
843
1001
  * This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
@@ -864,8 +1022,8 @@ class PermissionsController {
864
1022
  */
865
1023
  async getServersUserNonce() {
866
1024
  try {
867
- const userAddress = await this.getUserAddress();
868
- const chainId = await this.context.walletClient.getChainId();
1025
+ const userAddress = this.context.userAddress;
1026
+ const chainId = await this.context.publicClient.getChainId();
869
1027
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
870
1028
  chainId,
871
1029
  "DataPortabilityServers"
@@ -910,8 +1068,8 @@ class PermissionsController {
910
1068
  */
911
1069
  async getPermissionsUserNonce() {
912
1070
  try {
913
- const userAddress = await this.getUserAddress();
914
- const chainId = await this.context.walletClient.getChainId();
1071
+ const userAddress = this.context.userAddress;
1072
+ const chainId = await this.context.publicClient.getChainId();
915
1073
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
916
1074
  chainId,
917
1075
  "DataPortabilityPermissions"
@@ -950,7 +1108,7 @@ class PermissionsController {
950
1108
  "\u{1F50D} Debug - Composing permission message with grantUrl:",
951
1109
  params.grantUrl
952
1110
  );
953
- const chainId = await this.context.walletClient.getChainId();
1111
+ const chainId = await this.context.publicClient.getChainId();
954
1112
  const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
955
1113
  chainId,
956
1114
  "DataPortabilityGrantees"
@@ -1059,7 +1217,7 @@ class PermissionsController {
1059
1217
  * @returns Promise resolving to the EIP-712 domain configuration
1060
1218
  */
1061
1219
  async getPermissionDomain() {
1062
- const chainId = await this.context.walletClient.getChainId();
1220
+ const chainId = await this.context.publicClient.getChainId();
1063
1221
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
1064
1222
  chainId,
1065
1223
  "DataPortabilityPermissions"
@@ -1078,8 +1236,9 @@ class PermissionsController {
1078
1236
  * @returns Promise resolving to the cryptographic signature
1079
1237
  */
1080
1238
  async signTypedData(typedData) {
1239
+ this.assertWallet();
1081
1240
  try {
1082
- const walletAddress = this.context.walletClient.account?.address || await this.getUserAddress();
1241
+ const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
1083
1242
  return await (0, import_signatureCache.withSignatureCache)(
1084
1243
  this.context.platform.cache,
1085
1244
  walletAddress,
@@ -1088,9 +1247,9 @@ class PermissionsController {
1088
1247
  const viemCompatibleTypedData = (0, import_typedDataConverter.toViemTypedDataDefinition)(typedData);
1089
1248
  return await this.context.walletClient.signTypedData({
1090
1249
  ...viemCompatibleTypedData,
1091
- // Non-null assertion is safe here because getUserAddress() above ensures account exists
1092
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1093
- account: this.context.walletClient.account
1250
+ // Use the account if available, otherwise use the wallet address
1251
+ // This follows the same pattern used throughout this file
1252
+ account: this.context.walletClient.account ?? walletAddress
1094
1253
  });
1095
1254
  }
1096
1255
  );
@@ -1105,17 +1264,10 @@ class PermissionsController {
1105
1264
  }
1106
1265
  }
1107
1266
  /**
1108
- * Gets the user's address from the wallet client.
1267
+ * Gets the user's address from the context.
1109
1268
  *
1110
- * @returns Promise resolving to the user's wallet address
1269
+ * @returns The user's address
1111
1270
  */
1112
- async getUserAddress() {
1113
- const addresses = await this.context.walletClient.getAddresses();
1114
- if (addresses.length === 0) {
1115
- throw new import_errors.BlockchainError("No addresses available in wallet client");
1116
- }
1117
- return addresses[0];
1118
- }
1119
1271
  /**
1120
1272
  * Gets on-chain permission grant data without expensive off-chain resolution.
1121
1273
  *
@@ -1154,8 +1306,8 @@ class PermissionsController {
1154
1306
  async getUserPermissionGrantsOnChain(options = {}) {
1155
1307
  const { limit = 50, subgraphUrl } = options;
1156
1308
  try {
1157
- const userAddress = await this.getUserAddress();
1158
- const graphqlEndpoint = subgraphUrl || this.context.subgraphUrl;
1309
+ const userAddress = this.context.userAddress;
1310
+ const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
1159
1311
  if (!graphqlEndpoint) {
1160
1312
  throw new import_errors.BlockchainError(
1161
1313
  "subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
@@ -1207,7 +1359,7 @@ class PermissionsController {
1207
1359
  );
1208
1360
  }
1209
1361
  const userData = result.data?.user;
1210
- if (!userData || !userData.permissions?.length) {
1362
+ if (!userData?.permissions?.length) {
1211
1363
  return [];
1212
1364
  }
1213
1365
  const onChainGrants = userData.permissions.slice(0, limit).map(
@@ -1218,8 +1370,8 @@ class PermissionsController {
1218
1370
  nonce: BigInt(permission.nonce),
1219
1371
  startBlock: BigInt(permission.startBlock),
1220
1372
  addedAtBlock: BigInt(permission.addedAtBlock),
1221
- addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
1222
- transactionHash: permission.transactionHash || "",
1373
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
1374
+ transactionHash: permission.transactionHash ?? "",
1223
1375
  grantor: userAddress,
1224
1376
  grantee: permission.grantee,
1225
1377
  active: !permission.endBlock || BigInt(permission.endBlock) === 0n
@@ -1240,26 +1392,6 @@ class PermissionsController {
1240
1392
  );
1241
1393
  }
1242
1394
  }
1243
- /**
1244
- * Normalizes grant ID to hex format.
1245
- * Handles conversion from permission ID (bigint/number/string) to proper hex hash format.
1246
- *
1247
- * @param grantId - Permission ID or grant hash in various formats
1248
- * @returns Normalized hex hash
1249
- */
1250
- normalizeGrantId(grantId) {
1251
- if (typeof grantId === "string" && grantId.startsWith("0x") && grantId.length === 66) {
1252
- return grantId;
1253
- }
1254
- try {
1255
- const bigIntId = BigInt(grantId);
1256
- return `0x${bigIntId.toString(16).padStart(64, "0")}`;
1257
- } catch {
1258
- throw new Error(
1259
- `Invalid grant ID format: ${grantId}. Must be a permission ID (number/bigint/string) or a 32-byte hex hash.`
1260
- );
1261
- }
1262
- }
1263
1395
  /**
1264
1396
  * Registers a new server and immediately trusts it in the DataPortabilityServers contract.
1265
1397
  *
@@ -1268,7 +1400,6 @@ class PermissionsController {
1268
1400
  * Trusted servers can handle data export and portability requests from the user.
1269
1401
  *
1270
1402
  * @param params - Parameters for adding and trusting the server
1271
- * @param params.owner - Ethereum address that will own this server registration
1272
1403
  * @param params.serverAddress - Ethereum address of the server
1273
1404
  * @param params.serverUrl - HTTPS URL where the server can be reached
1274
1405
  * @param params.publicKey - Server's public key for encryption (hex string)
@@ -1295,6 +1426,7 @@ class PermissionsController {
1295
1426
  * ```
1296
1427
  */
1297
1428
  async addAndTrustServer(params) {
1429
+ this.assertWallet();
1298
1430
  try {
1299
1431
  const chainId = await this.context.walletClient.getChainId();
1300
1432
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1302,7 +1434,8 @@ class PermissionsController {
1302
1434
  "DataPortabilityServers"
1303
1435
  );
1304
1436
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1305
- const userAddress = this.context.walletClient.account?.address || await this.getUserAddress();
1437
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1438
+ const userAddress = typeof account === "string" ? account : account.address;
1306
1439
  const normalizedUserAddress = (0, import_viem.getAddress)(userAddress);
1307
1440
  const normalizedServerAddress = (0, import_viem.getAddress)(params.serverAddress);
1308
1441
  const txHash = await this.context.walletClient.writeContract({
@@ -1317,12 +1450,40 @@ class PermissionsController {
1317
1450
  publicKey: params.publicKey
1318
1451
  }
1319
1452
  ],
1320
- account: this.context.walletClient.account || await this.getUserAddress(),
1321
- chain: this.context.walletClient.chain || null
1453
+ account,
1454
+ chain: this.context.walletClient?.chain ?? null
1322
1455
  });
1323
- return {
1456
+ const { tx } = await import("../utils/transactionHelpers");
1457
+ const txResult = tx({
1324
1458
  hash: txHash,
1325
- from: this.context.walletClient.account?.address
1459
+ from: userAddress,
1460
+ contract: "DataPortabilityServers",
1461
+ fn: "addAndTrustServerByManager"
1462
+ });
1463
+ if (!this.context.waitForTransactionEvents) {
1464
+ throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
1465
+ }
1466
+ const result = await this.context.waitForTransactionEvents(txResult);
1467
+ const event = result.expectedEvents.ServerTrusted;
1468
+ if (!event) {
1469
+ throw new import_errors.BlockchainError(
1470
+ "ServerTrusted event not found in transaction"
1471
+ );
1472
+ }
1473
+ const receipt = await this.context.publicClient.getTransactionReceipt({
1474
+ hash: txHash
1475
+ });
1476
+ return {
1477
+ transactionHash: txHash,
1478
+ blockNumber: receipt.blockNumber,
1479
+ gasUsed: receipt.gasUsed,
1480
+ user: event.user,
1481
+ serverId: event.serverId,
1482
+ // bigint from event
1483
+ serverAddress: normalizedServerAddress,
1484
+ // derived from params
1485
+ serverUrl: params.serverUrl
1486
+ // provided in params
1326
1487
  };
1327
1488
  } catch (error) {
1328
1489
  if (error instanceof Error && error.message.includes("rejected")) {
@@ -1342,6 +1503,7 @@ class PermissionsController {
1342
1503
  * @deprecated Use addAndTrustServer instead
1343
1504
  */
1344
1505
  async submitTrustServer(params) {
1506
+ this.assertWallet();
1345
1507
  try {
1346
1508
  const chainId = await this.context.walletClient.getChainId();
1347
1509
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1349,18 +1511,22 @@ class PermissionsController {
1349
1511
  "DataPortabilityServers"
1350
1512
  );
1351
1513
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1514
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1352
1515
  const txHash = await this.context.walletClient.writeContract({
1353
1516
  address: DataPortabilityServersAddress,
1354
1517
  abi: DataPortabilityServersAbi,
1355
1518
  functionName: "trustServer",
1356
1519
  args: [BigInt(params.serverId)],
1357
- account: this.context.walletClient.account || await this.getUserAddress(),
1358
- chain: this.context.walletClient.chain || null
1520
+ account,
1521
+ chain: this.context.walletClient?.chain ?? null
1359
1522
  });
1360
- return {
1523
+ const { tx } = await import("../utils/transactionHelpers");
1524
+ return tx({
1361
1525
  hash: txHash,
1362
- from: this.context.walletClient.account?.address
1363
- };
1526
+ from: typeof account === "string" ? account : account.address,
1527
+ contract: "DataPortabilityServers",
1528
+ fn: "trustServer"
1529
+ });
1364
1530
  } catch (error) {
1365
1531
  if (error instanceof Error && error.message.includes("rejected")) {
1366
1532
  throw new import_errors.UserRejectedRequestError();
@@ -1378,6 +1544,7 @@ class PermissionsController {
1378
1544
  * @returns Promise resolving to TransactionResult with ServerTrustResult event data
1379
1545
  */
1380
1546
  async submitAddAndTrustServerWithSignature(params) {
1547
+ this.assertWallet();
1381
1548
  try {
1382
1549
  const nonce = await this.getServersUserNonce();
1383
1550
  const serverAddress = (0, import_viem.getAddress)(params.serverAddress);
@@ -1401,21 +1568,36 @@ class PermissionsController {
1401
1568
  const signature = await this.signTypedData(typedData);
1402
1569
  console.debug("\u{1F50D} Generated signature:", signature);
1403
1570
  let hash;
1404
- if (this.context.relayerCallbacks?.submitAddAndTrustServer) {
1405
- hash = await this.context.relayerCallbacks.submitAddAndTrustServer(
1571
+ if (this.context.relayer) {
1572
+ const request = {
1573
+ type: "signed",
1574
+ operation: "submitAddAndTrustServer",
1406
1575
  typedData,
1407
1576
  signature
1408
- );
1577
+ };
1578
+ const response = await this.context.relayer(request);
1579
+ if (response.type === "error") {
1580
+ throw new import_errors.RelayerError(response.error);
1581
+ }
1582
+ if (response.type === "signed") {
1583
+ hash = response.hash;
1584
+ } else {
1585
+ throw new Error("Unexpected response type from relayer");
1586
+ }
1409
1587
  } else {
1410
1588
  hash = await this.submitAddAndTrustServerTransaction(
1411
1589
  addAndTrustServerInput,
1412
1590
  signature
1413
1591
  );
1414
1592
  }
1415
- return {
1593
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1594
+ const { tx } = await import("../utils/transactionHelpers");
1595
+ return tx({
1416
1596
  hash,
1417
- from: this.context.walletClient.account?.address
1418
- };
1597
+ from: typeof account === "string" ? account : account.address,
1598
+ contract: "DataPortabilityServers",
1599
+ fn: "addAndTrustServerWithSignature"
1600
+ });
1419
1601
  } catch (error) {
1420
1602
  if (error instanceof Error) {
1421
1603
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
@@ -1445,6 +1627,7 @@ class PermissionsController {
1445
1627
  * @throws {BlockchainError} When trust operation fails for any other reason
1446
1628
  */
1447
1629
  async submitTrustServerWithSignature(params) {
1630
+ this.assertWallet();
1448
1631
  try {
1449
1632
  const nonce = await this.getServersUserNonce();
1450
1633
  const trustServerInput = {
@@ -1454,21 +1637,36 @@ class PermissionsController {
1454
1637
  const typedData = await this.composeTrustServerMessage(trustServerInput);
1455
1638
  const signature = await this.signTypedData(typedData);
1456
1639
  let hash;
1457
- if (this.context.relayerCallbacks?.submitTrustServer) {
1458
- hash = await this.context.relayerCallbacks.submitTrustServer(
1640
+ if (this.context.relayer) {
1641
+ const request = {
1642
+ type: "signed",
1643
+ operation: "submitTrustServer",
1459
1644
  typedData,
1460
1645
  signature
1461
- );
1646
+ };
1647
+ const response = await this.context.relayer(request);
1648
+ if (response.type === "error") {
1649
+ throw new import_errors.RelayerError(response.error);
1650
+ }
1651
+ if (response.type === "signed") {
1652
+ hash = response.hash;
1653
+ } else {
1654
+ throw new Error("Unexpected response type from relayer");
1655
+ }
1462
1656
  } else {
1463
1657
  hash = await this.submitTrustServerTransaction(
1464
1658
  trustServerInput,
1465
1659
  signature
1466
1660
  );
1467
1661
  }
1468
- return {
1662
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1663
+ const { tx } = await import("../utils/transactionHelpers");
1664
+ return tx({
1469
1665
  hash,
1470
- from: this.context.walletClient.account?.address
1471
- };
1666
+ from: typeof account === "string" ? account : account.address,
1667
+ contract: "DataPortabilityServers",
1668
+ fn: "trustServerWithSignature"
1669
+ });
1472
1670
  } catch (error) {
1473
1671
  if (error instanceof Error) {
1474
1672
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
@@ -1500,6 +1698,7 @@ class PermissionsController {
1500
1698
  * @throws {BlockchainError} When contract submission fails
1501
1699
  */
1502
1700
  async submitDirectUntrustTransaction(params) {
1701
+ this.assertWallet();
1503
1702
  try {
1504
1703
  const chainId = await this.context.walletClient.getChainId();
1505
1704
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1507,18 +1706,22 @@ class PermissionsController {
1507
1706
  "DataPortabilityServers"
1508
1707
  );
1509
1708
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1709
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1510
1710
  const txHash = await this.context.walletClient.writeContract({
1511
1711
  address: DataPortabilityServersAddress,
1512
1712
  abi: DataPortabilityServersAbi,
1513
1713
  functionName: "untrustServer",
1514
1714
  args: [BigInt(params.serverId)],
1515
- account: this.context.walletClient.account || await this.getUserAddress(),
1516
- chain: this.context.walletClient.chain || null
1715
+ account,
1716
+ chain: this.context.walletClient?.chain ?? null
1517
1717
  });
1518
- return {
1718
+ const { tx } = await import("../utils/transactionHelpers");
1719
+ return tx({
1519
1720
  hash: txHash,
1520
- from: this.context.walletClient.account?.address
1521
- };
1721
+ from: typeof account === "string" ? account : account.address,
1722
+ contract: "DataPortabilityServers",
1723
+ fn: "untrustServer"
1724
+ });
1522
1725
  } catch (error) {
1523
1726
  if (error instanceof Error && error.message.includes("rejected")) {
1524
1727
  throw new import_errors.UserRejectedRequestError();
@@ -1558,6 +1761,7 @@ class PermissionsController {
1558
1761
  * ```
1559
1762
  */
1560
1763
  async submitUntrustServer(params) {
1764
+ this.assertWallet();
1561
1765
  const nonce = await this.getServersUserNonce();
1562
1766
  const untrustServerInput = {
1563
1767
  nonce,
@@ -1578,6 +1782,7 @@ class PermissionsController {
1578
1782
  * @throws {BlockchainError} When untrust transaction fails
1579
1783
  */
1580
1784
  async submitUntrustServerWithSignature(params) {
1785
+ this.assertWallet();
1581
1786
  try {
1582
1787
  const nonce = await this.getServersUserNonce();
1583
1788
  const untrustServerInput = {
@@ -1587,18 +1792,33 @@ class PermissionsController {
1587
1792
  const typedData = await this.composeUntrustServerMessage(untrustServerInput);
1588
1793
  const signature = await this.signTypedData(typedData);
1589
1794
  let hash;
1590
- if (this.context.relayerCallbacks?.submitUntrustServer) {
1591
- hash = await this.context.relayerCallbacks.submitUntrustServer(
1795
+ if (this.context.relayer) {
1796
+ const request = {
1797
+ type: "signed",
1798
+ operation: "submitUntrustServer",
1592
1799
  typedData,
1593
1800
  signature
1594
- );
1801
+ };
1802
+ const response = await this.context.relayer(request);
1803
+ if (response.type === "error") {
1804
+ throw new import_errors.RelayerError(response.error);
1805
+ }
1806
+ if (response.type === "signed") {
1807
+ hash = response.hash;
1808
+ } else {
1809
+ throw new Error("Unexpected response type from relayer");
1810
+ }
1595
1811
  } else {
1596
1812
  hash = await this.submitSignedUntrustTransaction(typedData, signature);
1597
1813
  }
1598
- return {
1814
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1815
+ const { tx } = await import("../utils/transactionHelpers");
1816
+ return tx({
1599
1817
  hash,
1600
- from: this.context.walletClient.account?.address
1601
- };
1818
+ from: typeof account === "string" ? account : account.address,
1819
+ contract: "DataPortabilityServers",
1820
+ fn: "untrustServerWithSignature"
1821
+ });
1602
1822
  } catch (error) {
1603
1823
  if (error instanceof Error) {
1604
1824
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
@@ -1636,8 +1856,8 @@ class PermissionsController {
1636
1856
  */
1637
1857
  async getTrustedServers(userAddress) {
1638
1858
  try {
1639
- const user = userAddress || await this.getUserAddress();
1640
- const chainId = await this.context.walletClient.getChainId();
1859
+ const user = userAddress ?? this.context.userAddress;
1860
+ const chainId = await this.context.publicClient.getChainId();
1641
1861
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1642
1862
  chainId,
1643
1863
  "DataPortabilityServers"
@@ -1666,8 +1886,8 @@ class PermissionsController {
1666
1886
  */
1667
1887
  async getTrustedServersCount(userAddress) {
1668
1888
  try {
1669
- const user = userAddress || await this.getUserAddress();
1670
- const chainId = await this.context.walletClient.getChainId();
1889
+ const user = userAddress ?? this.context.userAddress;
1890
+ const chainId = await this.context.publicClient.getChainId();
1671
1891
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1672
1892
  chainId,
1673
1893
  "DataPortabilityServers"
@@ -1696,10 +1916,10 @@ class PermissionsController {
1696
1916
  */
1697
1917
  async getTrustedServersPaginated(options = {}) {
1698
1918
  try {
1699
- const user = options.userAddress || await this.getUserAddress();
1700
- const limit = options.limit || 50;
1701
- const offset = options.offset || 0;
1702
- const chainId = await this.context.walletClient.getChainId();
1919
+ const user = options.userAddress ?? this.context.userAddress;
1920
+ const limit = options.limit ?? 50;
1921
+ const offset = options.offset ?? 0;
1922
+ const chainId = await this.context.publicClient.getChainId();
1703
1923
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1704
1924
  chainId,
1705
1925
  "DataPortabilityServers"
@@ -1845,7 +2065,7 @@ class PermissionsController {
1845
2065
  };
1846
2066
  }
1847
2067
  try {
1848
- const chainId = await this.context.walletClient.getChainId();
2068
+ const chainId = await this.context.publicClient.getChainId();
1849
2069
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1850
2070
  chainId,
1851
2071
  "DataPortabilityServers"
@@ -1920,7 +2140,7 @@ class PermissionsController {
1920
2140
  */
1921
2141
  async checkServerTrustStatus(serverId, userAddress) {
1922
2142
  try {
1923
- const user = userAddress || await this.getUserAddress();
2143
+ const user = userAddress ?? this.context.userAddress;
1924
2144
  const trustedServers = await this.getTrustedServers(user);
1925
2145
  const trustIndex = trustedServers.findIndex(
1926
2146
  (server) => server === serverId
@@ -2010,7 +2230,7 @@ class PermissionsController {
2010
2230
  * @returns Promise resolving to the EIP-712 domain configuration
2011
2231
  */
2012
2232
  async getServersDomain() {
2013
- const chainId = await this.context.walletClient.getChainId();
2233
+ const chainId = await this.context.publicClient.getChainId();
2014
2234
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2015
2235
  chainId,
2016
2236
  "DataPortabilityServers"
@@ -2030,6 +2250,7 @@ class PermissionsController {
2030
2250
  * @returns Promise resolving to the transaction hash
2031
2251
  */
2032
2252
  async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
2253
+ this.assertWallet();
2033
2254
  const chainId = await this.context.walletClient.getChainId();
2034
2255
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2035
2256
  chainId,
@@ -2061,8 +2282,8 @@ class PermissionsController {
2061
2282
  },
2062
2283
  formattedSignature
2063
2284
  ],
2064
- account: this.context.walletClient.account || await this.getUserAddress(),
2065
- chain: this.context.walletClient.chain || null
2285
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2286
+ chain: this.context.walletClient?.chain ?? null
2066
2287
  });
2067
2288
  return txHash;
2068
2289
  }
@@ -2074,6 +2295,7 @@ class PermissionsController {
2074
2295
  * @returns Promise resolving to the transaction hash
2075
2296
  */
2076
2297
  async submitTrustServerTransaction(trustServerInput, signature) {
2298
+ this.assertWallet();
2077
2299
  const chainId = await this.context.walletClient.getChainId();
2078
2300
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2079
2301
  chainId,
@@ -2092,8 +2314,8 @@ class PermissionsController {
2092
2314
  },
2093
2315
  formattedSignature
2094
2316
  ],
2095
- account: this.context.walletClient.account || await this.getUserAddress(),
2096
- chain: this.context.walletClient.chain || null
2317
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2318
+ chain: this.context.walletClient?.chain ?? null
2097
2319
  });
2098
2320
  return txHash;
2099
2321
  }
@@ -2105,6 +2327,7 @@ class PermissionsController {
2105
2327
  * @returns Promise resolving to the transaction hash
2106
2328
  */
2107
2329
  async submitDirectRevokeTransaction(typedData, signature) {
2330
+ this.assertWallet();
2108
2331
  const chainId = await this.context.walletClient.getChainId();
2109
2332
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2110
2333
  chainId,
@@ -2116,10 +2339,9 @@ class PermissionsController {
2116
2339
  address: DataPortabilityPermissionsAddress,
2117
2340
  abi: DataPortabilityPermissionsAbi,
2118
2341
  functionName: "revokePermissionWithSignature",
2119
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2120
2342
  args: [typedData.message, formattedSignature],
2121
- account: this.context.walletClient.account || await this.getUserAddress(),
2122
- chain: this.context.walletClient.chain || null
2343
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2344
+ chain: this.context.walletClient?.chain ?? null
2123
2345
  });
2124
2346
  return txHash;
2125
2347
  }
@@ -2131,6 +2353,7 @@ class PermissionsController {
2131
2353
  * @returns Promise resolving to the transaction hash
2132
2354
  */
2133
2355
  async submitSignedUntrustTransaction(typedData, signature) {
2356
+ this.assertWallet();
2134
2357
  const chainId = await this.context.walletClient.getChainId();
2135
2358
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2136
2359
  chainId,
@@ -2138,14 +2361,17 @@ class PermissionsController {
2138
2361
  );
2139
2362
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
2140
2363
  const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
2364
+ const contractMessage = {
2365
+ nonce: typedData.message.nonce,
2366
+ serverId: BigInt(typedData.message.serverId)
2367
+ };
2141
2368
  const txHash = await this.context.walletClient.writeContract({
2142
2369
  address: DataPortabilityServersAddress,
2143
2370
  abi: DataPortabilityServersAbi,
2144
2371
  functionName: "untrustServerWithSignature",
2145
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2146
- args: [typedData.message, formattedSignature],
2147
- account: this.context.walletClient.account || await this.getUserAddress(),
2148
- chain: this.context.walletClient.chain || null
2372
+ args: [contractMessage, formattedSignature],
2373
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2374
+ chain: this.context.walletClient?.chain ?? null
2149
2375
  });
2150
2376
  return txHash;
2151
2377
  }
@@ -2178,6 +2404,7 @@ class PermissionsController {
2178
2404
  * ```
2179
2405
  */
2180
2406
  async submitRegisterGrantee(params) {
2407
+ this.assertWallet();
2181
2408
  const chainId = await this.context.walletClient.getChainId();
2182
2409
  const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
2183
2410
  chainId,
@@ -2186,77 +2413,26 @@ class PermissionsController {
2186
2413
  const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2187
2414
  const ownerAddress = (0, import_viem.getAddress)(params.owner);
2188
2415
  const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
2416
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
2189
2417
  const txHash = await this.context.walletClient.writeContract({
2190
2418
  address: DataPortabilityGranteesAddress,
2191
2419
  abi: DataPortabilityGranteesAbi,
2192
2420
  functionName: "registerGrantee",
2193
2421
  args: [ownerAddress, granteeAddress, params.publicKey],
2194
- account: this.context.walletClient.account || await this.getUserAddress(),
2195
- chain: this.context.walletClient.chain || null
2422
+ account,
2423
+ chain: this.context.walletClient?.chain ?? null
2196
2424
  });
2197
- return {
2425
+ const { tx } = await import("../utils/transactionHelpers");
2426
+ return tx({
2198
2427
  hash: txHash,
2199
- from: this.context.walletClient.account?.address
2200
- };
2201
- }
2202
- /**
2203
- * Registers a grantee with a signature (gasless transaction)
2204
- *
2205
- * @param params - Parameters for registering the grantee
2206
- * @returns Promise resolving to the transaction hash
2207
- *
2208
- * @example
2209
- * ```typescript
2210
- * const txHash = await vana.permissions.registerGranteeWithSignature({
2211
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2212
- * granteeAddress: "0xApp1234567890123456789012345678901234567890",
2213
- * publicKey: "0x1234567890abcdef..."
2214
- * });
2215
- * ```
2216
- */
2217
- async submitRegisterGranteeWithSignature(params) {
2218
- const nonce = await this.getServersUserNonce();
2219
- const owner = (0, import_viem.getAddress)(params.owner);
2220
- const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
2221
- const registerGranteeInput = {
2222
- nonce,
2223
- owner,
2224
- granteeAddress,
2225
- publicKey: params.publicKey
2226
- };
2227
- const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
2228
- const signature = await this.signTypedData(typedData);
2229
- const hash = await this.submitSignedRegisterGranteeTransaction(
2230
- typedData,
2231
- signature
2232
- );
2233
- return {
2234
- hash,
2235
- from: this.context.walletClient.account?.address
2236
- };
2237
- }
2238
- /**
2239
- * Submits a signed register grantee transaction via relayer
2240
- *
2241
- * @param typedData - The EIP-712 typed data for register grantee
2242
- * @param signature - The cryptographic signature
2243
- * @returns Promise resolving to the transaction hash
2244
- *
2245
- * @example
2246
- * ```typescript
2247
- * const result = await vana.permissions.submitSignedRegisterGrantee(typedData, signature);
2248
- * ```
2249
- */
2250
- async submitSignedRegisterGrantee(typedData, signature) {
2251
- const hash = await this.submitSignedRegisterGranteeTransaction(
2252
- typedData,
2253
- signature
2254
- );
2255
- return {
2256
- hash,
2257
- from: this.context.walletClient.account?.address
2258
- };
2428
+ from: typeof account === "string" ? account : account.address,
2429
+ contract: "DataPortabilityGrantees",
2430
+ fn: "registerGrantee"
2431
+ });
2259
2432
  }
2433
+ // TODO: When DataPortabilityGrantees contract adds registerGranteeWithSignature function,
2434
+ // implement submitRegisterGranteeWithSignature and submitSignedRegisterGrantee methods
2435
+ // to support gasless transactions via relayer
2260
2436
  /**
2261
2437
  * Retrieves all registered grantees from the DataPortabilityGrantees contract.
2262
2438
  *
@@ -2302,8 +2478,8 @@ class PermissionsController {
2302
2478
  functionName: "granteesCount"
2303
2479
  });
2304
2480
  const total = Number(totalCount);
2305
- const limit = options.limit || 50;
2306
- const offset = options.offset || 0;
2481
+ const limit = options.limit ?? 50;
2482
+ const offset = options.offset ?? 0;
2307
2483
  const grantees = [];
2308
2484
  const endIndex = Math.min(offset + limit, total);
2309
2485
  for (let i = offset; i < endIndex; i++) {
@@ -2443,67 +2619,6 @@ class PermissionsController {
2443
2619
  return null;
2444
2620
  }
2445
2621
  }
2446
- /**
2447
- * Builds EIP-712 typed data for grantee registration
2448
- *
2449
- * @param input - The register grantee input
2450
- * @returns Promise resolving to the typed data structure
2451
- * @private
2452
- */
2453
- async buildRegisterGranteeTypedData(input) {
2454
- const chainId = await this.context.walletClient.getChainId();
2455
- const verifyingContract = (0, import_addresses.getContractAddress)(
2456
- chainId,
2457
- "DataPortabilityGrantees"
2458
- );
2459
- return {
2460
- domain: {
2461
- name: "DataPortabilityGrantees",
2462
- version: "1",
2463
- chainId,
2464
- verifyingContract
2465
- },
2466
- types: {
2467
- RegisterGrantee: [
2468
- { name: "nonce", type: "uint256" },
2469
- { name: "owner", type: "address" },
2470
- { name: "granteeAddress", type: "address" },
2471
- { name: "publicKey", type: "string" }
2472
- ]
2473
- },
2474
- primaryType: "RegisterGrantee",
2475
- message: input
2476
- };
2477
- }
2478
- /**
2479
- * Submits a register grantee transaction with signature.
2480
- *
2481
- * @param typedData - The EIP-712 typed data structure for the registration
2482
- * @param _signature - The cryptographic signature authorizing the registration (currently unused)
2483
- * @returns Promise resolving to the transaction hash
2484
- * @private
2485
- */
2486
- async submitSignedRegisterGranteeTransaction(typedData, _signature) {
2487
- const chainId = await this.context.walletClient.getChainId();
2488
- const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
2489
- chainId,
2490
- "DataPortabilityGrantees"
2491
- );
2492
- const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2493
- const txHash = await this.context.walletClient.writeContract({
2494
- address: DataPortabilityGranteesAddress,
2495
- abi: DataPortabilityGranteesAbi,
2496
- functionName: "registerGrantee",
2497
- args: [
2498
- typedData.message.owner,
2499
- typedData.message.granteeAddress,
2500
- typedData.message.publicKey
2501
- ],
2502
- account: this.context.walletClient.account || await this.getUserAddress(),
2503
- chain: this.context.walletClient.chain || null
2504
- });
2505
- return txHash;
2506
- }
2507
2622
  // ===========================
2508
2623
  // DATA PORTABILITY SERVERS HELPER METHODS
2509
2624
  // ===========================
@@ -2515,7 +2630,7 @@ class PermissionsController {
2515
2630
  */
2516
2631
  async getUserServerIds(userAddress) {
2517
2632
  try {
2518
- const targetAddress = userAddress || await this.getUserAddress();
2633
+ const targetAddress = userAddress ?? this.context.userAddress;
2519
2634
  const chainId = await this.context.publicClient.getChainId();
2520
2635
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2521
2636
  chainId,
@@ -2573,7 +2688,7 @@ class PermissionsController {
2573
2688
  */
2574
2689
  async getUserServerCount(userAddress) {
2575
2690
  try {
2576
- const targetAddress = userAddress || await this.getUserAddress();
2691
+ const targetAddress = userAddress ?? this.context.userAddress;
2577
2692
  const chainId = await this.context.publicClient.getChainId();
2578
2693
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2579
2694
  chainId,
@@ -2602,7 +2717,7 @@ class PermissionsController {
2602
2717
  */
2603
2718
  async getUserTrustedServers(userAddress) {
2604
2719
  try {
2605
- const targetAddress = userAddress || await this.getUserAddress();
2720
+ const targetAddress = userAddress ?? this.context.userAddress;
2606
2721
  const chainId = await this.context.publicClient.getChainId();
2607
2722
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2608
2723
  chainId,
@@ -2719,7 +2834,7 @@ class PermissionsController {
2719
2834
  */
2720
2835
  async getUserPermissionIds(userAddress) {
2721
2836
  try {
2722
- const targetAddress = userAddress || await this.getUserAddress();
2837
+ const targetAddress = userAddress ?? this.context.userAddress;
2723
2838
  const chainId = await this.context.publicClient.getChainId();
2724
2839
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2725
2840
  chainId,
@@ -2781,7 +2896,7 @@ class PermissionsController {
2781
2896
  */
2782
2897
  async getUserPermissionCount(userAddress) {
2783
2898
  try {
2784
- const targetAddress = userAddress || await this.getUserAddress();
2899
+ const targetAddress = userAddress ?? this.context.userAddress;
2785
2900
  const chainId = await this.context.publicClient.getChainId();
2786
2901
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2787
2902
  chainId,
@@ -3226,6 +3341,7 @@ class PermissionsController {
3226
3341
  * @returns Promise resolving to transaction hash
3227
3342
  */
3228
3343
  async submitUpdateServer(serverId, url) {
3344
+ this.assertWallet();
3229
3345
  try {
3230
3346
  const chainId = await this.context.walletClient.getChainId();
3231
3347
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -3233,18 +3349,22 @@ class PermissionsController {
3233
3349
  "DataPortabilityServers"
3234
3350
  );
3235
3351
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
3352
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3236
3353
  const hash = await this.context.walletClient.writeContract({
3237
3354
  address: DataPortabilityServersAddress,
3238
3355
  abi: DataPortabilityServersAbi,
3239
3356
  functionName: "updateServer",
3240
3357
  args: [serverId, url],
3241
- chain: this.context.walletClient.chain,
3242
- account: this.context.walletClient.account || null
3358
+ chain: this.context.walletClient?.chain,
3359
+ account
3243
3360
  });
3244
- return {
3361
+ const { tx } = await import("../utils/transactionHelpers");
3362
+ return tx({
3245
3363
  hash,
3246
- from: this.context.walletClient.account?.address
3247
- };
3364
+ from: typeof account === "string" ? account : account.address,
3365
+ contract: "DataPortabilityServers",
3366
+ fn: "updateServer"
3367
+ });
3248
3368
  } catch (error) {
3249
3369
  throw new import_errors.BlockchainError(
3250
3370
  `Failed to update server: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3394,6 +3514,7 @@ class PermissionsController {
3394
3514
  * @throws {NetworkError} When network communication fails
3395
3515
  */
3396
3516
  async submitAddPermission(params) {
3517
+ this.assertWallet();
3397
3518
  try {
3398
3519
  const nonce = await this.getPermissionsUserNonce();
3399
3520
  const addPermissionInput = {
@@ -3432,23 +3553,39 @@ class PermissionsController {
3432
3553
  * @throws {NetworkError} When network communication fails
3433
3554
  */
3434
3555
  async submitSignedAddPermission(typedData, signature) {
3556
+ this.assertWallet();
3435
3557
  try {
3436
3558
  let hash;
3437
- if (this.context.relayerCallbacks?.submitAddPermission) {
3438
- hash = await this.context.relayerCallbacks.submitAddPermission(
3559
+ if (this.context.relayer) {
3560
+ const request = {
3561
+ type: "signed",
3562
+ operation: "submitAddPermission",
3439
3563
  typedData,
3440
3564
  signature
3441
- );
3565
+ };
3566
+ const response = await this.context.relayer(request);
3567
+ if (response.type === "error") {
3568
+ throw new import_errors.RelayerError(response.error);
3569
+ }
3570
+ if (response.type === "signed") {
3571
+ hash = response.hash;
3572
+ } else {
3573
+ throw new Error("Unexpected response type from relayer");
3574
+ }
3442
3575
  } else {
3443
3576
  hash = await this.submitDirectAddPermissionTransaction(
3444
3577
  typedData,
3445
3578
  signature
3446
3579
  );
3447
3580
  }
3448
- return {
3581
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3582
+ const { tx } = await import("../utils/transactionHelpers");
3583
+ return tx({
3449
3584
  hash,
3450
- from: this.context.walletClient.account?.address
3451
- };
3585
+ from: typeof account === "string" ? account : account.address,
3586
+ contract: "DataPortabilityPermissions",
3587
+ fn: "addPermission"
3588
+ });
3452
3589
  } catch (error) {
3453
3590
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
3454
3591
  throw error;
@@ -3477,7 +3614,7 @@ class PermissionsController {
3477
3614
  * @param params.serverAddress - Server wallet address for decryption permissions
3478
3615
  * @param params.serverUrl - Server endpoint URL
3479
3616
  * @param params.serverPublicKey - Server's public key for encryption.
3480
- * Obtain via `vana.server.getIdentity(userAddress).public_key`.
3617
+ * Obtain via `vana.server.getIdentity(userAddress).publicKey`.
3481
3618
  * @param params.filePermissions - Nested array of permissions for each file
3482
3619
  * @returns TransactionResult with immediate hash access and optional event data
3483
3620
  * @throws {Error} When schemaIds array length doesn't match fileUrls array length
@@ -3499,7 +3636,7 @@ class PermissionsController {
3499
3636
  * schemaIds: [123], // LinkedIn profile schema ID
3500
3637
  * serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3501
3638
  * serverUrl: "https://server.example.com",
3502
- * serverPublicKey: serverInfo.public_key,
3639
+ * serverPublicKey: serverInfo.publicKey,
3503
3640
  * filePermissions: [[{
3504
3641
  * account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3505
3642
  * key: encryptedKey
@@ -3510,6 +3647,7 @@ class PermissionsController {
3510
3647
  * ```
3511
3648
  */
3512
3649
  async submitAddServerFilesAndPermissions(params) {
3650
+ this.assertWallet();
3513
3651
  try {
3514
3652
  if (params.schemaIds.length !== params.fileUrls.length) {
3515
3653
  throw new Error(
@@ -3574,37 +3712,45 @@ class PermissionsController {
3574
3712
  * ```
3575
3713
  */
3576
3714
  async submitSignedAddServerFilesAndPermissions(typedData, signature) {
3715
+ this.assertWallet();
3577
3716
  try {
3578
- console.debug("\u{1F50D} submitSignedAddServerFilesAndPermissions Debug Info:", {
3579
- hasRelayerCallbacks: !!this.context.relayerCallbacks,
3580
- hasSubmitMethod: !!this.context.relayerCallbacks?.submitAddServerFilesAndPermissions,
3581
- availableRelayerMethods: this.context.relayerCallbacks ? Object.keys(this.context.relayerCallbacks) : []
3582
- });
3583
- if (this.context.relayerCallbacks?.submitAddServerFilesAndPermissions) {
3717
+ let hash;
3718
+ if (this.context.relayer) {
3584
3719
  console.debug(
3585
3720
  "\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
3586
3721
  );
3587
- const hash = await this.context.relayerCallbacks.submitAddServerFilesAndPermissions(
3722
+ const request = {
3723
+ type: "signed",
3724
+ operation: "submitAddServerFilesAndPermissions",
3588
3725
  typedData,
3589
3726
  signature
3590
- );
3591
- return {
3592
- hash,
3593
- from: this.context.walletClient.account?.address
3594
3727
  };
3728
+ const response = await this.context.relayer(request);
3729
+ if (response.type === "error") {
3730
+ throw new import_errors.RelayerError(response.error);
3731
+ }
3732
+ if (response.type === "signed") {
3733
+ hash = response.hash;
3734
+ } else {
3735
+ throw new Error("Unexpected response type from relayer");
3736
+ }
3595
3737
  } else {
3596
3738
  console.debug(
3597
3739
  "\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
3598
3740
  );
3599
- const hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3741
+ hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3600
3742
  typedData,
3601
3743
  signature
3602
3744
  );
3603
- return {
3604
- hash,
3605
- from: this.context.walletClient.account?.address
3606
- };
3607
3745
  }
3746
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3747
+ const { tx } = await import("../utils/transactionHelpers");
3748
+ return tx({
3749
+ hash,
3750
+ from: typeof account === "string" ? account : account.address,
3751
+ contract: "DataPortabilityPermissions",
3752
+ fn: "addServerFilesAndPermissions"
3753
+ });
3608
3754
  } catch (error) {
3609
3755
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
3610
3756
  throw error;
@@ -3622,6 +3768,7 @@ class PermissionsController {
3622
3768
  * @returns Promise resolving to transaction hash
3623
3769
  */
3624
3770
  async submitRevokePermission(permissionId) {
3771
+ this.assertWallet();
3625
3772
  try {
3626
3773
  const chainId = await this.context.walletClient.getChainId();
3627
3774
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
@@ -3631,18 +3778,25 @@ class PermissionsController {
3631
3778
  const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
3632
3779
  "DataPortabilityPermissions"
3633
3780
  );
3781
+ const { account } = this.context.walletClient;
3782
+ if (!account) {
3783
+ throw new Error("No wallet account connected");
3784
+ }
3634
3785
  const hash = await this.context.walletClient.writeContract({
3635
3786
  address: DataPortabilityPermissionsAddress,
3636
3787
  abi: DataPortabilityPermissionsAbi,
3637
3788
  functionName: "revokePermission",
3638
3789
  args: [permissionId],
3639
- chain: this.context.walletClient.chain,
3640
- account: this.context.walletClient.account || null
3790
+ chain: this.context.walletClient?.chain,
3791
+ account
3641
3792
  });
3642
- return {
3793
+ const { tx } = await import("../utils/transactionHelpers");
3794
+ return tx({
3643
3795
  hash,
3644
- from: this.context.walletClient.account?.address
3645
- };
3796
+ from: typeof account === "string" ? account : account.address,
3797
+ contract: "DataPortabilityPermissions",
3798
+ fn: "revokePermission"
3799
+ });
3646
3800
  } catch (error) {
3647
3801
  throw new import_errors.BlockchainError(
3648
3802
  `Failed to revoke permission: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3658,6 +3812,7 @@ class PermissionsController {
3658
3812
  * @returns Promise resolving to the transaction hash
3659
3813
  */
3660
3814
  async submitDirectAddPermissionTransaction(typedData, signature) {
3815
+ this.assertWallet();
3661
3816
  const chainId = await this.context.walletClient.getChainId();
3662
3817
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
3663
3818
  chainId,
@@ -3668,7 +3823,7 @@ class PermissionsController {
3668
3823
  nonce: typedData.message.nonce,
3669
3824
  granteeId: typedData.message.granteeId,
3670
3825
  grant: typedData.message.grant,
3671
- fileIds: typedData.message.fileIds || []
3826
+ fileIds: typedData.message.fileIds ?? []
3672
3827
  };
3673
3828
  const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
3674
3829
  const hash = await this.context.walletClient.writeContract({
@@ -3676,8 +3831,8 @@ class PermissionsController {
3676
3831
  abi: DataPortabilityPermissionsAbi,
3677
3832
  functionName: "addPermission",
3678
3833
  args: [permissionInput, formattedSignature],
3679
- account: this.context.walletClient.account || await this.getUserAddress(),
3680
- chain: this.context.walletClient.chain || null
3834
+ account: this.context.walletClient?.account ?? this.context.userAddress,
3835
+ chain: this.context.walletClient?.chain ?? null
3681
3836
  });
3682
3837
  return hash;
3683
3838
  }
@@ -3689,7 +3844,8 @@ class PermissionsController {
3689
3844
  * @returns Promise resolving to the transaction hash
3690
3845
  */
3691
3846
  async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
3692
- const chainId = await this.context.walletClient.getChainId();
3847
+ this.assertWallet();
3848
+ const chainId = await this.context.publicClient.getChainId();
3693
3849
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
3694
3850
  chainId,
3695
3851
  "DataPortabilityPermissions"
@@ -3713,8 +3869,8 @@ class PermissionsController {
3713
3869
  functionName: "addServerFilesAndPermissions",
3714
3870
  // @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
3715
3871
  args: [serverFilesAndPermissionInput, formattedSignature],
3716
- account: this.context.walletClient.account || await this.getUserAddress(),
3717
- chain: this.context.walletClient.chain || null
3872
+ account: this.context.userAddress,
3873
+ chain: this.context.walletClient?.chain ?? null
3718
3874
  });
3719
3875
  return hash;
3720
3876
  }