@opendatalabs/vana-sdk 0.1.0-alpha.eebb656 → 0.1.0-alpha.ef15099

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 (545) hide show
  1. package/README.md +67 -351
  2. package/dist/browser.cjs.map +1 -1
  3. package/dist/browser.d.ts +33 -1
  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 +2 -0
  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 +30 -1
  12. package/dist/chains/index.js.map +1 -1
  13. package/dist/client/enhancedResponse.cjs +164 -0
  14. package/dist/client/enhancedResponse.cjs.map +1 -0
  15. package/dist/client/enhancedResponse.d.ts +120 -0
  16. package/dist/client/enhancedResponse.js +138 -0
  17. package/dist/client/enhancedResponse.js.map +1 -0
  18. package/dist/config/chains.cjs.map +1 -1
  19. package/dist/config/chains.d.ts +99 -0
  20. package/dist/config/chains.js.map +1 -1
  21. package/dist/config/contracts.config.cjs +400 -0
  22. package/dist/config/contracts.config.cjs.map +1 -0
  23. package/dist/config/contracts.config.d.ts +84 -0
  24. package/dist/config/contracts.config.js +375 -0
  25. package/dist/config/contracts.config.js.map +1 -0
  26. package/dist/config/default-services.cjs +60 -0
  27. package/dist/config/default-services.cjs.map +1 -0
  28. package/dist/config/default-services.d.ts +46 -0
  29. package/dist/config/default-services.js +33 -0
  30. package/dist/config/default-services.js.map +1 -0
  31. package/dist/config/default-services.test.d.ts +1 -0
  32. package/dist/contracts/contractController.cjs +1 -1
  33. package/dist/contracts/contractController.cjs.map +1 -1
  34. package/dist/contracts/contractController.d.ts +66 -10
  35. package/dist/contracts/contractController.js +1 -1
  36. package/dist/contracts/contractController.js.map +1 -1
  37. package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
  38. package/dist/controllers/__tests__/operations.processQueue.test.d.ts +1 -0
  39. package/dist/controllers/accessSettlement.cjs +289 -0
  40. package/dist/controllers/accessSettlement.cjs.map +1 -0
  41. package/dist/controllers/accessSettlement.d.ts +157 -0
  42. package/dist/controllers/accessSettlement.js +265 -0
  43. package/dist/controllers/accessSettlement.js.map +1 -0
  44. package/dist/controllers/accessSettlement.test.d.ts +1 -0
  45. package/dist/controllers/base.cjs +116 -0
  46. package/dist/controllers/base.cjs.map +1 -0
  47. package/dist/controllers/base.d.ts +94 -0
  48. package/dist/controllers/base.js +92 -0
  49. package/dist/controllers/base.js.map +1 -0
  50. package/dist/controllers/data.cjs +634 -352
  51. package/dist/controllers/data.cjs.map +1 -1
  52. package/dist/controllers/data.d.ts +348 -213
  53. package/dist/controllers/data.js +647 -355
  54. package/dist/controllers/data.js.map +1 -1
  55. package/dist/controllers/operations.cjs +430 -0
  56. package/dist/controllers/operations.cjs.map +1 -0
  57. package/dist/controllers/operations.d.ts +229 -0
  58. package/dist/controllers/operations.js +406 -0
  59. package/dist/controllers/operations.js.map +1 -0
  60. package/dist/controllers/permissions.cjs +943 -443
  61. package/dist/controllers/permissions.cjs.map +1 -1
  62. package/dist/controllers/permissions.d.ts +201 -120
  63. package/dist/controllers/permissions.js +943 -443
  64. package/dist/controllers/permissions.js.map +1 -1
  65. package/dist/controllers/protocol.cjs +14 -10
  66. package/dist/controllers/protocol.cjs.map +1 -1
  67. package/dist/controllers/protocol.d.ts +30 -31
  68. package/dist/controllers/protocol.js +14 -10
  69. package/dist/controllers/protocol.js.map +1 -1
  70. package/dist/controllers/runtimePermissions.cjs +272 -0
  71. package/dist/controllers/runtimePermissions.cjs.map +1 -0
  72. package/dist/controllers/runtimePermissions.d.ts +152 -0
  73. package/dist/controllers/runtimePermissions.js +251 -0
  74. package/dist/controllers/runtimePermissions.js.map +1 -0
  75. package/dist/controllers/runtimePermissions.test.d.ts +1 -0
  76. package/dist/controllers/schemas.cjs +113 -43
  77. package/dist/controllers/schemas.cjs.map +1 -1
  78. package/dist/controllers/schemas.d.ts +90 -43
  79. package/dist/controllers/schemas.js +113 -43
  80. package/dist/controllers/schemas.js.map +1 -1
  81. package/dist/controllers/server.cjs +276 -60
  82. package/dist/controllers/server.cjs.map +1 -1
  83. package/dist/controllers/server.d.ts +159 -54
  84. package/dist/controllers/server.js +276 -60
  85. package/dist/controllers/server.js.map +1 -1
  86. package/dist/core/__tests__/health.test.d.ts +1 -0
  87. package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
  88. package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
  89. package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
  90. package/dist/core/apiClient.cjs +53 -3
  91. package/dist/core/apiClient.cjs.map +1 -1
  92. package/dist/core/apiClient.d.ts +132 -7
  93. package/dist/core/apiClient.js +53 -3
  94. package/dist/core/apiClient.js.map +1 -1
  95. package/dist/core/generics.cjs +30 -3
  96. package/dist/core/generics.cjs.map +1 -1
  97. package/dist/core/generics.d.ts +95 -6
  98. package/dist/core/generics.js +30 -3
  99. package/dist/core/generics.js.map +1 -1
  100. package/dist/core/health.cjs +289 -0
  101. package/dist/core/health.cjs.map +1 -0
  102. package/dist/core/health.d.ts +143 -0
  103. package/dist/core/health.js +265 -0
  104. package/dist/core/health.js.map +1 -0
  105. package/dist/core/inMemoryNonceManager.cjs +138 -0
  106. package/dist/core/inMemoryNonceManager.cjs.map +1 -0
  107. package/dist/core/inMemoryNonceManager.d.ts +69 -0
  108. package/dist/core/inMemoryNonceManager.js +114 -0
  109. package/dist/core/inMemoryNonceManager.js.map +1 -0
  110. package/dist/core/nonceManager.cjs +304 -0
  111. package/dist/core/nonceManager.cjs.map +1 -0
  112. package/dist/core/nonceManager.d.ts +116 -0
  113. package/dist/core/nonceManager.js +280 -0
  114. package/dist/core/nonceManager.js.map +1 -0
  115. package/dist/core/pollingManager.cjs +292 -0
  116. package/dist/core/pollingManager.cjs.map +1 -0
  117. package/dist/core/pollingManager.d.ts +120 -0
  118. package/dist/core/pollingManager.js +268 -0
  119. package/dist/core/pollingManager.js.map +1 -0
  120. package/dist/core.cjs +164 -36
  121. package/dist/core.cjs.map +1 -1
  122. package/dist/core.d.ts +69 -10
  123. package/dist/core.js +167 -37
  124. package/dist/core.js.map +1 -1
  125. package/dist/crypto/ecies/__tests__/constants.test.d.ts +1 -1
  126. package/dist/crypto/ecies/__tests__/interface.test.d.ts +1 -0
  127. package/dist/crypto/ecies/__tests__/serialization.test.d.ts +8 -0
  128. package/dist/crypto/ecies/__tests__/utils.test.d.ts +1 -0
  129. package/dist/crypto/ecies/base.cjs +59 -23
  130. package/dist/crypto/ecies/base.cjs.map +1 -1
  131. package/dist/crypto/ecies/base.js +59 -23
  132. package/dist/crypto/ecies/base.js.map +1 -1
  133. package/dist/crypto/ecies/constants.cjs +2 -10
  134. package/dist/crypto/ecies/constants.cjs.map +1 -1
  135. package/dist/crypto/ecies/constants.d.ts +0 -9
  136. package/dist/crypto/ecies/constants.js +1 -8
  137. package/dist/crypto/ecies/constants.js.map +1 -1
  138. package/dist/crypto/ecies/interface.cjs +19 -2
  139. package/dist/crypto/ecies/interface.cjs.map +1 -1
  140. package/dist/crypto/ecies/interface.js +19 -2
  141. package/dist/crypto/ecies/interface.js.map +1 -1
  142. package/dist/errors.cjs +45 -0
  143. package/dist/errors.cjs.map +1 -1
  144. package/dist/errors.d.ts +104 -0
  145. package/dist/errors.js +43 -0
  146. package/dist/errors.js.map +1 -1
  147. package/dist/generated/abi/AccessSettlementImplementation.cjs +635 -0
  148. package/dist/generated/abi/AccessSettlementImplementation.cjs.map +1 -0
  149. package/dist/generated/abi/AccessSettlementImplementation.d.ts +468 -0
  150. package/dist/generated/abi/AccessSettlementImplementation.js +611 -0
  151. package/dist/generated/abi/AccessSettlementImplementation.js.map +1 -0
  152. package/dist/generated/abi/AttestationPolicyImplementation.cjs +614 -0
  153. package/dist/generated/abi/AttestationPolicyImplementation.cjs.map +1 -0
  154. package/dist/generated/abi/AttestationPolicyImplementation.d.ts +449 -0
  155. package/dist/generated/abi/AttestationPolicyImplementation.js +590 -0
  156. package/dist/generated/abi/AttestationPolicyImplementation.js.map +1 -0
  157. package/dist/generated/abi/ComputeEngineImplementation.cjs.map +1 -1
  158. package/dist/generated/abi/ComputeEngineImplementation.js.map +1 -1
  159. package/dist/generated/abi/{DLPTreasuryImplementation.cjs → ComputeEngineTreasuryImplementation.cjs} +16 -92
  160. package/dist/generated/abi/ComputeEngineTreasuryImplementation.cjs.map +1 -0
  161. package/dist/generated/abi/{DLPTreasuryImplementation.d.ts → ComputeEngineTreasuryImplementation.d.ts} +9 -67
  162. package/dist/generated/abi/{DLPTreasuryImplementation.js → ComputeEngineTreasuryImplementation.js} +12 -88
  163. package/dist/generated/abi/ComputeEngineTreasuryImplementation.js.map +1 -0
  164. package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -1
  165. package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -1
  166. package/dist/generated/abi/DATFactoryImplementation.cjs.map +1 -1
  167. package/dist/generated/abi/DATFactoryImplementation.js.map +1 -1
  168. package/dist/generated/abi/DATImplementation.cjs.map +1 -1
  169. package/dist/generated/abi/DATImplementation.js.map +1 -1
  170. package/dist/generated/abi/DATPausableImplementation.cjs.map +1 -1
  171. package/dist/generated/abi/DATPausableImplementation.js.map +1 -1
  172. package/dist/generated/abi/DATVotesImplementation.cjs.map +1 -1
  173. package/dist/generated/abi/DATVotesImplementation.js.map +1 -1
  174. package/dist/generated/abi/DLPPerformanceImplementation.cjs +42 -0
  175. package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -1
  176. package/dist/generated/abi/DLPPerformanceImplementation.d.ts +32 -0
  177. package/dist/generated/abi/DLPPerformanceImplementation.js +42 -0
  178. package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -1
  179. package/dist/generated/abi/DLPRegistryImplementation.cjs +5 -5
  180. package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -1
  181. package/dist/generated/abi/DLPRegistryImplementation.d.ts +4 -4
  182. package/dist/generated/abi/DLPRegistryImplementation.js +5 -5
  183. package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -1
  184. package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs.map +1 -1
  185. package/dist/generated/abi/DLPRegistryTreasuryImplementation.js.map +1 -1
  186. package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +166 -2
  187. package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -1
  188. package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +129 -2
  189. package/dist/generated/abi/DLPRewardDeployerImplementation.js +166 -2
  190. package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -1
  191. package/dist/generated/abi/DLPRewardSwapImplementation.cjs.map +1 -1
  192. package/dist/generated/abi/DLPRewardSwapImplementation.js.map +1 -1
  193. package/dist/generated/abi/DataLiquidityPoolImplementation.cjs +282 -100
  194. package/dist/generated/abi/DataLiquidityPoolImplementation.cjs.map +1 -1
  195. package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +218 -79
  196. package/dist/generated/abi/DataLiquidityPoolImplementation.js +281 -99
  197. package/dist/generated/abi/DataLiquidityPoolImplementation.js.map +1 -1
  198. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +167 -19
  199. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -1
  200. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +127 -14
  201. package/dist/generated/abi/DataPortabilityGranteesImplementation.js +167 -19
  202. package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -1
  203. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +0 -19
  204. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -1
  205. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +0 -14
  206. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +0 -19
  207. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -1
  208. package/dist/generated/abi/DataPortabilityServersImplementation.cjs +0 -19
  209. package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -1
  210. package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +0 -14
  211. package/dist/generated/abi/DataPortabilityServersImplementation.js +0 -19
  212. package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -1
  213. package/dist/generated/abi/DataRefinerRegistryImplementation.cjs.map +1 -1
  214. package/dist/generated/abi/DataRefinerRegistryImplementation.js.map +1 -1
  215. package/dist/generated/abi/DataRegistryImplementation.cjs +0 -13
  216. package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
  217. package/dist/generated/abi/DataRegistryImplementation.d.ts +0 -10
  218. package/dist/generated/abi/DataRegistryImplementation.js +0 -13
  219. package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
  220. package/dist/generated/abi/DatasetRegistryImplementation.cjs +751 -0
  221. package/dist/generated/abi/DatasetRegistryImplementation.cjs.map +1 -0
  222. package/dist/generated/abi/DatasetRegistryImplementation.d.ts +557 -0
  223. package/dist/generated/abi/DatasetRegistryImplementation.js +727 -0
  224. package/dist/generated/abi/DatasetRegistryImplementation.js.map +1 -0
  225. package/dist/generated/abi/ProtocolConfigImplementation.cjs +578 -0
  226. package/dist/generated/abi/ProtocolConfigImplementation.cjs.map +1 -0
  227. package/dist/generated/abi/ProtocolConfigImplementation.d.ts +423 -0
  228. package/dist/generated/abi/ProtocolConfigImplementation.js +554 -0
  229. package/dist/generated/abi/ProtocolConfigImplementation.js.map +1 -0
  230. package/dist/generated/abi/QueryEngineImplementation.cjs.map +1 -1
  231. package/dist/generated/abi/QueryEngineImplementation.js.map +1 -1
  232. package/dist/generated/abi/SwapHelperImplementation.cjs +0 -43
  233. package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -1
  234. package/dist/generated/abi/SwapHelperImplementation.d.ts +0 -35
  235. package/dist/generated/abi/SwapHelperImplementation.js +0 -43
  236. package/dist/generated/abi/SwapHelperImplementation.js.map +1 -1
  237. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs.map +1 -1
  238. package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js.map +1 -1
  239. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs.map +1 -1
  240. package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js.map +1 -1
  241. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs.map +1 -1
  242. package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js.map +1 -1
  243. package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs.map +1 -1
  244. package/dist/generated/abi/TeePoolPersistentGpuImplementation.js.map +1 -1
  245. package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs.map +1 -1
  246. package/dist/generated/abi/TeePoolPersistentStandardImplementation.js.map +1 -1
  247. package/dist/generated/abi/TeePoolPhalaImplementation.cjs.map +1 -1
  248. package/dist/generated/abi/TeePoolPhalaImplementation.js.map +1 -1
  249. package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.cjs +1251 -0
  250. package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.cjs.map +1 -0
  251. package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.d.ts +948 -0
  252. package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.js +1227 -0
  253. package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.js.map +1 -0
  254. package/dist/generated/abi/UniswapV3QuoterV2Implementation.cjs +297 -0
  255. package/dist/generated/abi/UniswapV3QuoterV2Implementation.cjs.map +1 -0
  256. package/dist/generated/abi/UniswapV3QuoterV2Implementation.d.ts +206 -0
  257. package/dist/generated/abi/UniswapV3QuoterV2Implementation.js +273 -0
  258. package/dist/generated/abi/UniswapV3QuoterV2Implementation.js.map +1 -0
  259. package/dist/generated/abi/VanaEpochImplementation.cjs +195 -0
  260. package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -1
  261. package/dist/generated/abi/VanaEpochImplementation.d.ts +151 -0
  262. package/dist/generated/abi/VanaEpochImplementation.js +195 -0
  263. package/dist/generated/abi/VanaEpochImplementation.js.map +1 -1
  264. package/dist/generated/abi/VanaPoolEntityImplementation.cjs +22 -65
  265. package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -1
  266. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +17 -51
  267. package/dist/generated/abi/VanaPoolEntityImplementation.js +22 -65
  268. package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -1
  269. package/dist/generated/abi/VanaPoolStakingImplementation.cjs +113 -1
  270. package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -1
  271. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +85 -1
  272. package/dist/generated/abi/VanaPoolStakingImplementation.js +113 -1
  273. package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -1
  274. package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs.map +1 -1
  275. package/dist/generated/abi/VanaPoolTreasuryImplementation.js.map +1 -1
  276. package/dist/generated/abi/VanaRuntimePermissionsImplementation.cjs +759 -0
  277. package/dist/generated/abi/VanaRuntimePermissionsImplementation.cjs.map +1 -0
  278. package/dist/generated/abi/VanaRuntimePermissionsImplementation.d.ts +563 -0
  279. package/dist/generated/abi/VanaRuntimePermissionsImplementation.js +735 -0
  280. package/dist/generated/abi/VanaRuntimePermissionsImplementation.js.map +1 -0
  281. package/dist/generated/abi/VanaRuntimeServersImplementation.cjs +820 -0
  282. package/dist/generated/abi/VanaRuntimeServersImplementation.cjs.map +1 -0
  283. package/dist/generated/abi/VanaRuntimeServersImplementation.d.ts +609 -0
  284. package/dist/generated/abi/VanaRuntimeServersImplementation.js +796 -0
  285. package/dist/generated/abi/VanaRuntimeServersImplementation.js.map +1 -0
  286. package/dist/generated/abi/VanaTreasuryImplementation.cjs +536 -0
  287. package/dist/generated/abi/VanaTreasuryImplementation.cjs.map +1 -0
  288. package/dist/generated/abi/VanaTreasuryImplementation.d.ts +393 -0
  289. package/dist/generated/abi/VanaTreasuryImplementation.js +512 -0
  290. package/dist/generated/abi/VanaTreasuryImplementation.js.map +1 -0
  291. package/dist/generated/abi/WVANAImplementation.cjs +339 -0
  292. package/dist/generated/abi/WVANAImplementation.cjs.map +1 -0
  293. package/dist/generated/abi/WVANAImplementation.d.ts +244 -0
  294. package/dist/generated/abi/WVANAImplementation.js +315 -0
  295. package/dist/generated/abi/WVANAImplementation.js.map +1 -0
  296. package/dist/generated/abi/index.cjs +79 -47
  297. package/dist/generated/abi/index.cjs.map +1 -1
  298. package/dist/generated/abi/index.d.ts +15783 -10449
  299. package/dist/generated/abi/index.js +65 -43
  300. package/dist/generated/abi/index.js.map +1 -1
  301. package/dist/{config → generated}/addresses.cjs +174 -75
  302. package/dist/generated/addresses.cjs.map +1 -0
  303. package/dist/{config → generated}/addresses.d.ts +174 -165
  304. package/dist/{config → generated}/addresses.js +174 -75
  305. package/dist/generated/addresses.js.map +1 -0
  306. package/dist/generated/event-types.cjs.map +1 -1
  307. package/dist/generated/event-types.d.ts +482 -399
  308. package/dist/generated/eventRegistry.cjs +2601 -724
  309. package/dist/generated/eventRegistry.cjs.map +1 -1
  310. package/dist/generated/eventRegistry.d.ts +2 -2
  311. package/dist/generated/eventRegistry.js +2601 -724
  312. package/dist/generated/eventRegistry.js.map +1 -1
  313. package/dist/generated/server/server-exports.cjs +22 -0
  314. package/dist/generated/server/server-exports.cjs.map +1 -1
  315. package/dist/generated/server/server-exports.d.ts +31 -11
  316. package/dist/generated/server/server-exports.js +17 -0
  317. package/dist/generated/server/server-exports.js.map +1 -1
  318. package/dist/generated/server/server.cjs.map +1 -1
  319. package/dist/generated/server/server.d.ts +771 -402
  320. package/dist/generated/subgraph.cjs +797 -32
  321. package/dist/generated/subgraph.cjs.map +1 -1
  322. package/dist/generated/subgraph.d.ts +135 -0
  323. package/dist/generated/subgraph.js +792 -32
  324. package/dist/generated/subgraph.js.map +1 -1
  325. package/dist/index.browser.d.ts +6 -1
  326. package/dist/index.browser.js +26 -1
  327. package/dist/index.browser.js.map +1 -1
  328. package/dist/index.cjs.map +1 -1
  329. package/dist/index.js.map +1 -1
  330. package/dist/index.node.cjs +47 -4
  331. package/dist/index.node.cjs.map +1 -1
  332. package/dist/index.node.d.ts +60 -14
  333. package/dist/index.node.js +42 -3
  334. package/dist/index.node.js.map +1 -1
  335. package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
  336. package/dist/lib/redisAtomicStore.cjs +201 -0
  337. package/dist/lib/redisAtomicStore.cjs.map +1 -0
  338. package/dist/lib/redisAtomicStore.d.ts +120 -0
  339. package/dist/lib/redisAtomicStore.js +177 -0
  340. package/dist/lib/redisAtomicStore.js.map +1 -0
  341. package/dist/node.cjs.map +1 -1
  342. package/dist/node.d.ts +39 -1
  343. package/dist/node.js.map +1 -1
  344. package/dist/platform/browser.cjs +160 -2
  345. package/dist/platform/browser.cjs.map +1 -1
  346. package/dist/platform/browser.d.ts +232 -12
  347. package/dist/platform/browser.js +160 -2
  348. package/dist/platform/browser.js.map +1 -1
  349. package/dist/platform/interface.cjs.map +1 -1
  350. package/dist/platform/interface.d.ts +283 -90
  351. package/dist/platform/node.cjs +163 -2
  352. package/dist/platform/node.cjs.map +1 -1
  353. package/dist/platform/node.d.ts +69 -6
  354. package/dist/platform/node.js +163 -2
  355. package/dist/platform/node.js.map +1 -1
  356. package/dist/server/relayerHandler.cjs +452 -0
  357. package/dist/server/relayerHandler.cjs.map +1 -0
  358. package/dist/server/relayerHandler.d.ts +69 -0
  359. package/dist/server/relayerHandler.js +428 -0
  360. package/dist/server/relayerHandler.js.map +1 -0
  361. package/dist/storage/index.cjs +3 -0
  362. package/dist/storage/index.cjs.map +1 -1
  363. package/dist/storage/index.d.ts +1 -0
  364. package/dist/storage/index.js +2 -0
  365. package/dist/storage/index.js.map +1 -1
  366. package/dist/storage/manager.cjs +108 -25
  367. package/dist/storage/manager.cjs.map +1 -1
  368. package/dist/storage/manager.d.ts +119 -25
  369. package/dist/storage/manager.js +108 -25
  370. package/dist/storage/manager.js.map +1 -1
  371. package/dist/storage/providers/callback-storage.cjs +86 -15
  372. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  373. package/dist/storage/providers/callback-storage.d.ts +109 -20
  374. package/dist/storage/providers/callback-storage.js +86 -15
  375. package/dist/storage/providers/callback-storage.js.map +1 -1
  376. package/dist/storage/providers/dropbox.cjs +237 -0
  377. package/dist/storage/providers/dropbox.cjs.map +1 -0
  378. package/dist/storage/providers/dropbox.d.ts +39 -0
  379. package/dist/storage/providers/dropbox.js +215 -0
  380. package/dist/storage/providers/dropbox.js.map +1 -0
  381. package/dist/storage/providers/dropbox.test.d.ts +1 -0
  382. package/dist/storage/providers/pinata.cjs.map +1 -1
  383. package/dist/storage/providers/pinata.d.ts +12 -14
  384. package/dist/storage/providers/pinata.js.map +1 -1
  385. package/dist/tests/data-upload-owner-validation.test.d.ts +1 -0
  386. package/dist/tests/factories/mockFactory.d.ts +6 -6
  387. package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +2 -2
  388. package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
  389. package/dist/tests/permissions-transaction-options.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/server-relayer-handler.test.d.ts +1 -0
  394. package/dist/types/accessSettlement.cjs +17 -0
  395. package/dist/types/accessSettlement.cjs.map +1 -0
  396. package/dist/types/accessSettlement.d.ts +66 -0
  397. package/dist/types/accessSettlement.js +1 -0
  398. package/dist/types/accessSettlement.js.map +1 -0
  399. package/dist/types/atomicStore.cjs +31 -0
  400. package/dist/types/atomicStore.cjs.map +1 -0
  401. package/dist/types/atomicStore.d.ts +236 -0
  402. package/dist/types/atomicStore.js +7 -0
  403. package/dist/types/atomicStore.js.map +1 -0
  404. package/dist/types/blockchain.cjs.map +1 -1
  405. package/dist/types/blockchain.d.ts +39 -11
  406. package/dist/types/chains.cjs.map +1 -1
  407. package/dist/types/chains.d.ts +74 -7
  408. package/dist/types/chains.js.map +1 -1
  409. package/dist/types/config.cjs +10 -0
  410. package/dist/types/config.cjs.map +1 -1
  411. package/dist/types/config.d.ts +217 -220
  412. package/dist/types/config.js +8 -0
  413. package/dist/types/config.js.map +1 -1
  414. package/dist/types/contracts.cjs.map +1 -1
  415. package/dist/types/contracts.d.ts +71 -7
  416. package/dist/types/controller-context.cjs.map +1 -1
  417. package/dist/types/controller-context.d.ts +12 -6
  418. package/dist/types/data.cjs.map +1 -1
  419. package/dist/types/data.d.ts +82 -10
  420. package/dist/types/generics.cjs.map +1 -1
  421. package/dist/types/generics.d.ts +81 -10
  422. package/dist/types/index.cjs +4 -0
  423. package/dist/types/index.cjs.map +1 -1
  424. package/dist/types/index.d.ts +36 -6
  425. package/dist/types/index.js +9 -1
  426. package/dist/types/index.js.map +1 -1
  427. package/dist/types/operationStore.cjs +17 -0
  428. package/dist/types/operationStore.cjs.map +1 -0
  429. package/dist/types/operationStore.d.ts +171 -0
  430. package/dist/types/operationStore.js +1 -0
  431. package/dist/types/operationStore.js.map +1 -0
  432. package/dist/types/operations.cjs +3 -15
  433. package/dist/types/operations.cjs.map +1 -1
  434. package/dist/types/operations.d.ts +131 -39
  435. package/dist/types/operations.js +2 -13
  436. package/dist/types/operations.js.map +1 -1
  437. package/dist/types/options.cjs +17 -0
  438. package/dist/types/options.cjs.map +1 -0
  439. package/dist/types/options.d.ts +308 -0
  440. package/dist/types/options.js +1 -0
  441. package/dist/types/options.js.map +1 -0
  442. package/dist/types/permissions.cjs.map +1 -1
  443. package/dist/types/permissions.d.ts +19 -20
  444. package/dist/types/personal.cjs.map +1 -1
  445. package/dist/types/personal.d.ts +150 -14
  446. package/dist/types/relayer.cjs.map +1 -1
  447. package/dist/types/relayer.d.ts +307 -35
  448. package/dist/types/runtimePermissions.cjs +17 -0
  449. package/dist/types/runtimePermissions.cjs.map +1 -0
  450. package/dist/types/runtimePermissions.d.ts +122 -0
  451. package/dist/types/runtimePermissions.js +1 -0
  452. package/dist/types/runtimePermissions.js.map +1 -0
  453. package/dist/types/storage.cjs.map +1 -1
  454. package/dist/types/storage.d.ts +9 -21
  455. package/dist/types/storage.js.map +1 -1
  456. package/dist/types/utils.cjs.map +1 -1
  457. package/dist/types/utils.d.ts +0 -45
  458. package/dist/utils/__tests__/chainQuery.test.d.ts +1 -0
  459. package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
  460. package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
  461. package/dist/utils/blockchain/registry.cjs +3 -3
  462. package/dist/utils/blockchain/registry.cjs.map +1 -1
  463. package/dist/utils/blockchain/registry.d.ts +1 -1
  464. package/dist/utils/blockchain/registry.js +3 -3
  465. package/dist/utils/blockchain/registry.js.map +1 -1
  466. package/dist/utils/chainQuery.cjs +107 -0
  467. package/dist/utils/chainQuery.cjs.map +1 -0
  468. package/dist/utils/chainQuery.d.ts +31 -0
  469. package/dist/utils/chainQuery.js +82 -0
  470. package/dist/utils/chainQuery.js.map +1 -0
  471. package/dist/utils/grantFiles.cjs +4 -1
  472. package/dist/utils/grantFiles.cjs.map +1 -1
  473. package/dist/utils/grantFiles.d.ts +10 -20
  474. package/dist/utils/grantFiles.js +4 -1
  475. package/dist/utils/grantFiles.js.map +1 -1
  476. package/dist/utils/grantValidation.cjs.map +1 -1
  477. package/dist/utils/grantValidation.d.ts +95 -16
  478. package/dist/utils/grantValidation.js.map +1 -1
  479. package/dist/utils/grants.cjs.map +1 -1
  480. package/dist/utils/grants.d.ts +93 -12
  481. package/dist/utils/grants.js.map +1 -1
  482. package/dist/utils/ipfs.cjs +2 -4
  483. package/dist/utils/ipfs.cjs.map +1 -1
  484. package/dist/utils/ipfs.d.ts +1 -1
  485. package/dist/utils/ipfs.js +2 -4
  486. package/dist/utils/ipfs.js.map +1 -1
  487. package/dist/utils/lazy-import.cjs.map +1 -1
  488. package/dist/utils/lazy-import.d.ts +32 -7
  489. package/dist/utils/lazy-import.js.map +1 -1
  490. package/dist/utils/multicall.cjs +1 -1
  491. package/dist/utils/multicall.cjs.map +1 -1
  492. package/dist/utils/multicall.js +1 -1
  493. package/dist/utils/multicall.js.map +1 -1
  494. package/dist/utils/runtimeGrantFiles.cjs +84 -0
  495. package/dist/utils/runtimeGrantFiles.cjs.map +1 -0
  496. package/dist/utils/runtimeGrantFiles.d.ts +66 -0
  497. package/dist/utils/runtimeGrantFiles.js +58 -0
  498. package/dist/utils/runtimeGrantFiles.js.map +1 -0
  499. package/dist/utils/signatureCache.cjs +8 -2
  500. package/dist/utils/signatureCache.cjs.map +1 -1
  501. package/dist/utils/signatureCache.d.ts +49 -8
  502. package/dist/utils/signatureCache.js +8 -2
  503. package/dist/utils/signatureCache.js.map +1 -1
  504. package/dist/utils/subgraphConsistency.cjs +184 -0
  505. package/dist/utils/subgraphConsistency.cjs.map +1 -0
  506. package/dist/utils/subgraphConsistency.d.ts +65 -0
  507. package/dist/utils/subgraphConsistency.js +155 -0
  508. package/dist/utils/subgraphConsistency.js.map +1 -0
  509. package/dist/utils/subgraphMetaCache.cjs +101 -0
  510. package/dist/utils/subgraphMetaCache.cjs.map +1 -0
  511. package/dist/utils/subgraphMetaCache.d.ts +56 -0
  512. package/dist/utils/subgraphMetaCache.js +76 -0
  513. package/dist/utils/subgraphMetaCache.js.map +1 -0
  514. package/dist/utils/subgraphPagination.cjs +104 -0
  515. package/dist/utils/subgraphPagination.cjs.map +1 -0
  516. package/dist/utils/subgraphPagination.d.ts +78 -0
  517. package/dist/utils/subgraphPagination.js +78 -0
  518. package/dist/utils/subgraphPagination.js.map +1 -0
  519. package/dist/utils/transactionHelpers.cjs.map +1 -1
  520. package/dist/utils/transactionHelpers.d.ts +12 -12
  521. package/dist/utils/transactionHelpers.js.map +1 -1
  522. package/dist/utils/typedDataConverter.cjs.map +1 -1
  523. package/dist/utils/typedDataConverter.d.ts +39 -3
  524. package/dist/utils/typedDataConverter.js.map +1 -1
  525. package/dist/utils/urlResolver.cjs +7 -0
  526. package/dist/utils/urlResolver.cjs.map +1 -1
  527. package/dist/utils/urlResolver.d.ts +22 -4
  528. package/dist/utils/urlResolver.js +7 -0
  529. package/dist/utils/urlResolver.js.map +1 -1
  530. package/dist/utils/wallet.cjs +63 -0
  531. package/dist/utils/wallet.cjs.map +1 -0
  532. package/dist/utils/wallet.d.ts +94 -0
  533. package/dist/utils/wallet.js +37 -0
  534. package/dist/utils/wallet.js.map +1 -0
  535. package/package.json +7 -2
  536. package/dist/config/addresses.cjs.map +0 -1
  537. package/dist/config/addresses.js.map +0 -1
  538. package/dist/generated/abi/DLPTreasuryImplementation.cjs.map +0 -1
  539. package/dist/generated/abi/DLPTreasuryImplementation.js.map +0 -1
  540. package/dist/server/handler.cjs +0 -101
  541. package/dist/server/handler.cjs.map +0 -1
  542. package/dist/server/handler.d.ts +0 -87
  543. package/dist/server/handler.js +0 -77
  544. package/dist/server/handler.js.map +0 -1
  545. /package/dist/{tests/server-handler.test.d.ts → client/__tests__/enhancedResponse.test.d.ts} +0 -0
