@lifi/sdk 4.0.0-alpha.2 → 4.0.0-alpha.21

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 (338) hide show
  1. package/dist/cjs/actions/getChains.d.ts +1 -1
  2. package/dist/cjs/actions/getChains.js +4 -4
  3. package/dist/cjs/actions/getChains.js.map +1 -1
  4. package/dist/cjs/actions/getRelayedTransactionStatus.js +1 -1
  5. package/dist/cjs/actions/getRelayedTransactionStatus.js.map +1 -1
  6. package/dist/cjs/actions/getStepTransaction.js +9 -1
  7. package/dist/cjs/actions/getStepTransaction.js.map +1 -1
  8. package/dist/cjs/actions/index.d.ts +3 -1
  9. package/dist/cjs/actions/index.js +2 -0
  10. package/dist/cjs/actions/index.js.map +1 -1
  11. package/dist/cjs/actions/patchContractCalls.d.ts +10 -0
  12. package/dist/cjs/actions/patchContractCalls.js +16 -0
  13. package/dist/cjs/actions/patchContractCalls.js.map +1 -0
  14. package/dist/cjs/client/createClient.js +4 -0
  15. package/dist/cjs/client/createClient.js.map +1 -1
  16. package/dist/cjs/client/getClientStorage.d.ts +1 -0
  17. package/dist/cjs/client/getClientStorage.js +18 -6
  18. package/dist/cjs/client/getClientStorage.js.map +1 -1
  19. package/dist/cjs/core/BaseStepExecutionTask.d.ts +5 -0
  20. package/dist/cjs/core/BaseStepExecutionTask.js +10 -0
  21. package/dist/cjs/core/BaseStepExecutionTask.js.map +1 -0
  22. package/dist/cjs/core/BaseStepExecutor.d.ts +10 -3
  23. package/dist/cjs/core/BaseStepExecutor.js +53 -0
  24. package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
  25. package/dist/cjs/core/StatusManager.d.ts +13 -12
  26. package/dist/cjs/core/StatusManager.js +55 -61
  27. package/dist/cjs/core/StatusManager.js.map +1 -1
  28. package/dist/cjs/core/TaskPipeline.d.ts +7 -0
  29. package/dist/cjs/core/TaskPipeline.js +27 -0
  30. package/dist/cjs/core/TaskPipeline.js.map +1 -0
  31. package/dist/cjs/core/actionMessages.d.ts +4 -0
  32. package/dist/cjs/core/{processMessages.js → actionMessages.js} +25 -9
  33. package/dist/cjs/core/actionMessages.js.map +1 -0
  34. package/dist/cjs/core/execution.js +13 -1
  35. package/dist/cjs/core/execution.js.map +1 -1
  36. package/dist/cjs/core/prepareRestart.js +6 -6
  37. package/dist/cjs/core/prepareRestart.js.map +1 -1
  38. package/dist/cjs/core/storage.d.ts +17 -0
  39. package/dist/cjs/core/storage.js +36 -0
  40. package/dist/cjs/core/storage.js.map +1 -0
  41. package/dist/cjs/core/tasks/CheckBalanceTask.d.ts +5 -0
  42. package/dist/cjs/core/tasks/CheckBalanceTask.js +26 -0
  43. package/dist/cjs/core/tasks/CheckBalanceTask.js.map +1 -0
  44. package/dist/cjs/core/tasks/PrepareTransactionTask.d.ts +5 -0
  45. package/dist/cjs/core/tasks/PrepareTransactionTask.js +36 -0
  46. package/dist/cjs/core/tasks/PrepareTransactionTask.js.map +1 -0
  47. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.d.ts +8 -0
  48. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +73 -0
  49. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
  50. package/dist/cjs/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
  51. package/dist/cjs/core/{checkBalance.js → tasks/helpers/checkBalance.js} +6 -6
  52. package/dist/cjs/core/tasks/helpers/checkBalance.js.map +1 -0
  53. package/dist/cjs/core/tasks/helpers/getTransactionRequestData.d.ts +2 -0
  54. package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js +30 -0
  55. package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
  56. package/dist/cjs/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
  57. package/dist/cjs/core/{stepComparison.js → tasks/helpers/stepComparison.js} +3 -3
  58. package/dist/cjs/core/tasks/helpers/stepComparison.js.map +1 -0
  59. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +4 -0
  60. package/dist/cjs/core/{waitForTransactionStatus.js → tasks/helpers/waitForTransactionStatus.js} +10 -8
  61. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
  62. package/dist/cjs/core/utils.d.ts +9 -3
  63. package/dist/cjs/core/utils.js +0 -5
  64. package/dist/cjs/core/utils.js.map +1 -1
  65. package/dist/cjs/errors/SDKError.d.ts +3 -3
  66. package/dist/cjs/errors/SDKError.js +3 -3
  67. package/dist/cjs/errors/SDKError.js.map +1 -1
  68. package/dist/cjs/errors/constants.d.ts +5 -2
  69. package/dist/cjs/errors/constants.js +3 -0
  70. package/dist/cjs/errors/constants.js.map +1 -1
  71. package/dist/cjs/errors/errors.d.ts +5 -0
  72. package/dist/cjs/errors/errors.js +9 -1
  73. package/dist/cjs/errors/errors.js.map +1 -1
  74. package/dist/cjs/index.d.ts +20 -10
  75. package/dist/cjs/index.js +34 -14
  76. package/dist/cjs/index.js.map +1 -1
  77. package/dist/cjs/types/core.d.ts +51 -21
  78. package/dist/cjs/types/execution.d.ts +22 -0
  79. package/dist/cjs/types/execution.js +3 -0
  80. package/dist/cjs/types/execution.js.map +1 -0
  81. package/dist/cjs/utils/convertQuoteToRoute.d.ts +6 -1
  82. package/dist/cjs/utils/convertQuoteToRoute.js +73 -5
  83. package/dist/cjs/utils/convertQuoteToRoute.js.map +1 -1
  84. package/dist/cjs/utils/formatUnits.d.ts +1 -0
  85. package/dist/cjs/utils/formatUnits.js +18 -0
  86. package/dist/cjs/utils/formatUnits.js.map +1 -0
  87. package/dist/cjs/utils/isHex.d.ts +4 -0
  88. package/dist/cjs/utils/isHex.js +13 -0
  89. package/dist/cjs/utils/isHex.js.map +1 -0
  90. package/dist/cjs/utils/parseUnits.d.ts +1 -0
  91. package/dist/cjs/utils/parseUnits.js +44 -0
  92. package/dist/cjs/utils/parseUnits.js.map +1 -0
  93. package/dist/cjs/utils/request.js +7 -6
  94. package/dist/cjs/utils/request.js.map +1 -1
  95. package/dist/cjs/utils/waitForResult.d.ts +1 -1
  96. package/dist/cjs/utils/waitForResult.js +6 -2
  97. package/dist/cjs/utils/waitForResult.js.map +1 -1
  98. package/dist/cjs/utils/withDedupe.d.ts +5 -0
  99. package/dist/cjs/utils/withDedupe.js +2 -0
  100. package/dist/cjs/utils/withDedupe.js.map +1 -1
  101. package/dist/cjs/version.d.ts +1 -1
  102. package/dist/cjs/version.js +1 -1
  103. package/dist/cjs/version.js.map +1 -1
  104. package/dist/esm/actions/getChains.d.ts +1 -1
  105. package/dist/esm/actions/getChains.js +2 -2
  106. package/dist/esm/actions/getChains.js.map +1 -1
  107. package/dist/esm/actions/getRelayedTransactionStatus.js +1 -1
  108. package/dist/esm/actions/getRelayedTransactionStatus.js.map +1 -1
  109. package/dist/esm/actions/getStepTransaction.js +10 -1
  110. package/dist/esm/actions/getStepTransaction.js.map +1 -1
  111. package/dist/esm/actions/index.d.ts +9 -1
  112. package/dist/esm/actions/index.js +2 -0
  113. package/dist/esm/actions/index.js.map +1 -1
  114. package/dist/esm/actions/patchContractCalls.d.ts +10 -0
  115. package/dist/esm/actions/patchContractCalls.js +12 -0
  116. package/dist/esm/actions/patchContractCalls.js.map +1 -0
  117. package/dist/esm/client/createClient.js +4 -0
  118. package/dist/esm/client/createClient.js.map +1 -1
  119. package/dist/esm/client/getClientStorage.d.ts +1 -0
  120. package/dist/esm/client/getClientStorage.js +22 -7
  121. package/dist/esm/client/getClientStorage.js.map +1 -1
  122. package/dist/esm/core/BaseStepExecutionTask.d.ts +5 -0
  123. package/dist/esm/core/BaseStepExecutionTask.js +6 -0
  124. package/dist/esm/core/BaseStepExecutionTask.js.map +1 -0
  125. package/dist/esm/core/BaseStepExecutor.d.ts +10 -3
  126. package/dist/esm/core/BaseStepExecutor.js +53 -0
  127. package/dist/esm/core/BaseStepExecutor.js.map +1 -1
  128. package/dist/esm/core/StatusManager.d.ts +40 -39
  129. package/dist/esm/core/StatusManager.js +86 -92
  130. package/dist/esm/core/StatusManager.js.map +1 -1
  131. package/dist/esm/core/TaskPipeline.d.ts +7 -0
  132. package/dist/esm/core/TaskPipeline.js +23 -0
  133. package/dist/esm/core/TaskPipeline.js.map +1 -0
  134. package/dist/esm/core/actionMessages.d.ts +4 -0
  135. package/dist/esm/core/{processMessages.js → actionMessages.js} +24 -8
  136. package/dist/esm/core/actionMessages.js.map +1 -0
  137. package/dist/esm/core/execution.js +14 -3
  138. package/dist/esm/core/execution.js.map +1 -1
  139. package/dist/esm/core/prepareRestart.js +10 -9
  140. package/dist/esm/core/prepareRestart.js.map +1 -1
  141. package/dist/esm/core/storage.d.ts +17 -0
  142. package/dist/esm/core/storage.js +30 -0
  143. package/dist/esm/core/storage.js.map +1 -0
  144. package/dist/esm/core/tasks/CheckBalanceTask.d.ts +5 -0
  145. package/dist/esm/core/tasks/CheckBalanceTask.js +22 -0
  146. package/dist/esm/core/tasks/CheckBalanceTask.js.map +1 -0
  147. package/dist/esm/core/tasks/PrepareTransactionTask.d.ts +5 -0
  148. package/dist/esm/core/tasks/PrepareTransactionTask.js +32 -0
  149. package/dist/esm/core/tasks/PrepareTransactionTask.js.map +1 -0
  150. package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts +8 -0
  151. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +74 -0
  152. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
  153. package/dist/esm/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
  154. package/dist/esm/core/{checkBalance.js → tasks/helpers/checkBalance.js} +4 -4
  155. package/dist/esm/core/tasks/helpers/checkBalance.js.map +1 -0
  156. package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts +2 -0
  157. package/dist/esm/core/tasks/helpers/getTransactionRequestData.js +26 -0
  158. package/dist/esm/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
  159. package/dist/esm/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
  160. package/dist/esm/core/{stepComparison.js → tasks/helpers/stepComparison.js} +3 -3
  161. package/dist/esm/core/tasks/helpers/stepComparison.js.map +1 -0
  162. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +4 -0
  163. package/dist/esm/core/{waitForTransactionStatus.js → tasks/helpers/waitForTransactionStatus.js} +9 -7
  164. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
  165. package/dist/esm/core/utils.d.ts +9 -11
  166. package/dist/esm/core/utils.js +0 -11
  167. package/dist/esm/core/utils.js.map +1 -1
  168. package/dist/esm/errors/SDKError.d.ts +3 -3
  169. package/dist/esm/errors/SDKError.js +4 -4
  170. package/dist/esm/errors/SDKError.js.map +1 -1
  171. package/dist/esm/errors/constants.d.ts +5 -2
  172. package/dist/esm/errors/constants.js +3 -0
  173. package/dist/esm/errors/constants.js.map +1 -1
  174. package/dist/esm/errors/errors.d.ts +10 -0
  175. package/dist/esm/errors/errors.js +12 -0
  176. package/dist/esm/errors/errors.js.map +1 -1
  177. package/dist/esm/index.d.ts +20 -10
  178. package/dist/esm/index.js +17 -8
  179. package/dist/esm/index.js.map +1 -1
  180. package/dist/esm/types/core.d.ts +55 -21
  181. package/dist/esm/types/execution.d.ts +23 -0
  182. package/dist/esm/types/execution.js +2 -0
  183. package/dist/esm/types/execution.js.map +1 -0
  184. package/dist/esm/utils/convertQuoteToRoute.d.ts +11 -3
  185. package/dist/esm/utils/convertQuoteToRoute.js +76 -7
  186. package/dist/esm/utils/convertQuoteToRoute.js.map +1 -1
  187. package/dist/esm/utils/formatUnits.d.ts +4 -0
  188. package/dist/esm/utils/formatUnits.js +18 -0
  189. package/dist/esm/utils/formatUnits.js.map +1 -0
  190. package/dist/esm/utils/isHex.d.ts +4 -0
  191. package/dist/esm/utils/isHex.js +10 -0
  192. package/dist/esm/utils/isHex.js.map +1 -0
  193. package/dist/esm/utils/parseUnits.d.ts +4 -0
  194. package/dist/esm/utils/parseUnits.js +46 -0
  195. package/dist/esm/utils/parseUnits.js.map +1 -0
  196. package/dist/esm/utils/request.js +7 -6
  197. package/dist/esm/utils/request.js.map +1 -1
  198. package/dist/esm/utils/waitForResult.d.ts +2 -2
  199. package/dist/esm/utils/waitForResult.js +7 -3
  200. package/dist/esm/utils/waitForResult.js.map +1 -1
  201. package/dist/esm/utils/withDedupe.d.ts +10 -0
  202. package/dist/esm/utils/withDedupe.js +1 -1
  203. package/dist/esm/utils/withDedupe.js.map +1 -1
  204. package/dist/esm/version.d.ts +1 -1
  205. package/dist/esm/version.js +1 -1
  206. package/dist/esm/version.js.map +1 -1
  207. package/dist/types/actions/getChains.d.ts +1 -1
  208. package/dist/types/actions/getChains.d.ts.map +1 -1
  209. package/dist/types/actions/getStepTransaction.d.ts.map +1 -1
  210. package/dist/types/actions/index.d.ts +9 -1
  211. package/dist/types/actions/index.d.ts.map +1 -1
  212. package/dist/types/actions/patchContractCalls.d.ts +11 -0
  213. package/dist/types/actions/patchContractCalls.d.ts.map +1 -0
  214. package/dist/types/client/createClient.d.ts.map +1 -1
  215. package/dist/types/client/getClientStorage.d.ts +1 -0
  216. package/dist/types/client/getClientStorage.d.ts.map +1 -1
  217. package/dist/types/core/BaseStepExecutionTask.d.ts +6 -0
  218. package/dist/types/core/BaseStepExecutionTask.d.ts.map +1 -0
  219. package/dist/types/core/BaseStepExecutor.d.ts +10 -3
  220. package/dist/types/core/BaseStepExecutor.d.ts.map +1 -1
  221. package/dist/types/core/StatusManager.d.ts +40 -39
  222. package/dist/types/core/StatusManager.d.ts.map +1 -1
  223. package/dist/types/core/TaskPipeline.d.ts +8 -0
  224. package/dist/types/core/TaskPipeline.d.ts.map +1 -0
  225. package/dist/types/core/actionMessages.d.ts +5 -0
  226. package/dist/types/core/actionMessages.d.ts.map +1 -0
  227. package/dist/types/core/execution.d.ts.map +1 -1
  228. package/dist/types/core/prepareRestart.d.ts.map +1 -1
  229. package/dist/types/core/storage.d.ts +18 -0
  230. package/dist/types/core/storage.d.ts.map +1 -0
  231. package/dist/types/core/tasks/CheckBalanceTask.d.ts +6 -0
  232. package/dist/types/core/tasks/CheckBalanceTask.d.ts.map +1 -0
  233. package/dist/types/core/tasks/PrepareTransactionTask.d.ts +6 -0
  234. package/dist/types/core/tasks/PrepareTransactionTask.d.ts.map +1 -0
  235. package/dist/types/core/tasks/WaitForTransactionStatusTask.d.ts +9 -0
  236. package/dist/types/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -0
  237. package/dist/types/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
  238. package/dist/types/core/tasks/helpers/checkBalance.d.ts.map +1 -0
  239. package/dist/types/core/tasks/helpers/getTransactionRequestData.d.ts +3 -0
  240. package/dist/types/core/tasks/helpers/getTransactionRequestData.d.ts.map +1 -0
  241. package/dist/types/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
  242. package/dist/types/core/tasks/helpers/stepComparison.d.ts.map +1 -0
  243. package/dist/types/core/tasks/helpers/waitForTransactionStatus.d.ts +5 -0
  244. package/dist/types/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -0
  245. package/dist/types/core/utils.d.ts +9 -11
  246. package/dist/types/core/utils.d.ts.map +1 -1
  247. package/dist/types/errors/SDKError.d.ts +3 -3
  248. package/dist/types/errors/SDKError.d.ts.map +1 -1
  249. package/dist/types/errors/constants.d.ts +5 -2
  250. package/dist/types/errors/constants.d.ts.map +1 -1
  251. package/dist/types/errors/errors.d.ts +10 -0
  252. package/dist/types/errors/errors.d.ts.map +1 -1
  253. package/dist/types/index.d.ts +20 -10
  254. package/dist/types/index.d.ts.map +1 -1
  255. package/dist/types/types/core.d.ts +55 -21
  256. package/dist/types/types/core.d.ts.map +1 -1
  257. package/dist/types/types/execution.d.ts +24 -0
  258. package/dist/types/types/execution.d.ts.map +1 -0
  259. package/dist/types/utils/convertQuoteToRoute.d.ts +11 -3
  260. package/dist/types/utils/convertQuoteToRoute.d.ts.map +1 -1
  261. package/dist/types/utils/formatUnits.d.ts +5 -0
  262. package/dist/types/utils/formatUnits.d.ts.map +1 -0
  263. package/dist/types/utils/isHex.d.ts +5 -0
  264. package/dist/types/utils/isHex.d.ts.map +1 -0
  265. package/dist/types/utils/parseUnits.d.ts +5 -0
  266. package/dist/types/utils/parseUnits.d.ts.map +1 -0
  267. package/dist/types/utils/request.d.ts.map +1 -1
  268. package/dist/types/utils/waitForResult.d.ts +2 -2
  269. package/dist/types/utils/waitForResult.d.ts.map +1 -1
  270. package/dist/types/utils/withDedupe.d.ts +10 -0
  271. package/dist/types/utils/withDedupe.d.ts.map +1 -1
  272. package/dist/types/version.d.ts +1 -1
  273. package/dist/types/version.d.ts.map +1 -1
  274. package/package.json +2 -3
  275. package/src/actions/getChains.ts +2 -2
  276. package/src/actions/getRelayedTransactionStatus.ts +1 -1
  277. package/src/actions/getStepTransaction.ts +20 -12
  278. package/src/actions/index.ts +18 -0
  279. package/src/actions/patchContractCalls.ts +30 -0
  280. package/src/client/createClient.ts +5 -1
  281. package/src/client/getClientStorage.ts +25 -7
  282. package/src/core/BaseStepExecutionTask.ts +9 -0
  283. package/src/core/BaseStepExecutor.ts +91 -2
  284. package/src/core/StatusManager.ts +108 -113
  285. package/src/core/TaskPipeline.ts +28 -0
  286. package/src/core/{processMessages.ts → actionMessages.ts} +32 -12
  287. package/src/core/execution.ts +17 -3
  288. package/src/core/prepareRestart.ts +12 -11
  289. package/src/core/storage.ts +42 -0
  290. package/src/core/tasks/CheckBalanceTask.ts +29 -0
  291. package/src/core/tasks/PrepareTransactionTask.ts +62 -0
  292. package/src/core/tasks/WaitForTransactionStatusTask.ts +114 -0
  293. package/src/core/{checkBalance.ts → tasks/helpers/checkBalance.ts} +5 -5
  294. package/src/core/tasks/helpers/getTransactionRequestData.ts +47 -0
  295. package/src/core/{stepComparison.ts → tasks/helpers/stepComparison.ts} +5 -5
  296. package/src/core/{waitForTransactionStatus.ts → tasks/helpers/waitForTransactionStatus.ts} +11 -9
  297. package/src/core/utils.ts +1 -13
  298. package/src/errors/SDKError.ts +5 -5
  299. package/src/errors/constants.ts +3 -0
  300. package/src/errors/errors.ts +24 -0
  301. package/src/index.ts +37 -12
  302. package/src/types/core.ts +69 -29
  303. package/src/types/execution.ts +32 -0
  304. package/src/utils/convertQuoteToRoute.ts +117 -8
  305. package/src/utils/formatUnits.ts +22 -0
  306. package/src/utils/isHex.ts +14 -0
  307. package/src/utils/parseUnits.ts +50 -0
  308. package/src/utils/request.ts +9 -6
  309. package/src/utils/waitForResult.ts +9 -4
  310. package/src/utils/withDedupe.ts +1 -1
  311. package/src/version.ts +1 -1
  312. package/dist/cjs/core/checkBalance.js.map +0 -1
  313. package/dist/cjs/core/processMessages.d.ts +0 -4
  314. package/dist/cjs/core/processMessages.js.map +0 -1
  315. package/dist/cjs/core/stepComparison.js.map +0 -1
  316. package/dist/cjs/core/waitForDestinationChainTransaction.d.ts +0 -4
  317. package/dist/cjs/core/waitForDestinationChainTransaction.js +0 -69
  318. package/dist/cjs/core/waitForDestinationChainTransaction.js.map +0 -1
  319. package/dist/cjs/core/waitForTransactionStatus.d.ts +0 -4
  320. package/dist/cjs/core/waitForTransactionStatus.js.map +0 -1
  321. package/dist/esm/core/checkBalance.js.map +0 -1
  322. package/dist/esm/core/processMessages.d.ts +0 -4
  323. package/dist/esm/core/processMessages.js.map +0 -1
  324. package/dist/esm/core/stepComparison.js.map +0 -1
  325. package/dist/esm/core/waitForDestinationChainTransaction.d.ts +0 -4
  326. package/dist/esm/core/waitForDestinationChainTransaction.js +0 -71
  327. package/dist/esm/core/waitForDestinationChainTransaction.js.map +0 -1
  328. package/dist/esm/core/waitForTransactionStatus.d.ts +0 -4
  329. package/dist/esm/core/waitForTransactionStatus.js.map +0 -1
  330. package/dist/types/core/checkBalance.d.ts.map +0 -1
  331. package/dist/types/core/processMessages.d.ts +0 -5
  332. package/dist/types/core/processMessages.d.ts.map +0 -1
  333. package/dist/types/core/stepComparison.d.ts.map +0 -1
  334. package/dist/types/core/waitForDestinationChainTransaction.d.ts +0 -5
  335. package/dist/types/core/waitForDestinationChainTransaction.d.ts.map +0 -1
  336. package/dist/types/core/waitForTransactionStatus.d.ts +0 -5
  337. package/dist/types/core/waitForTransactionStatus.d.ts.map +0 -1
  338. package/src/core/waitForDestinationChainTransaction.ts +0 -106
