@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,4 +1,5 @@
1
1
  import type { LiFiStep, RequestOptions, SignedLiFiStep } from '@lifi/types'
2
+ import { ChainId } from '@lifi/types'
2
3
  import type { SDKClient } from '../types/core.js'
3
4
  import { isStep } from '../utils/isStep.js'
4
5
  import { request } from '../utils/request.js'
@@ -21,16 +22,23 @@ export const getStepTransaction = async (
21
22
  console.warn('SDK Validation: Invalid Step', step)
22
23
  }
23
24
 
24
- return await request<LiFiStep>(
25
- client.config,
26
- `${client.config.apiUrl}/advanced/stepTransaction`,
27
- {
28
- method: 'POST',
29
- headers: {
30
- 'Content-Type': 'application/json',
31
- },
32
- body: JSON.stringify(step),
33
- signal: options?.signal,
34
- }
35
- )
25
+ const { config } = client
26
+
27
+ let requestUrl = `${config.apiUrl}/advanced/stepTransaction`
28
+ const isJitoBundleEnabled = Boolean(config.routeOptions?.jitoBundle)
29
+
30
+ if (isJitoBundleEnabled && step.action.fromChainId === ChainId.SOL) {
31
+ // add jitoBundle param to url if from chain is SVM and jitoBundle is enabled in config
32
+ const queryParams = new URLSearchParams({ jitoBundle: 'true' })
33
+ requestUrl = `${requestUrl}?${queryParams}`
34
+ }
35
+
36
+ return await request<LiFiStep>(config, requestUrl, {
37
+ method: 'POST',
38
+ headers: {
39
+ 'Content-Type': 'application/json',
40
+ },
41
+ body: JSON.stringify(step),
42
+ signal: options?.signal,
43
+ })
36
44
  }