@@ -33,17 +33,19 @@ __export(permissions_exports, {
33
33
  module.exports = __toCommonJS(permissions_exports);
34
34
  var import_viem = require("viem");
35
35
  var import_multicall = require("../utils/multicall");
36
+ var import_pollingManager = require("../core/pollingManager");
36
37
  var import_errors = require("../errors");
37
- var import_addresses = require("../config/addresses");
38
+ var import_addresses = require("../generated/addresses");
38
39
  var import_abi = require("../generated/abi");
39
40
  var import_grantFiles = require("../utils/grantFiles");
40
41
  var import_grantValidation = require("../utils/grantValidation");
41
42
  var import_signatureCache = require("../utils/signatureCache");
42
43
  var import_signatureFormatter = require("../utils/signatureFormatter");
43
44
  var import_typedDataConverter = require("../utils/typedDataConverter");
44
- class PermissionsController {
45
+ var import_base = require("./base");
46
+ class PermissionsController extends import_base.BaseController {
45
47
  constructor(context) {
46
- this.context = context;
48
+ super(context);
47
49
  }
48
50
  /**
49
51
  * Grants permission for an application to access user data with gasless transactions.
@@ -79,9 +81,14 @@ class PermissionsController {
79
81
  * await vana.permissions.revoke({ permissionId: result.permissionId });
80
82
  * ```
81
83
  */
82
- async grant(params) {
84
+ async grant(params, options) {
85
+ this.assertWallet();
83
86
  const { typedData, signature } = await this.createAndSign(params);
84
- const result = await this.submitSignedGrantWithEvents(typedData, signature);
87
+ const result = await this.submitSignedGrantWithEvents(
88
+ typedData,
89
+ signature,
90
+ options
91
+ );
85
92
  return result;
86
93
  }
87
94
  /**
@@ -109,9 +116,10 @@ class PermissionsController {
109
116
  * console.log(`Permission ID: ${eventData.permissionId}`);
110
117
  * ```
111
118
  */
112
- async submitPermissionGrant(params) {
119
+ async submitPermissionGrant(params, options) {
120
+ this.assertWallet();
113
121
  const { typedData, signature } = await this.createAndSign(params);
114
- return await this.submitSignedGrant(typedData, signature);
122
+ return await this.submitSignedGrant(typedData, signature, options);
115
123
  }
116
124
  /**
117
125
  * Prepares a permission grant with preview before signing.
@@ -138,14 +146,19 @@ class PermissionsController {
138
146
  * const transactionHash = await confirm();
139
147
  * ```
140
148
  */
141
- async prepareGrant(params) {
149
+ async prepareGrant(params, options) {
150
+ this.assertWallet();
142
151
  try {
143
152
  const grantFile = (0, import_grantFiles.createGrantFile)(params);
144
153
  (0, import_grantValidation.validateGrant)(grantFile);
145
154
  return {
146
155
  preview: grantFile,
147
156
  confirm: async () => {
148
- return await this.confirmGrantInternalWithEvents(params, grantFile);
157
+ return await this.confirmGrantInternalWithEvents(
158
+ params,
159
+ grantFile,
160
+ options
161
+ );
149
162
  }
150
163
  };
151
164
  } catch (error) {
@@ -177,22 +190,36 @@ class PermissionsController {
177
190
  * @throws {NetworkError} When IPFS upload fails
178
191
  * @throws {SignatureError} When user rejects the signature
179
192
  */
180
- async confirmGrantInternal(params, grantFile) {
193
+ async confirmGrantInternal(params, grantFile, options) {
181
194
  try {
182
195
  let { grantUrl } = params;
183
196
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
184
197
  if (!grantUrl) {
185
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
198
+ const canStoreViaRelayer = this.context.relayer !== void 0;
199
+ if (!canStoreViaRelayer && !this.context.storageManager) {
186
200
  if (this.context.validateStorageRequired) {
187
201
  this.context.validateStorageRequired();
188
202
  } else {
189
203
  throw new Error(
190
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
204
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
191
205
  );
192
206
  }
193
207
  }
194
- if (this.context.relayerCallbacks?.storeGrantFile) {
195
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
208
+ if (canStoreViaRelayer && this.context.relayer) {
209
+ const request = {
210
+ type: "direct",
211
+ operation: "storeGrantFile",
212
+ params: grantFile
213
+ };
214
+ const response = await this.context.relayer(request);
215
+ if (response.type === "error") {
216
+ throw new Error(response.error);
217
+ }
218
+ if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
219
+ grantUrl = response.result.url;
220
+ } else {
221
+ throw new Error("Invalid response from relayer for grant storage");
222
+ }
196
223
  } else if (this.context.storageManager) {
197
224
  const blob = new Blob([JSON.stringify(grantFile)], {
198
225
  type: "application/json"
@@ -224,7 +251,7 @@ class PermissionsController {
224
251
  nonce
225
252
  });
226
253
  const signature = await this.signTypedData(typedData);
227
- return await this.submitSignedGrant(typedData, signature);
254
+ return await this.submitSignedGrant(typedData, signature, options);
228
255
  } catch (error) {
229
256
  if (error instanceof Error) {
230
257
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
@@ -269,23 +296,38 @@ class PermissionsController {
269
296
  * ```
270
297
  */
271
298
  async createAndSign(params) {
299
+ this.assertWallet();
272
300
  try {
273
301
  const grantFile = (0, import_grantFiles.createGrantFile)(params);
274
302
  (0, import_grantValidation.validateGrant)(grantFile);
275
303
  let { grantUrl } = params;
276
304
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
277
305
  if (!grantUrl) {
278
- if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
306
+ const canStoreViaRelayer = this.context.relayer !== void 0;
307
+ if (!canStoreViaRelayer && !this.context.storageManager) {
279
308
  if (this.context.validateStorageRequired) {
280
309
  this.context.validateStorageRequired();
281
310
  } else {
282
311
  throw new Error(
283
- "No storage available. Provide a grantUrl, configure relayerCallbacks.storeGrantFile, or storageManager."
312
+ "No storage available. Provide a grantUrl, configure relayer, or storageManager."
284
313
  );
285
314
  }
286
315
  }
287
- if (this.context.relayerCallbacks?.storeGrantFile) {
288
- grantUrl = await this.context.relayerCallbacks.storeGrantFile(grantFile);
316
+ if (canStoreViaRelayer && this.context.relayer) {
317
+ const request = {
318
+ type: "direct",
319
+ operation: "storeGrantFile",
320
+ params: grantFile
321
+ };
322
+ const response = await this.context.relayer(request);
323
+ if (response.type === "error") {
324
+ throw new Error(response.error);
325
+ }
326
+ if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
327
+ grantUrl = response.result.url;
328
+ } else {
329
+ throw new Error("Invalid response from relayer for grant storage");
330
+ }
289
331
  } else if (this.context.storageManager) {
290
332
  const blob = new Blob([JSON.stringify(grantFile)], {
291
333
  type: "application/json"
@@ -354,7 +396,7 @@ class PermissionsController {
354
396
  * );
355
397
  * ```
356
398
  */
357
- async submitSignedGrant(typedData, signature) {
399
+ async submitSignedGrant(typedData, signature, options) {
358
400
  try {
359
401
  console.debug(
360
402
  "\u{1F50D} Debug - submitSignedGrant called with typed data:",
@@ -364,21 +406,49 @@ class PermissionsController {
364
406
  2
365
407
  )
366
408
  );
367
- if (this.context.relayerCallbacks?.submitPermissionGrant) {
368
- const hash = await this.context.relayerCallbacks.submitPermissionGrant(
409
+ if (this.context.relayer) {
410
+ const response = await this.context.relayer({
411
+ type: "signed",
412
+ operation: "submitAddPermission",
369
413
  typedData,
370
- signature
371
- );
372
- const account = this.context.walletClient.account ?? await this.getUserAddress();
414
+ signature,
415
+ expectedUserAddress: this.context.userAddress
416
+ });
417
+ if (response.type === "error") {
418
+ throw new Error(`Relayer error: ${response.error}`);
419
+ }
420
+ let finalHash;
421
+ if (response.type === "submitted") {
422
+ finalHash = response.hash;
423
+ } else if (response.type === "pending") {
424
+ const pollResult = await this.pollRelayerForConfirmation(
425
+ response.operationId,
426
+ options
427
+ );
428
+ finalHash = pollResult.hash;
429
+ } else if (response.type === "confirmed") {
430
+ finalHash = response.hash;
431
+ } else if (response.type === "signed") {
432
+ finalHash = response.hash;
433
+ } else {
434
+ throw new Error(
435
+ "Invalid response from relayer: unexpected response type"
436
+ );
437
+ }
438
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
373
439
  const { tx } = await import("../utils/transactionHelpers");
374
440
  return tx({
375
- hash,
441
+ hash: finalHash,
376
442
  from: typeof account === "string" ? account : account.address,
377
443
  contract: "DataPortabilityPermissions",
378
444
  fn: "addPermission"
379
445
  });
380
446
  } else {
381
- return await this.submitDirectTransaction(typedData, signature);
447
+ return await this.submitDirectTransaction(
448
+ typedData,
449
+ signature,
450
+ options
451
+ );
382
452
  }
383
453
  } catch (error) {
384
454
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
@@ -411,7 +481,7 @@ class PermissionsController {
411
481
  * const result = await txHandle.waitForEvents();
412
482
  * ```
413
483
  */
414
- async submitSignedTrustServer(typedData, signature) {
484
+ async submitSignedTrustServer(typedData, signature, options) {
415
485
  try {
416
486
  const trustServerInput = {
417
487
  nonce: BigInt(typedData.message.nonce),
@@ -419,13 +489,14 @@ class PermissionsController {
419
489
  };
420
490
  const hash = await this.submitTrustServerTransaction(
421
491
  trustServerInput,
422
- signature
492
+ signature,
493
+ options
423
494
  );
424
- const account = this.context.walletClient.account ?? await this.getUserAddress();
495
+ const account = this.context.userAddress;
425
496
  const { tx } = await import("../utils/transactionHelpers");
426
497
  return tx({
427
498
  hash,
428
- from: typeof account === "string" ? account : account.address,
499
+ from: account,
429
500
  contract: "DataPortabilityServers",
430
501
  fn: "trustServerWithSignature"
431
502
  });
@@ -474,7 +545,7 @@ class PermissionsController {
474
545
  * const result = await txHandle.waitForEvents();
475
546
  * ```
476
547
  */
477
- async submitSignedAddAndTrustServer(typedData, signature) {
548
+ async submitSignedAddAndTrustServer(typedData, signature, options) {
478
549
  try {
479
550
  const addAndTrustServerInput = {
480
551
  nonce: BigInt(typedData.message.nonce),
@@ -484,9 +555,10 @@ class PermissionsController {
484
555
  };
485
556
  const hash = await this.submitAddAndTrustServerTransaction(
486
557
  addAndTrustServerInput,
487
- signature
558
+ signature,
559
+ options
488
560
  );
489
- const account = this.context.walletClient.account ?? await this.getUserAddress();
561
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
490
562
  const { tx } = await import("../utils/transactionHelpers");
491
563
  return tx({
492
564
  hash,
@@ -512,8 +584,12 @@ class PermissionsController {
512
584
  * @param signature - The user's signature authorizing the transaction
513
585
  * @returns Promise resolving to PermissionGrantResult with parsed events
514
586
  */
515
- async submitSignedGrantWithEvents(typedData, signature) {
516
- const txResult = await this.submitSignedGrant(typedData, signature);
587
+ async submitSignedGrantWithEvents(typedData, signature, options) {
588
+ const txResult = await this.submitSignedGrant(
589
+ typedData,
590
+ signature,
591
+ options
592
+ );
517
593
  if (!this.context.waitForTransactionEvents) {
518
594
  throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
519
595
  }
@@ -545,8 +621,12 @@ class PermissionsController {
545
621
  * @param grantFile - The pre-created grant file object
546
622
  * @returns Promise resolving to PermissionGrantResult with parsed events
547
623
  */
548
- async confirmGrantInternalWithEvents(params, grantFile) {
549
- const txResult = await this.confirmGrantInternal(params, grantFile);
624
+ async confirmGrantInternalWithEvents(params, grantFile, options) {
625
+ const txResult = await this.confirmGrantInternal(
626
+ params,
627
+ grantFile,
628
+ options
629
+ );
550
630
  if (!this.context.waitForTransactionEvents) {
551
631
  throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
552
632
  }
@@ -570,6 +650,27 @@ class PermissionsController {
570
650
  fileIds: event.fileIds
571
651
  };
572
652
  }
653
+ /**
654
+ * Polls the relayer for confirmation of a pending operation.
655
+ *
656
+ * @param operationId - The operation ID to poll
657
+ * @param options - Polling configuration including status updates and cancellation
658
+ * @returns Promise resolving to the confirmed hash and receipt
659
+ * @throws {TransactionPendingError} When the operation times out
660
+ * @throws {Error} When the operation fails or is cancelled
661
+ * @internal
662
+ */
663
+ async pollRelayerForConfirmation(operationId, options) {
664
+ if (!this.context.relayer) {
665
+ throw new Error("Relayer not configured for polling");
666
+ }
667
+ const pollingManager = new import_pollingManager.PollingManager(this.context.relayer);
668
+ return await pollingManager.startPolling(operationId, {
669
+ signal: options?.signal,
670
+ onStatusUpdate: options?.onStatusUpdate,
671
+ ...options?.pollingOptions
672
+ });
673
+ }
573
674
  /**
574
675
  * Submits an already-signed permission revoke transaction to the blockchain.
575
676
  *
@@ -591,21 +692,45 @@ class PermissionsController {
591
692
  * const result = await txHandle.waitForEvents();
592
693
  * ```
593
694
  */
594
- async submitSignedRevoke(typedData, signature) {
695
+ async submitSignedRevoke(typedData, signature, options) {
595
696
  try {
596
697
  let hash;
597
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
598
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
698
+ if (this.context.relayer) {
699
+ const response = await this.context.relayer({
700
+ type: "signed",
701
+ operation: "submitPermissionRevoke",
599
702
  typedData,
600
- signature
601
- );
703
+ signature,
704
+ expectedUserAddress: this.context.userAddress
705
+ });
706
+ if (response.type === "error") {
707
+ throw new Error(`Relayer error: ${response.error}`);
708
+ }
709
+ if (response.type === "submitted") {
710
+ hash = response.hash;
711
+ } else if (response.type === "pending") {
712
+ const pollResult = await this.pollRelayerForConfirmation(
713
+ response.operationId,
714
+ options
715
+ );
716
+ hash = pollResult.hash;
717
+ } else if (response.type === "confirmed") {
718
+ hash = response.hash;
719
+ } else if (response.type === "signed") {
720
+ hash = response.hash;
721
+ } else {
722
+ throw new Error(
723
+ "Invalid response from relayer: unexpected response type"
724
+ );
725
+ }
602
726
  } else {
603
727
  hash = await this.submitDirectRevokeTransaction(
604
728
  typedData,
605
- signature
729
+ signature,
730
+ options
606
731
  );
607
732
  }
608
- const account = this.context.walletClient.account ?? await this.getUserAddress();
733
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
609
734
  const { tx } = await import("../utils/transactionHelpers");
610
735
  return tx({
611
736
  hash,
@@ -644,21 +769,36 @@ class PermissionsController {
644
769
  * const result = await txHandle.waitForEvents();
645
770
  * ```
646
771
  */
647
- async submitSignedUntrustServer(typedData, signature) {
772
+ async submitSignedUntrustServer(typedData, signature, options) {
648
773
  try {
649
774
  let hash;
650
- if (this.context.relayerCallbacks?.submitUntrustServer) {
651
- hash = await this.context.relayerCallbacks.submitUntrustServer(
775
+ if (this.context.relayer) {
776
+ const response = await this.context.relayer({
777
+ type: "signed",
778
+ operation: "submitUntrustServer",
652
779
  typedData,
653
- signature
654
- );
780
+ signature,
781
+ expectedUserAddress: this.context.userAddress
782
+ });
783
+ if (response.type === "submitted") {
784
+ hash = response.hash;
785
+ } else if (response.type === "signed") {
786
+ hash = response.hash;
787
+ } else if (response.type === "error") {
788
+ throw new Error(`Relayer error: ${response.error}`);
789
+ } else {
790
+ throw new Error(
791
+ "Invalid response from relayer: expected signed transaction"
792
+ );
793
+ }
655
794
  } else {
656
795
  hash = await this.submitSignedUntrustTransaction(
657
796
  typedData,
658
- signature
797
+ signature,
798
+ options
659
799
  );
660
800
  }
661
- const account = this.context.walletClient.account ?? await this.getUserAddress();
801
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
662
802
  const { tx } = await import("../utils/transactionHelpers");
663
803
  return tx({
664
804
  hash,
@@ -688,8 +828,9 @@ class PermissionsController {
688
828
  * @returns Promise resolving to the transaction hash
689
829
  * @throws {BlockchainError} When contract submission fails
690
830
  */
691
- async submitDirectTransaction(typedData, signature) {
692
- const chainId = await this.context.walletClient.getChainId();
831
+ async submitDirectTransaction(typedData, signature, options) {
832
+ this.assertWallet();
833
+ const chainId = await this.context.publicClient.getChainId();
693
834
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
694
835
  chainId,
695
836
  "DataPortabilityPermissions"
@@ -712,14 +853,15 @@ class PermissionsController {
712
853
  typedData.message.grant?.length ?? 0
713
854
  );
714
855
  const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
715
- const account = this.context.walletClient.account ?? await this.getUserAddress();
856
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
716
857
  const txHash = await this.context.walletClient.writeContract({
717
858
  address: DataPortabilityPermissionsAddress,
718
859
  abi: DataPortabilityPermissionsAbi,
719
860
  functionName: "addPermission",
720
861
  args: [permissionInput, formattedSignature],
721
862
  account,
722
- chain: this.context.walletClient.chain ?? null
863
+ chain: this.context.walletClient?.chain ?? null,
864
+ ...this.spreadTransactionOptions(options)
723
865
  });
724
866
  const { tx } = await import("../utils/transactionHelpers");
725
867
  return tx({
@@ -754,6 +896,7 @@ class PermissionsController {
754
896
  * ```
755
897
  */
756
898
  async revoke(params) {
899
+ this.assertWallet();
757
900
  const txResult = await this.submitPermissionRevoke(params);
758
901
  if (!this.context.waitForTransactionEvents) {
759
902
  throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
@@ -782,6 +925,7 @@ class PermissionsController {
782
925
  * Use this when you want to handle transaction confirmation and event parsing separately.
783
926
  *
784
927
  * @param params - Parameters for revoking the permission
928
+ * @param options - Optional transaction options for gas parameters and timeout
785
929
  * @returns Promise resolving to the transaction hash when successfully submitted
786
930
  * @throws {BlockchainError} When revocation transaction fails
787
931
  * @throws {UserRejectedRequestError} When user rejects the transaction
@@ -794,12 +938,13 @@ class PermissionsController {
794
938
  * console.log(`Revocation submitted: ${txHash}`);
795
939
  * ```
796
940
  */
797
- async submitPermissionRevoke(params) {
941
+ async submitPermissionRevoke(params, options) {
942
+ this.assertWallet();
798
943
  try {
799
- if (!this.context.walletClient.chain?.id) {
944
+ if (!this.context.walletClient?.chain?.id) {
800
945
  throw new import_errors.BlockchainError("Chain ID not available");
801
946
  }
802
- const chainId = await this.context.walletClient.getChainId();
947
+ const chainId = await this.context.publicClient.getChainId();
803
948
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
804
949
  chainId,
805
950
  "DataPortabilityPermissions"
@@ -807,14 +952,25 @@ class PermissionsController {
807
952
  const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
808
953
  "DataPortabilityPermissions"
809
954
  );
810
- const account = this.context.walletClient.account ?? await this.getUserAddress();
955
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
811
956
  const txHash = await this.context.walletClient.writeContract({
812
957
  address: DataPortabilityPermissionsAddress,
813
958
  abi: DataPortabilityPermissionsAbi,
814
959
  functionName: "revokePermission",
815
960
  args: [params.permissionId],
816
961
  account,
817
- chain: this.context.walletClient.chain ?? null
962
+ chain: this.context.walletClient?.chain ?? null,
963
+ ...options?.gas && { gas: options.gas },
964
+ ...options?.nonce && { nonce: options.nonce },
965
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
966
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
967
+ ...options.maxFeePerGas && {
968
+ maxFeePerGas: options.maxFeePerGas
969
+ },
970
+ ...options.maxPriorityFeePerGas && {
971
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
972
+ }
973
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
818
974
  });
819
975
  const { tx } = await import("../utils/transactionHelpers");
820
976
  return tx({
@@ -861,9 +1017,10 @@ class PermissionsController {
861
1017
  * console.log(`Permission ${result.permissionId} revoked`);
862
1018
  * ```
863
1019
  */
864
- async submitRevokeWithSignature(params) {
1020
+ async submitRevokeWithSignature(params, options) {
1021
+ this.assertWallet();
865
1022
  try {
866
- if (!this.context.walletClient.chain?.id) {
1023
+ if (!this.context.walletClient?.chain?.id) {
867
1024
  throw new import_errors.BlockchainError("Chain ID not available");
868
1025
  }
869
1026
  const nonce = await this.getPermissionsUserNonce();
@@ -884,18 +1041,33 @@ class PermissionsController {
884
1041
  };
885
1042
  const signature = await this.signTypedData(typedData);
886
1043
  let hash;
887
- if (this.context.relayerCallbacks?.submitPermissionRevoke) {
888
- hash = await this.context.relayerCallbacks.submitPermissionRevoke(
1044
+ if (this.context.relayer) {
1045
+ const response = await this.context.relayer({
1046
+ type: "signed",
1047
+ operation: "submitPermissionRevoke",
889
1048
  typedData,
890
- signature
891
- );
1049
+ signature,
1050
+ expectedUserAddress: this.context.userAddress
1051
+ });
1052
+ if (response.type === "submitted") {
1053
+ hash = response.hash;
1054
+ } else if (response.type === "signed") {
1055
+ hash = response.hash;
1056
+ } else if (response.type === "error") {
1057
+ throw new Error(`Relayer error: ${response.error}`);
1058
+ } else {
1059
+ throw new Error(
1060
+ "Invalid response from relayer: expected signed transaction"
1061
+ );
1062
+ }
892
1063
  } else {
893
1064
  hash = await this.submitDirectRevokeTransaction(
894
1065
  typedData,
895
- signature
1066
+ signature,
1067
+ options
896
1068
  );
897
1069
  }
898
- const account = this.context.walletClient.account ?? await this.getUserAddress();
1070
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
899
1071
  const { tx } = await import("../utils/transactionHelpers");
900
1072
  return tx({
901
1073
  hash,
@@ -936,8 +1108,8 @@ class PermissionsController {
936
1108
  */
937
1109
  async getServersUserNonce() {
938
1110
  try {
939
- const userAddress = await this.getUserAddress();
940
- const chainId = await this.context.walletClient.getChainId();
1111
+ const userAddress = this.context.userAddress;
1112
+ const chainId = await this.context.publicClient.getChainId();
941
1113
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
942
1114
  chainId,
943
1115
  "DataPortabilityServers"
@@ -982,8 +1154,8 @@ class PermissionsController {
982
1154
  */
983
1155
  async getPermissionsUserNonce() {
984
1156
  try {
985
- const userAddress = await this.getUserAddress();
986
- const chainId = await this.context.walletClient.getChainId();
1157
+ const userAddress = this.context.userAddress;
1158
+ const chainId = await this.context.publicClient.getChainId();
987
1159
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
988
1160
  chainId,
989
1161
  "DataPortabilityPermissions"
@@ -1022,7 +1194,7 @@ class PermissionsController {
1022
1194
  "\u{1F50D} Debug - Composing permission message with grantUrl:",
1023
1195
  params.grantUrl
1024
1196
  );
1025
- const chainId = await this.context.walletClient.getChainId();
1197
+ const chainId = await this.context.publicClient.getChainId();
1026
1198
  const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
1027
1199
  chainId,
1028
1200
  "DataPortabilityGrantees"
@@ -1131,7 +1303,7 @@ class PermissionsController {
1131
1303
  * @returns Promise resolving to the EIP-712 domain configuration
1132
1304
  */
1133
1305
  async getPermissionDomain() {
1134
- const chainId = await this.context.walletClient.getChainId();
1306
+ const chainId = await this.context.publicClient.getChainId();
1135
1307
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
1136
1308
  chainId,
1137
1309
  "DataPortabilityPermissions"
@@ -1150,8 +1322,9 @@ class PermissionsController {
1150
1322
  * @returns Promise resolving to the cryptographic signature
1151
1323
  */
1152
1324
  async signTypedData(typedData) {
1325
+ this.assertWallet();
1153
1326
  try {
1154
- const walletAddress = this.context.walletClient.account?.address ?? await this.getUserAddress();
1327
+ const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
1155
1328
  return await (0, import_signatureCache.withSignatureCache)(
1156
1329
  this.context.platform.cache,
1157
1330
  walletAddress,
@@ -1177,17 +1350,10 @@ class PermissionsController {
1177
1350
  }
1178
1351
  }
1179
1352
  /**
1180
- * Gets the user's address from the wallet client.
1353
+ * Gets the user's address from the context.
1181
1354
  *
1182
- * @returns Promise resolving to the user's wallet address
1355
+ * @returns The user's address
1183
1356
  */
1184
- async getUserAddress() {
1185
- const addresses = await this.context.walletClient.getAddresses();
1186
- if (addresses.length === 0) {
1187
- throw new import_errors.BlockchainError("No addresses available in wallet client");
1188
- }
1189
- return addresses[0];
1190
- }
1191
1357
  /**
1192
1358
  * Gets on-chain permission grant data without expensive off-chain resolution.
1193
1359
  *
@@ -1224,9 +1390,11 @@ class PermissionsController {
1224
1390
  * ```
1225
1391
  */
1226
1392
  async getUserPermissionGrantsOnChain(options = {}) {
1227
- const { limit = 50, subgraphUrl } = options;
1393
+ const { limit = 50, fetchAll = false, subgraphUrl } = options;
1394
+ const pageSize = fetchAll ? 100 : limit;
1395
+ const maxResults = fetchAll ? 1e4 : limit;
1228
1396
  try {
1229
- const userAddress = await this.getUserAddress();
1397
+ const userAddress = this.context.userAddress;
1230
1398
  const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
1231
1399
  if (!graphqlEndpoint) {
1232
1400
  throw new import_errors.BlockchainError(
@@ -1234,10 +1402,10 @@ class PermissionsController {
1234
1402
  );
1235
1403
  }
1236
1404
  const query = `
1237
- query GetUserPermissions($userId: ID!) {
1405
+ query GetUserPermissions($userId: ID!, $first: Int!, $skip: Int!) {
1238
1406
  user(id: $userId) {
1239
1407
  id
1240
- permissions {
1408
+ permissions(first: $first, skip: $skip, orderBy: addedAtBlock, orderDirection: desc) {
1241
1409
  id
1242
1410
  grant
1243
1411
  nonce
@@ -1255,34 +1423,82 @@ class PermissionsController {
1255
1423
  }
1256
1424
  }
1257
1425
  `;
1258
- const response = await fetch(graphqlEndpoint, {
1259
- method: "POST",
1260
- headers: {
1261
- "Content-Type": "application/json"
1262
- },
1263
- body: JSON.stringify({
1264
- query,
1265
- variables: {
1266
- userId: userAddress.toLowerCase()
1426
+ const allPermissions = [];
1427
+ let currentOffset = 0;
1428
+ if (!fetchAll) {
1429
+ const response = await fetch(graphqlEndpoint, {
1430
+ method: "POST",
1431
+ headers: {
1432
+ "Content-Type": "application/json"
1433
+ },
1434
+ body: JSON.stringify({
1435
+ query,
1436
+ variables: {
1437
+ userId: userAddress.toLowerCase(),
1438
+ first: limit,
1439
+ skip: 0
1440
+ }
1441
+ })
1442
+ });
1443
+ if (!response.ok) {
1444
+ throw new import_errors.BlockchainError(
1445
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1446
+ );
1447
+ }
1448
+ const result = await response.json();
1449
+ if (result.errors) {
1450
+ throw new import_errors.BlockchainError(
1451
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1452
+ );
1453
+ }
1454
+ const userData = result.data?.user;
1455
+ if (!userData?.permissions?.length) {
1456
+ return [];
1457
+ }
1458
+ allPermissions.push(...userData.permissions);
1459
+ } else {
1460
+ while (allPermissions.length < maxResults) {
1461
+ const currentLimit = Math.min(
1462
+ pageSize,
1463
+ maxResults - allPermissions.length
1464
+ );
1465
+ const response = await fetch(graphqlEndpoint, {
1466
+ method: "POST",
1467
+ headers: {
1468
+ "Content-Type": "application/json"
1469
+ },
1470
+ body: JSON.stringify({
1471
+ query,
1472
+ variables: {
1473
+ userId: userAddress.toLowerCase(),
1474
+ first: currentLimit,
1475
+ skip: currentOffset
1476
+ }
1477
+ })
1478
+ });
1479
+ if (!response.ok) {
1480
+ throw new import_errors.BlockchainError(
1481
+ `Subgraph request failed: ${response.status} ${response.statusText}`
1482
+ );
1267
1483
  }
1268
- })
1269
- });
1270
- if (!response.ok) {
1271
- throw new import_errors.BlockchainError(
1272
- `Subgraph request failed: ${response.status} ${response.statusText}`
1273
- );
1274
- }
1275
- const result = await response.json();
1276
- if (result.errors) {
1277
- throw new import_errors.BlockchainError(
1278
- `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1279
- );
1280
- }
1281
- const userData = result.data?.user;
1282
- if (!userData?.permissions?.length) {
1283
- return [];
1484
+ const result = await response.json();
1485
+ if (result.errors) {
1486
+ throw new import_errors.BlockchainError(
1487
+ `Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
1488
+ );
1489
+ }
1490
+ const userData = result.data?.user;
1491
+ if (!userData?.permissions?.length) {
1492
+ break;
1493
+ }
1494
+ allPermissions.push(...userData.permissions);
1495
+ if (userData.permissions.length < currentLimit) {
1496
+ break;
1497
+ }
1498
+ currentOffset += userData.permissions.length;
1499
+ }
1284
1500
  }
1285
- const onChainGrants = userData.permissions.slice(0, limit).map(
1501
+ const onChainGrants = allPermissions.map(
1286
1502
  (permission) => ({
1287
1503
  id: BigInt(permission.id),
1288
1504
  grantUrl: permission.grant,
@@ -1346,6 +1562,7 @@ class PermissionsController {
1346
1562
  * ```
1347
1563
  */
1348
1564
  async addAndTrustServer(params) {
1565
+ this.assertWallet();
1349
1566
  try {
1350
1567
  const chainId = await this.context.walletClient.getChainId();
1351
1568
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1353,7 +1570,7 @@ class PermissionsController {
1353
1570
  "DataPortabilityServers"
1354
1571
  );
1355
1572
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1356
- const account = this.context.walletClient.account ?? await this.getUserAddress();
1573
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1357
1574
  const userAddress = typeof account === "string" ? account : account.address;
1358
1575
  const normalizedUserAddress = (0, import_viem.getAddress)(userAddress);
1359
1576
  const normalizedServerAddress = (0, import_viem.getAddress)(params.serverAddress);
@@ -1370,7 +1587,7 @@ class PermissionsController {
1370
1587
  }
1371
1588
  ],
1372
1589
  account,
1373
- chain: this.context.walletClient.chain ?? null
1590
+ chain: this.context.walletClient?.chain ?? null
1374
1591
  });
1375
1592
  const { tx } = await import("../utils/transactionHelpers");
1376
1593
  const txResult = tx({
@@ -1422,6 +1639,7 @@ class PermissionsController {
1422
1639
  * @deprecated Use addAndTrustServer instead
1423
1640
  */
1424
1641
  async submitTrustServer(params) {
1642
+ this.assertWallet();
1425
1643
  try {
1426
1644
  const chainId = await this.context.walletClient.getChainId();
1427
1645
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1429,14 +1647,14 @@ class PermissionsController {
1429
1647
  "DataPortabilityServers"
1430
1648
  );
1431
1649
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1432
- const account = this.context.walletClient.account ?? await this.getUserAddress();
1650
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1433
1651
  const txHash = await this.context.walletClient.writeContract({
1434
1652
  address: DataPortabilityServersAddress,
1435
1653
  abi: DataPortabilityServersAbi,
1436
1654
  functionName: "trustServer",
1437
1655
  args: [BigInt(params.serverId)],
1438
1656
  account,
1439
- chain: this.context.walletClient.chain ?? null
1657
+ chain: this.context.walletClient?.chain ?? null
1440
1658
  });
1441
1659
  const { tx } = await import("../utils/transactionHelpers");
1442
1660
  return tx({
@@ -1461,7 +1679,8 @@ class PermissionsController {
1461
1679
  * @param params - Parameters for adding and trusting the server
1462
1680
  * @returns Promise resolving to TransactionResult with ServerTrustResult event data
1463
1681
  */
1464
- async submitAddAndTrustServerWithSignature(params) {
1682
+ async submitAddAndTrustServerWithSignature(params, options) {
1683
+ this.assertWallet();
1465
1684
  try {
1466
1685
  const nonce = await this.getServersUserNonce();
1467
1686
  const serverAddress = (0, import_viem.getAddress)(params.serverAddress);
@@ -1485,18 +1704,32 @@ class PermissionsController {
1485
1704
  const signature = await this.signTypedData(typedData);
1486
1705
  console.debug("\u{1F50D} Generated signature:", signature);
1487
1706
  let hash;
1488
- if (this.context.relayerCallbacks?.submitAddAndTrustServer) {
1489
- hash = await this.context.relayerCallbacks.submitAddAndTrustServer(
1707
+ if (this.context.relayer) {
1708
+ const request = {
1709
+ type: "signed",
1710
+ operation: "submitAddAndTrustServer",
1490
1711
  typedData,
1491
1712
  signature
1492
- );
1713
+ };
1714
+ const response = await this.context.relayer(request);
1715
+ if (response.type === "error") {
1716
+ throw new import_errors.RelayerError(response.error);
1717
+ }
1718
+ if (response.type === "submitted") {
1719
+ hash = response.hash;
1720
+ } else if (response.type === "signed") {
1721
+ hash = response.hash;
1722
+ } else {
1723
+ throw new Error("Unexpected response type from relayer");
1724
+ }
1493
1725
  } else {
1494
1726
  hash = await this.submitAddAndTrustServerTransaction(
1495
1727
  addAndTrustServerInput,
1496
- signature
1728
+ signature,
1729
+ options
1497
1730
  );
1498
1731
  }
1499
- const account = this.context.walletClient.account ?? await this.getUserAddress();
1732
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1500
1733
  const { tx } = await import("../utils/transactionHelpers");
1501
1734
  return tx({
1502
1735
  hash,
@@ -1532,7 +1765,8 @@ class PermissionsController {
1532
1765
  * @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
1533
1766
  * @throws {BlockchainError} When trust operation fails for any other reason
1534
1767
  */
1535
- async submitTrustServerWithSignature(params) {
1768
+ async submitTrustServerWithSignature(params, options) {
1769
+ this.assertWallet();
1536
1770
  try {
1537
1771
  const nonce = await this.getServersUserNonce();
1538
1772
  const trustServerInput = {
@@ -1542,18 +1776,32 @@ class PermissionsController {
1542
1776
  const typedData = await this.composeTrustServerMessage(trustServerInput);
1543
1777
  const signature = await this.signTypedData(typedData);
1544
1778
  let hash;
1545
- if (this.context.relayerCallbacks?.submitTrustServer) {
1546
- hash = await this.context.relayerCallbacks.submitTrustServer(
1779
+ if (this.context.relayer) {
1780
+ const request = {
1781
+ type: "signed",
1782
+ operation: "submitTrustServer",
1547
1783
  typedData,
1548
1784
  signature
1549
- );
1785
+ };
1786
+ const response = await this.context.relayer(request);
1787
+ if (response.type === "error") {
1788
+ throw new import_errors.RelayerError(response.error);
1789
+ }
1790
+ if (response.type === "submitted") {
1791
+ hash = response.hash;
1792
+ } else if (response.type === "signed") {
1793
+ hash = response.hash;
1794
+ } else {
1795
+ throw new Error("Unexpected response type from relayer");
1796
+ }
1550
1797
  } else {
1551
1798
  hash = await this.submitTrustServerTransaction(
1552
1799
  trustServerInput,
1553
- signature
1800
+ signature,
1801
+ options
1554
1802
  );
1555
1803
  }
1556
- const account = this.context.walletClient.account ?? await this.getUserAddress();
1804
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1557
1805
  const { tx } = await import("../utils/transactionHelpers");
1558
1806
  return tx({
1559
1807
  hash,
@@ -1591,7 +1839,8 @@ class PermissionsController {
1591
1839
  * @returns Promise resolving to TransactionResult for transaction tracking
1592
1840
  * @throws {BlockchainError} When contract submission fails
1593
1841
  */
1594
- async submitDirectUntrustTransaction(params) {
1842
+ async submitDirectUntrustTransaction(params, options) {
1843
+ this.assertWallet();
1595
1844
  try {
1596
1845
  const chainId = await this.context.walletClient.getChainId();
1597
1846
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -1599,14 +1848,25 @@ class PermissionsController {
1599
1848
  "DataPortabilityServers"
1600
1849
  );
1601
1850
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
1602
- const account = this.context.walletClient.account ?? await this.getUserAddress();
1851
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1603
1852
  const txHash = await this.context.walletClient.writeContract({
1604
1853
  address: DataPortabilityServersAddress,
1605
1854
  abi: DataPortabilityServersAbi,
1606
1855
  functionName: "untrustServer",
1607
1856
  args: [BigInt(params.serverId)],
1608
1857
  account,
1609
- chain: this.context.walletClient.chain ?? null
1858
+ chain: this.context.walletClient?.chain ?? null,
1859
+ ...options?.gas && { gas: options.gas },
1860
+ ...options?.nonce && { nonce: options.nonce },
1861
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
1862
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
1863
+ ...options.maxFeePerGas && {
1864
+ maxFeePerGas: options.maxFeePerGas
1865
+ },
1866
+ ...options.maxPriorityFeePerGas && {
1867
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
1868
+ }
1869
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
1610
1870
  });
1611
1871
  const { tx } = await import("../utils/transactionHelpers");
1612
1872
  return tx({
@@ -1633,6 +1893,7 @@ class PermissionsController {
1633
1893
  *
1634
1894
  * @param params - Parameters for untrusting the server
1635
1895
  * @param params.serverId - The numeric ID of the server to untrust
1896
+ * @param options - Optional transaction options for gas parameters and timeout
1636
1897
  * @returns Promise resolving to transaction hash
1637
1898
  * @throws {Error} When wallet account is not available
1638
1899
  * @throws {NonceError} When retrieving user nonce fails
@@ -1653,13 +1914,17 @@ class PermissionsController {
1653
1914
  * console.log('Still trusting servers:', trustedServers);
1654
1915
  * ```
1655
1916
  */
1656
- async submitUntrustServer(params) {
1917
+ async submitUntrustServer(params, options) {
1918
+ this.assertWallet();
1657
1919
  const nonce = await this.getServersUserNonce();
1658
1920
  const untrustServerInput = {
1659
1921
  nonce,
1660
1922
  serverId: params.serverId
1661
1923
  };
1662
- return await this.submitDirectUntrustTransaction(untrustServerInput);
1924
+ return await this.submitDirectUntrustTransaction(
1925
+ untrustServerInput,
1926
+ options
1927
+ );
1663
1928
  }
1664
1929
  /**
1665
1930
  * Untrusts a server using a signature (gasless transaction).
@@ -1674,6 +1939,7 @@ class PermissionsController {
1674
1939
  * @throws {BlockchainError} When untrust transaction fails
1675
1940
  */
1676
1941
  async submitUntrustServerWithSignature(params) {
1942
+ this.assertWallet();
1677
1943
  try {
1678
1944
  const nonce = await this.getServersUserNonce();
1679
1945
  const untrustServerInput = {
@@ -1683,15 +1949,28 @@ class PermissionsController {
1683
1949
  const typedData = await this.composeUntrustServerMessage(untrustServerInput);
1684
1950
  const signature = await this.signTypedData(typedData);
1685
1951
  let hash;
1686
- if (this.context.relayerCallbacks?.submitUntrustServer) {
1687
- hash = await this.context.relayerCallbacks.submitUntrustServer(
1952
+ if (this.context.relayer) {
1953
+ const request = {
1954
+ type: "signed",
1955
+ operation: "submitUntrustServer",
1688
1956
  typedData,
1689
1957
  signature
1690
- );
1958
+ };
1959
+ const response = await this.context.relayer(request);
1960
+ if (response.type === "error") {
1961
+ throw new import_errors.RelayerError(response.error);
1962
+ }
1963
+ if (response.type === "submitted") {
1964
+ hash = response.hash;
1965
+ } else if (response.type === "signed") {
1966
+ hash = response.hash;
1967
+ } else {
1968
+ throw new Error("Unexpected response type from relayer");
1969
+ }
1691
1970
  } else {
1692
1971
  hash = await this.submitSignedUntrustTransaction(typedData, signature);
1693
1972
  }
1694
- const account = this.context.walletClient.account ?? await this.getUserAddress();
1973
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
1695
1974
  const { tx } = await import("../utils/transactionHelpers");
1696
1975
  return tx({
1697
1976
  hash,
@@ -1736,8 +2015,8 @@ class PermissionsController {
1736
2015
  */
1737
2016
  async getTrustedServers(userAddress) {
1738
2017
  try {
1739
- const user = userAddress ?? await this.getUserAddress();
1740
- const chainId = await this.context.walletClient.getChainId();
2018
+ const user = userAddress ?? this.context.userAddress;
2019
+ const chainId = await this.context.publicClient.getChainId();
1741
2020
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1742
2021
  chainId,
1743
2022
  "DataPortabilityServers"
@@ -1766,8 +2045,8 @@ class PermissionsController {
1766
2045
  */
1767
2046
  async getTrustedServersCount(userAddress) {
1768
2047
  try {
1769
- const user = userAddress ?? await this.getUserAddress();
1770
- const chainId = await this.context.walletClient.getChainId();
2048
+ const user = userAddress ?? this.context.userAddress;
2049
+ const chainId = await this.context.publicClient.getChainId();
1771
2050
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1772
2051
  chainId,
1773
2052
  "DataPortabilityServers"
@@ -1796,10 +2075,10 @@ class PermissionsController {
1796
2075
  */
1797
2076
  async getTrustedServersPaginated(options = {}) {
1798
2077
  try {
1799
- const user = options.userAddress ?? await this.getUserAddress();
2078
+ const user = options.userAddress ?? this.context.userAddress;
1800
2079
  const limit = options.limit ?? 50;
1801
2080
  const offset = options.offset ?? 0;
1802
- const chainId = await this.context.walletClient.getChainId();
2081
+ const chainId = await this.context.publicClient.getChainId();
1803
2082
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1804
2083
  chainId,
1805
2084
  "DataPortabilityServers"
@@ -1945,7 +2224,7 @@ class PermissionsController {
1945
2224
  };
1946
2225
  }
1947
2226
  try {
1948
- const chainId = await this.context.walletClient.getChainId();
2227
+ const chainId = await this.context.publicClient.getChainId();
1949
2228
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
1950
2229
  chainId,
1951
2230
  "DataPortabilityServers"
@@ -2020,7 +2299,7 @@ class PermissionsController {
2020
2299
  */
2021
2300
  async checkServerTrustStatus(serverId, userAddress) {
2022
2301
  try {
2023
- const user = userAddress ?? await this.getUserAddress();
2302
+ const user = userAddress ?? this.context.userAddress;
2024
2303
  const trustedServers = await this.getTrustedServers(user);
2025
2304
  const trustIndex = trustedServers.findIndex(
2026
2305
  (server) => server === serverId
@@ -2110,7 +2389,7 @@ class PermissionsController {
2110
2389
  * @returns Promise resolving to the EIP-712 domain configuration
2111
2390
  */
2112
2391
  async getServersDomain() {
2113
- const chainId = await this.context.walletClient.getChainId();
2392
+ const chainId = await this.context.publicClient.getChainId();
2114
2393
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2115
2394
  chainId,
2116
2395
  "DataPortabilityServers"
@@ -2129,7 +2408,8 @@ class PermissionsController {
2129
2408
  * @param signature - The cryptographic signature for the transaction
2130
2409
  * @returns Promise resolving to the transaction hash
2131
2410
  */
2132
- async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
2411
+ async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature, options) {
2412
+ this.assertWallet();
2133
2413
  const chainId = await this.context.walletClient.getChainId();
2134
2414
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2135
2415
  chainId,
@@ -2161,8 +2441,17 @@ class PermissionsController {
2161
2441
  },
2162
2442
  formattedSignature
2163
2443
  ],
2164
- account: this.context.walletClient.account ?? await this.getUserAddress(),
2165
- chain: this.context.walletClient.chain ?? null
2444
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2445
+ chain: this.context.walletClient?.chain ?? null,
2446
+ ...options && {
2447
+ gas: options.gas,
2448
+ nonce: options.nonce,
2449
+ // Use EIP-1559 gas pricing if available, otherwise legacy
2450
+ ...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
2451
+ maxFeePerGas: options.maxFeePerGas,
2452
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
2453
+ } : options.gasPrice ? { gasPrice: options.gasPrice } : {}
2454
+ }
2166
2455
  });
2167
2456
  return txHash;
2168
2457
  }
@@ -2173,7 +2462,8 @@ class PermissionsController {
2173
2462
  * @param signature - The cryptographic signature for the transaction
2174
2463
  * @returns Promise resolving to the transaction hash
2175
2464
  */
2176
- async submitTrustServerTransaction(trustServerInput, signature) {
2465
+ async submitTrustServerTransaction(trustServerInput, signature, options) {
2466
+ this.assertWallet();
2177
2467
  const chainId = await this.context.walletClient.getChainId();
2178
2468
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2179
2469
  chainId,
@@ -2192,8 +2482,9 @@ class PermissionsController {
2192
2482
  },
2193
2483
  formattedSignature
2194
2484
  ],
2195
- account: this.context.walletClient.account ?? await this.getUserAddress(),
2196
- chain: this.context.walletClient.chain ?? null
2485
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2486
+ chain: this.context.walletClient?.chain ?? null,
2487
+ ...this.spreadTransactionOptions(options)
2197
2488
  });
2198
2489
  return txHash;
2199
2490
  }
@@ -2204,7 +2495,8 @@ class PermissionsController {
2204
2495
  * @param signature - The cryptographic signature authorizing the revoke
2205
2496
  * @returns Promise resolving to the transaction hash
2206
2497
  */
2207
- async submitDirectRevokeTransaction(typedData, signature) {
2498
+ async submitDirectRevokeTransaction(typedData, signature, options) {
2499
+ this.assertWallet();
2208
2500
  const chainId = await this.context.walletClient.getChainId();
2209
2501
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2210
2502
  chainId,
@@ -2217,8 +2509,17 @@ class PermissionsController {
2217
2509
  abi: DataPortabilityPermissionsAbi,
2218
2510
  functionName: "revokePermissionWithSignature",
2219
2511
  args: [typedData.message, formattedSignature],
2220
- account: this.context.walletClient.account ?? await this.getUserAddress(),
2221
- chain: this.context.walletClient.chain ?? null
2512
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2513
+ chain: this.context.walletClient?.chain ?? null,
2514
+ ...options && {
2515
+ gas: options.gas,
2516
+ nonce: options.nonce,
2517
+ // Use EIP-1559 gas pricing if available, otherwise legacy
2518
+ ...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
2519
+ maxFeePerGas: options.maxFeePerGas,
2520
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
2521
+ } : options.gasPrice ? { gasPrice: options.gasPrice } : {}
2522
+ }
2222
2523
  });
2223
2524
  return txHash;
2224
2525
  }
@@ -2229,7 +2530,8 @@ class PermissionsController {
2229
2530
  * @param signature - The cryptographic signature authorizing the untrust
2230
2531
  * @returns Promise resolving to the transaction hash
2231
2532
  */
2232
- async submitSignedUntrustTransaction(typedData, signature) {
2533
+ async submitSignedUntrustTransaction(typedData, signature, options) {
2534
+ this.assertWallet();
2233
2535
  const chainId = await this.context.walletClient.getChainId();
2234
2536
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2235
2537
  chainId,
@@ -2246,8 +2548,17 @@ class PermissionsController {
2246
2548
  abi: DataPortabilityServersAbi,
2247
2549
  functionName: "untrustServerWithSignature",
2248
2550
  args: [contractMessage, formattedSignature],
2249
- account: this.context.walletClient.account ?? await this.getUserAddress(),
2250
- chain: this.context.walletClient.chain ?? null
2551
+ account: this.context.walletClient?.account ?? this.context.userAddress,
2552
+ chain: this.context.walletClient?.chain ?? null,
2553
+ ...options && {
2554
+ gas: options.gas,
2555
+ nonce: options.nonce,
2556
+ // Use EIP-1559 gas pricing if available, otherwise legacy
2557
+ ...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
2558
+ maxFeePerGas: options.maxFeePerGas,
2559
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
2560
+ } : options.gasPrice ? { gasPrice: options.gasPrice } : {}
2561
+ }
2251
2562
  });
2252
2563
  return txHash;
2253
2564
  }
@@ -2260,14 +2571,18 @@ class PermissionsController {
2260
2571
  * A grantee is an entity (like an application) that can receive data permissions
2261
2572
  * from users. Once registered, users can grant the grantee access to their data.
2262
2573
  *
2574
+ * This method supports gasless transactions via relayer when configured.
2575
+ * If no relayer is available, it falls back to direct wallet transactions.
2576
+ *
2263
2577
  * @param params - Parameters for registering the grantee
2264
2578
  * @param params.owner - The Ethereum address that will own this grantee registration
2265
2579
  * @param params.granteeAddress - The Ethereum address of the grantee (application)
2266
2580
  * @param params.publicKey - The public key used for data encryption/decryption (hex string)
2581
+ * @param options - Optional transaction options for gas parameters and timeout
2267
2582
  * @returns Promise resolving to the transaction hash
2268
2583
  * @throws {BlockchainError} When the grantee registration transaction fails
2269
2584
  * @throws {UserRejectedRequestError} When user rejects the transaction
2270
- * @throws {ContractError} When grantee is already registered
2585
+ * @throws {RelayerError} When gasless transaction submission fails
2271
2586
  *
2272
2587
  * @example
2273
2588
  * ```typescript
@@ -2279,98 +2594,88 @@ class PermissionsController {
2279
2594
  * console.log(`Grantee registered in transaction: ${txHash}`);
2280
2595
  * ```
2281
2596
  */
2282
- async submitRegisterGrantee(params) {
2283
- const chainId = await this.context.walletClient.getChainId();
2284
- const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
2285
- chainId,
2286
- "DataPortabilityGrantees"
2287
- );
2288
- const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2289
- const ownerAddress = (0, import_viem.getAddress)(params.owner);
2290
- const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
2291
- const account = this.context.walletClient.account ?? await this.getUserAddress();
2292
- const txHash = await this.context.walletClient.writeContract({
2293
- address: DataPortabilityGranteesAddress,
2294
- abi: DataPortabilityGranteesAbi,
2295
- functionName: "registerGrantee",
2296
- args: [ownerAddress, granteeAddress, params.publicKey],
2297
- account,
2298
- chain: this.context.walletClient.chain ?? null
2299
- });
2300
- const { tx } = await import("../utils/transactionHelpers");
2301
- return tx({
2302
- hash: txHash,
2303
- from: typeof account === "string" ? account : account.address,
2304
- contract: "DataPortabilityGrantees",
2305
- fn: "registerGrantee"
2306
- });
2307
- }
2308
- /**
2309
- * Registers a grantee with a signature (gasless transaction)
2310
- *
2311
- * @param params - Parameters for registering the grantee
2312
- * @returns Promise resolving to the transaction hash
2313
- *
2314
- * @example
2315
- * ```typescript
2316
- * const txHash = await vana.permissions.registerGranteeWithSignature({
2317
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2318
- * granteeAddress: "0xApp1234567890123456789012345678901234567890",
2319
- * publicKey: "0x1234567890abcdef..."
2320
- * });
2321
- * ```
2322
- */
2323
- async submitRegisterGranteeWithSignature(params) {
2324
- const nonce = await this.getServersUserNonce();
2325
- const owner = (0, import_viem.getAddress)(params.owner);
2326
- const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
2327
- const registerGranteeInput = {
2328
- nonce,
2329
- owner,
2330
- granteeAddress,
2331
- publicKey: params.publicKey
2332
- };
2333
- const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
2334
- const signature = await this.signTypedData(typedData);
2335
- const hash = await this.submitSignedRegisterGranteeTransaction(
2336
- typedData,
2337
- signature
2338
- );
2339
- const account = this.context.walletClient.account ?? await this.getUserAddress();
2340
- const { tx } = await import("../utils/transactionHelpers");
2341
- return tx({
2342
- hash,
2343
- from: typeof account === "string" ? account : account.address,
2344
- contract: "DataPortabilityGrantees",
2345
- fn: "registerGrantee"
2346
- });
2347
- }
2348
- /**
2349
- * Submits a signed register grantee transaction via relayer
2350
- *
2351
- * @param typedData - The EIP-712 typed data for register grantee
2352
- * @param signature - The cryptographic signature
2353
- * @returns Promise resolving to the transaction hash
2354
- *
2355
- * @example
2356
- * ```typescript
2357
- * const result = await vana.permissions.submitSignedRegisterGrantee(typedData, signature);
2358
- * ```
2359
- */
2360
- async submitSignedRegisterGrantee(typedData, signature) {
2361
- const hash = await this.submitSignedRegisterGranteeTransaction(
2362
- typedData,
2363
- signature
2364
- );
2365
- const account = this.context.walletClient.account ?? await this.getUserAddress();
2366
- const { tx } = await import("../utils/transactionHelpers");
2367
- return tx({
2368
- hash,
2369
- from: typeof account === "string" ? account : account.address,
2370
- contract: "DataPortabilityGrantees",
2371
- fn: "registerGrantee"
2372
- });
2597
+ async submitRegisterGrantee(params, options) {
2598
+ try {
2599
+ let hash;
2600
+ if (this.context.relayer) {
2601
+ const request = {
2602
+ type: "direct",
2603
+ operation: "submitRegisterGrantee",
2604
+ params: {
2605
+ owner: params.owner,
2606
+ granteeAddress: params.granteeAddress,
2607
+ publicKey: params.publicKey
2608
+ }
2609
+ };
2610
+ const response = await this.context.relayer(request);
2611
+ if (response.type === "error") {
2612
+ throw new import_errors.RelayerError(response.error);
2613
+ }
2614
+ if (response.type === "submitted") {
2615
+ hash = response.hash;
2616
+ } else if (response.type === "direct") {
2617
+ const result = response.result;
2618
+ hash = result.transactionHash;
2619
+ } else {
2620
+ throw new Error("Unexpected response type from relayer");
2621
+ }
2622
+ } else {
2623
+ this.assertWallet();
2624
+ const chainId = await this.context.walletClient.getChainId();
2625
+ const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
2626
+ chainId,
2627
+ "DataPortabilityGrantees"
2628
+ );
2629
+ const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2630
+ const ownerAddress = (0, import_viem.getAddress)(params.owner);
2631
+ const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
2632
+ const account2 = this.context.walletClient?.account ?? this.context.userAddress;
2633
+ hash = await this.context.walletClient.writeContract({
2634
+ address: DataPortabilityGranteesAddress,
2635
+ abi: DataPortabilityGranteesAbi,
2636
+ functionName: "registerGrantee",
2637
+ args: [ownerAddress, granteeAddress, params.publicKey],
2638
+ account: account2,
2639
+ chain: this.context.walletClient?.chain ?? null,
2640
+ ...this.spreadTransactionOptions(options)
2641
+ });
2642
+ }
2643
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
2644
+ const { tx } = await import("../utils/transactionHelpers");
2645
+ return tx({
2646
+ hash,
2647
+ from: typeof account === "string" ? account : account.address,
2648
+ contract: "DataPortabilityGrantees",
2649
+ fn: "registerGrantee"
2650
+ });
2651
+ } catch (error) {
2652
+ if (error instanceof Error) {
2653
+ if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.BlockchainError) {
2654
+ throw error;
2655
+ }
2656
+ if (error.name === "ContractFunctionExecutionError") {
2657
+ throw new import_errors.BlockchainError(
2658
+ `Grantee registration failed: ${error.message}`,
2659
+ error
2660
+ );
2661
+ }
2662
+ if (error.name === "UserRejectedRequestError") {
2663
+ throw new import_errors.UserRejectedRequestError(
2664
+ "User rejected the grantee registration transaction"
2665
+ );
2666
+ }
2667
+ throw new import_errors.BlockchainError(
2668
+ `Failed to register grantee: ${error.message}`,
2669
+ error
2670
+ );
2671
+ }
2672
+ throw new import_errors.BlockchainError(`Failed to register grantee: ${String(error)}`);
2673
+ }
2373
2674
  }
2675
+ // TODO: When DataPortabilityGrantees contract adds registerGranteeWithSignature function,
2676
+ // implement submitRegisterGranteeWithSignature and submitSignedRegisterGrantee methods
2677
+ // to support EIP-712 signed gasless transactions via relayer.
2678
+ // Current implementation above supports direct gasless transactions (relayer pays gas directly).
2374
2679
  /**
2375
2680
  * Retrieves all registered grantees from the DataPortabilityGrantees contract.
2376
2681
  *
@@ -2418,27 +2723,52 @@ class PermissionsController {
2418
2723
  const total = Number(totalCount);
2419
2724
  const limit = options.limit ?? 50;
2420
2725
  const offset = options.offset ?? 0;
2421
- const grantees = [];
2422
- const endIndex = Math.min(offset + limit, total);
2423
- for (let i = offset; i < endIndex; i++) {
2424
- try {
2425
- const granteeInfo = await this.context.publicClient.readContract({
2426
- address: DataPortabilityGranteesAddress,
2427
- abi: DataPortabilityGranteesAbi,
2428
- functionName: "grantees",
2429
- args: [BigInt(i + 1)]
2430
- // Grantee IDs are 1-indexed
2431
- });
2432
- grantees.push({
2433
- id: i + 1,
2434
- owner: granteeInfo.owner,
2435
- address: granteeInfo.granteeAddress,
2436
- publicKey: granteeInfo.publicKey,
2437
- permissionIds: granteeInfo.permissionIds.map((id) => Number(id))
2438
- });
2439
- } catch (error) {
2440
- console.warn(`Failed to fetch grantee ${i + 1}:`, error);
2441
- }
2726
+ const includePermissions = options.includePermissions ?? true;
2727
+ const startId = total - offset;
2728
+ const endId = Math.max(startId - limit + 1, 1);
2729
+ const granteeIds = Array.from(
2730
+ { length: startId - endId + 1 },
2731
+ (_, i) => startId - i
2732
+ // Generate IDs in descending order
2733
+ );
2734
+ let grantees;
2735
+ if (includePermissions) {
2736
+ const granteePromises = granteeIds.map(
2737
+ (granteeId) => this.getGranteeById(granteeId)
2738
+ );
2739
+ const granteeResults = await Promise.all(granteePromises);
2740
+ grantees = granteeResults.filter(
2741
+ (grantee) => grantee !== null
2742
+ );
2743
+ } else {
2744
+ const granteeInfoPromises = granteeIds.map(
2745
+ async (granteeId) => {
2746
+ try {
2747
+ const granteeInfo = await this.context.publicClient.readContract({
2748
+ address: DataPortabilityGranteesAddress,
2749
+ abi: DataPortabilityGranteesAbi,
2750
+ functionName: "granteesV2",
2751
+ args: [BigInt(granteeId)]
2752
+ });
2753
+ const grantee = {
2754
+ id: granteeId,
2755
+ owner: granteeInfo.owner,
2756
+ address: granteeInfo.granteeAddress,
2757
+ publicKey: granteeInfo.publicKey,
2758
+ permissionIds: []
2759
+ // TypeScript infers number[] from Grantee type
2760
+ };
2761
+ return grantee;
2762
+ } catch (error) {
2763
+ console.warn(`Failed to fetch grantee ${granteeId}:`, error);
2764
+ return null;
2765
+ }
2766
+ }
2767
+ );
2768
+ const granteeInfoResults = await Promise.all(granteeInfoPromises);
2769
+ grantees = granteeInfoResults.filter(
2770
+ (grantee) => grantee !== null
2771
+ );
2442
2772
  }
2443
2773
  return {
2444
2774
  grantees,
@@ -2449,15 +2779,16 @@ class PermissionsController {
2449
2779
  };
2450
2780
  }
2451
2781
  /**
2452
- * Retrieves a specific grantee by their Ethereum address from the DataPortabilityGrantees contract.
2782
+ * Retrieves a specific grantee by their Ethereum wallet address.
2453
2783
  *
2784
+ * @remarks
2454
2785
  * Looks up a registered grantee (application) using their Ethereum address
2455
- * and returns their complete registration information including permissions.
2786
+ * and returns their complete registration information including all associated permissions.
2456
2787
  *
2457
- * @param granteeAddress - The Ethereum address of the grantee to look up
2458
- * @returns Promise resolving to the grantee information, or null if not found
2459
- * @throws {BlockchainError} When contract read operation fails
2460
- * @throws {NetworkError} When unable to connect to the blockchain network
2788
+ * Returns `null` if the address is not registered as a grantee or if an error occurs.
2789
+ *
2790
+ * @param granteeAddress - Ethereum wallet address of the grantee to query
2791
+ * @returns Grantee information including ID, addresses, public key, and permission IDs, or `null` if not found
2461
2792
  *
2462
2793
  * @example
2463
2794
  * ```typescript
@@ -2482,40 +2813,32 @@ class PermissionsController {
2482
2813
  );
2483
2814
  const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2484
2815
  try {
2485
- const granteeInfo = await this.context.publicClient.readContract({
2486
- address: DataPortabilityGranteesAddress,
2487
- abi: DataPortabilityGranteesAbi,
2488
- functionName: "granteeByAddress",
2489
- args: [granteeAddress]
2490
- });
2491
2816
  const granteeId = await this.context.publicClient.readContract({
2492
2817
  address: DataPortabilityGranteesAddress,
2493
2818
  abi: DataPortabilityGranteesAbi,
2494
2819
  functionName: "granteeAddressToId",
2495
2820
  args: [granteeAddress]
2496
2821
  });
2497
- return {
2498
- id: Number(granteeId),
2499
- owner: granteeInfo.owner,
2500
- address: granteeInfo.granteeAddress,
2501
- publicKey: granteeInfo.publicKey,
2502
- permissionIds: granteeInfo.permissionIds.map((id) => Number(id))
2503
- };
2822
+ if (granteeId === 0n) {
2823
+ return null;
2824
+ }
2825
+ return await this.getGranteeById(Number(granteeId));
2504
2826
  } catch (error) {
2505
2827
  console.warn(`Failed to fetch grantee ${granteeAddress}:`, error);
2506
2828
  return null;
2507
2829
  }
2508
2830
  }
2509
2831
  /**
2510
- * Retrieves a specific grantee by their unique ID from the DataPortabilityGrantees contract.
2832
+ * Retrieves a specific grantee by their unique ID.
2511
2833
  *
2834
+ * @remarks
2512
2835
  * Looks up a registered grantee (application) using their numeric ID assigned during
2513
- * registration and returns their complete information including permissions.
2836
+ * registration and returns their complete information including all associated permissions.
2514
2837
  *
2515
- * @param granteeId - The unique numeric ID of the grantee (1-indexed)
2516
- * @returns Promise resolving to the grantee information, or null if not found
2517
- * @throws {BlockchainError} When contract read operation fails
2518
- * @throws {NetworkError} When unable to connect to the blockchain network
2838
+ * Returns `null` if the grantee is not found or if an error occurs during fetching.
2839
+ *
2840
+ * @param granteeId - Unique numeric ID of the grantee (1-indexed)
2841
+ * @returns Grantee information including ID, addresses, public key, and permission IDs, or `null` if not found
2519
2842
  *
2520
2843
  * @example
2521
2844
  * ```typescript
@@ -2523,7 +2846,7 @@ class PermissionsController {
2523
2846
  *
2524
2847
  * if (grantee) {
2525
2848
  * console.log(`Grantee ID: ${grantee.id}`);
2526
- * console.log(`Address: ${grantee.granteeAddress}`);
2849
+ * console.log(`Address: ${grantee.address}`);
2527
2850
  * console.log(`Owner: ${grantee.owner}`);
2528
2851
  * console.log(`Total permissions: ${grantee.permissionIds.length}`);
2529
2852
  * } else {
@@ -2539,85 +2862,29 @@ class PermissionsController {
2539
2862
  );
2540
2863
  const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2541
2864
  try {
2542
- const granteeInfo = await this.context.publicClient.readContract({
2865
+ const granteeInfoResult = await this.context.publicClient.readContract({
2543
2866
  address: DataPortabilityGranteesAddress,
2544
2867
  abi: DataPortabilityGranteesAbi,
2545
- functionName: "grantees",
2868
+ functionName: "granteesV2",
2546
2869
  args: [BigInt(granteeId)]
2547
2870
  });
2871
+ const granteeInfo = granteeInfoResult;
2872
+ const allPermissionIdsResult = await this.getGranteePermissionsPaginated(
2873
+ BigInt(granteeId)
2874
+ );
2875
+ const allPermissionIds = allPermissionIdsResult;
2548
2876
  return {
2549
2877
  id: granteeId,
2550
2878
  owner: granteeInfo.owner,
2551
2879
  address: granteeInfo.granteeAddress,
2552
2880
  publicKey: granteeInfo.publicKey,
2553
- permissionIds: granteeInfo.permissionIds.map((id) => Number(id))
2881
+ permissionIds: allPermissionIds.map((id) => Number(id))
2554
2882
  };
2555
2883
  } catch (error) {
2556
2884
  console.warn(`Failed to fetch grantee ${granteeId}:`, error);
2557
2885
  return null;
2558
2886
  }
2559
2887
  }
2560
- /**
2561
- * Builds EIP-712 typed data for grantee registration
2562
- *
2563
- * @param input - The register grantee input
2564
- * @returns Promise resolving to the typed data structure
2565
- * @private
2566
- */
2567
- async buildRegisterGranteeTypedData(input) {
2568
- const chainId = await this.context.walletClient.getChainId();
2569
- const verifyingContract = (0, import_addresses.getContractAddress)(
2570
- chainId,
2571
- "DataPortabilityGrantees"
2572
- );
2573
- return {
2574
- domain: {
2575
- name: "DataPortabilityGrantees",
2576
- version: "1",
2577
- chainId,
2578
- verifyingContract
2579
- },
2580
- types: {
2581
- RegisterGrantee: [
2582
- { name: "nonce", type: "uint256" },
2583
- { name: "owner", type: "address" },
2584
- { name: "granteeAddress", type: "address" },
2585
- { name: "publicKey", type: "string" }
2586
- ]
2587
- },
2588
- primaryType: "RegisterGrantee",
2589
- message: input
2590
- };
2591
- }
2592
- /**
2593
- * Submits a register grantee transaction with signature.
2594
- *
2595
- * @param typedData - The EIP-712 typed data structure for the registration
2596
- * @param _signature - The cryptographic signature authorizing the registration (currently unused)
2597
- * @returns Promise resolving to the transaction hash
2598
- * @private
2599
- */
2600
- async submitSignedRegisterGranteeTransaction(typedData, _signature) {
2601
- const chainId = await this.context.walletClient.getChainId();
2602
- const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
2603
- chainId,
2604
- "DataPortabilityGrantees"
2605
- );
2606
- const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
2607
- const txHash = await this.context.walletClient.writeContract({
2608
- address: DataPortabilityGranteesAddress,
2609
- abi: DataPortabilityGranteesAbi,
2610
- functionName: "registerGrantee",
2611
- args: [
2612
- typedData.message.owner,
2613
- typedData.message.granteeAddress,
2614
- typedData.message.publicKey
2615
- ],
2616
- account: this.context.walletClient.account ?? await this.getUserAddress(),
2617
- chain: this.context.walletClient.chain ?? null
2618
- });
2619
- return txHash;
2620
- }
2621
2888
  // ===========================
2622
2889
  // DATA PORTABILITY SERVERS HELPER METHODS
2623
2890
  // ===========================
@@ -2629,7 +2896,7 @@ class PermissionsController {
2629
2896
  */
2630
2897
  async getUserServerIds(userAddress) {
2631
2898
  try {
2632
- const targetAddress = userAddress ?? await this.getUserAddress();
2899
+ const targetAddress = userAddress ?? this.context.userAddress;
2633
2900
  const chainId = await this.context.publicClient.getChainId();
2634
2901
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2635
2902
  chainId,
@@ -2687,7 +2954,7 @@ class PermissionsController {
2687
2954
  */
2688
2955
  async getUserServerCount(userAddress) {
2689
2956
  try {
2690
- const targetAddress = userAddress ?? await this.getUserAddress();
2957
+ const targetAddress = userAddress ?? this.context.userAddress;
2691
2958
  const chainId = await this.context.publicClient.getChainId();
2692
2959
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2693
2960
  chainId,
@@ -2716,7 +2983,7 @@ class PermissionsController {
2716
2983
  */
2717
2984
  async getUserTrustedServers(userAddress) {
2718
2985
  try {
2719
- const targetAddress = userAddress ?? await this.getUserAddress();
2986
+ const targetAddress = userAddress ?? this.context.userAddress;
2720
2987
  const chainId = await this.context.publicClient.getChainId();
2721
2988
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
2722
2989
  chainId,
@@ -2833,7 +3100,7 @@ class PermissionsController {
2833
3100
  */
2834
3101
  async getUserPermissionIds(userAddress) {
2835
3102
  try {
2836
- const targetAddress = userAddress ?? await this.getUserAddress();
3103
+ const targetAddress = userAddress ?? this.context.userAddress;
2837
3104
  const chainId = await this.context.publicClient.getChainId();
2838
3105
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2839
3106
  chainId,
@@ -2895,7 +3162,7 @@ class PermissionsController {
2895
3162
  */
2896
3163
  async getUserPermissionCount(userAddress) {
2897
3164
  try {
2898
- const targetAddress = userAddress ?? await this.getUserAddress();
3165
+ const targetAddress = userAddress ?? this.context.userAddress;
2899
3166
  const chainId = await this.context.publicClient.getChainId();
2900
3167
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
2901
3168
  chainId,
@@ -3008,6 +3275,31 @@ class PermissionsController {
3008
3275
  );
3009
3276
  }
3010
3277
  }
3278
+ /**
3279
+ * Retrieves detailed grant file data from IPFS or HTTP storage.
3280
+ *
3281
+ * @remarks
3282
+ * This method automatically uses the SDK's configured downloadRelayer to bypass CORS restrictions.
3283
+ * Use this instead of importing the standalone `retrieveGrantFile` utility.
3284
+ *
3285
+ * @param grantUrl - The grant file URL (from OnChainPermissionGrant.grantUrl)
3286
+ * @returns Promise resolving to the complete grant file with operation details
3287
+ * @throws {NetworkError} When all retrieval attempts fail
3288
+ * @example
3289
+ * ```typescript
3290
+ * const grants = await vana.permissions.getUserPermissionGrantsOnChain();
3291
+ * const grantFile = await vana.permissions.retrieveGrantFile(grants[0].grantUrl);
3292
+ * console.log(`Operation: ${grantFile.operation}`);
3293
+ * ```
3294
+ */
3295
+ async retrieveGrantFile(grantUrl) {
3296
+ const { retrieveGrantFile: retrieveGrantFileUtil } = await import("../utils/grantFiles");
3297
+ return retrieveGrantFileUtil(
3298
+ grantUrl,
3299
+ void 0,
3300
+ this.context.downloadRelayer
3301
+ );
3302
+ }
3011
3303
  /**
3012
3304
  * Get all permissions for a specific file (alias for getFilePermissionIds)
3013
3305
  *
@@ -3033,26 +3325,34 @@ class PermissionsController {
3033
3325
  // DATA PORTABILITY GRANTEES HELPER METHODS
3034
3326
  // ===========================
3035
3327
  /**
3036
- * Get grantee information by grantee ID
3328
+ * Retrieves detailed grantee information including all associated permissions.
3037
3329
  *
3038
- * @param granteeId - Grantee ID to get info for
3039
- * @returns Promise resolving to grantee info
3330
+ * @remarks
3331
+ * Returns grantee metadata and associated permission IDs. Uses the newer
3332
+ * paginated contract method internally for efficient permission fetching.
3333
+ *
3334
+ * @param granteeId - Unique grantee identifier as bigint
3335
+ * @returns Grantee information containing owner address, grantee address, public key, and permission IDs
3336
+ * @throws {BlockchainError} When grantee ID is not found or contract read fails
3337
+ *
3338
+ * @example
3339
+ * ```typescript
3340
+ * const granteeInfo = await vana.permissions.getGranteeInfo(BigInt(1));
3341
+ * console.log(`Grantee ${granteeInfo.granteeAddress} has ${granteeInfo.permissionIds.length} permissions`);
3342
+ * ```
3040
3343
  */
3041
3344
  async getGranteeInfo(granteeId) {
3042
3345
  try {
3043
- const chainId = await this.context.publicClient.getChainId();
3044
- const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
3045
- chainId,
3046
- "DataPortabilityGrantees"
3047
- );
3048
- const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
3049
- const granteeInfo = await this.context.publicClient.readContract({
3050
- address: DataPortabilityGranteesAddress,
3051
- abi: DataPortabilityGranteesAbi,
3052
- functionName: "granteeInfo",
3053
- args: [granteeId]
3054
- });
3055
- return granteeInfo;
3346
+ const grantee = await this.getGranteeById(Number(granteeId));
3347
+ if (!grantee) {
3348
+ throw new Error("Grantee not found");
3349
+ }
3350
+ return {
3351
+ owner: grantee.owner,
3352
+ granteeAddress: grantee.address,
3353
+ publicKey: grantee.publicKey,
3354
+ permissionIds: grantee.permissionIds.map((id) => BigInt(id))
3355
+ };
3056
3356
  } catch (error) {
3057
3357
  throw new import_errors.BlockchainError(
3058
3358
  `Failed to get grantee info: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3061,10 +3361,21 @@ class PermissionsController {
3061
3361
  }
3062
3362
  }
3063
3363
  /**
3064
- * Get grantee information by grantee address
3364
+ * Retrieves detailed grantee information by wallet address.
3065
3365
  *
3066
- * @param granteeAddress - Grantee address to get info for
3067
- * @returns Promise resolving to grantee info
3366
+ * @remarks
3367
+ * Looks up the grantee ID from the provided address, then fetches complete
3368
+ * grantee information including all associated permissions.
3369
+ *
3370
+ * @param granteeAddress - Ethereum wallet address of the grantee to query
3371
+ * @returns Grantee information containing owner address, grantee address, public key, and permission IDs
3372
+ * @throws {BlockchainError} When grantee address is not registered or contract read fails
3373
+ *
3374
+ * @example
3375
+ * ```typescript
3376
+ * const granteeInfo = await vana.permissions.getGranteeInfoByAddress("0x742d35Cc6634c0532925a3b844Bc9e8e1ee3b2De");
3377
+ * console.log(`Found grantee with ${granteeInfo.permissionIds.length} permissions`);
3378
+ * ```
3068
3379
  */
3069
3380
  async getGranteeInfoByAddress(granteeAddress) {
3070
3381
  try {
@@ -3074,13 +3385,26 @@ class PermissionsController {
3074
3385
  "DataPortabilityGrantees"
3075
3386
  );
3076
3387
  const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
3077
- const granteeInfo = await this.context.publicClient.readContract({
3388
+ const granteeIdResult = await this.context.publicClient.readContract({
3078
3389
  address: DataPortabilityGranteesAddress,
3079
3390
  abi: DataPortabilityGranteesAbi,
3080
- functionName: "granteeByAddress",
3391
+ functionName: "granteeAddressToId",
3081
3392
  args: [granteeAddress]
3082
3393
  });
3083
- return granteeInfo;
3394
+ const granteeId = granteeIdResult;
3395
+ if (granteeId === 0n) {
3396
+ throw new Error("Grantee not found");
3397
+ }
3398
+ const grantee = await this.getGranteeById(Number(granteeId));
3399
+ if (!grantee) {
3400
+ throw new Error("Grantee not found");
3401
+ }
3402
+ return {
3403
+ owner: grantee.owner,
3404
+ granteeAddress: grantee.address,
3405
+ publicKey: grantee.publicKey,
3406
+ permissionIds: grantee.permissionIds.map((id) => BigInt(id))
3407
+ };
3084
3408
  } catch (error) {
3085
3409
  throw new import_errors.BlockchainError(
3086
3410
  `Failed to get grantee info by address: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3144,6 +3468,117 @@ class PermissionsController {
3144
3468
  );
3145
3469
  }
3146
3470
  }
3471
+ /**
3472
+ * Retrieves permission IDs for a specific grantee with flexible pagination.
3473
+ *
3474
+ * @remarks
3475
+ * **Pagination Behavior:**
3476
+ * Returns different types based on parameters:
3477
+ * - Without offset/limit: Returns `bigint[]` of all permissions using batched multicall
3478
+ * - With offset/limit: Returns paginated object with `permissionIds`, `totalCount`, and `hasMore`
3479
+ *
3480
+ * Uses gas-aware multicall for efficient batch fetching when retrieving all permissions.
3481
+ *
3482
+ * @param granteeId - Grantee ID to get permissions for
3483
+ * @param options - Optional pagination parameters
3484
+ * @param options.offset - Zero-based starting index for pagination. Defaults to 0 when fetching all permissions. Required for single-page requests.
3485
+ * @param options.limit - Maximum number of permission IDs to return per page. Defaults to 100 when fetching all permissions. Required for single-page requests.
3486
+ * @returns When called without options: Array of all permission IDs as `bigint[]`.
3487
+ * When called with offset and limit: Paginated result object containing `permissionIds` array,
3488
+ * `totalCount`, and `hasMore` boolean.
3489
+ * @throws {BlockchainError} When contract read operation fails
3490
+ *
3491
+ * @example
3492
+ * ```typescript
3493
+ * // Fetch all permissions (no pagination params)
3494
+ * const allPermissions = await vana.permissions.getGranteePermissionsPaginated(BigInt(1));
3495
+ * console.log(`Total permissions: ${allPermissions.length}`);
3496
+ *
3497
+ * // Fetch a specific page (with pagination params)
3498
+ * const page = await vana.permissions.getGranteePermissionsPaginated(BigInt(1), {
3499
+ * offset: BigInt(0),
3500
+ * limit: BigInt(100)
3501
+ * });
3502
+ * console.log(`Fetched ${page.permissionIds.length} permissions`);
3503
+ * console.log(`Total: ${page.totalCount}, Has more: ${page.hasMore}`);
3504
+ *
3505
+ * // Fetch next page
3506
+ * if (page.hasMore) {
3507
+ * const nextPage = await vana.permissions.getGranteePermissionsPaginated(BigInt(1), {
3508
+ * offset: BigInt(100),
3509
+ * limit: BigInt(100)
3510
+ * });
3511
+ * }
3512
+ * ```
3513
+ */
3514
+ async getGranteePermissionsPaginated(granteeId, options) {
3515
+ try {
3516
+ const chainId = await this.context.publicClient.getChainId();
3517
+ const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
3518
+ chainId,
3519
+ "DataPortabilityGrantees"
3520
+ );
3521
+ const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
3522
+ const fetchOnlyOnePage = options?.offset !== void 0 && options?.limit !== void 0;
3523
+ if (fetchOnlyOnePage) {
3524
+ const result = await this.context.publicClient.readContract({
3525
+ address: DataPortabilityGranteesAddress,
3526
+ abi: DataPortabilityGranteesAbi,
3527
+ functionName: "granteePermissionsPaginated",
3528
+ args: [granteeId, options.offset, options.limit]
3529
+ });
3530
+ const [permissionIds, totalCount2, hasMore] = result;
3531
+ return {
3532
+ permissionIds: [...permissionIds],
3533
+ totalCount: totalCount2,
3534
+ hasMore
3535
+ };
3536
+ }
3537
+ const countResult = await this.context.publicClient.readContract({
3538
+ address: DataPortabilityGranteesAddress,
3539
+ abi: DataPortabilityGranteesAbi,
3540
+ functionName: "granteePermissionsPaginated",
3541
+ args: [granteeId, BigInt(0), BigInt(1)]
3542
+ });
3543
+ const [, totalCount] = countResult;
3544
+ if (totalCount === BigInt(0)) {
3545
+ return [];
3546
+ }
3547
+ const batchSize = options?.limit ?? BigInt(100);
3548
+ const startOffset = options?.offset ?? BigInt(0);
3549
+ const endOffset = totalCount;
3550
+ const numBatches = Math.ceil(
3551
+ Number(endOffset - startOffset) / Number(batchSize)
3552
+ );
3553
+ const paginationCalls = Array.from({ length: numBatches }, (_, i) => ({
3554
+ address: DataPortabilityGranteesAddress,
3555
+ abi: DataPortabilityGranteesAbi,
3556
+ functionName: "granteePermissionsPaginated",
3557
+ args: [
3558
+ granteeId,
3559
+ startOffset + BigInt(i) * batchSize,
3560
+ batchSize
3561
+ ]
3562
+ }));
3563
+ const results = await (0, import_multicall.gasAwareMulticall)(
3564
+ this.context.publicClient,
3565
+ {
3566
+ contracts: paginationCalls
3567
+ }
3568
+ );
3569
+ const allPermissionIds = [];
3570
+ for (const result of results) {
3571
+ const [permissionIds] = result;
3572
+ allPermissionIds.push(...permissionIds);
3573
+ }
3574
+ return allPermissionIds;
3575
+ } catch (error) {
3576
+ throw new import_errors.BlockchainError(
3577
+ `Failed to get grantee permissions: ${error instanceof Error ? error.message : "Unknown error"}`,
3578
+ error
3579
+ );
3580
+ }
3581
+ }
3147
3582
  // ===== DataPortabilityServersImplementation Methods =====
3148
3583
  /**
3149
3584
  * Get all server IDs for a user
@@ -3337,9 +3772,11 @@ class PermissionsController {
3337
3772
  *
3338
3773
  * @param serverId - Server ID to update
3339
3774
  * @param url - New URL for the server
3775
+ * @param options - Optional transaction options for gas parameters and timeout
3340
3776
  * @returns Promise resolving to transaction hash
3341
3777
  */
3342
- async submitUpdateServer(serverId, url) {
3778
+ async submitUpdateServer(serverId, url, options) {
3779
+ this.assertWallet();
3343
3780
  try {
3344
3781
  const chainId = await this.context.walletClient.getChainId();
3345
3782
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -3347,14 +3784,25 @@ class PermissionsController {
3347
3784
  "DataPortabilityServers"
3348
3785
  );
3349
3786
  const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
3350
- const account = this.context.walletClient.account ?? await this.getUserAddress();
3787
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3351
3788
  const hash = await this.context.walletClient.writeContract({
3352
3789
  address: DataPortabilityServersAddress,
3353
3790
  abi: DataPortabilityServersAbi,
3354
3791
  functionName: "updateServer",
3355
3792
  args: [serverId, url],
3356
- chain: this.context.walletClient.chain,
3357
- account
3793
+ chain: this.context.walletClient?.chain,
3794
+ account,
3795
+ ...options?.gas && { gas: options.gas },
3796
+ ...options?.nonce && { nonce: options.nonce },
3797
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3798
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3799
+ ...options.maxFeePerGas && {
3800
+ maxFeePerGas: options.maxFeePerGas
3801
+ },
3802
+ ...options.maxPriorityFeePerGas && {
3803
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3804
+ }
3805
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3358
3806
  });
3359
3807
  const { tx } = await import("../utils/transactionHelpers");
3360
3808
  return tx({
@@ -3512,6 +3960,7 @@ class PermissionsController {
3512
3960
  * @throws {NetworkError} When network communication fails
3513
3961
  */
3514
3962
  async submitAddPermission(params) {
3963
+ this.assertWallet();
3515
3964
  try {
3516
3965
  const nonce = await this.getPermissionsUserNonce();
3517
3966
  const addPermissionInput = {
@@ -3549,21 +3998,36 @@ class PermissionsController {
3549
3998
  * @throws {BlockchainError} When permission addition fails
3550
3999
  * @throws {NetworkError} When network communication fails
3551
4000
  */
3552
- async submitSignedAddPermission(typedData, signature) {
4001
+ async submitSignedAddPermission(typedData, signature, options) {
4002
+ this.assertWallet();
3553
4003
  try {
3554
4004
  let hash;
3555
- if (this.context.relayerCallbacks?.submitAddPermission) {
3556
- hash = await this.context.relayerCallbacks.submitAddPermission(
4005
+ if (this.context.relayer) {
4006
+ const request = {
4007
+ type: "signed",
4008
+ operation: "submitAddPermission",
3557
4009
  typedData,
3558
4010
  signature
3559
- );
4011
+ };
4012
+ const response = await this.context.relayer(request);
4013
+ if (response.type === "error") {
4014
+ throw new import_errors.RelayerError(response.error);
4015
+ }
4016
+ if (response.type === "submitted") {
4017
+ hash = response.hash;
4018
+ } else if (response.type === "signed") {
4019
+ hash = response.hash;
4020
+ } else {
4021
+ throw new Error("Unexpected response type from relayer");
4022
+ }
3560
4023
  } else {
3561
4024
  hash = await this.submitDirectAddPermissionTransaction(
3562
4025
  typedData,
3563
- signature
4026
+ signature,
4027
+ options
3564
4028
  );
3565
4029
  }
3566
- const account = this.context.walletClient.account ?? await this.getUserAddress();
4030
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
3567
4031
  const { tx } = await import("../utils/transactionHelpers");
3568
4032
  return tx({
3569
4033
  hash,
@@ -3601,6 +4065,9 @@ class PermissionsController {
3601
4065
  * @param params.serverPublicKey - Server's public key for encryption.
3602
4066
  * Obtain via `vana.server.getIdentity(userAddress).publicKey`.
3603
4067
  * @param params.filePermissions - Nested array of permissions for each file
4068
+ * @param options - Optional transaction options for gas parameters and timeout.
4069
+ * Note: These options are only applied for direct blockchain transactions.
4070
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3604
4071
  * @returns TransactionResult with immediate hash access and optional event data
3605
4072
  * @throws {Error} When schemaIds array length doesn't match fileUrls array length
3606
4073
  * @throws {SchemaValidationError} When file data doesn't match the specified schema.
@@ -3614,6 +4081,7 @@ class PermissionsController {
3614
4081
  *
3615
4082
  * @example
3616
4083
  * ```typescript
4084
+ * // Submit with custom gas parameters and timeout
3617
4085
  * const result = await vana.permissions.submitAddServerFilesAndPermissions({
3618
4086
  * granteeId: BigInt(1),
3619
4087
  * grant: "ipfs://QmXxx...",
@@ -3626,12 +4094,20 @@ class PermissionsController {
3626
4094
  * account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3627
4095
  * key: encryptedKey
3628
4096
  * }]]
4097
+ * }, {
4098
+ * maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
4099
+ * maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
4100
+ * });
4101
+ *
4102
+ * // Wait for confirmation with custom timeout
4103
+ * const receipt = await vana.waitForTransactionReceipt(result, {
4104
+ * timeout: 180000 // 3 minutes
3629
4105
  * });
3630
- * const events = await result.waitForEvents();
3631
- * console.log(`Permission ID: ${events.permissionId}`);
4106
+ * console.log(`Transaction confirmed: ${receipt.transactionHash}`);
3632
4107
  * ```
3633
4108
  */
3634
- async submitAddServerFilesAndPermissions(params) {
4109
+ async submitAddServerFilesAndPermissions(params, options) {
4110
+ this.assertWallet();
3635
4111
  try {
3636
4112
  if (params.schemaIds.length !== params.fileUrls.length) {
3637
4113
  throw new Error(
@@ -3656,7 +4132,8 @@ class PermissionsController {
3656
4132
  const signature = await this.signTypedData(typedData);
3657
4133
  return await this.submitSignedAddServerFilesAndPermissions(
3658
4134
  typedData,
3659
- signature
4135
+ signature,
4136
+ options
3660
4137
  );
3661
4138
  } catch (error) {
3662
4139
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
@@ -3677,6 +4154,9 @@ class PermissionsController {
3677
4154
  *
3678
4155
  * @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
3679
4156
  * @param signature - The user's signature
4157
+ * @param options - Optional transaction options for gas parameters and timeout.
4158
+ * Note: These options are only applied for direct blockchain transactions.
4159
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3680
4160
  * @returns TransactionResult with immediate hash access and optional event data
3681
4161
  * @throws {RelayerError} When gasless transaction submission fails
3682
4162
  * @throws {BlockchainError} When server files and permissions addition fails
@@ -3695,46 +4175,49 @@ class PermissionsController {
3695
4175
  * console.log(`Permission created with ID: ${permissionId}`);
3696
4176
  * ```
3697
4177
  */
3698
- async submitSignedAddServerFilesAndPermissions(typedData, signature) {
4178
+ async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
4179
+ this.assertWallet();
3699
4180
  try {
3700
- console.debug("\u{1F50D} submitSignedAddServerFilesAndPermissions Debug Info:", {
3701
- hasRelayerCallbacks: !!this.context.relayerCallbacks,
3702
- hasSubmitMethod: !!this.context.relayerCallbacks?.submitAddServerFilesAndPermissions,
3703
- availableRelayerMethods: this.context.relayerCallbacks ? Object.keys(this.context.relayerCallbacks) : []
3704
- });
3705
- if (this.context.relayerCallbacks?.submitAddServerFilesAndPermissions) {
4181
+ let hash;
4182
+ if (this.context.relayer) {
3706
4183
  console.debug(
3707
4184
  "\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
3708
4185
  );
3709
- const hash = await this.context.relayerCallbacks.submitAddServerFilesAndPermissions(
4186
+ const request = {
4187
+ type: "signed",
4188
+ operation: "submitAddServerFilesAndPermissions",
3710
4189
  typedData,
3711
4190
  signature
3712
- );
3713
- const account = this.context.walletClient.account ?? await this.getUserAddress();
3714
- const { tx } = await import("../utils/transactionHelpers");
3715
- return tx({
3716
- hash,
3717
- from: typeof account === "string" ? account : account.address,
3718
- contract: "DataPortabilityPermissions",
3719
- fn: "addServerFilesAndPermissions"
3720
- });
4191
+ };
4192
+ const response = await this.context.relayer(request);
4193
+ if (response.type === "error") {
4194
+ throw new import_errors.RelayerError(response.error);
4195
+ }
4196
+ if (response.type === "submitted") {
4197
+ hash = response.hash;
4198
+ } else if (response.type === "signed") {
4199
+ hash = response.hash;
4200
+ } else {
4201
+ throw new Error("Unexpected response type from relayer");
4202
+ }
3721
4203
  } else {
3722
4204
  console.debug(
3723
4205
  "\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
3724
4206
  );
3725
- const hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
4207
+ hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3726
4208
  typedData,
3727
- signature
4209
+ signature,
4210
+ options
3728
4211
  );
3729
- const account = this.context.walletClient.account ?? await this.getUserAddress();
3730
- const { tx } = await import("../utils/transactionHelpers");
3731
- return tx({
3732
- hash,
3733
- from: typeof account === "string" ? account : account.address,
3734
- contract: "DataPortabilityPermissions",
3735
- fn: "addServerFilesAndPermissions"
3736
- });
3737
4212
  }
4213
+ const account = this.context.walletClient?.account ?? this.context.userAddress;
4214
+ const { tx } = await import("../utils/transactionHelpers");
4215
+ return tx({
4216
+ hash,
4217
+ from: typeof account === "string" ? account : account.address,
4218
+ contract: "DataPortabilityPermissions",
4219
+ fn: "addServerFilesAndPermissions"
4220
+ });
3738
4221
  } catch (error) {
3739
4222
  if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
3740
4223
  throw error;
@@ -3749,9 +4232,11 @@ class PermissionsController {
3749
4232
  * Submit permission revocation with signature to the blockchain
3750
4233
  *
3751
4234
  * @param permissionId - Permission ID to revoke
4235
+ * @param options - Optional transaction options for gas parameters and timeout
3752
4236
  * @returns Promise resolving to transaction hash
3753
4237
  */
3754
- async submitRevokePermission(permissionId) {
4238
+ async submitRevokePermission(permissionId, options) {
4239
+ this.assertWallet();
3755
4240
  try {
3756
4241
  const chainId = await this.context.walletClient.getChainId();
3757
4242
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
@@ -3770,8 +4255,19 @@ class PermissionsController {
3770
4255
  abi: DataPortabilityPermissionsAbi,
3771
4256
  functionName: "revokePermission",
3772
4257
  args: [permissionId],
3773
- chain: this.context.walletClient.chain,
3774
- account
4258
+ chain: this.context.walletClient?.chain,
4259
+ account,
4260
+ ...options?.gas && { gas: options.gas },
4261
+ ...options?.nonce && { nonce: options.nonce },
4262
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
4263
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
4264
+ ...options.maxFeePerGas && {
4265
+ maxFeePerGas: options.maxFeePerGas
4266
+ },
4267
+ ...options.maxPriorityFeePerGas && {
4268
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
4269
+ }
4270
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3775
4271
  });
3776
4272
  const { tx } = await import("../utils/transactionHelpers");
3777
4273
  return tx({
@@ -3794,7 +4290,8 @@ class PermissionsController {
3794
4290
  * @param signature - The cryptographic signature authorizing the transaction
3795
4291
  * @returns Promise resolving to the transaction hash
3796
4292
  */
3797
- async submitDirectAddPermissionTransaction(typedData, signature) {
4293
+ async submitDirectAddPermissionTransaction(typedData, signature, options) {
4294
+ this.assertWallet();
3798
4295
  const chainId = await this.context.walletClient.getChainId();
3799
4296
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
3800
4297
  chainId,
@@ -3813,8 +4310,9 @@ class PermissionsController {
3813
4310
  abi: DataPortabilityPermissionsAbi,
3814
4311
  functionName: "addPermission",
3815
4312
  args: [permissionInput, formattedSignature],
3816
- account: this.context.walletClient.account ?? await this.getUserAddress(),
3817
- chain: this.context.walletClient.chain ?? null
4313
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4314
+ chain: this.context.walletClient?.chain ?? null,
4315
+ ...this.spreadTransactionOptions(options)
3818
4316
  });
3819
4317
  return hash;
3820
4318
  }
@@ -3825,8 +4323,9 @@ class PermissionsController {
3825
4323
  * @param signature - The cryptographic signature authorizing the transaction
3826
4324
  * @returns Promise resolving to the transaction hash
3827
4325
  */
3828
- async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
3829
- const chainId = await this.context.walletClient.getChainId();
4326
+ async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
4327
+ this.assertWallet();
4328
+ const chainId = await this.context.publicClient.getChainId();
3830
4329
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
3831
4330
  chainId,
3832
4331
  "DataPortabilityPermissions"
@@ -3848,10 +4347,11 @@ class PermissionsController {
3848
4347
  address: DataPortabilityPermissionsAddress,
3849
4348
  abi: DataPortabilityPermissionsAbi,
3850
4349
  functionName: "addServerFilesAndPermissions",
3851
- // @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
3852
4350
  args: [serverFilesAndPermissionInput, formattedSignature],
3853
- account: this.context.walletClient.account ?? await this.getUserAddress(),
3854
- chain: this.context.walletClient.chain ?? null
4351
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4352
+ chain: this.context.walletClient?.chain ?? null,
4353
+ ...options?.value && { value: options.value },
4354
+ ...this.spreadTransactionOptions(options)
3855
4355
  });
3856
4356
  return hash;
3857
4357
  }