@@ -1,34 +1,49 @@
1
1
  import { ChainId, ChainType } from '@lifi/types';
2
- import { getChainsFromConfig } from '../actions/getChains.js';
2
+ import { _getChains } from '../actions/getChains.js';
3
3
  import { getRpcUrlsFromChains } from '../core/utils.js';
4
+ // 6 hours in milliseconds
5
+ const chainsRefreshInterval = 1000 * 60 * 60 * 6;
4
6
  export const getClientStorage = (config) => {
5
7
  let _chains = [];
6
8
  let _rpcUrls = { ...config.rpcUrls };
7
9
  let _chainsUpdatedAt;
10
+ const updateRpcUrls = () => {
11
+ _rpcUrls = { ...config.rpcUrls };
12
+ _rpcUrls = getRpcUrlsFromChains(_rpcUrls, _chains, [ChainId.SOL]);
13
+ };
8
14
  return {
9
15
  get needReset() {
10
16
  return (!_chainsUpdatedAt ||
11
- Date.now() - _chainsUpdatedAt >= 1000 * 60 * 60 * 24);
17
+ Date.now() - _chainsUpdatedAt >= chainsRefreshInterval);
18
+ },
19
+ setChains(chains) {
20
+ _chains = chains;
21
+ _chainsUpdatedAt = Date.now();
22
+ updateRpcUrls();
12
23
  },
13
24
  async getChains() {
25
+ // When preloadChains is false, SDK does not auto-fetch chains
26
+ // External consumer is responsible for calling setChains
27
+ if (!config.preloadChains) {
28
+ return _chains;
29
+ }
14
30
  if (this.needReset || !_chains.length) {
15
- _chains = await getChainsFromConfig(config, {
31
+ _chains = await _getChains(config, {
16
32
  chainTypes: [
17
33
  ChainType.EVM,
18
34
  ChainType.SVM,
19
35
  ChainType.UTXO,
20
36
  ChainType.MVM,
37
+ ChainType.TVM,
21
38
  ],
22
39
  });
23
40
  _chainsUpdatedAt = Date.now();
41
+ updateRpcUrls();
24
42
  }
25
43
  return _chains;
26
44
  },
27
45
  async getRpcUrls() {
28
- if (this.needReset || !Object.keys(_rpcUrls).length) {
29
- const chains = await this.getChains();
30
- _rpcUrls = getRpcUrlsFromChains(_rpcUrls, chains, [ChainId.SOL]);
31
- }
46
+ await this.getChains(); // _rpcUrls is updated when needed
32
47
  return _rpcUrls;
33
48
  },
34
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getClientStorage.js","sourceRoot":"","sources":["../../../src/client/getClientStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAsB,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAGvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAqB,EAAE,EAAE;IACxD,IAAI,OAAO,GAAG,EAAqB,CAAA;IACnC,IAAI,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,EAAa,CAAA;IAC/C,IAAI,gBAAoC,CAAA;IAExC,OAAO;QACL,IAAI,SAAS;YACX,OAAO,CACL,CAAC,gBAAgB;gBACjB,IAAI,CAAC,GAAG,EAAE,GAAG,gBAAgB,IAAI,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CACrD,CAAA;QACH,CAAC;QACD,KAAK,CAAC,SAAS;YACb,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;gBACtC,OAAO,GAAG,MAAM,mBAAmB,CAAC,MAAM,EAAE;oBAC1C,UAAU,EAAE;wBACV,SAAS,CAAC,GAAG;wBACb,SAAS,CAAC,GAAG;wBACb,SAAS,CAAC,IAAI;wBACd,SAAS,CAAC,GAAG;qBACd;iBACF,CAAC,CAAA;gBACF,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YAC/B,CAAC;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,KAAK,CAAC,UAAU;YAC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ACD,SAAS,CAAC,MAAuB;YAC/B,OAAO,GAAG,MAAM,CAAA;YAChB,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YAC7B,aAAa,EAAE,CAAA;QACjB,CAAC;QACD,KAAK,CAAC,SAAS;YACb,8DAA8D;YAC9D,yDAAyD;YACzD,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;gBAC1B,OAAO,OAAO,CAAA;YAChB,CAAC;YAED,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;gBACtC,OAAO,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE;oBACjC,UAAU,EAAE;wBACV,SAAS,CAAC,GAAG;wBACb,SAAS,CAAC,GAAG;wBACb,SAAS,CAAC,IAAI;wBACd,SAAS,CAAC,GAAG;wBACb,SAAS,CAAC,GAAG;qBACd;iBACF,CAAC,CAAA;gBACF,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBAC7B,aAAa,EAAE,CAAA;YACjB,CAAC;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,KAAK,CAAC,UAAU;YACd,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA,CAAC,kCAAkC;YACzD,OAAO,QAAQ,CAAA;QACjB,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { StepExecutorContext, TaskResult } from '../types/execution.js';
2
+ export declare abstract class BaseStepExecutionTask {
3
+ shouldRun(_context: StepExecutorContext): Promise<boolean>;
4
+ abstract run(context: StepExecutorContext): Promise<TaskResult>;
5
+ }
@@ -0,0 +1,6 @@
1
+ export class BaseStepExecutionTask {
2
+ shouldRun(_context) {
3
+ return Promise.resolve(true);
4
+ }
5
+ }
6
+ //# sourceMappingURL=BaseStepExecutionTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseStepExecutionTask.js","sourceRoot":"","sources":["../../../src/core/BaseStepExecutionTask.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,qBAAqB;IACzC,SAAS,CAAC,QAA6B;QACrC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;CAGF"}
@@ -1,6 +1,9 @@
1
- import type { LiFiStep } from '@lifi/types';
2
- import type { ExecutionOptions, InteractionSettings, SDKClient, StepExecutor, StepExecutorOptions } from '../types/core.js';
1
+ import { ExecuteStepRetryError } from '../errors/errors.js';
2
+ import type { SDKError } from '../errors/SDKError.js';
3
+ import type { ExecuteStepRetryParams, ExecutionAction, ExecutionOptions, InteractionSettings, LiFiStepExtended, SDKClient, StepExecutor, StepExecutorOptions } from '../types/core.js';
4
+ import type { StepExecutorBaseContext, StepExecutorContext } from '../types/execution.js';
3
5
  import { StatusManager } from './StatusManager.js';
6
+ import type { TaskPipeline } from './TaskPipeline.js';
4
7
  export declare abstract class BaseStepExecutor implements StepExecutor {
5
8
  protected executionOptions?: ExecutionOptions;
6
9
  protected statusManager: StatusManager;
@@ -8,5 +11,9 @@ export declare abstract class BaseStepExecutor implements StepExecutor {
8
11
  allowExecution: boolean;
9
12
  constructor(options: StepExecutorOptions);
10
13
  setInteraction: (settings?: InteractionSettings) => void;
11
- abstract executeStep(client: SDKClient, step: LiFiStep): Promise<LiFiStep>;
14
+ private createBaseContext;
15
+ abstract createContext(baseContext: StepExecutorBaseContext): Promise<StepExecutorContext>;
16
+ abstract createPipeline(context: StepExecutorContext): TaskPipeline;
17
+ abstract parseErrors(error: Error, step?: LiFiStepExtended, action?: ExecutionAction, retryParams?: ExecuteStepRetryParams): Promise<SDKError | ExecuteStepRetryError>;
18
+ executeStep: (client: SDKClient, step: LiFiStepExtended, retryParams?: ExecuteStepRetryParams) => Promise<LiFiStepExtended>;
12
19
  }
@@ -1,3 +1,4 @@
1
+ import { ExecuteStepRetryError } from '../errors/errors.js';
1
2
  import { StatusManager } from './StatusManager.js';
2
3
  // Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
3
4
  const defaultInteractionSettings = {
@@ -23,5 +24,57 @@ export class BaseStepExecutor {
23
24
  this.statusManager.allowUpdates(interactionSettings.allowUpdates);
24
25
  this.allowExecution = interactionSettings.allowExecution;
25
26
  };
27
+ createBaseContext = async (client, step, retryParams) => {
28
+ const fromChain = await client.getChainById(step.action.fromChainId);
29
+ const toChain = await client.getChainById(step.action.toChainId);
30
+ const isBridgeExecution = fromChain.id !== toChain.id;
31
+ return {
32
+ client,
33
+ step,
34
+ fromChain,
35
+ toChain,
36
+ isBridgeExecution,
37
+ retryParams,
38
+ statusManager: this.statusManager,
39
+ executionOptions: this.executionOptions,
40
+ allowUserInteraction: this.allowUserInteraction,
41
+ };
42
+ };
43
+ executeStep = async (client, step, retryParams) => {
44
+ try {
45
+ step.execution = this.statusManager.initializeExecution(step);
46
+ const baseContext = await this.createBaseContext(client, step, retryParams);
47
+ const context = await this.createContext(baseContext);
48
+ const pipeline = this.createPipeline(context);
49
+ await pipeline.run(context);
50
+ return step;
51
+ }
52
+ catch (error) {
53
+ const action = step.execution?.lastActionType
54
+ ? this.statusManager.findAction(step, step.execution.lastActionType)
55
+ : undefined;
56
+ const parsed = await this.parseErrors(error, step, action, retryParams);
57
+ if (!(parsed instanceof ExecuteStepRetryError)) {
58
+ if (action) {
59
+ this.statusManager.updateAction(step, action.type, 'FAILED', {
60
+ error: {
61
+ message: parsed.cause?.message,
62
+ code: parsed.code,
63
+ },
64
+ });
65
+ }
66
+ else {
67
+ this.statusManager.updateExecution(step, {
68
+ status: 'FAILED',
69
+ error: {
70
+ message: parsed.cause?.message,
71
+ code: parsed.code,
72
+ },
73
+ });
74
+ }
75
+ }
76
+ throw parsed;
77
+ }
78
+ };
26
79
  }
27
80
  //# sourceMappingURL=BaseStepExecutor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseStepExecutor.js","sourceRoot":"","sources":["../../../src/core/BaseStepExecutor.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,oBA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CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;YACD,MAAM,MAAM,CAAA;QACd,CAAC;IACH,CAAC,CAAA;CACF"}
@@ -1,16 +1,13 @@
1
1
  import type { ChainId, LiFiStep } from '@lifi/types';
2
- import type { Execution, ExecutionStatus, LiFiStepExtended, Process, ProcessStatus, ProcessType } from '../types/core.js';
3
- type FindOrCreateProcessProps = {
2
+ import type { Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, LiFiStepExtended } from '../types/core.js';
3
+ type ActionProps = {
4
4
  step: LiFiStepExtended;
5
- type: ProcessType;
6
- chainId?: ChainId;
7
- status?: ProcessStatus;
8
- startedAt?: number;
5
+ type: ExecutionActionType;
6
+ chainId: ChainId;
7
+ status: ExecutionActionStatus;
9
8
  };
10
9
  /**
11
- * Manages status updates of a route and provides various functions for tracking processes
12
- * @param {string} routeId The route dd this StatusManger belongs to.
13
- * @returns {StatusManager} An instance of StatusManager.
10
+ * Manages status updates of a route and provides various functions for tracking actions.
14
11
  */
15
12
  export declare class StatusManager {
16
13
  private readonly routeId;
@@ -18,50 +15,54 @@ export declare class StatusManager {
18
15
  constructor(routeId: string);
19
16
  /**
20
17
  * Initializes the execution object of a Step.
21
- * @param step The current step in execution
22
- * @returns The initialized execution object for this step and a function to update this step
18
+ * @param step The current step in execution
19
+ * @returns The initialized execution object for this step
23
20
  */
24
- initExecutionObject: (step: LiFiStepExtended) => Execution;
21
+ initializeExecution: (step: LiFiStepExtended) => Execution;
25
22
  /**
26
23
  * Updates the execution object of a Step.
27
- * @param step The current step in execution
28
- * @param status The status for the execution
29
- * @param execution Optional. Information about received tokens
24
+ * @param step The current step in execution
25
+ * @param execution Partial execution data to merge
30
26
  * @returns The step with the updated execution object
31
27
  */
32
- updateExecution(step: LiFiStepExtended, status: ExecutionStatus, execution?: Partial<Execution>): LiFiStep;
28
+ updateExecution(step: LiFiStepExtended, execution: Partial<Execution>): LiFiStep;
33
29
  /**
34
- * Finds a process of the specified type in the step's execution
30
+ * Finds an action of the specified type in the step's execution
35
31
  * @param step The step to search in
36
- * @param type The process type to find
37
- * @param status Optional status to update the process with if found
38
- * @returns The found process or undefined if not found
32
+ * @param type The action type to find
33
+ * @returns The found action or undefined if not found
39
34
  */
40
- findProcess(step: LiFiStepExtended, type: ProcessType, status?: ProcessStatus): Process | undefined;
35
+ findAction(step: LiFiStepExtended, type: ExecutionActionType): ExecutionAction | undefined;
41
36
  /**
42
- * Create and push a new process into the execution.
43
- * @param step The step that should contain the new process.
44
- * @param type Type of the process. Used to identify already existing processes.
45
- * @param chainId Chain Id of the process.
46
- * @param status By default created process is set to the STARTED status. We can override new process with the needed status.
47
- * @returns Returns process.
37
+ * Create and push a new action into the execution.
38
+ * Caller is responsible for ensuring an action of this type does not already exist.
39
+ * @param step The step that should contain the new action.
40
+ * @param type Type of the action.
41
+ * @param chainId Chain Id of the action.
42
+ * @param status The initial status for the new action.
43
+ * @returns The created action.
48
44
  */
49
- findOrCreateProcess: ({ step, type, chainId, status, startedAt, }: FindOrCreateProcessProps) => Process;
45
+ createAction: ({ step, type, chainId, status, }: ActionProps) => ExecutionAction;
50
46
  /**
51
- * Update a process object.
52
- * @param step The step where the process should be updated
53
- * @param type The process type to update
54
- * @param status The status the process gets.
55
- * @param [params] Additional parameters to append to the process.
56
- * @returns The update process
47
+ * Find an existing action by type and update it, or create a new one if none exists.
48
+ * @param step The step that should contain the action.
49
+ * @param type Type of the action. Used to identify already existing actions.
50
+ * @param chainId Chain Id of the action (used when creating).
51
+ * @param status The status to set on the found or newly created action.
52
+ * @returns The updated or newly created action.
57
53
  */
58
- updateProcess: (step: LiFiStepExtended, type: ProcessType, status: ProcessStatus, params?: Partial<Process>) => Process;
54
+ initializeAction: ({ step, type, chainId, status, }: ActionProps) => ExecutionAction;
59
55
  /**
60
- * Remove a process from the execution
61
- * @param step The step where the process should be removed from
62
- * @param type The process type to remove
56
+ * Update an action object.
57
+ * @param step The step where the action should be updated
58
+ * @param type The action type to update
59
+ * @param status The status the action gets.
60
+ * @param [params] Additional parameters to append to the action.
61
+ * @returns The updated action
63
62
  */
64
- removeProcess: (step: LiFiStepExtended, type: ProcessType) => void;
63
+ updateAction: (step: LiFiStepExtended, type: ExecutionActionType, status: ExecutionActionStatus, params?: Partial<ExecutionAction & {
64
+ signedAt?: number;
65
+ }>) => ExecutionAction;
65
66
  updateStepInRoute: (step: LiFiStep) => LiFiStep;
66
67
  allowUpdates(value: boolean): void;
67
68
  }
@@ -1,9 +1,7 @@
1
+ import { getActionMessage } from './actionMessages.js';
1
2
  import { executionState } from './executionState.js';
2
- import { getProcessMessage } from './processMessages.js';
3
3
  /**
4
- * Manages status updates of a route and provides various functions for tracking processes
5
- * @param {string} routeId The route dd this StatusManger belongs to.
6
- * @returns {StatusManager} An instance of StatusManager.
4
+ * Manages status updates of a route and provides various functions for tracking actions.
7
5
  */
8
6
  export class StatusManager {
9
7
  routeId;
@@ -13,15 +11,15 @@ export class StatusManager {
13
11
  }
14
12
  /**
15
13
  * Initializes the execution object of a Step.
16
- * @param step The current step in execution
17
- * @returns The initialized execution object for this step and a function to update this step
14
+ * @param step The current step in execution
15
+ * @returns The initialized execution object for this step
18
16
  */
19
- initExecutionObject = (step) => {
17
+ initializeExecution = (step) => {
20
18
  if (!step.execution) {
21
19
  step.execution = {
22
- status: 'PENDING',
23
- process: [],
24
20
  startedAt: Date.now(),
21
+ status: 'PENDING',
22
+ actions: [],
25
23
  };
26
24
  this.updateStepInRoute(step);
27
25
  }
@@ -29,144 +27,140 @@ export class StatusManager {
29
27
  if (step.execution.status === 'FAILED') {
30
28
  step.execution.startedAt = Date.now();
31
29
  step.execution.status = 'PENDING';
30
+ step.execution.signedAt = undefined;
31
+ step.execution.lastActionType = undefined;
32
+ step.execution.error = undefined;
32
33
  this.updateStepInRoute(step);
33
34
  }
34
35
  return step.execution;
35
36
  };
36
37
  /**
37
38
  * Updates the execution object of a Step.
38
- * @param step The current step in execution
39
- * @param status The status for the execution
40
- * @param execution Optional. Information about received tokens
39
+ * @param step The current step in execution
40
+ * @param execution Partial execution data to merge
41
41
  * @returns The step with the updated execution object
42
42
  */
43
- updateExecution(step, status, execution) {
43
+ updateExecution(step, execution) {
44
44
  if (!step.execution) {
45
45
  throw Error("Can't update empty execution.");
46
46
  }
47
- step.execution.status = status;
48
- if (status === 'DONE') {
49
- step.execution.doneAt = Date.now();
50
- }
51
- if (execution) {
52
- step.execution = {
53
- ...step.execution,
54
- ...execution,
55
- };
56
- }
47
+ step.execution = {
48
+ ...step.execution,
49
+ ...execution,
50
+ };
57
51
  this.updateStepInRoute(step);
58
52
  return step;
59
53
  }
60
54
  /**
61
- * Finds a process of the specified type in the step's execution
55
+ * Finds an action of the specified type in the step's execution
62
56
  * @param step The step to search in
63
- * @param type The process type to find
64
- * @param status Optional status to update the process with if found
65
- * @returns The found process or undefined if not found
57
+ * @param type The action type to find
58
+ * @returns The found action or undefined if not found
66
59
  */
67
- findProcess(step, type, status) {
68
- if (!step.execution?.process) {
60
+ findAction(step, type) {
61
+ if (!step.execution?.actions) {
69
62
  throw new Error("Execution hasn't been initialized.");
70
63
  }
71
- const process = step.execution.process.find((p) => p.type === type);
72
- if (process && status && process.status !== status) {
73
- process.status = status;
74
- this.updateStepInRoute(step);
75
- }
76
- return process;
64
+ const action = step.execution.actions.find((p) => p.type === type);
65
+ return action;
77
66
  }
78
67
  /**
79
- * Create and push a new process into the execution.
80
- * @param step The step that should contain the new process.
81
- * @param type Type of the process. Used to identify already existing processes.
82
- * @param chainId Chain Id of the process.
83
- * @param status By default created process is set to the STARTED status. We can override new process with the needed status.
84
- * @returns Returns process.
68
+ * Create and push a new action into the execution.
69
+ * Caller is responsible for ensuring an action of this type does not already exist.
70
+ * @param step The step that should contain the new action.
71
+ * @param type Type of the action.
72
+ * @param chainId Chain Id of the action.
73
+ * @param status The initial status for the new action.
74
+ * @returns The created action.
85
75
  */
86
- findOrCreateProcess = ({ step, type, chainId, status, startedAt, }) => {
87
- const process = this.findProcess(step, type, status);
88
- if (process) {
89
- return process;
76
+ createAction = ({ step, type, chainId, status, }) => {
77
+ if (!step.execution) {
78
+ throw new Error("Execution hasn't been initialized.");
90
79
  }
91
- const newProcess = {
92
- type: type,
93
- startedAt: startedAt ?? Date.now(),
94
- message: getProcessMessage(type, status ?? 'STARTED'),
95
- status: status ?? 'STARTED',
96
- chainId: chainId,
80
+ const newAction = {
81
+ type,
82
+ message: getActionMessage(type, status),
83
+ status,
84
+ chainId,
97
85
  };
98
- step.execution.process.push(newProcess);
86
+ step.execution.actions.push(newAction);
87
+ step.execution.lastActionType = type;
99
88
  this.updateStepInRoute(step);
100
- return newProcess;
89
+ return newAction;
101
90
  };
102
91
  /**
103
- * Update a process object.
104
- * @param step The step where the process should be updated
105
- * @param type The process type to update
106
- * @param status The status the process gets.
107
- * @param [params] Additional parameters to append to the process.
108
- * @returns The update process
92
+ * Find an existing action by type and update it, or create a new one if none exists.
93
+ * @param step The step that should contain the action.
94
+ * @param type Type of the action. Used to identify already existing actions.
95
+ * @param chainId Chain Id of the action (used when creating).
96
+ * @param status The status to set on the found or newly created action.
97
+ * @returns The updated or newly created action.
109
98
  */
110
- updateProcess = (step, type, status, params) => {
99
+ initializeAction = ({ step, type, chainId, status, }) => {
100
+ const action = this.findAction(step, type);
101
+ if (action) {
102
+ return this.updateAction(step, type, status, {
103
+ error: undefined,
104
+ });
105
+ }
106
+ return this.createAction({ step, type, chainId, status });
107
+ };
108
+ /**
109
+ * Update an action object.
110
+ * @param step The step where the action should be updated
111
+ * @param type The action type to update
112
+ * @param status The status the action gets.
113
+ * @param [params] Additional parameters to append to the action.
114
+ * @returns The updated action
115
+ */
116
+ updateAction = (step, type, status, params) => {
111
117
  if (!step.execution) {
112
118
  throw new Error("Can't update an empty step execution.");
113
119
  }
114
- const currentProcess = this.findProcess(step, type);
115
- if (!currentProcess) {
116
- throw new Error("Can't find a process for the given type.");
120
+ const currentAction = this.findAction(step, type);
121
+ if (!currentAction) {
122
+ throw new Error("Can't find an action for the given type.");
117
123
  }
118
124
  switch (status) {
119
125
  case 'CANCELLED':
120
- currentProcess.doneAt = Date.now();
121
126
  break;
122
127
  case 'FAILED':
123
- currentProcess.doneAt = Date.now();
124
128
  step.execution.status = 'FAILED';
129
+ if (params?.error) {
130
+ step.execution.error = params.error;
131
+ }
125
132
  break;
126
133
  case 'DONE':
127
- currentProcess.doneAt = Date.now();
128
134
  break;
129
135
  case 'PENDING':
130
136
  step.execution.status = 'PENDING';
131
- currentProcess.pendingAt = Date.now();
137
+ if (params?.signedAt) {
138
+ step.execution.signedAt = params.signedAt;
139
+ }
132
140
  break;
133
141
  case 'RESET_REQUIRED':
134
142
  case 'MESSAGE_REQUIRED':
135
143
  case 'ACTION_REQUIRED':
136
144
  step.execution.status = 'ACTION_REQUIRED';
137
- currentProcess.actionRequiredAt = Date.now();
138
145
  break;
139
146
  default:
140
147
  break;
141
148
  }
142
- currentProcess.status = status;
143
- currentProcess.message = getProcessMessage(type, status);
144
- // set extra parameters or overwritte the standard params set in the switch statement
149
+ step.execution.lastActionType = type;
150
+ currentAction.status = status;
151
+ currentAction.message = getActionMessage(type, status);
152
+ // set extra parameters or overwrite the standard params set in the switch statement
145
153
  if (params) {
146
- for (const [key, value] of Object.entries(params)) {
147
- currentProcess[key] = value;
148
- }
154
+ const { signedAt: _signedAt, ...rest } = params;
155
+ Object.assign(currentAction, rest);
149
156
  }
150
- // Sort processes, the ones with DONE status go first
151
- step.execution.process = [
152
- ...step.execution.process.filter((process) => process.status === 'DONE'),
153
- ...step.execution.process.filter((process) => process.status !== 'DONE'),
157
+ // Sort actions, the ones with DONE status go first
158
+ step.execution.actions = [
159
+ ...step.execution.actions.filter((action) => action.status === 'DONE'),
160
+ ...step.execution.actions.filter((action) => action.status !== 'DONE'),
154
161
  ];
155
162
  this.updateStepInRoute(step); // updates the step in the route
156
- return currentProcess;
157
- };
158
- /**
159
- * Remove a process from the execution
160
- * @param step The step where the process should be removed from
161
- * @param type The process type to remove
162
- */
163
- removeProcess = (step, type) => {
164
- if (!step.execution) {
165
- throw new Error("Execution hasn't been initialized.");
166
- }
167
- const index = step.execution.process.findIndex((p) => p.type === type);
168
- step.execution.process.splice(index, 1);
169
- this.updateStepInRoute(step);
163
+ return currentAction;
170
164
  };
171
165
  updateStepInRoute = (step) => {
172
166
  if (!this.shouldUpdate) {
@@ -1 +1 @@
1
- {"version":3,"file":"StatusManager.js","sourceRoot":"","sources":["../../../src/core/StatusManager.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAUxD;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACP,OAAO,CAAQ;IACxB,YAAY,GAAG,IAAI,CAAA;IAE3B,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED;;;;OAIG;IACH,mBAAmB,GAAG,CAAC,IAAsB,EAAa,EAAE;QAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG;gBACf,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,EAAE;gBACX,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAA;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;QAED,sDAAsD;QACtD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACrC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,SAAS,CAAA;YACjC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC,CAAA;IAED;;;;;;OAMG;IACH,eAAe,CACb,IAAsB,EACtB,MAAuB,EAC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I,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAE7C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAC1C,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CACxC,CAAA;QAED,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;QACpD,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,CAAA;QAEzE,IAAI,CAAC,gBAAgB,EAAE,eAAe,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IACpC,CAAC,CAAA;IAED,YAAY,CAAC,KAAc;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;IAC3B,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import type { StepExecutorContext, TaskResult } from '../types/execution.js';
2
+ import type { BaseStepExecutionTask } from './BaseStepExecutionTask.js';
3
+ export declare class TaskPipeline {
4
+ private readonly tasks;
5
+ constructor(tasks: BaseStepExecutionTask[]);
6
+ run(context: StepExecutorContext): Promise<TaskResult>;
7
+ }
@@ -0,0 +1,23 @@
1
+ export class TaskPipeline {
2
+ tasks;
3
+ constructor(tasks) {
4
+ this.tasks = tasks;
5
+ }
6
+ async run(context) {
7
+ for (const task of this.tasks) {
8
+ const shouldRun = await task.shouldRun(context);
9
+ if (!shouldRun) {
10
+ continue;
11
+ }
12
+ const result = await task.run(context);
13
+ if (result.status === 'PAUSED') {
14
+ return { status: 'PAUSED' };
15
+ }
16
+ if (result.context && typeof result.context === 'object') {
17
+ Object.assign(context, result.context);
18
+ }
19
+ }
20
+ return { status: 'COMPLETED' };
21
+ }
22
+ }
23
+ //# sourceMappingURL=TaskPipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskPipeline.js","sourceRoot":"","sources":["../../../src/core/TaskPipeline.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,YAAY;IACN,KAAK,CAAyB;IAE/C,YAAY,KAA8B;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAA4B;QACpC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;YAC/C,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,SAAQ;YACV,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACtC,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;YAC7B,CAAC;YACD,IAAI,MAAM,CAAC,OAAO,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACzD,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;YACxC,CAAC;QACH,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAA;IAChC,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { StatusMessage, Substatus } from '@lifi/types';
2
+ import type { ExecutionActionStatus, ExecutionActionType } from '../types/core.js';
3
+ export declare function getActionMessage(type: ExecutionActionType, status: ExecutionActionStatus): string | undefined;
4
+ export declare function getSubstatusMessage(status: StatusMessage, substatus?: Substatus): string | undefined;