@@ -10,6 +10,7 @@ import type {
10
10
  GasRecommendationRequest,
11
11
  GasRecommendationResponse,
12
12
  LiFiStep,
13
+ PatchCallDataRequest,
13
14
  RelayRequest,
14
15
  RelayResponseData,
15
16
  RelayStatusRequest,
@@ -55,6 +56,10 @@ import { getTokens } from './getTokens.js'
55
56
  import { getTools } from './getTools.js'
56
57
  import { getTransactionHistory } from './getTransactionHistory.js'
57
58
  import { getWalletBalances } from './getWalletBalances.js'
59
+ import {
60
+ type PatchContractCallsResponse,
61
+ patchContractCalls,
62
+ } from './patchContractCalls.js'
58
63
  import { relayTransaction } from './relayTransaction.js'
59
64
 
60
65
  export type Actions = {
@@ -287,6 +292,17 @@ export type Actions = {
287
292
  params: RelayRequest,
288
293
  options?: RequestOptions
289
294
  ) => Promise<RelayResponseData>
295
+
296
+ /**
297
+ * Patch contract calls
298
+ * @param params - The configuration for the patch contract calls request
299
+ * @param options - Request options
300
+ * @returns Patched contract calls
301
+ */
302
+ patchContractCalls: (
303
+ params: PatchCallDataRequest,
304
+ options?: RequestOptions
305
+ ) => Promise<PatchContractCallsResponse[]>
290
306
  }
291
307
 
292
308
  export function actions(client: SDKClient): Actions {
@@ -325,5 +341,7 @@ export function actions(client: SDKClient): Actions {
325
341
  getWalletBalances(client, walletAddress, options),
326
342
  relayTransaction: (params, options) =>
327
343
  relayTransaction(client, params, options),
344
+ patchContractCalls: (params, options) =>
345
+ patchContractCalls(client, params, options),
328
346
  }
329
347
  }
@@ -0,0 +1,30 @@
1
+ import type { PatchCallDataRequest, RequestOptions } from '@lifi/types'
2
+ import type { SDKClient } from '../types/core.js'
3
+ import { request } from '../utils/request.js'
4
+
5
+ export interface PatchContractCallsResponse {
6
+ target: string
7
+ value: bigint
8
+ callData: string
9
+ allowFailure: boolean
10
+ isDelegateCall: boolean
11
+ }
12
+
13
+ export const patchContractCalls = async (
14
+ client: SDKClient,
15
+ params: PatchCallDataRequest,
16
+ options?: RequestOptions
17
+ ): Promise<PatchContractCallsResponse[]> => {
18
+ return await request<PatchContractCallsResponse[]>(
19
+ client.config,
20
+ `${client.config.apiUrl}/patcher`,
21
+ {
22
+ method: 'POST',
23
+ headers: {
24
+ 'Content-Type': 'application/json',
25
+ },
26
+ body: JSON.stringify(params),
27
+ signal: options?.signal,
28
+ }
29
+ )
30
+ }
@@ -1,4 +1,4 @@
1
- import type { ChainId, ChainType } from '@lifi/types'
1
+ import type { ChainId, ChainType, ExtendedChain } from '@lifi/types'
2
2
  import type {
3
3
  SDKBaseConfig,
4
4
  SDKClient,
@@ -25,6 +25,7 @@ export function createClient(options: SDKConfig): SDKClient {
25
25
  apiUrl: options?.apiUrl ?? 'https://li.quest/v1',
26
26
  rpcUrls: options?.rpcUrls ?? {},
27
27
  debug: options?.debug ?? false,
28
+ preloadChains: options?.preloadChains ?? true,
28
29
  integrator: options?.integrator ?? 'lifi-sdk',
29
30
  }
30
31
 
@@ -50,6 +51,9 @@ export function createClient(options: SDKConfig): SDKClient {
50
51
  }
51
52
  _providers = Array.from(providerMap.values())
52
53
  },
54
+ setChains(chains: ExtendedChain[]) {
55
+ _storage.setChains(chains)
56
+ },
53
57
  async getChains() {
54
58
  return await _storage.getChains()
55
59
  },
@@ -1,39 +1,57 @@
1
1
  import { ChainId, ChainType, type ExtendedChain } 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
4
  import type { RPCUrls, SDKBaseConfig } from '../types/core.js'
5
5
 
6
+ // 6 hours in milliseconds
7
+ const chainsRefreshInterval = 1000 * 60 * 60 * 6
8
+
6
9
  export const getClientStorage = (config: SDKBaseConfig) => {
7
10
  let _chains = [] as ExtendedChain[]
8
11
  let _rpcUrls = { ...config.rpcUrls } as RPCUrls
9
12
  let _chainsUpdatedAt: number | undefined
10
13
 
14
+ const updateRpcUrls = () => {
15
+ _rpcUrls = { ...config.rpcUrls }
16
+ _rpcUrls = getRpcUrlsFromChains(_rpcUrls, _chains, [ChainId.SOL])
17
+ }
18
+
11
19
  return {
12
20
  get needReset() {
13
21
  return (
14
22
  !_chainsUpdatedAt ||
15
- Date.now() - _chainsUpdatedAt >= 1000 * 60 * 60 * 24
23
+ Date.now() - _chainsUpdatedAt >= chainsRefreshInterval
16
24
  )
17
25
  },
26
+ setChains(chains: ExtendedChain[]) {
27
+ _chains = chains
28
+ _chainsUpdatedAt = Date.now()
29
+ updateRpcUrls()
30
+ },
18
31
  async getChains() {
32
+ // When preloadChains is false, SDK does not auto-fetch chains
33
+ // External consumer is responsible for calling setChains
34
+ if (!config.preloadChains) {
35
+ return _chains
36
+ }
37
+
19
38
  if (this.needReset || !_chains.length) {
20
- _chains = await getChainsFromConfig(config, {
39
+ _chains = await _getChains(config, {
21
40
  chainTypes: [
22
41
  ChainType.EVM,
23
42
  ChainType.SVM,
24
43
  ChainType.UTXO,
25
44
  ChainType.MVM,
45
+ ChainType.TVM,
26
46
  ],
27
47
  })
28
48
  _chainsUpdatedAt = Date.now()
49
+ updateRpcUrls()
29
50
  }
30
51
  return _chains
31
52
  },
32
53
  async getRpcUrls() {
33
- if (this.needReset || !Object.keys(_rpcUrls).length) {
34
- const chains = await this.getChains()
35
- _rpcUrls = getRpcUrlsFromChains(_rpcUrls, chains, [ChainId.SOL])
36
- }
54
+ await this.getChains() // _rpcUrls is updated when needed
37
55
  return _rpcUrls
38
56
  },
39
57
  }
@@ -0,0 +1,9 @@
1
+ import type { StepExecutorContext, TaskResult } from '../types/execution.js'
2
+
3
+ export abstract class BaseStepExecutionTask {
4
+ shouldRun(_context: StepExecutorContext): Promise<boolean> {
5
+ return Promise.resolve(true)
6
+ }
7
+
8
+ abstract run(context: StepExecutorContext): Promise<TaskResult>
9
+ }
@@ -1,12 +1,21 @@
1
- import type { LiFiStep } from '@lifi/types'
1
+ import { ExecuteStepRetryError } from '../errors/errors.js'
2
+ import type { SDKError } from '../errors/SDKError.js'
2
3
  import type {
4
+ ExecuteStepRetryParams,
5
+ ExecutionAction,
3
6
  ExecutionOptions,
4
7
  InteractionSettings,
8
+ LiFiStepExtended,
5
9
  SDKClient,
6
10
  StepExecutor,
7
11
  StepExecutorOptions,
8
12
  } from '../types/core.js'
13
+ import type {
14
+ StepExecutorBaseContext,
15
+ StepExecutorContext,
16
+ } from '../types/execution.js'
9
17
  import { StatusManager } from './StatusManager.js'
18
+ import type { TaskPipeline } from './TaskPipeline.js'
10
19
 
11
20
  // Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
12
21
  const defaultInteractionSettings = {
@@ -37,5 +46,85 @@ export abstract class BaseStepExecutor implements StepExecutor {
37
46
  this.allowExecution = interactionSettings.allowExecution
38
47
  }
39
48
 
40
- abstract executeStep(client: SDKClient, step: LiFiStep): Promise<LiFiStep>
49
+ private createBaseContext = async (
50
+ client: SDKClient,
51
+ step: LiFiStepExtended,
52
+ retryParams?: ExecuteStepRetryParams
53
+ ): Promise<StepExecutorBaseContext> => {
54
+ const fromChain = await client.getChainById(step.action.fromChainId)
55
+ const toChain = await client.getChainById(step.action.toChainId)
56
+
57
+ const isBridgeExecution = fromChain.id !== toChain.id
58
+
59
+ return {
60
+ client,
61
+ step,
62
+ fromChain,
63
+ toChain,
64
+ isBridgeExecution,
65
+ retryParams,
66
+ statusManager: this.statusManager,
67
+ executionOptions: this.executionOptions,
68
+ allowUserInteraction: this.allowUserInteraction,
69
+ }
70
+ }
71
+
72
+ abstract createContext(
73
+ baseContext: StepExecutorBaseContext
74
+ ): Promise<StepExecutorContext>
75
+
76
+ abstract createPipeline(context: StepExecutorContext): TaskPipeline
77
+
78
+ abstract parseErrors(
79
+ error: Error,
80
+ step?: LiFiStepExtended,
81
+ action?: ExecutionAction,
82
+ retryParams?: ExecuteStepRetryParams
83
+ ): Promise<SDKError | ExecuteStepRetryError>
84
+
85
+ executeStep = async (
86
+ client: SDKClient,
87
+ step: LiFiStepExtended,
88
+ retryParams?: ExecuteStepRetryParams
89
+ ): Promise<LiFiStepExtended> => {
90
+ try {
91
+ step.execution = this.statusManager.initializeExecution(step)
92
+
93
+ const baseContext = await this.createBaseContext(
94
+ client,
95
+ step,
96
+ retryParams
97
+ )
98
+ const context = await this.createContext(baseContext)
99
+ const pipeline = this.createPipeline(context)
100
+
101
+ await pipeline.run(context)
102
+
103
+ return step
104
+ } catch (error: any) {
105
+ const action = step.execution?.lastActionType
106
+ ? this.statusManager.findAction(step, step.execution.lastActionType)
107
+ : undefined
108
+ const parsed = await this.parseErrors(error, step, action, retryParams)
109
+ if (!(parsed instanceof ExecuteStepRetryError)) {
110
+ if (action) {
111
+ this.statusManager.updateAction(step, action.type, 'FAILED', {
112
+ error: {
113
+ message: parsed.cause?.message,
114
+ code: parsed.code,
115
+ },
116
+ })
117
+ } else {
118
+ this.statusManager.updateExecution(step, {
119
+ status: 'FAILED',
120
+ error: {
121
+ message: parsed.cause?.message,
122
+ code: parsed.code,
123
+ },
124
+ })
125
+ }
126
+ }
127
+ throw parsed
128
+ }
129
+ }
41
130
  }
@@ -1,27 +1,23 @@
1
1
  import type { ChainId, LiFiStep } from '@lifi/types'
2
2
  import type {
3
3
  Execution,
4
- ExecutionStatus,
4
+ ExecutionAction,
5
+ ExecutionActionStatus,
6
+ ExecutionActionType,
5
7
  LiFiStepExtended,
6
- Process,
7
- ProcessStatus,
8
- ProcessType,
9
8
  } from '../types/core.js'
9
+ import { getActionMessage } from './actionMessages.js'
10
10
  import { executionState } from './executionState.js'
11
- import { getProcessMessage } from './processMessages.js'
12
11
 
13
- type FindOrCreateProcessProps = {
12
+ type ActionProps = {
14
13
  step: LiFiStepExtended
15
- type: ProcessType
16
- chainId?: ChainId
17
- status?: ProcessStatus
18
- startedAt?: number
14
+ type: ExecutionActionType
15
+ chainId: ChainId
16
+ status: ExecutionActionStatus
19
17
  }
20
18
 
21
19
  /**
22
- * Manages status updates of a route and provides various functions for tracking processes
23
- * @param {string} routeId The route dd this StatusManger belongs to.
24
- * @returns {StatusManager} An instance of StatusManager.
20
+ * Manages status updates of a route and provides various functions for tracking actions.
25
21
  */
26
22
  export class StatusManager {
27
23
  private readonly routeId: string
@@ -33,15 +29,15 @@ export class StatusManager {
33
29
 
34
30
  /**
35
31
  * Initializes the execution object of a Step.
36
- * @param step The current step in execution
37
- * @returns The initialized execution object for this step and a function to update this step
32
+ * @param step The current step in execution
33
+ * @returns The initialized execution object for this step
38
34
  */
39
- initExecutionObject = (step: LiFiStepExtended): Execution => {
35
+ initializeExecution = (step: LiFiStepExtended): Execution => {
40
36
  if (!step.execution) {
41
37
  step.execution = {
42
- status: 'PENDING',
43
- process: [],
44
38
  startedAt: Date.now(),
39
+ status: 'PENDING',
40
+ actions: [],
45
41
  }
46
42
  this.updateStepInRoute(step)
47
43
  }
@@ -50,6 +46,9 @@ export class StatusManager {
50
46
  if (step.execution.status === 'FAILED') {
51
47
  step.execution.startedAt = Date.now()
52
48
  step.execution.status = 'PENDING'
49
+ step.execution.signedAt = undefined
50
+ step.execution.lastActionType = undefined
51
+ step.execution.error = undefined
53
52
  this.updateStepInRoute(step)
54
53
  }
55
54
 
@@ -58,170 +57,166 @@ export class StatusManager {
58
57
 
59
58
  /**
60
59
  * Updates the execution object of a Step.
61
- * @param step The current step in execution
62
- * @param status The status for the execution
63
- * @param execution Optional. Information about received tokens
60
+ * @param step The current step in execution
61
+ * @param execution Partial execution data to merge
64
62
  * @returns The step with the updated execution object
65
63
  */
66
64
  updateExecution(
67
65
  step: LiFiStepExtended,
68
- status: ExecutionStatus,
69
- execution?: Partial<Execution>
66
+ execution: Partial<Execution>
70
67
  ): LiFiStep {
71
68
  if (!step.execution) {
72
69
  throw Error("Can't update empty execution.")
73
70
  }
74
- step.execution.status = status
75
- if (status === 'DONE') {
76
- step.execution.doneAt = Date.now()
77
- }
78
- if (execution) {
79
- step.execution = {
80
- ...step.execution,
81
- ...execution,
82
- }
71
+ step.execution = {
72
+ ...step.execution,
73
+ ...execution,
83
74
  }
84
75
  this.updateStepInRoute(step)
85
76
  return step
86
77
  }
87
78
 
88
79
  /**
89
- * Finds a process of the specified type in the step's execution
80
+ * Finds an action of the specified type in the step's execution
90
81
  * @param step The step to search in
91
- * @param type The process type to find
92
- * @param status Optional status to update the process with if found
93
- * @returns The found process or undefined if not found
82
+ * @param type The action type to find
83
+ * @returns The found action or undefined if not found
94
84
  */
95
- findProcess(
85
+ findAction(
96
86
  step: LiFiStepExtended,
97
- type: ProcessType,
98
- status?: ProcessStatus
99
- ): Process | undefined {
100
- if (!step.execution?.process) {
87
+ type: ExecutionActionType
88
+ ): ExecutionAction | undefined {
89
+ if (!step.execution?.actions) {
101
90
  throw new Error("Execution hasn't been initialized.")
102
91
  }
103
92
 
104
- const process = step.execution.process.find((p) => p.type === type)
105
-
106
- if (process && status && process.status !== status) {
107
- process.status = status
108
- this.updateStepInRoute(step)
109
- }
93
+ const action = step.execution.actions.find((p) => p.type === type)
110
94
 
111
- return process
95
+ return action
112
96
  }
113
97
 
114
98
  /**
115
- * Create and push a new process into the execution.
116
- * @param step The step that should contain the new process.
117
- * @param type Type of the process. Used to identify already existing processes.
118
- * @param chainId Chain Id of the process.
119
- * @param status By default created process is set to the STARTED status. We can override new process with the needed status.
120
- * @returns Returns process.
99
+ * Create and push a new action into the execution.
100
+ * Caller is responsible for ensuring an action of this type does not already exist.
101
+ * @param step The step that should contain the new action.
102
+ * @param type Type of the action.
103
+ * @param chainId Chain Id of the action.
104
+ * @param status The initial status for the new action.
105
+ * @returns The created action.
121
106
  */
122
- findOrCreateProcess = ({
107
+ createAction = ({
123
108
  step,
124
109
  type,
125
110
  chainId,
126
111
  status,
127
- startedAt,
128
- }: FindOrCreateProcessProps): Process => {
129
- const process = this.findProcess(step, type, status)
130
-
131
- if (process) {
132
- return process
112
+ }: ActionProps): ExecutionAction => {
113
+ if (!step.execution) {
114
+ throw new Error("Execution hasn't been initialized.")
133
115
  }
134
116
 
135
- const newProcess: Process = {
136
- type: type,
137
- startedAt: startedAt ?? Date.now(),
138
- message: getProcessMessage(type, status ?? 'STARTED'),
139
- status: status ?? 'STARTED',
140
- chainId: chainId,
117
+ const newAction: ExecutionAction = {
118
+ type,
119
+ message: getActionMessage(type, status),
120
+ status,
121
+ chainId,
141
122
  }
142
123
 
143
- step.execution!.process.push(newProcess)
124
+ step.execution.actions.push(newAction)
125
+ step.execution.lastActionType = type
144
126
  this.updateStepInRoute(step)
145
- return newProcess
127
+ return newAction
128
+ }
129
+
130
+ /**
131
+ * Find an existing action by type and update it, or create a new one if none exists.
132
+ * @param step The step that should contain the action.
133
+ * @param type Type of the action. Used to identify already existing actions.
134
+ * @param chainId Chain Id of the action (used when creating).
135
+ * @param status The status to set on the found or newly created action.
136
+ * @returns The updated or newly created action.
137
+ */
138
+ initializeAction = ({
139
+ step,
140
+ type,
141
+ chainId,
142
+ status,
143
+ }: ActionProps): ExecutionAction => {
144
+ const action = this.findAction(step, type)
145
+
146
+ if (action) {
147
+ return this.updateAction(step, type, status, {
148
+ error: undefined,
149
+ })
150
+ }
151
+
152
+ return this.createAction({ step, type, chainId, status })
146
153
  }
147
154
 
148
155
  /**
149
- * Update a process object.
150
- * @param step The step where the process should be updated
151
- * @param type The process type to update
152
- * @param status The status the process gets.
153
- * @param [params] Additional parameters to append to the process.
154
- * @returns The update process
156
+ * Update an action object.
157
+ * @param step The step where the action should be updated
158
+ * @param type The action type to update
159
+ * @param status The status the action gets.
160
+ * @param [params] Additional parameters to append to the action.
161
+ * @returns The updated action
155
162
  */
156
- updateProcess = (
163
+ updateAction = (
157
164
  step: LiFiStepExtended,
158
- type: ProcessType,
159
- status: ProcessStatus,
160
- params?: Partial<Process>
161
- ): Process => {
165
+ type: ExecutionActionType,
166
+ status: ExecutionActionStatus,
167
+ params?: Partial<ExecutionAction & { signedAt?: number }>
168
+ ): ExecutionAction => {
162
169
  if (!step.execution) {
163
170
  throw new Error("Can't update an empty step execution.")
164
171
  }
165
- const currentProcess = this.findProcess(step, type)
172
+ const currentAction = this.findAction(step, type)
166
173
 
167
- if (!currentProcess) {
168
- throw new Error("Can't find a process for the given type.")
174
+ if (!currentAction) {
175
+ throw new Error("Can't find an action for the given type.")
169
176
  }
170
177
 
171
178
  switch (status) {
172
179
  case 'CANCELLED':
173
- currentProcess.doneAt = Date.now()
174
180
  break
175
181
  case 'FAILED':
176
- currentProcess.doneAt = Date.now()
177
182
  step.execution.status = 'FAILED'
183
+ if (params?.error) {
184
+ step.execution.error = params.error
185
+ }
178
186
  break
179
187
  case 'DONE':
180
- currentProcess.doneAt = Date.now()
181
188
  break
182
189
  case 'PENDING':
183
190
  step.execution.status = 'PENDING'
184
- currentProcess.pendingAt = Date.now()
191
+ if (params?.signedAt) {
192
+ step.execution.signedAt = params.signedAt
193
+ }
185
194
  break
186
195
  case 'RESET_REQUIRED':
187
196
  case 'MESSAGE_REQUIRED':
188
197
  case 'ACTION_REQUIRED':
189
198
  step.execution.status = 'ACTION_REQUIRED'
190
- currentProcess.actionRequiredAt = Date.now()
191
199
  break
192
200
  default:
193
201
  break
194
202
  }
195
203
 
196
- currentProcess.status = status
197
- currentProcess.message = getProcessMessage(type, status)
198
- // set extra parameters or overwritte the standard params set in the switch statement
204
+ step.execution.lastActionType = type
205
+
206
+ currentAction.status = status
207
+ currentAction.message = getActionMessage(type, status)
208
+ // set extra parameters or overwrite the standard params set in the switch statement
199
209
  if (params) {
200
- for (const [key, value] of Object.entries(params)) {
201
- currentProcess[key] = value
202
- }
210
+ const { signedAt: _signedAt, ...rest } = params
211
+ Object.assign(currentAction, rest)
203
212
  }
204
- // Sort processes, the ones with DONE status go first
205
- step.execution.process = [
206
- ...step.execution.process.filter((process) => process.status === 'DONE'),
207
- ...step.execution.process.filter((process) => process.status !== 'DONE'),
213
+ // Sort actions, the ones with DONE status go first
214
+ step.execution.actions = [
215
+ ...step.execution.actions.filter((action) => action.status === 'DONE'),
216
+ ...step.execution.actions.filter((action) => action.status !== 'DONE'),
208
217
  ]
209
218
  this.updateStepInRoute(step) // updates the step in the route
210
- return currentProcess
211
- }
212
-
213
- /**
214
- * Remove a process from the execution
215
- * @param step The step where the process should be removed from
216
- * @param type The process type to remove
217
- */
218
- removeProcess = (step: LiFiStepExtended, type: ProcessType): void => {
219
- if (!step.execution) {
220
- throw new Error("Execution hasn't been initialized.")
221
- }
222
- const index = step.execution.process.findIndex((p) => p.type === type)
223
- step.execution.process.splice(index, 1)
224
- this.updateStepInRoute(step)
219
+ return currentAction
225
220
  }
226
221
 
227
222
  updateStepInRoute = (step: LiFiStep): LiFiStep => {
@@ -0,0 +1,28 @@
1
+ import type { StepExecutorContext, TaskResult } from '../types/execution.js'
2
+ import type { BaseStepExecutionTask } from './BaseStepExecutionTask.js'
3
+
4
+ export class TaskPipeline {
5
+ private readonly tasks: BaseStepExecutionTask[]
6
+
7
+ constructor(tasks: BaseStepExecutionTask[]) {
8
+ this.tasks = tasks
9
+ }
10
+
11
+ async run(context: StepExecutorContext): Promise<TaskResult> {
12
+ for (const task of this.tasks) {
13
+ const shouldRun = await task.shouldRun(context)
14
+ if (!shouldRun) {
15
+ continue
16
+ }
17
+ const result = await task.run(context)
18
+ if (result.status === 'PAUSED') {
19
+ return { status: 'PAUSED' }
20
+ }
21
+ if (result.context && typeof result.context === 'object') {
22
+ Object.assign(context, result.context)
23
+ }
24
+ }
25
+
26
+ return { status: 'COMPLETED' }
27
+ }
28
+ }