@opendatalabs/vana-sdk 0.1.0-alpha.fd33fc9 → 2.0.0

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 (351) hide show
  1. package/dist/browser.cjs.map +1 -1
  2. package/dist/browser.d.ts +33 -1
  3. package/dist/browser.js.map +1 -1
  4. package/dist/chains/index.cjs.map +1 -1
  5. package/dist/chains/index.d.ts +30 -1
  6. package/dist/chains/index.js.map +1 -1
  7. package/dist/client/__tests__/enhancedResponse.test.d.ts +1 -0
  8. package/dist/client/enhancedResponse.cjs +164 -0
  9. package/dist/client/enhancedResponse.cjs.map +1 -0
  10. package/dist/client/enhancedResponse.d.ts +120 -0
  11. package/dist/client/enhancedResponse.js +138 -0
  12. package/dist/client/enhancedResponse.js.map +1 -0
  13. package/dist/config/chains.cjs.map +1 -1
  14. package/dist/config/chains.d.ts +99 -0
  15. package/dist/config/chains.js.map +1 -1
  16. package/dist/contracts/contractController.cjs.map +1 -1
  17. package/dist/contracts/contractController.d.ts +66 -10
  18. package/dist/contracts/contractController.js.map +1 -1
  19. package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
  20. package/dist/controllers/__tests__/operations.processQueue.test.d.ts +1 -0
  21. package/dist/controllers/base.cjs +33 -0
  22. package/dist/controllers/base.cjs.map +1 -1
  23. package/dist/controllers/base.d.ts +10 -0
  24. package/dist/controllers/base.js +33 -0
  25. package/dist/controllers/base.js.map +1 -1
  26. package/dist/controllers/data.cjs +417 -276
  27. package/dist/controllers/data.cjs.map +1 -1
  28. package/dist/controllers/data.d.ts +246 -193
  29. package/dist/controllers/data.js +430 -279
  30. package/dist/controllers/data.js.map +1 -1
  31. package/dist/controllers/operations.cjs +430 -0
  32. package/dist/controllers/operations.cjs.map +1 -0
  33. package/dist/controllers/operations.d.ts +229 -0
  34. package/dist/controllers/operations.js +406 -0
  35. package/dist/controllers/operations.js.map +1 -0
  36. package/dist/controllers/permissions.cjs +690 -209
  37. package/dist/controllers/permissions.cjs.map +1 -1
  38. package/dist/controllers/permissions.d.ts +196 -68
  39. package/dist/controllers/permissions.js +690 -209
  40. package/dist/controllers/permissions.js.map +1 -1
  41. package/dist/controllers/protocol.cjs.map +1 -1
  42. package/dist/controllers/protocol.d.ts +27 -28
  43. package/dist/controllers/protocol.js.map +1 -1
  44. package/dist/controllers/schemas.cjs +104 -25
  45. package/dist/controllers/schemas.cjs.map +1 -1
  46. package/dist/controllers/schemas.d.ts +88 -40
  47. package/dist/controllers/schemas.js +104 -25
  48. package/dist/controllers/schemas.js.map +1 -1
  49. package/dist/controllers/server.cjs +269 -58
  50. package/dist/controllers/server.cjs.map +1 -1
  51. package/dist/controllers/server.d.ts +157 -52
  52. package/dist/controllers/server.js +269 -58
  53. package/dist/controllers/server.js.map +1 -1
  54. package/dist/core/__tests__/health.test.d.ts +1 -0
  55. package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
  56. package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
  57. package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
  58. package/dist/core/apiClient.cjs +53 -3
  59. package/dist/core/apiClient.cjs.map +1 -1
  60. package/dist/core/apiClient.d.ts +132 -7
  61. package/dist/core/apiClient.js +53 -3
  62. package/dist/core/apiClient.js.map +1 -1
  63. package/dist/core/generics.cjs +30 -3
  64. package/dist/core/generics.cjs.map +1 -1
  65. package/dist/core/generics.d.ts +95 -6
  66. package/dist/core/generics.js +30 -3
  67. package/dist/core/generics.js.map +1 -1
  68. package/dist/core/health.cjs +289 -0
  69. package/dist/core/health.cjs.map +1 -0
  70. package/dist/core/health.d.ts +143 -0
  71. package/dist/core/health.js +265 -0
  72. package/dist/core/health.js.map +1 -0
  73. package/dist/core/inMemoryNonceManager.cjs +138 -0
  74. package/dist/core/inMemoryNonceManager.cjs.map +1 -0
  75. package/dist/core/inMemoryNonceManager.d.ts +69 -0
  76. package/dist/core/inMemoryNonceManager.js +114 -0
  77. package/dist/core/inMemoryNonceManager.js.map +1 -0
  78. package/dist/core/nonceManager.cjs +304 -0
  79. package/dist/core/nonceManager.cjs.map +1 -0
  80. package/dist/core/nonceManager.d.ts +116 -0
  81. package/dist/core/nonceManager.js +280 -0
  82. package/dist/core/nonceManager.js.map +1 -0
  83. package/dist/core/pollingManager.cjs +292 -0
  84. package/dist/core/pollingManager.cjs.map +1 -0
  85. package/dist/core/pollingManager.d.ts +120 -0
  86. package/dist/core/pollingManager.js +268 -0
  87. package/dist/core/pollingManager.js.map +1 -0
  88. package/dist/core.cjs +55 -1
  89. package/dist/core.cjs.map +1 -1
  90. package/dist/core.d.ts +54 -3
  91. package/dist/core.js +55 -1
  92. package/dist/core.js.map +1 -1
  93. package/dist/crypto/ecies/base.cjs +16 -3
  94. package/dist/crypto/ecies/base.cjs.map +1 -1
  95. package/dist/crypto/ecies/base.js +16 -3
  96. package/dist/crypto/ecies/base.js.map +1 -1
  97. package/dist/errors.cjs +29 -0
  98. package/dist/errors.cjs.map +1 -1
  99. package/dist/errors.d.ts +64 -0
  100. package/dist/errors.js +28 -0
  101. package/dist/errors.js.map +1 -1
  102. package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -1
  103. package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -1
  104. package/dist/generated/abi/DLPPerformanceImplementation.cjs +42 -0
  105. package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -1
  106. package/dist/generated/abi/DLPPerformanceImplementation.d.ts +32 -0
  107. package/dist/generated/abi/DLPPerformanceImplementation.js +42 -0
  108. package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -1
  109. package/dist/generated/abi/DLPRegistryImplementation.cjs +5 -5
  110. package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -1
  111. package/dist/generated/abi/DLPRegistryImplementation.d.ts +4 -4
  112. package/dist/generated/abi/DLPRegistryImplementation.js +5 -5
  113. package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -1
  114. package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +166 -2
  115. package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -1
  116. package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +129 -2
  117. package/dist/generated/abi/DLPRewardDeployerImplementation.js +166 -2
  118. package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -1
  119. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +167 -19
  120. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -1
  121. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +127 -14
  122. package/dist/generated/abi/DataPortabilityGranteesImplementation.js +167 -19
  123. package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -1
  124. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +0 -19
  125. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -1
  126. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +0 -14
  127. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +0 -19
  128. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -1
  129. package/dist/generated/abi/DataPortabilityServersImplementation.cjs +0 -19
  130. package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -1
  131. package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +0 -14
  132. package/dist/generated/abi/DataPortabilityServersImplementation.js +0 -19
  133. package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -1
  134. package/dist/generated/abi/DataRegistryImplementation.cjs +0 -13
  135. package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
  136. package/dist/generated/abi/DataRegistryImplementation.d.ts +0 -10
  137. package/dist/generated/abi/DataRegistryImplementation.js +0 -13
  138. package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
  139. package/dist/generated/abi/SwapHelperImplementation.cjs +0 -43
  140. package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -1
  141. package/dist/generated/abi/SwapHelperImplementation.d.ts +0 -35
  142. package/dist/generated/abi/SwapHelperImplementation.js +0 -43
  143. package/dist/generated/abi/SwapHelperImplementation.js.map +1 -1
  144. package/dist/generated/abi/VanaEpochImplementation.cjs +195 -0
  145. package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -1
  146. package/dist/generated/abi/VanaEpochImplementation.d.ts +151 -0
  147. package/dist/generated/abi/VanaEpochImplementation.js +195 -0
  148. package/dist/generated/abi/VanaEpochImplementation.js.map +1 -1
  149. package/dist/generated/abi/VanaPoolEntityImplementation.cjs +22 -65
  150. package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -1
  151. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +17 -51
  152. package/dist/generated/abi/VanaPoolEntityImplementation.js +22 -65
  153. package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -1
  154. package/dist/generated/abi/VanaPoolStakingImplementation.cjs +113 -1
  155. package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -1
  156. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +85 -1
  157. package/dist/generated/abi/VanaPoolStakingImplementation.js +113 -1
  158. package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -1
  159. package/dist/generated/abi/index.d.ts +546 -146
  160. package/dist/generated/event-types.cjs.map +1 -1
  161. package/dist/generated/event-types.d.ts +14 -8
  162. package/dist/generated/eventRegistry.cjs +42 -18
  163. package/dist/generated/eventRegistry.cjs.map +1 -1
  164. package/dist/generated/eventRegistry.js +42 -18
  165. package/dist/generated/eventRegistry.js.map +1 -1
  166. package/dist/generated/server/server-exports.cjs +22 -0
  167. package/dist/generated/server/server-exports.cjs.map +1 -1
  168. package/dist/generated/server/server-exports.d.ts +27 -10
  169. package/dist/generated/server/server-exports.js +17 -0
  170. package/dist/generated/server/server-exports.js.map +1 -1
  171. package/dist/generated/server/server.cjs.map +1 -1
  172. package/dist/generated/server/server.d.ts +771 -402
  173. package/dist/generated/subgraph.cjs +797 -32
  174. package/dist/generated/subgraph.cjs.map +1 -1
  175. package/dist/generated/subgraph.d.ts +135 -0
  176. package/dist/generated/subgraph.js +792 -32
  177. package/dist/generated/subgraph.js.map +1 -1
  178. package/dist/index.browser.d.ts +2 -0
  179. package/dist/index.browser.js +10 -0
  180. package/dist/index.browser.js.map +1 -1
  181. package/dist/index.cjs.map +1 -1
  182. package/dist/index.js.map +1 -1
  183. package/dist/index.node.cjs +26 -0
  184. package/dist/index.node.cjs.map +1 -1
  185. package/dist/index.node.d.ts +49 -5
  186. package/dist/index.node.js +25 -1
  187. package/dist/index.node.js.map +1 -1
  188. package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
  189. package/dist/lib/redisAtomicStore.cjs +201 -0
  190. package/dist/lib/redisAtomicStore.cjs.map +1 -0
  191. package/dist/lib/redisAtomicStore.d.ts +120 -0
  192. package/dist/lib/redisAtomicStore.js +177 -0
  193. package/dist/lib/redisAtomicStore.js.map +1 -0
  194. package/dist/node.cjs.map +1 -1
  195. package/dist/node.d.ts +39 -1
  196. package/dist/node.js.map +1 -1
  197. package/dist/platform/browser.cjs +160 -2
  198. package/dist/platform/browser.cjs.map +1 -1
  199. package/dist/platform/browser.d.ts +232 -12
  200. package/dist/platform/browser.js +160 -2
  201. package/dist/platform/browser.js.map +1 -1
  202. package/dist/platform/interface.cjs.map +1 -1
  203. package/dist/platform/interface.d.ts +283 -90
  204. package/dist/platform/node.cjs +163 -2
  205. package/dist/platform/node.cjs.map +1 -1
  206. package/dist/platform/node.d.ts +69 -6
  207. package/dist/platform/node.js +163 -2
  208. package/dist/platform/node.js.map +1 -1
  209. package/dist/server/relayerHandler.cjs +315 -81
  210. package/dist/server/relayerHandler.cjs.map +1 -1
  211. package/dist/server/relayerHandler.d.ts +35 -2
  212. package/dist/server/relayerHandler.js +315 -81
  213. package/dist/server/relayerHandler.js.map +1 -1
  214. package/dist/storage/index.cjs +3 -0
  215. package/dist/storage/index.cjs.map +1 -1
  216. package/dist/storage/index.d.ts +1 -0
  217. package/dist/storage/index.js +2 -0
  218. package/dist/storage/index.js.map +1 -1
  219. package/dist/storage/manager.cjs +108 -25
  220. package/dist/storage/manager.cjs.map +1 -1
  221. package/dist/storage/manager.d.ts +119 -25
  222. package/dist/storage/manager.js +108 -25
  223. package/dist/storage/manager.js.map +1 -1
  224. package/dist/storage/providers/callback-storage.cjs +86 -15
  225. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  226. package/dist/storage/providers/callback-storage.d.ts +109 -20
  227. package/dist/storage/providers/callback-storage.js +86 -15
  228. package/dist/storage/providers/callback-storage.js.map +1 -1
  229. package/dist/storage/providers/dropbox.cjs +237 -0
  230. package/dist/storage/providers/dropbox.cjs.map +1 -0
  231. package/dist/storage/providers/dropbox.d.ts +39 -0
  232. package/dist/storage/providers/dropbox.js +215 -0
  233. package/dist/storage/providers/dropbox.js.map +1 -0
  234. package/dist/storage/providers/dropbox.test.d.ts +1 -0
  235. package/dist/storage/providers/pinata.cjs.map +1 -1
  236. package/dist/storage/providers/pinata.d.ts +12 -14
  237. package/dist/storage/providers/pinata.js.map +1 -1
  238. package/dist/tests/data-upload-owner-validation.test.d.ts +1 -0
  239. package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
  240. package/dist/types/atomicStore.cjs +31 -0
  241. package/dist/types/atomicStore.cjs.map +1 -0
  242. package/dist/types/atomicStore.d.ts +236 -0
  243. package/dist/types/atomicStore.js +7 -0
  244. package/dist/types/atomicStore.js.map +1 -0
  245. package/dist/types/blockchain.cjs.map +1 -1
  246. package/dist/types/blockchain.d.ts +39 -11
  247. package/dist/types/chains.cjs.map +1 -1
  248. package/dist/types/chains.d.ts +74 -7
  249. package/dist/types/chains.js.map +1 -1
  250. package/dist/types/config.cjs.map +1 -1
  251. package/dist/types/config.d.ts +38 -4
  252. package/dist/types/config.js.map +1 -1
  253. package/dist/types/contracts.cjs.map +1 -1
  254. package/dist/types/contracts.d.ts +71 -7
  255. package/dist/types/controller-context.cjs.map +1 -1
  256. package/dist/types/controller-context.d.ts +4 -1
  257. package/dist/types/data.cjs.map +1 -1
  258. package/dist/types/data.d.ts +11 -10
  259. package/dist/types/generics.cjs.map +1 -1
  260. package/dist/types/generics.d.ts +81 -10
  261. package/dist/types/index.cjs.map +1 -1
  262. package/dist/types/index.d.ts +31 -3
  263. package/dist/types/index.js.map +1 -1
  264. package/dist/types/operationStore.cjs +17 -0
  265. package/dist/types/operationStore.cjs.map +1 -0
  266. package/dist/types/operationStore.d.ts +171 -0
  267. package/dist/types/operationStore.js +1 -0
  268. package/dist/types/operationStore.js.map +1 -0
  269. package/dist/types/operations.cjs +3 -15
  270. package/dist/types/operations.cjs.map +1 -1
  271. package/dist/types/operations.d.ts +131 -39
  272. package/dist/types/operations.js +2 -13
  273. package/dist/types/operations.js.map +1 -1
  274. package/dist/types/options.cjs +17 -0
  275. package/dist/types/options.cjs.map +1 -0
  276. package/dist/types/options.d.ts +308 -0
  277. package/dist/types/options.js +1 -0
  278. package/dist/types/options.js.map +1 -0
  279. package/dist/types/permissions.cjs.map +1 -1
  280. package/dist/types/permissions.d.ts +19 -20
  281. package/dist/types/personal.cjs.map +1 -1
  282. package/dist/types/personal.d.ts +150 -14
  283. package/dist/types/relayer.cjs.map +1 -1
  284. package/dist/types/relayer.d.ts +145 -24
  285. package/dist/types/storage.cjs.map +1 -1
  286. package/dist/types/storage.d.ts +9 -21
  287. package/dist/types/storage.js.map +1 -1
  288. package/dist/types/utils.cjs.map +1 -1
  289. package/dist/types/utils.d.ts +0 -45
  290. package/dist/utils/__tests__/chainQuery.test.d.ts +1 -0
  291. package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
  292. package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
  293. package/dist/utils/chainQuery.cjs +107 -0
  294. package/dist/utils/chainQuery.cjs.map +1 -0
  295. package/dist/utils/chainQuery.d.ts +31 -0
  296. package/dist/utils/chainQuery.js +82 -0
  297. package/dist/utils/chainQuery.js.map +1 -0
  298. package/dist/utils/grantFiles.cjs +4 -1
  299. package/dist/utils/grantFiles.cjs.map +1 -1
  300. package/dist/utils/grantFiles.d.ts +10 -20
  301. package/dist/utils/grantFiles.js +4 -1
  302. package/dist/utils/grantFiles.js.map +1 -1
  303. package/dist/utils/grantValidation.cjs.map +1 -1
  304. package/dist/utils/grantValidation.d.ts +95 -16
  305. package/dist/utils/grantValidation.js.map +1 -1
  306. package/dist/utils/grants.cjs.map +1 -1
  307. package/dist/utils/grants.d.ts +93 -12
  308. package/dist/utils/grants.js.map +1 -1
  309. package/dist/utils/ipfs.cjs +2 -4
  310. package/dist/utils/ipfs.cjs.map +1 -1
  311. package/dist/utils/ipfs.d.ts +1 -1
  312. package/dist/utils/ipfs.js +2 -4
  313. package/dist/utils/ipfs.js.map +1 -1
  314. package/dist/utils/lazy-import.cjs.map +1 -1
  315. package/dist/utils/lazy-import.d.ts +32 -7
  316. package/dist/utils/lazy-import.js.map +1 -1
  317. package/dist/utils/signatureCache.cjs +8 -2
  318. package/dist/utils/signatureCache.cjs.map +1 -1
  319. package/dist/utils/signatureCache.d.ts +49 -8
  320. package/dist/utils/signatureCache.js +8 -2
  321. package/dist/utils/signatureCache.js.map +1 -1
  322. package/dist/utils/subgraphConsistency.cjs +184 -0
  323. package/dist/utils/subgraphConsistency.cjs.map +1 -0
  324. package/dist/utils/subgraphConsistency.d.ts +65 -0
  325. package/dist/utils/subgraphConsistency.js +155 -0
  326. package/dist/utils/subgraphConsistency.js.map +1 -0
  327. package/dist/utils/subgraphMetaCache.cjs +101 -0
  328. package/dist/utils/subgraphMetaCache.cjs.map +1 -0
  329. package/dist/utils/subgraphMetaCache.d.ts +56 -0
  330. package/dist/utils/subgraphMetaCache.js +76 -0
  331. package/dist/utils/subgraphMetaCache.js.map +1 -0
  332. package/dist/utils/subgraphPagination.cjs +104 -0
  333. package/dist/utils/subgraphPagination.cjs.map +1 -0
  334. package/dist/utils/subgraphPagination.d.ts +78 -0
  335. package/dist/utils/subgraphPagination.js +78 -0
  336. package/dist/utils/subgraphPagination.js.map +1 -0
  337. package/dist/utils/transactionHelpers.cjs.map +1 -1
  338. package/dist/utils/transactionHelpers.d.ts +12 -12
  339. package/dist/utils/transactionHelpers.js.map +1 -1
  340. package/dist/utils/typedDataConverter.cjs.map +1 -1
  341. package/dist/utils/typedDataConverter.d.ts +39 -3
  342. package/dist/utils/typedDataConverter.js.map +1 -1
  343. package/dist/utils/urlResolver.cjs +7 -0
  344. package/dist/utils/urlResolver.cjs.map +1 -1
  345. package/dist/utils/urlResolver.d.ts +22 -4
  346. package/dist/utils/urlResolver.js +7 -0
  347. package/dist/utils/urlResolver.js.map +1 -1
  348. package/dist/utils/wallet.cjs.map +1 -1
  349. package/dist/utils/wallet.d.ts +78 -16
  350. package/dist/utils/wallet.js.map +1 -1
  351. package/package.json +3 -1
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Operation storage interfaces for queuing and managing asynchronous operations.
3
+ *
4
+ * @module
5
+ */
6
+ import type { Hash, TransactionReceipt } from "viem";
7
+ import type { UnifiedRelayerRequest } from "./relayer";
8
+ /**
9
+ * The state of an asynchronous, relayed operation.
10
+ *
11
+ * @remarks
12
+ * This is the data the application backend is responsible for persisting.
13
+ * It serves as a complete recovery log for a given operation.
14
+ *
15
+ * @category Operations
16
+ */
17
+ export interface OperationState {
18
+ status: "pending" | "confirmed" | "failed";
19
+ transactionHash: Hash;
20
+ originalRequest: UnifiedRelayerRequest;
21
+ nonce?: number;
22
+ retryCount: number;
23
+ lastAttemptedGas: {
24
+ maxFeePerGas?: string;
25
+ maxPriorityFeePerGas?: string;
26
+ };
27
+ submittedAt: number;
28
+ finalReceipt?: TransactionReceipt;
29
+ error?: string;
30
+ }
31
+ /**
32
+ * Simple storage interface for operation state tracking.
33
+ *
34
+ * @remarks
35
+ * This interface is used by the relayer handler to track operation state
36
+ * in a stateful mode. Implementations can use any backend storage system.
37
+ *
38
+ * @category Operations
39
+ */
40
+ export interface IRelayerStateStore {
41
+ /**
42
+ * Gets the state of an operation.
43
+ *
44
+ * @param operationId - The operation ID
45
+ * @returns The operation state or null if not found
46
+ */
47
+ get(operationId: string): Promise<OperationState | null>;
48
+ /**
49
+ * Sets the state of an operation.
50
+ *
51
+ * @param operationId - The operation ID
52
+ * @param state - The operation state to store
53
+ */
54
+ set(operationId: string, state: OperationState): Promise<void>;
55
+ }
56
+ /**
57
+ * Represents a stored operation in the queue.
58
+ */
59
+ export interface StoredOperation {
60
+ /** Unique identifier for the operation */
61
+ id: string;
62
+ /** Current status of the operation */
63
+ status: "queued" | "processing" | "submitted" | "completed" | "failed";
64
+ /** Serialized transaction or operation data */
65
+ data: string;
66
+ /** Number of retry attempts */
67
+ retryCount?: number;
68
+ /** Timestamp when the operation was created */
69
+ createdAt?: number;
70
+ /** Additional metadata */
71
+ metadata?: any;
72
+ }
73
+ /**
74
+ * Interface for operation storage backends.
75
+ *
76
+ * @remarks
77
+ * Implementations of this interface provide persistent storage for queued
78
+ * operations in a distributed relayer system. This allows operations to
79
+ * be processed asynchronously and recovered after failures.
80
+ *
81
+ * Common implementations include:
82
+ * - PostgreSQL for production environments
83
+ * - MongoDB for document-based storage
84
+ * - DynamoDB for serverless deployments
85
+ * - In-memory storage for testing
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * class PostgresOperationStore implements IOperationStore {
90
+ * async storeOperation(operation) {
91
+ * await this.db.query(
92
+ * 'INSERT INTO operations (id, status, data) VALUES ($1, $2, $3)',
93
+ * [operation.id, 'queued', operation.data]
94
+ * );
95
+ * }
96
+ *
97
+ * async getQueuedOperations(options) {
98
+ * const result = await this.db.query(
99
+ * 'SELECT * FROM operations WHERE status = $1 LIMIT $2',
100
+ * ['queued', options.limit || 100]
101
+ * );
102
+ * return result.rows;
103
+ * }
104
+ * }
105
+ * ```
106
+ *
107
+ * @category Storage
108
+ */
109
+ export interface IOperationStore {
110
+ /**
111
+ * Stores a new operation in the queue.
112
+ *
113
+ * @param operation - The operation to store
114
+ * @returns Promise that resolves when the operation is stored
115
+ */
116
+ storeOperation(operation: {
117
+ id: string;
118
+ data: any;
119
+ metadata?: any;
120
+ }): Promise<void>;
121
+ /**
122
+ * Retrieves queued operations for processing.
123
+ *
124
+ * @param options - Query options
125
+ * @returns Promise resolving to an array of queued operations
126
+ */
127
+ getQueuedOperations(options?: {
128
+ limit?: number;
129
+ }): Promise<StoredOperation[]>;
130
+ /**
131
+ * Updates the status of an operation.
132
+ *
133
+ * @param operationId - The ID of the operation to update
134
+ * @param status - The new status
135
+ * @param metadata - Optional metadata to store with the update
136
+ * @returns Promise that resolves when the status is updated
137
+ */
138
+ updateStatus(operationId: string, status: string, metadata?: any): Promise<void>;
139
+ /**
140
+ * Gets operations currently being processed.
141
+ *
142
+ * @param options - Query options
143
+ * @returns Promise resolving to an array of processing operations
144
+ */
145
+ getProcessingOperations?(options?: {
146
+ limit?: number;
147
+ }): Promise<StoredOperation[]>;
148
+ /**
149
+ * Gets failed operations.
150
+ *
151
+ * @param options - Query options
152
+ * @returns Promise resolving to an array of failed operations
153
+ */
154
+ getFailedOperations?(options?: {
155
+ limit?: number;
156
+ }): Promise<StoredOperation[]>;
157
+ /**
158
+ * Gets the status of a specific operation.
159
+ *
160
+ * @param operationId - The ID of the operation to check
161
+ * @returns Promise resolving to the operation or null if not found
162
+ */
163
+ getOperation?(operationId: string): Promise<StoredOperation | null>;
164
+ /**
165
+ * Deletes an operation from storage.
166
+ *
167
+ * @param operationId - The ID of the operation to delete
168
+ * @returns Promise that resolves when the operation is deleted
169
+ */
170
+ deleteOperation?(operationId: string): Promise<void>;
171
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=operationStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -21,12 +21,11 @@ __export(operations_exports, {
21
21
  getOperationId: () => getOperationId,
22
22
  getTransactionHash: () => getTransactionHash,
23
23
  isOperation: () => isOperation,
24
- isTransactionResult: () => isTransactionResult,
25
- toOperation: () => toOperation
24
+ isTransactionResult: () => isTransactionResult
26
25
  });
27
26
  module.exports = __toCommonJS(operations_exports);
28
27
  function isOperation(obj) {
29
- return typeof obj === "object" && obj !== null && "id" in obj && "status" in obj && typeof obj.id === "string" && typeof obj.status === "string";
28
+ return typeof obj === "object" && obj !== null && "kind" in obj && "id" in obj && "status" in obj && obj.kind === "OperationStatus" && typeof obj.id === "string" && typeof obj.status === "string";
30
29
  }
31
30
  function isTransactionResult(obj) {
32
31
  if (typeof obj !== "object" || obj === null || !("hash" in obj)) {
@@ -35,16 +34,6 @@ function isTransactionResult(obj) {
35
34
  const { hash } = obj;
36
35
  return typeof hash === "string" && hash.startsWith("0x");
37
36
  }
38
- function toOperation(response) {
39
- return {
40
- id: response.id,
41
- status: response.status,
42
- createdAt: Date.now(),
43
- // Server doesn't provide this, so we use current time
44
- result: response.status === "succeeded" ? response.result : void 0,
45
- error: response.status === "failed" ? response.result ?? void 0 : void 0
46
- };
47
- }
48
37
  function getOperationId(opOrId) {
49
38
  return typeof opOrId === "string" ? opOrId : opOrId.id;
50
39
  }
@@ -59,7 +48,6 @@ function getTransactionHash(txOrHash) {
59
48
  getOperationId,
60
49
  getTransactionHash,
61
50
  isOperation,
62
- isTransactionResult,
63
- toOperation
51
+ isTransactionResult
64
52
  });
65
53
  //# sourceMappingURL=operations.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/operations.ts"],"sourcesContent":["import type { Hash, TransactionReceipt as ViemReceipt, Address } from \"viem\";\nimport type { GetOperationResponse } from \"../generated/server/server-exports\";\nimport type { Contract, Fn } from \"../generated/event-types\";\n\n/**\n * Server operation result as a plain object.\n * Fully serializable for API responses and cross-process communication.\n */\nexport interface Operation<T = unknown> {\n /** Unique operation identifier */\n id: string;\n /** Current operation status */\n status: \"starting\" | \"running\" | \"succeeded\" | \"failed\" | \"canceled\";\n /** Unix timestamp when operation was created */\n createdAt: number;\n /** Unix timestamp when operation was last updated */\n updatedAt?: number;\n /** Operation result when status is 'succeeded' */\n result?: T;\n /** Error message when status is 'failed' */\n error?: string;\n /** Additional operation metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Represents a submitted blockchain transaction as a self-describing POJO.\n *\n * @remarks\n * Transaction results MUST include contract and function for proper event parsing.\n * This is a strongly-typed, heuristic-free design following POJO architecture.\n */\nexport interface TransactionResult<\n C extends Contract = Contract,\n F extends Fn<C> = Fn<C>,\n> {\n /** Transaction hash for tracking and confirmation */\n hash: Hash;\n /** Sender's wallet address */\n from: Address;\n /** Contract that was called (required for event parsing) */\n contract: C;\n /** Function that was called (required for event parsing) */\n fn: F;\n /** Network chain ID where transaction was submitted */\n chainId?: number;\n /** Transaction value in wei (for payable functions) */\n value?: bigint;\n /** Transaction sequence number for the sender */\n nonce?: number;\n /** Contract address (if different from standard deployment) */\n to?: Address;\n}\n\n/**\n * Extended transaction receipt with Vana-specific fields\n */\nexport interface TransactionReceipt extends ViemReceipt {\n /** Parsed event data if available */\n events?: unknown;\n}\n\n/**\n * Options for polling operations\n */\nexport interface PollingOptions {\n /** Polling interval in milliseconds (default: 500) */\n pollingInterval?: number;\n /** Maximum time to wait in milliseconds (default: 30000) */\n timeout?: number;\n}\n\n/**\n * Options for waiting for transaction confirmation\n */\nexport interface TransactionWaitOptions {\n /** Number of confirmations to wait for (default: 1) */\n confirmations?: number;\n /** Polling interval in milliseconds (default: 1000) */\n pollingInterval?: number;\n /** Maximum time to wait in milliseconds (default: 30000) */\n timeout?: number;\n}\n\n/**\n * Validates whether an object conforms to the Operation interface.\n *\n * @param obj - The object to validate as an Operation.\n * @returns `true` if the object has required Operation properties, `false` otherwise.\n */\nexport function isOperation(obj: unknown): obj is Operation {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"id\" in obj &&\n \"status\" in obj &&\n typeof (obj as Record<string, unknown>).id === \"string\" &&\n typeof (obj as Record<string, unknown>).status === \"string\"\n );\n}\n\n/**\n * Validates whether an object conforms to the TransactionResult interface.\n *\n * @param obj - The object to validate as a TransactionResult.\n * @returns `true` if the object has a valid transaction hash, `false` otherwise.\n */\nexport function isTransactionResult(obj: unknown): obj is TransactionResult {\n if (typeof obj !== \"object\" || obj === null || !(\"hash\" in obj)) {\n return false;\n }\n const { hash } = obj as Record<string, unknown>;\n return typeof hash === \"string\" && hash.startsWith(\"0x\");\n}\n\n/**\n * Converts a server response to an Operation POJO.\n *\n * @param response - The raw server response containing operation status data.\n * @returns An Operation object with normalized fields for client consumption.\n */\nexport function toOperation<T>(response: GetOperationResponse): Operation<T> {\n return {\n id: response.id,\n status: response.status as Operation[\"status\"],\n createdAt: Date.now(), // Server doesn't provide this, so we use current time\n result:\n response.status === \"succeeded\" ? (response.result as T) : undefined,\n error:\n response.status === \"failed\" ? (response.result ?? undefined) : undefined,\n };\n}\n\n/**\n * Extracts the operation ID from flexible input types.\n *\n * @param opOrId - An Operation object containing an `id` field or a raw operation ID string.\n * @returns The operation ID string for use in API calls.\n */\nexport function getOperationId(opOrId: Operation | string): string {\n return typeof opOrId === \"string\" ? opOrId : opOrId.id;\n}\n\n/**\n * Extracts the transaction hash from flexible input types.\n *\n * @param txOrHash - A TransactionResult object, any object with a `hash` field, or a raw hash string.\n * @returns The transaction hash as a `0x`-prefixed string.\n */\nexport function getTransactionHash(\n txOrHash: TransactionResult | { hash: Hash } | Hash,\n): Hash {\n if (typeof txOrHash === \"string\") {\n return txOrHash;\n }\n return txOrHash.hash;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0FO,SAAS,YAAY,KAAgC;AAC1D,SACE,OAAO,QAAQ,YACf,QAAQ,QACR,QAAQ,OACR,YAAY,OACZ,OAAQ,IAAgC,OAAO,YAC/C,OAAQ,IAAgC,WAAW;AAEvD;AAQO,SAAS,oBAAoB,KAAwC;AAC1E,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,EAAE,UAAU,MAAM;AAC/D,WAAO;AAAA,EACT;AACA,QAAM,EAAE,KAAK,IAAI;AACjB,SAAO,OAAO,SAAS,YAAY,KAAK,WAAW,IAAI;AACzD;AAQO,SAAS,YAAe,UAA8C;AAC3E,SAAO;AAAA,IACL,IAAI,SAAS;AAAA,IACb,QAAQ,SAAS;AAAA,IACjB,WAAW,KAAK,IAAI;AAAA;AAAA,IACpB,QACE,SAAS,WAAW,cAAe,SAAS,SAAe;AAAA,IAC7D,OACE,SAAS,WAAW,WAAY,SAAS,UAAU,SAAa;AAAA,EACpE;AACF;AAQO,SAAS,eAAe,QAAoC;AACjE,SAAO,OAAO,WAAW,WAAW,SAAS,OAAO;AACtD;AAQO,SAAS,mBACd,UACM;AACN,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO;AAAA,EACT;AACA,SAAO,SAAS;AAClB;","names":[]}
1
+ {"version":3,"sources":["../../src/types/operations.ts"],"sourcesContent":["import type { Hash, TransactionReceipt as ViemReceipt, Address } from \"viem\";\nimport type {\n GetOperationResponse,\n ArtifactInfo,\n} from \"../generated/server/server-exports\";\nimport type { Contract, Fn } from \"../generated/event-types\";\n\n// Re-export TransactionOptions from the new options module\nexport type { TransactionOptions } from \"./options\";\n\n/**\n * Represents an artifact generated by a server operation.\n *\n * @remarks\n * Artifacts are files generated during operations like Gemini agent analysis.\n * These can be downloaded separately using the artifact download API.\n * This type is imported directly from the server's OpenAPI schema.\n *\n * @category Operations\n */\nexport type Artifact = ArtifactInfo;\n\n/**\n * Represents a server-side operation status and result.\n *\n * @remarks\n * Operations track asynchronous server processes like data refinement or ML inference.\n * Poll operation status using `vana.server.waitForOperation()` until completion.\n * This type is now directly imported from the server's OpenAPI schema for type safety.\n *\n * @category Operations\n * @see {@link https://docs.vana.org/docs/operations | Operations Guide}\n */\nexport type Operation = GetOperationResponse;\n\n/**\n * Represents a submitted blockchain transaction as a self-describing POJO.\n *\n * @remarks\n * Transaction results MUST include contract and function for proper event parsing.\n * This strongly-typed design enables automatic event extraction without heuristics.\n * Use `vana.waitForTransactionEvents()` to retrieve typed events from the receipt.\n *\n * **Architecture:**\n * POJOs (Plain Old JavaScript Objects) ensure serialization safety and framework\n * independence. Contract and function fields enable deterministic event parsing.\n *\n * @category Operations\n * @example\n * ```typescript\n * const result: TransactionResult = {\n * hash: '0x123...',\n * from: '0x456...',\n * contract: 'DataRegistry',\n * fn: 'addFile',\n * chainId: 14800\n * };\n *\n * // Wait for events\n * const events = await vana.waitForTransactionEvents(result);\n * ```\n */\nexport interface TransactionResult<\n C extends Contract = Contract,\n F extends Fn<C> = Fn<C>,\n> {\n /** Transaction hash for tracking and confirmation */\n hash: Hash;\n /** Sender's wallet address */\n from: Address;\n /** Contract that was called (required for event parsing) */\n contract: C;\n /** Function that was called (required for event parsing) */\n fn: F;\n /** Network chain ID where transaction was submitted */\n chainId?: number;\n /** Transaction value in wei (for payable functions) */\n value?: bigint;\n /** Transaction sequence number for the sender */\n nonce?: number;\n /** Contract address (if different from standard deployment) */\n to?: Address;\n}\n\n/**\n * Extends viem's TransactionReceipt with Vana-specific event data.\n *\n * @remarks\n * Includes parsed event data when available after transaction confirmation.\n * Use this for detailed transaction analysis and event processing.\n *\n * @category Operations\n */\nexport interface TransactionReceipt extends ViemReceipt {\n /** Parsed event data if available */\n events?: unknown;\n}\n\n/**\n * Configures polling behavior for asynchronous operations.\n *\n * @remarks\n * Controls how frequently and how long to poll for operation completion.\n * Lower intervals provide faster updates but increase server load.\n *\n * @category Operations\n */\nexport interface PollingOptions {\n /** Polling interval in milliseconds (default: 500) */\n pollingInterval?: number;\n /** Maximum time to wait in milliseconds (default: 30000) */\n timeout?: number;\n}\n\n/**\n * Configures transaction confirmation waiting behavior.\n *\n * @remarks\n * Controls confirmation depth and timeout for transaction finality.\n * Higher confirmations provide more security against chain reorganizations.\n *\n * @category Operations\n */\nexport interface TransactionWaitOptions {\n /** Number of confirmations to wait for (default: 1) */\n confirmations?: number;\n /** Polling interval in milliseconds (default: 1000) */\n pollingInterval?: number;\n /** Maximum time to wait in milliseconds (default: 30000) */\n timeout?: number;\n}\n\n/**\n * Validates whether an object conforms to the Operation (GetOperationResponse) type.\n *\n * @remarks\n * Type guard for runtime validation of operation objects from external sources.\n * Use when deserializing operations from API responses or storage.\n * Validates against the server's OpenAPI schema structure.\n *\n * @param obj - The object to validate as an Operation\n * @returns `true` if the object has required Operation properties, `false` otherwise\n *\n * @example\n * ```typescript\n * const response = await fetch('/api/operation/123');\n * const data = await response.json();\n *\n * if (isOperation(data)) {\n * console.log(`Operation ${data.id}: ${data.status}`);\n * }\n * ```\n *\n * @category Operations\n */\nexport function isOperation(obj: unknown): obj is Operation {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"kind\" in obj &&\n \"id\" in obj &&\n \"status\" in obj &&\n (obj as Record<string, unknown>).kind === \"OperationStatus\" &&\n typeof (obj as Record<string, unknown>).id === \"string\" &&\n typeof (obj as Record<string, unknown>).status === \"string\"\n );\n}\n\n/**\n * Validates whether an object conforms to the TransactionResult interface.\n *\n * @remarks\n * Type guard for runtime validation of transaction results.\n * Checks for required hash field with proper `0x` prefix.\n *\n * @param obj - The object to validate as a TransactionResult\n * @returns `true` if the object has a valid transaction hash, `false` otherwise\n *\n * @example\n * ```typescript\n * if (isTransactionResult(result)) {\n * await vana.waitForTransactionEvents(result);\n * }\n * ```\n *\n * @category Operations\n */\nexport function isTransactionResult(obj: unknown): obj is TransactionResult {\n if (typeof obj !== \"object\" || obj === null || !(\"hash\" in obj)) {\n return false;\n }\n const { hash } = obj as Record<string, unknown>;\n return typeof hash === \"string\" && hash.startsWith(\"0x\");\n}\n\n/**\n * Extracts the operation ID from flexible input types.\n *\n * @remarks\n * Utility for handling both Operation objects and raw ID strings.\n * Enables flexible API design accepting either format.\n *\n * @param opOrId - An Operation object containing an `id` field or a raw operation ID string\n * @returns The operation ID string for use in API calls\n *\n * @example\n * ```typescript\n * // Works with both formats\n * await vana.server.getOperation(operation); // Operation object\n * await vana.server.getOperation('op-123'); // ID string\n * ```\n *\n * @category Operations\n */\nexport function getOperationId(opOrId: Operation | string): string {\n return typeof opOrId === \"string\" ? opOrId : opOrId.id;\n}\n\n/**\n * Extracts the transaction hash from flexible input types.\n *\n * @remarks\n * Utility for handling TransactionResult objects, hash objects, or raw hash strings.\n * Enables consistent hash extraction across different transaction representations.\n *\n * @param txOrHash - A TransactionResult object, any object with a `hash` field, or a raw hash string\n * @returns The transaction hash as a `0x`-prefixed string\n *\n * @example\n * ```typescript\n * // All these work\n * const hash1 = getTransactionHash(transactionResult);\n * const hash2 = getTransactionHash({ hash: '0x123...' });\n * const hash3 = getTransactionHash('0x123...');\n * ```\n *\n * @category Operations\n */\nexport function getTransactionHash(\n txOrHash: TransactionResult | { hash: Hash } | Hash,\n): Hash {\n if (typeof txOrHash === \"string\") {\n return txOrHash;\n }\n return txOrHash.hash;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2JO,SAAS,YAAY,KAAgC;AAC1D,SACE,OAAO,QAAQ,YACf,QAAQ,QACR,UAAU,OACV,QAAQ,OACR,YAAY,OACX,IAAgC,SAAS,qBAC1C,OAAQ,IAAgC,OAAO,YAC/C,OAAQ,IAAgC,WAAW;AAEvD;AAqBO,SAAS,oBAAoB,KAAwC;AAC1E,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,EAAE,UAAU,MAAM;AAC/D,WAAO;AAAA,EACT;AACA,QAAM,EAAE,KAAK,IAAI;AACjB,SAAO,OAAO,SAAS,YAAY,KAAK,WAAW,IAAI;AACzD;AAqBO,SAAS,eAAe,QAAoC;AACjE,SAAO,OAAO,WAAW,WAAW,SAAS,OAAO;AACtD;AAsBO,SAAS,mBACd,UACM;AACN,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO;AAAA,EACT;AACA,SAAO,SAAS;AAClB;","names":[]}
@@ -1,32 +1,56 @@
1
1
  import type { Hash, TransactionReceipt as ViemReceipt, Address } from "viem";
2
- import type { GetOperationResponse } from "../generated/server/server-exports";
2
+ import type { GetOperationResponse, ArtifactInfo } from "../generated/server/server-exports";
3
3
  import type { Contract, Fn } from "../generated/event-types";
4
+ export type { TransactionOptions } from "./options";
4
5
  /**
5
- * Server operation result as a plain object.
6
- * Fully serializable for API responses and cross-process communication.
6
+ * Represents an artifact generated by a server operation.
7
+ *
8
+ * @remarks
9
+ * Artifacts are files generated during operations like Gemini agent analysis.
10
+ * These can be downloaded separately using the artifact download API.
11
+ * This type is imported directly from the server's OpenAPI schema.
12
+ *
13
+ * @category Operations
7
14
  */
8
- export interface Operation<T = unknown> {
9
- /** Unique operation identifier */
10
- id: string;
11
- /** Current operation status */
12
- status: "starting" | "running" | "succeeded" | "failed" | "canceled";
13
- /** Unix timestamp when operation was created */
14
- createdAt: number;
15
- /** Unix timestamp when operation was last updated */
16
- updatedAt?: number;
17
- /** Operation result when status is 'succeeded' */
18
- result?: T;
19
- /** Error message when status is 'failed' */
20
- error?: string;
21
- /** Additional operation metadata */
22
- metadata?: Record<string, unknown>;
23
- }
15
+ export type Artifact = ArtifactInfo;
16
+ /**
17
+ * Represents a server-side operation status and result.
18
+ *
19
+ * @remarks
20
+ * Operations track asynchronous server processes like data refinement or ML inference.
21
+ * Poll operation status using `vana.server.waitForOperation()` until completion.
22
+ * This type is now directly imported from the server's OpenAPI schema for type safety.
23
+ *
24
+ * @category Operations
25
+ * @see {@link https://docs.vana.org/docs/operations | Operations Guide}
26
+ */
27
+ export type Operation = GetOperationResponse;
24
28
  /**
25
29
  * Represents a submitted blockchain transaction as a self-describing POJO.
26
30
  *
27
31
  * @remarks
28
32
  * Transaction results MUST include contract and function for proper event parsing.
29
- * This is a strongly-typed, heuristic-free design following POJO architecture.
33
+ * This strongly-typed design enables automatic event extraction without heuristics.
34
+ * Use `vana.waitForTransactionEvents()` to retrieve typed events from the receipt.
35
+ *
36
+ * **Architecture:**
37
+ * POJOs (Plain Old JavaScript Objects) ensure serialization safety and framework
38
+ * independence. Contract and function fields enable deterministic event parsing.
39
+ *
40
+ * @category Operations
41
+ * @example
42
+ * ```typescript
43
+ * const result: TransactionResult = {
44
+ * hash: '0x123...',
45
+ * from: '0x456...',
46
+ * contract: 'DataRegistry',
47
+ * fn: 'addFile',
48
+ * chainId: 14800
49
+ * };
50
+ *
51
+ * // Wait for events
52
+ * const events = await vana.waitForTransactionEvents(result);
53
+ * ```
30
54
  */
31
55
  export interface TransactionResult<C extends Contract = Contract, F extends Fn<C> = Fn<C>> {
32
56
  /** Transaction hash for tracking and confirmation */
@@ -47,14 +71,26 @@ export interface TransactionResult<C extends Contract = Contract, F extends Fn<C
47
71
  to?: Address;
48
72
  }
49
73
  /**
50
- * Extended transaction receipt with Vana-specific fields
74
+ * Extends viem's TransactionReceipt with Vana-specific event data.
75
+ *
76
+ * @remarks
77
+ * Includes parsed event data when available after transaction confirmation.
78
+ * Use this for detailed transaction analysis and event processing.
79
+ *
80
+ * @category Operations
51
81
  */
52
82
  export interface TransactionReceipt extends ViemReceipt {
53
83
  /** Parsed event data if available */
54
84
  events?: unknown;
55
85
  }
56
86
  /**
57
- * Options for polling operations
87
+ * Configures polling behavior for asynchronous operations.
88
+ *
89
+ * @remarks
90
+ * Controls how frequently and how long to poll for operation completion.
91
+ * Lower intervals provide faster updates but increase server load.
92
+ *
93
+ * @category Operations
58
94
  */
59
95
  export interface PollingOptions {
60
96
  /** Polling interval in milliseconds (default: 500) */
@@ -63,7 +99,13 @@ export interface PollingOptions {
63
99
  timeout?: number;
64
100
  }
65
101
  /**
66
- * Options for waiting for transaction confirmation
102
+ * Configures transaction confirmation waiting behavior.
103
+ *
104
+ * @remarks
105
+ * Controls confirmation depth and timeout for transaction finality.
106
+ * Higher confirmations provide more security against chain reorganizations.
107
+ *
108
+ * @category Operations
67
109
  */
68
110
  export interface TransactionWaitOptions {
69
111
  /** Number of confirmations to wait for (default: 1) */
@@ -74,38 +116,88 @@ export interface TransactionWaitOptions {
74
116
  timeout?: number;
75
117
  }
76
118
  /**
77
- * Validates whether an object conforms to the Operation interface.
119
+ * Validates whether an object conforms to the Operation (GetOperationResponse) type.
78
120
  *
79
- * @param obj - The object to validate as an Operation.
80
- * @returns `true` if the object has required Operation properties, `false` otherwise.
121
+ * @remarks
122
+ * Type guard for runtime validation of operation objects from external sources.
123
+ * Use when deserializing operations from API responses or storage.
124
+ * Validates against the server's OpenAPI schema structure.
125
+ *
126
+ * @param obj - The object to validate as an Operation
127
+ * @returns `true` if the object has required Operation properties, `false` otherwise
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const response = await fetch('/api/operation/123');
132
+ * const data = await response.json();
133
+ *
134
+ * if (isOperation(data)) {
135
+ * console.log(`Operation ${data.id}: ${data.status}`);
136
+ * }
137
+ * ```
138
+ *
139
+ * @category Operations
81
140
  */
82
141
  export declare function isOperation(obj: unknown): obj is Operation;
83
142
  /**
84
143
  * Validates whether an object conforms to the TransactionResult interface.
85
144
  *
86
- * @param obj - The object to validate as a TransactionResult.
87
- * @returns `true` if the object has a valid transaction hash, `false` otherwise.
88
- */
89
- export declare function isTransactionResult(obj: unknown): obj is TransactionResult;
90
- /**
91
- * Converts a server response to an Operation POJO.
145
+ * @remarks
146
+ * Type guard for runtime validation of transaction results.
147
+ * Checks for required hash field with proper `0x` prefix.
148
+ *
149
+ * @param obj - The object to validate as a TransactionResult
150
+ * @returns `true` if the object has a valid transaction hash, `false` otherwise
92
151
  *
93
- * @param response - The raw server response containing operation status data.
94
- * @returns An Operation object with normalized fields for client consumption.
152
+ * @example
153
+ * ```typescript
154
+ * if (isTransactionResult(result)) {
155
+ * await vana.waitForTransactionEvents(result);
156
+ * }
157
+ * ```
158
+ *
159
+ * @category Operations
95
160
  */
96
- export declare function toOperation<T>(response: GetOperationResponse): Operation<T>;
161
+ export declare function isTransactionResult(obj: unknown): obj is TransactionResult;
97
162
  /**
98
163
  * Extracts the operation ID from flexible input types.
99
164
  *
100
- * @param opOrId - An Operation object containing an `id` field or a raw operation ID string.
101
- * @returns The operation ID string for use in API calls.
165
+ * @remarks
166
+ * Utility for handling both Operation objects and raw ID strings.
167
+ * Enables flexible API design accepting either format.
168
+ *
169
+ * @param opOrId - An Operation object containing an `id` field or a raw operation ID string
170
+ * @returns The operation ID string for use in API calls
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * // Works with both formats
175
+ * await vana.server.getOperation(operation); // Operation object
176
+ * await vana.server.getOperation('op-123'); // ID string
177
+ * ```
178
+ *
179
+ * @category Operations
102
180
  */
103
181
  export declare function getOperationId(opOrId: Operation | string): string;
104
182
  /**
105
183
  * Extracts the transaction hash from flexible input types.
106
184
  *
107
- * @param txOrHash - A TransactionResult object, any object with a `hash` field, or a raw hash string.
108
- * @returns The transaction hash as a `0x`-prefixed string.
185
+ * @remarks
186
+ * Utility for handling TransactionResult objects, hash objects, or raw hash strings.
187
+ * Enables consistent hash extraction across different transaction representations.
188
+ *
189
+ * @param txOrHash - A TransactionResult object, any object with a `hash` field, or a raw hash string
190
+ * @returns The transaction hash as a `0x`-prefixed string
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * // All these work
195
+ * const hash1 = getTransactionHash(transactionResult);
196
+ * const hash2 = getTransactionHash({ hash: '0x123...' });
197
+ * const hash3 = getTransactionHash('0x123...');
198
+ * ```
199
+ *
200
+ * @category Operations
109
201
  */
110
202
  export declare function getTransactionHash(txOrHash: TransactionResult | {
111
203
  hash: Hash;
@@ -1,5 +1,5 @@
1
1
  function isOperation(obj) {
2
- return typeof obj === "object" && obj !== null && "id" in obj && "status" in obj && typeof obj.id === "string" && typeof obj.status === "string";
2
+ return typeof obj === "object" && obj !== null && "kind" in obj && "id" in obj && "status" in obj && obj.kind === "OperationStatus" && typeof obj.id === "string" && typeof obj.status === "string";
3
3
  }
4
4
  function isTransactionResult(obj) {
5
5
  if (typeof obj !== "object" || obj === null || !("hash" in obj)) {
@@ -8,16 +8,6 @@ function isTransactionResult(obj) {
8
8
  const { hash } = obj;
9
9
  return typeof hash === "string" && hash.startsWith("0x");
10
10
  }
11
- function toOperation(response) {
12
- return {
13
- id: response.id,
14
- status: response.status,
15
- createdAt: Date.now(),
16
- // Server doesn't provide this, so we use current time
17
- result: response.status === "succeeded" ? response.result : void 0,
18
- error: response.status === "failed" ? response.result ?? void 0 : void 0
19
- };
20
- }
21
11
  function getOperationId(opOrId) {
22
12
  return typeof opOrId === "string" ? opOrId : opOrId.id;
23
13
  }
@@ -31,7 +21,6 @@ export {
31
21
  getOperationId,
32
22
  getTransactionHash,
33
23
  isOperation,
34
- isTransactionResult,
35
- toOperation
24
+ isTransactionResult
36
25
  };
37
26
  //# sourceMappingURL=operations.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/operations.ts"],"sourcesContent":["import type { Hash, TransactionReceipt as ViemReceipt, Address } from \"viem\";\nimport type { GetOperationResponse } from \"../generated/server/server-exports\";\nimport type { Contract, Fn } from \"../generated/event-types\";\n\n/**\n * Server operation result as a plain object.\n * Fully serializable for API responses and cross-process communication.\n */\nexport interface Operation<T = unknown> {\n /** Unique operation identifier */\n id: string;\n /** Current operation status */\n status: \"starting\" | \"running\" | \"succeeded\" | \"failed\" | \"canceled\";\n /** Unix timestamp when operation was created */\n createdAt: number;\n /** Unix timestamp when operation was last updated */\n updatedAt?: number;\n /** Operation result when status is 'succeeded' */\n result?: T;\n /** Error message when status is 'failed' */\n error?: string;\n /** Additional operation metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Represents a submitted blockchain transaction as a self-describing POJO.\n *\n * @remarks\n * Transaction results MUST include contract and function for proper event parsing.\n * This is a strongly-typed, heuristic-free design following POJO architecture.\n */\nexport interface TransactionResult<\n C extends Contract = Contract,\n F extends Fn<C> = Fn<C>,\n> {\n /** Transaction hash for tracking and confirmation */\n hash: Hash;\n /** Sender's wallet address */\n from: Address;\n /** Contract that was called (required for event parsing) */\n contract: C;\n /** Function that was called (required for event parsing) */\n fn: F;\n /** Network chain ID where transaction was submitted */\n chainId?: number;\n /** Transaction value in wei (for payable functions) */\n value?: bigint;\n /** Transaction sequence number for the sender */\n nonce?: number;\n /** Contract address (if different from standard deployment) */\n to?: Address;\n}\n\n/**\n * Extended transaction receipt with Vana-specific fields\n */\nexport interface TransactionReceipt extends ViemReceipt {\n /** Parsed event data if available */\n events?: unknown;\n}\n\n/**\n * Options for polling operations\n */\nexport interface PollingOptions {\n /** Polling interval in milliseconds (default: 500) */\n pollingInterval?: number;\n /** Maximum time to wait in milliseconds (default: 30000) */\n timeout?: number;\n}\n\n/**\n * Options for waiting for transaction confirmation\n */\nexport interface TransactionWaitOptions {\n /** Number of confirmations to wait for (default: 1) */\n confirmations?: number;\n /** Polling interval in milliseconds (default: 1000) */\n pollingInterval?: number;\n /** Maximum time to wait in milliseconds (default: 30000) */\n timeout?: number;\n}\n\n/**\n * Validates whether an object conforms to the Operation interface.\n *\n * @param obj - The object to validate as an Operation.\n * @returns `true` if the object has required Operation properties, `false` otherwise.\n */\nexport function isOperation(obj: unknown): obj is Operation {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"id\" in obj &&\n \"status\" in obj &&\n typeof (obj as Record<string, unknown>).id === \"string\" &&\n typeof (obj as Record<string, unknown>).status === \"string\"\n );\n}\n\n/**\n * Validates whether an object conforms to the TransactionResult interface.\n *\n * @param obj - The object to validate as a TransactionResult.\n * @returns `true` if the object has a valid transaction hash, `false` otherwise.\n */\nexport function isTransactionResult(obj: unknown): obj is TransactionResult {\n if (typeof obj !== \"object\" || obj === null || !(\"hash\" in obj)) {\n return false;\n }\n const { hash } = obj as Record<string, unknown>;\n return typeof hash === \"string\" && hash.startsWith(\"0x\");\n}\n\n/**\n * Converts a server response to an Operation POJO.\n *\n * @param response - The raw server response containing operation status data.\n * @returns An Operation object with normalized fields for client consumption.\n */\nexport function toOperation<T>(response: GetOperationResponse): Operation<T> {\n return {\n id: response.id,\n status: response.status as Operation[\"status\"],\n createdAt: Date.now(), // Server doesn't provide this, so we use current time\n result:\n response.status === \"succeeded\" ? (response.result as T) : undefined,\n error:\n response.status === \"failed\" ? (response.result ?? undefined) : undefined,\n };\n}\n\n/**\n * Extracts the operation ID from flexible input types.\n *\n * @param opOrId - An Operation object containing an `id` field or a raw operation ID string.\n * @returns The operation ID string for use in API calls.\n */\nexport function getOperationId(opOrId: Operation | string): string {\n return typeof opOrId === \"string\" ? opOrId : opOrId.id;\n}\n\n/**\n * Extracts the transaction hash from flexible input types.\n *\n * @param txOrHash - A TransactionResult object, any object with a `hash` field, or a raw hash string.\n * @returns The transaction hash as a `0x`-prefixed string.\n */\nexport function getTransactionHash(\n txOrHash: TransactionResult | { hash: Hash } | Hash,\n): Hash {\n if (typeof txOrHash === \"string\") {\n return txOrHash;\n }\n return txOrHash.hash;\n}\n"],"mappings":"AA0FO,SAAS,YAAY,KAAgC;AAC1D,SACE,OAAO,QAAQ,YACf,QAAQ,QACR,QAAQ,OACR,YAAY,OACZ,OAAQ,IAAgC,OAAO,YAC/C,OAAQ,IAAgC,WAAW;AAEvD;AAQO,SAAS,oBAAoB,KAAwC;AAC1E,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,EAAE,UAAU,MAAM;AAC/D,WAAO;AAAA,EACT;AACA,QAAM,EAAE,KAAK,IAAI;AACjB,SAAO,OAAO,SAAS,YAAY,KAAK,WAAW,IAAI;AACzD;AAQO,SAAS,YAAe,UAA8C;AAC3E,SAAO;AAAA,IACL,IAAI,SAAS;AAAA,IACb,QAAQ,SAAS;AAAA,IACjB,WAAW,KAAK,IAAI;AAAA;AAAA,IACpB,QACE,SAAS,WAAW,cAAe,SAAS,SAAe;AAAA,IAC7D,OACE,SAAS,WAAW,WAAY,SAAS,UAAU,SAAa;AAAA,EACpE;AACF;AAQO,SAAS,eAAe,QAAoC;AACjE,SAAO,OAAO,WAAW,WAAW,SAAS,OAAO;AACtD;AAQO,SAAS,mBACd,UACM;AACN,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO;AAAA,EACT;AACA,SAAO,SAAS;AAClB;","names":[]}
1
+ {"version":3,"sources":["../../src/types/operations.ts"],"sourcesContent":["import type { Hash, TransactionReceipt as ViemReceipt, Address } from \"viem\";\nimport type {\n GetOperationResponse,\n ArtifactInfo,\n} from \"../generated/server/server-exports\";\nimport type { Contract, Fn } from \"../generated/event-types\";\n\n// Re-export TransactionOptions from the new options module\nexport type { TransactionOptions } from \"./options\";\n\n/**\n * Represents an artifact generated by a server operation.\n *\n * @remarks\n * Artifacts are files generated during operations like Gemini agent analysis.\n * These can be downloaded separately using the artifact download API.\n * This type is imported directly from the server's OpenAPI schema.\n *\n * @category Operations\n */\nexport type Artifact = ArtifactInfo;\n\n/**\n * Represents a server-side operation status and result.\n *\n * @remarks\n * Operations track asynchronous server processes like data refinement or ML inference.\n * Poll operation status using `vana.server.waitForOperation()` until completion.\n * This type is now directly imported from the server's OpenAPI schema for type safety.\n *\n * @category Operations\n * @see {@link https://docs.vana.org/docs/operations | Operations Guide}\n */\nexport type Operation = GetOperationResponse;\n\n/**\n * Represents a submitted blockchain transaction as a self-describing POJO.\n *\n * @remarks\n * Transaction results MUST include contract and function for proper event parsing.\n * This strongly-typed design enables automatic event extraction without heuristics.\n * Use `vana.waitForTransactionEvents()` to retrieve typed events from the receipt.\n *\n * **Architecture:**\n * POJOs (Plain Old JavaScript Objects) ensure serialization safety and framework\n * independence. Contract and function fields enable deterministic event parsing.\n *\n * @category Operations\n * @example\n * ```typescript\n * const result: TransactionResult = {\n * hash: '0x123...',\n * from: '0x456...',\n * contract: 'DataRegistry',\n * fn: 'addFile',\n * chainId: 14800\n * };\n *\n * // Wait for events\n * const events = await vana.waitForTransactionEvents(result);\n * ```\n */\nexport interface TransactionResult<\n C extends Contract = Contract,\n F extends Fn<C> = Fn<C>,\n> {\n /** Transaction hash for tracking and confirmation */\n hash: Hash;\n /** Sender's wallet address */\n from: Address;\n /** Contract that was called (required for event parsing) */\n contract: C;\n /** Function that was called (required for event parsing) */\n fn: F;\n /** Network chain ID where transaction was submitted */\n chainId?: number;\n /** Transaction value in wei (for payable functions) */\n value?: bigint;\n /** Transaction sequence number for the sender */\n nonce?: number;\n /** Contract address (if different from standard deployment) */\n to?: Address;\n}\n\n/**\n * Extends viem's TransactionReceipt with Vana-specific event data.\n *\n * @remarks\n * Includes parsed event data when available after transaction confirmation.\n * Use this for detailed transaction analysis and event processing.\n *\n * @category Operations\n */\nexport interface TransactionReceipt extends ViemReceipt {\n /** Parsed event data if available */\n events?: unknown;\n}\n\n/**\n * Configures polling behavior for asynchronous operations.\n *\n * @remarks\n * Controls how frequently and how long to poll for operation completion.\n * Lower intervals provide faster updates but increase server load.\n *\n * @category Operations\n */\nexport interface PollingOptions {\n /** Polling interval in milliseconds (default: 500) */\n pollingInterval?: number;\n /** Maximum time to wait in milliseconds (default: 30000) */\n timeout?: number;\n}\n\n/**\n * Configures transaction confirmation waiting behavior.\n *\n * @remarks\n * Controls confirmation depth and timeout for transaction finality.\n * Higher confirmations provide more security against chain reorganizations.\n *\n * @category Operations\n */\nexport interface TransactionWaitOptions {\n /** Number of confirmations to wait for (default: 1) */\n confirmations?: number;\n /** Polling interval in milliseconds (default: 1000) */\n pollingInterval?: number;\n /** Maximum time to wait in milliseconds (default: 30000) */\n timeout?: number;\n}\n\n/**\n * Validates whether an object conforms to the Operation (GetOperationResponse) type.\n *\n * @remarks\n * Type guard for runtime validation of operation objects from external sources.\n * Use when deserializing operations from API responses or storage.\n * Validates against the server's OpenAPI schema structure.\n *\n * @param obj - The object to validate as an Operation\n * @returns `true` if the object has required Operation properties, `false` otherwise\n *\n * @example\n * ```typescript\n * const response = await fetch('/api/operation/123');\n * const data = await response.json();\n *\n * if (isOperation(data)) {\n * console.log(`Operation ${data.id}: ${data.status}`);\n * }\n * ```\n *\n * @category Operations\n */\nexport function isOperation(obj: unknown): obj is Operation {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"kind\" in obj &&\n \"id\" in obj &&\n \"status\" in obj &&\n (obj as Record<string, unknown>).kind === \"OperationStatus\" &&\n typeof (obj as Record<string, unknown>).id === \"string\" &&\n typeof (obj as Record<string, unknown>).status === \"string\"\n );\n}\n\n/**\n * Validates whether an object conforms to the TransactionResult interface.\n *\n * @remarks\n * Type guard for runtime validation of transaction results.\n * Checks for required hash field with proper `0x` prefix.\n *\n * @param obj - The object to validate as a TransactionResult\n * @returns `true` if the object has a valid transaction hash, `false` otherwise\n *\n * @example\n * ```typescript\n * if (isTransactionResult(result)) {\n * await vana.waitForTransactionEvents(result);\n * }\n * ```\n *\n * @category Operations\n */\nexport function isTransactionResult(obj: unknown): obj is TransactionResult {\n if (typeof obj !== \"object\" || obj === null || !(\"hash\" in obj)) {\n return false;\n }\n const { hash } = obj as Record<string, unknown>;\n return typeof hash === \"string\" && hash.startsWith(\"0x\");\n}\n\n/**\n * Extracts the operation ID from flexible input types.\n *\n * @remarks\n * Utility for handling both Operation objects and raw ID strings.\n * Enables flexible API design accepting either format.\n *\n * @param opOrId - An Operation object containing an `id` field or a raw operation ID string\n * @returns The operation ID string for use in API calls\n *\n * @example\n * ```typescript\n * // Works with both formats\n * await vana.server.getOperation(operation); // Operation object\n * await vana.server.getOperation('op-123'); // ID string\n * ```\n *\n * @category Operations\n */\nexport function getOperationId(opOrId: Operation | string): string {\n return typeof opOrId === \"string\" ? opOrId : opOrId.id;\n}\n\n/**\n * Extracts the transaction hash from flexible input types.\n *\n * @remarks\n * Utility for handling TransactionResult objects, hash objects, or raw hash strings.\n * Enables consistent hash extraction across different transaction representations.\n *\n * @param txOrHash - A TransactionResult object, any object with a `hash` field, or a raw hash string\n * @returns The transaction hash as a `0x`-prefixed string\n *\n * @example\n * ```typescript\n * // All these work\n * const hash1 = getTransactionHash(transactionResult);\n * const hash2 = getTransactionHash({ hash: '0x123...' });\n * const hash3 = getTransactionHash('0x123...');\n * ```\n *\n * @category Operations\n */\nexport function getTransactionHash(\n txOrHash: TransactionResult | { hash: Hash } | Hash,\n): Hash {\n if (typeof txOrHash === \"string\") {\n return txOrHash;\n }\n return txOrHash.hash;\n}\n"],"mappings":"AA2JO,SAAS,YAAY,KAAgC;AAC1D,SACE,OAAO,QAAQ,YACf,QAAQ,QACR,UAAU,OACV,QAAQ,OACR,YAAY,OACX,IAAgC,SAAS,qBAC1C,OAAQ,IAAgC,OAAO,YAC/C,OAAQ,IAAgC,WAAW;AAEvD;AAqBO,SAAS,oBAAoB,KAAwC;AAC1E,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,EAAE,UAAU,MAAM;AAC/D,WAAO;AAAA,EACT;AACA,QAAM,EAAE,KAAK,IAAI;AACjB,SAAO,OAAO,SAAS,YAAY,KAAK,WAAW,IAAI;AACzD;AAqBO,SAAS,eAAe,QAAoC;AACjE,SAAO,OAAO,WAAW,WAAW,SAAS,OAAO;AACtD;AAsBO,SAAS,mBACd,UACM;AACN,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO;AAAA,EACT;AACA,SAAO,SAAS;AAClB;","names":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var options_exports = {};
16
+ module.exports = __toCommonJS(options_exports);
17
+ //# sourceMappingURL=options.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/options.ts"],"sourcesContent":["/**\n * @file Standard option types for Vana SDK methods\n * @module vana-sdk/types/options\n */\n\n/**\n * Transaction options for blockchain write operations.\n *\n * @remarks\n * Aligned with viem's transaction parameters for consistency.\n * These options control gas pricing, limits, polling behavior, and other transaction-specific settings.\n *\n * @example\n * ```typescript\n * // Basic usage with gas options\n * await vana.data.upload(params, {\n * gas: 1000000n,\n * maxFeePerGas: 20000000000n\n * });\n *\n * // With status updates for long-running operations\n * await vana.permissions.grant({ grantee: '0x...' }, {\n * onStatusUpdate: (status) => {\n * if (status.type === 'queued') {\n * console.log(`Position in queue: ${status.position}`);\n * }\n * }\n * });\n *\n * // With cancellation support\n * const controller = new AbortController();\n * const promise = vana.permissions.grant({ grantee: '0x...' }, {\n * signal: controller.signal\n * });\n * // Cancel after 30 seconds\n * setTimeout(() => controller.abort(), 30000);\n * ```\n *\n * @category Options\n */\nexport interface TransactionOptions {\n /** Gas limit for the transaction */\n gas?: bigint;\n\n /** Gas price in wei (for legacy transactions) */\n gasPrice?: bigint;\n\n /** Maximum fee per gas in wei (EIP-1559) */\n maxFeePerGas?: bigint;\n\n /** Maximum priority fee per gas in wei (EIP-1559) */\n maxPriorityFeePerGas?: bigint;\n\n /** Transaction nonce override */\n nonce?: number;\n\n /** ETH value to send with transaction */\n value?: bigint;\n\n /**\n * AbortSignal for cancelling long-running operations.\n *\n * @remarks\n * Useful for cancelling pending transactions or polling operations.\n * When aborted, the operation will throw an error immediately.\n */\n signal?: AbortSignal;\n\n /**\n * Callback for receiving status updates during long-running operations.\n *\n * @remarks\n * Called whenever the operation status changes (e.g., from pending to queued).\n * Useful for showing progress in UI during multi-minute operations.\n *\n * @param status - The current operation status\n */\n onStatusUpdate?: (status: OperationStatus) => void;\n\n /**\n * Custom polling options for long-running operations.\n *\n * @remarks\n * Overrides default polling behavior for operations that use the relayer.\n * Generally not needed unless you have specific timing requirements.\n */\n pollingOptions?: {\n /** Total timeout in milliseconds (default: 300000 = 5 min) */\n timeout?: number;\n /** Initial polling interval in milliseconds (default: 1000) */\n initialInterval?: number;\n /** Maximum polling interval in milliseconds (default: 10000) */\n maxInterval?: number;\n };\n}\n\n/**\n * Represents the current status of a blockchain operation.\n *\n * @remarks\n * Used for status updates during long-running operations via the onStatusUpdate callback.\n * Provides detailed information about the operation's progress through its lifecycle.\n *\n * @category Options\n */\nexport type OperationStatus =\n | {\n /** Operation is pending, not yet processed */\n type: \"pending\";\n /** The operation ID for tracking */\n operationId: string;\n }\n | {\n /** Operation is queued for processing */\n type: \"queued\";\n /** Position in the processing queue */\n position?: number;\n /** Estimated wait time in seconds */\n estimatedWait?: number;\n }\n | {\n /** Operation is actively being processed */\n type: \"processing\";\n }\n | {\n /** Transaction has been submitted to blockchain */\n type: \"submitted\";\n /** The transaction hash */\n hash: `0x${string}`;\n }\n | {\n /** Transaction has been confirmed on-chain */\n type: \"confirmed\";\n /** The transaction hash */\n hash: `0x${string}`;\n /** The transaction receipt if available */\n receipt?: unknown;\n }\n | {\n /** Operation failed with an error */\n type: \"failed\";\n /** Error message describing the failure */\n error: string;\n /** Operation ID if available for recovery */\n operationId?: string;\n };\n\n/**\n * Source selection for data queries.\n *\n * @remarks\n * - `chain`: Query directly from blockchain (immediate consistency)\n * - `subgraph`: Query from indexed subgraph (may lag 15-60s)\n * - `auto`: SDK chooses optimal source (default)\n *\n * @category Options\n */\nexport type DataSource = \"chain\" | \"subgraph\" | \"auto\";\n\n/**\n * Consistency options for read operations.\n *\n * @remarks\n * Controls data freshness requirements and source selection.\n * Essential for read-after-write consistency when data must reflect recent transactions.\n *\n * @example\n * ```typescript\n * // Ensure data includes a recent transaction\n * const files = await vana.data.getUserFiles({ owner }, {\n * minBlock: receipt.blockNumber,\n * waitForSync: 30000 // Wait up to 30s\n * });\n * ```\n *\n * @category Options\n */\nexport interface ConsistencyOptions {\n /**\n * Minimum block number the data source must have indexed.\n *\n * @remarks\n * Operation will fail or wait (if waitForSync set) until source reaches this block.\n * Critical for ensuring recently created data is visible.\n */\n minBlock?: number;\n\n /**\n * Maximum milliseconds to wait for data source to sync to minBlock.\n *\n * @remarks\n * If not set, operation fails immediately when source is behind.\n * Useful for critical operations where waiting is preferable to failure.\n *\n * @default undefined (no waiting)\n */\n waitForSync?: number;\n\n /**\n * Explicitly select data source.\n *\n * @remarks\n * Useful for debugging or when specific consistency guarantees are needed.\n * Not all methods support all sources - unsupported selections will error.\n *\n * @default 'auto'\n */\n source?: DataSource;\n\n /**\n * AbortSignal for cancelling long-running operations.\n *\n * @remarks\n * Particularly useful with waitForSync to cancel polling operations.\n * Properly cleans up timers and pending requests when aborted.\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * const promise = vana.data.getUserFiles(\n * { owner },\n * { waitForSync: 30000, signal: controller.signal }\n * );\n *\n * // Cancel after 5 seconds\n * setTimeout(() => controller.abort(), 5000);\n * ```\n */\n signal?: AbortSignal;\n}\n\n/**\n * Pagination options for list operations.\n *\n * @remarks\n * Controls result set size, ordering, and pagination.\n * By default returns first 100 items to prevent accidental large fetches.\n *\n * @example\n * ```typescript\n * // Get all files (explicit opt-in)\n * const allFiles = await vana.data.getUserFiles({ owner }, {\n * fetchAll: true\n * });\n *\n * // Get 10 most recent files\n * const recentFiles = await vana.data.getUserFiles({ owner }, {\n * limit: 10,\n * orderBy: 'addedAtBlock',\n * orderDirection: 'desc'\n * });\n * ```\n *\n * @category Options\n */\nexport interface PaginationOptions {\n /**\n * Maximum number of items to return.\n *\n * @remarks\n * Prevents accidental large fetches. Use fetchAll: true for unlimited.\n *\n * @default 100\n */\n limit?: number;\n\n /**\n * Number of items to skip (for manual pagination).\n *\n * @default 0\n */\n offset?: number;\n\n /**\n * Field to order results by.\n *\n * @remarks\n * Field names depend on the entity type.\n * Common: 'id', 'addedAtBlock', 'addedAtTimestamp'\n */\n orderBy?: string;\n\n /**\n * Sort direction for orderBy field.\n *\n * @default 'desc' for timestamp/block fields, 'asc' for others\n */\n orderDirection?: \"asc\" | \"desc\";\n\n /**\n * Explicitly fetch all available items.\n *\n * @remarks\n * Override safety limit. SDK will paginate internally to fetch all results.\n * Use with caution - can result in many API calls and large memory usage.\n *\n * @default false\n */\n fetchAll?: boolean;\n}\n\n/**\n * Combined options for read operations that return lists.\n *\n * @remarks\n * Convenience type combining consistency and pagination controls.\n *\n * @category Options\n */\nexport type ListOptions = ConsistencyOptions & PaginationOptions;\n\n/**\n * Combined options for write operations that may read data.\n *\n * @remarks\n * Some write operations need to read data (e.g., schema validation).\n * This type combines transaction and consistency options.\n *\n * @category Options\n */\nexport type WriteOptions = TransactionOptions & ConsistencyOptions;\n\n/**\n * Legacy transaction options type for backwards compatibility.\n *\n * @deprecated Use TransactionOptions instead. Will be removed in next major version.\n * @category Options\n */\nexport interface LegacyTransactionOptions {\n /** @deprecated Use `gas` instead */\n gasLimit?: bigint;\n gasPrice?: bigint;\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n nonce?: number;\n value?: bigint;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}