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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (700) hide show
  1. package/dist/__tests__/waitForTransactionEvents.test.d.ts +1 -0
  2. package/dist/browser.cjs.map +1 -1
  3. package/dist/browser.d.ts +36 -2
  4. package/dist/browser.js.map +1 -1
  5. package/dist/chains/definitions.cjs +9 -6
  6. package/dist/chains/definitions.cjs.map +1 -1
  7. package/dist/chains/definitions.d.ts +9 -11
  8. package/dist/chains/definitions.js +9 -6
  9. package/dist/chains/definitions.js.map +1 -1
  10. package/dist/chains/index.cjs.map +1 -1
  11. package/dist/chains/index.d.ts +34 -2
  12. package/dist/chains/index.js.map +1 -1
  13. package/dist/chains.browser.d.ts +8 -2
  14. package/dist/chains.d.ts +8 -2
  15. package/dist/chains.node.d.ts +8 -2
  16. package/dist/config/addresses.d.ts +8 -45
  17. package/dist/config/chains.cjs.map +1 -1
  18. package/dist/config/chains.d.ts +108 -13
  19. package/dist/config/chains.js.map +1 -1
  20. package/dist/config/default-services.cjs +60 -0
  21. package/dist/config/default-services.cjs.map +1 -0
  22. package/dist/config/default-services.d.ts +46 -0
  23. package/dist/config/default-services.js +33 -0
  24. package/dist/config/default-services.js.map +1 -0
  25. package/dist/config/default-services.test.d.ts +1 -0
  26. package/dist/config/features.d.ts +1 -3
  27. package/dist/config/tests/addresses.test.d.ts +1 -0
  28. package/dist/contracts/contractController.cjs +3 -3
  29. package/dist/contracts/contractController.cjs.map +1 -1
  30. package/dist/contracts/contractController.d.ts +77 -59
  31. package/dist/contracts/contractController.js +4 -7
  32. package/dist/contracts/contractController.js.map +1 -1
  33. package/dist/contracts/tests/contractController.test.d.ts +1 -0
  34. package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
  35. package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
  36. package/dist/controllers/base.cjs +116 -0
  37. package/dist/controllers/base.cjs.map +1 -0
  38. package/dist/controllers/base.d.ts +94 -0
  39. package/dist/controllers/base.js +92 -0
  40. package/dist/controllers/base.js.map +1 -0
  41. package/dist/controllers/data-error-handling.test.d.ts +1 -0
  42. package/dist/controllers/data.cjs +699 -373
  43. package/dist/controllers/data.cjs.map +1 -1
  44. package/dist/controllers/data.d.ts +368 -228
  45. package/dist/controllers/data.js +712 -376
  46. package/dist/controllers/data.js.map +1 -1
  47. package/dist/controllers/permissions.cjs +688 -489
  48. package/dist/controllers/permissions.cjs.map +1 -1
  49. package/dist/controllers/permissions.d.ts +98 -165
  50. package/dist/controllers/permissions.js +688 -489
  51. package/dist/controllers/permissions.js.map +1 -1
  52. package/dist/controllers/protocol.cjs +15 -11
  53. package/dist/controllers/protocol.cjs.map +1 -1
  54. package/dist/controllers/protocol.d.ts +34 -84
  55. package/dist/controllers/protocol.js +15 -14
  56. package/dist/controllers/protocol.js.map +1 -1
  57. package/dist/controllers/schemas.cjs +57 -52
  58. package/dist/controllers/schemas.cjs.map +1 -1
  59. package/dist/controllers/schemas.d.ts +55 -61
  60. package/dist/controllers/schemas.js +57 -52
  61. package/dist/controllers/schemas.js.map +1 -1
  62. package/dist/controllers/server-additional.test.d.ts +1 -0
  63. package/dist/controllers/server.cjs +32 -25
  64. package/dist/controllers/server.cjs.map +1 -1
  65. package/dist/controllers/server.d.ts +53 -58
  66. package/dist/controllers/server.js +32 -25
  67. package/dist/controllers/server.js.map +1 -1
  68. package/dist/core/apiClient.cjs +68 -15
  69. package/dist/core/apiClient.cjs.map +1 -1
  70. package/dist/core/apiClient.d.ts +137 -16
  71. package/dist/core/apiClient.js +72 -22
  72. package/dist/core/apiClient.js.map +1 -1
  73. package/dist/core/client.cjs +7 -7
  74. package/dist/core/client.cjs.map +1 -1
  75. package/dist/core/client.d.ts +6 -9
  76. package/dist/core/client.js +7 -7
  77. package/dist/core/client.js.map +1 -1
  78. package/dist/core/core.test.d.ts +1 -0
  79. package/dist/core/generics.cjs +41 -12
  80. package/dist/core/generics.cjs.map +1 -1
  81. package/dist/core/generics.d.ts +104 -19
  82. package/dist/core/generics.js +52 -32
  83. package/dist/core/generics.js.map +1 -1
  84. package/dist/core/tests/apiClient.test.d.ts +1 -0
  85. package/dist/core/tests/client.test.d.ts +1 -0
  86. package/dist/core/tests/generics.test.d.ts +1 -0
  87. package/dist/core.cjs +115 -47
  88. package/dist/core.cjs.map +1 -1
  89. package/dist/core.d.ts +24 -74
  90. package/dist/core.js +137 -72
  91. package/dist/core.js.map +1 -1
  92. package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
  93. package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
  94. package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
  95. package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
  96. package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
  97. package/dist/crypto/ecies/__tests__/test-vectors.d.ts +2 -4
  98. package/dist/crypto/ecies/base.cjs +4 -3
  99. package/dist/crypto/ecies/base.cjs.map +1 -1
  100. package/dist/crypto/ecies/base.d.ts +2 -5
  101. package/dist/crypto/ecies/base.js +12 -15
  102. package/dist/crypto/ecies/base.js.map +1 -1
  103. package/dist/crypto/ecies/browser.cjs +2 -1
  104. package/dist/crypto/ecies/browser.cjs.map +1 -1
  105. package/dist/crypto/ecies/browser.d.ts +2 -7
  106. package/dist/crypto/ecies/browser.js +2 -1
  107. package/dist/crypto/ecies/browser.js.map +1 -1
  108. package/dist/crypto/ecies/constants.d.ts +7 -9
  109. package/dist/crypto/ecies/index.d.ts +8 -1
  110. package/dist/crypto/ecies/interface.cjs +4 -5
  111. package/dist/crypto/ecies/interface.cjs.map +1 -1
  112. package/dist/crypto/ecies/interface.d.ts +9 -11
  113. package/dist/crypto/ecies/interface.js +4 -5
  114. package/dist/crypto/ecies/interface.js.map +1 -1
  115. package/dist/crypto/ecies/node.cjs +3 -2
  116. package/dist/crypto/ecies/node.cjs.map +1 -1
  117. package/dist/crypto/ecies/node.d.ts +2 -7
  118. package/dist/crypto/ecies/node.js +11 -16
  119. package/dist/crypto/ecies/node.js.map +1 -1
  120. package/dist/crypto/ecies/utils.cjs +2 -41
  121. package/dist/crypto/ecies/utils.cjs.map +1 -1
  122. package/dist/crypto/ecies/utils.d.ts +3 -40
  123. package/dist/crypto/ecies/utils.js +1 -35
  124. package/dist/crypto/ecies/utils.js.map +1 -1
  125. package/dist/crypto/services/WalletKeyEncryptionService.cjs +2 -2
  126. package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -1
  127. package/dist/crypto/services/WalletKeyEncryptionService.d.ts +3 -7
  128. package/dist/crypto/services/WalletKeyEncryptionService.js +5 -9
  129. package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -1
  130. package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
  131. package/dist/diagnostics.d.ts +1 -3
  132. package/dist/diagnostics.test.d.ts +1 -0
  133. package/dist/errors.cjs +16 -0
  134. package/dist/errors.cjs.map +1 -1
  135. package/dist/errors.d.ts +53 -15
  136. package/dist/errors.js +18 -6
  137. package/dist/errors.js.map +1 -1
  138. package/dist/generated/abi/ComputeEngineImplementation.d.ts +2 -3
  139. package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -1
  140. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +2 -3
  141. package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -1
  142. package/dist/generated/abi/DATFactoryImplementation.d.ts +2 -3
  143. package/dist/generated/abi/DATImplementation.d.ts +2 -3
  144. package/dist/generated/abi/DATPausableImplementation.d.ts +2 -3
  145. package/dist/generated/abi/DATVotesImplementation.d.ts +2 -3
  146. package/dist/generated/abi/DLPPerformanceImplementation.d.ts +2 -3
  147. package/dist/generated/abi/DLPRegistryImplementation.d.ts +2 -3
  148. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +2 -3
  149. package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +2 -3
  150. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +2 -3
  151. package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +2 -3
  152. package/dist/generated/abi/DLPRootImplementation.d.ts +1 -3
  153. package/dist/generated/abi/DLPTreasuryImplementation.d.ts +2 -3
  154. package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +1 -3
  155. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +2 -3
  156. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -1
  157. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +2 -3
  158. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -1
  159. package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -1
  160. package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +2 -3
  161. package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -1
  162. package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +2 -3
  163. package/dist/generated/abi/DataRegistryImplementation.d.ts +2 -3
  164. package/dist/generated/abi/QueryEngineImplementation.d.ts +2 -3
  165. package/dist/generated/abi/SwapHelperImplementation.d.ts +2 -3
  166. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +2 -3
  167. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +2 -3
  168. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +2 -3
  169. package/dist/generated/abi/TeePoolImplementation.d.ts +2 -3
  170. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +2 -3
  171. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +2 -3
  172. package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +2 -3
  173. package/dist/generated/abi/VanaEpochImplementation.d.ts +2 -3
  174. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +2 -3
  175. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +2 -3
  176. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +2 -3
  177. package/dist/generated/abi/index.d.ts +37 -39
  178. package/dist/generated/event-types.d.ts +9 -10
  179. package/dist/generated/eventRegistry.d.ts +3 -7
  180. package/dist/generated/server/server-exports.d.ts +19 -21
  181. package/dist/generated/server/server.cjs.map +1 -1
  182. package/dist/generated/server/server.d.ts +113 -87
  183. package/dist/generated/subgraph.cjs +797 -32
  184. package/dist/generated/subgraph.cjs.map +1 -1
  185. package/dist/generated/subgraph.d.ts +464 -332
  186. package/dist/generated/subgraph.js +792 -32
  187. package/dist/generated/subgraph.js.map +1 -1
  188. package/dist/index.browser.d.ts +47 -96
  189. package/dist/index.browser.js +12 -0
  190. package/dist/index.browser.js.map +1 -1
  191. package/dist/index.cjs +3 -1
  192. package/dist/index.cjs.map +1 -1
  193. package/dist/index.d.ts +0 -2
  194. package/dist/index.js +3 -1
  195. package/dist/index.js.map +1 -1
  196. package/dist/index.node.cjs +14 -3
  197. package/dist/index.node.cjs.map +1 -1
  198. package/dist/index.node.d.ts +203 -87
  199. package/dist/index.node.js +14 -2
  200. package/dist/index.node.js.map +1 -1
  201. package/dist/node.cjs.map +1 -1
  202. package/dist/node.d.ts +42 -2
  203. package/dist/node.js.map +1 -1
  204. package/dist/platform/browser-only.d.ts +5 -8
  205. package/dist/platform/browser-only.test.d.ts +1 -0
  206. package/dist/platform/browser-safe.d.ts +6 -9
  207. package/dist/platform/browser-safe.test.d.ts +1 -0
  208. package/dist/platform/browser.cjs +167 -8
  209. package/dist/platform/browser.cjs.map +1 -1
  210. package/dist/platform/browser.d.ts +235 -18
  211. package/dist/platform/browser.js +179 -29
  212. package/dist/platform/browser.js.map +1 -1
  213. package/dist/platform/browser.test.d.ts +1 -0
  214. package/dist/platform/index.d.ts +11 -5
  215. package/dist/platform/interface.cjs.map +1 -1
  216. package/dist/platform/interface.d.ts +289 -98
  217. package/dist/platform/node.cjs +163 -2
  218. package/dist/platform/node.cjs.map +1 -1
  219. package/dist/platform/node.d.ts +72 -13
  220. package/dist/platform/node.js +175 -21
  221. package/dist/platform/node.js.map +1 -1
  222. package/dist/platform/ports/openpgp-port.cjs +74 -0
  223. package/dist/platform/ports/openpgp-port.cjs.map +1 -0
  224. package/dist/platform/ports/openpgp-port.d.ts +13 -0
  225. package/dist/platform/ports/openpgp-port.js +59 -0
  226. package/dist/platform/ports/openpgp-port.js.map +1 -0
  227. package/dist/platform/ports/pgp-port.cjs +17 -0
  228. package/dist/platform/ports/pgp-port.cjs.map +1 -0
  229. package/dist/platform/ports/pgp-port.d.ts +35 -0
  230. package/dist/platform/ports/pgp-port.js +1 -0
  231. package/dist/platform/ports/pgp-port.js.map +1 -0
  232. package/dist/platform/shared/error-utils.d.ts +2 -4
  233. package/dist/platform/shared/pgp-utils.cjs +2 -2
  234. package/dist/platform/shared/pgp-utils.cjs.map +1 -1
  235. package/dist/platform/shared/pgp-utils.d.ts +3 -5
  236. package/dist/platform/shared/pgp-utils.js +2 -2
  237. package/dist/platform/shared/pgp-utils.js.map +1 -1
  238. package/dist/platform/shared/stream-utils.d.ts +1 -3
  239. package/dist/platform/utils.d.ts +6 -10
  240. package/dist/platform/utils.test.d.ts +1 -0
  241. package/dist/platform.browser.d.ts +9 -4
  242. package/dist/platform.d.ts +11 -5
  243. package/dist/platform.node.d.ts +10 -5
  244. package/dist/server/relayerHandler.cjs +337 -0
  245. package/dist/server/relayerHandler.cjs.map +1 -0
  246. package/dist/server/relayerHandler.d.ts +38 -0
  247. package/dist/server/relayerHandler.js +313 -0
  248. package/dist/server/relayerHandler.js.map +1 -0
  249. package/dist/storage/index.d.ts +56 -10
  250. package/dist/storage/manager.cjs +110 -27
  251. package/dist/storage/manager.cjs.map +1 -1
  252. package/dist/storage/manager.d.ts +121 -30
  253. package/dist/storage/manager.js +113 -37
  254. package/dist/storage/manager.js.map +1 -1
  255. package/dist/storage/providers/callback-storage.cjs +89 -18
  256. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  257. package/dist/storage/providers/callback-storage.d.ts +111 -28
  258. package/dist/storage/providers/callback-storage.js +89 -18
  259. package/dist/storage/providers/callback-storage.js.map +1 -1
  260. package/dist/storage/providers/google-drive.cjs +2 -2
  261. package/dist/storage/providers/google-drive.cjs.map +1 -1
  262. package/dist/storage/providers/google-drive.d.ts +3 -7
  263. package/dist/storage/providers/google-drive.js +4 -7
  264. package/dist/storage/providers/google-drive.js.map +1 -1
  265. package/dist/storage/providers/google-drive.test.d.ts +1 -0
  266. package/dist/storage/providers/ipfs.cjs +5 -5
  267. package/dist/storage/providers/ipfs.cjs.map +1 -1
  268. package/dist/storage/providers/ipfs.d.ts +3 -6
  269. package/dist/storage/providers/ipfs.js +7 -10
  270. package/dist/storage/providers/ipfs.js.map +1 -1
  271. package/dist/storage/providers/pinata.cjs +6 -6
  272. package/dist/storage/providers/pinata.cjs.map +1 -1
  273. package/dist/storage/providers/pinata.d.ts +17 -22
  274. package/dist/storage/providers/pinata.js +8 -11
  275. package/dist/storage/providers/pinata.js.map +1 -1
  276. package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
  277. package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
  278. package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
  279. package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
  280. package/dist/storage/tests/storageManager.test.d.ts +1 -0
  281. package/dist/tests/abi.test.d.ts +1 -0
  282. package/dist/tests/chains-definitions.test.d.ts +1 -0
  283. package/dist/tests/core-encryption.test.d.ts +1 -0
  284. package/dist/tests/core-extended.test.d.ts +1 -0
  285. package/dist/tests/core-generics-coverage.test.d.ts +1 -0
  286. package/dist/tests/coverage-boost.test.d.ts +1 -0
  287. package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
  288. package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
  289. package/dist/tests/data-additional-methods.test.d.ts +1 -0
  290. package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
  291. package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
  292. package/dist/tests/data-relayer.test.d.ts +1 -0
  293. package/dist/tests/data-schema-validation.test.d.ts +1 -0
  294. package/dist/tests/data-simple-methods.test.d.ts +1 -0
  295. package/dist/tests/data.test.d.ts +1 -0
  296. package/dist/tests/demo-integration.test.d.ts +1 -0
  297. package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
  298. package/dist/tests/download-relayer.test.d.ts +1 -0
  299. package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
  300. package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
  301. package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
  302. package/dist/tests/encryption-coverage.test.d.ts +1 -0
  303. package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
  304. package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
  305. package/dist/tests/errors-coverage.test.d.ts +1 -0
  306. package/dist/tests/errors.test.d.ts +1 -0
  307. package/dist/tests/factories/mockFactory.d.ts +316 -0
  308. package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
  309. package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
  310. package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
  311. package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
  312. package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
  313. package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
  314. package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
  315. package/dist/tests/helper-methods.test.d.ts +1 -0
  316. package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
  317. package/dist/tests/helpers/typedMocks.d.ts +64 -0
  318. package/dist/tests/index-browser.test.d.ts +1 -0
  319. package/dist/tests/index-node.test.d.ts +1 -0
  320. package/dist/tests/index.test.d.ts +1 -0
  321. package/dist/tests/mocks/platformAdapter.d.ts +12 -0
  322. package/dist/tests/new-permissions-methods.test.d.ts +1 -0
  323. package/dist/tests/no-buffer-browser.test.d.ts +1 -0
  324. package/dist/tests/permissions-grantee.test.d.ts +1 -0
  325. package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
  326. package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
  327. package/dist/tests/permissions-server-files.test.d.ts +1 -0
  328. package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
  329. package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
  330. package/dist/tests/permissions.test.d.ts +1 -0
  331. package/dist/tests/personal.test.d.ts +1 -0
  332. package/dist/tests/platform-browser.test.d.ts +1 -0
  333. package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
  334. package/dist/tests/platform-crypto.test.d.ts +1 -0
  335. package/dist/tests/platform-index.test.d.ts +1 -0
  336. package/dist/tests/platform-node.test.d.ts +1 -0
  337. package/dist/tests/platform-shared-utils.test.d.ts +1 -0
  338. package/dist/tests/platform-updated.test.d.ts +1 -0
  339. package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
  340. package/dist/tests/protocol.test.d.ts +1 -0
  341. package/dist/tests/read-only-mode.test.d.ts +1 -0
  342. package/dist/tests/relayer-integration.test.d.ts +1 -0
  343. package/dist/tests/relayer-unified.test.d.ts +1 -0
  344. package/dist/tests/schemas.test.d.ts +1 -0
  345. package/dist/tests/server-relayer-handler.test.d.ts +1 -0
  346. package/dist/tests/setup.d.ts +7 -0
  347. package/dist/tests/signatureFormatter.test.d.ts +1 -0
  348. package/dist/tests/trusted-server-queries.test.d.ts +1 -0
  349. package/dist/tests/typedDataConverter.test.d.ts +1 -0
  350. package/dist/tests/types-contracts.test.d.ts +1 -0
  351. package/dist/tests/types-data.test.d.ts +1 -0
  352. package/dist/tests/types-external-apis.test.d.ts +1 -0
  353. package/dist/tests/types-generics.test.d.ts +1 -0
  354. package/dist/tests/types-permissions.test.d.ts +1 -0
  355. package/dist/tests/types-upload-params.test.d.ts +1 -0
  356. package/dist/tests/types.test.d.ts +1 -0
  357. package/dist/tests/utils-formatters.test.d.ts +1 -0
  358. package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
  359. package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
  360. package/dist/tests/utils-grantFiles.test.d.ts +1 -0
  361. package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
  362. package/dist/tests/utils-grants.test.d.ts +1 -0
  363. package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
  364. package/dist/tests/utils-ipfs.test.d.ts +4 -0
  365. package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
  366. package/dist/tests/vana.test.d.ts +1 -0
  367. package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
  368. package/dist/types/blockchain.cjs.map +1 -1
  369. package/dist/types/blockchain.d.ts +46 -13
  370. package/dist/types/chains-additional.test.d.ts +1 -0
  371. package/dist/types/chains.cjs.map +1 -1
  372. package/dist/types/chains.d.ts +80 -16
  373. package/dist/types/chains.js.map +1 -1
  374. package/dist/types/config.cjs +10 -0
  375. package/dist/types/config.cjs.map +1 -1
  376. package/dist/types/config.d.ts +236 -242
  377. package/dist/types/config.js +8 -0
  378. package/dist/types/config.js.map +1 -1
  379. package/dist/types/contracts.cjs.map +1 -1
  380. package/dist/types/contracts.d.ts +79 -18
  381. package/dist/types/controller-context.cjs.map +1 -1
  382. package/dist/types/controller-context.d.ts +17 -21
  383. package/dist/types/data.cjs.map +1 -1
  384. package/dist/types/data.d.ts +111 -49
  385. package/dist/types/external-apis.d.ts +10 -12
  386. package/dist/types/generics.cjs.map +1 -1
  387. package/dist/types/generics.d.ts +116 -48
  388. package/dist/types/index.cjs +5 -4
  389. package/dist/types/index.cjs.map +1 -1
  390. package/dist/types/index.d.ts +47 -22
  391. package/dist/types/index.js +9 -2
  392. package/dist/types/index.js.map +1 -1
  393. package/dist/types/operations.cjs +2 -2
  394. package/dist/types/operations.cjs.map +1 -1
  395. package/dist/types/operations.d.ts +178 -32
  396. package/dist/types/operations.js +2 -2
  397. package/dist/types/operations.js.map +1 -1
  398. package/dist/types/options.cjs +17 -0
  399. package/dist/types/options.cjs.map +1 -0
  400. package/dist/types/options.d.ts +213 -0
  401. package/dist/types/options.js +1 -0
  402. package/dist/types/options.js.map +1 -0
  403. package/dist/types/permissions.cjs.map +1 -1
  404. package/dist/types/permissions.d.ts +72 -78
  405. package/dist/types/personal.cjs.map +1 -1
  406. package/dist/types/personal.d.ts +137 -22
  407. package/dist/types/relayer.cjs.map +1 -1
  408. package/dist/types/relayer.d.ts +293 -50
  409. package/dist/types/storage.cjs.map +1 -1
  410. package/dist/types/storage.d.ts +15 -29
  411. package/dist/types/storage.js +2 -5
  412. package/dist/types/storage.js.map +1 -1
  413. package/dist/types/transactionResults.d.ts +16 -18
  414. package/dist/types/utils.cjs.map +1 -1
  415. package/dist/types/utils.d.ts +20 -68
  416. package/dist/types.d.ts +4 -28
  417. package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
  418. package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
  419. package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
  420. package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
  421. package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
  422. package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
  423. package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
  424. package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
  425. package/dist/utils/blockchain/registry.cjs +2 -2
  426. package/dist/utils/blockchain/registry.cjs.map +1 -1
  427. package/dist/utils/blockchain/registry.d.ts +6 -8
  428. package/dist/utils/blockchain/registry.js +2 -2
  429. package/dist/utils/blockchain/registry.js.map +1 -1
  430. package/dist/utils/blockchain/registry.test.d.ts +1 -0
  431. package/dist/utils/chainQuery.cjs +107 -0
  432. package/dist/utils/chainQuery.cjs.map +1 -0
  433. package/dist/utils/chainQuery.d.ts +31 -0
  434. package/dist/utils/chainQuery.js +82 -0
  435. package/dist/utils/chainQuery.js.map +1 -0
  436. package/dist/utils/crypto-utils.cjs +0 -12
  437. package/dist/utils/crypto-utils.cjs.map +1 -1
  438. package/dist/utils/crypto-utils.d.ts +9 -27
  439. package/dist/utils/crypto-utils.js +0 -11
  440. package/dist/utils/crypto-utils.js.map +1 -1
  441. package/dist/utils/crypto-utils.test.d.ts +1 -0
  442. package/dist/utils/download.cjs +3 -3
  443. package/dist/utils/download.cjs.map +1 -1
  444. package/dist/utils/download.d.ts +13 -14
  445. package/dist/utils/download.js +2 -2
  446. package/dist/utils/download.js.map +1 -1
  447. package/dist/utils/encoding.cjs +1 -1
  448. package/dist/utils/encoding.cjs.map +1 -1
  449. package/dist/utils/encoding.d.ts +4 -6
  450. package/dist/utils/encoding.js +1 -1
  451. package/dist/utils/encoding.js.map +1 -1
  452. package/dist/utils/encoding.test.d.ts +1 -0
  453. package/dist/utils/encryption.cjs +16 -10
  454. package/dist/utils/encryption.cjs.map +1 -1
  455. package/dist/utils/encryption.d.ts +13 -17
  456. package/dist/utils/encryption.js +16 -10
  457. package/dist/utils/encryption.js.map +1 -1
  458. package/dist/utils/formatters.cjs +4 -2
  459. package/dist/utils/formatters.cjs.map +1 -1
  460. package/dist/utils/formatters.d.ts +4 -6
  461. package/dist/utils/formatters.js +4 -2
  462. package/dist/utils/formatters.js.map +1 -1
  463. package/dist/utils/grantFiles.cjs +7 -4
  464. package/dist/utils/grantFiles.cjs.map +1 -1
  465. package/dist/utils/grantFiles.d.ts +16 -30
  466. package/dist/utils/grantFiles.js +7 -4
  467. package/dist/utils/grantFiles.js.map +1 -1
  468. package/dist/utils/grantValidation.cjs +1 -1
  469. package/dist/utils/grantValidation.cjs.map +1 -1
  470. package/dist/utils/grantValidation.d.ts +109 -33
  471. package/dist/utils/grantValidation.js +1 -1
  472. package/dist/utils/grantValidation.js.map +1 -1
  473. package/dist/utils/grants.cjs +1 -1
  474. package/dist/utils/grants.cjs.map +1 -1
  475. package/dist/utils/grants.d.ts +101 -23
  476. package/dist/utils/grants.js +1 -1
  477. package/dist/utils/grants.js.map +1 -1
  478. package/dist/utils/ipfs.cjs +2 -4
  479. package/dist/utils/ipfs.cjs.map +1 -1
  480. package/dist/utils/ipfs.d.ts +8 -10
  481. package/dist/utils/ipfs.js +2 -4
  482. package/dist/utils/ipfs.js.map +1 -1
  483. package/dist/utils/lazy-import.cjs +4 -6
  484. package/dist/utils/lazy-import.cjs.map +1 -1
  485. package/dist/utils/lazy-import.d.ts +33 -10
  486. package/dist/utils/lazy-import.js +4 -6
  487. package/dist/utils/lazy-import.js.map +1 -1
  488. package/dist/utils/multicall.cjs +4 -2
  489. package/dist/utils/multicall.cjs.map +1 -1
  490. package/dist/utils/multicall.d.ts +5 -8
  491. package/dist/utils/multicall.js +4 -2
  492. package/dist/utils/multicall.js.map +1 -1
  493. package/dist/utils/parseTransactionPojo.cjs.map +1 -1
  494. package/dist/utils/parseTransactionPojo.d.ts +4 -10
  495. package/dist/utils/parseTransactionPojo.js.map +1 -1
  496. package/dist/utils/schemaValidation.cjs +5 -5
  497. package/dist/utils/schemaValidation.cjs.map +1 -1
  498. package/dist/utils/schemaValidation.d.ts +8 -12
  499. package/dist/utils/schemaValidation.js +7 -10
  500. package/dist/utils/schemaValidation.js.map +1 -1
  501. package/dist/utils/signatureCache.cjs +9 -4
  502. package/dist/utils/signatureCache.cjs.map +1 -1
  503. package/dist/utils/signatureCache.d.ts +53 -15
  504. package/dist/utils/signatureCache.js +12 -10
  505. package/dist/utils/signatureCache.js.map +1 -1
  506. package/dist/utils/signatureFormatter.cjs +6 -9
  507. package/dist/utils/signatureFormatter.cjs.map +1 -1
  508. package/dist/utils/signatureFormatter.d.ts +2 -5
  509. package/dist/utils/signatureFormatter.js +6 -9
  510. package/dist/utils/signatureFormatter.js.map +1 -1
  511. package/dist/utils/subgraphConsistency.cjs +184 -0
  512. package/dist/utils/subgraphConsistency.cjs.map +1 -0
  513. package/dist/utils/subgraphConsistency.d.ts +65 -0
  514. package/dist/utils/subgraphConsistency.js +155 -0
  515. package/dist/utils/subgraphConsistency.js.map +1 -0
  516. package/dist/utils/subgraphMetaCache.cjs +101 -0
  517. package/dist/utils/subgraphMetaCache.cjs.map +1 -0
  518. package/dist/utils/subgraphMetaCache.d.ts +56 -0
  519. package/dist/utils/subgraphMetaCache.js +76 -0
  520. package/dist/utils/subgraphMetaCache.js.map +1 -0
  521. package/dist/utils/subgraphPagination.cjs +104 -0
  522. package/dist/utils/subgraphPagination.cjs.map +1 -0
  523. package/dist/utils/subgraphPagination.d.ts +78 -0
  524. package/dist/utils/subgraphPagination.js +78 -0
  525. package/dist/utils/subgraphPagination.js.map +1 -0
  526. package/dist/utils/tests/multicall.test.d.ts +1 -0
  527. package/dist/utils/transactionHelpers.cjs.map +1 -1
  528. package/dist/utils/transactionHelpers.d.ts +17 -23
  529. package/dist/utils/transactionHelpers.js.map +1 -1
  530. package/dist/utils/typeGuards.cjs +109 -0
  531. package/dist/utils/typeGuards.cjs.map +1 -0
  532. package/dist/utils/typeGuards.d.ts +138 -0
  533. package/dist/utils/typeGuards.js +74 -0
  534. package/dist/utils/typeGuards.js.map +1 -0
  535. package/dist/utils/typedDataConverter.cjs.map +1 -1
  536. package/dist/utils/typedDataConverter.d.ts +42 -9
  537. package/dist/utils/typedDataConverter.js.map +1 -1
  538. package/dist/utils/urlResolver.cjs +8 -1
  539. package/dist/utils/urlResolver.cjs.map +1 -1
  540. package/dist/utils/urlResolver.d.ts +24 -8
  541. package/dist/utils/urlResolver.js +9 -2
  542. package/dist/utils/urlResolver.js.map +1 -1
  543. package/dist/utils/wallet.cjs +63 -0
  544. package/dist/utils/wallet.cjs.map +1 -0
  545. package/dist/utils/wallet.d.ts +94 -0
  546. package/dist/utils/wallet.js +37 -0
  547. package/dist/utils/wallet.js.map +1 -0
  548. package/dist/utils/withEvents.cjs.map +1 -1
  549. package/dist/utils/withEvents.d.ts +5 -12
  550. package/dist/utils/withEvents.js.map +1 -1
  551. package/package.json +24 -16
  552. package/dist/browser.d.cts +0 -2
  553. package/dist/chains/definitions.d.cts +0 -53
  554. package/dist/chains/index.d.cts +0 -2
  555. package/dist/chains.browser.cjs +0 -37
  556. package/dist/chains.browser.cjs.map +0 -1
  557. package/dist/chains.browser.d.cts +0 -2
  558. package/dist/chains.d.cts +0 -2
  559. package/dist/chains.node.d.cts +0 -2
  560. package/dist/config/addresses.d.cts +0 -401
  561. package/dist/config/chains.d.cts +0 -85
  562. package/dist/config/features.d.cts +0 -64
  563. package/dist/contracts/contractController.d.cts +0 -117
  564. package/dist/controllers/data.d.cts +0 -915
  565. package/dist/controllers/permissions.d.cts +0 -1383
  566. package/dist/controllers/protocol.d.cts +0 -188
  567. package/dist/controllers/schemas.d.cts +0 -260
  568. package/dist/controllers/server.d.cts +0 -230
  569. package/dist/core/apiClient.d.cts +0 -165
  570. package/dist/core/client.d.cts +0 -92
  571. package/dist/core/generics.d.cts +0 -120
  572. package/dist/core.d.cts +0 -493
  573. package/dist/crypto/ecies/__tests__/test-vectors.d.cts +0 -40
  574. package/dist/crypto/ecies/base.d.cts +0 -143
  575. package/dist/crypto/ecies/browser.d.cts +0 -48
  576. package/dist/crypto/ecies/constants.d.cts +0 -122
  577. package/dist/crypto/ecies/index.d.cts +0 -1
  578. package/dist/crypto/ecies/interface.d.cts +0 -176
  579. package/dist/crypto/ecies/node.d.cts +0 -50
  580. package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.cts +0 -76
  581. package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.ts +0 -76
  582. package/dist/crypto/ecies/utils.d.cts +0 -67
  583. package/dist/crypto/services/WalletKeyEncryptionService.d.cts +0 -92
  584. package/dist/diagnostics.d.cts +0 -26
  585. package/dist/errors.d.cts +0 -350
  586. package/dist/generated/abi/ComputeEngineImplementation.d.cts +0 -996
  587. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +0 -545
  588. package/dist/generated/abi/DATFactoryImplementation.d.cts +0 -661
  589. package/dist/generated/abi/DATImplementation.d.cts +0 -693
  590. package/dist/generated/abi/DATPausableImplementation.d.cts +0 -1145
  591. package/dist/generated/abi/DATVotesImplementation.d.cts +0 -1095
  592. package/dist/generated/abi/DLPPerformanceImplementation.d.cts +0 -883
  593. package/dist/generated/abi/DLPRegistryImplementation.d.cts +0 -1123
  594. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +0 -452
  595. package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +0 -714
  596. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +0 -452
  597. package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +0 -706
  598. package/dist/generated/abi/DLPRootImplementation.d.cts +0 -1248
  599. package/dist/generated/abi/DLPTreasuryImplementation.d.cts +0 -452
  600. package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +0 -737
  601. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +0 -661
  602. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +0 -989
  603. package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +0 -1086
  604. package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +0 -737
  605. package/dist/generated/abi/DataRegistryImplementation.d.cts +0 -1014
  606. package/dist/generated/abi/QueryEngineImplementation.d.cts +0 -1001
  607. package/dist/generated/abi/SwapHelperImplementation.d.cts +0 -764
  608. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +0 -701
  609. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +0 -701
  610. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +0 -701
  611. package/dist/generated/abi/TeePoolImplementation.d.cts +0 -993
  612. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +0 -701
  613. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +0 -701
  614. package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +0 -993
  615. package/dist/generated/abi/VanaEpochImplementation.d.cts +0 -900
  616. package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +0 -934
  617. package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +0 -693
  618. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +0 -394
  619. package/dist/generated/abi/index.d.cts +0 -26547
  620. package/dist/generated/event-types.d.cts +0 -855
  621. package/dist/generated/eventRegistry.d.cts +0 -18
  622. package/dist/generated/server/server-exports.d.cts +0 -21
  623. package/dist/generated/server/server.d.cts +0 -512
  624. package/dist/generated/subgraph.d.cts +0 -5981
  625. package/dist/index.browser.cjs +0 -151
  626. package/dist/index.browser.cjs.map +0 -1
  627. package/dist/index.browser.d.cts +0 -201
  628. package/dist/index.d.cts +0 -2
  629. package/dist/index.node.d.cts +0 -87
  630. package/dist/node.d.cts +0 -2
  631. package/dist/platform/browser-only.d.cts +0 -25
  632. package/dist/platform/browser-safe.d.cts +0 -32
  633. package/dist/platform/browser.d.cts +0 -74
  634. package/dist/platform/index.d.cts +0 -5
  635. package/dist/platform/interface.d.cts +0 -218
  636. package/dist/platform/node.d.cts +0 -27
  637. package/dist/platform/shared/error-utils.d.cts +0 -25
  638. package/dist/platform/shared/pgp-utils.d.cts +0 -61
  639. package/dist/platform/shared/stream-utils.d.cts +0 -16
  640. package/dist/platform/utils.d.cts +0 -53
  641. package/dist/platform.browser.cjs +0 -41
  642. package/dist/platform.browser.cjs.map +0 -1
  643. package/dist/platform.browser.d.cts +0 -4
  644. package/dist/platform.d.cts +0 -5
  645. package/dist/platform.node.d.cts +0 -5
  646. package/dist/schemas/dataSchema.schema.d.cts +0 -88
  647. package/dist/schemas/dataSchema.schema.d.ts +0 -88
  648. package/dist/schemas/grantFile.schema.d.cts +0 -57
  649. package/dist/schemas/grantFile.schema.d.ts +0 -57
  650. package/dist/server/handler.cjs +0 -101
  651. package/dist/server/handler.cjs.map +0 -1
  652. package/dist/server/handler.d.cts +0 -306
  653. package/dist/server/handler.d.ts +0 -306
  654. package/dist/server/handler.js +0 -77
  655. package/dist/server/handler.js.map +0 -1
  656. package/dist/storage/index.d.cts +0 -10
  657. package/dist/storage/manager.d.cts +0 -150
  658. package/dist/storage/providers/callback-storage.d.cts +0 -100
  659. package/dist/storage/providers/google-drive.d.cts +0 -156
  660. package/dist/storage/providers/ipfs.d.cts +0 -163
  661. package/dist/storage/providers/pinata.d.cts +0 -173
  662. package/dist/types/blockchain.d.cts +0 -52
  663. package/dist/types/chains.d.cts +0 -34
  664. package/dist/types/config.d.cts +0 -726
  665. package/dist/types/contracts.d.cts +0 -68
  666. package/dist/types/controller-context.d.cts +0 -71
  667. package/dist/types/data.d.cts +0 -694
  668. package/dist/types/eccrypto-js.d.d.cts +0 -13
  669. package/dist/types/eccrypto-js.d.d.ts +0 -13
  670. package/dist/types/external-apis.d.cts +0 -186
  671. package/dist/types/generics.d.cts +0 -450
  672. package/dist/types/index.d.cts +0 -22
  673. package/dist/types/operations.d.cts +0 -116
  674. package/dist/types/permissions.d.cts +0 -957
  675. package/dist/types/personal.d.cts +0 -40
  676. package/dist/types/relayer.d.cts +0 -284
  677. package/dist/types/storage.d.cts +0 -131
  678. package/dist/types/transactionResults.d.cts +0 -195
  679. package/dist/types/utils.d.cts +0 -819
  680. package/dist/types.d.cts +0 -54
  681. package/dist/utils/blockchain/registry.d.cts +0 -34
  682. package/dist/utils/crypto-utils.d.cts +0 -118
  683. package/dist/utils/download.d.cts +0 -41
  684. package/dist/utils/encoding.d.cts +0 -54
  685. package/dist/utils/encryption.d.cts +0 -275
  686. package/dist/utils/formatters.d.cts +0 -120
  687. package/dist/utils/grantFiles.d.cts +0 -186
  688. package/dist/utils/grantValidation.d.cts +0 -150
  689. package/dist/utils/grants.d.cts +0 -70
  690. package/dist/utils/ipfs.d.cts +0 -90
  691. package/dist/utils/lazy-import.d.cts +0 -20
  692. package/dist/utils/multicall.d.cts +0 -129
  693. package/dist/utils/parseTransactionPojo.d.cts +0 -37
  694. package/dist/utils/schemaValidation.d.cts +0 -172
  695. package/dist/utils/signatureCache.d.cts +0 -134
  696. package/dist/utils/signatureFormatter.d.cts +0 -39
  697. package/dist/utils/transactionHelpers.d.cts +0 -86
  698. package/dist/utils/typedDataConverter.d.cts +0 -13
  699. package/dist/utils/urlResolver.d.cts +0 -40
  700. package/dist/utils/withEvents.d.cts +0 -63
