@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
@@ -41,9 +41,10 @@ var import_grantValidation = require("../utils/grantValidation");
41
41
  var import_signatureCache = require("../utils/signatureCache");
42
42
  var import_signatureFormatter = require("../utils/signatureFormatter");
43
43
  var import_typedDataConverter = require("../utils/typedDataConverter");
44
- class PermissionsController {
44
+ var import_base = require("./base");
45
+ class PermissionsController extends import_base.BaseController {
45
46
  constructor(context) {
46
- this.context = context;
47
+ super(context);
47
48
  }
48
49
  /**
49
50
  * Grants permission for an application to access user data with gasless transactions.
@@ -79,9 +80,14 @@ class PermissionsController {
79
80
  * await vana.permissions.revoke({ permissionId: result.permissionId });
80
81
  * ```
81
82
  */
82
- async grant(params) {
83
+ async grant(params, options) {
84
+ this.assertWallet();
83
85
  const { typedData, signature } = await this.createAndSign(params);
84
- const result = await this.submitSignedGrantWithEvents(typedData, signature);
86
+ const result = await this.submitSignedGrantWithEvents(
87
+ typedData,
88
+ signature,
89
+ options
90
+ );
85
91
  return result;
86
92
  }
87
93
  /**
@@ -109,9 +115,10 @@ class PermissionsController {
109
115
  * console.log(`Permission ID: ${eventData.permissionId}`);
110
116
  * ```
111
117
  */
112
- async submitPermissionGrant(params) {
118
+ async submitPermissionGrant(params, options) {
119
+ this.assertWallet();
113
120
  const { typedData, signature } = await this.createAndSign(params);
114
- return await this.submitSignedGrant(typedData, signature);
121
+ return await this.submitSignedGrant(typedData, signature, options);
115
122
  }
116
123
  /**
117
124
  * Prepares a permission grant with preview before signing.
@@ -138,14 +145,19 @@ class PermissionsController {
138
145
  * const transactionHash = await confirm();
139
146
  * ```
140
147
  */
141
- async prepareGrant(params) {
148
+ async prepareGrant(params, options) {
149
+ this.assertWallet();
142
150
  try {
143
151
  const grantFile = (0, import_grantFiles.createGrantFile)(params);
144
152
  (0, import_grantValidation.validateGrant)(grantFile);
145
153
  return {
146
154
  preview: grantFile,
147
155
  confirm: async () => {
148
- return await this.confirmGrantInternalWithEvents(params, grantFile);
156
+ return await this.confirmGrantInternalWithEvents(
157
+ params,
158
+ grantFile,
159
+ options
160
+ );
149
161
  }
150
162
  };
151
163
  } catch (error) {
@@ -177,22 +189,36 @@ class PermissionsController {
177
189
  * @throws {NetworkError} When IPFS upload fails
178
190
  * @throws {SignatureError} When user rejects the signature
179
191
  */
180
- async confirmGrantInternal(params, grantFile) {
192
+ async confirmGrantInternal(params, grantFile, options) {
181
193
  try {
182
- let grantUrl = params.grantUrl;
194
+ let { grantUrl } = params;
183
195
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
184
196
  if (!grantUrl) {
185
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
197
+ const canStoreViaRelayer = this.context.relayer !== void 0;
198
+ if (!canStoreViaRelayer && !this.context.storageManager) {
186
199
  if (this.context.validateStorageRequired) {
187
200
  this.context.validateStorageRequired();
188
201
  } else {
189
202
  throw new Error(
190
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
203
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
191
204
  );
192
205
  }
193
206
  }
194
- if (this.context.relayerCallbacks?.storeGrantFile) {
195
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
207
+ if (canStoreViaRelayer && this.context.relayer) {
208
+ const request = {
209
+ type: "direct",
210
+ operation: "storeGrantFile",
211
+ params: grantFile
212
+ };
213
+ const response = await this.context.relayer(request);
214
+ if (response.type === "error") {
215
+ throw new Error(response.error);
216
+ }
217
+ if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
218
+ grantUrl = response.result.url;
219
+ } else {
220
+ throw new Error("Invalid response from relayer for grant storage");
221
+ }
196
222
  } else if (this.context.storageManager) {
197
223
  const blob = new Blob([JSON.stringify(grantFile)], {
198
224
  type: "application/json"
@@ -224,7 +250,7 @@ class PermissionsController {
224
250
  nonce
225
251
  });
226
252
  const signature = await this.signTypedData(typedData);
227
- return await this.submitSignedGrant(typedData, signature);
253
+ return await this.submitSignedGrant(typedData, signature, options);
228
254
  } catch (error) {
229
255
  if (error instanceof Error) {
230
256
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
@@ -269,23 +295,38 @@ class PermissionsController {
269
295
  * ```
270
296
  */
271
297
  async createAndSign(params) {
298
+ this.assertWallet();
272
299
  try {
273
300
  const grantFile = (0, import_grantFiles.createGrantFile)(params);
274
301
  (0, import_grantValidation.validateGrant)(grantFile);
275
- let grantUrl = params.grantUrl;
302
+ let { grantUrl } = params;
276
303
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
277
304
  if (!grantUrl) {
278
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
305
+ const canStoreViaRelayer = this.context.relayer !== void 0;
306
+ if (!canStoreViaRelayer && !this.context.storageManager) {
279
307
  if (this.context.validateStorageRequired) {
280
308
  this.context.validateStorageRequired();
281
309
  } else {
282
310
  throw new Error(
283
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
311
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
284
312
  );
285
313
  }
286
314
  }
287
- if (this.context.relayerCallbacks?.storeGrantFile) {
288
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
315
+ if (canStoreViaRelayer && this.context.relayer) {
316
+ const request = {
317
+ type: "direct",
318
+ operation: "storeGrantFile",
319
+ params: grantFile
320
+ };
321
+ const response = await this.context.relayer(request);
322
+ if (response.type === "error") {
323
+ throw new Error(response.error);
324
+ }
325
+ if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
326
+ grantUrl = response.result.url;
327
+ } else {
328
+ throw new Error("Invalid response from relayer for grant storage");
329
+ }
289
330
  } else if (this.context.storageManager) {
290
331
  const blob = new Blob([JSON.stringify(grantFile)], {
291
332
  type: "application/json"
@@ -354,31 +395,58 @@ class PermissionsController {
354
395
  * );
355
396
  * ```
356
397
  */
357
- async submitSignedGrant(typedData, signature) {
398
+ async submitSignedGrant(typedData, signature, options) {
358
399
  try {
359
400
  console.debug(
360
401
  "\u{1F50D} Debug - submitSignedGrant called with typed data:",
361
402
  JSON.stringify(
362
403
  typedData,
363
- (key, value) => typeof value === "bigint" ? value.toString() : value,
404
+ (_key, value) => typeof value === "bigint" ? value.toString() : value,
364
405
  2
365
406
  )
366
407
  );
367
- if (this.context.relayerCallbacks?.submitPermissionGrant) {
368
- const hash = await this.context.relayerCallbacks.submitPermissionGrant(
408
+ if (this.context.relayer) {
409
+ const response = await this.context.relayer({
410
+ type: "signed",
411
+ operation: "submitAddPermission",
369
412
  typedData,
370
- signature
371
- );
372
- const account = this.context.walletClient.account || await this.getUserAddress();
413
+ signature,
414
+ expectedUserAddress: this.context.userAddress
415
+ });
416
+ if (response.type === "error") {
417
+ throw new Error(`Relayer error: ${response.error}`);
418
+ }
419
+ let finalHash;
420
+ if (response.type === "submitted") {
421
+ finalHash = response.hash;
422
+ } else if (response.type === "pending") {
423
+ const pollResult = await this.pollRelayerForConfirmation(
424
+ response.operationId
425
+ );
426
+ finalHash = pollResult.hash;
427
+ } else if (response.type === "confirmed") {
428
+ finalHash = response.hash;
429
+ } else if (response.type === "signed") {
430
+ finalHash = response.hash;
431
+ } else {
432
+ throw new Error(
433
+ "Invalid response from relayer: unexpected response type"
434
+ );
435
+ }
436
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
373
437
  const { tx } = await import("../utils/transactionHelpers");
374
438
  return tx({
375
- hash,
439
+ hash: finalHash,
376
440
  from: typeof account === "string" ? account : account.address,
377
441
  contract: "DataPortabilityPermissions",
378
442
  fn: "addPermission"
379
443
  });
380
444
  } else {
381
- return await this.submitDirectTransaction(typedData, signature);
445
+ return await this.submitDirectTransaction(
446
+ typedData,
447
+ signature,
448
+ options
449
+ );
382
450
  }
383
451
  } catch (error) {
384
452
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
@@ -411,7 +479,7 @@ class PermissionsController {
411
479
  * const result = await txHandle.waitForEvents();
412
480
  * ```
413
481
  */
414
- async submitSignedTrustServer(typedData, signature) {
482
+ async submitSignedTrustServer(typedData, signature, options) {
415
483
  try {
416
484
  const trustServerInput = {
417
485
  nonce: BigInt(typedData.message.nonce),
@@ -419,13 +487,14 @@ class PermissionsController {
419
487
  };
420
488
  const hash = await this.submitTrustServerTransaction(
421
489
  trustServerInput,
422
- signature
490
+ signature,
491
+ options
423
492
  );
424
- const account = this.context.walletClient.account || await this.getUserAddress();
493
+ const account = this.context.userAddress;
425
494
  const { tx } = await import("../utils/transactionHelpers");
426
495
  return tx({
427
496
  hash,
428
- from: typeof account === "string" ? account : account.address,
497
+ from: account,
429
498
  contract: "DataPortabilityServers",
430
499
  fn: "trustServerWithSignature"
431
500
  });
@@ -474,7 +543,7 @@ class PermissionsController {
474
543
  * const result = await txHandle.waitForEvents();
475
544
  * ```
476
545
  */
477
- async submitSignedAddAndTrustServer(typedData, signature) {
546
+ async submitSignedAddAndTrustServer(typedData, signature, _options) {
478
547
  try {
479
548
  const addAndTrustServerInput = {
480
549
  nonce: BigInt(typedData.message.nonce),
@@ -486,7 +555,7 @@ class PermissionsController {
486
555
  addAndTrustServerInput,
487
556
  signature
488
557
  );
489
- const account = this.context.walletClient.account || await this.getUserAddress();
558
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
490
559
  const { tx } = await import("../utils/transactionHelpers");
491
560
  return tx({
492
561
  hash,
@@ -506,21 +575,27 @@ class PermissionsController {
506
575
  }
507
576
  /**
508
577
  * Internal method to submit a signed grant and wait for events.
509
- *
578
+ *
510
579
  * @internal
511
580
  * @param typedData - The EIP-712 typed data for the permission grant
512
581
  * @param signature - The user's signature authorizing the transaction
513
582
  * @returns Promise resolving to PermissionGrantResult with parsed events
514
583
  */
515
- async submitSignedGrantWithEvents(typedData, signature) {
516
- const txResult = await this.submitSignedGrant(typedData, signature);
584
+ async submitSignedGrantWithEvents(typedData, signature, options) {
585
+ const txResult = await this.submitSignedGrant(
586
+ typedData,
587
+ signature,
588
+ options
589
+ );
517
590
  if (!this.context.waitForTransactionEvents) {
518
591
  throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
519
592
  }
520
593
  const result = await this.context.waitForTransactionEvents(txResult);
521
594
  const event = result.expectedEvents.PermissionAdded;
522
595
  if (!event) {
523
- throw new import_errors.BlockchainError("PermissionAdded event not found in transaction");
596
+ throw new import_errors.BlockchainError(
597
+ "PermissionAdded event not found in transaction"
598
+ );
524
599
  }
525
600
  const receipt = await this.context.publicClient.getTransactionReceipt({
526
601
  hash: result.hash
@@ -537,21 +612,27 @@ class PermissionsController {
537
612
  }
538
613
  /**
539
614
  * Internal method for confirm grant with events.
540
- *
615
+ *
541
616
  * @internal
542
617
  * @param params - The permission grant parameters
543
618
  * @param grantFile - The pre-created grant file object
544
619
  * @returns Promise resolving to PermissionGrantResult with parsed events
545
620
  */
546
- async confirmGrantInternalWithEvents(params, grantFile) {
547
- const txResult = await this.confirmGrantInternal(params, grantFile);
621
+ async confirmGrantInternalWithEvents(params, grantFile, options) {
622
+ const txResult = await this.confirmGrantInternal(
623
+ params,
624
+ grantFile,
625
+ options
626
+ );
548
627
  if (!this.context.waitForTransactionEvents) {
549
628
  throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
550
629
  }
551
630
  const result = await this.context.waitForTransactionEvents(txResult);
552
631
  const event = result.expectedEvents.PermissionAdded;
553
632
  if (!event) {
554
- throw new import_errors.BlockchainError("PermissionAdded event not found in transaction");
633
+ throw new import_errors.BlockchainError(
634
+ "PermissionAdded event not found in transaction"
635
+ );
555
636
  }
556
637
  const receipt = await this.context.publicClient.getTransactionReceipt({
557
638
  hash: result.hash
@@ -567,32 +648,37 @@ class PermissionsController {
567
648
  };
568
649
  }
569
650
  /**
570
- * Internal method to submit a signed revoke and wait for events.
571
- *
651
+ * Polls the relayer for confirmation of a pending operation.
652
+ *
653
+ * @param operationId - The operation ID to poll
654
+ * @returns Promise resolving to the confirmed hash
655
+ * @throws {Error} When the operation fails or times out
572
656
  * @internal
573
- * @param typedData - The EIP-712 typed data for the permission revoke
574
- * @param signature - The user's signature authorizing the transaction
575
- * @returns Promise resolving to PermissionRevokeResult with parsed events
576
657
  */
577
- async submitSignedRevokeWithEvents(typedData, signature) {
578
- const txResult = await this.submitSignedRevoke(typedData, signature);
579
- if (!this.context.waitForTransactionEvents) {
580
- throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
581
- }
582
- const result = await this.context.waitForTransactionEvents(txResult);
583
- const event = result.expectedEvents.PermissionRevoked;
584
- if (!event) {
585
- throw new import_errors.BlockchainError("PermissionRevoked event not found in transaction");
658
+ async pollRelayerForConfirmation(operationId, options = {}) {
659
+ const timeout = options.timeout ?? 3e4;
660
+ let interval = options.pollingInterval ?? 1e3;
661
+ const startTime = Date.now();
662
+ while (Date.now() - startTime < timeout) {
663
+ if (!this.context.relayer) {
664
+ throw new Error("Relayer not configured for polling");
665
+ }
666
+ const statusResponse = await this.context.relayer({
667
+ type: "status_check",
668
+ operationId
669
+ });
670
+ if (statusResponse.type === "confirmed") {
671
+ return { hash: statusResponse.hash };
672
+ }
673
+ if (statusResponse.type === "error") {
674
+ throw new Error(
675
+ `Operation ${operationId} failed: ${statusResponse.error}`
676
+ );
677
+ }
678
+ await new Promise((resolve) => setTimeout(resolve, interval));
679
+ interval = Math.min(interval * 1.5, 5e3);
586
680
  }
587
- const receipt = await this.context.publicClient.getTransactionReceipt({
588
- hash: result.hash
589
- });
590
- return {
591
- transactionHash: result.hash,
592
- blockNumber: receipt.blockNumber,
593
- gasUsed: receipt.gasUsed,
594
- permissionId: event.permissionId
595
- };
681
+ throw new Error(`Operation ${operationId} timed out after ${timeout}ms`);
596
682
  }
597
683
  /**
598
684
  * Submits an already-signed permission revoke transaction to the blockchain.
@@ -615,18 +701,43 @@ class PermissionsController {
615
701
  * const result = await txHandle.waitForEvents();
616
702
  * ```
617
703
  */
618
- async submitSignedRevoke(typedData, signature) {
704
+ async submitSignedRevoke(typedData, signature, _options) {
619
705
  try {
620
706
  let hash;
621
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
622
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
707
+ if (this.context.relayer) {
708
+ const response = await this.context.relayer({
709
+ type: "signed",
710
+ operation: "submitPermissionRevoke",
711
+ typedData,
712
+ signature,
713
+ expectedUserAddress: this.context.userAddress
714
+ });
715
+ if (response.type === "error") {
716
+ throw new Error(`Relayer error: ${response.error}`);
717
+ }
718
+ if (response.type === "submitted") {
719
+ hash = response.hash;
720
+ } else if (response.type === "pending") {
721
+ const pollResult = await this.pollRelayerForConfirmation(
722
+ response.operationId
723
+ );
724
+ hash = pollResult.hash;
725
+ } else if (response.type === "confirmed") {
726
+ hash = response.hash;
727
+ } else if (response.type === "signed") {
728
+ hash = response.hash;
729
+ } else {
730
+ throw new Error(
731
+ "Invalid response from relayer: unexpected response type"
732
+ );
733
+ }
734
+ } else {
735
+ hash = await this.submitDirectRevokeTransaction(
623
736
  typedData,
624
737
  signature
625
738
  );
626
- } else {
627
- hash = await this.submitDirectRevokeTransaction(typedData, signature);
628
739
  }
629
- const account = this.context.walletClient.account || await this.getUserAddress();
740
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
630
741
  const { tx } = await import("../utils/transactionHelpers");
631
742
  return tx({
632
743
  hash,
@@ -665,18 +776,35 @@ class PermissionsController {
665
776
  * const result = await txHandle.waitForEvents();
666
777
  * ```
667
778
  */
668
- async submitSignedUntrustServer(typedData, signature) {
779
+ async submitSignedUntrustServer(typedData, signature, _options) {
669
780
  try {
670
781
  let hash;
671
- if (this.context.relayerCallbacks?.submitUntrustServer) {
672
- hash = await this.context.relayerCallbacks.submitUntrustServer(
782
+ if (this.context.relayer) {
783
+ const response = await this.context.relayer({
784
+ type: "signed",
785
+ operation: "submitUntrustServer",
786
+ typedData,
787
+ signature,
788
+ expectedUserAddress: this.context.userAddress
789
+ });
790
+ if (response.type === "submitted") {
791
+ hash = response.hash;
792
+ } else if (response.type === "signed") {
793
+ hash = response.hash;
794
+ } else if (response.type === "error") {
795
+ throw new Error(`Relayer error: ${response.error}`);
796
+ } else {
797
+ throw new Error(
798
+ "Invalid response from relayer: expected signed transaction"
799
+ );
800
+ }
801
+ } else {
802
+ hash = await this.submitSignedUntrustTransaction(
673
803
  typedData,
674
804
  signature
675
805
  );
676
- } else {
677
- hash = await this.submitSignedUntrustTransaction(typedData, signature);
678
806
  }
679
- const account = this.context.walletClient.account || await this.getUserAddress();
807
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
680
808
  const { tx } = await import("../utils/transactionHelpers");
681
809
  return tx({
682
810
  hash,
@@ -706,8 +834,9 @@ class PermissionsController {
706
834
  * @returns Promise resolving to the transaction hash
707
835
  * @throws {BlockchainError} When contract submission fails
708
836
  */
709
- async submitDirectTransaction(typedData, signature) {
710
- const chainId = await this.context.walletClient.getChainId();
837
+ async submitDirectTransaction(typedData, signature, options) {
838
+ this.assertWallet();
839
+ const chainId = await this.context.publicClient.getChainId();
711
840
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
712
841
  chainId,
713
842
  "DataPortabilityPermissions"
@@ -727,17 +856,18 @@ class PermissionsController {
727
856
  console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
728
857
  console.debug(
729
858
  "\u{1F50D} Debug - Grant field length:",
730
- typedData.message.grant?.length || 0
859
+ typedData.message.grant?.length ?? 0
731
860
  );
732
861
  const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
733
- const account = this.context.walletClient.account || await this.getUserAddress();
862
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
734
863
  const txHash = await this.context.walletClient.writeContract({
735
864
  address: DataPortabilityPermissionsAddress,
736
865
  abi: DataPortabilityPermissionsAbi,
737
866
  functionName: "addPermission",
738
867
  args: [permissionInput, formattedSignature],
739
868
  account,
740
- chain: this.context.walletClient.chain || null
869
+ chain: this.context.walletClient?.chain ?? null,
870
+ ...this.spreadTransactionOptions(options)
741
871
  });
742
872
  const { tx } = await import("../utils/transactionHelpers");
743
873
  return tx({
@@ -772,6 +902,7 @@ class PermissionsController {
772
902
  * ```
773
903
  */
774
904
  async revoke(params) {
905
+ this.assertWallet();
775
906
  const txResult = await this.submitPermissionRevoke(params);
776
907
  if (!this.context.waitForTransactionEvents) {
777
908
  throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
@@ -779,7 +910,9 @@ class PermissionsController {
779
910
  const result = await this.context.waitForTransactionEvents(txResult);
780
911
  const event = result.expectedEvents.PermissionRevoked;
781
912
  if (!event) {
782
- throw new import_errors.BlockchainError("PermissionRevoked event not found in transaction");
913
+ throw new import_errors.BlockchainError(
914
+ "PermissionRevoked event not found in transaction"
915
+ );
783
916
  }
784
917
  const receipt = await this.context.publicClient.getTransactionReceipt({
785
918
  hash: result.hash
@@ -798,6 +931,7 @@ class PermissionsController {
798
931
  * Use this when you want to handle transaction confirmation and event parsing separately.
799
932
  *
800
933
  * @param params - Parameters for revoking the permission
934
+ * @param options - Optional transaction options for gas parameters and timeout
801
935
  * @returns Promise resolving to the transaction hash when successfully submitted
802
936
  * @throws {BlockchainError} When revocation transaction fails
803
937
  * @throws {UserRejectedRequestError} When user rejects the transaction
@@ -810,12 +944,13 @@ class PermissionsController {
810
944
  * console.log(`Revocation submitted: ${txHash}`);
811
945
  * ```
812
946
  */
813
- async submitPermissionRevoke(params) {
947
+ async submitPermissionRevoke(params, options) {
948
+ this.assertWallet();
814
949
  try {
815
- if (!this.context.walletClient.chain?.id) {
950
+ if (!this.context.walletClient?.chain?.id) {
816
951
  throw new import_errors.BlockchainError("Chain ID not available");
817
952
  }
818
- const chainId = await this.context.walletClient.getChainId();
953
+ const chainId = await this.context.publicClient.getChainId();
819
954
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
820
955
  chainId,
821
956
  "DataPortabilityPermissions"
@@ -823,14 +958,25 @@ class PermissionsController {
823
958
  const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
824
959
  "DataPortabilityPermissions"
825
960
  );
826
- const account = this.context.walletClient.account || await this.getUserAddress();
961
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
827
962
  const txHash = await this.context.walletClient.writeContract({
828
963
  address: DataPortabilityPermissionsAddress,
829
964
  abi: DataPortabilityPermissionsAbi,
830
965
  functionName: "revokePermission",
831
966
  args: [params.permissionId],
832
967
  account,
833
- chain: this.context.walletClient.chain || null
968
+ chain: this.context.walletClient?.chain ?? null,
969
+ ...options?.gas && { gas: options.gas },
970
+ ...options?.nonce && { nonce: options.nonce },
971
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
972
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
973
+ ...options.maxFeePerGas && {
974
+ maxFeePerGas: options.maxFeePerGas
975
+ },
976
+ ...options.maxPriorityFeePerGas && {
977
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
978
+ }
979
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
834
980
  });
835
981
  const { tx } = await import("../utils/transactionHelpers");
836
982
  return tx({
@@ -878,8 +1024,9 @@ class PermissionsController {
878
1024
  * ```
879
1025
  */
880
1026
  async submitRevokeWithSignature(params) {
1027
+ this.assertWallet();
881
1028
  try {
882
- if (!this.context.walletClient.chain?.id) {
1029
+ if (!this.context.walletClient?.chain?.id) {
883
1030
  throw new import_errors.BlockchainError("Chain ID not available");
884
1031
  }
885
1032
  const nonce = await this.getPermissionsUserNonce();
@@ -900,15 +1047,32 @@ class PermissionsController {
900
1047
  };
901
1048
  const signature = await this.signTypedData(typedData);
902
1049
  let hash;
903
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
904
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
1050
+ if (this.context.relayer) {
1051
+ const response = await this.context.relayer({
1052
+ type: "signed",
1053
+ operation: "submitPermissionRevoke",
1054
+ typedData,
1055
+ signature,
1056
+ expectedUserAddress: this.context.userAddress
1057
+ });
1058
+ if (response.type === "submitted") {
1059
+ hash = response.hash;
1060
+ } else if (response.type === "signed") {
1061
+ hash = response.hash;
1062
+ } else if (response.type === "error") {
1063
+ throw new Error(`Relayer error: ${response.error}`);
1064
+ } else {
1065
+ throw new Error(
1066
+ "Invalid response from relayer: expected signed transaction"
1067
+ );
1068
+ }
1069
+ } else {
1070
+ hash = await this.submitDirectRevokeTransaction(
905
1071
  typedData,
906
1072
  signature
907
1073
  );
908
- } else {
909
- hash = await this.submitDirectRevokeTransaction(typedData, signature);
910
1074
  }
911
- const account = this.context.walletClient.account || await this.getUserAddress();
1075
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
912
1076
  const { tx } = await import("../utils/transactionHelpers");
913
1077
  return tx({
914
1078
  hash,
@@ -923,64 +1087,6 @@ class PermissionsController {
923
1087
  );
924
1088
  }
925
1089
  }
926
- /**
927
- * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
928
- *
929
- * Retrieves the user's current nonce from the DataPortabilityServers contract.
930
- * This method is deprecated in favor of more specific nonce methods.
931
- *
932
- * The nonce is used to prevent replay attacks in signed transactions and must
933
- * be incremented with each transaction to maintain security.
934
- *
935
- * @returns Promise resolving to the user's current nonce value as a bigint
936
- * @throws {Error} When wallet account is not available
937
- * @throws {Error} When chain ID is not available
938
- * @throws {NonceError} When reading nonce from contract fails
939
- * @private
940
- * @example
941
- * ```typescript
942
- * // Deprecated - use specific methods instead
943
- * const nonce = await this.getUserNonce();
944
- *
945
- * // Use these instead:
946
- * const permissionsNonce = await this.getPermissionsUserNonce();
947
- * const serversNonce = await this.getServersUserNonce();
948
- * ```
949
- */
950
- /**
951
- * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
952
- *
953
- * Retrieves the user's current nonce from the DataPortabilityServers contract.
954
- *
955
- * @remarks
956
- * This method is deprecated in favor of more specific nonce methods that target
957
- * the appropriate contract for the operation being performed.
958
- *
959
- * @returns Promise resolving to the user's current nonce as a bigint
960
- * @throws {NonceError} When retrieving the nonce fails
961
- */
962
- async getUserNonce() {
963
- try {
964
- const userAddress = await this.getUserAddress();
965
- const chainId = await this.context.walletClient.getChainId();
966
- const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
967
- chainId,
968
- "DataPortabilityServers"
969
- );
970
- const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
971
- const nonce = await this.context.publicClient.readContract({
972
- address: DataPortabilityServersAddress,
973
- abi: DataPortabilityServersAbi,
974
- functionName: "userNonce",
975
- args: [userAddress]
976
- });
977
- return nonce;
978
- } catch (error) {
979
- throw new import_errors.NonceError(
980
- `Failed to retrieve user nonce: ${error instanceof Error ? error.message : "Unknown error"}`
981
- );
982
- }
983
- }
984
1090
  /**
985
1091
  * Retrieves the user's current nonce from the DataPortabilityServers contract.
986
1092
  * This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
@@ -1007,8 +1113,8 @@ class PermissionsController {
1007
1113
  */
1008
1114
  async getServersUserNonce() {
1009
1115
  try {
1010
- const userAddress = await this.getUserAddress();
1011
- const chainId = await this.context.walletClient.getChainId();
1116
+ const userAddress = this.context.userAddress;
1117
+ const chainId = await this.context.publicClient.getChainId();
1012
1118
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1013
1119
  chainId,
1014
1120
  "DataPortabilityServers"
@@ -1053,8 +1159,8 @@ class PermissionsController {
1053
1159
  */
1054
1160
  async getPermissionsUserNonce() {
1055
1161
  try {
1056
- const userAddress = await this.getUserAddress();
1057
- const chainId = await this.context.walletClient.getChainId();
1162
+ const userAddress = this.context.userAddress;
1163
+ const chainId = await this.context.publicClient.getChainId();
1058
1164
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
1059
1165
  chainId,
1060
1166
  "DataPortabilityPermissions"
@@ -1093,7 +1199,7 @@ class PermissionsController {
1093
1199
  "\u{1F50D} Debug - Composing permission message with grantUrl:",
1094
1200
  params.grantUrl
1095
1201
  );
1096
- const chainId = await this.context.walletClient.getChainId();
1202
+ const chainId = await this.context.publicClient.getChainId();
1097
1203
  const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
1098
1204
  chainId,
1099
1205
  "DataPortabilityGrantees"
@@ -1202,7 +1308,7 @@ class PermissionsController {
1202
1308
  * @returns Promise resolving to the EIP-712 domain configuration
1203
1309
  */
1204
1310
  async getPermissionDomain() {
1205
- const chainId = await this.context.walletClient.getChainId();
1311
+ const chainId = await this.context.publicClient.getChainId();
1206
1312
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
1207
1313
  chainId,
1208
1314
  "DataPortabilityPermissions"
@@ -1221,8 +1327,9 @@ class PermissionsController {
1221
1327
  * @returns Promise resolving to the cryptographic signature
1222
1328
  */
1223
1329
  async signTypedData(typedData) {
1330
+ this.assertWallet();
1224
1331
  try {
1225
- const walletAddress = this.context.walletClient.account?.address || await this.getUserAddress();
1332
+ const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
1226
1333
  return await (0, import_signatureCache.withSignatureCache)(
1227
1334
  this.context.platform.cache,
1228
1335
  walletAddress,
@@ -1231,9 +1338,9 @@ class PermissionsController {
1231
1338
  const viemCompatibleTypedData = (0, import_typedDataConverter.toViemTypedDataDefinition)(typedData);
1232
1339
  return await this.context.walletClient.signTypedData({
1233
1340
  ...viemCompatibleTypedData,
1234
- // Non-null assertion is safe here because getUserAddress() above ensures account exists
1235
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1236
- account: this.context.walletClient.account
1341
+ // Use the account if available, otherwise use the wallet address
1342
+ // This follows the same pattern used throughout this file
1343
+ account: this.context.walletClient.account ?? walletAddress
1237
1344
  });
1238
1345
  }
1239
1346
  );
@@ -1248,17 +1355,10 @@ class PermissionsController {
1248
1355
  }
1249
1356
  }
1250
1357
  /**
1251
- * Gets the user's address from the wallet client.
1358
+ * Gets the user's address from the context.
1252
1359
  *
1253
- * @returns Promise resolving to the user's wallet address
1360
+ * @returns The user's address
1254
1361
  */
1255
- async getUserAddress() {
1256
- const addresses = await this.context.walletClient.getAddresses();
1257
- if (addresses.length === 0) {
1258
- throw new import_errors.BlockchainError("No addresses available in wallet client");
1259
- }
1260
- return addresses[0];
1261
- }
1262
1362
  /**
1263
1363
  * Gets on-chain permission grant data without expensive off-chain resolution.
1264
1364
  *
@@ -1295,20 +1395,22 @@ class PermissionsController {
1295
1395
  * ```
1296
1396
  */
1297
1397
  async getUserPermissionGrantsOnChain(options = {}) {
1298
- const { limit = 50, subgraphUrl } = options;
1398
+ const { limit = 50, fetchAll = false, subgraphUrl } = options;
1399
+ const pageSize = fetchAll ? 100 : limit;
1400
+ const maxResults = fetchAll ? 1e4 : limit;
1299
1401
  try {
1300
- const userAddress = await this.getUserAddress();
1301
- const graphqlEndpoint = subgraphUrl || this.context.subgraphUrl;
1402
+ const userAddress = this.context.userAddress;
1403
+ const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
1302
1404
  if (!graphqlEndpoint) {
1303
1405
  throw new import_errors.BlockchainError(
1304
1406
  "subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
1305
1407
  );
1306
1408
  }
1307
1409
  const query = `
1308
- query GetUserPermissions($userId: ID!) {
1410
+ query GetUserPermissions($userId: ID!, $first: Int!, $skip: Int!) {
1309
1411
  user(id: $userId) {
1310
1412
  id
1311
- permissions {
1413
+ permissions(first: $first, skip: $skip, orderBy: addedAtBlock, orderDirection: desc) {
1312
1414
  id
1313
1415
  grant
1314
1416
  nonce
@@ -1326,34 +1428,82 @@ class PermissionsController {
1326
1428
  }
1327
1429
  }
1328
1430
  `;
1329
- const response = await fetch(graphqlEndpoint, {
1330
- method: "POST",
1331
- headers: {
1332
- "Content-Type": "application/json"
1333
- },
1334
- body: JSON.stringify({
1335
- query,
1336
- variables: {
1337
- userId: userAddress.toLowerCase()
1431
+ const allPermissions = [];
1432
+ let currentOffset = 0;
1433
+ if (!fetchAll) {
1434
+ const response = await fetch(graphqlEndpoint, {
1435
+ method: "POST",
1436
+ headers: {
1437
+ "Content-Type": "application/json"
1438
+ },
1439
+ body: JSON.stringify({
1440
+ query,
1441
+ variables: {
1442
+ userId: userAddress.toLowerCase(),
1443
+ first: limit,
1444
+ skip: 0
1445
+ }
1446
+ })
1447
+ });
1448
+ if (!response.ok) {
1449
+ throw new import_errors.BlockchainError(
1450
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1451
+ );
1452
+ }
1453
+ const result = await response.json();
1454
+ if (result.errors) {
1455
+ throw new import_errors.BlockchainError(
1456
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1457
+ );
1458
+ }
1459
+ const userData = result.data?.user;
1460
+ if (!userData?.permissions?.length) {
1461
+ return [];
1462
+ }
1463
+ allPermissions.push(...userData.permissions);
1464
+ } else {
1465
+ while (allPermissions.length < maxResults) {
1466
+ const currentLimit = Math.min(
1467
+ pageSize,
1468
+ maxResults - allPermissions.length
1469
+ );
1470
+ const response = await fetch(graphqlEndpoint, {
1471
+ method: "POST",
1472
+ headers: {
1473
+ "Content-Type": "application/json"
1474
+ },
1475
+ body: JSON.stringify({
1476
+ query,
1477
+ variables: {
1478
+ userId: userAddress.toLowerCase(),
1479
+ first: currentLimit,
1480
+ skip: currentOffset
1481
+ }
1482
+ })
1483
+ });
1484
+ if (!response.ok) {
1485
+ throw new import_errors.BlockchainError(
1486
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1487
+ );
1338
1488
  }
1339
- })
1340
- });
1341
- if (!response.ok) {
1342
- throw new import_errors.BlockchainError(
1343
- `Subgraph request failed: ${response.status} ${response.statusText}`
1344
- );
1345
- }
1346
- const result = await response.json();
1347
- if (result.errors) {
1348
- throw new import_errors.BlockchainError(
1349
- `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1350
- );
1351
- }
1352
- const userData = result.data?.user;
1353
- if (!userData || !userData.permissions?.length) {
1354
- return [];
1489
+ const result = await response.json();
1490
+ if (result.errors) {
1491
+ throw new import_errors.BlockchainError(
1492
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1493
+ );
1494
+ }
1495
+ const userData = result.data?.user;
1496
+ if (!userData?.permissions?.length) {
1497
+ break;
1498
+ }
1499
+ allPermissions.push(...userData.permissions);
1500
+ if (userData.permissions.length < currentLimit) {
1501
+ break;
1502
+ }
1503
+ currentOffset += userData.permissions.length;
1504
+ }
1355
1505
  }
1356
- const onChainGrants = userData.permissions.slice(0, limit).map(
1506
+ const onChainGrants = allPermissions.map(
1357
1507
  (permission) => ({
1358
1508
  id: BigInt(permission.id),
1359
1509
  grantUrl: permission.grant,
@@ -1361,8 +1511,8 @@ class PermissionsController {
1361
1511
  nonce: BigInt(permission.nonce),
1362
1512
  startBlock: BigInt(permission.startBlock),
1363
1513
  addedAtBlock: BigInt(permission.addedAtBlock),
1364
- addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
1365
- transactionHash: permission.transactionHash || "",
1514
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
1515
+ transactionHash: permission.transactionHash ?? "",
1366
1516
  grantor: userAddress,
1367
1517
  grantee: permission.grantee,
1368
1518
  active: !permission.endBlock || BigInt(permission.endBlock) === 0n
@@ -1383,26 +1533,6 @@ class PermissionsController {
1383
1533
  );
1384
1534
  }
1385
1535
  }
1386
- /**
1387
- * Normalizes grant ID to hex format.
1388
- * Handles conversion from permission ID (bigint/number/string) to proper hex hash format.
1389
- *
1390
- * @param grantId - Permission ID or grant hash in various formats
1391
- * @returns Normalized hex hash
1392
- */
1393
- normalizeGrantId(grantId) {
1394
- if (typeof grantId === "string" && grantId.startsWith("0x") && grantId.length === 66) {
1395
- return grantId;
1396
- }
1397
- try {
1398
- const bigIntId = BigInt(grantId);
1399
- return `0x${bigIntId.toString(16).padStart(64, "0")}`;
1400
- } catch {
1401
- throw new Error(
1402
- `Invalid grant ID format: ${grantId}. Must be a permission ID (number/bigint/string) or a 32-byte hex hash.`
1403
- );
1404
- }
1405
- }
1406
1536
  /**
1407
1537
  * Registers a new server and immediately trusts it in the DataPortabilityServers contract.
1408
1538
  *
@@ -1411,7 +1541,6 @@ class PermissionsController {
1411
1541
  * Trusted servers can handle data export and portability requests from the user.
1412
1542
  *
1413
1543
  * @param params - Parameters for adding and trusting the server
1414
- * @param params.owner - Ethereum address that will own this server registration
1415
1544
  * @param params.serverAddress - Ethereum address of the server
1416
1545
  * @param params.serverUrl - HTTPS URL where the server can be reached
1417
1546
  * @param params.publicKey - Server's public key for encryption (hex string)
@@ -1438,6 +1567,7 @@ class PermissionsController {
1438
1567
  * ```
1439
1568
  */
1440
1569
  async addAndTrustServer(params) {
1570
+ this.assertWallet();
1441
1571
  try {
1442
1572
  const chainId = await this.context.walletClient.getChainId();
1443
1573
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1445,7 +1575,7 @@ class PermissionsController {
1445
1575
  "DataPortabilityServers"
1446
1576
  );
1447
1577
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1448
- const account = this.context.walletClient.account || await this.getUserAddress();
1578
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1449
1579
  const userAddress = typeof account === "string" ? account : account.address;
1450
1580
  const normalizedUserAddress = (0, import_viem.getAddress)(userAddress);
1451
1581
  const normalizedServerAddress = (0, import_viem.getAddress)(params.serverAddress);
@@ -1462,7 +1592,7 @@ class PermissionsController {
1462
1592
  }
1463
1593
  ],
1464
1594
  account,
1465
- chain: this.context.walletClient.chain || null
1595
+ chain: this.context.walletClient?.chain ?? null
1466
1596
  });
1467
1597
  const { tx } = await import("../utils/transactionHelpers");
1468
1598
  const txResult = tx({
@@ -1477,9 +1607,13 @@ class PermissionsController {
1477
1607
  const result = await this.context.waitForTransactionEvents(txResult);
1478
1608
  const event = result.expectedEvents.ServerTrusted;
1479
1609
  if (!event) {
1480
- throw new import_errors.BlockchainError("ServerTrusted event not found in transaction");
1610
+ throw new import_errors.BlockchainError(
1611
+ "ServerTrusted event not found in transaction"
1612
+ );
1481
1613
  }
1482
- const receipt = await this.context.publicClient.getTransactionReceipt({ hash: txHash });
1614
+ const receipt = await this.context.publicClient.getTransactionReceipt({
1615
+ hash: txHash
1616
+ });
1483
1617
  return {
1484
1618
  transactionHash: txHash,
1485
1619
  blockNumber: receipt.blockNumber,
@@ -1510,6 +1644,7 @@ class PermissionsController {
1510
1644
  * @deprecated Use addAndTrustServer instead
1511
1645
  */
1512
1646
  async submitTrustServer(params) {
1647
+ this.assertWallet();
1513
1648
  try {
1514
1649
  const chainId = await this.context.walletClient.getChainId();
1515
1650
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1517,14 +1652,14 @@ class PermissionsController {
1517
1652
  "DataPortabilityServers"
1518
1653
  );
1519
1654
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1520
- const account = this.context.walletClient.account || await this.getUserAddress();
1655
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1521
1656
  const txHash = await this.context.walletClient.writeContract({
1522
1657
  address: DataPortabilityServersAddress,
1523
1658
  abi: DataPortabilityServersAbi,
1524
1659
  functionName: "trustServer",
1525
1660
  args: [BigInt(params.serverId)],
1526
1661
  account,
1527
- chain: this.context.walletClient.chain || null
1662
+ chain: this.context.walletClient?.chain ?? null
1528
1663
  });
1529
1664
  const { tx } = await import("../utils/transactionHelpers");
1530
1665
  return tx({
@@ -1550,6 +1685,7 @@ class PermissionsController {
1550
1685
  * @returns Promise resolving to TransactionResult with ServerTrustResult event data
1551
1686
  */
1552
1687
  async submitAddAndTrustServerWithSignature(params) {
1688
+ this.assertWallet();
1553
1689
  try {
1554
1690
  const nonce = await this.getServersUserNonce();
1555
1691
  const serverAddress = (0, import_viem.getAddress)(params.serverAddress);
@@ -1573,18 +1709,31 @@ class PermissionsController {
1573
1709
  const signature = await this.signTypedData(typedData);
1574
1710
  console.debug("\u{1F50D} Generated signature:", signature);
1575
1711
  let hash;
1576
- if (this.context.relayerCallbacks?.submitAddAndTrustServer) {
1577
- hash = await this.context.relayerCallbacks.submitAddAndTrustServer(
1712
+ if (this.context.relayer) {
1713
+ const request = {
1714
+ type: "signed",
1715
+ operation: "submitAddAndTrustServer",
1578
1716
  typedData,
1579
1717
  signature
1580
- );
1718
+ };
1719
+ const response = await this.context.relayer(request);
1720
+ if (response.type === "error") {
1721
+ throw new import_errors.RelayerError(response.error);
1722
+ }
1723
+ if (response.type === "submitted") {
1724
+ hash = response.hash;
1725
+ } else if (response.type === "signed") {
1726
+ hash = response.hash;
1727
+ } else {
1728
+ throw new Error("Unexpected response type from relayer");
1729
+ }
1581
1730
  } else {
1582
1731
  hash = await this.submitAddAndTrustServerTransaction(
1583
1732
  addAndTrustServerInput,
1584
1733
  signature
1585
1734
  );
1586
1735
  }
1587
- const account = this.context.walletClient.account || await this.getUserAddress();
1736
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1588
1737
  const { tx } = await import("../utils/transactionHelpers");
1589
1738
  return tx({
1590
1739
  hash,
@@ -1621,6 +1770,7 @@ class PermissionsController {
1621
1770
  * @throws {BlockchainError} When trust operation fails for any other reason
1622
1771
  */
1623
1772
  async submitTrustServerWithSignature(params) {
1773
+ this.assertWallet();
1624
1774
  try {
1625
1775
  const nonce = await this.getServersUserNonce();
1626
1776
  const trustServerInput = {
@@ -1630,18 +1780,31 @@ class PermissionsController {
1630
1780
  const typedData = await this.composeTrustServerMessage(trustServerInput);
1631
1781
  const signature = await this.signTypedData(typedData);
1632
1782
  let hash;
1633
- if (this.context.relayerCallbacks?.submitTrustServer) {
1634
- hash = await this.context.relayerCallbacks.submitTrustServer(
1783
+ if (this.context.relayer) {
1784
+ const request = {
1785
+ type: "signed",
1786
+ operation: "submitTrustServer",
1635
1787
  typedData,
1636
1788
  signature
1637
- );
1789
+ };
1790
+ const response = await this.context.relayer(request);
1791
+ if (response.type === "error") {
1792
+ throw new import_errors.RelayerError(response.error);
1793
+ }
1794
+ if (response.type === "submitted") {
1795
+ hash = response.hash;
1796
+ } else if (response.type === "signed") {
1797
+ hash = response.hash;
1798
+ } else {
1799
+ throw new Error("Unexpected response type from relayer");
1800
+ }
1638
1801
  } else {
1639
1802
  hash = await this.submitTrustServerTransaction(
1640
1803
  trustServerInput,
1641
1804
  signature
1642
1805
  );
1643
1806
  }
1644
- const account = this.context.walletClient.account || await this.getUserAddress();
1807
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1645
1808
  const { tx } = await import("../utils/transactionHelpers");
1646
1809
  return tx({
1647
1810
  hash,
@@ -1679,7 +1842,8 @@ class PermissionsController {
1679
1842
  * @returns Promise resolving to TransactionResult for transaction tracking
1680
1843
  * @throws {BlockchainError} When contract submission fails
1681
1844
  */
1682
- async submitDirectUntrustTransaction(params) {
1845
+ async submitDirectUntrustTransaction(params, options) {
1846
+ this.assertWallet();
1683
1847
  try {
1684
1848
  const chainId = await this.context.walletClient.getChainId();
1685
1849
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1687,14 +1851,25 @@ class PermissionsController {
1687
1851
  "DataPortabilityServers"
1688
1852
  );
1689
1853
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1690
- const account = this.context.walletClient.account || await this.getUserAddress();
1854
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1691
1855
  const txHash = await this.context.walletClient.writeContract({
1692
1856
  address: DataPortabilityServersAddress,
1693
1857
  abi: DataPortabilityServersAbi,
1694
1858
  functionName: "untrustServer",
1695
1859
  args: [BigInt(params.serverId)],
1696
1860
  account,
1697
- chain: this.context.walletClient.chain || null
1861
+ chain: this.context.walletClient?.chain ?? null,
1862
+ ...options?.gas && { gas: options.gas },
1863
+ ...options?.nonce && { nonce: options.nonce },
1864
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
1865
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
1866
+ ...options.maxFeePerGas && {
1867
+ maxFeePerGas: options.maxFeePerGas
1868
+ },
1869
+ ...options.maxPriorityFeePerGas && {
1870
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
1871
+ }
1872
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
1698
1873
  });
1699
1874
  const { tx } = await import("../utils/transactionHelpers");
1700
1875
  return tx({
@@ -1721,6 +1896,7 @@ class PermissionsController {
1721
1896
  *
1722
1897
  * @param params - Parameters for untrusting the server
1723
1898
  * @param params.serverId - The numeric ID of the server to untrust
1899
+ * @param options - Optional transaction options for gas parameters and timeout
1724
1900
  * @returns Promise resolving to transaction hash
1725
1901
  * @throws {Error} When wallet account is not available
1726
1902
  * @throws {NonceError} When retrieving user nonce fails
@@ -1741,13 +1917,17 @@ class PermissionsController {
1741
1917
  * console.log('Still trusting servers:', trustedServers);
1742
1918
  * ```
1743
1919
  */
1744
- async submitUntrustServer(params) {
1920
+ async submitUntrustServer(params, options) {
1921
+ this.assertWallet();
1745
1922
  const nonce = await this.getServersUserNonce();
1746
1923
  const untrustServerInput = {
1747
1924
  nonce,
1748
1925
  serverId: params.serverId
1749
1926
  };
1750
- return await this.submitDirectUntrustTransaction(untrustServerInput);
1927
+ return await this.submitDirectUntrustTransaction(
1928
+ untrustServerInput,
1929
+ options
1930
+ );
1751
1931
  }
1752
1932
  /**
1753
1933
  * Untrusts a server using a signature (gasless transaction).
@@ -1762,6 +1942,7 @@ class PermissionsController {
1762
1942
  * @throws {BlockchainError} When untrust transaction fails
1763
1943
  */
1764
1944
  async submitUntrustServerWithSignature(params) {
1945
+ this.assertWallet();
1765
1946
  try {
1766
1947
  const nonce = await this.getServersUserNonce();
1767
1948
  const untrustServerInput = {
@@ -1771,15 +1952,28 @@ class PermissionsController {
1771
1952
  const typedData = await this.composeUntrustServerMessage(untrustServerInput);
1772
1953
  const signature = await this.signTypedData(typedData);
1773
1954
  let hash;
1774
- if (this.context.relayerCallbacks?.submitUntrustServer) {
1775
- hash = await this.context.relayerCallbacks.submitUntrustServer(
1955
+ if (this.context.relayer) {
1956
+ const request = {
1957
+ type: "signed",
1958
+ operation: "submitUntrustServer",
1776
1959
  typedData,
1777
1960
  signature
1778
- );
1961
+ };
1962
+ const response = await this.context.relayer(request);
1963
+ if (response.type === "error") {
1964
+ throw new import_errors.RelayerError(response.error);
1965
+ }
1966
+ if (response.type === "submitted") {
1967
+ hash = response.hash;
1968
+ } else if (response.type === "signed") {
1969
+ hash = response.hash;
1970
+ } else {
1971
+ throw new Error("Unexpected response type from relayer");
1972
+ }
1779
1973
  } else {
1780
1974
  hash = await this.submitSignedUntrustTransaction(typedData, signature);
1781
1975
  }
1782
- const account = this.context.walletClient.account || await this.getUserAddress();
1976
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1783
1977
  const { tx } = await import("../utils/transactionHelpers");
1784
1978
  return tx({
1785
1979
  hash,
@@ -1824,8 +2018,8 @@ class PermissionsController {
1824
2018
  */
1825
2019
  async getTrustedServers(userAddress) {
1826
2020
  try {
1827
- const user = userAddress || await this.getUserAddress();
1828
- const chainId = await this.context.walletClient.getChainId();
2021
+ const user = userAddress ?? this.context.userAddress;
2022
+ const chainId = await this.context.publicClient.getChainId();
1829
2023
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1830
2024
  chainId,
1831
2025
  "DataPortabilityServers"
@@ -1854,8 +2048,8 @@ class PermissionsController {
1854
2048
  */
1855
2049
  async getTrustedServersCount(userAddress) {
1856
2050
  try {
1857
- const user = userAddress || await this.getUserAddress();
1858
- const chainId = await this.context.walletClient.getChainId();
2051
+ const user = userAddress ?? this.context.userAddress;
2052
+ const chainId = await this.context.publicClient.getChainId();
1859
2053
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1860
2054
  chainId,
1861
2055
  "DataPortabilityServers"
@@ -1884,10 +2078,10 @@ class PermissionsController {
1884
2078
  */
1885
2079
  async getTrustedServersPaginated(options = {}) {
1886
2080
  try {
1887
- const user = options.userAddress || await this.getUserAddress();
1888
- const limit = options.limit || 50;
1889
- const offset = options.offset || 0;
1890
- const chainId = await this.context.walletClient.getChainId();
2081
+ const user = options.userAddress ?? this.context.userAddress;
2082
+ const limit = options.limit ?? 50;
2083
+ const offset = options.offset ?? 0;
2084
+ const chainId = await this.context.publicClient.getChainId();
1891
2085
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1892
2086
  chainId,
1893
2087
  "DataPortabilityServers"
@@ -2033,7 +2227,7 @@ class PermissionsController {
2033
2227
  };
2034
2228
  }
2035
2229
  try {
2036
- const chainId = await this.context.walletClient.getChainId();
2230
+ const chainId = await this.context.publicClient.getChainId();
2037
2231
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2038
2232
  chainId,
2039
2233
  "DataPortabilityServers"
@@ -2108,7 +2302,7 @@ class PermissionsController {
2108
2302
  */
2109
2303
  async checkServerTrustStatus(serverId, userAddress) {
2110
2304
  try {
2111
- const user = userAddress || await this.getUserAddress();
2305
+ const user = userAddress ?? this.context.userAddress;
2112
2306
  const trustedServers = await this.getTrustedServers(user);
2113
2307
  const trustIndex = trustedServers.findIndex(
2114
2308
  (server) => server === serverId
@@ -2198,7 +2392,7 @@ class PermissionsController {
2198
2392
  * @returns Promise resolving to the EIP-712 domain configuration
2199
2393
  */
2200
2394
  async getServersDomain() {
2201
- const chainId = await this.context.walletClient.getChainId();
2395
+ const chainId = await this.context.publicClient.getChainId();
2202
2396
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2203
2397
  chainId,
2204
2398
  "DataPortabilityServers"
@@ -2218,6 +2412,7 @@ class PermissionsController {
2218
2412
  * @returns Promise resolving to the transaction hash
2219
2413
  */
2220
2414
  async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
2415
+ this.assertWallet();
2221
2416
  const chainId = await this.context.walletClient.getChainId();
2222
2417
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2223
2418
  chainId,
@@ -2249,8 +2444,8 @@ class PermissionsController {
2249
2444
  },
2250
2445
  formattedSignature
2251
2446
  ],
2252
- account: this.context.walletClient.account || await this.getUserAddress(),
2253
- chain: this.context.walletClient.chain || null
2447
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2448
+ chain: this.context.walletClient?.chain ?? null
2254
2449
  });
2255
2450
  return txHash;
2256
2451
  }
@@ -2261,7 +2456,8 @@ class PermissionsController {
2261
2456
  * @param signature - The cryptographic signature for the transaction
2262
2457
  * @returns Promise resolving to the transaction hash
2263
2458
  */
2264
- async submitTrustServerTransaction(trustServerInput, signature) {
2459
+ async submitTrustServerTransaction(trustServerInput, signature, options) {
2460
+ this.assertWallet();
2265
2461
  const chainId = await this.context.walletClient.getChainId();
2266
2462
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2267
2463
  chainId,
@@ -2280,8 +2476,9 @@ class PermissionsController {
2280
2476
  },
2281
2477
  formattedSignature
2282
2478
  ],
2283
- account: this.context.walletClient.account || await this.getUserAddress(),
2284
- chain: this.context.walletClient.chain || null
2479
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2480
+ chain: this.context.walletClient?.chain ?? null,
2481
+ ...this.spreadTransactionOptions(options)
2285
2482
  });
2286
2483
  return txHash;
2287
2484
  }
@@ -2293,6 +2490,7 @@ class PermissionsController {
2293
2490
  * @returns Promise resolving to the transaction hash
2294
2491
  */
2295
2492
  async submitDirectRevokeTransaction(typedData, signature) {
2493
+ this.assertWallet();
2296
2494
  const chainId = await this.context.walletClient.getChainId();
2297
2495
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2298
2496
  chainId,
@@ -2304,10 +2502,9 @@ class PermissionsController {
2304
2502
  address: DataPortabilityPermissionsAddress,
2305
2503
  abi: DataPortabilityPermissionsAbi,
2306
2504
  functionName: "revokePermissionWithSignature",
2307
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2308
2505
  args: [typedData.message, formattedSignature],
2309
- account: this.context.walletClient.account || await this.getUserAddress(),
2310
- chain: this.context.walletClient.chain || null
2506
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2507
+ chain: this.context.walletClient?.chain ?? null
2311
2508
  });
2312
2509
  return txHash;
2313
2510
  }
@@ -2318,7 +2515,8 @@ class PermissionsController {
2318
2515
  * @param signature - The cryptographic signature authorizing the untrust
2319
2516
  * @returns Promise resolving to the transaction hash
2320
2517
  */
2321
- async submitSignedUntrustTransaction(typedData, signature) {
2518
+ async submitSignedUntrustTransaction(typedData, signature, _options) {
2519
+ this.assertWallet();
2322
2520
  const chainId = await this.context.walletClient.getChainId();
2323
2521
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2324
2522
  chainId,
@@ -2326,14 +2524,17 @@ class PermissionsController {
2326
2524
  );
2327
2525
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
2328
2526
  const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
2527
+ const contractMessage = {
2528
+ nonce: typedData.message.nonce,
2529
+ serverId: BigInt(typedData.message.serverId)
2530
+ };
2329
2531
  const txHash = await this.context.walletClient.writeContract({
2330
2532
  address: DataPortabilityServersAddress,
2331
2533
  abi: DataPortabilityServersAbi,
2332
2534
  functionName: "untrustServerWithSignature",
2333
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2334
- args: [typedData.message, formattedSignature],
2335
- account: this.context.walletClient.account || await this.getUserAddress(),
2336
- chain: this.context.walletClient.chain || null
2535
+ args: [contractMessage, formattedSignature],
2536
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2537
+ chain: this.context.walletClient?.chain ?? null
2337
2538
  });
2338
2539
  return txHash;
2339
2540
  }
@@ -2346,14 +2547,18 @@ class PermissionsController {
2346
2547
  * A grantee is an entity (like an application) that can receive data permissions
2347
2548
  * from users. Once registered, users can grant the grantee access to their data.
2348
2549
  *
2550
+ * This method supports gasless transactions via relayer when configured.
2551
+ * If no relayer is available, it falls back to direct wallet transactions.
2552
+ *
2349
2553
  * @param params - Parameters for registering the grantee
2350
2554
  * @param params.owner - The Ethereum address that will own this grantee registration
2351
2555
  * @param params.granteeAddress - The Ethereum address of the grantee (application)
2352
2556
  * @param params.publicKey - The public key used for data encryption/decryption (hex string)
2557
+ * @param options - Optional transaction options for gas parameters and timeout
2353
2558
  * @returns Promise resolving to the transaction hash
2354
2559
  * @throws {BlockchainError} When the grantee registration transaction fails
2355
2560
  * @throws {UserRejectedRequestError} When user rejects the transaction
2356
- * @throws {ContractError} When grantee is already registered
2561
+ * @throws {RelayerError} When gasless transaction submission fails
2357
2562
  *
2358
2563
  * @example
2359
2564
  * ```typescript
@@ -2365,98 +2570,88 @@ class PermissionsController {
2365
2570
  * console.log(`Grantee registered in transaction: ${txHash}`);
2366
2571
  * ```
2367
2572
  */
2368
- async submitRegisterGrantee(params) {
2369
- const chainId = await this.context.walletClient.getChainId();
2370
- const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
2371
- chainId,
2372
- "DataPortabilityGrantees"
2373
- );
2374
- const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2375
- const ownerAddress = (0, import_viem.getAddress)(params.owner);
2376
- const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
2377
- const account = this.context.walletClient.account || await this.getUserAddress();
2378
- const txHash = await this.context.walletClient.writeContract({
2379
- address: DataPortabilityGranteesAddress,
2380
- abi: DataPortabilityGranteesAbi,
2381
- functionName: "registerGrantee",
2382
- args: [ownerAddress, granteeAddress, params.publicKey],
2383
- account,
2384
- chain: this.context.walletClient.chain || null
2385
- });
2386
- const { tx } = await import("../utils/transactionHelpers");
2387
- return tx({
2388
- hash: txHash,
2389
- from: typeof account === "string" ? account : account.address,
2390
- contract: "DataPortabilityGrantees",
2391
- fn: "registerGrantee"
2392
- });
2393
- }
2394
- /**
2395
- * Registers a grantee with a signature (gasless transaction)
2396
- *
2397
- * @param params - Parameters for registering the grantee
2398
- * @returns Promise resolving to the transaction hash
2399
- *
2400
- * @example
2401
- * ```typescript
2402
- * const txHash = await vana.permissions.registerGranteeWithSignature({
2403
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2404
- * granteeAddress: "0xApp1234567890123456789012345678901234567890",
2405
- * publicKey: "0x1234567890abcdef..."
2406
- * });
2407
- * ```
2408
- */
2409
- async submitRegisterGranteeWithSignature(params) {
2410
- const nonce = await this.getServersUserNonce();
2411
- const owner = (0, import_viem.getAddress)(params.owner);
2412
- const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
2413
- const registerGranteeInput = {
2414
- nonce,
2415
- owner,
2416
- granteeAddress,
2417
- publicKey: params.publicKey
2418
- };
2419
- const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
2420
- const signature = await this.signTypedData(typedData);
2421
- const hash = await this.submitSignedRegisterGranteeTransaction(
2422
- typedData,
2423
- signature
2424
- );
2425
- const account = this.context.walletClient.account || await this.getUserAddress();
2426
- const { tx } = await import("../utils/transactionHelpers");
2427
- return tx({
2428
- hash,
2429
- from: typeof account === "string" ? account : account.address,
2430
- contract: "DataPortabilityGrantees",
2431
- fn: "registerGrantee"
2432
- });
2433
- }
2434
- /**
2435
- * Submits a signed register grantee transaction via relayer
2436
- *
2437
- * @param typedData - The EIP-712 typed data for register grantee
2438
- * @param signature - The cryptographic signature
2439
- * @returns Promise resolving to the transaction hash
2440
- *
2441
- * @example
2442
- * ```typescript
2443
- * const result = await vana.permissions.submitSignedRegisterGrantee(typedData, signature);
2444
- * ```
2445
- */
2446
- async submitSignedRegisterGrantee(typedData, signature) {
2447
- const hash = await this.submitSignedRegisterGranteeTransaction(
2448
- typedData,
2449
- signature
2450
- );
2451
- const account = this.context.walletClient.account || await this.getUserAddress();
2452
- const { tx } = await import("../utils/transactionHelpers");
2453
- return tx({
2454
- hash,
2455
- from: typeof account === "string" ? account : account.address,
2456
- contract: "DataPortabilityGrantees",
2457
- fn: "registerGrantee"
2458
- });
2573
+ async submitRegisterGrantee(params, options) {
2574
+ try {
2575
+ let hash;
2576
+ if (this.context.relayer) {
2577
+ const request = {
2578
+ type: "direct",
2579
+ operation: "submitRegisterGrantee",
2580
+ params: {
2581
+ owner: params.owner,
2582
+ granteeAddress: params.granteeAddress,
2583
+ publicKey: params.publicKey
2584
+ }
2585
+ };
2586
+ const response = await this.context.relayer(request);
2587
+ if (response.type === "error") {
2588
+ throw new import_errors.RelayerError(response.error);
2589
+ }
2590
+ if (response.type === "submitted") {
2591
+ hash = response.hash;
2592
+ } else if (response.type === "direct") {
2593
+ const result = response.result;
2594
+ hash = result.transactionHash;
2595
+ } else {
2596
+ throw new Error("Unexpected response type from relayer");
2597
+ }
2598
+ } else {
2599
+ this.assertWallet();
2600
+ const chainId = await this.context.walletClient.getChainId();
2601
+ const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
2602
+ chainId,
2603
+ "DataPortabilityGrantees"
2604
+ );
2605
+ const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2606
+ const ownerAddress = (0, import_viem.getAddress)(params.owner);
2607
+ const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
2608
+ const account2 = this.context.walletClient?.account ?? this.context.userAddress;
2609
+ hash = await this.context.walletClient.writeContract({
2610
+ address: DataPortabilityGranteesAddress,
2611
+ abi: DataPortabilityGranteesAbi,
2612
+ functionName: "registerGrantee",
2613
+ args: [ownerAddress, granteeAddress, params.publicKey],
2614
+ account: account2,
2615
+ chain: this.context.walletClient?.chain ?? null,
2616
+ ...this.spreadTransactionOptions(options)
2617
+ });
2618
+ }
2619
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
2620
+ const { tx } = await import("../utils/transactionHelpers");
2621
+ return tx({
2622
+ hash,
2623
+ from: typeof account === "string" ? account : account.address,
2624
+ contract: "DataPortabilityGrantees",
2625
+ fn: "registerGrantee"
2626
+ });
2627
+ } catch (error) {
2628
+ if (error instanceof Error) {
2629
+ if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.BlockchainError) {
2630
+ throw error;
2631
+ }
2632
+ if (error.name === "ContractFunctionExecutionError") {
2633
+ throw new import_errors.BlockchainError(
2634
+ `Grantee registration failed: ${error.message}`,
2635
+ error
2636
+ );
2637
+ }
2638
+ if (error.name === "UserRejectedRequestError") {
2639
+ throw new import_errors.UserRejectedRequestError(
2640
+ "User rejected the grantee registration transaction"
2641
+ );
2642
+ }
2643
+ throw new import_errors.BlockchainError(
2644
+ `Failed to register grantee: ${error.message}`,
2645
+ error
2646
+ );
2647
+ }
2648
+ throw new import_errors.BlockchainError(`Failed to register grantee: ${String(error)}`);
2649
+ }
2459
2650
  }
2651
+ // TODO: When DataPortabilityGrantees contract adds registerGranteeWithSignature function,
2652
+ // implement submitRegisterGranteeWithSignature and submitSignedRegisterGrantee methods
2653
+ // to support EIP-712 signed gasless transactions via relayer.
2654
+ // Current implementation above supports direct gasless transactions (relayer pays gas directly).
2460
2655
  /**
2461
2656
  * Retrieves all registered grantees from the DataPortabilityGrantees contract.
2462
2657
  *
@@ -2502,8 +2697,8 @@ class PermissionsController {
2502
2697
  functionName: "granteesCount"
2503
2698
  });
2504
2699
  const total = Number(totalCount);
2505
- const limit = options.limit || 50;
2506
- const offset = options.offset || 0;
2700
+ const limit = options.limit ?? 50;
2701
+ const offset = options.offset ?? 0;
2507
2702
  const grantees = [];
2508
2703
  const endIndex = Math.min(offset + limit, total);
2509
2704
  for (let i = offset; i < endIndex; i++) {
@@ -2643,67 +2838,6 @@ class PermissionsController {
2643
2838
  return null;
2644
2839
  }
2645
2840
  }
2646
- /**
2647
- * Builds EIP-712 typed data for grantee registration
2648
- *
2649
- * @param input - The register grantee input
2650
- * @returns Promise resolving to the typed data structure
2651
- * @private
2652
- */
2653
- async buildRegisterGranteeTypedData(input) {
2654
- const chainId = await this.context.walletClient.getChainId();
2655
- const verifyingContract = (0, import_addresses.getContractAddress)(
2656
- chainId,
2657
- "DataPortabilityGrantees"
2658
- );
2659
- return {
2660
- domain: {
2661
- name: "DataPortabilityGrantees",
2662
- version: "1",
2663
- chainId,
2664
- verifyingContract
2665
- },
2666
- types: {
2667
- RegisterGrantee: [
2668
- { name: "nonce", type: "uint256" },
2669
- { name: "owner", type: "address" },
2670
- { name: "granteeAddress", type: "address" },
2671
- { name: "publicKey", type: "string" }
2672
- ]
2673
- },
2674
- primaryType: "RegisterGrantee",
2675
- message: input
2676
- };
2677
- }
2678
- /**
2679
- * Submits a register grantee transaction with signature.
2680
- *
2681
- * @param typedData - The EIP-712 typed data structure for the registration
2682
- * @param _signature - The cryptographic signature authorizing the registration (currently unused)
2683
- * @returns Promise resolving to the transaction hash
2684
- * @private
2685
- */
2686
- async submitSignedRegisterGranteeTransaction(typedData, _signature) {
2687
- const chainId = await this.context.walletClient.getChainId();
2688
- const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
2689
- chainId,
2690
- "DataPortabilityGrantees"
2691
- );
2692
- const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2693
- const txHash = await this.context.walletClient.writeContract({
2694
- address: DataPortabilityGranteesAddress,
2695
- abi: DataPortabilityGranteesAbi,
2696
- functionName: "registerGrantee",
2697
- args: [
2698
- typedData.message.owner,
2699
- typedData.message.granteeAddress,
2700
- typedData.message.publicKey
2701
- ],
2702
- account: this.context.walletClient.account || await this.getUserAddress(),
2703
- chain: this.context.walletClient.chain || null
2704
- });
2705
- return txHash;
2706
- }
2707
2841
  // ===========================
2708
2842
  // DATA PORTABILITY SERVERS HELPER METHODS
2709
2843
  // ===========================
@@ -2715,7 +2849,7 @@ class PermissionsController {
2715
2849
  */
2716
2850
  async getUserServerIds(userAddress) {
2717
2851
  try {
2718
- const targetAddress = userAddress || await this.getUserAddress();
2852
+ const targetAddress = userAddress ?? this.context.userAddress;
2719
2853
  const chainId = await this.context.publicClient.getChainId();
2720
2854
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2721
2855
  chainId,
@@ -2773,7 +2907,7 @@ class PermissionsController {
2773
2907
  */
2774
2908
  async getUserServerCount(userAddress) {
2775
2909
  try {
2776
- const targetAddress = userAddress || await this.getUserAddress();
2910
+ const targetAddress = userAddress ?? this.context.userAddress;
2777
2911
  const chainId = await this.context.publicClient.getChainId();
2778
2912
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2779
2913
  chainId,
@@ -2802,7 +2936,7 @@ class PermissionsController {
2802
2936
  */
2803
2937
  async getUserTrustedServers(userAddress) {
2804
2938
  try {
2805
- const targetAddress = userAddress || await this.getUserAddress();
2939
+ const targetAddress = userAddress ?? this.context.userAddress;
2806
2940
  const chainId = await this.context.publicClient.getChainId();
2807
2941
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2808
2942
  chainId,
@@ -2919,7 +3053,7 @@ class PermissionsController {
2919
3053
  */
2920
3054
  async getUserPermissionIds(userAddress) {
2921
3055
  try {
2922
- const targetAddress = userAddress || await this.getUserAddress();
3056
+ const targetAddress = userAddress ?? this.context.userAddress;
2923
3057
  const chainId = await this.context.publicClient.getChainId();
2924
3058
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2925
3059
  chainId,
@@ -2981,7 +3115,7 @@ class PermissionsController {
2981
3115
  */
2982
3116
  async getUserPermissionCount(userAddress) {
2983
3117
  try {
2984
- const targetAddress = userAddress || await this.getUserAddress();
3118
+ const targetAddress = userAddress ?? this.context.userAddress;
2985
3119
  const chainId = await this.context.publicClient.getChainId();
2986
3120
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2987
3121
  chainId,
@@ -3423,9 +3557,11 @@ class PermissionsController {
3423
3557
  *
3424
3558
  * @param serverId - Server ID to update
3425
3559
  * @param url - New URL for the server
3560
+ * @param options - Optional transaction options for gas parameters and timeout
3426
3561
  * @returns Promise resolving to transaction hash
3427
3562
  */
3428
- async submitUpdateServer(serverId, url) {
3563
+ async submitUpdateServer(serverId, url, options) {
3564
+ this.assertWallet();
3429
3565
  try {
3430
3566
  const chainId = await this.context.walletClient.getChainId();
3431
3567
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -3433,14 +3569,25 @@ class PermissionsController {
3433
3569
  "DataPortabilityServers"
3434
3570
  );
3435
3571
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
3436
- const account = this.context.walletClient.account || await this.getUserAddress();
3572
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3437
3573
  const hash = await this.context.walletClient.writeContract({
3438
3574
  address: DataPortabilityServersAddress,
3439
3575
  abi: DataPortabilityServersAbi,
3440
3576
  functionName: "updateServer",
3441
3577
  args: [serverId, url],
3442
- chain: this.context.walletClient.chain,
3443
- account
3578
+ chain: this.context.walletClient?.chain,
3579
+ account,
3580
+ ...options?.gas && { gas: options.gas },
3581
+ ...options?.nonce && { nonce: options.nonce },
3582
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3583
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3584
+ ...options.maxFeePerGas && {
3585
+ maxFeePerGas: options.maxFeePerGas
3586
+ },
3587
+ ...options.maxPriorityFeePerGas && {
3588
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3589
+ }
3590
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3444
3591
  });
3445
3592
  const { tx } = await import("../utils/transactionHelpers");
3446
3593
  return tx({
@@ -3598,6 +3745,7 @@ class PermissionsController {
3598
3745
  * @throws {NetworkError} When network communication fails
3599
3746
  */
3600
3747
  async submitAddPermission(params) {
3748
+ this.assertWallet();
3601
3749
  try {
3602
3750
  const nonce = await this.getPermissionsUserNonce();
3603
3751
  const addPermissionInput = {
@@ -3635,21 +3783,36 @@ class PermissionsController {
3635
3783
  * @throws {BlockchainError} When permission addition fails
3636
3784
  * @throws {NetworkError} When network communication fails
3637
3785
  */
3638
- async submitSignedAddPermission(typedData, signature) {
3786
+ async submitSignedAddPermission(typedData, signature, options) {
3787
+ this.assertWallet();
3639
3788
  try {
3640
3789
  let hash;
3641
- if (this.context.relayerCallbacks?.submitAddPermission) {
3642
- hash = await this.context.relayerCallbacks.submitAddPermission(
3790
+ if (this.context.relayer) {
3791
+ const request = {
3792
+ type: "signed",
3793
+ operation: "submitAddPermission",
3643
3794
  typedData,
3644
3795
  signature
3645
- );
3796
+ };
3797
+ const response = await this.context.relayer(request);
3798
+ if (response.type === "error") {
3799
+ throw new import_errors.RelayerError(response.error);
3800
+ }
3801
+ if (response.type === "submitted") {
3802
+ hash = response.hash;
3803
+ } else if (response.type === "signed") {
3804
+ hash = response.hash;
3805
+ } else {
3806
+ throw new Error("Unexpected response type from relayer");
3807
+ }
3646
3808
  } else {
3647
3809
  hash = await this.submitDirectAddPermissionTransaction(
3648
3810
  typedData,
3649
- signature
3811
+ signature,
3812
+ options
3650
3813
  );
3651
3814
  }
3652
- const account = this.context.walletClient.account || await this.getUserAddress();
3815
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3653
3816
  const { tx } = await import("../utils/transactionHelpers");
3654
3817
  return tx({
3655
3818
  hash,
@@ -3685,8 +3848,11 @@ class PermissionsController {
3685
3848
  * @param params.serverAddress - Server wallet address for decryption permissions
3686
3849
  * @param params.serverUrl - Server endpoint URL
3687
3850
  * @param params.serverPublicKey - Server's public key for encryption.
3688
- * Obtain via `vana.server.getIdentity(userAddress).public_key`.
3851
+ * Obtain via `vana.server.getIdentity(userAddress).publicKey`.
3689
3852
  * @param params.filePermissions - Nested array of permissions for each file
3853
+ * @param options - Optional transaction options for gas parameters and timeout.
3854
+ * Note: These options are only applied for direct blockchain transactions.
3855
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3690
3856
  * @returns TransactionResult with immediate hash access and optional event data
3691
3857
  * @throws {Error} When schemaIds array length doesn't match fileUrls array length
3692
3858
  * @throws {SchemaValidationError} When file data doesn't match the specified schema.
@@ -3700,6 +3866,7 @@ class PermissionsController {
3700
3866
  *
3701
3867
  * @example
3702
3868
  * ```typescript
3869
+ * // Submit with custom gas parameters and timeout
3703
3870
  * const result = await vana.permissions.submitAddServerFilesAndPermissions({
3704
3871
  * granteeId: BigInt(1),
3705
3872
  * grant: "ipfs://QmXxx...",
@@ -3707,17 +3874,25 @@ class PermissionsController {
3707
3874
  * schemaIds: [123], // LinkedIn profile schema ID
3708
3875
  * serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3709
3876
  * serverUrl: "https://server.example.com",
3710
- * serverPublicKey: serverInfo.public_key,
3877
+ * serverPublicKey: serverInfo.publicKey,
3711
3878
  * filePermissions: [[{
3712
3879
  * account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3713
3880
  * key: encryptedKey
3714
3881
  * }]]
3882
+ * }, {
3883
+ * maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
3884
+ * maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
3715
3885
  * });
3716
- * const events = await result.waitForEvents();
3717
- * console.log(`Permission ID: ${events.permissionId}`);
3886
+ *
3887
+ * // Wait for confirmation with custom timeout
3888
+ * const receipt = await vana.waitForTransactionReceipt(result, {
3889
+ * timeout: 180000 // 3 minutes
3890
+ * });
3891
+ * console.log(`Transaction confirmed: ${receipt.transactionHash}`);
3718
3892
  * ```
3719
3893
  */
3720
- async submitAddServerFilesAndPermissions(params) {
3894
+ async submitAddServerFilesAndPermissions(params, options) {
3895
+ this.assertWallet();
3721
3896
  try {
3722
3897
  if (params.schemaIds.length !== params.fileUrls.length) {
3723
3898
  throw new Error(
@@ -3742,7 +3917,8 @@ class PermissionsController {
3742
3917
  const signature = await this.signTypedData(typedData);
3743
3918
  return await this.submitSignedAddServerFilesAndPermissions(
3744
3919
  typedData,
3745
- signature
3920
+ signature,
3921
+ options
3746
3922
  );
3747
3923
  } catch (error) {
3748
3924
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
@@ -3763,6 +3939,9 @@ class PermissionsController {
3763
3939
  *
3764
3940
  * @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
3765
3941
  * @param signature - The user's signature
3942
+ * @param options - Optional transaction options for gas parameters and timeout.
3943
+ * Note: These options are only applied for direct blockchain transactions.
3944
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3766
3945
  * @returns TransactionResult with immediate hash access and optional event data
3767
3946
  * @throws {RelayerError} When gasless transaction submission fails
3768
3947
  * @throws {BlockchainError} When server files and permissions addition fails
@@ -3781,46 +3960,49 @@ class PermissionsController {
3781
3960
  * console.log(`Permission created with ID: ${permissionId}`);
3782
3961
  * ```
3783
3962
  */
3784
- async submitSignedAddServerFilesAndPermissions(typedData, signature) {
3963
+ async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
3964
+ this.assertWallet();
3785
3965
  try {
3786
- console.debug("\u{1F50D} submitSignedAddServerFilesAndPermissions Debug Info:", {
3787
- hasRelayerCallbacks: !!this.context.relayerCallbacks,
3788
- hasSubmitMethod: !!this.context.relayerCallbacks?.submitAddServerFilesAndPermissions,
3789
- availableRelayerMethods: this.context.relayerCallbacks ? Object.keys(this.context.relayerCallbacks) : []
3790
- });
3791
- if (this.context.relayerCallbacks?.submitAddServerFilesAndPermissions) {
3966
+ let hash;
3967
+ if (this.context.relayer) {
3792
3968
  console.debug(
3793
3969
  "\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
3794
3970
  );
3795
- const hash = await this.context.relayerCallbacks.submitAddServerFilesAndPermissions(
3971
+ const request = {
3972
+ type: "signed",
3973
+ operation: "submitAddServerFilesAndPermissions",
3796
3974
  typedData,
3797
3975
  signature
3798
- );
3799
- const account = this.context.walletClient.account || await this.getUserAddress();
3800
- const { tx } = await import("../utils/transactionHelpers");
3801
- return tx({
3802
- hash,
3803
- from: typeof account === "string" ? account : account.address,
3804
- contract: "DataPortabilityPermissions",
3805
- fn: "addServerFilesAndPermissions"
3806
- });
3976
+ };
3977
+ const response = await this.context.relayer(request);
3978
+ if (response.type === "error") {
3979
+ throw new import_errors.RelayerError(response.error);
3980
+ }
3981
+ if (response.type === "submitted") {
3982
+ hash = response.hash;
3983
+ } else if (response.type === "signed") {
3984
+ hash = response.hash;
3985
+ } else {
3986
+ throw new Error("Unexpected response type from relayer");
3987
+ }
3807
3988
  } else {
3808
3989
  console.debug(
3809
3990
  "\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
3810
3991
  );
3811
- const hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3992
+ hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3812
3993
  typedData,
3813
- signature
3994
+ signature,
3995
+ options
3814
3996
  );
3815
- const account = this.context.walletClient.account || await this.getUserAddress();
3816
- const { tx } = await import("../utils/transactionHelpers");
3817
- return tx({
3818
- hash,
3819
- from: typeof account === "string" ? account : account.address,
3820
- contract: "DataPortabilityPermissions",
3821
- fn: "addServerFilesAndPermissions"
3822
- });
3823
3997
  }
3998
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3999
+ const { tx } = await import("../utils/transactionHelpers");
4000
+ return tx({
4001
+ hash,
4002
+ from: typeof account === "string" ? account : account.address,
4003
+ contract: "DataPortabilityPermissions",
4004
+ fn: "addServerFilesAndPermissions"
4005
+ });
3824
4006
  } catch (error) {
3825
4007
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
3826
4008
  throw error;
@@ -3835,9 +4017,11 @@ class PermissionsController {
3835
4017
  * Submit permission revocation with signature to the blockchain
3836
4018
  *
3837
4019
  * @param permissionId - Permission ID to revoke
4020
+ * @param options - Optional transaction options for gas parameters and timeout
3838
4021
  * @returns Promise resolving to transaction hash
3839
4022
  */
3840
- async submitRevokePermission(permissionId) {
4023
+ async submitRevokePermission(permissionId, options) {
4024
+ this.assertWallet();
3841
4025
  try {
3842
4026
  const chainId = await this.context.walletClient.getChainId();
3843
4027
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
@@ -3847,7 +4031,7 @@ class PermissionsController {
3847
4031
  const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
3848
4032
  "DataPortabilityPermissions"
3849
4033
  );
3850
- const account = this.context.walletClient.account;
4034
+ const { account } = this.context.walletClient;
3851
4035
  if (!account) {
3852
4036
  throw new Error("No wallet account connected");
3853
4037
  }
@@ -3856,8 +4040,19 @@ class PermissionsController {
3856
4040
  abi: DataPortabilityPermissionsAbi,
3857
4041
  functionName: "revokePermission",
3858
4042
  args: [permissionId],
3859
- chain: this.context.walletClient.chain,
3860
- account
4043
+ chain: this.context.walletClient?.chain,
4044
+ account,
4045
+ ...options?.gas && { gas: options.gas },
4046
+ ...options?.nonce && { nonce: options.nonce },
4047
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
4048
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
4049
+ ...options.maxFeePerGas && {
4050
+ maxFeePerGas: options.maxFeePerGas
4051
+ },
4052
+ ...options.maxPriorityFeePerGas && {
4053
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
4054
+ }
4055
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3861
4056
  });
3862
4057
  const { tx } = await import("../utils/transactionHelpers");
3863
4058
  return tx({
@@ -3880,7 +4075,8 @@ class PermissionsController {
3880
4075
  * @param signature - The cryptographic signature authorizing the transaction
3881
4076
  * @returns Promise resolving to the transaction hash
3882
4077
  */
3883
- async submitDirectAddPermissionTransaction(typedData, signature) {
4078
+ async submitDirectAddPermissionTransaction(typedData, signature, options) {
4079
+ this.assertWallet();
3884
4080
  const chainId = await this.context.walletClient.getChainId();
3885
4081
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
3886
4082
  chainId,
@@ -3891,7 +4087,7 @@ class PermissionsController {
3891
4087
  nonce: typedData.message.nonce,
3892
4088
  granteeId: typedData.message.granteeId,
3893
4089
  grant: typedData.message.grant,
3894
- fileIds: typedData.message.fileIds || []
4090
+ fileIds: typedData.message.fileIds ?? []
3895
4091
  };
3896
4092
  const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
3897
4093
  const hash = await this.context.walletClient.writeContract({
@@ -3899,8 +4095,9 @@ class PermissionsController {
3899
4095
  abi: DataPortabilityPermissionsAbi,
3900
4096
  functionName: "addPermission",
3901
4097
  args: [permissionInput, formattedSignature],
3902
- account: this.context.walletClient.account || await this.getUserAddress(),
3903
- chain: this.context.walletClient.chain || null
4098
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4099
+ chain: this.context.walletClient?.chain ?? null,
4100
+ ...this.spreadTransactionOptions(options)
3904
4101
  });
3905
4102
  return hash;
3906
4103
  }
@@ -3911,8 +4108,9 @@ class PermissionsController {
3911
4108
  * @param signature - The cryptographic signature authorizing the transaction
3912
4109
  * @returns Promise resolving to the transaction hash
3913
4110
  */
3914
- async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
3915
- const chainId = await this.context.walletClient.getChainId();
4111
+ async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
4112
+ this.assertWallet();
4113
+ const chainId = await this.context.publicClient.getChainId();
3916
4114
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
3917
4115
  chainId,
3918
4116
  "DataPortabilityPermissions"
@@ -3934,10 +4132,11 @@ class PermissionsController {
3934
4132
  address: DataPortabilityPermissionsAddress,
3935
4133
  abi: DataPortabilityPermissionsAbi,
3936
4134
  functionName: "addServerFilesAndPermissions",
3937
- // @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
3938
4135
  args: [serverFilesAndPermissionInput, formattedSignature],
3939
- account: this.context.walletClient.account || await this.getUserAddress(),
3940
- chain: this.context.walletClient.chain || null
4136
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4137
+ chain: this.context.walletClient?.chain ?? null,
4138
+ ...options?.value && { value: options.value },
4139
+ ...this.spreadTransactionOptions(options)
3941
4140
  });
3942
4141
  return hash;
3943
4142
  }