@lifi/sdk 4.0.1-alpha.0 → 4.1.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 (696) hide show
  1. package/CHANGELOG.md +1233 -0
  2. package/README.md +88 -5
  3. package/dist/cjs/actions/getChains.d.ts +17 -4
  4. package/dist/cjs/actions/getChains.js +22 -19
  5. package/dist/cjs/actions/getChains.js.map +1 -1
  6. package/dist/cjs/actions/getConnections.d.ts +15 -3
  7. package/dist/cjs/actions/getConnections.js +30 -35
  8. package/dist/cjs/actions/getConnections.js.map +1 -1
  9. package/dist/cjs/actions/getContractCallsQuote.d.ts +16 -3
  10. package/dist/cjs/actions/getContractCallsQuote.js +41 -42
  11. package/dist/cjs/actions/getContractCallsQuote.js.map +1 -1
  12. package/dist/cjs/actions/getGasRecommendation.d.ts +16 -3
  13. package/dist/cjs/actions/getGasRecommendation.js +20 -19
  14. package/dist/cjs/actions/getGasRecommendation.js.map +1 -1
  15. package/dist/cjs/actions/getNameServiceAddress.d.ts +15 -3
  16. package/dist/cjs/actions/getNameServiceAddress.js +25 -27
  17. package/dist/cjs/actions/getNameServiceAddress.js.map +1 -1
  18. package/dist/cjs/actions/getQuote.d.ts +18 -5
  19. package/dist/cjs/actions/getQuote.js +33 -45
  20. package/dist/cjs/actions/getQuote.js.map +1 -1
  21. package/dist/cjs/actions/getRelayedTransactionStatus.d.ts +16 -3
  22. package/dist/cjs/actions/getRelayedTransactionStatus.js +26 -26
  23. package/dist/cjs/actions/getRelayedTransactionStatus.js.map +1 -1
  24. package/dist/cjs/actions/getRelayerQuote.d.ts +17 -4
  25. package/dist/cjs/actions/getRelayerQuote.js +40 -44
  26. package/dist/cjs/actions/getRelayerQuote.js.map +1 -1
  27. package/dist/cjs/actions/getRoutes.d.ts +17 -3
  28. package/dist/cjs/actions/getRoutes.js +28 -23
  29. package/dist/cjs/actions/getRoutes.js.map +1 -1
  30. package/dist/cjs/actions/getStatus.d.ts +17 -4
  31. package/dist/cjs/actions/getStatus.js +18 -14
  32. package/dist/cjs/actions/getStatus.js.map +1 -1
  33. package/dist/cjs/actions/getStepTransaction.d.ts +17 -3
  34. package/dist/cjs/actions/getStepTransaction.js +32 -24
  35. package/dist/cjs/actions/getStepTransaction.js.map +1 -1
  36. package/dist/cjs/actions/getToken.d.ts +17 -3
  37. package/dist/cjs/actions/getToken.js +22 -18
  38. package/dist/cjs/actions/getToken.js.map +1 -1
  39. package/dist/cjs/actions/getTokenBalance.d.ts +17 -3
  40. package/dist/cjs/actions/getTokenBalance.js +16 -6
  41. package/dist/cjs/actions/getTokenBalance.js.map +1 -1
  42. package/dist/cjs/actions/getTokenBalances.d.ts +17 -3
  43. package/dist/cjs/actions/getTokenBalances.js +12 -13
  44. package/dist/cjs/actions/getTokenBalances.js.map +1 -1
  45. package/dist/cjs/actions/getTokenBalancesByChain.d.ts +19 -5
  46. package/dist/cjs/actions/getTokenBalancesByChain.js +22 -37
  47. package/dist/cjs/actions/getTokenBalancesByChain.js.map +1 -1
  48. package/dist/cjs/actions/getTokens.d.ts +18 -6
  49. package/dist/cjs/actions/getTokens.js +14 -18
  50. package/dist/cjs/actions/getTokens.js.map +1 -1
  51. package/dist/cjs/actions/getTools.d.ts +15 -3
  52. package/dist/cjs/actions/getTools.js +17 -14
  53. package/dist/cjs/actions/getTools.js.map +1 -1
  54. package/dist/cjs/actions/getTransactionHistory.d.ts +26 -3
  55. package/dist/cjs/actions/getTransactionHistory.js +27 -21
  56. package/dist/cjs/actions/getTransactionHistory.js.map +1 -1
  57. package/dist/cjs/actions/getWalletBalances.d.ts +16 -3
  58. package/dist/cjs/actions/getWalletBalances.js +16 -12
  59. package/dist/cjs/actions/getWalletBalances.js.map +1 -1
  60. package/dist/cjs/actions/index.d.ts +174 -39
  61. package/dist/cjs/actions/index.js +49 -47
  62. package/dist/cjs/actions/index.js.map +1 -1
  63. package/dist/cjs/actions/patchContractCalls.d.ts +14 -9
  64. package/dist/cjs/actions/patchContractCalls.js +11 -12
  65. package/dist/cjs/actions/patchContractCalls.js.map +1 -1
  66. package/dist/cjs/actions/relayTransaction.d.ts +16 -3
  67. package/dist/cjs/actions/relayTransaction.js +30 -34
  68. package/dist/cjs/actions/relayTransaction.js.map +1 -1
  69. package/dist/cjs/client/createClient.d.ts +7 -2
  70. package/dist/cjs/client/createClient.js +67 -75
  71. package/dist/cjs/client/createClient.js.map +1 -1
  72. package/dist/cjs/client/getClientStorage.d.ts +14 -8
  73. package/dist/cjs/client/getClientStorage.js +44 -47
  74. package/dist/cjs/client/getClientStorage.js.map +1 -1
  75. package/dist/cjs/core/BaseStepExecutionTask.d.ts +10 -0
  76. package/dist/cjs/core/BaseStepExecutionTask.js +11 -0
  77. package/dist/cjs/core/BaseStepExecutionTask.js.map +1 -0
  78. package/dist/cjs/core/BaseStepExecutor.d.ts +23 -11
  79. package/dist/cjs/core/BaseStepExecutor.js +67 -26
  80. package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
  81. package/dist/cjs/core/StatusManager.d.ts +81 -20
  82. package/dist/cjs/core/StatusManager.js +158 -137
  83. package/dist/cjs/core/StatusManager.js.map +1 -1
  84. package/dist/cjs/core/TaskPipeline.d.ts +12 -0
  85. package/dist/cjs/core/TaskPipeline.js +21 -0
  86. package/dist/cjs/core/TaskPipeline.js.map +1 -0
  87. package/dist/cjs/core/actionMessages.d.ts +9 -4
  88. package/dist/cjs/core/actionMessages.js +72 -58
  89. package/dist/cjs/core/actionMessages.js.map +1 -1
  90. package/dist/cjs/core/execution.d.ts +48 -8
  91. package/dist/cjs/core/execution.js +131 -121
  92. package/dist/cjs/core/execution.js.map +1 -1
  93. package/dist/cjs/core/executionState.d.ts +17 -13
  94. package/dist/cjs/core/executionState.js +27 -27
  95. package/dist/cjs/core/executionState.js.map +1 -1
  96. package/dist/cjs/core/prepareRestart.d.ts +7 -2
  97. package/dist/cjs/core/prepareRestart.js +17 -19
  98. package/dist/cjs/core/prepareRestart.js.map +1 -1
  99. package/dist/cjs/core/storage.d.ts +21 -0
  100. package/dist/cjs/core/storage.js +35 -0
  101. package/dist/cjs/core/storage.js.map +1 -0
  102. package/dist/cjs/core/tasks/CheckBalanceTask.d.ts +19 -0
  103. package/dist/cjs/core/tasks/CheckBalanceTask.js +35 -0
  104. package/dist/cjs/core/tasks/CheckBalanceTask.js.map +1 -0
  105. package/dist/cjs/core/tasks/PrepareTransactionTask.d.ts +10 -0
  106. package/dist/cjs/core/tasks/PrepareTransactionTask.js +30 -0
  107. package/dist/cjs/core/tasks/PrepareTransactionTask.js.map +1 -0
  108. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.d.ts +13 -0
  109. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +63 -0
  110. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
  111. package/dist/cjs/core/tasks/helpers/checkBalance.d.ts +30 -0
  112. package/dist/cjs/core/tasks/helpers/checkBalance.js +108 -0
  113. package/dist/cjs/core/tasks/helpers/checkBalance.js.map +1 -0
  114. package/dist/cjs/core/tasks/helpers/getTransactionRequestData.d.ts +7 -0
  115. package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js +25 -0
  116. package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
  117. package/dist/cjs/core/tasks/helpers/stepComparison.d.ts +21 -0
  118. package/dist/cjs/core/tasks/helpers/stepComparison.js +32 -0
  119. package/dist/cjs/core/tasks/helpers/stepComparison.js.map +1 -0
  120. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +9 -0
  121. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js +48 -0
  122. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
  123. package/dist/cjs/core/utils.d.ts +17 -86
  124. package/dist/cjs/core/utils.js +37 -38
  125. package/dist/cjs/core/utils.js.map +1 -1
  126. package/dist/cjs/errors/SDKError.d.ts +16 -11
  127. package/dist/cjs/errors/SDKError.js +22 -21
  128. package/dist/cjs/errors/SDKError.js.map +1 -1
  129. package/dist/cjs/errors/baseError.d.ts +10 -5
  130. package/dist/cjs/errors/baseError.js +17 -18
  131. package/dist/cjs/errors/baseError.js.map +1 -1
  132. package/dist/cjs/errors/constants.d.ts +52 -47
  133. package/dist/cjs/errors/constants.js +60 -55
  134. package/dist/cjs/errors/constants.js.map +1 -1
  135. package/dist/cjs/errors/errors.d.ts +31 -16
  136. package/dist/cjs/errors/errors.js +57 -43
  137. package/dist/cjs/errors/errors.js.map +1 -1
  138. package/dist/cjs/errors/httpError.d.ts +21 -17
  139. package/dist/cjs/errors/httpError.js +63 -66
  140. package/dist/cjs/errors/httpError.js.map +1 -1
  141. package/dist/cjs/errors/utils/baseErrorRootCause.d.ts +8 -3
  142. package/dist/cjs/errors/utils/baseErrorRootCause.js +12 -15
  143. package/dist/cjs/errors/utils/baseErrorRootCause.js.map +1 -1
  144. package/dist/cjs/errors/utils/rootCause.d.ts +5 -1
  145. package/dist/cjs/errors/utils/rootCause.js +7 -8
  146. package/dist/cjs/errors/utils/rootCause.js.map +1 -1
  147. package/dist/cjs/index.d.ts +56 -46
  148. package/dist/cjs/index.js +130 -119
  149. package/dist/cjs/types/actions.d.ts +32 -7
  150. package/dist/cjs/types/actions.js +0 -3
  151. package/dist/cjs/types/core.d.ts +181 -164
  152. package/dist/cjs/types/core.js +0 -3
  153. package/dist/cjs/types/execution.d.ts +28 -0
  154. package/dist/cjs/types/execution.js +0 -0
  155. package/dist/cjs/types/request.d.ts +6 -2
  156. package/dist/cjs/types/request.js +0 -3
  157. package/dist/cjs/utils/checkPackageUpdates.d.ts +5 -1
  158. package/dist/cjs/utils/checkPackageUpdates.js +11 -16
  159. package/dist/cjs/utils/checkPackageUpdates.js.map +1 -1
  160. package/dist/cjs/utils/convertQuoteToRoute.d.ts +20 -5
  161. package/dist/cjs/utils/convertQuoteToRoute.js +72 -85
  162. package/dist/cjs/utils/convertQuoteToRoute.js.map +1 -1
  163. package/dist/cjs/utils/decode.d.ts +5 -1
  164. package/dist/cjs/utils/decode.js +5 -10
  165. package/dist/cjs/utils/decode.js.map +1 -1
  166. package/dist/cjs/utils/fetchTxErrorDetails.d.ts +5 -1
  167. package/dist/cjs/utils/fetchTxErrorDetails.js +9 -9
  168. package/dist/cjs/utils/fetchTxErrorDetails.js.map +1 -1
  169. package/dist/cjs/utils/formatUnits.d.ts +8 -1
  170. package/dist/cjs/utils/formatUnits.js +15 -15
  171. package/dist/cjs/utils/formatUnits.js.map +1 -1
  172. package/dist/cjs/utils/getTransactionMessage.d.ts +8 -3
  173. package/dist/cjs/utils/getTransactionMessage.js +8 -10
  174. package/dist/cjs/utils/getTransactionMessage.js.map +1 -1
  175. package/dist/cjs/utils/isHex.d.ts +9 -3
  176. package/dist/cjs/utils/isHex.js +8 -10
  177. package/dist/cjs/utils/isHex.js.map +1 -1
  178. package/dist/cjs/utils/isRoutesRequest.d.ts +7 -2
  179. package/dist/cjs/utils/isRoutesRequest.js +7 -14
  180. package/dist/cjs/utils/isRoutesRequest.js.map +1 -1
  181. package/dist/cjs/utils/isStep.d.ts +7 -2
  182. package/dist/cjs/utils/isStep.js +16 -25
  183. package/dist/cjs/utils/isStep.js.map +1 -1
  184. package/dist/cjs/utils/isToken.d.ts +7 -2
  185. package/dist/cjs/utils/isToken.js +6 -7
  186. package/dist/cjs/utils/isToken.js.map +1 -1
  187. package/dist/cjs/utils/parseUnits.d.ts +8 -1
  188. package/dist/cjs/utils/parseUnits.js +32 -41
  189. package/dist/cjs/utils/parseUnits.js.map +1 -1
  190. package/dist/cjs/utils/request.d.ts +10 -5
  191. package/dist/cjs/utils/request.js +53 -69
  192. package/dist/cjs/utils/request.js.map +1 -1
  193. package/dist/cjs/utils/sleep.d.ts +5 -1
  194. package/dist/cjs/utils/sleep.js +8 -6
  195. package/dist/cjs/utils/sleep.js.map +1 -1
  196. package/dist/cjs/utils/toQueryString.d.ts +5 -0
  197. package/dist/cjs/utils/toQueryString.js +17 -0
  198. package/dist/cjs/utils/toQueryString.js.map +1 -0
  199. package/dist/cjs/utils/waitForResult.d.ts +14 -1
  200. package/dist/cjs/utils/waitForResult.js +33 -26
  201. package/dist/cjs/utils/waitForResult.js.map +1 -1
  202. package/dist/cjs/utils/withDedupe.d.ts +21 -4
  203. package/dist/cjs/utils/withDedupe.js +31 -27
  204. package/dist/cjs/utils/withDedupe.js.map +1 -1
  205. package/dist/cjs/utils/withTimeout.d.ts +26 -0
  206. package/dist/cjs/utils/withTimeout.js +35 -0
  207. package/dist/cjs/utils/withTimeout.js.map +1 -0
  208. package/dist/cjs/version.d.ts +6 -2
  209. package/dist/cjs/version.js +8 -5
  210. package/dist/cjs/version.js.map +1 -1
  211. package/dist/esm/actions/getChains.d.ts +16 -11
  212. package/dist/esm/actions/getChains.d.ts.map +1 -0
  213. package/dist/esm/actions/getChains.js +22 -24
  214. package/dist/esm/actions/getChains.js.map +1 -1
  215. package/dist/esm/actions/getConnections.d.ts +14 -9
  216. package/dist/esm/actions/getConnections.d.ts.map +1 -0
  217. package/dist/esm/actions/getConnections.js +30 -39
  218. package/dist/esm/actions/getConnections.js.map +1 -1
  219. package/dist/esm/actions/getContractCallsQuote.d.ts +15 -10
  220. package/dist/esm/actions/getContractCallsQuote.d.ts.map +1 -0
  221. package/dist/esm/actions/getContractCallsQuote.js +41 -51
  222. package/dist/esm/actions/getContractCallsQuote.js.map +1 -1
  223. package/dist/esm/actions/getGasRecommendation.d.ts +15 -10
  224. package/dist/esm/actions/getGasRecommendation.d.ts.map +1 -0
  225. package/dist/esm/actions/getGasRecommendation.js +20 -24
  226. package/dist/esm/actions/getGasRecommendation.js.map +1 -1
  227. package/dist/esm/actions/getNameServiceAddress.d.ts +14 -9
  228. package/dist/esm/actions/getNameServiceAddress.d.ts.map +1 -0
  229. package/dist/esm/actions/getNameServiceAddress.js +25 -31
  230. package/dist/esm/actions/getNameServiceAddress.js.map +1 -1
  231. package/dist/esm/actions/getQuote.d.ts +17 -12
  232. package/dist/esm/actions/getQuote.d.ts.map +1 -0
  233. package/dist/esm/actions/getQuote.js +33 -44
  234. package/dist/esm/actions/getQuote.js.map +1 -1
  235. package/dist/esm/actions/getRelayedTransactionStatus.d.ts +15 -10
  236. package/dist/esm/actions/getRelayedTransactionStatus.d.ts.map +1 -0
  237. package/dist/esm/actions/getRelayedTransactionStatus.js +26 -32
  238. package/dist/esm/actions/getRelayedTransactionStatus.js.map +1 -1
  239. package/dist/esm/actions/getRelayerQuote.d.ts +16 -11
  240. package/dist/esm/actions/getRelayerQuote.d.ts.map +1 -0
  241. package/dist/esm/actions/getRelayerQuote.js +40 -50
  242. package/dist/esm/actions/getRelayerQuote.js.map +1 -1
  243. package/dist/esm/actions/getRoutes.d.ts +16 -10
  244. package/dist/esm/actions/getRoutes.d.ts.map +1 -0
  245. package/dist/esm/actions/getRoutes.js +28 -29
  246. package/dist/esm/actions/getRoutes.js.map +1 -1
  247. package/dist/esm/actions/getStatus.d.ts +16 -11
  248. package/dist/esm/actions/getStatus.d.ts.map +1 -0
  249. package/dist/esm/actions/getStatus.js +18 -19
  250. package/dist/esm/actions/getStatus.js.map +1 -1
  251. package/dist/esm/actions/getStepTransaction.d.ts +16 -10
  252. package/dist/esm/actions/getStepTransaction.d.ts.map +1 -0
  253. package/dist/esm/actions/getStepTransaction.js +32 -31
  254. package/dist/esm/actions/getStepTransaction.js.map +1 -1
  255. package/dist/esm/actions/getToken.d.ts +16 -11
  256. package/dist/esm/actions/getToken.d.ts.map +1 -0
  257. package/dist/esm/actions/getToken.js +22 -24
  258. package/dist/esm/actions/getToken.js.map +1 -1
  259. package/dist/esm/actions/getTokenBalance.d.ts +16 -11
  260. package/dist/esm/actions/getTokenBalance.d.ts.map +1 -0
  261. package/dist/esm/actions/getTokenBalance.js +16 -12
  262. package/dist/esm/actions/getTokenBalance.js.map +1 -1
  263. package/dist/esm/actions/getTokenBalances.d.ts +16 -11
  264. package/dist/esm/actions/getTokenBalances.d.ts.map +1 -0
  265. package/dist/esm/actions/getTokenBalances.js +12 -12
  266. package/dist/esm/actions/getTokenBalances.js.map +1 -1
  267. package/dist/esm/actions/getTokenBalancesByChain.d.ts +18 -13
  268. package/dist/esm/actions/getTokenBalancesByChain.d.ts.map +1 -0
  269. package/dist/esm/actions/getTokenBalancesByChain.js +22 -37
  270. package/dist/esm/actions/getTokenBalancesByChain.js.map +1 -1
  271. package/dist/esm/actions/getTokens.d.ts +17 -12
  272. package/dist/esm/actions/getTokens.d.ts.map +1 -0
  273. package/dist/esm/actions/getTokens.js +14 -16
  274. package/dist/esm/actions/getTokens.js.map +1 -1
  275. package/dist/esm/actions/getTools.d.ts +14 -9
  276. package/dist/esm/actions/getTools.d.ts.map +1 -0
  277. package/dist/esm/actions/getTools.js +17 -18
  278. package/dist/esm/actions/getTools.js.map +1 -1
  279. package/dist/esm/actions/getTransactionHistory.d.ts +25 -15
  280. package/dist/esm/actions/getTransactionHistory.d.ts.map +1 -0
  281. package/dist/esm/actions/getTransactionHistory.js +27 -31
  282. package/dist/esm/actions/getTransactionHistory.js.map +1 -1
  283. package/dist/esm/actions/getWalletBalances.d.ts +15 -10
  284. package/dist/esm/actions/getWalletBalances.d.ts.map +1 -0
  285. package/dist/esm/actions/getWalletBalances.js +16 -17
  286. package/dist/esm/actions/getWalletBalances.js.map +1 -1
  287. package/dist/esm/actions/index.d.ts +174 -166
  288. package/dist/esm/actions/index.d.ts.map +1 -0
  289. package/dist/esm/actions/index.js +49 -45
  290. package/dist/esm/actions/index.js.map +1 -1
  291. package/dist/esm/actions/patchContractCalls.d.ts +14 -9
  292. package/dist/esm/actions/patchContractCalls.d.ts.map +1 -0
  293. package/dist/esm/actions/patchContractCalls.js +12 -10
  294. package/dist/esm/actions/patchContractCalls.js.map +1 -1
  295. package/dist/esm/actions/relayTransaction.d.ts +15 -10
  296. package/dist/esm/actions/relayTransaction.d.ts.map +1 -0
  297. package/dist/esm/actions/relayTransaction.js +30 -41
  298. package/dist/esm/actions/relayTransaction.js.map +1 -1
  299. package/dist/esm/client/createClient.d.ts +7 -2
  300. package/dist/esm/client/createClient.d.ts.map +1 -0
  301. package/dist/esm/client/createClient.js +67 -74
  302. package/dist/esm/client/createClient.js.map +1 -1
  303. package/dist/esm/client/getClientStorage.d.ts +14 -8
  304. package/dist/esm/client/getClientStorage.d.ts.map +1 -0
  305. package/dist/esm/client/getClientStorage.js +45 -48
  306. package/dist/esm/client/getClientStorage.js.map +1 -1
  307. package/dist/esm/core/BaseStepExecutionTask.d.ts +10 -0
  308. package/dist/esm/core/BaseStepExecutionTask.d.ts.map +1 -0
  309. package/dist/esm/core/BaseStepExecutionTask.js +10 -0
  310. package/dist/esm/core/BaseStepExecutionTask.js.map +1 -0
  311. package/dist/esm/core/BaseStepExecutor.d.ts +23 -11
  312. package/dist/esm/core/BaseStepExecutor.d.ts.map +1 -0
  313. package/dist/esm/core/BaseStepExecutor.js +67 -24
  314. package/dist/esm/core/BaseStepExecutor.js.map +1 -1
  315. package/dist/esm/core/StatusManager.d.ts +80 -64
  316. package/dist/esm/core/StatusManager.d.ts.map +1 -0
  317. package/dist/esm/core/StatusManager.js +157 -181
  318. package/dist/esm/core/StatusManager.js.map +1 -1
  319. package/dist/esm/core/TaskPipeline.d.ts +12 -0
  320. package/dist/esm/core/TaskPipeline.d.ts.map +1 -0
  321. package/dist/esm/core/TaskPipeline.js +20 -0
  322. package/dist/esm/core/TaskPipeline.js.map +1 -0
  323. package/dist/esm/core/actionMessages.d.ts +9 -4
  324. package/dist/esm/core/actionMessages.d.ts.map +1 -0
  325. package/dist/esm/core/actionMessages.js +72 -56
  326. package/dist/esm/core/actionMessages.js.map +1 -1
  327. package/dist/esm/core/execution.d.ts +42 -37
  328. package/dist/esm/core/execution.d.ts.map +1 -0
  329. package/dist/esm/core/execution.js +126 -162
  330. package/dist/esm/core/execution.js.map +1 -1
  331. package/dist/esm/core/executionState.d.ts +17 -13
  332. package/dist/esm/core/executionState.d.ts.map +1 -0
  333. package/dist/esm/core/executionState.js +26 -24
  334. package/dist/esm/core/executionState.js.map +1 -1
  335. package/dist/esm/core/prepareRestart.d.ts +7 -2
  336. package/dist/esm/core/prepareRestart.d.ts.map +1 -0
  337. package/dist/esm/core/prepareRestart.js +18 -20
  338. package/dist/esm/core/prepareRestart.js.map +1 -1
  339. package/dist/esm/core/storage.d.ts +21 -0
  340. package/dist/esm/core/storage.d.ts.map +1 -0
  341. package/dist/esm/core/storage.js +32 -0
  342. package/dist/esm/core/storage.js.map +1 -0
  343. package/dist/esm/core/tasks/CheckBalanceTask.d.ts +19 -0
  344. package/dist/esm/core/tasks/CheckBalanceTask.d.ts.map +1 -0
  345. package/dist/esm/core/tasks/CheckBalanceTask.js +34 -0
  346. package/dist/esm/core/tasks/CheckBalanceTask.js.map +1 -0
  347. package/dist/esm/core/tasks/PrepareTransactionTask.d.ts +10 -0
  348. package/dist/esm/core/tasks/PrepareTransactionTask.d.ts.map +1 -0
  349. package/dist/esm/core/tasks/PrepareTransactionTask.js +29 -0
  350. package/dist/esm/core/tasks/PrepareTransactionTask.js.map +1 -0
  351. package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts +13 -0
  352. package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -0
  353. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +61 -0
  354. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
  355. package/dist/esm/core/tasks/helpers/checkBalance.d.ts +30 -0
  356. package/dist/esm/core/tasks/helpers/checkBalance.d.ts.map +1 -0
  357. package/dist/esm/core/tasks/helpers/checkBalance.js +107 -0
  358. package/dist/esm/core/tasks/helpers/checkBalance.js.map +1 -0
  359. package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts +7 -0
  360. package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts.map +1 -0
  361. package/dist/esm/core/tasks/helpers/getTransactionRequestData.js +24 -0
  362. package/dist/esm/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
  363. package/dist/esm/core/tasks/helpers/stepComparison.d.ts +21 -0
  364. package/dist/esm/core/tasks/helpers/stepComparison.d.ts.map +1 -0
  365. package/dist/esm/core/tasks/helpers/stepComparison.js +31 -0
  366. package/dist/esm/core/tasks/helpers/stepComparison.js.map +1 -0
  367. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +9 -0
  368. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -0
  369. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js +47 -0
  370. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
  371. package/dist/esm/core/utils.d.ts +16 -93
  372. package/dist/esm/core/utils.d.ts.map +1 -0
  373. package/dist/esm/core/utils.js +36 -45
  374. package/dist/esm/core/utils.js.map +1 -1
  375. package/dist/esm/errors/SDKError.d.ts +16 -11
  376. package/dist/esm/errors/SDKError.d.ts.map +1 -0
  377. package/dist/esm/errors/SDKError.js +22 -20
  378. package/dist/esm/errors/SDKError.js.map +1 -1
  379. package/dist/esm/errors/baseError.d.ts +10 -5
  380. package/dist/esm/errors/baseError.d.ts.map +1 -0
  381. package/dist/esm/errors/baseError.js +17 -17
  382. package/dist/esm/errors/baseError.js.map +1 -1
  383. package/dist/esm/errors/constants.d.ts +52 -47
  384. package/dist/esm/errors/constants.d.ts.map +1 -0
  385. package/dist/esm/errors/constants.js +57 -52
  386. package/dist/esm/errors/constants.js.map +1 -1
  387. package/dist/esm/errors/errors.d.ts +31 -16
  388. package/dist/esm/errors/errors.d.ts.map +1 -0
  389. package/dist/esm/errors/errors.js +53 -37
  390. package/dist/esm/errors/errors.js.map +1 -1
  391. package/dist/esm/errors/httpError.d.ts +21 -17
  392. package/dist/esm/errors/httpError.d.ts.map +1 -0
  393. package/dist/esm/errors/httpError.js +63 -63
  394. package/dist/esm/errors/httpError.js.map +1 -1
  395. package/dist/esm/errors/utils/baseErrorRootCause.d.ts +8 -3
  396. package/dist/esm/errors/utils/baseErrorRootCause.d.ts.map +1 -0
  397. package/dist/esm/errors/utils/baseErrorRootCause.js +13 -13
  398. package/dist/esm/errors/utils/baseErrorRootCause.js.map +1 -1
  399. package/dist/esm/errors/utils/rootCause.d.ts +5 -1
  400. package/dist/esm/errors/utils/rootCause.d.ts.map +1 -0
  401. package/dist/esm/errors/utils/rootCause.js +8 -6
  402. package/dist/esm/errors/utils/rootCause.js.map +1 -1
  403. package/dist/esm/index.d.ts +56 -46
  404. package/dist/esm/index.js +53 -47
  405. package/dist/esm/package.json +1 -1
  406. package/dist/esm/types/actions.d.ts +32 -7
  407. package/dist/esm/types/actions.d.ts.map +1 -0
  408. package/dist/esm/types/actions.js +0 -1
  409. package/dist/esm/types/core.d.ts +181 -167
  410. package/dist/esm/types/core.d.ts.map +1 -0
  411. package/dist/esm/types/core.js +0 -1
  412. package/dist/esm/types/execution.d.ts +28 -0
  413. package/dist/esm/types/execution.d.ts.map +1 -0
  414. package/dist/esm/types/execution.js +1 -0
  415. package/dist/esm/types/request.d.ts +6 -2
  416. package/dist/esm/types/request.d.ts.map +1 -0
  417. package/dist/esm/types/request.js +0 -1
  418. package/dist/esm/utils/checkPackageUpdates.d.ts +5 -1
  419. package/dist/esm/utils/checkPackageUpdates.d.ts.map +1 -0
  420. package/dist/esm/utils/checkPackageUpdates.js +12 -15
  421. package/dist/esm/utils/checkPackageUpdates.js.map +1 -1
  422. package/dist/esm/utils/convertQuoteToRoute.d.ts +19 -15
  423. package/dist/esm/utils/convertQuoteToRoute.d.ts.map +1 -0
  424. package/dist/esm/utils/convertQuoteToRoute.js +72 -92
  425. package/dist/esm/utils/convertQuoteToRoute.js.map +1 -1
  426. package/dist/esm/utils/decode.d.ts +5 -1
  427. package/dist/esm/utils/decode.d.ts.map +1 -0
  428. package/dist/esm/utils/decode.js +6 -8
  429. package/dist/esm/utils/decode.js.map +1 -1
  430. package/dist/esm/utils/fetchTxErrorDetails.d.ts +5 -1
  431. package/dist/esm/utils/fetchTxErrorDetails.d.ts.map +1 -0
  432. package/dist/esm/utils/fetchTxErrorDetails.js +10 -7
  433. package/dist/esm/utils/fetchTxErrorDetails.js.map +1 -1
  434. package/dist/esm/utils/formatUnits.d.ts +7 -3
  435. package/dist/esm/utils/formatUnits.d.ts.map +1 -0
  436. package/dist/esm/utils/formatUnits.js +14 -15
  437. package/dist/esm/utils/formatUnits.js.map +1 -1
  438. package/dist/esm/utils/getTransactionMessage.d.ts +8 -3
  439. package/dist/esm/utils/getTransactionMessage.d.ts.map +1 -0
  440. package/dist/esm/utils/getTransactionMessage.js +9 -8
  441. package/dist/esm/utils/getTransactionMessage.js.map +1 -1
  442. package/dist/esm/utils/isHex.d.ts +9 -3
  443. package/dist/esm/utils/isHex.d.ts.map +1 -0
  444. package/dist/esm/utils/isHex.js +8 -8
  445. package/dist/esm/utils/isHex.js.map +1 -1
  446. package/dist/esm/utils/isRoutesRequest.d.ts +7 -2
  447. package/dist/esm/utils/isRoutesRequest.d.ts.map +1 -0
  448. package/dist/esm/utils/isRoutesRequest.js +8 -12
  449. package/dist/esm/utils/isRoutesRequest.js.map +1 -1
  450. package/dist/esm/utils/isStep.d.ts +7 -2
  451. package/dist/esm/utils/isStep.d.ts.map +1 -0
  452. package/dist/esm/utils/isStep.js +17 -23
  453. package/dist/esm/utils/isStep.js.map +1 -1
  454. package/dist/esm/utils/isToken.d.ts +7 -2
  455. package/dist/esm/utils/isToken.d.ts.map +1 -0
  456. package/dist/esm/utils/isToken.js +7 -5
  457. package/dist/esm/utils/isToken.js.map +1 -1
  458. package/dist/esm/utils/parseUnits.d.ts +7 -3
  459. package/dist/esm/utils/parseUnits.d.ts.map +1 -0
  460. package/dist/esm/utils/parseUnits.js +31 -43
  461. package/dist/esm/utils/parseUnits.js.map +1 -1
  462. package/dist/esm/utils/request.d.ts +10 -5
  463. package/dist/esm/utils/request.d.ts.map +1 -0
  464. package/dist/esm/utils/request.js +52 -67
  465. package/dist/esm/utils/request.js.map +1 -1
  466. package/dist/esm/utils/sleep.d.ts +5 -1
  467. package/dist/esm/utils/sleep.d.ts.map +1 -0
  468. package/dist/esm/utils/sleep.js +8 -4
  469. package/dist/esm/utils/sleep.js.map +1 -1
  470. package/dist/esm/utils/toQueryString.d.ts +5 -0
  471. package/dist/esm/utils/toQueryString.d.ts.map +1 -0
  472. package/dist/esm/utils/toQueryString.js +16 -0
  473. package/dist/esm/utils/toQueryString.js.map +1 -0
  474. package/dist/esm/utils/waitForResult.d.ts +13 -9
  475. package/dist/esm/utils/waitForResult.d.ts.map +1 -0
  476. package/dist/esm/utils/waitForResult.js +32 -31
  477. package/dist/esm/utils/waitForResult.js.map +1 -1
  478. package/dist/esm/utils/withDedupe.d.ts +20 -4
  479. package/dist/esm/utils/withDedupe.d.ts.map +1 -0
  480. package/dist/esm/utils/withDedupe.js +26 -28
  481. package/dist/esm/utils/withDedupe.js.map +1 -1
  482. package/dist/esm/utils/withTimeout.d.ts +26 -0
  483. package/dist/esm/utils/withTimeout.d.ts.map +1 -0
  484. package/dist/esm/utils/withTimeout.js +34 -0
  485. package/dist/esm/utils/withTimeout.js.map +1 -0
  486. package/dist/esm/version.d.ts +6 -2
  487. package/dist/esm/version.d.ts.map +1 -0
  488. package/dist/esm/version.js +6 -2
  489. package/dist/esm/version.js.map +1 -1
  490. package/package.json +6 -5
  491. package/src/actions/getChains.ts +2 -1
  492. package/src/actions/getQuote.ts +7 -3
  493. package/src/actions/getRelayedTransactionStatus.ts +1 -1
  494. package/src/actions/getRelayerQuote.ts +4 -1
  495. package/src/actions/getRoutes.ts +2 -1
  496. package/src/actions/getStepTransaction.ts +16 -7
  497. package/src/actions/getTokens.ts +6 -3
  498. package/src/actions/getTools.ts +2 -1
  499. package/src/actions/index.ts +8 -5
  500. package/src/client/createClient.ts +9 -7
  501. package/src/client/getClientStorage.ts +9 -1
  502. package/src/core/BaseStepExecutionTask.ts +9 -0
  503. package/src/core/BaseStepExecutor.ts +90 -2
  504. package/src/core/StatusManager.ts +62 -61
  505. package/src/core/TaskPipeline.ts +28 -0
  506. package/src/core/actionMessages.ts +20 -3
  507. package/src/core/execution.ts +17 -3
  508. package/src/core/prepareRestart.ts +3 -4
  509. package/src/core/storage.ts +42 -0
  510. package/src/core/tasks/CheckBalanceTask.ts +46 -0
  511. package/src/core/tasks/PrepareTransactionTask.ts +62 -0
  512. package/src/core/tasks/WaitForTransactionStatusTask.ts +114 -0
  513. package/src/core/tasks/helpers/checkBalance.ts +218 -0
  514. package/src/core/tasks/helpers/getTransactionRequestData.ts +47 -0
  515. package/src/core/{stepComparison.ts → tasks/helpers/stepComparison.ts} +5 -5
  516. package/src/core/{waitForTransactionStatus.ts → tasks/helpers/waitForTransactionStatus.ts} +10 -7
  517. package/src/core/utils.ts +1 -1
  518. package/src/errors/constants.ts +1 -0
  519. package/src/errors/errors.ts +24 -0
  520. package/src/errors/httpError.ts +4 -6
  521. package/src/errors/utils/baseErrorRootCause.ts +2 -2
  522. package/src/errors/utils/rootCause.ts +1 -1
  523. package/src/index.ts +35 -4
  524. package/src/types/actions.ts +29 -0
  525. package/src/types/core.ts +23 -17
  526. package/src/types/execution.ts +32 -0
  527. package/src/utils/checkPackageUpdates.ts +1 -1
  528. package/src/utils/convertQuoteToRoute.ts +1 -1
  529. package/src/utils/decode.ts +1 -1
  530. package/src/utils/fetchTxErrorDetails.ts +7 -2
  531. package/src/utils/formatUnits.ts +1 -1
  532. package/src/utils/isStep.ts +4 -1
  533. package/src/utils/parseUnits.ts +1 -1
  534. package/src/utils/toQueryString.ts +35 -0
  535. package/src/utils/waitForResult.ts +9 -4
  536. package/src/utils/withDedupe.ts +2 -2
  537. package/src/utils/withTimeout.ts +50 -0
  538. package/src/version.ts +1 -1
  539. package/dist/cjs/core/checkBalance.d.ts +0 -3
  540. package/dist/cjs/core/checkBalance.js +0 -37
  541. package/dist/cjs/core/checkBalance.js.map +0 -1
  542. package/dist/cjs/core/stepComparison.d.ts +0 -4
  543. package/dist/cjs/core/stepComparison.js +0 -25
  544. package/dist/cjs/core/stepComparison.js.map +0 -1
  545. package/dist/cjs/core/waitForDestinationChainTransaction.d.ts +0 -4
  546. package/dist/cjs/core/waitForDestinationChainTransaction.js +0 -71
  547. package/dist/cjs/core/waitForDestinationChainTransaction.js.map +0 -1
  548. package/dist/cjs/core/waitForTransactionStatus.d.ts +0 -4
  549. package/dist/cjs/core/waitForTransactionStatus.js +0 -54
  550. package/dist/cjs/core/waitForTransactionStatus.js.map +0 -1
  551. package/dist/cjs/index.js.map +0 -1
  552. package/dist/cjs/types/actions.js.map +0 -1
  553. package/dist/cjs/types/core.js.map +0 -1
  554. package/dist/cjs/types/request.js.map +0 -1
  555. package/dist/esm/core/checkBalance.d.ts +0 -3
  556. package/dist/esm/core/checkBalance.js +0 -34
  557. package/dist/esm/core/checkBalance.js.map +0 -1
  558. package/dist/esm/core/stepComparison.d.ts +0 -16
  559. package/dist/esm/core/stepComparison.js +0 -35
  560. package/dist/esm/core/stepComparison.js.map +0 -1
  561. package/dist/esm/core/waitForDestinationChainTransaction.d.ts +0 -4
  562. package/dist/esm/core/waitForDestinationChainTransaction.js +0 -74
  563. package/dist/esm/core/waitForDestinationChainTransaction.js.map +0 -1
  564. package/dist/esm/core/waitForTransactionStatus.d.ts +0 -4
  565. package/dist/esm/core/waitForTransactionStatus.js +0 -51
  566. package/dist/esm/core/waitForTransactionStatus.js.map +0 -1
  567. package/dist/esm/index.js.map +0 -1
  568. package/dist/esm/types/actions.js.map +0 -1
  569. package/dist/esm/types/core.js.map +0 -1
  570. package/dist/esm/types/request.js.map +0 -1
  571. package/dist/types/actions/getChains.d.ts +0 -13
  572. package/dist/types/actions/getChains.d.ts.map +0 -1
  573. package/dist/types/actions/getConnections.d.ts +0 -11
  574. package/dist/types/actions/getConnections.d.ts.map +0 -1
  575. package/dist/types/actions/getContractCallsQuote.d.ts +0 -12
  576. package/dist/types/actions/getContractCallsQuote.d.ts.map +0 -1
  577. package/dist/types/actions/getGasRecommendation.d.ts +0 -12
  578. package/dist/types/actions/getGasRecommendation.d.ts.map +0 -1
  579. package/dist/types/actions/getNameServiceAddress.d.ts +0 -11
  580. package/dist/types/actions/getNameServiceAddress.d.ts.map +0 -1
  581. package/dist/types/actions/getQuote.d.ts +0 -14
  582. package/dist/types/actions/getQuote.d.ts.map +0 -1
  583. package/dist/types/actions/getRelayedTransactionStatus.d.ts +0 -12
  584. package/dist/types/actions/getRelayedTransactionStatus.d.ts.map +0 -1
  585. package/dist/types/actions/getRelayerQuote.d.ts +0 -13
  586. package/dist/types/actions/getRelayerQuote.d.ts.map +0 -1
  587. package/dist/types/actions/getRoutes.d.ts +0 -12
  588. package/dist/types/actions/getRoutes.d.ts.map +0 -1
  589. package/dist/types/actions/getStatus.d.ts +0 -13
  590. package/dist/types/actions/getStatus.d.ts.map +0 -1
  591. package/dist/types/actions/getStepTransaction.d.ts +0 -12
  592. package/dist/types/actions/getStepTransaction.d.ts.map +0 -1
  593. package/dist/types/actions/getToken.d.ts +0 -13
  594. package/dist/types/actions/getToken.d.ts.map +0 -1
  595. package/dist/types/actions/getTokenBalance.d.ts +0 -13
  596. package/dist/types/actions/getTokenBalance.d.ts.map +0 -1
  597. package/dist/types/actions/getTokenBalances.d.ts +0 -13
  598. package/dist/types/actions/getTokenBalances.d.ts.map +0 -1
  599. package/dist/types/actions/getTokenBalancesByChain.d.ts +0 -17
  600. package/dist/types/actions/getTokenBalancesByChain.d.ts.map +0 -1
  601. package/dist/types/actions/getTokens.d.ts +0 -16
  602. package/dist/types/actions/getTokens.d.ts.map +0 -1
  603. package/dist/types/actions/getTools.d.ts +0 -11
  604. package/dist/types/actions/getTools.d.ts.map +0 -1
  605. package/dist/types/actions/getTransactionHistory.d.ts +0 -17
  606. package/dist/types/actions/getTransactionHistory.d.ts.map +0 -1
  607. package/dist/types/actions/getWalletBalances.d.ts +0 -12
  608. package/dist/types/actions/getWalletBalances.d.ts.map +0 -1
  609. package/dist/types/actions/index.d.ts +0 -168
  610. package/dist/types/actions/index.d.ts.map +0 -1
  611. package/dist/types/actions/patchContractCalls.d.ts +0 -11
  612. package/dist/types/actions/patchContractCalls.d.ts.map +0 -1
  613. package/dist/types/actions/relayTransaction.d.ts +0 -12
  614. package/dist/types/actions/relayTransaction.d.ts.map +0 -1
  615. package/dist/types/client/createClient.d.ts +0 -3
  616. package/dist/types/client/createClient.d.ts.map +0 -1
  617. package/dist/types/client/getClientStorage.d.ts +0 -9
  618. package/dist/types/client/getClientStorage.d.ts.map +0 -1
  619. package/dist/types/core/BaseStepExecutor.d.ts +0 -13
  620. package/dist/types/core/BaseStepExecutor.d.ts.map +0 -1
  621. package/dist/types/core/StatusManager.d.ts +0 -68
  622. package/dist/types/core/StatusManager.d.ts.map +0 -1
  623. package/dist/types/core/actionMessages.d.ts +0 -5
  624. package/dist/types/core/actionMessages.d.ts.map +0 -1
  625. package/dist/types/core/checkBalance.d.ts +0 -4
  626. package/dist/types/core/checkBalance.d.ts.map +0 -1
  627. package/dist/types/core/execution.d.ts +0 -44
  628. package/dist/types/core/execution.d.ts.map +0 -1
  629. package/dist/types/core/executionState.d.ts +0 -18
  630. package/dist/types/core/executionState.d.ts.map +0 -1
  631. package/dist/types/core/prepareRestart.d.ts +0 -3
  632. package/dist/types/core/prepareRestart.d.ts.map +0 -1
  633. package/dist/types/core/stepComparison.d.ts +0 -17
  634. package/dist/types/core/stepComparison.d.ts.map +0 -1
  635. package/dist/types/core/utils.d.ts +0 -95
  636. package/dist/types/core/utils.d.ts.map +0 -1
  637. package/dist/types/core/waitForDestinationChainTransaction.d.ts +0 -5
  638. package/dist/types/core/waitForDestinationChainTransaction.d.ts.map +0 -1
  639. package/dist/types/core/waitForTransactionStatus.d.ts +0 -5
  640. package/dist/types/core/waitForTransactionStatus.d.ts.map +0 -1
  641. package/dist/types/errors/SDKError.d.ts +0 -13
  642. package/dist/types/errors/SDKError.d.ts.map +0 -1
  643. package/dist/types/errors/baseError.d.ts +0 -7
  644. package/dist/types/errors/baseError.d.ts.map +0 -1
  645. package/dist/types/errors/constants.d.ts +0 -51
  646. package/dist/types/errors/constants.d.ts.map +0 -1
  647. package/dist/types/errors/errors.d.ts +0 -24
  648. package/dist/types/errors/errors.d.ts.map +0 -1
  649. package/dist/types/errors/httpError.d.ts +0 -21
  650. package/dist/types/errors/httpError.d.ts.map +0 -1
  651. package/dist/types/errors/utils/baseErrorRootCause.d.ts +0 -4
  652. package/dist/types/errors/utils/baseErrorRootCause.d.ts.map +0 -1
  653. package/dist/types/errors/utils/rootCause.d.ts +0 -2
  654. package/dist/types/errors/utils/rootCause.d.ts.map +0 -1
  655. package/dist/types/index.d.ts +0 -47
  656. package/dist/types/index.d.ts.map +0 -1
  657. package/dist/types/types/actions.d.ts +0 -10
  658. package/dist/types/types/actions.d.ts.map +0 -1
  659. package/dist/types/types/core.d.ts +0 -171
  660. package/dist/types/types/core.d.ts.map +0 -1
  661. package/dist/types/types/request.d.ts +0 -4
  662. package/dist/types/types/request.d.ts.map +0 -1
  663. package/dist/types/utils/checkPackageUpdates.d.ts +0 -2
  664. package/dist/types/utils/checkPackageUpdates.d.ts.map +0 -1
  665. package/dist/types/utils/convertQuoteToRoute.d.ts +0 -19
  666. package/dist/types/utils/convertQuoteToRoute.d.ts.map +0 -1
  667. package/dist/types/utils/decode.d.ts +0 -2
  668. package/dist/types/utils/decode.d.ts.map +0 -1
  669. package/dist/types/utils/fetchTxErrorDetails.d.ts +0 -2
  670. package/dist/types/utils/fetchTxErrorDetails.d.ts.map +0 -1
  671. package/dist/types/utils/formatUnits.d.ts +0 -5
  672. package/dist/types/utils/formatUnits.d.ts.map +0 -1
  673. package/dist/types/utils/getTransactionMessage.d.ts +0 -4
  674. package/dist/types/utils/getTransactionMessage.d.ts.map +0 -1
  675. package/dist/types/utils/isHex.d.ts +0 -5
  676. package/dist/types/utils/isHex.d.ts.map +0 -1
  677. package/dist/types/utils/isRoutesRequest.d.ts +0 -3
  678. package/dist/types/utils/isRoutesRequest.d.ts.map +0 -1
  679. package/dist/types/utils/isStep.d.ts +0 -3
  680. package/dist/types/utils/isStep.d.ts.map +0 -1
  681. package/dist/types/utils/isToken.d.ts +0 -3
  682. package/dist/types/utils/isToken.d.ts.map +0 -1
  683. package/dist/types/utils/parseUnits.d.ts +0 -5
  684. package/dist/types/utils/parseUnits.d.ts.map +0 -1
  685. package/dist/types/utils/request.d.ts +0 -7
  686. package/dist/types/utils/request.d.ts.map +0 -1
  687. package/dist/types/utils/sleep.d.ts +0 -2
  688. package/dist/types/utils/sleep.d.ts.map +0 -1
  689. package/dist/types/utils/waitForResult.d.ts +0 -11
  690. package/dist/types/utils/waitForResult.d.ts.map +0 -1
  691. package/dist/types/utils/withDedupe.d.ts +0 -8
  692. package/dist/types/utils/withDedupe.d.ts.map +0 -1
  693. package/dist/types/version.d.ts +0 -3
  694. package/dist/types/version.d.ts.map +0 -1
  695. package/src/core/checkBalance.ts +0 -51
  696. package/src/core/waitForDestinationChainTransaction.ts +0 -112