@@ -18,9 +18,10 @@ import { validateGrant } from "../utils/grantValidation";
18
18
  import { withSignatureCache } from "../utils/signatureCache";
19
19
  import { formatSignatureForContract } from "../utils/signatureFormatter";
20
20
  import { toViemTypedDataDefinition } from "../utils/typedDataConverter";
21
- class PermissionsController {
21
+ import { BaseController } from "./base";
22
+ class PermissionsController extends BaseController {
22
23
  constructor(context) {
23
- this.context = context;
24
+ super(context);
24
25
  }
25
26
  /**
26
27
  * Grants permission for an application to access user data with gasless transactions.
@@ -56,9 +57,14 @@ class PermissionsController {
56
57
  * await vana.permissions.revoke({ permissionId: result.permissionId });
57
58
  * ```
58
59
  */
59
- async grant(params) {
60
+ async grant(params, options) {
61
+ this.assertWallet();
60
62
  const { typedData, signature } = await this.createAndSign(params);
61
- const result = await this.submitSignedGrantWithEvents(typedData, signature);
63
+ const result = await this.submitSignedGrantWithEvents(
64
+ typedData,
65
+ signature,
66
+ options
67
+ );
62
68
  return result;
63
69
  }
64
70
  /**
@@ -86,9 +92,10 @@ class PermissionsController {
86
92
  * console.log(`Permission ID: ${eventData.permissionId}`);
87
93
  * ```
88
94
  */
89
- async submitPermissionGrant(params) {
95
+ async submitPermissionGrant(params, options) {
96
+ this.assertWallet();
90
97
  const { typedData, signature } = await this.createAndSign(params);
91
- return await this.submitSignedGrant(typedData, signature);
98
+ return await this.submitSignedGrant(typedData, signature, options);
92
99
  }
93
100
  /**
94
101
  * Prepares a permission grant with preview before signing.
@@ -115,14 +122,19 @@ class PermissionsController {
115
122
  * const transactionHash = await confirm();
116
123
  * ```
117
124
  */
118
- async prepareGrant(params) {
125
+ async prepareGrant(params, options) {
126
+ this.assertWallet();
119
127
  try {
120
128
  const grantFile = createGrantFile(params);
121
129
  validateGrant(grantFile);
122
130
  return {
123
131
  preview: grantFile,
124
132
  confirm: async () => {
125
- return await this.confirmGrantInternalWithEvents(params, grantFile);
133
+ return await this.confirmGrantInternalWithEvents(
134
+ params,
135
+ grantFile,
136
+ options
137
+ );
126
138
  }
127
139
  };
128
140
  } catch (error) {
@@ -154,22 +166,36 @@ class PermissionsController {
154
166
  * @throws {NetworkError} When IPFS upload fails
155
167
  * @throws {SignatureError} When user rejects the signature
156
168
  */
157
- async confirmGrantInternal(params, grantFile) {
169
+ async confirmGrantInternal(params, grantFile, options) {
158
170
  try {
159
- let grantUrl = params.grantUrl;
171
+ let { grantUrl } = params;
160
172
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
161
173
  if (!grantUrl) {
162
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
174
+ const canStoreViaRelayer = this.context.relayer !== void 0;
175
+ if (!canStoreViaRelayer && !this.context.storageManager) {
163
176
  if (this.context.validateStorageRequired) {
164
177
  this.context.validateStorageRequired();
165
178
  } else {
166
179
  throw new Error(
167
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
180
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
168
181
  );
169
182
  }
170
183
  }
171
- if (this.context.relayerCallbacks?.storeGrantFile) {
172
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
184
+ if (canStoreViaRelayer && this.context.relayer) {
185
+ const request = {
186
+ type: "direct",
187
+ operation: "storeGrantFile",
188
+ params: grantFile
189
+ };
190
+ const response = await this.context.relayer(request);
191
+ if (response.type === "error") {
192
+ throw new Error(response.error);
193
+ }
194
+ if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
195
+ grantUrl = response.result.url;
196
+ } else {
197
+ throw new Error("Invalid response from relayer for grant storage");
198
+ }
173
199
  } else if (this.context.storageManager) {
174
200
  const blob = new Blob([JSON.stringify(grantFile)], {
175
201
  type: "application/json"
@@ -201,7 +227,7 @@ class PermissionsController {
201
227
  nonce
202
228
  });
203
229
  const signature = await this.signTypedData(typedData);
204
- return await this.submitSignedGrant(typedData, signature);
230
+ return await this.submitSignedGrant(typedData, signature, options);
205
231
  } catch (error) {
206
232
  if (error instanceof Error) {
207
233
  if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
@@ -246,23 +272,38 @@ class PermissionsController {
246
272
  * ```
247
273
  */
248
274
  async createAndSign(params) {
275
+ this.assertWallet();
249
276
  try {
250
277
  const grantFile = createGrantFile(params);
251
278
  validateGrant(grantFile);
252
- let grantUrl = params.grantUrl;
279
+ let { grantUrl } = params;
253
280
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
254
281
  if (!grantUrl) {
255
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
282
+ const canStoreViaRelayer = this.context.relayer !== void 0;
283
+ if (!canStoreViaRelayer && !this.context.storageManager) {
256
284
  if (this.context.validateStorageRequired) {
257
285
  this.context.validateStorageRequired();
258
286
  } else {
259
287
  throw new Error(
260
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
288
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
261
289
  );
262
290
  }
263
291
  }
264
- if (this.context.relayerCallbacks?.storeGrantFile) {
265
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
292
+ if (canStoreViaRelayer && this.context.relayer) {
293
+ const request = {
294
+ type: "direct",
295
+ operation: "storeGrantFile",
296
+ params: grantFile
297
+ };
298
+ const response = await this.context.relayer(request);
299
+ if (response.type === "error") {
300
+ throw new Error(response.error);
301
+ }
302
+ if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
303
+ grantUrl = response.result.url;
304
+ } else {
305
+ throw new Error("Invalid response from relayer for grant storage");
306
+ }
266
307
  } else if (this.context.storageManager) {
267
308
  const blob = new Blob([JSON.stringify(grantFile)], {
268
309
  type: "application/json"
@@ -331,31 +372,58 @@ class PermissionsController {
331
372
  * );
332
373
  * ```
333
374
  */
334
- async submitSignedGrant(typedData, signature) {
375
+ async submitSignedGrant(typedData, signature, options) {
335
376
  try {
336
377
  console.debug(
337
378
  "\u{1F50D} Debug - submitSignedGrant called with typed data:",
338
379
  JSON.stringify(
339
380
  typedData,
340
- (key, value) => typeof value === "bigint" ? value.toString() : value,
381
+ (_key, value) => typeof value === "bigint" ? value.toString() : value,
341
382
  2
342
383
  )
343
384
  );
344
- if (this.context.relayerCallbacks?.submitPermissionGrant) {
345
- const hash = await this.context.relayerCallbacks.submitPermissionGrant(
385
+ if (this.context.relayer) {
386
+ const response = await this.context.relayer({
387
+ type: "signed",
388
+ operation: "submitAddPermission",
346
389
  typedData,
347
- signature
348
- );
349
- const account = this.context.walletClient.account || await this.getUserAddress();
390
+ signature,
391
+ expectedUserAddress: this.context.userAddress
392
+ });
393
+ if (response.type === "error") {
394
+ throw new Error(`Relayer error: ${response.error}`);
395
+ }
396
+ let finalHash;
397
+ if (response.type === "submitted") {
398
+ finalHash = response.hash;
399
+ } else if (response.type === "pending") {
400
+ const pollResult = await this.pollRelayerForConfirmation(
401
+ response.operationId
402
+ );
403
+ finalHash = pollResult.hash;
404
+ } else if (response.type === "confirmed") {
405
+ finalHash = response.hash;
406
+ } else if (response.type === "signed") {
407
+ finalHash = response.hash;
408
+ } else {
409
+ throw new Error(
410
+ "Invalid response from relayer: unexpected response type"
411
+ );
412
+ }
413
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
350
414
  const { tx } = await import("../utils/transactionHelpers");
351
415
  return tx({
352
- hash,
416
+ hash: finalHash,
353
417
  from: typeof account === "string" ? account : account.address,
354
418
  contract: "DataPortabilityPermissions",
355
419
  fn: "addPermission"
356
420
  });
357
421
  } else {
358
- return await this.submitDirectTransaction(typedData, signature);
422
+ return await this.submitDirectTransaction(
423
+ typedData,
424
+ signature,
425
+ options
426
+ );
359
427
  }
360
428
  } catch (error) {
361
429
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
@@ -388,7 +456,7 @@ class PermissionsController {
388
456
  * const result = await txHandle.waitForEvents();
389
457
  * ```
390
458
  */
391
- async submitSignedTrustServer(typedData, signature) {
459
+ async submitSignedTrustServer(typedData, signature, options) {
392
460
  try {
393
461
  const trustServerInput = {
394
462
  nonce: BigInt(typedData.message.nonce),
@@ -396,13 +464,14 @@ class PermissionsController {
396
464
  };
397
465
  const hash = await this.submitTrustServerTransaction(
398
466
  trustServerInput,
399
- signature
467
+ signature,
468
+ options
400
469
  );
401
- const account = this.context.walletClient.account || await this.getUserAddress();
470
+ const account = this.context.userAddress;
402
471
  const { tx } = await import("../utils/transactionHelpers");
403
472
  return tx({
404
473
  hash,
405
- from: typeof account === "string" ? account : account.address,
474
+ from: account,
406
475
  contract: "DataPortabilityServers",
407
476
  fn: "trustServerWithSignature"
408
477
  });
@@ -451,7 +520,7 @@ class PermissionsController {
451
520
  * const result = await txHandle.waitForEvents();
452
521
  * ```
453
522
  */
454
- async submitSignedAddAndTrustServer(typedData, signature) {
523
+ async submitSignedAddAndTrustServer(typedData, signature, _options) {
455
524
  try {
456
525
  const addAndTrustServerInput = {
457
526
  nonce: BigInt(typedData.message.nonce),
@@ -463,7 +532,7 @@ class PermissionsController {
463
532
  addAndTrustServerInput,
464
533
  signature
465
534
  );
466
- const account = this.context.walletClient.account || await this.getUserAddress();
535
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
467
536
  const { tx } = await import("../utils/transactionHelpers");
468
537
  return tx({
469
538
  hash,
@@ -483,21 +552,27 @@ class PermissionsController {
483
552
  }
484
553
  /**
485
554
  * Internal method to submit a signed grant and wait for events.
486
- *
555
+ *
487
556
  * @internal
488
557
  * @param typedData - The EIP-712 typed data for the permission grant
489
558
  * @param signature - The user's signature authorizing the transaction
490
559
  * @returns Promise resolving to PermissionGrantResult with parsed events
491
560
  */
492
- async submitSignedGrantWithEvents(typedData, signature) {
493
- const txResult = await this.submitSignedGrant(typedData, signature);
561
+ async submitSignedGrantWithEvents(typedData, signature, options) {
562
+ const txResult = await this.submitSignedGrant(
563
+ typedData,
564
+ signature,
565
+ options
566
+ );
494
567
  if (!this.context.waitForTransactionEvents) {
495
568
  throw new BlockchainError("waitForTransactionEvents not configured");
496
569
  }
497
570
  const result = await this.context.waitForTransactionEvents(txResult);
498
571
  const event = result.expectedEvents.PermissionAdded;
499
572
  if (!event) {
500
- throw new BlockchainError("PermissionAdded event not found in transaction");
573
+ throw new BlockchainError(
574
+ "PermissionAdded event not found in transaction"
575
+ );
501
576
  }
502
577
  const receipt = await this.context.publicClient.getTransactionReceipt({
503
578
  hash: result.hash
@@ -514,21 +589,27 @@ class PermissionsController {
514
589
  }
515
590
  /**
516
591
  * Internal method for confirm grant with events.
517
- *
592
+ *
518
593
  * @internal
519
594
  * @param params - The permission grant parameters
520
595
  * @param grantFile - The pre-created grant file object
521
596
  * @returns Promise resolving to PermissionGrantResult with parsed events
522
597
  */
523
- async confirmGrantInternalWithEvents(params, grantFile) {
524
- const txResult = await this.confirmGrantInternal(params, grantFile);
598
+ async confirmGrantInternalWithEvents(params, grantFile, options) {
599
+ const txResult = await this.confirmGrantInternal(
600
+ params,
601
+ grantFile,
602
+ options
603
+ );
525
604
  if (!this.context.waitForTransactionEvents) {
526
605
  throw new BlockchainError("waitForTransactionEvents not configured");
527
606
  }
528
607
  const result = await this.context.waitForTransactionEvents(txResult);
529
608
  const event = result.expectedEvents.PermissionAdded;
530
609
  if (!event) {
531
- throw new BlockchainError("PermissionAdded event not found in transaction");
610
+ throw new BlockchainError(
611
+ "PermissionAdded event not found in transaction"
612
+ );
532
613
  }
533
614
  const receipt = await this.context.publicClient.getTransactionReceipt({
534
615
  hash: result.hash
@@ -544,32 +625,37 @@ class PermissionsController {
544
625
  };
545
626
  }
546
627
  /**
547
- * Internal method to submit a signed revoke and wait for events.
548
- *
628
+ * Polls the relayer for confirmation of a pending operation.
629
+ *
630
+ * @param operationId - The operation ID to poll
631
+ * @returns Promise resolving to the confirmed hash
632
+ * @throws {Error} When the operation fails or times out
549
633
  * @internal
550
- * @param typedData - The EIP-712 typed data for the permission revoke
551
- * @param signature - The user's signature authorizing the transaction
552
- * @returns Promise resolving to PermissionRevokeResult with parsed events
553
634
  */
554
- async submitSignedRevokeWithEvents(typedData, signature) {
555
- const txResult = await this.submitSignedRevoke(typedData, signature);
556
- if (!this.context.waitForTransactionEvents) {
557
- throw new BlockchainError("waitForTransactionEvents not configured");
558
- }
559
- const result = await this.context.waitForTransactionEvents(txResult);
560
- const event = result.expectedEvents.PermissionRevoked;
561
- if (!event) {
562
- throw new BlockchainError("PermissionRevoked event not found in transaction");
635
+ async pollRelayerForConfirmation(operationId, options = {}) {
636
+ const timeout = options.timeout ?? 3e4;
637
+ let interval = options.pollingInterval ?? 1e3;
638
+ const startTime = Date.now();
639
+ while (Date.now() - startTime < timeout) {
640
+ if (!this.context.relayer) {
641
+ throw new Error("Relayer not configured for polling");
642
+ }
643
+ const statusResponse = await this.context.relayer({
644
+ type: "status_check",
645
+ operationId
646
+ });
647
+ if (statusResponse.type === "confirmed") {
648
+ return { hash: statusResponse.hash };
649
+ }
650
+ if (statusResponse.type === "error") {
651
+ throw new Error(
652
+ `Operation ${operationId} failed: ${statusResponse.error}`
653
+ );
654
+ }
655
+ await new Promise((resolve) => setTimeout(resolve, interval));
656
+ interval = Math.min(interval * 1.5, 5e3);
563
657
  }
564
- const receipt = await this.context.publicClient.getTransactionReceipt({
565
- hash: result.hash
566
- });
567
- return {
568
- transactionHash: result.hash,
569
- blockNumber: receipt.blockNumber,
570
- gasUsed: receipt.gasUsed,
571
- permissionId: event.permissionId
572
- };
658
+ throw new Error(`Operation ${operationId} timed out after ${timeout}ms`);
573
659
  }
574
660
  /**
575
661
  * Submits an already-signed permission revoke transaction to the blockchain.
@@ -592,18 +678,43 @@ class PermissionsController {
592
678
  * const result = await txHandle.waitForEvents();
593
679
  * ```
594
680
  */
595
- async submitSignedRevoke(typedData, signature) {
681
+ async submitSignedRevoke(typedData, signature, _options) {
596
682
  try {
597
683
  let hash;
598
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
599
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
684
+ if (this.context.relayer) {
685
+ const response = await this.context.relayer({
686
+ type: "signed",
687
+ operation: "submitPermissionRevoke",
688
+ typedData,
689
+ signature,
690
+ expectedUserAddress: this.context.userAddress
691
+ });
692
+ if (response.type === "error") {
693
+ throw new Error(`Relayer error: ${response.error}`);
694
+ }
695
+ if (response.type === "submitted") {
696
+ hash = response.hash;
697
+ } else if (response.type === "pending") {
698
+ const pollResult = await this.pollRelayerForConfirmation(
699
+ response.operationId
700
+ );
701
+ hash = pollResult.hash;
702
+ } else if (response.type === "confirmed") {
703
+ hash = response.hash;
704
+ } else if (response.type === "signed") {
705
+ hash = response.hash;
706
+ } else {
707
+ throw new Error(
708
+ "Invalid response from relayer: unexpected response type"
709
+ );
710
+ }
711
+ } else {
712
+ hash = await this.submitDirectRevokeTransaction(
600
713
  typedData,
601
714
  signature
602
715
  );
603
- } else {
604
- hash = await this.submitDirectRevokeTransaction(typedData, signature);
605
716
  }
606
- const account = this.context.walletClient.account || await this.getUserAddress();
717
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
607
718
  const { tx } = await import("../utils/transactionHelpers");
608
719
  return tx({
609
720
  hash,
@@ -642,18 +753,35 @@ class PermissionsController {
642
753
  * const result = await txHandle.waitForEvents();
643
754
  * ```
644
755
  */
645
- async submitSignedUntrustServer(typedData, signature) {
756
+ async submitSignedUntrustServer(typedData, signature, _options) {
646
757
  try {
647
758
  let hash;
648
- if (this.context.relayerCallbacks?.submitUntrustServer) {
649
- hash = await this.context.relayerCallbacks.submitUntrustServer(
759
+ if (this.context.relayer) {
760
+ const response = await this.context.relayer({
761
+ type: "signed",
762
+ operation: "submitUntrustServer",
763
+ typedData,
764
+ signature,
765
+ expectedUserAddress: this.context.userAddress
766
+ });
767
+ if (response.type === "submitted") {
768
+ hash = response.hash;
769
+ } else if (response.type === "signed") {
770
+ hash = response.hash;
771
+ } else if (response.type === "error") {
772
+ throw new Error(`Relayer error: ${response.error}`);
773
+ } else {
774
+ throw new Error(
775
+ "Invalid response from relayer: expected signed transaction"
776
+ );
777
+ }
778
+ } else {
779
+ hash = await this.submitSignedUntrustTransaction(
650
780
  typedData,
651
781
  signature
652
782
  );
653
- } else {
654
- hash = await this.submitSignedUntrustTransaction(typedData, signature);
655
783
  }
656
- const account = this.context.walletClient.account || await this.getUserAddress();
784
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
657
785
  const { tx } = await import("../utils/transactionHelpers");
658
786
  return tx({
659
787
  hash,
@@ -683,8 +811,9 @@ class PermissionsController {
683
811
  * @returns Promise resolving to the transaction hash
684
812
  * @throws {BlockchainError} When contract submission fails
685
813
  */
686
- async submitDirectTransaction(typedData, signature) {
687
- const chainId = await this.context.walletClient.getChainId();
814
+ async submitDirectTransaction(typedData, signature, options) {
815
+ this.assertWallet();
816
+ const chainId = await this.context.publicClient.getChainId();
688
817
  const DataPortabilityPermissionsAddress = getContractAddress(
689
818
  chainId,
690
819
  "DataPortabilityPermissions"
@@ -704,17 +833,18 @@ class PermissionsController {
704
833
  console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
705
834
  console.debug(
706
835
  "\u{1F50D} Debug - Grant field length:",
707
- typedData.message.grant?.length || 0
836
+ typedData.message.grant?.length ?? 0
708
837
  );
709
838
  const formattedSignature = formatSignatureForContract(signature);
710
- const account = this.context.walletClient.account || await this.getUserAddress();
839
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
711
840
  const txHash = await this.context.walletClient.writeContract({
712
841
  address: DataPortabilityPermissionsAddress,
713
842
  abi: DataPortabilityPermissionsAbi,
714
843
  functionName: "addPermission",
715
844
  args: [permissionInput, formattedSignature],
716
845
  account,
717
- chain: this.context.walletClient.chain || null
846
+ chain: this.context.walletClient?.chain ?? null,
847
+ ...this.spreadTransactionOptions(options)
718
848
  });
719
849
  const { tx } = await import("../utils/transactionHelpers");
720
850
  return tx({
@@ -749,6 +879,7 @@ class PermissionsController {
749
879
  * ```
750
880
  */
751
881
  async revoke(params) {
882
+ this.assertWallet();
752
883
  const txResult = await this.submitPermissionRevoke(params);
753
884
  if (!this.context.waitForTransactionEvents) {
754
885
  throw new BlockchainError("waitForTransactionEvents not configured");
@@ -756,7 +887,9 @@ class PermissionsController {
756
887
  const result = await this.context.waitForTransactionEvents(txResult);
757
888
  const event = result.expectedEvents.PermissionRevoked;
758
889
  if (!event) {
759
- throw new BlockchainError("PermissionRevoked event not found in transaction");
890
+ throw new BlockchainError(
891
+ "PermissionRevoked event not found in transaction"
892
+ );
760
893
  }
761
894
  const receipt = await this.context.publicClient.getTransactionReceipt({
762
895
  hash: result.hash
@@ -775,6 +908,7 @@ class PermissionsController {
775
908
  * Use this when you want to handle transaction confirmation and event parsing separately.
776
909
  *
777
910
  * @param params - Parameters for revoking the permission
911
+ * @param options - Optional transaction options for gas parameters and timeout
778
912
  * @returns Promise resolving to the transaction hash when successfully submitted
779
913
  * @throws {BlockchainError} When revocation transaction fails
780
914
  * @throws {UserRejectedRequestError} When user rejects the transaction
@@ -787,12 +921,13 @@ class PermissionsController {
787
921
  * console.log(`Revocation submitted: ${txHash}`);
788
922
  * ```
789
923
  */
790
- async submitPermissionRevoke(params) {
924
+ async submitPermissionRevoke(params, options) {
925
+ this.assertWallet();
791
926
  try {
792
- if (!this.context.walletClient.chain?.id) {
927
+ if (!this.context.walletClient?.chain?.id) {
793
928
  throw new BlockchainError("Chain ID not available");
794
929
  }
795
- const chainId = await this.context.walletClient.getChainId();
930
+ const chainId = await this.context.publicClient.getChainId();
796
931
  const DataPortabilityPermissionsAddress = getContractAddress(
797
932
  chainId,
798
933
  "DataPortabilityPermissions"
@@ -800,14 +935,25 @@ class PermissionsController {
800
935
  const DataPortabilityPermissionsAbi = getAbi(
801
936
  "DataPortabilityPermissions"
802
937
  );
803
- const account = this.context.walletClient.account || await this.getUserAddress();
938
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
804
939
  const txHash = await this.context.walletClient.writeContract({
805
940
  address: DataPortabilityPermissionsAddress,
806
941
  abi: DataPortabilityPermissionsAbi,
807
942
  functionName: "revokePermission",
808
943
  args: [params.permissionId],
809
944
  account,
810
- chain: this.context.walletClient.chain || null
945
+ chain: this.context.walletClient?.chain ?? null,
946
+ ...options?.gas && { gas: options.gas },
947
+ ...options?.nonce && { nonce: options.nonce },
948
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
949
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
950
+ ...options.maxFeePerGas && {
951
+ maxFeePerGas: options.maxFeePerGas
952
+ },
953
+ ...options.maxPriorityFeePerGas && {
954
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
955
+ }
956
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
811
957
  });
812
958
  const { tx } = await import("../utils/transactionHelpers");
813
959
  return tx({
@@ -855,8 +1001,9 @@ class PermissionsController {
855
1001
  * ```
856
1002
  */
857
1003
  async submitRevokeWithSignature(params) {
1004
+ this.assertWallet();
858
1005
  try {
859
- if (!this.context.walletClient.chain?.id) {
1006
+ if (!this.context.walletClient?.chain?.id) {
860
1007
  throw new BlockchainError("Chain ID not available");
861
1008
  }
862
1009
  const nonce = await this.getPermissionsUserNonce();
@@ -877,15 +1024,32 @@ class PermissionsController {
877
1024
  };
878
1025
  const signature = await this.signTypedData(typedData);
879
1026
  let hash;
880
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
881
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
1027
+ if (this.context.relayer) {
1028
+ const response = await this.context.relayer({
1029
+ type: "signed",
1030
+ operation: "submitPermissionRevoke",
1031
+ typedData,
1032
+ signature,
1033
+ expectedUserAddress: this.context.userAddress
1034
+ });
1035
+ if (response.type === "submitted") {
1036
+ hash = response.hash;
1037
+ } else if (response.type === "signed") {
1038
+ hash = response.hash;
1039
+ } else if (response.type === "error") {
1040
+ throw new Error(`Relayer error: ${response.error}`);
1041
+ } else {
1042
+ throw new Error(
1043
+ "Invalid response from relayer: expected signed transaction"
1044
+ );
1045
+ }
1046
+ } else {
1047
+ hash = await this.submitDirectRevokeTransaction(
882
1048
  typedData,
883
1049
  signature
884
1050
  );
885
- } else {
886
- hash = await this.submitDirectRevokeTransaction(typedData, signature);
887
1051
  }
888
- const account = this.context.walletClient.account || await this.getUserAddress();
1052
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
889
1053
  const { tx } = await import("../utils/transactionHelpers");
890
1054
  return tx({
891
1055
  hash,
@@ -900,64 +1064,6 @@ class PermissionsController {
900
1064
  );
901
1065
  }
902
1066
  }
903
- /**
904
- * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
905
- *
906
- * Retrieves the user's current nonce from the DataPortabilityServers contract.
907
- * This method is deprecated in favor of more specific nonce methods.
908
- *
909
- * The nonce is used to prevent replay attacks in signed transactions and must
910
- * be incremented with each transaction to maintain security.
911
- *
912
- * @returns Promise resolving to the user's current nonce value as a bigint
913
- * @throws {Error} When wallet account is not available
914
- * @throws {Error} When chain ID is not available
915
- * @throws {NonceError} When reading nonce from contract fails
916
- * @private
917
- * @example
918
- * ```typescript
919
- * // Deprecated - use specific methods instead
920
- * const nonce = await this.getUserNonce();
921
- *
922
- * // Use these instead:
923
- * const permissionsNonce = await this.getPermissionsUserNonce();
924
- * const serversNonce = await this.getServersUserNonce();
925
- * ```
926
- */
927
- /**
928
- * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
929
- *
930
- * Retrieves the user's current nonce from the DataPortabilityServers contract.
931
- *
932
- * @remarks
933
- * This method is deprecated in favor of more specific nonce methods that target
934
- * the appropriate contract for the operation being performed.
935
- *
936
- * @returns Promise resolving to the user's current nonce as a bigint
937
- * @throws {NonceError} When retrieving the nonce fails
938
- */
939
- async getUserNonce() {
940
- try {
941
- const userAddress = await this.getUserAddress();
942
- const chainId = await this.context.walletClient.getChainId();
943
- const DataPortabilityServersAddress = getContractAddress(
944
- chainId,
945
- "DataPortabilityServers"
946
- );
947
- const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
948
- const nonce = await this.context.publicClient.readContract({
949
- address: DataPortabilityServersAddress,
950
- abi: DataPortabilityServersAbi,
951
- functionName: "userNonce",
952
- args: [userAddress]
953
- });
954
- return nonce;
955
- } catch (error) {
956
- throw new NonceError(
957
- `Failed to retrieve user nonce: ${error instanceof Error ? error.message : "Unknown error"}`
958
- );
959
- }
960
- }
961
1067
  /**
962
1068
  * Retrieves the user's current nonce from the DataPortabilityServers contract.
963
1069
  * This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
@@ -984,8 +1090,8 @@ class PermissionsController {
984
1090
  */
985
1091
  async getServersUserNonce() {
986
1092
  try {
987
- const userAddress = await this.getUserAddress();
988
- const chainId = await this.context.walletClient.getChainId();
1093
+ const userAddress = this.context.userAddress;
1094
+ const chainId = await this.context.publicClient.getChainId();
989
1095
  const DataPortabilityServersAddress = getContractAddress(
990
1096
  chainId,
991
1097
  "DataPortabilityServers"
@@ -1030,8 +1136,8 @@ class PermissionsController {
1030
1136
  */
1031
1137
  async getPermissionsUserNonce() {
1032
1138
  try {
1033
- const userAddress = await this.getUserAddress();
1034
- const chainId = await this.context.walletClient.getChainId();
1139
+ const userAddress = this.context.userAddress;
1140
+ const chainId = await this.context.publicClient.getChainId();
1035
1141
  const DataPortabilityPermissionsAddress = getContractAddress(
1036
1142
  chainId,
1037
1143
  "DataPortabilityPermissions"
@@ -1070,7 +1176,7 @@ class PermissionsController {
1070
1176
  "\u{1F50D} Debug - Composing permission message with grantUrl:",
1071
1177
  params.grantUrl
1072
1178
  );
1073
- const chainId = await this.context.walletClient.getChainId();
1179
+ const chainId = await this.context.publicClient.getChainId();
1074
1180
  const DataPortabilityGranteesAddress = getContractAddress(
1075
1181
  chainId,
1076
1182
  "DataPortabilityGrantees"
@@ -1179,7 +1285,7 @@ class PermissionsController {
1179
1285
  * @returns Promise resolving to the EIP-712 domain configuration
1180
1286
  */
1181
1287
  async getPermissionDomain() {
1182
- const chainId = await this.context.walletClient.getChainId();
1288
+ const chainId = await this.context.publicClient.getChainId();
1183
1289
  const DataPortabilityPermissionsAddress = getContractAddress(
1184
1290
  chainId,
1185
1291
  "DataPortabilityPermissions"
@@ -1198,8 +1304,9 @@ class PermissionsController {
1198
1304
  * @returns Promise resolving to the cryptographic signature
1199
1305
  */
1200
1306
  async signTypedData(typedData) {
1307
+ this.assertWallet();
1201
1308
  try {
1202
- const walletAddress = this.context.walletClient.account?.address || await this.getUserAddress();
1309
+ const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
1203
1310
  return await withSignatureCache(
1204
1311
  this.context.platform.cache,
1205
1312
  walletAddress,
@@ -1208,9 +1315,9 @@ class PermissionsController {
1208
1315
  const viemCompatibleTypedData = toViemTypedDataDefinition(typedData);
1209
1316
  return await this.context.walletClient.signTypedData({
1210
1317
  ...viemCompatibleTypedData,
1211
- // Non-null assertion is safe here because getUserAddress() above ensures account exists
1212
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1213
- account: this.context.walletClient.account
1318
+ // Use the account if available, otherwise use the wallet address
1319
+ // This follows the same pattern used throughout this file
1320
+ account: this.context.walletClient.account ?? walletAddress
1214
1321
  });
1215
1322
  }
1216
1323
  );
@@ -1225,17 +1332,10 @@ class PermissionsController {
1225
1332
  }
1226
1333
  }
1227
1334
  /**
1228
- * Gets the user's address from the wallet client.
1335
+ * Gets the user's address from the context.
1229
1336
  *
1230
- * @returns Promise resolving to the user's wallet address
1337
+ * @returns The user's address
1231
1338
  */
1232
- async getUserAddress() {
1233
- const addresses = await this.context.walletClient.getAddresses();
1234
- if (addresses.length === 0) {
1235
- throw new BlockchainError("No addresses available in wallet client");
1236
- }
1237
- return addresses[0];
1238
- }
1239
1339
  /**
1240
1340
  * Gets on-chain permission grant data without expensive off-chain resolution.
1241
1341
  *
@@ -1272,20 +1372,22 @@ class PermissionsController {
1272
1372
  * ```
1273
1373
  */
1274
1374
  async getUserPermissionGrantsOnChain(options = {}) {
1275
- const { limit = 50, subgraphUrl } = options;
1375
+ const { limit = 50, fetchAll = false, subgraphUrl } = options;
1376
+ const pageSize = fetchAll ? 100 : limit;
1377
+ const maxResults = fetchAll ? 1e4 : limit;
1276
1378
  try {
1277
- const userAddress = await this.getUserAddress();
1278
- const graphqlEndpoint = subgraphUrl || this.context.subgraphUrl;
1379
+ const userAddress = this.context.userAddress;
1380
+ const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
1279
1381
  if (!graphqlEndpoint) {
1280
1382
  throw new BlockchainError(
1281
1383
  "subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
1282
1384
  );
1283
1385
  }
1284
1386
  const query = `
1285
- query GetUserPermissions($userId: ID!) {
1387
+ query GetUserPermissions($userId: ID!, $first: Int!, $skip: Int!) {
1286
1388
  user(id: $userId) {
1287
1389
  id
1288
- permissions {
1390
+ permissions(first: $first, skip: $skip, orderBy: addedAtBlock, orderDirection: desc) {
1289
1391
  id
1290
1392
  grant
1291
1393
  nonce
@@ -1303,34 +1405,82 @@ class PermissionsController {
1303
1405
  }
1304
1406
  }
1305
1407
  `;
1306
- const response = await fetch(graphqlEndpoint, {
1307
- method: "POST",
1308
- headers: {
1309
- "Content-Type": "application/json"
1310
- },
1311
- body: JSON.stringify({
1312
- query,
1313
- variables: {
1314
- userId: userAddress.toLowerCase()
1408
+ const allPermissions = [];
1409
+ let currentOffset = 0;
1410
+ if (!fetchAll) {
1411
+ const response = await fetch(graphqlEndpoint, {
1412
+ method: "POST",
1413
+ headers: {
1414
+ "Content-Type": "application/json"
1415
+ },
1416
+ body: JSON.stringify({
1417
+ query,
1418
+ variables: {
1419
+ userId: userAddress.toLowerCase(),
1420
+ first: limit,
1421
+ skip: 0
1422
+ }
1423
+ })
1424
+ });
1425
+ if (!response.ok) {
1426
+ throw new BlockchainError(
1427
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1428
+ );
1429
+ }
1430
+ const result = await response.json();
1431
+ if (result.errors) {
1432
+ throw new BlockchainError(
1433
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1434
+ );
1435
+ }
1436
+ const userData = result.data?.user;
1437
+ if (!userData?.permissions?.length) {
1438
+ return [];
1439
+ }
1440
+ allPermissions.push(...userData.permissions);
1441
+ } else {
1442
+ while (allPermissions.length < maxResults) {
1443
+ const currentLimit = Math.min(
1444
+ pageSize,
1445
+ maxResults - allPermissions.length
1446
+ );
1447
+ const response = await fetch(graphqlEndpoint, {
1448
+ method: "POST",
1449
+ headers: {
1450
+ "Content-Type": "application/json"
1451
+ },
1452
+ body: JSON.stringify({
1453
+ query,
1454
+ variables: {
1455
+ userId: userAddress.toLowerCase(),
1456
+ first: currentLimit,
1457
+ skip: currentOffset
1458
+ }
1459
+ })
1460
+ });
1461
+ if (!response.ok) {
1462
+ throw new BlockchainError(
1463
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1464
+ );
1315
1465
  }
1316
- })
1317
- });
1318
- if (!response.ok) {
1319
- throw new BlockchainError(
1320
- `Subgraph request failed: ${response.status} ${response.statusText}`
1321
- );
1322
- }
1323
- const result = await response.json();
1324
- if (result.errors) {
1325
- throw new BlockchainError(
1326
- `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1327
- );
1328
- }
1329
- const userData = result.data?.user;
1330
- if (!userData || !userData.permissions?.length) {
1331
- return [];
1466
+ const result = await response.json();
1467
+ if (result.errors) {
1468
+ throw new BlockchainError(
1469
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1470
+ );
1471
+ }
1472
+ const userData = result.data?.user;
1473
+ if (!userData?.permissions?.length) {
1474
+ break;
1475
+ }
1476
+ allPermissions.push(...userData.permissions);
1477
+ if (userData.permissions.length < currentLimit) {
1478
+ break;
1479
+ }
1480
+ currentOffset += userData.permissions.length;
1481
+ }
1332
1482
  }
1333
- const onChainGrants = userData.permissions.slice(0, limit).map(
1483
+ const onChainGrants = allPermissions.map(
1334
1484
  (permission) => ({
1335
1485
  id: BigInt(permission.id),
1336
1486
  grantUrl: permission.grant,
@@ -1338,8 +1488,8 @@ class PermissionsController {
1338
1488
  nonce: BigInt(permission.nonce),
1339
1489
  startBlock: BigInt(permission.startBlock),
1340
1490
  addedAtBlock: BigInt(permission.addedAtBlock),
1341
- addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
1342
- transactionHash: permission.transactionHash || "",
1491
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
1492
+ transactionHash: permission.transactionHash ?? "",
1343
1493
  grantor: userAddress,
1344
1494
  grantee: permission.grantee,
1345
1495
  active: !permission.endBlock || BigInt(permission.endBlock) === 0n
@@ -1360,26 +1510,6 @@ class PermissionsController {
1360
1510
  );
1361
1511
  }
1362
1512
  }
1363
- /**
1364
- * Normalizes grant ID to hex format.
1365
- * Handles conversion from permission ID (bigint/number/string) to proper hex hash format.
1366
- *
1367
- * @param grantId - Permission ID or grant hash in various formats
1368
- * @returns Normalized hex hash
1369
- */
1370
- normalizeGrantId(grantId) {
1371
- if (typeof grantId === "string" && grantId.startsWith("0x") && grantId.length === 66) {
1372
- return grantId;
1373
- }
1374
- try {
1375
- const bigIntId = BigInt(grantId);
1376
- return `0x${bigIntId.toString(16).padStart(64, "0")}`;
1377
- } catch {
1378
- throw new Error(
1379
- `Invalid grant ID format: ${grantId}. Must be a permission ID (number/bigint/string) or a 32-byte hex hash.`
1380
- );
1381
- }
1382
- }
1383
1513
  /**
1384
1514
  * Registers a new server and immediately trusts it in the DataPortabilityServers contract.
1385
1515
  *
@@ -1388,7 +1518,6 @@ class PermissionsController {
1388
1518
  * Trusted servers can handle data export and portability requests from the user.
1389
1519
  *
1390
1520
  * @param params - Parameters for adding and trusting the server
1391
- * @param params.owner - Ethereum address that will own this server registration
1392
1521
  * @param params.serverAddress - Ethereum address of the server
1393
1522
  * @param params.serverUrl - HTTPS URL where the server can be reached
1394
1523
  * @param params.publicKey - Server's public key for encryption (hex string)
@@ -1415,6 +1544,7 @@ class PermissionsController {
1415
1544
  * ```
1416
1545
  */
1417
1546
  async addAndTrustServer(params) {
1547
+ this.assertWallet();
1418
1548
  try {
1419
1549
  const chainId = await this.context.walletClient.getChainId();
1420
1550
  const DataPortabilityServersAddress = getContractAddress(
@@ -1422,7 +1552,7 @@ class PermissionsController {
1422
1552
  "DataPortabilityServers"
1423
1553
  );
1424
1554
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1425
- const account = this.context.walletClient.account || await this.getUserAddress();
1555
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1426
1556
  const userAddress = typeof account === "string" ? account : account.address;
1427
1557
  const normalizedUserAddress = getAddress(userAddress);
1428
1558
  const normalizedServerAddress = getAddress(params.serverAddress);
@@ -1439,7 +1569,7 @@ class PermissionsController {
1439
1569
  }
1440
1570
  ],
1441
1571
  account,
1442
- chain: this.context.walletClient.chain || null
1572
+ chain: this.context.walletClient?.chain ?? null
1443
1573
  });
1444
1574
  const { tx } = await import("../utils/transactionHelpers");
1445
1575
  const txResult = tx({
@@ -1454,9 +1584,13 @@ class PermissionsController {
1454
1584
  const result = await this.context.waitForTransactionEvents(txResult);
1455
1585
  const event = result.expectedEvents.ServerTrusted;
1456
1586
  if (!event) {
1457
- throw new BlockchainError("ServerTrusted event not found in transaction");
1587
+ throw new BlockchainError(
1588
+ "ServerTrusted event not found in transaction"
1589
+ );
1458
1590
  }
1459
- const receipt = await this.context.publicClient.getTransactionReceipt({ hash: txHash });
1591
+ const receipt = await this.context.publicClient.getTransactionReceipt({
1592
+ hash: txHash
1593
+ });
1460
1594
  return {
1461
1595
  transactionHash: txHash,
1462
1596
  blockNumber: receipt.blockNumber,
@@ -1487,6 +1621,7 @@ class PermissionsController {
1487
1621
  * @deprecated Use addAndTrustServer instead
1488
1622
  */
1489
1623
  async submitTrustServer(params) {
1624
+ this.assertWallet();
1490
1625
  try {
1491
1626
  const chainId = await this.context.walletClient.getChainId();
1492
1627
  const DataPortabilityServersAddress = getContractAddress(
@@ -1494,14 +1629,14 @@ class PermissionsController {
1494
1629
  "DataPortabilityServers"
1495
1630
  );
1496
1631
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1497
- const account = this.context.walletClient.account || await this.getUserAddress();
1632
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1498
1633
  const txHash = await this.context.walletClient.writeContract({
1499
1634
  address: DataPortabilityServersAddress,
1500
1635
  abi: DataPortabilityServersAbi,
1501
1636
  functionName: "trustServer",
1502
1637
  args: [BigInt(params.serverId)],
1503
1638
  account,
1504
- chain: this.context.walletClient.chain || null
1639
+ chain: this.context.walletClient?.chain ?? null
1505
1640
  });
1506
1641
  const { tx } = await import("../utils/transactionHelpers");
1507
1642
  return tx({
@@ -1527,6 +1662,7 @@ class PermissionsController {
1527
1662
  * @returns Promise resolving to TransactionResult with ServerTrustResult event data
1528
1663
  */
1529
1664
  async submitAddAndTrustServerWithSignature(params) {
1665
+ this.assertWallet();
1530
1666
  try {
1531
1667
  const nonce = await this.getServersUserNonce();
1532
1668
  const serverAddress = getAddress(params.serverAddress);
@@ -1550,18 +1686,31 @@ class PermissionsController {
1550
1686
  const signature = await this.signTypedData(typedData);
1551
1687
  console.debug("\u{1F50D} Generated signature:", signature);
1552
1688
  let hash;
1553
- if (this.context.relayerCallbacks?.submitAddAndTrustServer) {
1554
- hash = await this.context.relayerCallbacks.submitAddAndTrustServer(
1689
+ if (this.context.relayer) {
1690
+ const request = {
1691
+ type: "signed",
1692
+ operation: "submitAddAndTrustServer",
1555
1693
  typedData,
1556
1694
  signature
1557
- );
1695
+ };
1696
+ const response = await this.context.relayer(request);
1697
+ if (response.type === "error") {
1698
+ throw new RelayerError(response.error);
1699
+ }
1700
+ if (response.type === "submitted") {
1701
+ hash = response.hash;
1702
+ } else if (response.type === "signed") {
1703
+ hash = response.hash;
1704
+ } else {
1705
+ throw new Error("Unexpected response type from relayer");
1706
+ }
1558
1707
  } else {
1559
1708
  hash = await this.submitAddAndTrustServerTransaction(
1560
1709
  addAndTrustServerInput,
1561
1710
  signature
1562
1711
  );
1563
1712
  }
1564
- const account = this.context.walletClient.account || await this.getUserAddress();
1713
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1565
1714
  const { tx } = await import("../utils/transactionHelpers");
1566
1715
  return tx({
1567
1716
  hash,
@@ -1598,6 +1747,7 @@ class PermissionsController {
1598
1747
  * @throws {BlockchainError} When trust operation fails for any other reason
1599
1748
  */
1600
1749
  async submitTrustServerWithSignature(params) {
1750
+ this.assertWallet();
1601
1751
  try {
1602
1752
  const nonce = await this.getServersUserNonce();
1603
1753
  const trustServerInput = {
@@ -1607,18 +1757,31 @@ class PermissionsController {
1607
1757
  const typedData = await this.composeTrustServerMessage(trustServerInput);
1608
1758
  const signature = await this.signTypedData(typedData);
1609
1759
  let hash;
1610
- if (this.context.relayerCallbacks?.submitTrustServer) {
1611
- hash = await this.context.relayerCallbacks.submitTrustServer(
1760
+ if (this.context.relayer) {
1761
+ const request = {
1762
+ type: "signed",
1763
+ operation: "submitTrustServer",
1612
1764
  typedData,
1613
1765
  signature
1614
- );
1766
+ };
1767
+ const response = await this.context.relayer(request);
1768
+ if (response.type === "error") {
1769
+ throw new RelayerError(response.error);
1770
+ }
1771
+ if (response.type === "submitted") {
1772
+ hash = response.hash;
1773
+ } else if (response.type === "signed") {
1774
+ hash = response.hash;
1775
+ } else {
1776
+ throw new Error("Unexpected response type from relayer");
1777
+ }
1615
1778
  } else {
1616
1779
  hash = await this.submitTrustServerTransaction(
1617
1780
  trustServerInput,
1618
1781
  signature
1619
1782
  );
1620
1783
  }
1621
- const account = this.context.walletClient.account || await this.getUserAddress();
1784
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1622
1785
  const { tx } = await import("../utils/transactionHelpers");
1623
1786
  return tx({
1624
1787
  hash,
@@ -1656,7 +1819,8 @@ class PermissionsController {
1656
1819
  * @returns Promise resolving to TransactionResult for transaction tracking
1657
1820
  * @throws {BlockchainError} When contract submission fails
1658
1821
  */
1659
- async submitDirectUntrustTransaction(params) {
1822
+ async submitDirectUntrustTransaction(params, options) {
1823
+ this.assertWallet();
1660
1824
  try {
1661
1825
  const chainId = await this.context.walletClient.getChainId();
1662
1826
  const DataPortabilityServersAddress = getContractAddress(
@@ -1664,14 +1828,25 @@ class PermissionsController {
1664
1828
  "DataPortabilityServers"
1665
1829
  );
1666
1830
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1667
- const account = this.context.walletClient.account || await this.getUserAddress();
1831
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1668
1832
  const txHash = await this.context.walletClient.writeContract({
1669
1833
  address: DataPortabilityServersAddress,
1670
1834
  abi: DataPortabilityServersAbi,
1671
1835
  functionName: "untrustServer",
1672
1836
  args: [BigInt(params.serverId)],
1673
1837
  account,
1674
- chain: this.context.walletClient.chain || null
1838
+ chain: this.context.walletClient?.chain ?? null,
1839
+ ...options?.gas && { gas: options.gas },
1840
+ ...options?.nonce && { nonce: options.nonce },
1841
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
1842
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
1843
+ ...options.maxFeePerGas && {
1844
+ maxFeePerGas: options.maxFeePerGas
1845
+ },
1846
+ ...options.maxPriorityFeePerGas && {
1847
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
1848
+ }
1849
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
1675
1850
  });
1676
1851
  const { tx } = await import("../utils/transactionHelpers");
1677
1852
  return tx({
@@ -1698,6 +1873,7 @@ class PermissionsController {
1698
1873
  *
1699
1874
  * @param params - Parameters for untrusting the server
1700
1875
  * @param params.serverId - The numeric ID of the server to untrust
1876
+ * @param options - Optional transaction options for gas parameters and timeout
1701
1877
  * @returns Promise resolving to transaction hash
1702
1878
  * @throws {Error} When wallet account is not available
1703
1879
  * @throws {NonceError} When retrieving user nonce fails
@@ -1718,13 +1894,17 @@ class PermissionsController {
1718
1894
  * console.log('Still trusting servers:', trustedServers);
1719
1895
  * ```
1720
1896
  */
1721
- async submitUntrustServer(params) {
1897
+ async submitUntrustServer(params, options) {
1898
+ this.assertWallet();
1722
1899
  const nonce = await this.getServersUserNonce();
1723
1900
  const untrustServerInput = {
1724
1901
  nonce,
1725
1902
  serverId: params.serverId
1726
1903
  };
1727
- return await this.submitDirectUntrustTransaction(untrustServerInput);
1904
+ return await this.submitDirectUntrustTransaction(
1905
+ untrustServerInput,
1906
+ options
1907
+ );
1728
1908
  }
1729
1909
  /**
1730
1910
  * Untrusts a server using a signature (gasless transaction).
@@ -1739,6 +1919,7 @@ class PermissionsController {
1739
1919
  * @throws {BlockchainError} When untrust transaction fails
1740
1920
  */
1741
1921
  async submitUntrustServerWithSignature(params) {
1922
+ this.assertWallet();
1742
1923
  try {
1743
1924
  const nonce = await this.getServersUserNonce();
1744
1925
  const untrustServerInput = {
@@ -1748,15 +1929,28 @@ class PermissionsController {
1748
1929
  const typedData = await this.composeUntrustServerMessage(untrustServerInput);
1749
1930
  const signature = await this.signTypedData(typedData);
1750
1931
  let hash;
1751
- if (this.context.relayerCallbacks?.submitUntrustServer) {
1752
- hash = await this.context.relayerCallbacks.submitUntrustServer(
1932
+ if (this.context.relayer) {
1933
+ const request = {
1934
+ type: "signed",
1935
+ operation: "submitUntrustServer",
1753
1936
  typedData,
1754
1937
  signature
1755
- );
1938
+ };
1939
+ const response = await this.context.relayer(request);
1940
+ if (response.type === "error") {
1941
+ throw new RelayerError(response.error);
1942
+ }
1943
+ if (response.type === "submitted") {
1944
+ hash = response.hash;
1945
+ } else if (response.type === "signed") {
1946
+ hash = response.hash;
1947
+ } else {
1948
+ throw new Error("Unexpected response type from relayer");
1949
+ }
1756
1950
  } else {
1757
1951
  hash = await this.submitSignedUntrustTransaction(typedData, signature);
1758
1952
  }
1759
- const account = this.context.walletClient.account || await this.getUserAddress();
1953
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1760
1954
  const { tx } = await import("../utils/transactionHelpers");
1761
1955
  return tx({
1762
1956
  hash,
@@ -1801,8 +1995,8 @@ class PermissionsController {
1801
1995
  */
1802
1996
  async getTrustedServers(userAddress) {
1803
1997
  try {
1804
- const user = userAddress || await this.getUserAddress();
1805
- const chainId = await this.context.walletClient.getChainId();
1998
+ const user = userAddress ?? this.context.userAddress;
1999
+ const chainId = await this.context.publicClient.getChainId();
1806
2000
  const DataPortabilityServersAddress = getContractAddress(
1807
2001
  chainId,
1808
2002
  "DataPortabilityServers"
@@ -1831,8 +2025,8 @@ class PermissionsController {
1831
2025
  */
1832
2026
  async getTrustedServersCount(userAddress) {
1833
2027
  try {
1834
- const user = userAddress || await this.getUserAddress();
1835
- const chainId = await this.context.walletClient.getChainId();
2028
+ const user = userAddress ?? this.context.userAddress;
2029
+ const chainId = await this.context.publicClient.getChainId();
1836
2030
  const DataPortabilityServersAddress = getContractAddress(
1837
2031
  chainId,
1838
2032
  "DataPortabilityServers"
@@ -1861,10 +2055,10 @@ class PermissionsController {
1861
2055
  */
1862
2056
  async getTrustedServersPaginated(options = {}) {
1863
2057
  try {
1864
- const user = options.userAddress || await this.getUserAddress();
1865
- const limit = options.limit || 50;
1866
- const offset = options.offset || 0;
1867
- const chainId = await this.context.walletClient.getChainId();
2058
+ const user = options.userAddress ?? this.context.userAddress;
2059
+ const limit = options.limit ?? 50;
2060
+ const offset = options.offset ?? 0;
2061
+ const chainId = await this.context.publicClient.getChainId();
1868
2062
  const DataPortabilityServersAddress = getContractAddress(
1869
2063
  chainId,
1870
2064
  "DataPortabilityServers"
@@ -2010,7 +2204,7 @@ class PermissionsController {
2010
2204
  };
2011
2205
  }
2012
2206
  try {
2013
- const chainId = await this.context.walletClient.getChainId();
2207
+ const chainId = await this.context.publicClient.getChainId();
2014
2208
  const DataPortabilityServersAddress = getContractAddress(
2015
2209
  chainId,
2016
2210
  "DataPortabilityServers"
@@ -2085,7 +2279,7 @@ class PermissionsController {
2085
2279
  */
2086
2280
  async checkServerTrustStatus(serverId, userAddress) {
2087
2281
  try {
2088
- const user = userAddress || await this.getUserAddress();
2282
+ const user = userAddress ?? this.context.userAddress;
2089
2283
  const trustedServers = await this.getTrustedServers(user);
2090
2284
  const trustIndex = trustedServers.findIndex(
2091
2285
  (server) => server === serverId
@@ -2175,7 +2369,7 @@ class PermissionsController {
2175
2369
  * @returns Promise resolving to the EIP-712 domain configuration
2176
2370
  */
2177
2371
  async getServersDomain() {
2178
- const chainId = await this.context.walletClient.getChainId();
2372
+ const chainId = await this.context.publicClient.getChainId();
2179
2373
  const DataPortabilityServersAddress = getContractAddress(
2180
2374
  chainId,
2181
2375
  "DataPortabilityServers"
@@ -2195,6 +2389,7 @@ class PermissionsController {
2195
2389
  * @returns Promise resolving to the transaction hash
2196
2390
  */
2197
2391
  async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
2392
+ this.assertWallet();
2198
2393
  const chainId = await this.context.walletClient.getChainId();
2199
2394
  const DataPortabilityServersAddress = getContractAddress(
2200
2395
  chainId,
@@ -2226,8 +2421,8 @@ class PermissionsController {
2226
2421
  },
2227
2422
  formattedSignature
2228
2423
  ],
2229
- account: this.context.walletClient.account || await this.getUserAddress(),
2230
- chain: this.context.walletClient.chain || null
2424
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2425
+ chain: this.context.walletClient?.chain ?? null
2231
2426
  });
2232
2427
  return txHash;
2233
2428
  }
@@ -2238,7 +2433,8 @@ class PermissionsController {
2238
2433
  * @param signature - The cryptographic signature for the transaction
2239
2434
  * @returns Promise resolving to the transaction hash
2240
2435
  */
2241
- async submitTrustServerTransaction(trustServerInput, signature) {
2436
+ async submitTrustServerTransaction(trustServerInput, signature, options) {
2437
+ this.assertWallet();
2242
2438
  const chainId = await this.context.walletClient.getChainId();
2243
2439
  const DataPortabilityServersAddress = getContractAddress(
2244
2440
  chainId,
@@ -2257,8 +2453,9 @@ class PermissionsController {
2257
2453
  },
2258
2454
  formattedSignature
2259
2455
  ],
2260
- account: this.context.walletClient.account || await this.getUserAddress(),
2261
- chain: this.context.walletClient.chain || null
2456
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2457
+ chain: this.context.walletClient?.chain ?? null,
2458
+ ...this.spreadTransactionOptions(options)
2262
2459
  });
2263
2460
  return txHash;
2264
2461
  }
@@ -2270,6 +2467,7 @@ class PermissionsController {
2270
2467
  * @returns Promise resolving to the transaction hash
2271
2468
  */
2272
2469
  async submitDirectRevokeTransaction(typedData, signature) {
2470
+ this.assertWallet();
2273
2471
  const chainId = await this.context.walletClient.getChainId();
2274
2472
  const DataPortabilityPermissionsAddress = getContractAddress(
2275
2473
  chainId,
@@ -2281,10 +2479,9 @@ class PermissionsController {
2281
2479
  address: DataPortabilityPermissionsAddress,
2282
2480
  abi: DataPortabilityPermissionsAbi,
2283
2481
  functionName: "revokePermissionWithSignature",
2284
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2285
2482
  args: [typedData.message, formattedSignature],
2286
- account: this.context.walletClient.account || await this.getUserAddress(),
2287
- chain: this.context.walletClient.chain || null
2483
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2484
+ chain: this.context.walletClient?.chain ?? null
2288
2485
  });
2289
2486
  return txHash;
2290
2487
  }
@@ -2295,7 +2492,8 @@ class PermissionsController {
2295
2492
  * @param signature - The cryptographic signature authorizing the untrust
2296
2493
  * @returns Promise resolving to the transaction hash
2297
2494
  */
2298
- async submitSignedUntrustTransaction(typedData, signature) {
2495
+ async submitSignedUntrustTransaction(typedData, signature, _options) {
2496
+ this.assertWallet();
2299
2497
  const chainId = await this.context.walletClient.getChainId();
2300
2498
  const DataPortabilityServersAddress = getContractAddress(
2301
2499
  chainId,
@@ -2303,14 +2501,17 @@ class PermissionsController {
2303
2501
  );
2304
2502
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2305
2503
  const formattedSignature = formatSignatureForContract(signature);
2504
+ const contractMessage = {
2505
+ nonce: typedData.message.nonce,
2506
+ serverId: BigInt(typedData.message.serverId)
2507
+ };
2306
2508
  const txHash = await this.context.walletClient.writeContract({
2307
2509
  address: DataPortabilityServersAddress,
2308
2510
  abi: DataPortabilityServersAbi,
2309
2511
  functionName: "untrustServerWithSignature",
2310
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2311
- args: [typedData.message, formattedSignature],
2312
- account: this.context.walletClient.account || await this.getUserAddress(),
2313
- chain: this.context.walletClient.chain || null
2512
+ args: [contractMessage, formattedSignature],
2513
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2514
+ chain: this.context.walletClient?.chain ?? null
2314
2515
  });
2315
2516
  return txHash;
2316
2517
  }
@@ -2323,14 +2524,18 @@ class PermissionsController {
2323
2524
  * A grantee is an entity (like an application) that can receive data permissions
2324
2525
  * from users. Once registered, users can grant the grantee access to their data.
2325
2526
  *
2527
+ * This method supports gasless transactions via relayer when configured.
2528
+ * If no relayer is available, it falls back to direct wallet transactions.
2529
+ *
2326
2530
  * @param params - Parameters for registering the grantee
2327
2531
  * @param params.owner - The Ethereum address that will own this grantee registration
2328
2532
  * @param params.granteeAddress - The Ethereum address of the grantee (application)
2329
2533
  * @param params.publicKey - The public key used for data encryption/decryption (hex string)
2534
+ * @param options - Optional transaction options for gas parameters and timeout
2330
2535
  * @returns Promise resolving to the transaction hash
2331
2536
  * @throws {BlockchainError} When the grantee registration transaction fails
2332
2537
  * @throws {UserRejectedRequestError} When user rejects the transaction
2333
- * @throws {ContractError} When grantee is already registered
2538
+ * @throws {RelayerError} When gasless transaction submission fails
2334
2539
  *
2335
2540
  * @example
2336
2541
  * ```typescript
@@ -2342,98 +2547,88 @@ class PermissionsController {
2342
2547
  * console.log(`Grantee registered in transaction: ${txHash}`);
2343
2548
  * ```
2344
2549
  */
2345
- async submitRegisterGrantee(params) {
2346
- const chainId = await this.context.walletClient.getChainId();
2347
- const DataPortabilityGranteesAddress = getContractAddress(
2348
- chainId,
2349
- "DataPortabilityGrantees"
2350
- );
2351
- const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2352
- const ownerAddress = getAddress(params.owner);
2353
- const granteeAddress = getAddress(params.granteeAddress);
2354
- const account = this.context.walletClient.account || await this.getUserAddress();
2355
- const txHash = await this.context.walletClient.writeContract({
2356
- address: DataPortabilityGranteesAddress,
2357
- abi: DataPortabilityGranteesAbi,
2358
- functionName: "registerGrantee",
2359
- args: [ownerAddress, granteeAddress, params.publicKey],
2360
- account,
2361
- chain: this.context.walletClient.chain || null
2362
- });
2363
- const { tx } = await import("../utils/transactionHelpers");
2364
- return tx({
2365
- hash: txHash,
2366
- from: typeof account === "string" ? account : account.address,
2367
- contract: "DataPortabilityGrantees",
2368
- fn: "registerGrantee"
2369
- });
2370
- }
2371
- /**
2372
- * Registers a grantee with a signature (gasless transaction)
2373
- *
2374
- * @param params - Parameters for registering the grantee
2375
- * @returns Promise resolving to the transaction hash
2376
- *
2377
- * @example
2378
- * ```typescript
2379
- * const txHash = await vana.permissions.registerGranteeWithSignature({
2380
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2381
- * granteeAddress: "0xApp1234567890123456789012345678901234567890",
2382
- * publicKey: "0x1234567890abcdef..."
2383
- * });
2384
- * ```
2385
- */
2386
- async submitRegisterGranteeWithSignature(params) {
2387
- const nonce = await this.getServersUserNonce();
2388
- const owner = getAddress(params.owner);
2389
- const granteeAddress = getAddress(params.granteeAddress);
2390
- const registerGranteeInput = {
2391
- nonce,
2392
- owner,
2393
- granteeAddress,
2394
- publicKey: params.publicKey
2395
- };
2396
- const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
2397
- const signature = await this.signTypedData(typedData);
2398
- const hash = await this.submitSignedRegisterGranteeTransaction(
2399
- typedData,
2400
- signature
2401
- );
2402
- const account = this.context.walletClient.account || await this.getUserAddress();
2403
- const { tx } = await import("../utils/transactionHelpers");
2404
- return tx({
2405
- hash,
2406
- from: typeof account === "string" ? account : account.address,
2407
- contract: "DataPortabilityGrantees",
2408
- fn: "registerGrantee"
2409
- });
2410
- }
2411
- /**
2412
- * Submits a signed register grantee transaction via relayer
2413
- *
2414
- * @param typedData - The EIP-712 typed data for register grantee
2415
- * @param signature - The cryptographic signature
2416
- * @returns Promise resolving to the transaction hash
2417
- *
2418
- * @example
2419
- * ```typescript
2420
- * const result = await vana.permissions.submitSignedRegisterGrantee(typedData, signature);
2421
- * ```
2422
- */
2423
- async submitSignedRegisterGrantee(typedData, signature) {
2424
- const hash = await this.submitSignedRegisterGranteeTransaction(
2425
- typedData,
2426
- signature
2427
- );
2428
- const account = this.context.walletClient.account || await this.getUserAddress();
2429
- const { tx } = await import("../utils/transactionHelpers");
2430
- return tx({
2431
- hash,
2432
- from: typeof account === "string" ? account : account.address,
2433
- contract: "DataPortabilityGrantees",
2434
- fn: "registerGrantee"
2435
- });
2550
+ async submitRegisterGrantee(params, options) {
2551
+ try {
2552
+ let hash;
2553
+ if (this.context.relayer) {
2554
+ const request = {
2555
+ type: "direct",
2556
+ operation: "submitRegisterGrantee",
2557
+ params: {
2558
+ owner: params.owner,
2559
+ granteeAddress: params.granteeAddress,
2560
+ publicKey: params.publicKey
2561
+ }
2562
+ };
2563
+ const response = await this.context.relayer(request);
2564
+ if (response.type === "error") {
2565
+ throw new RelayerError(response.error);
2566
+ }
2567
+ if (response.type === "submitted") {
2568
+ hash = response.hash;
2569
+ } else if (response.type === "direct") {
2570
+ const result = response.result;
2571
+ hash = result.transactionHash;
2572
+ } else {
2573
+ throw new Error("Unexpected response type from relayer");
2574
+ }
2575
+ } else {
2576
+ this.assertWallet();
2577
+ const chainId = await this.context.walletClient.getChainId();
2578
+ const DataPortabilityGranteesAddress = getContractAddress(
2579
+ chainId,
2580
+ "DataPortabilityGrantees"
2581
+ );
2582
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2583
+ const ownerAddress = getAddress(params.owner);
2584
+ const granteeAddress = getAddress(params.granteeAddress);
2585
+ const account2 = this.context.walletClient?.account ?? this.context.userAddress;
2586
+ hash = await this.context.walletClient.writeContract({
2587
+ address: DataPortabilityGranteesAddress,
2588
+ abi: DataPortabilityGranteesAbi,
2589
+ functionName: "registerGrantee",
2590
+ args: [ownerAddress, granteeAddress, params.publicKey],
2591
+ account: account2,
2592
+ chain: this.context.walletClient?.chain ?? null,
2593
+ ...this.spreadTransactionOptions(options)
2594
+ });
2595
+ }
2596
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
2597
+ const { tx } = await import("../utils/transactionHelpers");
2598
+ return tx({
2599
+ hash,
2600
+ from: typeof account === "string" ? account : account.address,
2601
+ contract: "DataPortabilityGrantees",
2602
+ fn: "registerGrantee"
2603
+ });
2604
+ } catch (error) {
2605
+ if (error instanceof Error) {
2606
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof BlockchainError) {
2607
+ throw error;
2608
+ }
2609
+ if (error.name === "ContractFunctionExecutionError") {
2610
+ throw new BlockchainError(
2611
+ `Grantee registration failed: ${error.message}`,
2612
+ error
2613
+ );
2614
+ }
2615
+ if (error.name === "UserRejectedRequestError") {
2616
+ throw new UserRejectedRequestError(
2617
+ "User rejected the grantee registration transaction"
2618
+ );
2619
+ }
2620
+ throw new BlockchainError(
2621
+ `Failed to register grantee: ${error.message}`,
2622
+ error
2623
+ );
2624
+ }
2625
+ throw new BlockchainError(`Failed to register grantee: ${String(error)}`);
2626
+ }
2436
2627
  }
2628
+ // TODO: When DataPortabilityGrantees contract adds registerGranteeWithSignature function,
2629
+ // implement submitRegisterGranteeWithSignature and submitSignedRegisterGrantee methods
2630
+ // to support EIP-712 signed gasless transactions via relayer.
2631
+ // Current implementation above supports direct gasless transactions (relayer pays gas directly).
2437
2632
  /**
2438
2633
  * Retrieves all registered grantees from the DataPortabilityGrantees contract.
2439
2634
  *
@@ -2479,8 +2674,8 @@ class PermissionsController {
2479
2674
  functionName: "granteesCount"
2480
2675
  });
2481
2676
  const total = Number(totalCount);
2482
- const limit = options.limit || 50;
2483
- const offset = options.offset || 0;
2677
+ const limit = options.limit ?? 50;
2678
+ const offset = options.offset ?? 0;
2484
2679
  const grantees = [];
2485
2680
  const endIndex = Math.min(offset + limit, total);
2486
2681
  for (let i = offset; i < endIndex; i++) {
@@ -2620,67 +2815,6 @@ class PermissionsController {
2620
2815
  return null;
2621
2816
  }
2622
2817
  }
2623
- /**
2624
- * Builds EIP-712 typed data for grantee registration
2625
- *
2626
- * @param input - The register grantee input
2627
- * @returns Promise resolving to the typed data structure
2628
- * @private
2629
- */
2630
- async buildRegisterGranteeTypedData(input) {
2631
- const chainId = await this.context.walletClient.getChainId();
2632
- const verifyingContract = getContractAddress(
2633
- chainId,
2634
- "DataPortabilityGrantees"
2635
- );
2636
- return {
2637
- domain: {
2638
- name: "DataPortabilityGrantees",
2639
- version: "1",
2640
- chainId,
2641
- verifyingContract
2642
- },
2643
- types: {
2644
- RegisterGrantee: [
2645
- { name: "nonce", type: "uint256" },
2646
- { name: "owner", type: "address" },
2647
- { name: "granteeAddress", type: "address" },
2648
- { name: "publicKey", type: "string" }
2649
- ]
2650
- },
2651
- primaryType: "RegisterGrantee",
2652
- message: input
2653
- };
2654
- }
2655
- /**
2656
- * Submits a register grantee transaction with signature.
2657
- *
2658
- * @param typedData - The EIP-712 typed data structure for the registration
2659
- * @param _signature - The cryptographic signature authorizing the registration (currently unused)
2660
- * @returns Promise resolving to the transaction hash
2661
- * @private
2662
- */
2663
- async submitSignedRegisterGranteeTransaction(typedData, _signature) {
2664
- const chainId = await this.context.walletClient.getChainId();
2665
- const DataPortabilityGranteesAddress = getContractAddress(
2666
- chainId,
2667
- "DataPortabilityGrantees"
2668
- );
2669
- const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2670
- const txHash = await this.context.walletClient.writeContract({
2671
- address: DataPortabilityGranteesAddress,
2672
- abi: DataPortabilityGranteesAbi,
2673
- functionName: "registerGrantee",
2674
- args: [
2675
- typedData.message.owner,
2676
- typedData.message.granteeAddress,
2677
- typedData.message.publicKey
2678
- ],
2679
- account: this.context.walletClient.account || await this.getUserAddress(),
2680
- chain: this.context.walletClient.chain || null
2681
- });
2682
- return txHash;
2683
- }
2684
2818
  // ===========================
2685
2819
  // DATA PORTABILITY SERVERS HELPER METHODS
2686
2820
  // ===========================
@@ -2692,7 +2826,7 @@ class PermissionsController {
2692
2826
  */
2693
2827
  async getUserServerIds(userAddress) {
2694
2828
  try {
2695
- const targetAddress = userAddress || await this.getUserAddress();
2829
+ const targetAddress = userAddress ?? this.context.userAddress;
2696
2830
  const chainId = await this.context.publicClient.getChainId();
2697
2831
  const DataPortabilityServersAddress = getContractAddress(
2698
2832
  chainId,
@@ -2750,7 +2884,7 @@ class PermissionsController {
2750
2884
  */
2751
2885
  async getUserServerCount(userAddress) {
2752
2886
  try {
2753
- const targetAddress = userAddress || await this.getUserAddress();
2887
+ const targetAddress = userAddress ?? this.context.userAddress;
2754
2888
  const chainId = await this.context.publicClient.getChainId();
2755
2889
  const DataPortabilityServersAddress = getContractAddress(
2756
2890
  chainId,
@@ -2779,7 +2913,7 @@ class PermissionsController {
2779
2913
  */
2780
2914
  async getUserTrustedServers(userAddress) {
2781
2915
  try {
2782
- const targetAddress = userAddress || await this.getUserAddress();
2916
+ const targetAddress = userAddress ?? this.context.userAddress;
2783
2917
  const chainId = await this.context.publicClient.getChainId();
2784
2918
  const DataPortabilityServersAddress = getContractAddress(
2785
2919
  chainId,
@@ -2896,7 +3030,7 @@ class PermissionsController {
2896
3030
  */
2897
3031
  async getUserPermissionIds(userAddress) {
2898
3032
  try {
2899
- const targetAddress = userAddress || await this.getUserAddress();
3033
+ const targetAddress = userAddress ?? this.context.userAddress;
2900
3034
  const chainId = await this.context.publicClient.getChainId();
2901
3035
  const DataPortabilityPermissionsAddress = getContractAddress(
2902
3036
  chainId,
@@ -2958,7 +3092,7 @@ class PermissionsController {
2958
3092
  */
2959
3093
  async getUserPermissionCount(userAddress) {
2960
3094
  try {
2961
- const targetAddress = userAddress || await this.getUserAddress();
3095
+ const targetAddress = userAddress ?? this.context.userAddress;
2962
3096
  const chainId = await this.context.publicClient.getChainId();
2963
3097
  const DataPortabilityPermissionsAddress = getContractAddress(
2964
3098
  chainId,
@@ -3400,9 +3534,11 @@ class PermissionsController {
3400
3534
  *
3401
3535
  * @param serverId - Server ID to update
3402
3536
  * @param url - New URL for the server
3537
+ * @param options - Optional transaction options for gas parameters and timeout
3403
3538
  * @returns Promise resolving to transaction hash
3404
3539
  */
3405
- async submitUpdateServer(serverId, url) {
3540
+ async submitUpdateServer(serverId, url, options) {
3541
+ this.assertWallet();
3406
3542
  try {
3407
3543
  const chainId = await this.context.walletClient.getChainId();
3408
3544
  const DataPortabilityServersAddress = getContractAddress(
@@ -3410,14 +3546,25 @@ class PermissionsController {
3410
3546
  "DataPortabilityServers"
3411
3547
  );
3412
3548
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3413
- const account = this.context.walletClient.account || await this.getUserAddress();
3549
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3414
3550
  const hash = await this.context.walletClient.writeContract({
3415
3551
  address: DataPortabilityServersAddress,
3416
3552
  abi: DataPortabilityServersAbi,
3417
3553
  functionName: "updateServer",
3418
3554
  args: [serverId, url],
3419
- chain: this.context.walletClient.chain,
3420
- account
3555
+ chain: this.context.walletClient?.chain,
3556
+ account,
3557
+ ...options?.gas && { gas: options.gas },
3558
+ ...options?.nonce && { nonce: options.nonce },
3559
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3560
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3561
+ ...options.maxFeePerGas && {
3562
+ maxFeePerGas: options.maxFeePerGas
3563
+ },
3564
+ ...options.maxPriorityFeePerGas && {
3565
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3566
+ }
3567
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3421
3568
  });
3422
3569
  const { tx } = await import("../utils/transactionHelpers");
3423
3570
  return tx({
@@ -3575,6 +3722,7 @@ class PermissionsController {
3575
3722
  * @throws {NetworkError} When network communication fails
3576
3723
  */
3577
3724
  async submitAddPermission(params) {
3725
+ this.assertWallet();
3578
3726
  try {
3579
3727
  const nonce = await this.getPermissionsUserNonce();
3580
3728
  const addPermissionInput = {
@@ -3612,21 +3760,36 @@ class PermissionsController {
3612
3760
  * @throws {BlockchainError} When permission addition fails
3613
3761
  * @throws {NetworkError} When network communication fails
3614
3762
  */
3615
- async submitSignedAddPermission(typedData, signature) {
3763
+ async submitSignedAddPermission(typedData, signature, options) {
3764
+ this.assertWallet();
3616
3765
  try {
3617
3766
  let hash;
3618
- if (this.context.relayerCallbacks?.submitAddPermission) {
3619
- hash = await this.context.relayerCallbacks.submitAddPermission(
3767
+ if (this.context.relayer) {
3768
+ const request = {
3769
+ type: "signed",
3770
+ operation: "submitAddPermission",
3620
3771
  typedData,
3621
3772
  signature
3622
- );
3773
+ };
3774
+ const response = await this.context.relayer(request);
3775
+ if (response.type === "error") {
3776
+ throw new RelayerError(response.error);
3777
+ }
3778
+ if (response.type === "submitted") {
3779
+ hash = response.hash;
3780
+ } else if (response.type === "signed") {
3781
+ hash = response.hash;
3782
+ } else {
3783
+ throw new Error("Unexpected response type from relayer");
3784
+ }
3623
3785
  } else {
3624
3786
  hash = await this.submitDirectAddPermissionTransaction(
3625
3787
  typedData,
3626
- signature
3788
+ signature,
3789
+ options
3627
3790
  );
3628
3791
  }
3629
- const account = this.context.walletClient.account || await this.getUserAddress();
3792
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3630
3793
  const { tx } = await import("../utils/transactionHelpers");
3631
3794
  return tx({
3632
3795
  hash,
@@ -3662,8 +3825,11 @@ class PermissionsController {
3662
3825
  * @param params.serverAddress - Server wallet address for decryption permissions
3663
3826
  * @param params.serverUrl - Server endpoint URL
3664
3827
  * @param params.serverPublicKey - Server's public key for encryption.
3665
- * Obtain via `vana.server.getIdentity(userAddress).public_key`.
3828
+ * Obtain via `vana.server.getIdentity(userAddress).publicKey`.
3666
3829
  * @param params.filePermissions - Nested array of permissions for each file
3830
+ * @param options - Optional transaction options for gas parameters and timeout.
3831
+ * Note: These options are only applied for direct blockchain transactions.
3832
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3667
3833
  * @returns TransactionResult with immediate hash access and optional event data
3668
3834
  * @throws {Error} When schemaIds array length doesn't match fileUrls array length
3669
3835
  * @throws {SchemaValidationError} When file data doesn't match the specified schema.
@@ -3677,6 +3843,7 @@ class PermissionsController {
3677
3843
  *
3678
3844
  * @example
3679
3845
  * ```typescript
3846
+ * // Submit with custom gas parameters and timeout
3680
3847
  * const result = await vana.permissions.submitAddServerFilesAndPermissions({
3681
3848
  * granteeId: BigInt(1),
3682
3849
  * grant: "ipfs://QmXxx...",
@@ -3684,17 +3851,25 @@ class PermissionsController {
3684
3851
  * schemaIds: [123], // LinkedIn profile schema ID
3685
3852
  * serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3686
3853
  * serverUrl: "https://server.example.com",
3687
- * serverPublicKey: serverInfo.public_key,
3854
+ * serverPublicKey: serverInfo.publicKey,
3688
3855
  * filePermissions: [[{
3689
3856
  * account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3690
3857
  * key: encryptedKey
3691
3858
  * }]]
3859
+ * }, {
3860
+ * maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
3861
+ * maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
3692
3862
  * });
3693
- * const events = await result.waitForEvents();
3694
- * console.log(`Permission ID: ${events.permissionId}`);
3863
+ *
3864
+ * // Wait for confirmation with custom timeout
3865
+ * const receipt = await vana.waitForTransactionReceipt(result, {
3866
+ * timeout: 180000 // 3 minutes
3867
+ * });
3868
+ * console.log(`Transaction confirmed: ${receipt.transactionHash}`);
3695
3869
  * ```
3696
3870
  */
3697
- async submitAddServerFilesAndPermissions(params) {
3871
+ async submitAddServerFilesAndPermissions(params, options) {
3872
+ this.assertWallet();
3698
3873
  try {
3699
3874
  if (params.schemaIds.length !== params.fileUrls.length) {
3700
3875
  throw new Error(
@@ -3719,7 +3894,8 @@ class PermissionsController {
3719
3894
  const signature = await this.signTypedData(typedData);
3720
3895
  return await this.submitSignedAddServerFilesAndPermissions(
3721
3896
  typedData,
3722
- signature
3897
+ signature,
3898
+ options
3723
3899
  );
3724
3900
  } catch (error) {
3725
3901
  if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
@@ -3740,6 +3916,9 @@ class PermissionsController {
3740
3916
  *
3741
3917
  * @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
3742
3918
  * @param signature - The user's signature
3919
+ * @param options - Optional transaction options for gas parameters and timeout.
3920
+ * Note: These options are only applied for direct blockchain transactions.
3921
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3743
3922
  * @returns TransactionResult with immediate hash access and optional event data
3744
3923
  * @throws {RelayerError} When gasless transaction submission fails
3745
3924
  * @throws {BlockchainError} When server files and permissions addition fails
@@ -3758,46 +3937,49 @@ class PermissionsController {
3758
3937
  * console.log(`Permission created with ID: ${permissionId}`);
3759
3938
  * ```
3760
3939
  */
3761
- async submitSignedAddServerFilesAndPermissions(typedData, signature) {
3940
+ async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
3941
+ this.assertWallet();
3762
3942
  try {
3763
- console.debug("\u{1F50D} submitSignedAddServerFilesAndPermissions Debug Info:", {
3764
- hasRelayerCallbacks: !!this.context.relayerCallbacks,
3765
- hasSubmitMethod: !!this.context.relayerCallbacks?.submitAddServerFilesAndPermissions,
3766
- availableRelayerMethods: this.context.relayerCallbacks ? Object.keys(this.context.relayerCallbacks) : []
3767
- });
3768
- if (this.context.relayerCallbacks?.submitAddServerFilesAndPermissions) {
3943
+ let hash;
3944
+ if (this.context.relayer) {
3769
3945
  console.debug(
3770
3946
  "\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
3771
3947
  );
3772
- const hash = await this.context.relayerCallbacks.submitAddServerFilesAndPermissions(
3948
+ const request = {
3949
+ type: "signed",
3950
+ operation: "submitAddServerFilesAndPermissions",
3773
3951
  typedData,
3774
3952
  signature
3775
- );
3776
- const account = this.context.walletClient.account || await this.getUserAddress();
3777
- const { tx } = await import("../utils/transactionHelpers");
3778
- return tx({
3779
- hash,
3780
- from: typeof account === "string" ? account : account.address,
3781
- contract: "DataPortabilityPermissions",
3782
- fn: "addServerFilesAndPermissions"
3783
- });
3953
+ };
3954
+ const response = await this.context.relayer(request);
3955
+ if (response.type === "error") {
3956
+ throw new RelayerError(response.error);
3957
+ }
3958
+ if (response.type === "submitted") {
3959
+ hash = response.hash;
3960
+ } else if (response.type === "signed") {
3961
+ hash = response.hash;
3962
+ } else {
3963
+ throw new Error("Unexpected response type from relayer");
3964
+ }
3784
3965
  } else {
3785
3966
  console.debug(
3786
3967
  "\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
3787
3968
  );
3788
- const hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3969
+ hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3789
3970
  typedData,
3790
- signature
3971
+ signature,
3972
+ options
3791
3973
  );
3792
- const account = this.context.walletClient.account || await this.getUserAddress();
3793
- const { tx } = await import("../utils/transactionHelpers");
3794
- return tx({
3795
- hash,
3796
- from: typeof account === "string" ? account : account.address,
3797
- contract: "DataPortabilityPermissions",
3798
- fn: "addServerFilesAndPermissions"
3799
- });
3800
3974
  }
3975
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3976
+ const { tx } = await import("../utils/transactionHelpers");
3977
+ return tx({
3978
+ hash,
3979
+ from: typeof account === "string" ? account : account.address,
3980
+ contract: "DataPortabilityPermissions",
3981
+ fn: "addServerFilesAndPermissions"
3982
+ });
3801
3983
  } catch (error) {
3802
3984
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
3803
3985
  throw error;
@@ -3812,9 +3994,11 @@ class PermissionsController {
3812
3994
  * Submit permission revocation with signature to the blockchain
3813
3995
  *
3814
3996
  * @param permissionId - Permission ID to revoke
3997
+ * @param options - Optional transaction options for gas parameters and timeout
3815
3998
  * @returns Promise resolving to transaction hash
3816
3999
  */
3817
- async submitRevokePermission(permissionId) {
4000
+ async submitRevokePermission(permissionId, options) {
4001
+ this.assertWallet();
3818
4002
  try {
3819
4003
  const chainId = await this.context.walletClient.getChainId();
3820
4004
  const DataPortabilityPermissionsAddress = getContractAddress(
@@ -3824,7 +4008,7 @@ class PermissionsController {
3824
4008
  const DataPortabilityPermissionsAbi = getAbi(
3825
4009
  "DataPortabilityPermissions"
3826
4010
  );
3827
- const account = this.context.walletClient.account;
4011
+ const { account } = this.context.walletClient;
3828
4012
  if (!account) {
3829
4013
  throw new Error("No wallet account connected");
3830
4014
  }
@@ -3833,8 +4017,19 @@ class PermissionsController {
3833
4017
  abi: DataPortabilityPermissionsAbi,
3834
4018
  functionName: "revokePermission",
3835
4019
  args: [permissionId],
3836
- chain: this.context.walletClient.chain,
3837
- account
4020
+ chain: this.context.walletClient?.chain,
4021
+ account,
4022
+ ...options?.gas && { gas: options.gas },
4023
+ ...options?.nonce && { nonce: options.nonce },
4024
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
4025
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
4026
+ ...options.maxFeePerGas && {
4027
+ maxFeePerGas: options.maxFeePerGas
4028
+ },
4029
+ ...options.maxPriorityFeePerGas && {
4030
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
4031
+ }
4032
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3838
4033
  });
3839
4034
  const { tx } = await import("../utils/transactionHelpers");
3840
4035
  return tx({
@@ -3857,7 +4052,8 @@ class PermissionsController {
3857
4052
  * @param signature - The cryptographic signature authorizing the transaction
3858
4053
  * @returns Promise resolving to the transaction hash
3859
4054
  */
3860
- async submitDirectAddPermissionTransaction(typedData, signature) {
4055
+ async submitDirectAddPermissionTransaction(typedData, signature, options) {
4056
+ this.assertWallet();
3861
4057
  const chainId = await this.context.walletClient.getChainId();
3862
4058
  const DataPortabilityPermissionsAddress = getContractAddress(
3863
4059
  chainId,
@@ -3868,7 +4064,7 @@ class PermissionsController {
3868
4064
  nonce: typedData.message.nonce,
3869
4065
  granteeId: typedData.message.granteeId,
3870
4066
  grant: typedData.message.grant,
3871
- fileIds: typedData.message.fileIds || []
4067
+ fileIds: typedData.message.fileIds ?? []
3872
4068
  };
3873
4069
  const formattedSignature = formatSignatureForContract(signature);
3874
4070
  const hash = await this.context.walletClient.writeContract({
@@ -3876,8 +4072,9 @@ class PermissionsController {
3876
4072
  abi: DataPortabilityPermissionsAbi,
3877
4073
  functionName: "addPermission",
3878
4074
  args: [permissionInput, formattedSignature],
3879
- account: this.context.walletClient.account || await this.getUserAddress(),
3880
- chain: this.context.walletClient.chain || null
4075
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4076
+ chain: this.context.walletClient?.chain ?? null,
4077
+ ...this.spreadTransactionOptions(options)
3881
4078
  });
3882
4079
  return hash;
3883
4080
  }
@@ -3888,8 +4085,9 @@ class PermissionsController {
3888
4085
  * @param signature - The cryptographic signature authorizing the transaction
3889
4086
  * @returns Promise resolving to the transaction hash
3890
4087
  */
3891
- async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
3892
- const chainId = await this.context.walletClient.getChainId();
4088
+ async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
4089
+ this.assertWallet();
4090
+ const chainId = await this.context.publicClient.getChainId();
3893
4091
  const DataPortabilityPermissionsAddress = getContractAddress(
3894
4092
  chainId,
3895
4093
  "DataPortabilityPermissions"
@@ -3911,10 +4109,11 @@ class PermissionsController {
3911
4109
  address: DataPortabilityPermissionsAddress,
3912
4110
  abi: DataPortabilityPermissionsAbi,
3913
4111
  functionName: "addServerFilesAndPermissions",
3914
- // @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
3915
4112
  args: [serverFilesAndPermissionInput, formattedSignature],
3916
- account: this.context.walletClient.account || await this.getUserAddress(),
3917
- chain: this.context.walletClient.chain || null
4113
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4114
+ chain: this.context.walletClient?.chain ?? null,
4115
+ ...options?.value && { value: options.value },
4116
+ ...this.spreadTransactionOptions(options)
3918
4117
  });
3919
4118
  return hash;
3920
4119
  }