@opendatalabs/vana-sdk 0.1.0-alpha.d7fc764 → 0.1.0-alpha.dba79a3

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 (778) 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 -24
  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 -38
  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__/operations.processQueue.test.d.ts +1 -0
  36. package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
  37. package/dist/controllers/base.cjs +116 -0
  38. package/dist/controllers/base.cjs.map +1 -0
  39. package/dist/controllers/base.d.ts +94 -0
  40. package/dist/controllers/base.js +92 -0
  41. package/dist/controllers/base.js.map +1 -0
  42. package/dist/controllers/data-error-handling.test.d.ts +1 -0
  43. package/dist/controllers/data.cjs +827 -439
  44. package/dist/controllers/data.cjs.map +1 -1
  45. package/dist/controllers/data.d.ts +373 -254
  46. package/dist/controllers/data.js +840 -442
  47. package/dist/controllers/data.js.map +1 -1
  48. package/dist/controllers/operations.cjs +430 -0
  49. package/dist/controllers/operations.cjs.map +1 -0
  50. package/dist/controllers/operations.d.ts +229 -0
  51. package/dist/controllers/operations.js +406 -0
  52. package/dist/controllers/operations.js.map +1 -0
  53. package/dist/controllers/permissions.cjs +929 -483
  54. package/dist/controllers/permissions.cjs.map +1 -1
  55. package/dist/controllers/permissions.d.ts +1318 -25
  56. package/dist/controllers/permissions.js +929 -483
  57. package/dist/controllers/permissions.js.map +1 -1
  58. package/dist/controllers/protocol.cjs +15 -11
  59. package/dist/controllers/protocol.cjs.map +1 -1
  60. package/dist/controllers/protocol.d.ts +34 -63
  61. package/dist/controllers/protocol.js +15 -14
  62. package/dist/controllers/protocol.js.map +1 -1
  63. package/dist/controllers/schemas.cjs +100 -75
  64. package/dist/controllers/schemas.cjs.map +1 -1
  65. package/dist/controllers/schemas.d.ts +56 -74
  66. package/dist/controllers/schemas.js +100 -75
  67. package/dist/controllers/schemas.js.map +1 -1
  68. package/dist/controllers/server-additional.test.d.ts +1 -0
  69. package/dist/controllers/server.cjs +32 -25
  70. package/dist/controllers/server.cjs.map +1 -1
  71. package/dist/controllers/server.d.ts +53 -71
  72. package/dist/controllers/server.js +32 -25
  73. package/dist/controllers/server.js.map +1 -1
  74. package/dist/core/__tests__/health.test.d.ts +1 -0
  75. package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
  76. package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
  77. package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
  78. package/dist/core/apiClient.cjs +68 -15
  79. package/dist/core/apiClient.cjs.map +1 -1
  80. package/dist/core/apiClient.d.ts +137 -16
  81. package/dist/core/apiClient.js +72 -22
  82. package/dist/core/apiClient.js.map +1 -1
  83. package/dist/core/client.cjs +7 -7
  84. package/dist/core/client.cjs.map +1 -1
  85. package/dist/core/client.d.ts +6 -9
  86. package/dist/core/client.js +7 -7
  87. package/dist/core/client.js.map +1 -1
  88. package/dist/core/core.test.d.ts +1 -0
  89. package/dist/core/generics.cjs +41 -12
  90. package/dist/core/generics.cjs.map +1 -1
  91. package/dist/core/generics.d.ts +104 -19
  92. package/dist/core/generics.js +52 -32
  93. package/dist/core/generics.js.map +1 -1
  94. package/dist/core/health.cjs +289 -0
  95. package/dist/core/health.cjs.map +1 -0
  96. package/dist/core/health.d.ts +143 -0
  97. package/dist/core/health.js +265 -0
  98. package/dist/core/health.js.map +1 -0
  99. package/dist/core/inMemoryNonceManager.cjs +138 -0
  100. package/dist/core/inMemoryNonceManager.cjs.map +1 -0
  101. package/dist/core/inMemoryNonceManager.d.ts +69 -0
  102. package/dist/core/inMemoryNonceManager.js +114 -0
  103. package/dist/core/inMemoryNonceManager.js.map +1 -0
  104. package/dist/core/nonceManager.cjs +304 -0
  105. package/dist/core/nonceManager.cjs.map +1 -0
  106. package/dist/core/nonceManager.d.ts +116 -0
  107. package/dist/core/nonceManager.js +280 -0
  108. package/dist/core/nonceManager.js.map +1 -0
  109. package/dist/core/pollingManager.cjs +292 -0
  110. package/dist/core/pollingManager.cjs.map +1 -0
  111. package/dist/core/pollingManager.d.ts +120 -0
  112. package/dist/core/pollingManager.js +268 -0
  113. package/dist/core/pollingManager.js.map +1 -0
  114. package/dist/core/tests/apiClient.test.d.ts +1 -0
  115. package/dist/core/tests/client.test.d.ts +1 -0
  116. package/dist/core/tests/generics.test.d.ts +1 -0
  117. package/dist/core.cjs +152 -61
  118. package/dist/core.cjs.map +1 -1
  119. package/dist/core.d.ts +50 -67
  120. package/dist/core.js +164 -86
  121. package/dist/core.js.map +1 -1
  122. package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
  123. package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
  124. package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
  125. package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
  126. package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
  127. package/dist/crypto/ecies/__tests__/test-vectors.d.ts +2 -4
  128. package/dist/crypto/ecies/base.cjs +20 -6
  129. package/dist/crypto/ecies/base.cjs.map +1 -1
  130. package/dist/crypto/ecies/base.d.ts +2 -5
  131. package/dist/crypto/ecies/base.js +28 -18
  132. package/dist/crypto/ecies/base.js.map +1 -1
  133. package/dist/crypto/ecies/browser.cjs +2 -1
  134. package/dist/crypto/ecies/browser.cjs.map +1 -1
  135. package/dist/crypto/ecies/browser.d.ts +2 -7
  136. package/dist/crypto/ecies/browser.js +2 -1
  137. package/dist/crypto/ecies/browser.js.map +1 -1
  138. package/dist/crypto/ecies/constants.d.ts +7 -9
  139. package/dist/crypto/ecies/index.d.ts +8 -1
  140. package/dist/crypto/ecies/interface.cjs +4 -5
  141. package/dist/crypto/ecies/interface.cjs.map +1 -1
  142. package/dist/crypto/ecies/interface.d.ts +9 -11
  143. package/dist/crypto/ecies/interface.js +4 -5
  144. package/dist/crypto/ecies/interface.js.map +1 -1
  145. package/dist/crypto/ecies/node.cjs +3 -2
  146. package/dist/crypto/ecies/node.cjs.map +1 -1
  147. package/dist/crypto/ecies/node.d.ts +2 -7
  148. package/dist/crypto/ecies/node.js +11 -16
  149. package/dist/crypto/ecies/node.js.map +1 -1
  150. package/dist/crypto/ecies/test-vectors/eccrypto-vectors.json +72 -0
  151. package/dist/crypto/ecies/utils.cjs +2 -41
  152. package/dist/crypto/ecies/utils.cjs.map +1 -1
  153. package/dist/crypto/ecies/utils.d.ts +3 -40
  154. package/dist/crypto/ecies/utils.js +1 -35
  155. package/dist/crypto/ecies/utils.js.map +1 -1
  156. package/dist/crypto/services/WalletKeyEncryptionService.cjs +2 -2
  157. package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -1
  158. package/dist/crypto/services/WalletKeyEncryptionService.d.ts +3 -7
  159. package/dist/crypto/services/WalletKeyEncryptionService.js +5 -9
  160. package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -1
  161. package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
  162. package/dist/diagnostics.d.ts +1 -3
  163. package/dist/diagnostics.test.d.ts +1 -0
  164. package/dist/errors.cjs +45 -0
  165. package/dist/errors.cjs.map +1 -1
  166. package/dist/errors.d.ts +117 -15
  167. package/dist/errors.js +46 -6
  168. package/dist/errors.js.map +1 -1
  169. package/dist/generated/abi/ComputeEngineImplementation.d.ts +2 -3
  170. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +2 -3
  171. package/dist/generated/abi/DATFactoryImplementation.d.ts +2 -3
  172. package/dist/generated/abi/DATImplementation.d.ts +2 -3
  173. package/dist/generated/abi/DATPausableImplementation.d.ts +2 -3
  174. package/dist/generated/abi/DATVotesImplementation.d.ts +2 -3
  175. package/dist/generated/abi/DLPPerformanceImplementation.d.ts +2 -3
  176. package/dist/generated/abi/DLPRegistryImplementation.d.ts +2 -3
  177. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +2 -3
  178. package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +2 -3
  179. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +2 -3
  180. package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +2 -3
  181. package/dist/generated/abi/DLPRootImplementation.d.ts +1 -3
  182. package/dist/generated/abi/DLPTreasuryImplementation.d.ts +2 -3
  183. package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +1 -3
  184. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +2 -3
  185. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +2 -3
  186. package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +2 -3
  187. package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +2 -3
  188. package/dist/generated/abi/DataRegistryImplementation.cjs +13 -0
  189. package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
  190. package/dist/generated/abi/DataRegistryImplementation.d.ts +12 -3
  191. package/dist/generated/abi/DataRegistryImplementation.js +13 -0
  192. package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
  193. package/dist/generated/abi/QueryEngineImplementation.d.ts +2 -3
  194. package/dist/generated/abi/SwapHelperImplementation.d.ts +2 -3
  195. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +2 -3
  196. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +2 -3
  197. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +2 -3
  198. package/dist/generated/abi/TeePoolImplementation.d.ts +2 -3
  199. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +2 -3
  200. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +2 -3
  201. package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +2 -3
  202. package/dist/generated/abi/VanaEpochImplementation.d.ts +2 -3
  203. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +2 -3
  204. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +2 -3
  205. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +2 -3
  206. package/dist/generated/abi/index.cjs +42 -0
  207. package/dist/generated/abi/index.cjs.map +1 -1
  208. package/dist/generated/abi/index.d.ts +47 -18
  209. package/dist/generated/abi/index.js +21 -0
  210. package/dist/generated/abi/index.js.map +1 -1
  211. package/dist/generated/event-types.cjs +17 -0
  212. package/dist/generated/event-types.cjs.map +1 -0
  213. package/dist/generated/event-types.d.ts +854 -0
  214. package/dist/generated/event-types.js +1 -0
  215. package/dist/generated/event-types.js.map +1 -0
  216. package/dist/generated/eventRegistry.cjs +3351 -0
  217. package/dist/generated/eventRegistry.cjs.map +1 -0
  218. package/dist/generated/eventRegistry.d.ts +14 -0
  219. package/dist/generated/eventRegistry.js +3326 -0
  220. package/dist/generated/eventRegistry.js.map +1 -0
  221. package/dist/generated/server/server-exports.d.ts +19 -21
  222. package/dist/generated/server/server.cjs.map +1 -1
  223. package/dist/generated/server/server.d.ts +113 -87
  224. package/dist/generated/subgraph.cjs +797 -32
  225. package/dist/generated/subgraph.cjs.map +1 -1
  226. package/dist/generated/subgraph.d.ts +464 -332
  227. package/dist/generated/subgraph.js +792 -32
  228. package/dist/generated/subgraph.js.map +1 -1
  229. package/dist/index.browser.d.ts +49 -73
  230. package/dist/index.browser.js +14 -0
  231. package/dist/index.browser.js.map +1 -1
  232. package/dist/index.cjs +3 -1
  233. package/dist/index.cjs.map +1 -1
  234. package/dist/index.d.ts +0 -2
  235. package/dist/index.js +3 -1
  236. package/dist/index.js.map +1 -1
  237. package/dist/index.node.cjs +31 -3
  238. package/dist/index.node.cjs.map +1 -1
  239. package/dist/index.node.d.ts +223 -64
  240. package/dist/index.node.js +28 -2
  241. package/dist/index.node.js.map +1 -1
  242. package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
  243. package/dist/lib/redisAtomicStore.cjs +201 -0
  244. package/dist/lib/redisAtomicStore.cjs.map +1 -0
  245. package/dist/lib/redisAtomicStore.d.ts +120 -0
  246. package/dist/lib/redisAtomicStore.js +177 -0
  247. package/dist/lib/redisAtomicStore.js.map +1 -0
  248. package/dist/node.cjs.map +1 -1
  249. package/dist/node.d.ts +42 -2
  250. package/dist/node.js.map +1 -1
  251. package/dist/platform/browser-only.d.ts +5 -8
  252. package/dist/platform/browser-only.test.d.ts +1 -0
  253. package/dist/platform/browser-safe.d.ts +6 -9
  254. package/dist/platform/browser-safe.test.d.ts +1 -0
  255. package/dist/platform/browser.cjs +167 -8
  256. package/dist/platform/browser.cjs.map +1 -1
  257. package/dist/platform/browser.d.ts +235 -18
  258. package/dist/platform/browser.js +179 -29
  259. package/dist/platform/browser.js.map +1 -1
  260. package/dist/platform/browser.test.d.ts +1 -0
  261. package/dist/platform/index.d.ts +11 -5
  262. package/dist/platform/interface.cjs.map +1 -1
  263. package/dist/platform/interface.d.ts +289 -98
  264. package/dist/platform/node.cjs +163 -2
  265. package/dist/platform/node.cjs.map +1 -1
  266. package/dist/platform/node.d.ts +72 -13
  267. package/dist/platform/node.js +175 -21
  268. package/dist/platform/node.js.map +1 -1
  269. package/dist/platform/ports/openpgp-port.cjs +74 -0
  270. package/dist/platform/ports/openpgp-port.cjs.map +1 -0
  271. package/dist/platform/ports/openpgp-port.d.ts +13 -0
  272. package/dist/platform/ports/openpgp-port.js +59 -0
  273. package/dist/platform/ports/openpgp-port.js.map +1 -0
  274. package/dist/platform/ports/pgp-port.cjs +17 -0
  275. package/dist/platform/ports/pgp-port.cjs.map +1 -0
  276. package/dist/platform/ports/pgp-port.d.ts +35 -0
  277. package/dist/platform/ports/pgp-port.js +1 -0
  278. package/dist/platform/ports/pgp-port.js.map +1 -0
  279. package/dist/platform/shared/error-utils.d.ts +2 -4
  280. package/dist/platform/shared/pgp-utils.cjs +2 -2
  281. package/dist/platform/shared/pgp-utils.cjs.map +1 -1
  282. package/dist/platform/shared/pgp-utils.d.ts +3 -5
  283. package/dist/platform/shared/pgp-utils.js +2 -2
  284. package/dist/platform/shared/pgp-utils.js.map +1 -1
  285. package/dist/platform/shared/stream-utils.d.ts +1 -3
  286. package/dist/platform/utils.d.ts +6 -10
  287. package/dist/platform/utils.test.d.ts +1 -0
  288. package/dist/platform.browser.d.ts +9 -4
  289. package/dist/platform.d.ts +11 -5
  290. package/dist/platform.node.d.ts +10 -5
  291. package/dist/schemas/dataSchema.schema.json +53 -0
  292. package/dist/schemas/grantFile.schema.json +43 -0
  293. package/dist/server/relayerHandler.cjs +420 -0
  294. package/dist/server/relayerHandler.cjs.map +1 -0
  295. package/dist/server/relayerHandler.d.ts +69 -0
  296. package/dist/server/relayerHandler.js +396 -0
  297. package/dist/server/relayerHandler.js.map +1 -0
  298. package/dist/storage/index.d.ts +56 -10
  299. package/dist/storage/manager.cjs +114 -31
  300. package/dist/storage/manager.cjs.map +1 -1
  301. package/dist/storage/manager.d.ts +121 -30
  302. package/dist/storage/manager.js +113 -37
  303. package/dist/storage/manager.js.map +1 -1
  304. package/dist/storage/providers/callback-storage.cjs +89 -18
  305. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  306. package/dist/storage/providers/callback-storage.d.ts +111 -28
  307. package/dist/storage/providers/callback-storage.js +89 -18
  308. package/dist/storage/providers/callback-storage.js.map +1 -1
  309. package/dist/storage/providers/google-drive.cjs +2 -2
  310. package/dist/storage/providers/google-drive.cjs.map +1 -1
  311. package/dist/storage/providers/google-drive.d.ts +3 -7
  312. package/dist/storage/providers/google-drive.js +4 -7
  313. package/dist/storage/providers/google-drive.js.map +1 -1
  314. package/dist/storage/providers/google-drive.test.d.ts +1 -0
  315. package/dist/storage/providers/ipfs.cjs +5 -5
  316. package/dist/storage/providers/ipfs.cjs.map +1 -1
  317. package/dist/storage/providers/ipfs.d.ts +3 -6
  318. package/dist/storage/providers/ipfs.js +7 -10
  319. package/dist/storage/providers/ipfs.js.map +1 -1
  320. package/dist/storage/providers/pinata.cjs +6 -6
  321. package/dist/storage/providers/pinata.cjs.map +1 -1
  322. package/dist/storage/providers/pinata.d.ts +17 -22
  323. package/dist/storage/providers/pinata.js +8 -11
  324. package/dist/storage/providers/pinata.js.map +1 -1
  325. package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
  326. package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
  327. package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
  328. package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
  329. package/dist/storage/tests/storageManager.test.d.ts +1 -0
  330. package/dist/tests/abi.test.d.ts +1 -0
  331. package/dist/tests/chains-definitions.test.d.ts +1 -0
  332. package/dist/tests/core-encryption.test.d.ts +1 -0
  333. package/dist/tests/core-extended.test.d.ts +1 -0
  334. package/dist/tests/core-generics-coverage.test.d.ts +1 -0
  335. package/dist/tests/coverage-boost.test.d.ts +1 -0
  336. package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
  337. package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
  338. package/dist/tests/data-additional-methods.test.d.ts +1 -0
  339. package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
  340. package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
  341. package/dist/tests/data-relayer.test.d.ts +1 -0
  342. package/dist/tests/data-schema-validation.test.d.ts +1 -0
  343. package/dist/tests/data-simple-methods.test.d.ts +1 -0
  344. package/dist/tests/data.test.d.ts +1 -0
  345. package/dist/tests/demo-integration.test.d.ts +1 -0
  346. package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
  347. package/dist/tests/download-relayer.test.d.ts +1 -0
  348. package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
  349. package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
  350. package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
  351. package/dist/tests/encryption-coverage.test.d.ts +1 -0
  352. package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
  353. package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
  354. package/dist/tests/errors-coverage.test.d.ts +1 -0
  355. package/dist/tests/errors.test.d.ts +1 -0
  356. package/dist/tests/factories/mockFactory.d.ts +316 -0
  357. package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
  358. package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
  359. package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
  360. package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
  361. package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
  362. package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
  363. package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
  364. package/dist/tests/helper-methods.test.d.ts +1 -0
  365. package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
  366. package/dist/tests/helpers/typedMocks.d.ts +64 -0
  367. package/dist/tests/index-browser.test.d.ts +1 -0
  368. package/dist/tests/index-node.test.d.ts +1 -0
  369. package/dist/tests/index.test.d.ts +1 -0
  370. package/dist/tests/mocks/platformAdapter.d.ts +12 -0
  371. package/dist/tests/new-permissions-methods.test.d.ts +1 -0
  372. package/dist/tests/no-buffer-browser.test.d.ts +1 -0
  373. package/dist/tests/permissions-grantee.test.d.ts +1 -0
  374. package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
  375. package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
  376. package/dist/tests/permissions-server-files.test.d.ts +1 -0
  377. package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
  378. package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
  379. package/dist/tests/permissions.test.d.ts +1 -0
  380. package/dist/tests/personal.test.d.ts +1 -0
  381. package/dist/tests/platform-browser.test.d.ts +1 -0
  382. package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
  383. package/dist/tests/platform-crypto.test.d.ts +1 -0
  384. package/dist/tests/platform-index.test.d.ts +1 -0
  385. package/dist/tests/platform-node.test.d.ts +1 -0
  386. package/dist/tests/platform-shared-utils.test.d.ts +1 -0
  387. package/dist/tests/platform-updated.test.d.ts +1 -0
  388. package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
  389. package/dist/tests/protocol.test.d.ts +1 -0
  390. package/dist/tests/read-only-mode.test.d.ts +1 -0
  391. package/dist/tests/relayer-integration.test.d.ts +1 -0
  392. package/dist/tests/relayer-unified.test.d.ts +1 -0
  393. package/dist/tests/schemas.test.d.ts +1 -0
  394. package/dist/tests/server-relayer-handler.test.d.ts +1 -0
  395. package/dist/tests/setup.d.ts +7 -0
  396. package/dist/tests/signatureFormatter.test.d.ts +1 -0
  397. package/dist/tests/trusted-server-queries.test.d.ts +1 -0
  398. package/dist/tests/typedDataConverter.test.d.ts +1 -0
  399. package/dist/tests/types-contracts.test.d.ts +1 -0
  400. package/dist/tests/types-data.test.d.ts +1 -0
  401. package/dist/tests/types-external-apis.test.d.ts +1 -0
  402. package/dist/tests/types-generics.test.d.ts +1 -0
  403. package/dist/tests/types-permissions.test.d.ts +1 -0
  404. package/dist/tests/types-upload-params.test.d.ts +1 -0
  405. package/dist/tests/types.test.d.ts +1 -0
  406. package/dist/tests/utils-formatters.test.d.ts +1 -0
  407. package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
  408. package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
  409. package/dist/tests/utils-grantFiles.test.d.ts +1 -0
  410. package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
  411. package/dist/tests/utils-grants.test.d.ts +1 -0
  412. package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
  413. package/dist/tests/utils-ipfs.test.d.ts +4 -0
  414. package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
  415. package/dist/tests/vana.test.d.ts +1 -0
  416. package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
  417. package/dist/{chains.browser.cjs → types/atomicStore.cjs} +9 -15
  418. package/dist/types/atomicStore.cjs.map +1 -0
  419. package/dist/types/atomicStore.d.ts +236 -0
  420. package/dist/types/atomicStore.js +7 -0
  421. package/dist/types/atomicStore.js.map +1 -0
  422. package/dist/types/blockchain.cjs +17 -0
  423. package/dist/types/blockchain.cjs.map +1 -0
  424. package/dist/types/blockchain.d.ts +85 -0
  425. package/dist/types/blockchain.js +1 -0
  426. package/dist/types/blockchain.js.map +1 -0
  427. package/dist/types/chains-additional.test.d.ts +1 -0
  428. package/dist/types/chains.cjs.map +1 -1
  429. package/dist/types/chains.d.ts +80 -16
  430. package/dist/types/chains.js.map +1 -1
  431. package/dist/types/config.cjs +10 -0
  432. package/dist/types/config.cjs.map +1 -1
  433. package/dist/types/config.d.ts +236 -242
  434. package/dist/types/config.js +8 -0
  435. package/dist/types/config.js.map +1 -1
  436. package/dist/types/contracts.cjs.map +1 -1
  437. package/dist/types/contracts.d.ts +79 -18
  438. package/dist/types/controller-context.cjs +17 -0
  439. package/dist/types/controller-context.cjs.map +1 -0
  440. package/dist/types/controller-context.d.ts +68 -0
  441. package/dist/types/controller-context.js +1 -0
  442. package/dist/types/controller-context.js.map +1 -0
  443. package/dist/types/data.cjs.map +1 -1
  444. package/dist/types/data.d.ts +118 -49
  445. package/dist/types/external-apis.d.ts +10 -12
  446. package/dist/types/generics.cjs.map +1 -1
  447. package/dist/types/generics.d.ts +116 -48
  448. package/dist/types/index.cjs +5 -4
  449. package/dist/types/index.cjs.map +1 -1
  450. package/dist/types/index.d.ts +48 -34
  451. package/dist/types/index.js +9 -2
  452. package/dist/types/index.js.map +1 -1
  453. package/dist/types/operationStore.cjs +17 -0
  454. package/dist/types/operationStore.cjs.map +1 -0
  455. package/dist/types/operationStore.d.ts +171 -0
  456. package/dist/types/operationStore.js +1 -0
  457. package/dist/types/operationStore.js.map +1 -0
  458. package/dist/types/operations.cjs +2 -2
  459. package/dist/types/operations.cjs.map +1 -1
  460. package/dist/types/operations.d.ts +164 -42
  461. package/dist/types/operations.js +2 -2
  462. package/dist/types/operations.js.map +1 -1
  463. package/dist/types/options.cjs +17 -0
  464. package/dist/types/options.cjs.map +1 -0
  465. package/dist/types/options.d.ts +308 -0
  466. package/dist/types/options.js +1 -0
  467. package/dist/types/options.js.map +1 -0
  468. package/dist/types/permissions.cjs.map +1 -1
  469. package/dist/types/permissions.d.ts +72 -78
  470. package/dist/types/personal.cjs.map +1 -1
  471. package/dist/types/personal.d.ts +137 -22
  472. package/dist/types/relayer.cjs.map +1 -1
  473. package/dist/types/relayer.d.ts +293 -50
  474. package/dist/types/storage.cjs.map +1 -1
  475. package/dist/types/storage.d.ts +15 -29
  476. package/dist/types/storage.js +2 -5
  477. package/dist/types/storage.js.map +1 -1
  478. package/dist/types/transactionResults.cjs.map +1 -1
  479. package/dist/types/transactionResults.d.ts +193 -25
  480. package/dist/types/utils.cjs.map +1 -1
  481. package/dist/types/utils.d.ts +20 -68
  482. package/dist/types.d.ts +4 -40
  483. package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
  484. package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
  485. package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
  486. package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
  487. package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
  488. package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
  489. package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
  490. package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
  491. package/dist/utils/blockchain/registry.cjs +2 -2
  492. package/dist/utils/blockchain/registry.cjs.map +1 -1
  493. package/dist/utils/blockchain/registry.d.ts +6 -8
  494. package/dist/utils/blockchain/registry.js +2 -2
  495. package/dist/utils/blockchain/registry.js.map +1 -1
  496. package/dist/utils/blockchain/registry.test.d.ts +1 -0
  497. package/dist/utils/chainQuery.cjs +107 -0
  498. package/dist/utils/chainQuery.cjs.map +1 -0
  499. package/dist/utils/chainQuery.d.ts +31 -0
  500. package/dist/utils/chainQuery.js +82 -0
  501. package/dist/utils/chainQuery.js.map +1 -0
  502. package/dist/utils/crypto-utils.cjs +0 -12
  503. package/dist/utils/crypto-utils.cjs.map +1 -1
  504. package/dist/utils/crypto-utils.d.ts +9 -27
  505. package/dist/utils/crypto-utils.js +0 -11
  506. package/dist/utils/crypto-utils.js.map +1 -1
  507. package/dist/utils/crypto-utils.test.d.ts +1 -0
  508. package/dist/utils/download.cjs +3 -3
  509. package/dist/utils/download.cjs.map +1 -1
  510. package/dist/utils/download.d.ts +13 -14
  511. package/dist/utils/download.js +2 -2
  512. package/dist/utils/download.js.map +1 -1
  513. package/dist/utils/encoding.cjs +1 -1
  514. package/dist/utils/encoding.cjs.map +1 -1
  515. package/dist/utils/encoding.d.ts +4 -6
  516. package/dist/utils/encoding.js +1 -1
  517. package/dist/utils/encoding.js.map +1 -1
  518. package/dist/utils/encoding.test.d.ts +1 -0
  519. package/dist/utils/encryption.cjs +16 -10
  520. package/dist/utils/encryption.cjs.map +1 -1
  521. package/dist/utils/encryption.d.ts +13 -17
  522. package/dist/utils/encryption.js +16 -10
  523. package/dist/utils/encryption.js.map +1 -1
  524. package/dist/utils/formatters.cjs +4 -2
  525. package/dist/utils/formatters.cjs.map +1 -1
  526. package/dist/utils/formatters.d.ts +4 -6
  527. package/dist/utils/formatters.js +4 -2
  528. package/dist/utils/formatters.js.map +1 -1
  529. package/dist/utils/grantFiles.cjs +7 -4
  530. package/dist/utils/grantFiles.cjs.map +1 -1
  531. package/dist/utils/grantFiles.d.ts +16 -30
  532. package/dist/utils/grantFiles.js +7 -4
  533. package/dist/utils/grantFiles.js.map +1 -1
  534. package/dist/utils/grantValidation.cjs +1 -1
  535. package/dist/utils/grantValidation.cjs.map +1 -1
  536. package/dist/utils/grantValidation.d.ts +109 -33
  537. package/dist/utils/grantValidation.js +1 -1
  538. package/dist/utils/grantValidation.js.map +1 -1
  539. package/dist/utils/grants.cjs +1 -1
  540. package/dist/utils/grants.cjs.map +1 -1
  541. package/dist/utils/grants.d.ts +101 -23
  542. package/dist/utils/grants.js +1 -1
  543. package/dist/utils/grants.js.map +1 -1
  544. package/dist/utils/ipfs.cjs +2 -4
  545. package/dist/utils/ipfs.cjs.map +1 -1
  546. package/dist/utils/ipfs.d.ts +8 -10
  547. package/dist/utils/ipfs.js +2 -4
  548. package/dist/utils/ipfs.js.map +1 -1
  549. package/dist/utils/lazy-import.cjs +4 -6
  550. package/dist/utils/lazy-import.cjs.map +1 -1
  551. package/dist/utils/lazy-import.d.ts +33 -10
  552. package/dist/utils/lazy-import.js +4 -6
  553. package/dist/utils/lazy-import.js.map +1 -1
  554. package/dist/utils/multicall.cjs +4 -2
  555. package/dist/utils/multicall.cjs.map +1 -1
  556. package/dist/utils/multicall.d.ts +5 -8
  557. package/dist/utils/multicall.js +4 -2
  558. package/dist/utils/multicall.js.map +1 -1
  559. package/dist/utils/parseTransactionPojo.cjs +87 -0
  560. package/dist/utils/parseTransactionPojo.cjs.map +1 -0
  561. package/dist/utils/parseTransactionPojo.d.ts +31 -0
  562. package/dist/utils/parseTransactionPojo.js +63 -0
  563. package/dist/utils/parseTransactionPojo.js.map +1 -0
  564. package/dist/utils/schemaValidation.cjs +5 -5
  565. package/dist/utils/schemaValidation.cjs.map +1 -1
  566. package/dist/utils/schemaValidation.d.ts +8 -12
  567. package/dist/utils/schemaValidation.js +7 -10
  568. package/dist/utils/schemaValidation.js.map +1 -1
  569. package/dist/utils/signatureCache.cjs +9 -4
  570. package/dist/utils/signatureCache.cjs.map +1 -1
  571. package/dist/utils/signatureCache.d.ts +53 -15
  572. package/dist/utils/signatureCache.js +12 -10
  573. package/dist/utils/signatureCache.js.map +1 -1
  574. package/dist/utils/signatureFormatter.cjs +6 -9
  575. package/dist/utils/signatureFormatter.cjs.map +1 -1
  576. package/dist/utils/signatureFormatter.d.ts +2 -5
  577. package/dist/utils/signatureFormatter.js +6 -9
  578. package/dist/utils/signatureFormatter.js.map +1 -1
  579. package/dist/utils/subgraphConsistency.cjs +184 -0
  580. package/dist/utils/subgraphConsistency.cjs.map +1 -0
  581. package/dist/utils/subgraphConsistency.d.ts +65 -0
  582. package/dist/utils/subgraphConsistency.js +155 -0
  583. package/dist/utils/subgraphConsistency.js.map +1 -0
  584. package/dist/utils/subgraphMetaCache.cjs +101 -0
  585. package/dist/utils/subgraphMetaCache.cjs.map +1 -0
  586. package/dist/utils/subgraphMetaCache.d.ts +56 -0
  587. package/dist/utils/subgraphMetaCache.js +76 -0
  588. package/dist/utils/subgraphMetaCache.js.map +1 -0
  589. package/dist/utils/subgraphPagination.cjs +104 -0
  590. package/dist/utils/subgraphPagination.cjs.map +1 -0
  591. package/dist/utils/subgraphPagination.d.ts +78 -0
  592. package/dist/utils/subgraphPagination.js +78 -0
  593. package/dist/utils/subgraphPagination.js.map +1 -0
  594. package/dist/utils/tests/multicall.test.d.ts +1 -0
  595. package/dist/utils/transactionHelpers.cjs +54 -0
  596. package/dist/utils/transactionHelpers.cjs.map +1 -0
  597. package/dist/utils/transactionHelpers.d.ts +80 -0
  598. package/dist/utils/transactionHelpers.js +29 -0
  599. package/dist/utils/transactionHelpers.js.map +1 -0
  600. package/dist/utils/typeGuards.cjs +109 -0
  601. package/dist/utils/typeGuards.cjs.map +1 -0
  602. package/dist/utils/typeGuards.d.ts +138 -0
  603. package/dist/utils/typeGuards.js +74 -0
  604. package/dist/utils/typeGuards.js.map +1 -0
  605. package/dist/utils/typedDataConverter.cjs.map +1 -1
  606. package/dist/utils/typedDataConverter.d.ts +42 -9
  607. package/dist/utils/typedDataConverter.js.map +1 -1
  608. package/dist/utils/urlResolver.cjs +8 -1
  609. package/dist/utils/urlResolver.cjs.map +1 -1
  610. package/dist/utils/urlResolver.d.ts +24 -8
  611. package/dist/utils/urlResolver.js +9 -2
  612. package/dist/utils/urlResolver.js.map +1 -1
  613. package/dist/utils/wallet.cjs +63 -0
  614. package/dist/utils/wallet.cjs.map +1 -0
  615. package/dist/utils/wallet.d.ts +94 -0
  616. package/dist/utils/wallet.js +37 -0
  617. package/dist/utils/wallet.js.map +1 -0
  618. package/dist/utils/withEvents.cjs +44 -0
  619. package/dist/utils/withEvents.cjs.map +1 -0
  620. package/dist/utils/withEvents.d.ts +56 -0
  621. package/dist/utils/withEvents.js +18 -0
  622. package/dist/utils/withEvents.js.map +1 -0
  623. package/package.json +25 -13
  624. package/dist/browser.d.cts +0 -2
  625. package/dist/chains/definitions.d.cts +0 -53
  626. package/dist/chains/index.d.cts +0 -2
  627. package/dist/chains.browser.cjs.map +0 -1
  628. package/dist/chains.browser.d.cts +0 -2
  629. package/dist/chains.d.cts +0 -2
  630. package/dist/chains.node.d.cts +0 -2
  631. package/dist/config/addresses.d.cts +0 -380
  632. package/dist/config/chains.d.cts +0 -85
  633. package/dist/config/eventMappings.cjs +0 -114
  634. package/dist/config/eventMappings.cjs.map +0 -1
  635. package/dist/config/eventMappings.d.cts +0 -108
  636. package/dist/config/eventMappings.d.ts +0 -108
  637. package/dist/config/eventMappings.js +0 -90
  638. package/dist/config/eventMappings.js.map +0 -1
  639. package/dist/config/features.d.cts +0 -64
  640. package/dist/contracts/contractController.d.cts +0 -96
  641. package/dist/controllers/data.d.cts +0 -941
  642. package/dist/controllers/permissions.d.cts +0 -25
  643. package/dist/controllers/protocol.d.cts +0 -167
  644. package/dist/controllers/schemas.d.cts +0 -272
  645. package/dist/controllers/server.d.cts +0 -243
  646. package/dist/core/apiClient.d.cts +0 -165
  647. package/dist/core/client.d.cts +0 -92
  648. package/dist/core/generics.d.cts +0 -120
  649. package/dist/core.d.cts +0 -466
  650. package/dist/crypto/ecies/__tests__/test-vectors.d.cts +0 -40
  651. package/dist/crypto/ecies/base.d.cts +0 -143
  652. package/dist/crypto/ecies/browser.d.cts +0 -48
  653. package/dist/crypto/ecies/constants.d.cts +0 -122
  654. package/dist/crypto/ecies/index.d.cts +0 -1
  655. package/dist/crypto/ecies/interface.d.cts +0 -176
  656. package/dist/crypto/ecies/node.d.cts +0 -50
  657. package/dist/crypto/ecies/utils.d.cts +0 -67
  658. package/dist/crypto/services/WalletKeyEncryptionService.d.cts +0 -92
  659. package/dist/diagnostics.d.cts +0 -26
  660. package/dist/errors.d.cts +0 -350
  661. package/dist/generated/abi/ComputeEngineImplementation.d.cts +0 -996
  662. package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +0 -545
  663. package/dist/generated/abi/DATFactoryImplementation.d.cts +0 -661
  664. package/dist/generated/abi/DATImplementation.d.cts +0 -693
  665. package/dist/generated/abi/DATPausableImplementation.d.cts +0 -1145
  666. package/dist/generated/abi/DATVotesImplementation.d.cts +0 -1095
  667. package/dist/generated/abi/DLPPerformanceImplementation.d.cts +0 -883
  668. package/dist/generated/abi/DLPRegistryImplementation.d.cts +0 -1123
  669. package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +0 -452
  670. package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +0 -714
  671. package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +0 -452
  672. package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +0 -706
  673. package/dist/generated/abi/DLPRootImplementation.d.cts +0 -1248
  674. package/dist/generated/abi/DLPTreasuryImplementation.d.cts +0 -452
  675. package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +0 -737
  676. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +0 -661
  677. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +0 -989
  678. package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +0 -1086
  679. package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +0 -737
  680. package/dist/generated/abi/DataRegistryImplementation.d.cts +0 -1004
  681. package/dist/generated/abi/QueryEngineImplementation.d.cts +0 -1001
  682. package/dist/generated/abi/SwapHelperImplementation.d.cts +0 -764
  683. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +0 -701
  684. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +0 -701
  685. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +0 -701
  686. package/dist/generated/abi/TeePoolImplementation.d.cts +0 -993
  687. package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +0 -701
  688. package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +0 -701
  689. package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +0 -993
  690. package/dist/generated/abi/VanaEpochImplementation.d.cts +0 -900
  691. package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +0 -934
  692. package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +0 -693
  693. package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +0 -394
  694. package/dist/generated/abi/index.d.cts +0 -26516
  695. package/dist/generated/server/server-exports.d.cts +0 -21
  696. package/dist/generated/server/server.d.cts +0 -512
  697. package/dist/generated/subgraph.d.cts +0 -5981
  698. package/dist/index.browser.cjs +0 -151
  699. package/dist/index.browser.cjs.map +0 -1
  700. package/dist/index.browser.d.cts +0 -177
  701. package/dist/index.d.cts +0 -2
  702. package/dist/index.node.d.cts +0 -64
  703. package/dist/node.d.cts +0 -2
  704. package/dist/permissions-DNKPu_G0.d.cts +0 -1666
  705. package/dist/permissions-eo8YeLGf.d.ts +0 -1666
  706. package/dist/platform/browser-only.d.cts +0 -25
  707. package/dist/platform/browser-safe.d.cts +0 -32
  708. package/dist/platform/browser.d.cts +0 -74
  709. package/dist/platform/index.d.cts +0 -5
  710. package/dist/platform/interface.d.cts +0 -218
  711. package/dist/platform/node.d.cts +0 -27
  712. package/dist/platform/shared/error-utils.d.cts +0 -25
  713. package/dist/platform/shared/pgp-utils.d.cts +0 -61
  714. package/dist/platform/shared/stream-utils.d.cts +0 -16
  715. package/dist/platform/utils.d.cts +0 -53
  716. package/dist/platform.browser.cjs +0 -41
  717. package/dist/platform.browser.cjs.map +0 -1
  718. package/dist/platform.browser.d.cts +0 -4
  719. package/dist/platform.d.cts +0 -5
  720. package/dist/platform.node.d.cts +0 -5
  721. package/dist/server/handler.cjs +0 -101
  722. package/dist/server/handler.cjs.map +0 -1
  723. package/dist/server/handler.d.cts +0 -282
  724. package/dist/server/handler.d.ts +0 -282
  725. package/dist/server/handler.js +0 -77
  726. package/dist/server/handler.js.map +0 -1
  727. package/dist/storage/index.d.cts +0 -10
  728. package/dist/storage/manager.d.cts +0 -150
  729. package/dist/storage/providers/callback-storage.d.cts +0 -100
  730. package/dist/storage/providers/google-drive.d.cts +0 -156
  731. package/dist/storage/providers/ipfs.d.cts +0 -163
  732. package/dist/storage/providers/pinata.d.cts +0 -173
  733. package/dist/types/chains.d.cts +0 -34
  734. package/dist/types/config.d.cts +0 -726
  735. package/dist/types/contracts.d.cts +0 -68
  736. package/dist/types/data.d.cts +0 -694
  737. package/dist/types/eccrypto-js.d.d.cts +0 -13
  738. package/dist/types/eccrypto-js.d.d.ts +0 -13
  739. package/dist/types/external-apis.d.cts +0 -186
  740. package/dist/types/generics.d.cts +0 -450
  741. package/dist/types/index.d.cts +0 -34
  742. package/dist/types/operations.d.cts +0 -108
  743. package/dist/types/permissions.d.cts +0 -957
  744. package/dist/types/personal.d.cts +0 -40
  745. package/dist/types/relayer.d.cts +0 -284
  746. package/dist/types/storage.d.cts +0 -131
  747. package/dist/types/transactionResults.d.cts +0 -25
  748. package/dist/types/utils.d.cts +0 -819
  749. package/dist/types.d.cts +0 -66
  750. package/dist/utils/blockchain/registry.d.cts +0 -34
  751. package/dist/utils/crypto-utils.d.cts +0 -118
  752. package/dist/utils/download.d.cts +0 -41
  753. package/dist/utils/encoding.d.cts +0 -54
  754. package/dist/utils/encryption.d.cts +0 -275
  755. package/dist/utils/eventParsing.cjs +0 -111
  756. package/dist/utils/eventParsing.cjs.map +0 -1
  757. package/dist/utils/eventParsing.d.cts +0 -60
  758. package/dist/utils/eventParsing.d.ts +0 -60
  759. package/dist/utils/eventParsing.js +0 -86
  760. package/dist/utils/eventParsing.js.map +0 -1
  761. package/dist/utils/formatters.d.cts +0 -120
  762. package/dist/utils/grantFiles.d.cts +0 -186
  763. package/dist/utils/grantValidation.d.cts +0 -150
  764. package/dist/utils/grants.d.cts +0 -70
  765. package/dist/utils/ipfs.d.cts +0 -90
  766. package/dist/utils/lazy-import.d.cts +0 -20
  767. package/dist/utils/multicall.d.cts +0 -129
  768. package/dist/utils/schemaValidation.d.cts +0 -172
  769. package/dist/utils/signatureCache.d.cts +0 -134
  770. package/dist/utils/signatureFormatter.d.cts +0 -39
  771. package/dist/utils/transactionParsing.cjs +0 -84
  772. package/dist/utils/transactionParsing.cjs.map +0 -1
  773. package/dist/utils/transactionParsing.d.cts +0 -25
  774. package/dist/utils/transactionParsing.d.ts +0 -25
  775. package/dist/utils/transactionParsing.js +0 -62
  776. package/dist/utils/transactionParsing.js.map +0 -1
  777. package/dist/utils/typedDataConverter.d.cts +0 -13
  778. package/dist/utils/urlResolver.d.cts +0 -40