@@ -1,43 +1,48 @@
1
- import type { Route } from '@lifi/types';
2
- import type { ExecutionOptions, RouteExtended, SDKClient } from '../types/core.js';
1
+ import { ExecutionOptions, RouteExtended, SDKClient } from "../types/core.js";
2
+ import { Route } from "@lifi/types";
3
+
4
+ //#region src/core/execution.d.ts
3
5
  /**
4
- * Execute a route.
5
- * @param client - The SDK client.
6
- * @param route - The route that should be executed. Cannot be an active route.
7
- * @param executionOptions - An object containing settings and callbacks.
8
- * @returns The executed route.
9
- * @throws {LiFiError} Throws a LiFiError if the execution fails.
10
- */
11
- export declare const executeRoute: (client: SDKClient, route: Route, executionOptions?: ExecutionOptions) => Promise<RouteExtended>;
6
+ * Execute a route.
7
+ * @param client - The SDK client.
8
+ * @param route - The route that should be executed. Cannot be an active route.
9
+ * @param executionOptions - An object containing settings and callbacks.
10
+ * @returns The executed route.
11
+ * @throws {LiFiError} Throws a LiFiError if the execution fails.
12
+ */
13
+ declare const executeRoute: (client: SDKClient, route: Route, executionOptions?: ExecutionOptions) => Promise<RouteExtended>;
12
14
  /**
13
- * Resume the execution of a route that has been stopped or had an error while executing.
14
- * @param client - The SDK client.
15
- * @param route - The route that is to be executed. Cannot be an active route.
16
- * @param executionOptions - An object containing settings and callbacks.
17
- * @returns The executed route.
18
- * @throws {LiFiError} Throws a LiFiError if the execution fails.
19
- */
20
- export declare const resumeRoute: (client: SDKClient, route: Route, executionOptions?: ExecutionOptions) => Promise<RouteExtended>;
15
+ * Resume the execution of a route that has been stopped or had an error while executing.
16
+ * @param client - The SDK client.
17
+ * @param route - The route that is to be executed. Cannot be an active route.
18
+ * @param executionOptions - An object containing settings and callbacks.
19
+ * @returns The executed route.
20
+ * @throws {LiFiError} Throws a LiFiError if the execution fails.
21
+ */
22
+ declare const resumeRoute: (client: SDKClient, route: Route, executionOptions?: ExecutionOptions) => Promise<RouteExtended>;
21
23
  /**
22
- * Updates route execution to background or foreground state.
23
- * @param route - A route that is currently in execution.
24
- * @param options - An object with execution settings.
25
- */
26
- export declare const updateRouteExecution: (route: Route, options: ExecutionOptions) => void;
24
+ * Updates route execution to background or foreground state.
25
+ * @param route - A route that is currently in execution.
26
+ * @param options - An object with execution settings.
27
+ */
28
+ declare const updateRouteExecution: (route: Route, options: ExecutionOptions) => void;
27
29
  /**
28
- * Stops the execution of an active route.
29
- * @param route - A route that is currently in execution.
30
- * @returns The stopped route.
31
- */
32
- export declare const stopRouteExecution: (route: Route) => Route;
30
+ * Stops the execution of an active route.
31
+ * @param route - A route that is currently in execution.
32
+ * @returns The stopped route.
33
+ */
34
+ declare const stopRouteExecution: (route: Route) => Route;
33
35
  /**
34
- * Get the list of active routes.
35
- * @returns A list of routes.
36
- */
37
- export declare const getActiveRoutes: () => RouteExtended[];
36
+ * Get the list of active routes.
37
+ * @returns A list of routes.
38
+ */
39
+ declare const getActiveRoutes: () => RouteExtended[];
38
40
  /**
39
- * Return the current route information for given route. The route has to be active.
40
- * @param routeId - A route id.
41
- * @returns The updated route.
42
- */
43
- export declare const getActiveRoute: (routeId: string) => RouteExtended | undefined;
41
+ * Return the current route information for given route. The route has to be active.
42
+ * @param routeId - A route id.
43
+ * @returns The updated route.
44
+ */
45
+ declare const getActiveRoute: (routeId: string) => RouteExtended | undefined;
46
+ //#endregion
47
+ export { executeRoute, getActiveRoute, getActiveRoutes, resumeRoute, stopRouteExecution, updateRouteExecution };
48
+ //# sourceMappingURL=execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.d.ts","names":[],"sources":["../../../src/core/execution.ts"],"mappings":";;;;;;AAqBA;;;;;;cAAa,YAAA,GACX,MAAA,EAAQ,SAAA,EACR,KAAA,EAAO,KAAA,EACP,gBAAA,GAAmB,gBAAA,KAClB,OAAA,CAAQ,aAAA;;;;;;;;;cA4BE,WAAA,GACX,MAAA,EAAQ,SAAA,EACR,KAAA,EAAO,KAAA,EACP,gBAAA,GAAmB,gBAAA,KAClB,OAAA,CAAQ,aAAA;;;;AAhCA;AA4BX;cA8Ha,oBAAA,GACX,KAAA,EAAO,KAAA,EACP,OAAA,EAAS,gBAAA;;;;;;cA2BE,kBAAA,GAAsB,KAAA,EAAO,KAAA,KAAQ,KAAA;;;;;cAqBrC,eAAA,QAAsB,aAAA;;;;;;cAWtB,cAAA,GAAkB,OAAA,aAAkB,aAAA"}
@@ -1,177 +1,141 @@
1
- import { LiFiErrorCode } from '../errors/constants.js';
2
- import { ProviderError } from '../errors/errors.js';
3
- import { executionState } from './executionState.js';
4
- import { prepareRestart } from './prepareRestart.js';
1
+ import "../errors/constants.js";
2
+ import { ExecuteStepRetryError, ProviderError } from "../errors/errors.js";
3
+ import { executionState } from "./executionState.js";
4
+ import { prepareRestart } from "./prepareRestart.js";
5
+ //#region src/core/execution.ts
5
6
  /**
6
- * Execute a route.
7
- * @param client - The SDK client.
8
- * @param route - The route that should be executed. Cannot be an active route.
9
- * @param executionOptions - An object containing settings and callbacks.
10
- * @returns The executed route.
11
- * @throws {LiFiError} Throws a LiFiError if the execution fails.
12
- */
13
- export const executeRoute = async (client, route, executionOptions) => {
14
- // Deep clone to prevent side effects
15
- const clonedRoute = structuredClone(route);
16
- let executionPromise = executionState.get(clonedRoute.id)?.promise;
17
- // Check if route is already running
18
- if (executionPromise) {
19
- return executionPromise;
20
- }
21
- executionState.create({ route: clonedRoute, executionOptions });
22
- executionPromise = executeSteps(client, clonedRoute);
23
- executionState.update({
24
- route: clonedRoute,
25
- promise: executionPromise,
26
- });
27
- return executionPromise;
7
+ * Execute a route.
8
+ * @param client - The SDK client.
9
+ * @param route - The route that should be executed. Cannot be an active route.
10
+ * @param executionOptions - An object containing settings and callbacks.
11
+ * @returns The executed route.
12
+ * @throws {LiFiError} Throws a LiFiError if the execution fails.
13
+ */
14
+ const executeRoute = async (client, route, executionOptions) => {
15
+ const clonedRoute = structuredClone(route);
16
+ let executionPromise = executionState.get(clonedRoute.id)?.promise;
17
+ if (executionPromise) return executionPromise;
18
+ executionState.create({
19
+ route: clonedRoute,
20
+ executionOptions
21
+ });
22
+ executionPromise = executeSteps(client, clonedRoute);
23
+ executionState.update({
24
+ route: clonedRoute,
25
+ promise: executionPromise
26
+ });
27
+ return executionPromise;
28
28
  };
29
29
  /**
30
- * Resume the execution of a route that has been stopped or had an error while executing.
31
- * @param client - The SDK client.
32
- * @param route - The route that is to be executed. Cannot be an active route.
33
- * @param executionOptions - An object containing settings and callbacks.
34
- * @returns The executed route.
35
- * @throws {LiFiError} Throws a LiFiError if the execution fails.
36
- */
37
- export const resumeRoute = async (client, route, executionOptions) => {
38
- const execution = executionState.get(route.id);
39
- if (execution) {
40
- const executionHalted = execution.executors.some((executor) => !executor.allowExecution);
41
- if (!executionHalted) {
42
- // Check if we want to resume route execution in the background
43
- updateRouteExecution(route, {
44
- executeInBackground: executionOptions?.executeInBackground,
45
- });
46
- if (!execution.promise) {
47
- // We should never reach this point if we do clean-up properly
48
- throw new Error('Route execution promise not found.');
49
- }
50
- return execution.promise;
51
- }
52
- }
53
- prepareRestart(route);
54
- return executeRoute(client, route, executionOptions);
30
+ * Resume the execution of a route that has been stopped or had an error while executing.
31
+ * @param client - The SDK client.
32
+ * @param route - The route that is to be executed. Cannot be an active route.
33
+ * @param executionOptions - An object containing settings and callbacks.
34
+ * @returns The executed route.
35
+ * @throws {LiFiError} Throws a LiFiError if the execution fails.
36
+ */
37
+ const resumeRoute = async (client, route, executionOptions) => {
38
+ const execution = executionState.get(route.id);
39
+ if (execution) {
40
+ if (!execution.executors.some((executor) => !executor.allowExecution)) {
41
+ updateRouteExecution(route, { executeInBackground: executionOptions?.executeInBackground });
42
+ if (!execution.promise) throw new Error("Route execution promise not found.");
43
+ return execution.promise;
44
+ }
45
+ }
46
+ prepareRestart(route);
47
+ return executeRoute(client, route, executionOptions);
55
48
  };
56
49
  const executeSteps = async (client, route) => {
57
- // Loop over steps and execute them
58
- for (let index = 0; index < route.steps.length; index++) {
59
- const execution = executionState.get(route.id);
60
- // Check if execution has stopped in the meantime
61
- if (!execution) {
62
- break;
63
- }
64
- const step = route.steps[index];
65
- const previousStep = route.steps[index - 1];
66
- // Check if the step is already done
67
- //
68
- if (step.execution?.status === 'DONE') {
69
- continue;
70
- }
71
- // Update step fromAmount using output of the previous step execution. In the future this should be handled by calling `updateRoute`
72
- if (previousStep?.execution?.toAmount) {
73
- step.action.fromAmount = previousStep.execution.toAmount;
74
- if (step.includedSteps?.length) {
75
- step.includedSteps[0].action.fromAmount =
76
- previousStep.execution.toAmount;
77
- }
78
- }
79
- try {
80
- const fromAddress = step.action.fromAddress;
81
- if (!fromAddress) {
82
- throw new Error('Action fromAddress is not specified.');
83
- }
84
- const provider = client.providers.find((provider) => provider.isAddress(fromAddress));
85
- if (!provider) {
86
- throw new ProviderError(LiFiErrorCode.ProviderUnavailable, 'SDK Execution Provider not found.');
87
- }
88
- const stepExecutor = await provider.getStepExecutor({
89
- routeId: route.id,
90
- executionOptions: execution.executionOptions,
91
- });
92
- execution.executors.push(stepExecutor);
93
- // Check if we want to execute this step in the background
94
- if (execution.executionOptions) {
95
- updateRouteExecution(route, execution.executionOptions);
96
- }
97
- const executedStep = await stepExecutor.executeStep(client, step);
98
- // We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it
99
- if (executedStep.execution?.status !== 'DONE') {
100
- stopRouteExecution(route);
101
- }
102
- // Execution stopped during the current step, we don't want to continue to the next step so we return already
103
- if (!stepExecutor.allowExecution) {
104
- return route;
105
- }
106
- }
107
- catch (e) {
108
- stopRouteExecution(route);
109
- throw e;
110
- }
111
- }
112
- // Clean up after the execution
113
- executionState.delete(route.id);
114
- return route;
50
+ for (let index = 0; index < route.steps.length; index++) {
51
+ const execution = executionState.get(route.id);
52
+ if (!execution) break;
53
+ const step = route.steps[index];
54
+ const previousStep = route.steps[index - 1];
55
+ if (step.execution?.status === "DONE") continue;
56
+ if (previousStep?.execution?.toAmount) {
57
+ step.action.fromAmount = previousStep.execution.toAmount;
58
+ if (step.includedSteps?.length) step.includedSteps[0].action.fromAmount = previousStep.execution.toAmount;
59
+ }
60
+ try {
61
+ const fromAddress = step.action.fromAddress;
62
+ if (!fromAddress) throw new Error("Action fromAddress is not specified.");
63
+ const provider = client.providers.find((provider) => provider.isAddress(fromAddress));
64
+ if (!provider) throw new ProviderError(1005, "SDK Execution Provider not found.");
65
+ const stepExecutor = await provider.getStepExecutor({
66
+ routeId: route.id,
67
+ executionOptions: execution.executionOptions
68
+ });
69
+ execution.executors.push(stepExecutor);
70
+ if (execution.executionOptions) updateRouteExecution(route, execution.executionOptions);
71
+ let executedStep;
72
+ try {
73
+ executedStep = await stepExecutor.executeStep(client, step);
74
+ } catch (e) {
75
+ if (e instanceof ExecuteStepRetryError) {
76
+ step.execution = void 0;
77
+ executedStep = await stepExecutor.executeStep(client, step, e.retryParams);
78
+ } else throw e;
79
+ }
80
+ if (executedStep.execution?.status !== "DONE") stopRouteExecution(route);
81
+ if (!stepExecutor.allowExecution) return route;
82
+ } catch (e) {
83
+ stopRouteExecution(route);
84
+ throw e;
85
+ }
86
+ }
87
+ executionState.delete(route.id);
88
+ return route;
115
89
  };
116
90
  /**
117
- * Updates route execution to background or foreground state.
118
- * @param route - A route that is currently in execution.
119
- * @param options - An object with execution settings.
120
- */
121
- export const updateRouteExecution = (route, options) => {
122
- const execution = executionState.get(route.id);
123
- if (!execution) {
124
- return;
125
- }
126
- if ('executeInBackground' in options) {
127
- for (const executor of execution.executors) {
128
- executor.setInteraction({
129
- allowInteraction: !options?.executeInBackground,
130
- allowUpdates: true,
131
- });
132
- }
133
- }
134
- // Update active route settings so we know what the current state of execution is
135
- execution.executionOptions = {
136
- ...execution.executionOptions,
137
- ...options,
138
- };
91
+ * Updates route execution to background or foreground state.
92
+ * @param route - A route that is currently in execution.
93
+ * @param options - An object with execution settings.
94
+ */
95
+ const updateRouteExecution = (route, options) => {
96
+ const execution = executionState.get(route.id);
97
+ if (!execution) return;
98
+ if ("executeInBackground" in options) for (const executor of execution.executors) executor.setInteraction({
99
+ allowInteraction: !options?.executeInBackground,
100
+ allowUpdates: true
101
+ });
102
+ execution.executionOptions = {
103
+ ...execution.executionOptions,
104
+ ...options
105
+ };
139
106
  };
140
107
  /**
141
- * Stops the execution of an active route.
142
- * @param route - A route that is currently in execution.
143
- * @returns The stopped route.
144
- */
145
- export const stopRouteExecution = (route) => {
146
- const execution = executionState.get(route.id);
147
- if (!execution) {
148
- return route;
149
- }
150
- for (const executor of execution.executors) {
151
- executor.setInteraction({
152
- allowInteraction: false,
153
- allowUpdates: false,
154
- allowExecution: false,
155
- });
156
- }
157
- executionState.delete(route.id);
158
- return execution.route;
108
+ * Stops the execution of an active route.
109
+ * @param route - A route that is currently in execution.
110
+ * @returns The stopped route.
111
+ */
112
+ const stopRouteExecution = (route) => {
113
+ const execution = executionState.get(route.id);
114
+ if (!execution) return route;
115
+ for (const executor of execution.executors) executor.setInteraction({
116
+ allowInteraction: false,
117
+ allowUpdates: false,
118
+ allowExecution: false
119
+ });
120
+ executionState.delete(route.id);
121
+ return execution.route;
159
122
  };
160
123
  /**
161
- * Get the list of active routes.
162
- * @returns A list of routes.
163
- */
164
- export const getActiveRoutes = () => {
165
- return Object.values(executionState.state)
166
- .map((dict) => dict?.route)
167
- .filter(Boolean);
124
+ * Get the list of active routes.
125
+ * @returns A list of routes.
126
+ */
127
+ const getActiveRoutes = () => {
128
+ return Object.values(executionState.state).map((dict) => dict?.route).filter(Boolean);
168
129
  };
169
130
  /**
170
- * Return the current route information for given route. The route has to be active.
171
- * @param routeId - A route id.
172
- * @returns The updated route.
173
- */
174
- export const getActiveRoute = (routeId) => {
175
- return executionState.get(routeId)?.route;
131
+ * Return the current route information for given route. The route has to be active.
132
+ * @param routeId - A route id.
133
+ * @returns The updated route.
134
+ */
135
+ const getActiveRoute = (routeId) => {
136
+ return executionState.get(routeId)?.route;
176
137
  };
138
+ //#endregion
139
+ export { executeRoute, getActiveRoute, getActiveRoutes, resumeRoute, stopRouteExecution, updateRouteExecution };
140
+
177
141
  //# sourceMappingURL=execution.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/core/execution.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"execution.js","names":[],"sources":["../../../src/core/execution.ts"],"sourcesContent":["import type { Route } from '@lifi/types'\nimport { LiFiErrorCode } from '../errors/constants.js'\nimport { ExecuteStepRetryError, ProviderError } from '../errors/errors.js'\nimport type {\n ExecutionOptions,\n LiFiStepExtended,\n RouteExtended,\n SDKClient,\n SDKProvider,\n} from '../types/core.js'\nimport { executionState } from './executionState.js'\nimport { prepareRestart } from './prepareRestart.js'\n\n/**\n * Execute a route.\n * @param client - The SDK client.\n * @param route - The route that should be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const executeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n // Deep clone to prevent side effects\n const clonedRoute = structuredClone<Route>(route)\n\n let executionPromise = executionState.get(clonedRoute.id)?.promise\n // Check if route is already running\n if (executionPromise) {\n return executionPromise\n }\n\n executionState.create({ route: clonedRoute, executionOptions })\n executionPromise = executeSteps(client, clonedRoute)\n executionState.update({\n route: clonedRoute,\n promise: executionPromise,\n })\n\n return executionPromise\n}\n\n/**\n * Resume the execution of a route that has been stopped or had an error while executing.\n * @param client - The SDK client.\n * @param route - The route that is to be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const resumeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n const execution = executionState.get(route.id)\n\n if (execution) {\n const executionHalted = execution.executors.some(\n (executor) => !executor.allowExecution\n )\n if (!executionHalted) {\n // Check if we want to resume route execution in the background\n updateRouteExecution(route, {\n executeInBackground: executionOptions?.executeInBackground,\n })\n if (!execution.promise) {\n // We should never reach this point if we do clean-up properly\n throw new Error('Route execution promise not found.')\n }\n return execution.promise\n }\n }\n\n prepareRestart(route)\n\n return executeRoute(client, route, executionOptions)\n}\n\nconst executeSteps = async (\n client: SDKClient,\n route: RouteExtended\n): Promise<RouteExtended> => {\n // Loop over steps and execute them\n for (let index = 0; index < route.steps.length; index++) {\n const execution = executionState.get(route.id)\n // Check if execution has stopped in the meantime\n if (!execution) {\n break\n }\n\n const step = route.steps[index]\n const previousStep = route.steps[index - 1]\n // Check if the step is already done\n if (step.execution?.status === 'DONE') {\n continue\n }\n\n // Update step fromAmount using output of the previous step execution. In the future this should be handled by calling `updateRoute`\n if (previousStep?.execution?.toAmount) {\n step.action.fromAmount = previousStep.execution.toAmount\n if (step.includedSteps?.length) {\n step.includedSteps[0].action.fromAmount =\n previousStep.execution.toAmount\n }\n }\n\n try {\n const fromAddress = step.action.fromAddress\n if (!fromAddress) {\n throw new Error('Action fromAddress is not specified.')\n }\n\n const provider = client.providers.find((provider: SDKProvider) =>\n provider.isAddress(fromAddress)\n )\n\n if (!provider) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'SDK Execution Provider not found.'\n )\n }\n\n const stepExecutor = await provider.getStepExecutor({\n routeId: route.id,\n executionOptions: execution.executionOptions,\n })\n execution.executors.push(stepExecutor)\n\n // Check if we want to execute this step in the background\n if (execution.executionOptions) {\n updateRouteExecution(route, execution.executionOptions)\n }\n\n let executedStep: LiFiStepExtended\n try {\n executedStep = await stepExecutor.executeStep(client, step)\n } catch (e) {\n if (e instanceof ExecuteStepRetryError) {\n step.execution = undefined\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n e.retryParams\n )\n } else {\n throw e\n }\n }\n\n // We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it\n if (executedStep.execution?.status !== 'DONE') {\n stopRouteExecution(route)\n }\n\n // Execution stopped during the current step, we don't want to continue to the next step so we return already\n if (!stepExecutor.allowExecution) {\n return route\n }\n } catch (e) {\n stopRouteExecution(route)\n throw e\n }\n }\n\n // Clean up after the execution\n executionState.delete(route.id)\n return route\n}\n\n/**\n * Updates route execution to background or foreground state.\n * @param route - A route that is currently in execution.\n * @param options - An object with execution settings.\n */\nexport const updateRouteExecution = (\n route: Route,\n options: ExecutionOptions\n): void => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return\n }\n\n if ('executeInBackground' in options) {\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: !options?.executeInBackground,\n allowUpdates: true,\n })\n }\n }\n // Update active route settings so we know what the current state of execution is\n execution.executionOptions = {\n ...execution.executionOptions,\n ...options,\n }\n}\n\n/**\n * Stops the execution of an active route.\n * @param route - A route that is currently in execution.\n * @returns The stopped route.\n */\nexport const stopRouteExecution = (route: Route): Route => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return route\n }\n\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: false,\n allowUpdates: false,\n allowExecution: false,\n })\n }\n executionState.delete(route.id)\n return execution.route\n}\n\n/**\n * Get the list of active routes.\n * @returns A list of routes.\n */\nexport const getActiveRoutes = (): RouteExtended[] => {\n return Object.values(executionState.state)\n .map((dict) => dict?.route)\n .filter(Boolean) as RouteExtended[]\n}\n\n/**\n * Return the current route information for given route. The route has to be active.\n * @param routeId - A route id.\n * @returns The updated route.\n */\nexport const getActiveRoute = (routeId: string): RouteExtended | undefined => {\n return executionState.get(routeId)?.route\n}\n"],"mappings":"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"}
@@ -1,17 +1,21 @@
1
- import type { ExecutionOptions, RouteExtended, StepExecutor } from '../types/core.js';
1
+ import { ExecutionOptions, RouteExtended, StepExecutor } from "../types/core.js";
2
+
3
+ //#region src/core/executionState.d.ts
2
4
  interface ExecutionData {
3
- route: RouteExtended;
4
- executors: StepExecutor[];
5
- executionOptions?: ExecutionOptions;
6
- promise?: Promise<RouteExtended>;
5
+ route: RouteExtended;
6
+ executors: StepExecutor[];
7
+ executionOptions?: ExecutionOptions;
8
+ promise?: Promise<RouteExtended>;
7
9
  }
8
- type ExecutionStateParams = Omit<ExecutionData, 'executors'>;
10
+ type ExecutionStateParams = Omit<ExecutionData, "executors">;
9
11
  interface ExecutionState {
10
- state: Partial<Record<string, ExecutionData>>;
11
- get(routeId: string): ExecutionData | undefined;
12
- create(params: ExecutionStateParams): ExecutionData;
13
- update(params: ExecutionStateParams): void;
14
- delete(routeId: string): void;
12
+ state: Partial<Record<string, ExecutionData>>;
13
+ get(routeId: string): ExecutionData | undefined;
14
+ create(params: ExecutionStateParams): ExecutionData;
15
+ update(params: ExecutionStateParams): void;
16
+ delete(routeId: string): void;
15
17
  }
16
- export declare const executionState: ExecutionState;
17
- export {};
18
+ declare const executionState: ExecutionState;
19
+ //#endregion
20
+ export { executionState };
21
+ //# sourceMappingURL=executionState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executionState.d.ts","names":[],"sources":["../../../src/core/executionState.ts"],"mappings":";;;UAMU,aAAA;EACR,KAAA,EAAO,aAAA;EACP,SAAA,EAAW,YAAA;EACX,gBAAA,GAAmB,gBAAA;EACnB,OAAA,GAAU,OAAA,CAAQ,aAAA;AAAA;AAAA,KAGf,oBAAA,GAAuB,IAAA,CAAK,aAAA;AAAA,UAEvB,cAAA;EACR,KAAA,EAAO,OAAA,CAAQ,MAAA,SAAe,aAAA;EAC9B,GAAA,CAAI,OAAA,WAAkB,aAAA;EACtB,MAAA,CAAO,MAAA,EAAQ,oBAAA,GAAuB,aAAA;EACtC,MAAA,CAAO,MAAA,EAAQ,oBAAA;EACf,MAAA,CAAO,OAAA;AAAA;AAAA,cAGI,cAAA,EAAgB,cAAA"}
@@ -1,26 +1,28 @@
1
- export const executionState = {
2
- state: {},
3
- get(routeId) {
4
- return this.state[routeId];
5
- },
6
- create(params) {
7
- this.state[params.route.id] = {
8
- ...this.state[params.route.id],
9
- ...params,
10
- executors: this.state[params.route.id]?.executors ?? [],
11
- };
12
- return this.state[params.route.id];
13
- },
14
- update(state) {
15
- if (this.state[state.route.id]) {
16
- this.state[state.route.id] = {
17
- ...this.state[state.route.id],
18
- ...state,
19
- };
20
- }
21
- },
22
- delete(routeId) {
23
- delete this.state[routeId];
24
- },
1
+ //#region src/core/executionState.ts
2
+ const executionState = {
3
+ state: {},
4
+ get(routeId) {
5
+ return this.state[routeId];
6
+ },
7
+ create(params) {
8
+ this.state[params.route.id] = {
9
+ ...this.state[params.route.id],
10
+ ...params,
11
+ executors: this.state[params.route.id]?.executors ?? []
12
+ };
13
+ return this.state[params.route.id];
14
+ },
15
+ update(state) {
16
+ if (this.state[state.route.id]) this.state[state.route.id] = {
17
+ ...this.state[state.route.id],
18
+ ...state
19
+ };
20
+ },
21
+ delete(routeId) {
22
+ delete this.state[routeId];
23
+ }
25
24
  };
25
+ //#endregion
26
+ export { executionState };
27
+
26
28
  //# sourceMappingURL=executionState.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"executionState.js","sourceRoot":"","sources":["../../../src/core/executionState.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,KAAK,EAAE,EAAE;IACT,GAAG,CAAC,OAAe;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IACD,MAAM,CAAC,MAAM;QACX,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG;YAC5B,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,GAAG,MAAM;YACT,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,SAAS,IAAI,EAAE;SACxD,CAAA;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAE,CAAA;IACrC,CAAC;IACD,MAAM,CAAC,KAAK;QACV,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG;gBAC3B,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE;gBAC9B,GAAG,KAAK;aACT,CAAA;QACH,CAAC;IACH,CAAC;IACD,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"executionState.js","names":[],"sources":["../../../src/core/executionState.ts"],"sourcesContent":["import type {\n ExecutionOptions,\n RouteExtended,\n StepExecutor,\n} from '../types/core.js'\n\ninterface ExecutionData {\n route: RouteExtended\n executors: StepExecutor[]\n executionOptions?: ExecutionOptions\n promise?: Promise<RouteExtended>\n}\n\ntype ExecutionStateParams = Omit<ExecutionData, 'executors'>\n\ninterface ExecutionState {\n state: Partial<Record<string, ExecutionData>>\n get(routeId: string): ExecutionData | undefined\n create(params: ExecutionStateParams): ExecutionData\n update(params: ExecutionStateParams): void\n delete(routeId: string): void\n}\n\nexport const executionState: ExecutionState = {\n state: {},\n get(routeId: string) {\n return this.state[routeId]\n },\n create(params) {\n this.state[params.route.id] = {\n ...this.state[params.route.id],\n ...params,\n executors: this.state[params.route.id]?.executors ?? [],\n }\n return this.state[params.route.id]!\n },\n update(state) {\n if (this.state[state.route.id]) {\n this.state[state.route.id] = {\n ...this.state[state.route.id]!,\n ...state,\n }\n }\n },\n delete(routeId) {\n delete this.state[routeId]\n },\n}\n"],"mappings":";AAuBA,MAAa,iBAAiC;CAC5C,OAAO,CAAC;CACR,IAAI,SAAiB;EACnB,OAAO,KAAK,MAAM;CACpB;CACA,OAAO,QAAQ;EACb,KAAK,MAAM,OAAO,MAAM,MAAM;GAC5B,GAAG,KAAK,MAAM,OAAO,MAAM;GAC3B,GAAG;GACH,WAAW,KAAK,MAAM,OAAO,MAAM,GAAG,EAAE,aAAa,CAAC;EACxD;EACA,OAAO,KAAK,MAAM,OAAO,MAAM;CACjC;CACA,OAAO,OAAO;EACZ,IAAI,KAAK,MAAM,MAAM,MAAM,KACzB,KAAK,MAAM,MAAM,MAAM,MAAM;GAC3B,GAAG,KAAK,MAAM,MAAM,MAAM;GAC1B,GAAG;EACL;CAEJ;CACA,OAAO,SAAS;EACd,OAAO,KAAK,MAAM;CACpB;AACF"}
@@ -1,2 +1,7 @@
1
- import type { RouteExtended } from '../types/core.js';
2
- export declare const prepareRestart: (route: RouteExtended) => void;
1
+ import { RouteExtended } from "../types/core.js";
2
+
3
+ //#region src/core/prepareRestart.d.ts
4
+ declare const prepareRestart: (route: RouteExtended) => void;
5
+ //#endregion
6
+ export { prepareRestart };
7
+ //# sourceMappingURL=prepareRestart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareRestart.d.ts","names":[],"sources":["../../../src/core/prepareRestart.ts"],"mappings":";;;cAEa,cAAA,GAAkB,KAAO,EAAA,aAAA"}
@@ -1,22 +1,20 @@
1
- export const prepareRestart = (route) => {
2
- for (let index = 0; index < route.steps.length; index++) {
3
- const step = route.steps[index];
4
- if (step.execution) {
5
- // Find the index of the last action that has tx hash, taskId, or signed messages
6
- const lastValidIndex = step.execution.actions.findLastIndex((action) => (!!action.txHash ||
7
- !!action.taskId ||
8
- !!action.signedTypedData?.length) &&
9
- action.status !== 'FAILED');
10
- // Keep all actions up to the one with tx hash
11
- if (lastValidIndex >= 0) {
12
- step.execution.actions = step.execution.actions.slice(0, lastValidIndex + 1);
13
- }
14
- else {
15
- // If no tx hash exists, reset the actions array
16
- step.execution.actions = [];
17
- }
18
- }
19
- step.transactionRequest = undefined;
20
- }
1
+ //#region src/core/prepareRestart.ts
2
+ const prepareRestart = (route) => {
3
+ for (let index = 0; index < route.steps.length; index++) {
4
+ const step = route.steps[index];
5
+ if (step.execution) {
6
+ const lastValidIndex = step.execution.actions.findLastIndex((action) => [
7
+ "SWAP",
8
+ "CROSS_CHAIN",
9
+ "RECEIVING_CHAIN"
10
+ ].includes(action.type) && (!!action.txHash || !!action.taskId) && action.status !== "FAILED");
11
+ if (lastValidIndex >= 0) step.execution.actions = step.execution.actions.slice(0, lastValidIndex + 1);
12
+ else step.execution.actions = [];
13
+ }
14
+ step.transactionRequest = void 0;
15
+ }
21
16
  };
17
+ //#endregion
18
+ export { prepareRestart };
19
+
22
20
  //# sourceMappingURL=prepareRestart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareRestart.js","sourceRoot":"","sources":["../../../src/core/prepareRestart.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAoB,EAAE,EAAE;IACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACxD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC/B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,iFAAiF;YACjF,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CACzD,CAAC,MAAM,EAAE,EAAE,CACT,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM;gBACd,CAAC,CAAC,MAAM,CAAC,MAAM;gBACf,CAAC,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC;gBACnC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAC7B,CAAA;YAED,8CAA8C;YAC9C,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;gBACxB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CACnD,CAAC,EACD,cAAc,GAAG,CAAC,CACnB,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,gDAAgD;gBAChD,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,EAAE,CAAA;YAC7B,CAAC;QACH,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;IACrC,CAAC;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"prepareRestart.js","names":[],"sources":["../../../src/core/prepareRestart.ts"],"sourcesContent":["import type { RouteExtended } from '../types/core.js'\n\nexport const prepareRestart = (route: RouteExtended): void => {\n for (let index = 0; index < route.steps.length; index++) {\n const step = route.steps[index]\n if (step.execution) {\n // Find the index of the last action that has tx hash, taskId, or signed messages\n const lastValidIndex = step.execution.actions.findLastIndex(\n (action) =>\n ['SWAP', 'CROSS_CHAIN', 'RECEIVING_CHAIN'].includes(action.type) &&\n (!!action.txHash || !!action.taskId) &&\n action.status !== 'FAILED'\n )\n\n // Keep all actions up to the one with tx hash\n if (lastValidIndex >= 0) {\n step.execution.actions = step.execution.actions.slice(\n 0,\n lastValidIndex + 1\n )\n } else {\n // If no tx hash exists, reset the actions array\n step.execution.actions = []\n }\n }\n step.transactionRequest = undefined\n }\n}\n"],"mappings":";AAEA,MAAa,kBAAkB,UAA+B;CAC5D,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,QAAQ,SAAS;EACvD,MAAM,OAAO,MAAM,MAAM;EACzB,IAAI,KAAK,WAAW;GAElB,MAAM,iBAAiB,KAAK,UAAU,QAAQ,eAC3C,WACC;IAAC;IAAQ;IAAe;GAAiB,CAAC,CAAC,SAAS,OAAO,IAAI,MAC9D,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,OAAO,WAC7B,OAAO,WAAW,QACtB;GAGA,IAAI,kBAAkB,GACpB,KAAK,UAAU,UAAU,KAAK,UAAU,QAAQ,MAC9C,GACA,iBAAiB,CACnB;QAGA,KAAK,UAAU,UAAU,CAAC;EAE9B;EACA,KAAK,qBAAqB,KAAA;CAC5B;AACF"}