@@ -1,5 +1,6 @@
1
1
  import { getAddress } from "viem";
2
2
  import { gasAwareMulticall } from "../utils/multicall";
3
+ import { PollingManager } from "../core/pollingManager";
3
4
  import {
4
5
  RelayerError,
5
6
  UserRejectedRequestError,
@@ -18,9 +19,10 @@ import { validateGrant } from "../utils/grantValidation";
18
19
  import { withSignatureCache } from "../utils/signatureCache";
19
20
  import { formatSignatureForContract } from "../utils/signatureFormatter";
20
21
  import { toViemTypedDataDefinition } from "../utils/typedDataConverter";
21
- class PermissionsController {
22
+ import { BaseController } from "./base";
23
+ class PermissionsController extends BaseController {
22
24
  constructor(context) {
23
- this.context = context;
25
+ super(context);
24
26
  }
25
27
  /**
26
28
  * Grants permission for an application to access user data with gasless transactions.
@@ -56,8 +58,15 @@ class PermissionsController {
56
58
  * await vana.permissions.revoke({ permissionId: result.permissionId });
57
59
  * ```
58
60
  */
59
- async grant(params) {
60
- return await this.submitPermissionGrant(params);
61
+ async grant(params, options) {
62
+ this.assertWallet();
63
+ const { typedData, signature } = await this.createAndSign(params);
64
+ const result = await this.submitSignedGrantWithEvents(
65
+ typedData,
66
+ signature,
67
+ options
68
+ );
69
+ return result;
61
70
  }
62
71
  /**
63
72
  * Submits a permission grant transaction and returns a handle for flexible result access.
@@ -84,9 +93,10 @@ class PermissionsController {
84
93
  * console.log(`Permission ID: ${eventData.permissionId}`);
85
94
  * ```
86
95
  */
87
- async submitPermissionGrant(params) {
96
+ async submitPermissionGrant(params, options) {
97
+ this.assertWallet();
88
98
  const { typedData, signature } = await this.createAndSign(params);
89
- return await this.submitSignedGrant(typedData, signature);
99
+ return await this.submitSignedGrant(typedData, signature, options);
90
100
  }
91
101
  /**
92
102
  * Prepares a permission grant with preview before signing.
@@ -113,14 +123,19 @@ class PermissionsController {
113
123
  * const transactionHash = await confirm();
114
124
  * ```
115
125
  */
116
- async prepareGrant(params) {
126
+ async prepareGrant(params, options) {
127
+ this.assertWallet();
117
128
  try {
118
129
  const grantFile = createGrantFile(params);
119
130
  validateGrant(grantFile);
120
131
  return {
121
132
  preview: grantFile,
122
133
  confirm: async () => {
123
- return await this.confirmGrantInternal(params, grantFile);
134
+ return await this.confirmGrantInternalWithEvents(
135
+ params,
136
+ grantFile,
137
+ options
138
+ );
124
139
  }
125
140
  };
126
141
  } catch (error) {
@@ -152,22 +167,36 @@ class PermissionsController {
152
167
  * @throws {NetworkError} When IPFS upload fails
153
168
  * @throws {SignatureError} When user rejects the signature
154
169
  */
155
- async confirmGrantInternal(params, grantFile) {
170
+ async confirmGrantInternal(params, grantFile, options) {
156
171
  try {
157
- let grantUrl = params.grantUrl;
172
+ let { grantUrl } = params;
158
173
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
159
174
  if (!grantUrl) {
160
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
175
+ const canStoreViaRelayer = this.context.relayer !== void 0;
176
+ if (!canStoreViaRelayer && !this.context.storageManager) {
161
177
  if (this.context.validateStorageRequired) {
162
178
  this.context.validateStorageRequired();
163
179
  } else {
164
180
  throw new Error(
165
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
181
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
166
182
  );
167
183
  }
168
184
  }
169
- if (this.context.relayerCallbacks?.storeGrantFile) {
170
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
185
+ if (canStoreViaRelayer && this.context.relayer) {
186
+ const request = {
187
+ type: "direct",
188
+ operation: "storeGrantFile",
189
+ params: grantFile
190
+ };
191
+ const response = await this.context.relayer(request);
192
+ if (response.type === "error") {
193
+ throw new Error(response.error);
194
+ }
195
+ if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
196
+ grantUrl = response.result.url;
197
+ } else {
198
+ throw new Error("Invalid response from relayer for grant storage");
199
+ }
171
200
  } else if (this.context.storageManager) {
172
201
  const blob = new Blob([JSON.stringify(grantFile)], {
173
202
  type: "application/json"
@@ -199,7 +228,7 @@ class PermissionsController {
199
228
  nonce
200
229
  });
201
230
  const signature = await this.signTypedData(typedData);
202
- return await this.submitSignedGrant(typedData, signature);
231
+ return await this.submitSignedGrant(typedData, signature, options);
203
232
  } catch (error) {
204
233
  if (error instanceof Error) {
205
234
  if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
@@ -244,23 +273,38 @@ class PermissionsController {
244
273
  * ```
245
274
  */
246
275
  async createAndSign(params) {
276
+ this.assertWallet();
247
277
  try {
248
278
  const grantFile = createGrantFile(params);
249
279
  validateGrant(grantFile);
250
- let grantUrl = params.grantUrl;
280
+ let { grantUrl } = params;
251
281
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
252
282
  if (!grantUrl) {
253
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
283
+ const canStoreViaRelayer = this.context.relayer !== void 0;
284
+ if (!canStoreViaRelayer && !this.context.storageManager) {
254
285
  if (this.context.validateStorageRequired) {
255
286
  this.context.validateStorageRequired();
256
287
  } else {
257
288
  throw new Error(
258
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
289
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
259
290
  );
260
291
  }
261
292
  }
262
- if (this.context.relayerCallbacks?.storeGrantFile) {
263
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
293
+ if (canStoreViaRelayer && this.context.relayer) {
294
+ const request = {
295
+ type: "direct",
296
+ operation: "storeGrantFile",
297
+ params: grantFile
298
+ };
299
+ const response = await this.context.relayer(request);
300
+ if (response.type === "error") {
301
+ throw new Error(response.error);
302
+ }
303
+ if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
304
+ grantUrl = response.result.url;
305
+ } else {
306
+ throw new Error("Invalid response from relayer for grant storage");
307
+ }
264
308
  } else if (this.context.storageManager) {
265
309
  const blob = new Blob([JSON.stringify(grantFile)], {
266
310
  type: "application/json"
@@ -329,29 +373,60 @@ class PermissionsController {
329
373
  * );
330
374
  * ```
331
375
  */
332
- async submitSignedGrant(typedData, signature) {
376
+ async submitSignedGrant(typedData, signature, options) {
333
377
  try {
334
378
  console.debug(
335
379
  "\u{1F50D} Debug - submitSignedGrant called with typed data:",
336
380
  JSON.stringify(
337
381
  typedData,
338
- (key, value) => typeof value === "bigint" ? value.toString() : value,
382
+ (_key, value) => typeof value === "bigint" ? value.toString() : value,
339
383
  2
340
384
  )
341
385
  );
342
- let hash;
343
- if (this.context.relayerCallbacks?.submitPermissionGrant) {
344
- hash = await this.context.relayerCallbacks.submitPermissionGrant(
386
+ if (this.context.relayer) {
387
+ const response = await this.context.relayer({
388
+ type: "signed",
389
+ operation: "submitAddPermission",
345
390
  typedData,
346
- signature
347
- );
391
+ signature,
392
+ expectedUserAddress: this.context.userAddress
393
+ });
394
+ if (response.type === "error") {
395
+ throw new Error(`Relayer error: ${response.error}`);
396
+ }
397
+ let finalHash;
398
+ if (response.type === "submitted") {
399
+ finalHash = response.hash;
400
+ } else if (response.type === "pending") {
401
+ const pollResult = await this.pollRelayerForConfirmation(
402
+ response.operationId,
403
+ options
404
+ );
405
+ finalHash = pollResult.hash;
406
+ } else if (response.type === "confirmed") {
407
+ finalHash = response.hash;
408
+ } else if (response.type === "signed") {
409
+ finalHash = response.hash;
410
+ } else {
411
+ throw new Error(
412
+ "Invalid response from relayer: unexpected response type"
413
+ );
414
+ }
415
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
416
+ const { tx } = await import("../utils/transactionHelpers");
417
+ return tx({
418
+ hash: finalHash,
419
+ from: typeof account === "string" ? account : account.address,
420
+ contract: "DataPortabilityPermissions",
421
+ fn: "addPermission"
422
+ });
348
423
  } else {
349
- hash = await this.submitDirectTransaction(typedData, signature);
424
+ return await this.submitDirectTransaction(
425
+ typedData,
426
+ signature,
427
+ options
428
+ );
350
429
  }
351
- return {
352
- hash,
353
- from: this.context.walletClient.account?.address
354
- };
355
430
  } catch (error) {
356
431
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
357
432
  throw error;
@@ -383,7 +458,7 @@ class PermissionsController {
383
458
  * const result = await txHandle.waitForEvents();
384
459
  * ```
385
460
  */
386
- async submitSignedTrustServer(typedData, signature) {
461
+ async submitSignedTrustServer(typedData, signature, options) {
387
462
  try {
388
463
  const trustServerInput = {
389
464
  nonce: BigInt(typedData.message.nonce),
@@ -391,12 +466,17 @@ class PermissionsController {
391
466
  };
392
467
  const hash = await this.submitTrustServerTransaction(
393
468
  trustServerInput,
394
- signature
469
+ signature,
470
+ options
395
471
  );
396
- return {
472
+ const account = this.context.userAddress;
473
+ const { tx } = await import("../utils/transactionHelpers");
474
+ return tx({
397
475
  hash,
398
- from: this.context.walletClient.account?.address
399
- };
476
+ from: account,
477
+ contract: "DataPortabilityServers",
478
+ fn: "trustServerWithSignature"
479
+ });
400
480
  } catch (error) {
401
481
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
402
482
  throw error;
@@ -442,7 +522,7 @@ class PermissionsController {
442
522
  * const result = await txHandle.waitForEvents();
443
523
  * ```
444
524
  */
445
- async submitSignedAddAndTrustServer(typedData, signature) {
525
+ async submitSignedAddAndTrustServer(typedData, signature, options) {
446
526
  try {
447
527
  const addAndTrustServerInput = {
448
528
  nonce: BigInt(typedData.message.nonce),
@@ -452,12 +532,17 @@ class PermissionsController {
452
532
  };
453
533
  const hash = await this.submitAddAndTrustServerTransaction(
454
534
  addAndTrustServerInput,
455
- signature
535
+ signature,
536
+ options
456
537
  );
457
- return {
538
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
539
+ const { tx } = await import("../utils/transactionHelpers");
540
+ return tx({
458
541
  hash,
459
- from: this.context.walletClient.account?.address
460
- };
542
+ from: typeof account === "string" ? account : account.address,
543
+ contract: "DataPortabilityServers",
544
+ fn: "addAndTrustServerWithSignature"
545
+ });
461
546
  } catch (error) {
462
547
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
463
548
  throw error;
@@ -468,6 +553,101 @@ class PermissionsController {
468
553
  );
469
554
  }
470
555
  }
556
+ /**
557
+ * Internal method to submit a signed grant and wait for events.
558
+ *
559
+ * @internal
560
+ * @param typedData - The EIP-712 typed data for the permission grant
561
+ * @param signature - The user's signature authorizing the transaction
562
+ * @returns Promise resolving to PermissionGrantResult with parsed events
563
+ */
564
+ async submitSignedGrantWithEvents(typedData, signature, options) {
565
+ const txResult = await this.submitSignedGrant(
566
+ typedData,
567
+ signature,
568
+ options
569
+ );
570
+ if (!this.context.waitForTransactionEvents) {
571
+ throw new BlockchainError("waitForTransactionEvents not configured");
572
+ }
573
+ const result = await this.context.waitForTransactionEvents(txResult);
574
+ const event = result.expectedEvents.PermissionAdded;
575
+ if (!event) {
576
+ throw new BlockchainError(
577
+ "PermissionAdded event not found in transaction"
578
+ );
579
+ }
580
+ const receipt = await this.context.publicClient.getTransactionReceipt({
581
+ hash: result.hash
582
+ });
583
+ return {
584
+ transactionHash: result.hash,
585
+ blockNumber: receipt.blockNumber,
586
+ gasUsed: receipt.gasUsed,
587
+ permissionId: event.permissionId,
588
+ user: event.user,
589
+ grant: event.grant,
590
+ fileIds: event.fileIds
591
+ };
592
+ }
593
+ /**
594
+ * Internal method for confirm grant with events.
595
+ *
596
+ * @internal
597
+ * @param params - The permission grant parameters
598
+ * @param grantFile - The pre-created grant file object
599
+ * @returns Promise resolving to PermissionGrantResult with parsed events
600
+ */
601
+ async confirmGrantInternalWithEvents(params, grantFile, options) {
602
+ const txResult = await this.confirmGrantInternal(
603
+ params,
604
+ grantFile,
605
+ options
606
+ );
607
+ if (!this.context.waitForTransactionEvents) {
608
+ throw new BlockchainError("waitForTransactionEvents not configured");
609
+ }
610
+ const result = await this.context.waitForTransactionEvents(txResult);
611
+ const event = result.expectedEvents.PermissionAdded;
612
+ if (!event) {
613
+ throw new BlockchainError(
614
+ "PermissionAdded event not found in transaction"
615
+ );
616
+ }
617
+ const receipt = await this.context.publicClient.getTransactionReceipt({
618
+ hash: result.hash
619
+ });
620
+ return {
621
+ transactionHash: result.hash,
622
+ blockNumber: receipt.blockNumber,
623
+ gasUsed: receipt.gasUsed,
624
+ permissionId: event.permissionId,
625
+ user: event.user,
626
+ grant: event.grant,
627
+ fileIds: event.fileIds
628
+ };
629
+ }
630
+ /**
631
+ * Polls the relayer for confirmation of a pending operation.
632
+ *
633
+ * @param operationId - The operation ID to poll
634
+ * @param options - Polling configuration including status updates and cancellation
635
+ * @returns Promise resolving to the confirmed hash and receipt
636
+ * @throws {TransactionPendingError} When the operation times out
637
+ * @throws {Error} When the operation fails or is cancelled
638
+ * @internal
639
+ */
640
+ async pollRelayerForConfirmation(operationId, options) {
641
+ if (!this.context.relayer) {
642
+ throw new Error("Relayer not configured for polling");
643
+ }
644
+ const pollingManager = new PollingManager(this.context.relayer);
645
+ return await pollingManager.startPolling(operationId, {
646
+ signal: options?.signal,
647
+ onStatusUpdate: options?.onStatusUpdate,
648
+ ...options?.pollingOptions
649
+ });
650
+ }
471
651
  /**
472
652
  * Submits an already-signed permission revoke transaction to the blockchain.
473
653
  *
@@ -489,21 +669,52 @@ class PermissionsController {
489
669
  * const result = await txHandle.waitForEvents();
490
670
  * ```
491
671
  */
492
- async submitSignedRevoke(typedData, signature) {
672
+ async submitSignedRevoke(typedData, signature, options) {
493
673
  try {
494
674
  let hash;
495
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
496
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
675
+ if (this.context.relayer) {
676
+ const response = await this.context.relayer({
677
+ type: "signed",
678
+ operation: "submitPermissionRevoke",
497
679
  typedData,
498
- signature
499
- );
680
+ signature,
681
+ expectedUserAddress: this.context.userAddress
682
+ });
683
+ if (response.type === "error") {
684
+ throw new Error(`Relayer error: ${response.error}`);
685
+ }
686
+ if (response.type === "submitted") {
687
+ hash = response.hash;
688
+ } else if (response.type === "pending") {
689
+ const pollResult = await this.pollRelayerForConfirmation(
690
+ response.operationId,
691
+ options
692
+ );
693
+ hash = pollResult.hash;
694
+ } else if (response.type === "confirmed") {
695
+ hash = response.hash;
696
+ } else if (response.type === "signed") {
697
+ hash = response.hash;
698
+ } else {
699
+ throw new Error(
700
+ "Invalid response from relayer: unexpected response type"
701
+ );
702
+ }
500
703
  } else {
501
- hash = await this.submitDirectRevokeTransaction(typedData, signature);
704
+ hash = await this.submitDirectRevokeTransaction(
705
+ typedData,
706
+ signature,
707
+ options
708
+ );
502
709
  }
503
- return {
710
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
711
+ const { tx } = await import("../utils/transactionHelpers");
712
+ return tx({
504
713
  hash,
505
- from: this.context.walletClient.account?.address
506
- };
714
+ from: typeof account === "string" ? account : account.address,
715
+ contract: "DataPortabilityPermissions",
716
+ fn: "revokePermissionWithSignature"
717
+ });
507
718
  } catch (error) {
508
719
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
509
720
  throw error;
@@ -535,21 +746,43 @@ class PermissionsController {
535
746
  * const result = await txHandle.waitForEvents();
536
747
  * ```
537
748
  */
538
- async submitSignedUntrustServer(typedData, signature) {
749
+ async submitSignedUntrustServer(typedData, signature, options) {
539
750
  try {
540
751
  let hash;
541
- if (this.context.relayerCallbacks?.submitUntrustServer) {
542
- hash = await this.context.relayerCallbacks.submitUntrustServer(
752
+ if (this.context.relayer) {
753
+ const response = await this.context.relayer({
754
+ type: "signed",
755
+ operation: "submitUntrustServer",
543
756
  typedData,
544
- signature
545
- );
757
+ signature,
758
+ expectedUserAddress: this.context.userAddress
759
+ });
760
+ if (response.type === "submitted") {
761
+ hash = response.hash;
762
+ } else if (response.type === "signed") {
763
+ hash = response.hash;
764
+ } else if (response.type === "error") {
765
+ throw new Error(`Relayer error: ${response.error}`);
766
+ } else {
767
+ throw new Error(
768
+ "Invalid response from relayer: expected signed transaction"
769
+ );
770
+ }
546
771
  } else {
547
- hash = await this.submitSignedUntrustTransaction(typedData, signature);
772
+ hash = await this.submitSignedUntrustTransaction(
773
+ typedData,
774
+ signature,
775
+ options
776
+ );
548
777
  }
549
- return {
778
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
779
+ const { tx } = await import("../utils/transactionHelpers");
780
+ return tx({
550
781
  hash,
551
- from: this.context.walletClient.account?.address
552
- };
782
+ from: typeof account === "string" ? account : account.address,
783
+ contract: "DataPortabilityServers",
784
+ fn: "untrustServerWithSignature"
785
+ });
553
786
  } catch (error) {
554
787
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
555
788
  throw error;
@@ -572,8 +805,9 @@ class PermissionsController {
572
805
  * @returns Promise resolving to the transaction hash
573
806
  * @throws {BlockchainError} When contract submission fails
574
807
  */
575
- async submitDirectTransaction(typedData, signature) {
576
- const chainId = await this.context.walletClient.getChainId();
808
+ async submitDirectTransaction(typedData, signature, options) {
809
+ this.assertWallet();
810
+ const chainId = await this.context.publicClient.getChainId();
577
811
  const DataPortabilityPermissionsAddress = getContractAddress(
578
812
  chainId,
579
813
  "DataPortabilityPermissions"
@@ -593,18 +827,26 @@ class PermissionsController {
593
827
  console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
594
828
  console.debug(
595
829
  "\u{1F50D} Debug - Grant field length:",
596
- typedData.message.grant?.length || 0
830
+ typedData.message.grant?.length ?? 0
597
831
  );
598
832
  const formattedSignature = formatSignatureForContract(signature);
833
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
599
834
  const txHash = await this.context.walletClient.writeContract({
600
835
  address: DataPortabilityPermissionsAddress,
601
836
  abi: DataPortabilityPermissionsAbi,
602
837
  functionName: "addPermission",
603
838
  args: [permissionInput, formattedSignature],
604
- account: this.context.walletClient.account || await this.getUserAddress(),
605
- chain: this.context.walletClient.chain || null
839
+ account,
840
+ chain: this.context.walletClient?.chain ?? null,
841
+ ...this.spreadTransactionOptions(options)
842
+ });
843
+ const { tx } = await import("../utils/transactionHelpers");
844
+ return tx({
845
+ hash: txHash,
846
+ from: typeof account === "string" ? account : account.address,
847
+ contract: "DataPortabilityPermissions",
848
+ fn: "addPermission"
606
849
  });
607
- return txHash;
608
850
  }
609
851
  /**
610
852
  * Revokes a previously granted permission.
@@ -631,7 +873,27 @@ class PermissionsController {
631
873
  * ```
632
874
  */
633
875
  async revoke(params) {
634
- return await this.submitPermissionRevoke(params);
876
+ this.assertWallet();
877
+ const txResult = await this.submitPermissionRevoke(params);
878
+ if (!this.context.waitForTransactionEvents) {
879
+ throw new BlockchainError("waitForTransactionEvents not configured");
880
+ }
881
+ const result = await this.context.waitForTransactionEvents(txResult);
882
+ const event = result.expectedEvents.PermissionRevoked;
883
+ if (!event) {
884
+ throw new BlockchainError(
885
+ "PermissionRevoked event not found in transaction"
886
+ );
887
+ }
888
+ const receipt = await this.context.publicClient.getTransactionReceipt({
889
+ hash: result.hash
890
+ });
891
+ return {
892
+ transactionHash: result.hash,
893
+ blockNumber: receipt.blockNumber,
894
+ gasUsed: receipt.gasUsed,
895
+ permissionId: event.permissionId
896
+ };
635
897
  }
636
898
  /**
637
899
  * Submits a permission revocation transaction and returns the transaction hash immediately.
@@ -640,6 +902,7 @@ class PermissionsController {
640
902
  * Use this when you want to handle transaction confirmation and event parsing separately.
641
903
  *
642
904
  * @param params - Parameters for revoking the permission
905
+ * @param options - Optional transaction options for gas parameters and timeout
643
906
  * @returns Promise resolving to the transaction hash when successfully submitted
644
907
  * @throws {BlockchainError} When revocation transaction fails
645
908
  * @throws {UserRejectedRequestError} When user rejects the transaction
@@ -652,12 +915,13 @@ class PermissionsController {
652
915
  * console.log(`Revocation submitted: ${txHash}`);
653
916
  * ```
654
917
  */
655
- async submitPermissionRevoke(params) {
918
+ async submitPermissionRevoke(params, options) {
919
+ this.assertWallet();
656
920
  try {
657
- if (!this.context.walletClient.chain?.id) {
921
+ if (!this.context.walletClient?.chain?.id) {
658
922
  throw new BlockchainError("Chain ID not available");
659
923
  }
660
- const chainId = await this.context.walletClient.getChainId();
924
+ const chainId = await this.context.publicClient.getChainId();
661
925
  const DataPortabilityPermissionsAddress = getContractAddress(
662
926
  chainId,
663
927
  "DataPortabilityPermissions"
@@ -665,18 +929,33 @@ class PermissionsController {
665
929
  const DataPortabilityPermissionsAbi = getAbi(
666
930
  "DataPortabilityPermissions"
667
931
  );
932
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
668
933
  const txHash = await this.context.walletClient.writeContract({
669
934
  address: DataPortabilityPermissionsAddress,
670
935
  abi: DataPortabilityPermissionsAbi,
671
936
  functionName: "revokePermission",
672
937
  args: [params.permissionId],
673
- account: this.context.walletClient.account || await this.getUserAddress(),
674
- chain: this.context.walletClient.chain || null
938
+ account,
939
+ chain: this.context.walletClient?.chain ?? null,
940
+ ...options?.gas && { gas: options.gas },
941
+ ...options?.nonce && { nonce: options.nonce },
942
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
943
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
944
+ ...options.maxFeePerGas && {
945
+ maxFeePerGas: options.maxFeePerGas
946
+ },
947
+ ...options.maxPriorityFeePerGas && {
948
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
949
+ }
950
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
675
951
  });
676
- return {
952
+ const { tx } = await import("../utils/transactionHelpers");
953
+ return tx({
677
954
  hash: txHash,
678
- from: this.context.walletClient.account?.address
679
- };
955
+ from: typeof account === "string" ? account : account.address,
956
+ contract: "DataPortabilityPermissions",
957
+ fn: "revokePermission"
958
+ });
680
959
  } catch (error) {
681
960
  if (error instanceof Error) {
682
961
  if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
@@ -715,9 +994,10 @@ class PermissionsController {
715
994
  * console.log(`Permission ${result.permissionId} revoked`);
716
995
  * ```
717
996
  */
718
- async submitRevokeWithSignature(params) {
997
+ async submitRevokeWithSignature(params, options) {
998
+ this.assertWallet();
719
999
  try {
720
- if (!this.context.walletClient.chain?.id) {
1000
+ if (!this.context.walletClient?.chain?.id) {
721
1001
  throw new BlockchainError("Chain ID not available");
722
1002
  }
723
1003
  const nonce = await this.getPermissionsUserNonce();
@@ -738,18 +1018,40 @@ class PermissionsController {
738
1018
  };
739
1019
  const signature = await this.signTypedData(typedData);
740
1020
  let hash;
741
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
742
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
1021
+ if (this.context.relayer) {
1022
+ const response = await this.context.relayer({
1023
+ type: "signed",
1024
+ operation: "submitPermissionRevoke",
743
1025
  typedData,
744
- signature
745
- );
1026
+ signature,
1027
+ expectedUserAddress: this.context.userAddress
1028
+ });
1029
+ if (response.type === "submitted") {
1030
+ hash = response.hash;
1031
+ } else if (response.type === "signed") {
1032
+ hash = response.hash;
1033
+ } else if (response.type === "error") {
1034
+ throw new Error(`Relayer error: ${response.error}`);
1035
+ } else {
1036
+ throw new Error(
1037
+ "Invalid response from relayer: expected signed transaction"
1038
+ );
1039
+ }
746
1040
  } else {
747
- hash = await this.submitDirectRevokeTransaction(typedData, signature);
1041
+ hash = await this.submitDirectRevokeTransaction(
1042
+ typedData,
1043
+ signature,
1044
+ options
1045
+ );
748
1046
  }
749
- return {
1047
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1048
+ const { tx } = await import("../utils/transactionHelpers");
1049
+ return tx({
750
1050
  hash,
751
- from: this.context.walletClient.account?.address
752
- };
1051
+ from: typeof account === "string" ? account : account.address,
1052
+ contract: "DataPortabilityPermissions",
1053
+ fn: "revokePermissionWithSignature"
1054
+ });
753
1055
  } catch (error) {
754
1056
  throw new PermissionError(
755
1057
  `Failed to revoke permission with signature: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -757,64 +1059,6 @@ class PermissionsController {
757
1059
  );
758
1060
  }
759
1061
  }
760
- /**
761
- * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
762
- *
763
- * Retrieves the user's current nonce from the DataPortabilityServers contract.
764
- * This method is deprecated in favor of more specific nonce methods.
765
- *
766
- * The nonce is used to prevent replay attacks in signed transactions and must
767
- * be incremented with each transaction to maintain security.
768
- *
769
- * @returns Promise resolving to the user's current nonce value as a bigint
770
- * @throws {Error} When wallet account is not available
771
- * @throws {Error} When chain ID is not available
772
- * @throws {NonceError} When reading nonce from contract fails
773
- * @private
774
- * @example
775
- * ```typescript
776
- * // Deprecated - use specific methods instead
777
- * const nonce = await this.getUserNonce();
778
- *
779
- * // Use these instead:
780
- * const permissionsNonce = await this.getPermissionsUserNonce();
781
- * const serversNonce = await this.getServersUserNonce();
782
- * ```
783
- */
784
- /**
785
- * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
786
- *
787
- * Retrieves the user's current nonce from the DataPortabilityServers contract.
788
- *
789
- * @remarks
790
- * This method is deprecated in favor of more specific nonce methods that target
791
- * the appropriate contract for the operation being performed.
792
- *
793
- * @returns Promise resolving to the user's current nonce as a bigint
794
- * @throws {NonceError} When retrieving the nonce fails
795
- */
796
- async getUserNonce() {
797
- try {
798
- const userAddress = await this.getUserAddress();
799
- const chainId = await this.context.walletClient.getChainId();
800
- const DataPortabilityServersAddress = getContractAddress(
801
- chainId,
802
- "DataPortabilityServers"
803
- );
804
- const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
805
- const nonce = await this.context.publicClient.readContract({
806
- address: DataPortabilityServersAddress,
807
- abi: DataPortabilityServersAbi,
808
- functionName: "userNonce",
809
- args: [userAddress]
810
- });
811
- return nonce;
812
- } catch (error) {
813
- throw new NonceError(
814
- `Failed to retrieve user nonce: ${error instanceof Error ? error.message : "Unknown error"}`
815
- );
816
- }
817
- }
818
1062
  /**
819
1063
  * Retrieves the user's current nonce from the DataPortabilityServers contract.
820
1064
  * This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
@@ -841,8 +1085,8 @@ class PermissionsController {
841
1085
  */
842
1086
  async getServersUserNonce() {
843
1087
  try {
844
- const userAddress = await this.getUserAddress();
845
- const chainId = await this.context.walletClient.getChainId();
1088
+ const userAddress = this.context.userAddress;
1089
+ const chainId = await this.context.publicClient.getChainId();
846
1090
  const DataPortabilityServersAddress = getContractAddress(
847
1091
  chainId,
848
1092
  "DataPortabilityServers"
@@ -887,8 +1131,8 @@ class PermissionsController {
887
1131
  */
888
1132
  async getPermissionsUserNonce() {
889
1133
  try {
890
- const userAddress = await this.getUserAddress();
891
- const chainId = await this.context.walletClient.getChainId();
1134
+ const userAddress = this.context.userAddress;
1135
+ const chainId = await this.context.publicClient.getChainId();
892
1136
  const DataPortabilityPermissionsAddress = getContractAddress(
893
1137
  chainId,
894
1138
  "DataPortabilityPermissions"
@@ -927,7 +1171,7 @@ class PermissionsController {
927
1171
  "\u{1F50D} Debug - Composing permission message with grantUrl:",
928
1172
  params.grantUrl
929
1173
  );
930
- const chainId = await this.context.walletClient.getChainId();
1174
+ const chainId = await this.context.publicClient.getChainId();
931
1175
  const DataPortabilityGranteesAddress = getContractAddress(
932
1176
  chainId,
933
1177
  "DataPortabilityGrantees"
@@ -1036,7 +1280,7 @@ class PermissionsController {
1036
1280
  * @returns Promise resolving to the EIP-712 domain configuration
1037
1281
  */
1038
1282
  async getPermissionDomain() {
1039
- const chainId = await this.context.walletClient.getChainId();
1283
+ const chainId = await this.context.publicClient.getChainId();
1040
1284
  const DataPortabilityPermissionsAddress = getContractAddress(
1041
1285
  chainId,
1042
1286
  "DataPortabilityPermissions"
@@ -1055,8 +1299,9 @@ class PermissionsController {
1055
1299
  * @returns Promise resolving to the cryptographic signature
1056
1300
  */
1057
1301
  async signTypedData(typedData) {
1302
+ this.assertWallet();
1058
1303
  try {
1059
- const walletAddress = this.context.walletClient.account?.address || await this.getUserAddress();
1304
+ const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
1060
1305
  return await withSignatureCache(
1061
1306
  this.context.platform.cache,
1062
1307
  walletAddress,
@@ -1065,9 +1310,9 @@ class PermissionsController {
1065
1310
  const viemCompatibleTypedData = toViemTypedDataDefinition(typedData);
1066
1311
  return await this.context.walletClient.signTypedData({
1067
1312
  ...viemCompatibleTypedData,
1068
- // Non-null assertion is safe here because getUserAddress() above ensures account exists
1069
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1070
- account: this.context.walletClient.account
1313
+ // Use the account if available, otherwise use the wallet address
1314
+ // This follows the same pattern used throughout this file
1315
+ account: this.context.walletClient.account ?? walletAddress
1071
1316
  });
1072
1317
  }
1073
1318
  );
@@ -1082,17 +1327,10 @@ class PermissionsController {
1082
1327
  }
1083
1328
  }
1084
1329
  /**
1085
- * Gets the user's address from the wallet client.
1330
+ * Gets the user's address from the context.
1086
1331
  *
1087
- * @returns Promise resolving to the user's wallet address
1332
+ * @returns The user's address
1088
1333
  */
1089
- async getUserAddress() {
1090
- const addresses = await this.context.walletClient.getAddresses();
1091
- if (addresses.length === 0) {
1092
- throw new BlockchainError("No addresses available in wallet client");
1093
- }
1094
- return addresses[0];
1095
- }
1096
1334
  /**
1097
1335
  * Gets on-chain permission grant data without expensive off-chain resolution.
1098
1336
  *
@@ -1129,20 +1367,22 @@ class PermissionsController {
1129
1367
  * ```
1130
1368
  */
1131
1369
  async getUserPermissionGrantsOnChain(options = {}) {
1132
- const { limit = 50, subgraphUrl } = options;
1370
+ const { limit = 50, fetchAll = false, subgraphUrl } = options;
1371
+ const pageSize = fetchAll ? 100 : limit;
1372
+ const maxResults = fetchAll ? 1e4 : limit;
1133
1373
  try {
1134
- const userAddress = await this.getUserAddress();
1135
- const graphqlEndpoint = subgraphUrl || this.context.subgraphUrl;
1374
+ const userAddress = this.context.userAddress;
1375
+ const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
1136
1376
  if (!graphqlEndpoint) {
1137
1377
  throw new BlockchainError(
1138
1378
  "subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
1139
1379
  );
1140
1380
  }
1141
1381
  const query = `
1142
- query GetUserPermissions($userId: ID!) {
1382
+ query GetUserPermissions($userId: ID!, $first: Int!, $skip: Int!) {
1143
1383
  user(id: $userId) {
1144
1384
  id
1145
- permissions {
1385
+ permissions(first: $first, skip: $skip, orderBy: addedAtBlock, orderDirection: desc) {
1146
1386
  id
1147
1387
  grant
1148
1388
  nonce
@@ -1160,34 +1400,82 @@ class PermissionsController {
1160
1400
  }
1161
1401
  }
1162
1402
  `;
1163
- const response = await fetch(graphqlEndpoint, {
1164
- method: "POST",
1165
- headers: {
1166
- "Content-Type": "application/json"
1167
- },
1168
- body: JSON.stringify({
1169
- query,
1170
- variables: {
1171
- userId: userAddress.toLowerCase()
1403
+ const allPermissions = [];
1404
+ let currentOffset = 0;
1405
+ if (!fetchAll) {
1406
+ const response = await fetch(graphqlEndpoint, {
1407
+ method: "POST",
1408
+ headers: {
1409
+ "Content-Type": "application/json"
1410
+ },
1411
+ body: JSON.stringify({
1412
+ query,
1413
+ variables: {
1414
+ userId: userAddress.toLowerCase(),
1415
+ first: limit,
1416
+ skip: 0
1417
+ }
1418
+ })
1419
+ });
1420
+ if (!response.ok) {
1421
+ throw new BlockchainError(
1422
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1423
+ );
1424
+ }
1425
+ const result = await response.json();
1426
+ if (result.errors) {
1427
+ throw new BlockchainError(
1428
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1429
+ );
1430
+ }
1431
+ const userData = result.data?.user;
1432
+ if (!userData?.permissions?.length) {
1433
+ return [];
1434
+ }
1435
+ allPermissions.push(...userData.permissions);
1436
+ } else {
1437
+ while (allPermissions.length < maxResults) {
1438
+ const currentLimit = Math.min(
1439
+ pageSize,
1440
+ maxResults - allPermissions.length
1441
+ );
1442
+ const response = await fetch(graphqlEndpoint, {
1443
+ method: "POST",
1444
+ headers: {
1445
+ "Content-Type": "application/json"
1446
+ },
1447
+ body: JSON.stringify({
1448
+ query,
1449
+ variables: {
1450
+ userId: userAddress.toLowerCase(),
1451
+ first: currentLimit,
1452
+ skip: currentOffset
1453
+ }
1454
+ })
1455
+ });
1456
+ if (!response.ok) {
1457
+ throw new BlockchainError(
1458
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1459
+ );
1172
1460
  }
1173
- })
1174
- });
1175
- if (!response.ok) {
1176
- throw new BlockchainError(
1177
- `Subgraph request failed: ${response.status} ${response.statusText}`
1178
- );
1179
- }
1180
- const result = await response.json();
1181
- if (result.errors) {
1182
- throw new BlockchainError(
1183
- `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1184
- );
1185
- }
1186
- const userData = result.data?.user;
1187
- if (!userData || !userData.permissions?.length) {
1188
- return [];
1461
+ const result = await response.json();
1462
+ if (result.errors) {
1463
+ throw new BlockchainError(
1464
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1465
+ );
1466
+ }
1467
+ const userData = result.data?.user;
1468
+ if (!userData?.permissions?.length) {
1469
+ break;
1470
+ }
1471
+ allPermissions.push(...userData.permissions);
1472
+ if (userData.permissions.length < currentLimit) {
1473
+ break;
1474
+ }
1475
+ currentOffset += userData.permissions.length;
1476
+ }
1189
1477
  }
1190
- const onChainGrants = userData.permissions.slice(0, limit).map(
1478
+ const onChainGrants = allPermissions.map(
1191
1479
  (permission) => ({
1192
1480
  id: BigInt(permission.id),
1193
1481
  grantUrl: permission.grant,
@@ -1195,8 +1483,8 @@ class PermissionsController {
1195
1483
  nonce: BigInt(permission.nonce),
1196
1484
  startBlock: BigInt(permission.startBlock),
1197
1485
  addedAtBlock: BigInt(permission.addedAtBlock),
1198
- addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
1199
- transactionHash: permission.transactionHash || "",
1486
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
1487
+ transactionHash: permission.transactionHash ?? "",
1200
1488
  grantor: userAddress,
1201
1489
  grantee: permission.grantee,
1202
1490
  active: !permission.endBlock || BigInt(permission.endBlock) === 0n
@@ -1217,26 +1505,6 @@ class PermissionsController {
1217
1505
  );
1218
1506
  }
1219
1507
  }
1220
- /**
1221
- * Normalizes grant ID to hex format.
1222
- * Handles conversion from permission ID (bigint/number/string) to proper hex hash format.
1223
- *
1224
- * @param grantId - Permission ID or grant hash in various formats
1225
- * @returns Normalized hex hash
1226
- */
1227
- normalizeGrantId(grantId) {
1228
- if (typeof grantId === "string" && grantId.startsWith("0x") && grantId.length === 66) {
1229
- return grantId;
1230
- }
1231
- try {
1232
- const bigIntId = BigInt(grantId);
1233
- return `0x${bigIntId.toString(16).padStart(64, "0")}`;
1234
- } catch {
1235
- throw new Error(
1236
- `Invalid grant ID format: ${grantId}. Must be a permission ID (number/bigint/string) or a 32-byte hex hash.`
1237
- );
1238
- }
1239
- }
1240
1508
  /**
1241
1509
  * Registers a new server and immediately trusts it in the DataPortabilityServers contract.
1242
1510
  *
@@ -1245,7 +1513,6 @@ class PermissionsController {
1245
1513
  * Trusted servers can handle data export and portability requests from the user.
1246
1514
  *
1247
1515
  * @param params - Parameters for adding and trusting the server
1248
- * @param params.owner - Ethereum address that will own this server registration
1249
1516
  * @param params.serverAddress - Ethereum address of the server
1250
1517
  * @param params.serverUrl - HTTPS URL where the server can be reached
1251
1518
  * @param params.publicKey - Server's public key for encryption (hex string)
@@ -1272,6 +1539,7 @@ class PermissionsController {
1272
1539
  * ```
1273
1540
  */
1274
1541
  async addAndTrustServer(params) {
1542
+ this.assertWallet();
1275
1543
  try {
1276
1544
  const chainId = await this.context.walletClient.getChainId();
1277
1545
  const DataPortabilityServersAddress = getContractAddress(
@@ -1279,7 +1547,8 @@ class PermissionsController {
1279
1547
  "DataPortabilityServers"
1280
1548
  );
1281
1549
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1282
- const userAddress = this.context.walletClient.account?.address || await this.getUserAddress();
1550
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1551
+ const userAddress = typeof account === "string" ? account : account.address;
1283
1552
  const normalizedUserAddress = getAddress(userAddress);
1284
1553
  const normalizedServerAddress = getAddress(params.serverAddress);
1285
1554
  const txHash = await this.context.walletClient.writeContract({
@@ -1294,12 +1563,40 @@ class PermissionsController {
1294
1563
  publicKey: params.publicKey
1295
1564
  }
1296
1565
  ],
1297
- account: this.context.walletClient.account || await this.getUserAddress(),
1298
- chain: this.context.walletClient.chain || null
1566
+ account,
1567
+ chain: this.context.walletClient?.chain ?? null
1299
1568
  });
1300
- return {
1569
+ const { tx } = await import("../utils/transactionHelpers");
1570
+ const txResult = tx({
1301
1571
  hash: txHash,
1302
- from: this.context.walletClient.account?.address
1572
+ from: userAddress,
1573
+ contract: "DataPortabilityServers",
1574
+ fn: "addAndTrustServerByManager"
1575
+ });
1576
+ if (!this.context.waitForTransactionEvents) {
1577
+ throw new BlockchainError("waitForTransactionEvents not configured");
1578
+ }
1579
+ const result = await this.context.waitForTransactionEvents(txResult);
1580
+ const event = result.expectedEvents.ServerTrusted;
1581
+ if (!event) {
1582
+ throw new BlockchainError(
1583
+ "ServerTrusted event not found in transaction"
1584
+ );
1585
+ }
1586
+ const receipt = await this.context.publicClient.getTransactionReceipt({
1587
+ hash: txHash
1588
+ });
1589
+ return {
1590
+ transactionHash: txHash,
1591
+ blockNumber: receipt.blockNumber,
1592
+ gasUsed: receipt.gasUsed,
1593
+ user: event.user,
1594
+ serverId: event.serverId,
1595
+ // bigint from event
1596
+ serverAddress: normalizedServerAddress,
1597
+ // derived from params
1598
+ serverUrl: params.serverUrl
1599
+ // provided in params
1303
1600
  };
1304
1601
  } catch (error) {
1305
1602
  if (error instanceof Error && error.message.includes("rejected")) {
@@ -1319,6 +1616,7 @@ class PermissionsController {
1319
1616
  * @deprecated Use addAndTrustServer instead
1320
1617
  */
1321
1618
  async submitTrustServer(params) {
1619
+ this.assertWallet();
1322
1620
  try {
1323
1621
  const chainId = await this.context.walletClient.getChainId();
1324
1622
  const DataPortabilityServersAddress = getContractAddress(
@@ -1326,18 +1624,22 @@ class PermissionsController {
1326
1624
  "DataPortabilityServers"
1327
1625
  );
1328
1626
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1627
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1329
1628
  const txHash = await this.context.walletClient.writeContract({
1330
1629
  address: DataPortabilityServersAddress,
1331
1630
  abi: DataPortabilityServersAbi,
1332
1631
  functionName: "trustServer",
1333
1632
  args: [BigInt(params.serverId)],
1334
- account: this.context.walletClient.account || await this.getUserAddress(),
1335
- chain: this.context.walletClient.chain || null
1633
+ account,
1634
+ chain: this.context.walletClient?.chain ?? null
1336
1635
  });
1337
- return {
1636
+ const { tx } = await import("../utils/transactionHelpers");
1637
+ return tx({
1338
1638
  hash: txHash,
1339
- from: this.context.walletClient.account?.address
1340
- };
1639
+ from: typeof account === "string" ? account : account.address,
1640
+ contract: "DataPortabilityServers",
1641
+ fn: "trustServer"
1642
+ });
1341
1643
  } catch (error) {
1342
1644
  if (error instanceof Error && error.message.includes("rejected")) {
1343
1645
  throw new UserRejectedRequestError();
@@ -1354,7 +1656,8 @@ class PermissionsController {
1354
1656
  * @param params - Parameters for adding and trusting the server
1355
1657
  * @returns Promise resolving to TransactionResult with ServerTrustResult event data
1356
1658
  */
1357
- async submitAddAndTrustServerWithSignature(params) {
1659
+ async submitAddAndTrustServerWithSignature(params, options) {
1660
+ this.assertWallet();
1358
1661
  try {
1359
1662
  const nonce = await this.getServersUserNonce();
1360
1663
  const serverAddress = getAddress(params.serverAddress);
@@ -1378,21 +1681,39 @@ class PermissionsController {
1378
1681
  const signature = await this.signTypedData(typedData);
1379
1682
  console.debug("\u{1F50D} Generated signature:", signature);
1380
1683
  let hash;
1381
- if (this.context.relayerCallbacks?.submitAddAndTrustServer) {
1382
- hash = await this.context.relayerCallbacks.submitAddAndTrustServer(
1684
+ if (this.context.relayer) {
1685
+ const request = {
1686
+ type: "signed",
1687
+ operation: "submitAddAndTrustServer",
1383
1688
  typedData,
1384
1689
  signature
1385
- );
1690
+ };
1691
+ const response = await this.context.relayer(request);
1692
+ if (response.type === "error") {
1693
+ throw new RelayerError(response.error);
1694
+ }
1695
+ if (response.type === "submitted") {
1696
+ hash = response.hash;
1697
+ } else if (response.type === "signed") {
1698
+ hash = response.hash;
1699
+ } else {
1700
+ throw new Error("Unexpected response type from relayer");
1701
+ }
1386
1702
  } else {
1387
1703
  hash = await this.submitAddAndTrustServerTransaction(
1388
1704
  addAndTrustServerInput,
1389
- signature
1705
+ signature,
1706
+ options
1390
1707
  );
1391
1708
  }
1392
- return {
1709
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1710
+ const { tx } = await import("../utils/transactionHelpers");
1711
+ return tx({
1393
1712
  hash,
1394
- from: this.context.walletClient.account?.address
1395
- };
1713
+ from: typeof account === "string" ? account : account.address,
1714
+ contract: "DataPortabilityServers",
1715
+ fn: "addAndTrustServerWithSignature"
1716
+ });
1396
1717
  } catch (error) {
1397
1718
  if (error instanceof Error) {
1398
1719
  if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
@@ -1421,7 +1742,8 @@ class PermissionsController {
1421
1742
  * @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
1422
1743
  * @throws {BlockchainError} When trust operation fails for any other reason
1423
1744
  */
1424
- async submitTrustServerWithSignature(params) {
1745
+ async submitTrustServerWithSignature(params, options) {
1746
+ this.assertWallet();
1425
1747
  try {
1426
1748
  const nonce = await this.getServersUserNonce();
1427
1749
  const trustServerInput = {
@@ -1431,21 +1753,39 @@ class PermissionsController {
1431
1753
  const typedData = await this.composeTrustServerMessage(trustServerInput);
1432
1754
  const signature = await this.signTypedData(typedData);
1433
1755
  let hash;
1434
- if (this.context.relayerCallbacks?.submitTrustServer) {
1435
- hash = await this.context.relayerCallbacks.submitTrustServer(
1756
+ if (this.context.relayer) {
1757
+ const request = {
1758
+ type: "signed",
1759
+ operation: "submitTrustServer",
1436
1760
  typedData,
1437
1761
  signature
1438
- );
1762
+ };
1763
+ const response = await this.context.relayer(request);
1764
+ if (response.type === "error") {
1765
+ throw new RelayerError(response.error);
1766
+ }
1767
+ if (response.type === "submitted") {
1768
+ hash = response.hash;
1769
+ } else if (response.type === "signed") {
1770
+ hash = response.hash;
1771
+ } else {
1772
+ throw new Error("Unexpected response type from relayer");
1773
+ }
1439
1774
  } else {
1440
1775
  hash = await this.submitTrustServerTransaction(
1441
1776
  trustServerInput,
1442
- signature
1777
+ signature,
1778
+ options
1443
1779
  );
1444
1780
  }
1445
- return {
1781
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1782
+ const { tx } = await import("../utils/transactionHelpers");
1783
+ return tx({
1446
1784
  hash,
1447
- from: this.context.walletClient.account?.address
1448
- };
1785
+ from: typeof account === "string" ? account : account.address,
1786
+ contract: "DataPortabilityServers",
1787
+ fn: "trustServerWithSignature"
1788
+ });
1449
1789
  } catch (error) {
1450
1790
  if (error instanceof Error) {
1451
1791
  if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
@@ -1476,7 +1816,8 @@ class PermissionsController {
1476
1816
  * @returns Promise resolving to TransactionResult for transaction tracking
1477
1817
  * @throws {BlockchainError} When contract submission fails
1478
1818
  */
1479
- async submitDirectUntrustTransaction(params) {
1819
+ async submitDirectUntrustTransaction(params, options) {
1820
+ this.assertWallet();
1480
1821
  try {
1481
1822
  const chainId = await this.context.walletClient.getChainId();
1482
1823
  const DataPortabilityServersAddress = getContractAddress(
@@ -1484,18 +1825,33 @@ class PermissionsController {
1484
1825
  "DataPortabilityServers"
1485
1826
  );
1486
1827
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
1828
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1487
1829
  const txHash = await this.context.walletClient.writeContract({
1488
1830
  address: DataPortabilityServersAddress,
1489
1831
  abi: DataPortabilityServersAbi,
1490
1832
  functionName: "untrustServer",
1491
1833
  args: [BigInt(params.serverId)],
1492
- account: this.context.walletClient.account || await this.getUserAddress(),
1493
- chain: this.context.walletClient.chain || null
1834
+ account,
1835
+ chain: this.context.walletClient?.chain ?? null,
1836
+ ...options?.gas && { gas: options.gas },
1837
+ ...options?.nonce && { nonce: options.nonce },
1838
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
1839
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
1840
+ ...options.maxFeePerGas && {
1841
+ maxFeePerGas: options.maxFeePerGas
1842
+ },
1843
+ ...options.maxPriorityFeePerGas && {
1844
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
1845
+ }
1846
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
1494
1847
  });
1495
- return {
1848
+ const { tx } = await import("../utils/transactionHelpers");
1849
+ return tx({
1496
1850
  hash: txHash,
1497
- from: this.context.walletClient.account?.address
1498
- };
1851
+ from: typeof account === "string" ? account : account.address,
1852
+ contract: "DataPortabilityServers",
1853
+ fn: "untrustServer"
1854
+ });
1499
1855
  } catch (error) {
1500
1856
  if (error instanceof Error && error.message.includes("rejected")) {
1501
1857
  throw new UserRejectedRequestError();
@@ -1514,6 +1870,7 @@ class PermissionsController {
1514
1870
  *
1515
1871
  * @param params - Parameters for untrusting the server
1516
1872
  * @param params.serverId - The numeric ID of the server to untrust
1873
+ * @param options - Optional transaction options for gas parameters and timeout
1517
1874
  * @returns Promise resolving to transaction hash
1518
1875
  * @throws {Error} When wallet account is not available
1519
1876
  * @throws {NonceError} When retrieving user nonce fails
@@ -1534,13 +1891,17 @@ class PermissionsController {
1534
1891
  * console.log('Still trusting servers:', trustedServers);
1535
1892
  * ```
1536
1893
  */
1537
- async submitUntrustServer(params) {
1894
+ async submitUntrustServer(params, options) {
1895
+ this.assertWallet();
1538
1896
  const nonce = await this.getServersUserNonce();
1539
1897
  const untrustServerInput = {
1540
1898
  nonce,
1541
1899
  serverId: params.serverId
1542
1900
  };
1543
- return await this.submitDirectUntrustTransaction(untrustServerInput);
1901
+ return await this.submitDirectUntrustTransaction(
1902
+ untrustServerInput,
1903
+ options
1904
+ );
1544
1905
  }
1545
1906
  /**
1546
1907
  * Untrusts a server using a signature (gasless transaction).
@@ -1555,6 +1916,7 @@ class PermissionsController {
1555
1916
  * @throws {BlockchainError} When untrust transaction fails
1556
1917
  */
1557
1918
  async submitUntrustServerWithSignature(params) {
1919
+ this.assertWallet();
1558
1920
  try {
1559
1921
  const nonce = await this.getServersUserNonce();
1560
1922
  const untrustServerInput = {
@@ -1564,18 +1926,35 @@ class PermissionsController {
1564
1926
  const typedData = await this.composeUntrustServerMessage(untrustServerInput);
1565
1927
  const signature = await this.signTypedData(typedData);
1566
1928
  let hash;
1567
- if (this.context.relayerCallbacks?.submitUntrustServer) {
1568
- hash = await this.context.relayerCallbacks.submitUntrustServer(
1929
+ if (this.context.relayer) {
1930
+ const request = {
1931
+ type: "signed",
1932
+ operation: "submitUntrustServer",
1569
1933
  typedData,
1570
1934
  signature
1571
- );
1935
+ };
1936
+ const response = await this.context.relayer(request);
1937
+ if (response.type === "error") {
1938
+ throw new RelayerError(response.error);
1939
+ }
1940
+ if (response.type === "submitted") {
1941
+ hash = response.hash;
1942
+ } else if (response.type === "signed") {
1943
+ hash = response.hash;
1944
+ } else {
1945
+ throw new Error("Unexpected response type from relayer");
1946
+ }
1572
1947
  } else {
1573
1948
  hash = await this.submitSignedUntrustTransaction(typedData, signature);
1574
1949
  }
1575
- return {
1950
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1951
+ const { tx } = await import("../utils/transactionHelpers");
1952
+ return tx({
1576
1953
  hash,
1577
- from: this.context.walletClient.account?.address
1578
- };
1954
+ from: typeof account === "string" ? account : account.address,
1955
+ contract: "DataPortabilityServers",
1956
+ fn: "untrustServerWithSignature"
1957
+ });
1579
1958
  } catch (error) {
1580
1959
  if (error instanceof Error) {
1581
1960
  if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
@@ -1613,8 +1992,8 @@ class PermissionsController {
1613
1992
  */
1614
1993
  async getTrustedServers(userAddress) {
1615
1994
  try {
1616
- const user = userAddress || await this.getUserAddress();
1617
- const chainId = await this.context.walletClient.getChainId();
1995
+ const user = userAddress ?? this.context.userAddress;
1996
+ const chainId = await this.context.publicClient.getChainId();
1618
1997
  const DataPortabilityServersAddress = getContractAddress(
1619
1998
  chainId,
1620
1999
  "DataPortabilityServers"
@@ -1643,8 +2022,8 @@ class PermissionsController {
1643
2022
  */
1644
2023
  async getTrustedServersCount(userAddress) {
1645
2024
  try {
1646
- const user = userAddress || await this.getUserAddress();
1647
- const chainId = await this.context.walletClient.getChainId();
2025
+ const user = userAddress ?? this.context.userAddress;
2026
+ const chainId = await this.context.publicClient.getChainId();
1648
2027
  const DataPortabilityServersAddress = getContractAddress(
1649
2028
  chainId,
1650
2029
  "DataPortabilityServers"
@@ -1673,10 +2052,10 @@ class PermissionsController {
1673
2052
  */
1674
2053
  async getTrustedServersPaginated(options = {}) {
1675
2054
  try {
1676
- const user = options.userAddress || await this.getUserAddress();
1677
- const limit = options.limit || 50;
1678
- const offset = options.offset || 0;
1679
- const chainId = await this.context.walletClient.getChainId();
2055
+ const user = options.userAddress ?? this.context.userAddress;
2056
+ const limit = options.limit ?? 50;
2057
+ const offset = options.offset ?? 0;
2058
+ const chainId = await this.context.publicClient.getChainId();
1680
2059
  const DataPortabilityServersAddress = getContractAddress(
1681
2060
  chainId,
1682
2061
  "DataPortabilityServers"
@@ -1822,7 +2201,7 @@ class PermissionsController {
1822
2201
  };
1823
2202
  }
1824
2203
  try {
1825
- const chainId = await this.context.walletClient.getChainId();
2204
+ const chainId = await this.context.publicClient.getChainId();
1826
2205
  const DataPortabilityServersAddress = getContractAddress(
1827
2206
  chainId,
1828
2207
  "DataPortabilityServers"
@@ -1897,7 +2276,7 @@ class PermissionsController {
1897
2276
  */
1898
2277
  async checkServerTrustStatus(serverId, userAddress) {
1899
2278
  try {
1900
- const user = userAddress || await this.getUserAddress();
2279
+ const user = userAddress ?? this.context.userAddress;
1901
2280
  const trustedServers = await this.getTrustedServers(user);
1902
2281
  const trustIndex = trustedServers.findIndex(
1903
2282
  (server) => server === serverId
@@ -1987,7 +2366,7 @@ class PermissionsController {
1987
2366
  * @returns Promise resolving to the EIP-712 domain configuration
1988
2367
  */
1989
2368
  async getServersDomain() {
1990
- const chainId = await this.context.walletClient.getChainId();
2369
+ const chainId = await this.context.publicClient.getChainId();
1991
2370
  const DataPortabilityServersAddress = getContractAddress(
1992
2371
  chainId,
1993
2372
  "DataPortabilityServers"
@@ -2006,7 +2385,8 @@ class PermissionsController {
2006
2385
  * @param signature - The cryptographic signature for the transaction
2007
2386
  * @returns Promise resolving to the transaction hash
2008
2387
  */
2009
- async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
2388
+ async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature, options) {
2389
+ this.assertWallet();
2010
2390
  const chainId = await this.context.walletClient.getChainId();
2011
2391
  const DataPortabilityServersAddress = getContractAddress(
2012
2392
  chainId,
@@ -2038,8 +2418,17 @@ class PermissionsController {
2038
2418
  },
2039
2419
  formattedSignature
2040
2420
  ],
2041
- account: this.context.walletClient.account || await this.getUserAddress(),
2042
- chain: this.context.walletClient.chain || null
2421
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2422
+ chain: this.context.walletClient?.chain ?? null,
2423
+ ...options && {
2424
+ gas: options.gas,
2425
+ nonce: options.nonce,
2426
+ // Use EIP-1559 gas pricing if available, otherwise legacy
2427
+ ...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
2428
+ maxFeePerGas: options.maxFeePerGas,
2429
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
2430
+ } : options.gasPrice ? { gasPrice: options.gasPrice } : {}
2431
+ }
2043
2432
  });
2044
2433
  return txHash;
2045
2434
  }
@@ -2050,7 +2439,8 @@ class PermissionsController {
2050
2439
  * @param signature - The cryptographic signature for the transaction
2051
2440
  * @returns Promise resolving to the transaction hash
2052
2441
  */
2053
- async submitTrustServerTransaction(trustServerInput, signature) {
2442
+ async submitTrustServerTransaction(trustServerInput, signature, options) {
2443
+ this.assertWallet();
2054
2444
  const chainId = await this.context.walletClient.getChainId();
2055
2445
  const DataPortabilityServersAddress = getContractAddress(
2056
2446
  chainId,
@@ -2069,8 +2459,9 @@ class PermissionsController {
2069
2459
  },
2070
2460
  formattedSignature
2071
2461
  ],
2072
- account: this.context.walletClient.account || await this.getUserAddress(),
2073
- chain: this.context.walletClient.chain || null
2462
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2463
+ chain: this.context.walletClient?.chain ?? null,
2464
+ ...this.spreadTransactionOptions(options)
2074
2465
  });
2075
2466
  return txHash;
2076
2467
  }
@@ -2081,7 +2472,8 @@ class PermissionsController {
2081
2472
  * @param signature - The cryptographic signature authorizing the revoke
2082
2473
  * @returns Promise resolving to the transaction hash
2083
2474
  */
2084
- async submitDirectRevokeTransaction(typedData, signature) {
2475
+ async submitDirectRevokeTransaction(typedData, signature, options) {
2476
+ this.assertWallet();
2085
2477
  const chainId = await this.context.walletClient.getChainId();
2086
2478
  const DataPortabilityPermissionsAddress = getContractAddress(
2087
2479
  chainId,
@@ -2093,10 +2485,18 @@ class PermissionsController {
2093
2485
  address: DataPortabilityPermissionsAddress,
2094
2486
  abi: DataPortabilityPermissionsAbi,
2095
2487
  functionName: "revokePermissionWithSignature",
2096
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2097
2488
  args: [typedData.message, formattedSignature],
2098
- account: this.context.walletClient.account || await this.getUserAddress(),
2099
- chain: this.context.walletClient.chain || null
2489
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2490
+ chain: this.context.walletClient?.chain ?? null,
2491
+ ...options && {
2492
+ gas: options.gas,
2493
+ nonce: options.nonce,
2494
+ // Use EIP-1559 gas pricing if available, otherwise legacy
2495
+ ...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
2496
+ maxFeePerGas: options.maxFeePerGas,
2497
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
2498
+ } : options.gasPrice ? { gasPrice: options.gasPrice } : {}
2499
+ }
2100
2500
  });
2101
2501
  return txHash;
2102
2502
  }
@@ -2107,7 +2507,8 @@ class PermissionsController {
2107
2507
  * @param signature - The cryptographic signature authorizing the untrust
2108
2508
  * @returns Promise resolving to the transaction hash
2109
2509
  */
2110
- async submitSignedUntrustTransaction(typedData, signature) {
2510
+ async submitSignedUntrustTransaction(typedData, signature, options) {
2511
+ this.assertWallet();
2111
2512
  const chainId = await this.context.walletClient.getChainId();
2112
2513
  const DataPortabilityServersAddress = getContractAddress(
2113
2514
  chainId,
@@ -2115,14 +2516,26 @@ class PermissionsController {
2115
2516
  );
2116
2517
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
2117
2518
  const formattedSignature = formatSignatureForContract(signature);
2519
+ const contractMessage = {
2520
+ nonce: typedData.message.nonce,
2521
+ serverId: BigInt(typedData.message.serverId)
2522
+ };
2118
2523
  const txHash = await this.context.walletClient.writeContract({
2119
2524
  address: DataPortabilityServersAddress,
2120
2525
  abi: DataPortabilityServersAbi,
2121
2526
  functionName: "untrustServerWithSignature",
2122
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2123
- args: [typedData.message, formattedSignature],
2124
- account: this.context.walletClient.account || await this.getUserAddress(),
2125
- chain: this.context.walletClient.chain || null
2527
+ args: [contractMessage, formattedSignature],
2528
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2529
+ chain: this.context.walletClient?.chain ?? null,
2530
+ ...options && {
2531
+ gas: options.gas,
2532
+ nonce: options.nonce,
2533
+ // Use EIP-1559 gas pricing if available, otherwise legacy
2534
+ ...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
2535
+ maxFeePerGas: options.maxFeePerGas,
2536
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
2537
+ } : options.gasPrice ? { gasPrice: options.gasPrice } : {}
2538
+ }
2126
2539
  });
2127
2540
  return txHash;
2128
2541
  }
@@ -2135,14 +2548,18 @@ class PermissionsController {
2135
2548
  * A grantee is an entity (like an application) that can receive data permissions
2136
2549
  * from users. Once registered, users can grant the grantee access to their data.
2137
2550
  *
2551
+ * This method supports gasless transactions via relayer when configured.
2552
+ * If no relayer is available, it falls back to direct wallet transactions.
2553
+ *
2138
2554
  * @param params - Parameters for registering the grantee
2139
2555
  * @param params.owner - The Ethereum address that will own this grantee registration
2140
2556
  * @param params.granteeAddress - The Ethereum address of the grantee (application)
2141
2557
  * @param params.publicKey - The public key used for data encryption/decryption (hex string)
2558
+ * @param options - Optional transaction options for gas parameters and timeout
2142
2559
  * @returns Promise resolving to the transaction hash
2143
2560
  * @throws {BlockchainError} When the grantee registration transaction fails
2144
2561
  * @throws {UserRejectedRequestError} When user rejects the transaction
2145
- * @throws {ContractError} When grantee is already registered
2562
+ * @throws {RelayerError} When gasless transaction submission fails
2146
2563
  *
2147
2564
  * @example
2148
2565
  * ```typescript
@@ -2154,86 +2571,88 @@ class PermissionsController {
2154
2571
  * console.log(`Grantee registered in transaction: ${txHash}`);
2155
2572
  * ```
2156
2573
  */
2157
- async submitRegisterGrantee(params) {
2158
- const chainId = await this.context.walletClient.getChainId();
2159
- const DataPortabilityGranteesAddress = getContractAddress(
2160
- chainId,
2161
- "DataPortabilityGrantees"
2162
- );
2163
- const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2164
- const ownerAddress = getAddress(params.owner);
2165
- const granteeAddress = getAddress(params.granteeAddress);
2166
- const txHash = await this.context.walletClient.writeContract({
2167
- address: DataPortabilityGranteesAddress,
2168
- abi: DataPortabilityGranteesAbi,
2169
- functionName: "registerGrantee",
2170
- args: [ownerAddress, granteeAddress, params.publicKey],
2171
- account: this.context.walletClient.account || await this.getUserAddress(),
2172
- chain: this.context.walletClient.chain || null
2173
- });
2174
- return {
2175
- hash: txHash,
2176
- from: this.context.walletClient.account?.address
2177
- };
2178
- }
2179
- /**
2180
- * Registers a grantee with a signature (gasless transaction)
2181
- *
2182
- * @param params - Parameters for registering the grantee
2183
- * @returns Promise resolving to the transaction hash
2184
- *
2185
- * @example
2186
- * ```typescript
2187
- * const txHash = await vana.permissions.registerGranteeWithSignature({
2188
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2189
- * granteeAddress: "0xApp1234567890123456789012345678901234567890",
2190
- * publicKey: "0x1234567890abcdef..."
2191
- * });
2192
- * ```
2193
- */
2194
- async submitRegisterGranteeWithSignature(params) {
2195
- const nonce = await this.getServersUserNonce();
2196
- const owner = getAddress(params.owner);
2197
- const granteeAddress = getAddress(params.granteeAddress);
2198
- const registerGranteeInput = {
2199
- nonce,
2200
- owner,
2201
- granteeAddress,
2202
- publicKey: params.publicKey
2203
- };
2204
- const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
2205
- const signature = await this.signTypedData(typedData);
2206
- const hash = await this.submitSignedRegisterGranteeTransaction(
2207
- typedData,
2208
- signature
2209
- );
2210
- return {
2211
- hash,
2212
- from: this.context.walletClient.account?.address
2213
- };
2214
- }
2215
- /**
2216
- * Submits a signed register grantee transaction via relayer
2217
- *
2218
- * @param typedData - The EIP-712 typed data for register grantee
2219
- * @param signature - The cryptographic signature
2220
- * @returns Promise resolving to the transaction hash
2221
- *
2222
- * @example
2223
- * ```typescript
2224
- * const result = await vana.permissions.submitSignedRegisterGrantee(typedData, signature);
2225
- * ```
2226
- */
2227
- async submitSignedRegisterGrantee(typedData, signature) {
2228
- const hash = await this.submitSignedRegisterGranteeTransaction(
2229
- typedData,
2230
- signature
2231
- );
2232
- return {
2233
- hash,
2234
- from: this.context.walletClient.account?.address
2235
- };
2574
+ async submitRegisterGrantee(params, options) {
2575
+ try {
2576
+ let hash;
2577
+ if (this.context.relayer) {
2578
+ const request = {
2579
+ type: "direct",
2580
+ operation: "submitRegisterGrantee",
2581
+ params: {
2582
+ owner: params.owner,
2583
+ granteeAddress: params.granteeAddress,
2584
+ publicKey: params.publicKey
2585
+ }
2586
+ };
2587
+ const response = await this.context.relayer(request);
2588
+ if (response.type === "error") {
2589
+ throw new RelayerError(response.error);
2590
+ }
2591
+ if (response.type === "submitted") {
2592
+ hash = response.hash;
2593
+ } else if (response.type === "direct") {
2594
+ const result = response.result;
2595
+ hash = result.transactionHash;
2596
+ } else {
2597
+ throw new Error("Unexpected response type from relayer");
2598
+ }
2599
+ } else {
2600
+ this.assertWallet();
2601
+ const chainId = await this.context.walletClient.getChainId();
2602
+ const DataPortabilityGranteesAddress = getContractAddress(
2603
+ chainId,
2604
+ "DataPortabilityGrantees"
2605
+ );
2606
+ const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2607
+ const ownerAddress = getAddress(params.owner);
2608
+ const granteeAddress = getAddress(params.granteeAddress);
2609
+ const account2 = this.context.walletClient?.account ?? this.context.userAddress;
2610
+ hash = await this.context.walletClient.writeContract({
2611
+ address: DataPortabilityGranteesAddress,
2612
+ abi: DataPortabilityGranteesAbi,
2613
+ functionName: "registerGrantee",
2614
+ args: [ownerAddress, granteeAddress, params.publicKey],
2615
+ account: account2,
2616
+ chain: this.context.walletClient?.chain ?? null,
2617
+ ...this.spreadTransactionOptions(options)
2618
+ });
2619
+ }
2620
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
2621
+ const { tx } = await import("../utils/transactionHelpers");
2622
+ return tx({
2623
+ hash,
2624
+ from: typeof account === "string" ? account : account.address,
2625
+ contract: "DataPortabilityGrantees",
2626
+ fn: "registerGrantee"
2627
+ });
2628
+ } catch (error) {
2629
+ if (error instanceof Error) {
2630
+ if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof BlockchainError) {
2631
+ throw error;
2632
+ }
2633
+ if (error.name === "ContractFunctionExecutionError") {
2634
+ throw new BlockchainError(
2635
+ `Grantee registration failed: ${error.message}`,
2636
+ error
2637
+ );
2638
+ }
2639
+ if (error.name === "UserRejectedRequestError") {
2640
+ throw new UserRejectedRequestError(
2641
+ "User rejected the grantee registration transaction"
2642
+ );
2643
+ }
2644
+ throw new BlockchainError(
2645
+ `Failed to register grantee: ${error.message}`,
2646
+ error
2647
+ );
2648
+ }
2649
+ throw new BlockchainError(`Failed to register grantee: ${String(error)}`);
2650
+ }
2236
2651
  }
2652
+ // TODO: When DataPortabilityGrantees contract adds registerGranteeWithSignature function,
2653
+ // implement submitRegisterGranteeWithSignature and submitSignedRegisterGrantee methods
2654
+ // to support EIP-712 signed gasless transactions via relayer.
2655
+ // Current implementation above supports direct gasless transactions (relayer pays gas directly).
2237
2656
  /**
2238
2657
  * Retrieves all registered grantees from the DataPortabilityGrantees contract.
2239
2658
  *
@@ -2279,8 +2698,8 @@ class PermissionsController {
2279
2698
  functionName: "granteesCount"
2280
2699
  });
2281
2700
  const total = Number(totalCount);
2282
- const limit = options.limit || 50;
2283
- const offset = options.offset || 0;
2701
+ const limit = options.limit ?? 50;
2702
+ const offset = options.offset ?? 0;
2284
2703
  const grantees = [];
2285
2704
  const endIndex = Math.min(offset + limit, total);
2286
2705
  for (let i = offset; i < endIndex; i++) {
@@ -2420,67 +2839,6 @@ class PermissionsController {
2420
2839
  return null;
2421
2840
  }
2422
2841
  }
2423
- /**
2424
- * Builds EIP-712 typed data for grantee registration
2425
- *
2426
- * @param input - The register grantee input
2427
- * @returns Promise resolving to the typed data structure
2428
- * @private
2429
- */
2430
- async buildRegisterGranteeTypedData(input) {
2431
- const chainId = await this.context.walletClient.getChainId();
2432
- const verifyingContract = getContractAddress(
2433
- chainId,
2434
- "DataPortabilityGrantees"
2435
- );
2436
- return {
2437
- domain: {
2438
- name: "DataPortabilityGrantees",
2439
- version: "1",
2440
- chainId,
2441
- verifyingContract
2442
- },
2443
- types: {
2444
- RegisterGrantee: [
2445
- { name: "nonce", type: "uint256" },
2446
- { name: "owner", type: "address" },
2447
- { name: "granteeAddress", type: "address" },
2448
- { name: "publicKey", type: "string" }
2449
- ]
2450
- },
2451
- primaryType: "RegisterGrantee",
2452
- message: input
2453
- };
2454
- }
2455
- /**
2456
- * Submits a register grantee transaction with signature.
2457
- *
2458
- * @param typedData - The EIP-712 typed data structure for the registration
2459
- * @param _signature - The cryptographic signature authorizing the registration (currently unused)
2460
- * @returns Promise resolving to the transaction hash
2461
- * @private
2462
- */
2463
- async submitSignedRegisterGranteeTransaction(typedData, _signature) {
2464
- const chainId = await this.context.walletClient.getChainId();
2465
- const DataPortabilityGranteesAddress = getContractAddress(
2466
- chainId,
2467
- "DataPortabilityGrantees"
2468
- );
2469
- const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
2470
- const txHash = await this.context.walletClient.writeContract({
2471
- address: DataPortabilityGranteesAddress,
2472
- abi: DataPortabilityGranteesAbi,
2473
- functionName: "registerGrantee",
2474
- args: [
2475
- typedData.message.owner,
2476
- typedData.message.granteeAddress,
2477
- typedData.message.publicKey
2478
- ],
2479
- account: this.context.walletClient.account || await this.getUserAddress(),
2480
- chain: this.context.walletClient.chain || null
2481
- });
2482
- return txHash;
2483
- }
2484
2842
  // ===========================
2485
2843
  // DATA PORTABILITY SERVERS HELPER METHODS
2486
2844
  // ===========================
@@ -2492,7 +2850,7 @@ class PermissionsController {
2492
2850
  */
2493
2851
  async getUserServerIds(userAddress) {
2494
2852
  try {
2495
- const targetAddress = userAddress || await this.getUserAddress();
2853
+ const targetAddress = userAddress ?? this.context.userAddress;
2496
2854
  const chainId = await this.context.publicClient.getChainId();
2497
2855
  const DataPortabilityServersAddress = getContractAddress(
2498
2856
  chainId,
@@ -2550,7 +2908,7 @@ class PermissionsController {
2550
2908
  */
2551
2909
  async getUserServerCount(userAddress) {
2552
2910
  try {
2553
- const targetAddress = userAddress || await this.getUserAddress();
2911
+ const targetAddress = userAddress ?? this.context.userAddress;
2554
2912
  const chainId = await this.context.publicClient.getChainId();
2555
2913
  const DataPortabilityServersAddress = getContractAddress(
2556
2914
  chainId,
@@ -2579,7 +2937,7 @@ class PermissionsController {
2579
2937
  */
2580
2938
  async getUserTrustedServers(userAddress) {
2581
2939
  try {
2582
- const targetAddress = userAddress || await this.getUserAddress();
2940
+ const targetAddress = userAddress ?? this.context.userAddress;
2583
2941
  const chainId = await this.context.publicClient.getChainId();
2584
2942
  const DataPortabilityServersAddress = getContractAddress(
2585
2943
  chainId,
@@ -2696,7 +3054,7 @@ class PermissionsController {
2696
3054
  */
2697
3055
  async getUserPermissionIds(userAddress) {
2698
3056
  try {
2699
- const targetAddress = userAddress || await this.getUserAddress();
3057
+ const targetAddress = userAddress ?? this.context.userAddress;
2700
3058
  const chainId = await this.context.publicClient.getChainId();
2701
3059
  const DataPortabilityPermissionsAddress = getContractAddress(
2702
3060
  chainId,
@@ -2758,7 +3116,7 @@ class PermissionsController {
2758
3116
  */
2759
3117
  async getUserPermissionCount(userAddress) {
2760
3118
  try {
2761
- const targetAddress = userAddress || await this.getUserAddress();
3119
+ const targetAddress = userAddress ?? this.context.userAddress;
2762
3120
  const chainId = await this.context.publicClient.getChainId();
2763
3121
  const DataPortabilityPermissionsAddress = getContractAddress(
2764
3122
  chainId,
@@ -3200,9 +3558,11 @@ class PermissionsController {
3200
3558
  *
3201
3559
  * @param serverId - Server ID to update
3202
3560
  * @param url - New URL for the server
3561
+ * @param options - Optional transaction options for gas parameters and timeout
3203
3562
  * @returns Promise resolving to transaction hash
3204
3563
  */
3205
- async submitUpdateServer(serverId, url) {
3564
+ async submitUpdateServer(serverId, url, options) {
3565
+ this.assertWallet();
3206
3566
  try {
3207
3567
  const chainId = await this.context.walletClient.getChainId();
3208
3568
  const DataPortabilityServersAddress = getContractAddress(
@@ -3210,18 +3570,33 @@ class PermissionsController {
3210
3570
  "DataPortabilityServers"
3211
3571
  );
3212
3572
  const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
3573
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3213
3574
  const hash = await this.context.walletClient.writeContract({
3214
3575
  address: DataPortabilityServersAddress,
3215
3576
  abi: DataPortabilityServersAbi,
3216
3577
  functionName: "updateServer",
3217
3578
  args: [serverId, url],
3218
- chain: this.context.walletClient.chain,
3219
- account: this.context.walletClient.account || null
3579
+ chain: this.context.walletClient?.chain,
3580
+ account,
3581
+ ...options?.gas && { gas: options.gas },
3582
+ ...options?.nonce && { nonce: options.nonce },
3583
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3584
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3585
+ ...options.maxFeePerGas && {
3586
+ maxFeePerGas: options.maxFeePerGas
3587
+ },
3588
+ ...options.maxPriorityFeePerGas && {
3589
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3590
+ }
3591
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3220
3592
  });
3221
- return {
3593
+ const { tx } = await import("../utils/transactionHelpers");
3594
+ return tx({
3222
3595
  hash,
3223
- from: this.context.walletClient.account?.address
3224
- };
3596
+ from: typeof account === "string" ? account : account.address,
3597
+ contract: "DataPortabilityServers",
3598
+ fn: "updateServer"
3599
+ });
3225
3600
  } catch (error) {
3226
3601
  throw new BlockchainError(
3227
3602
  `Failed to update server: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3371,6 +3746,7 @@ class PermissionsController {
3371
3746
  * @throws {NetworkError} When network communication fails
3372
3747
  */
3373
3748
  async submitAddPermission(params) {
3749
+ this.assertWallet();
3374
3750
  try {
3375
3751
  const nonce = await this.getPermissionsUserNonce();
3376
3752
  const addPermissionInput = {
@@ -3408,24 +3784,43 @@ class PermissionsController {
3408
3784
  * @throws {BlockchainError} When permission addition fails
3409
3785
  * @throws {NetworkError} When network communication fails
3410
3786
  */
3411
- async submitSignedAddPermission(typedData, signature) {
3787
+ async submitSignedAddPermission(typedData, signature, options) {
3788
+ this.assertWallet();
3412
3789
  try {
3413
3790
  let hash;
3414
- if (this.context.relayerCallbacks?.submitAddPermission) {
3415
- hash = await this.context.relayerCallbacks.submitAddPermission(
3791
+ if (this.context.relayer) {
3792
+ const request = {
3793
+ type: "signed",
3794
+ operation: "submitAddPermission",
3416
3795
  typedData,
3417
3796
  signature
3418
- );
3797
+ };
3798
+ const response = await this.context.relayer(request);
3799
+ if (response.type === "error") {
3800
+ throw new RelayerError(response.error);
3801
+ }
3802
+ if (response.type === "submitted") {
3803
+ hash = response.hash;
3804
+ } else if (response.type === "signed") {
3805
+ hash = response.hash;
3806
+ } else {
3807
+ throw new Error("Unexpected response type from relayer");
3808
+ }
3419
3809
  } else {
3420
3810
  hash = await this.submitDirectAddPermissionTransaction(
3421
3811
  typedData,
3422
- signature
3812
+ signature,
3813
+ options
3423
3814
  );
3424
3815
  }
3425
- return {
3816
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3817
+ const { tx } = await import("../utils/transactionHelpers");
3818
+ return tx({
3426
3819
  hash,
3427
- from: this.context.walletClient.account?.address
3428
- };
3820
+ from: typeof account === "string" ? account : account.address,
3821
+ contract: "DataPortabilityPermissions",
3822
+ fn: "addPermission"
3823
+ });
3429
3824
  } catch (error) {
3430
3825
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
3431
3826
  throw error;
@@ -3454,8 +3849,11 @@ class PermissionsController {
3454
3849
  * @param params.serverAddress - Server wallet address for decryption permissions
3455
3850
  * @param params.serverUrl - Server endpoint URL
3456
3851
  * @param params.serverPublicKey - Server's public key for encryption.
3457
- * Obtain via `vana.server.getIdentity(userAddress).public_key`.
3852
+ * Obtain via `vana.server.getIdentity(userAddress).publicKey`.
3458
3853
  * @param params.filePermissions - Nested array of permissions for each file
3854
+ * @param options - Optional transaction options for gas parameters and timeout.
3855
+ * Note: These options are only applied for direct blockchain transactions.
3856
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3459
3857
  * @returns TransactionResult with immediate hash access and optional event data
3460
3858
  * @throws {Error} When schemaIds array length doesn't match fileUrls array length
3461
3859
  * @throws {SchemaValidationError} When file data doesn't match the specified schema.
@@ -3469,6 +3867,7 @@ class PermissionsController {
3469
3867
  *
3470
3868
  * @example
3471
3869
  * ```typescript
3870
+ * // Submit with custom gas parameters and timeout
3472
3871
  * const result = await vana.permissions.submitAddServerFilesAndPermissions({
3473
3872
  * granteeId: BigInt(1),
3474
3873
  * grant: "ipfs://QmXxx...",
@@ -3476,17 +3875,25 @@ class PermissionsController {
3476
3875
  * schemaIds: [123], // LinkedIn profile schema ID
3477
3876
  * serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3478
3877
  * serverUrl: "https://server.example.com",
3479
- * serverPublicKey: serverInfo.public_key,
3878
+ * serverPublicKey: serverInfo.publicKey,
3480
3879
  * filePermissions: [[{
3481
3880
  * account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3482
3881
  * key: encryptedKey
3483
3882
  * }]]
3883
+ * }, {
3884
+ * maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
3885
+ * maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
3484
3886
  * });
3485
- * const events = await result.waitForEvents();
3486
- * console.log(`Permission ID: ${events.permissionId}`);
3887
+ *
3888
+ * // Wait for confirmation with custom timeout
3889
+ * const receipt = await vana.waitForTransactionReceipt(result, {
3890
+ * timeout: 180000 // 3 minutes
3891
+ * });
3892
+ * console.log(`Transaction confirmed: ${receipt.transactionHash}`);
3487
3893
  * ```
3488
3894
  */
3489
- async submitAddServerFilesAndPermissions(params) {
3895
+ async submitAddServerFilesAndPermissions(params, options) {
3896
+ this.assertWallet();
3490
3897
  try {
3491
3898
  if (params.schemaIds.length !== params.fileUrls.length) {
3492
3899
  throw new Error(
@@ -3511,7 +3918,8 @@ class PermissionsController {
3511
3918
  const signature = await this.signTypedData(typedData);
3512
3919
  return await this.submitSignedAddServerFilesAndPermissions(
3513
3920
  typedData,
3514
- signature
3921
+ signature,
3922
+ options
3515
3923
  );
3516
3924
  } catch (error) {
3517
3925
  if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
@@ -3532,6 +3940,9 @@ class PermissionsController {
3532
3940
  *
3533
3941
  * @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
3534
3942
  * @param signature - The user's signature
3943
+ * @param options - Optional transaction options for gas parameters and timeout.
3944
+ * Note: These options are only applied for direct blockchain transactions.
3945
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3535
3946
  * @returns TransactionResult with immediate hash access and optional event data
3536
3947
  * @throws {RelayerError} When gasless transaction submission fails
3537
3948
  * @throws {BlockchainError} When server files and permissions addition fails
@@ -3550,38 +3961,49 @@ class PermissionsController {
3550
3961
  * console.log(`Permission created with ID: ${permissionId}`);
3551
3962
  * ```
3552
3963
  */
3553
- async submitSignedAddServerFilesAndPermissions(typedData, signature) {
3964
+ async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
3965
+ this.assertWallet();
3554
3966
  try {
3555
- console.debug("\u{1F50D} submitSignedAddServerFilesAndPermissions Debug Info:", {
3556
- hasRelayerCallbacks: !!this.context.relayerCallbacks,
3557
- hasSubmitMethod: !!this.context.relayerCallbacks?.submitAddServerFilesAndPermissions,
3558
- availableRelayerMethods: this.context.relayerCallbacks ? Object.keys(this.context.relayerCallbacks) : []
3559
- });
3560
- if (this.context.relayerCallbacks?.submitAddServerFilesAndPermissions) {
3967
+ let hash;
3968
+ if (this.context.relayer) {
3561
3969
  console.debug(
3562
3970
  "\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
3563
3971
  );
3564
- const hash = await this.context.relayerCallbacks.submitAddServerFilesAndPermissions(
3972
+ const request = {
3973
+ type: "signed",
3974
+ operation: "submitAddServerFilesAndPermissions",
3565
3975
  typedData,
3566
3976
  signature
3567
- );
3568
- return {
3569
- hash,
3570
- from: this.context.walletClient.account?.address
3571
3977
  };
3978
+ const response = await this.context.relayer(request);
3979
+ if (response.type === "error") {
3980
+ throw new RelayerError(response.error);
3981
+ }
3982
+ if (response.type === "submitted") {
3983
+ hash = response.hash;
3984
+ } else if (response.type === "signed") {
3985
+ hash = response.hash;
3986
+ } else {
3987
+ throw new Error("Unexpected response type from relayer");
3988
+ }
3572
3989
  } else {
3573
3990
  console.debug(
3574
3991
  "\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
3575
3992
  );
3576
- const hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3993
+ hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3577
3994
  typedData,
3578
- signature
3995
+ signature,
3996
+ options
3579
3997
  );
3580
- return {
3581
- hash,
3582
- from: this.context.walletClient.account?.address
3583
- };
3584
3998
  }
3999
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
4000
+ const { tx } = await import("../utils/transactionHelpers");
4001
+ return tx({
4002
+ hash,
4003
+ from: typeof account === "string" ? account : account.address,
4004
+ contract: "DataPortabilityPermissions",
4005
+ fn: "addServerFilesAndPermissions"
4006
+ });
3585
4007
  } catch (error) {
3586
4008
  if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
3587
4009
  throw error;
@@ -3596,9 +4018,11 @@ class PermissionsController {
3596
4018
  * Submit permission revocation with signature to the blockchain
3597
4019
  *
3598
4020
  * @param permissionId - Permission ID to revoke
4021
+ * @param options - Optional transaction options for gas parameters and timeout
3599
4022
  * @returns Promise resolving to transaction hash
3600
4023
  */
3601
- async submitRevokePermission(permissionId) {
4024
+ async submitRevokePermission(permissionId, options) {
4025
+ this.assertWallet();
3602
4026
  try {
3603
4027
  const chainId = await this.context.walletClient.getChainId();
3604
4028
  const DataPortabilityPermissionsAddress = getContractAddress(
@@ -3608,18 +4032,36 @@ class PermissionsController {
3608
4032
  const DataPortabilityPermissionsAbi = getAbi(
3609
4033
  "DataPortabilityPermissions"
3610
4034
  );
4035
+ const { account } = this.context.walletClient;
4036
+ if (!account) {
4037
+ throw new Error("No wallet account connected");
4038
+ }
3611
4039
  const hash = await this.context.walletClient.writeContract({
3612
4040
  address: DataPortabilityPermissionsAddress,
3613
4041
  abi: DataPortabilityPermissionsAbi,
3614
4042
  functionName: "revokePermission",
3615
4043
  args: [permissionId],
3616
- chain: this.context.walletClient.chain,
3617
- account: this.context.walletClient.account || null
4044
+ chain: this.context.walletClient?.chain,
4045
+ account,
4046
+ ...options?.gas && { gas: options.gas },
4047
+ ...options?.nonce && { nonce: options.nonce },
4048
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
4049
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
4050
+ ...options.maxFeePerGas && {
4051
+ maxFeePerGas: options.maxFeePerGas
4052
+ },
4053
+ ...options.maxPriorityFeePerGas && {
4054
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
4055
+ }
4056
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3618
4057
  });
3619
- return {
4058
+ const { tx } = await import("../utils/transactionHelpers");
4059
+ return tx({
3620
4060
  hash,
3621
- from: this.context.walletClient.account?.address
3622
- };
4061
+ from: typeof account === "string" ? account : account.address,
4062
+ contract: "DataPortabilityPermissions",
4063
+ fn: "revokePermission"
4064
+ });
3623
4065
  } catch (error) {
3624
4066
  throw new BlockchainError(
3625
4067
  `Failed to revoke permission: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3634,7 +4076,8 @@ class PermissionsController {
3634
4076
  * @param signature - The cryptographic signature authorizing the transaction
3635
4077
  * @returns Promise resolving to the transaction hash
3636
4078
  */
3637
- async submitDirectAddPermissionTransaction(typedData, signature) {
4079
+ async submitDirectAddPermissionTransaction(typedData, signature, options) {
4080
+ this.assertWallet();
3638
4081
  const chainId = await this.context.walletClient.getChainId();
3639
4082
  const DataPortabilityPermissionsAddress = getContractAddress(
3640
4083
  chainId,
@@ -3645,7 +4088,7 @@ class PermissionsController {
3645
4088
  nonce: typedData.message.nonce,
3646
4089
  granteeId: typedData.message.granteeId,
3647
4090
  grant: typedData.message.grant,
3648
- fileIds: typedData.message.fileIds || []
4091
+ fileIds: typedData.message.fileIds ?? []
3649
4092
  };
3650
4093
  const formattedSignature = formatSignatureForContract(signature);
3651
4094
  const hash = await this.context.walletClient.writeContract({
@@ -3653,8 +4096,9 @@ class PermissionsController {
3653
4096
  abi: DataPortabilityPermissionsAbi,
3654
4097
  functionName: "addPermission",
3655
4098
  args: [permissionInput, formattedSignature],
3656
- account: this.context.walletClient.account || await this.getUserAddress(),
3657
- chain: this.context.walletClient.chain || null
4099
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4100
+ chain: this.context.walletClient?.chain ?? null,
4101
+ ...this.spreadTransactionOptions(options)
3658
4102
  });
3659
4103
  return hash;
3660
4104
  }
@@ -3665,8 +4109,9 @@ class PermissionsController {
3665
4109
  * @param signature - The cryptographic signature authorizing the transaction
3666
4110
  * @returns Promise resolving to the transaction hash
3667
4111
  */
3668
- async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
3669
- const chainId = await this.context.walletClient.getChainId();
4112
+ async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
4113
+ this.assertWallet();
4114
+ const chainId = await this.context.publicClient.getChainId();
3670
4115
  const DataPortabilityPermissionsAddress = getContractAddress(
3671
4116
  chainId,
3672
4117
  "DataPortabilityPermissions"
@@ -3688,10 +4133,11 @@ class PermissionsController {
3688
4133
  address: DataPortabilityPermissionsAddress,
3689
4134
  abi: DataPortabilityPermissionsAbi,
3690
4135
  functionName: "addServerFilesAndPermissions",
3691
- // @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
3692
4136
  args: [serverFilesAndPermissionInput, formattedSignature],
3693
- account: this.context.walletClient.account || await this.getUserAddress(),
3694
- chain: this.context.walletClient.chain || null
4137
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4138
+ chain: this.context.walletClient?.chain ?? null,
4139
+ ...options?.value && { value: options.value },
4140
+ ...this.spreadTransactionOptions(options)
3695
4141
  });
3696
4142
  return hash;
3697
4143
  }