@lifi/sdk 4.12.0 → 4.13.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 (428) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/cjs/actions/getChains.d.ts +1 -4
  3. package/dist/cjs/actions/getChains.js +1 -2
  4. package/dist/cjs/actions/getConnections.d.ts +1 -4
  5. package/dist/cjs/actions/getConnections.js +1 -2
  6. package/dist/cjs/actions/getContractCallsQuote.d.ts +1 -4
  7. package/dist/cjs/actions/getContractCallsQuote.js +2 -3
  8. package/dist/cjs/actions/getGasRecommendation.d.ts +1 -4
  9. package/dist/cjs/actions/getGasRecommendation.js +2 -3
  10. package/dist/cjs/actions/getNameServiceAddress.d.ts +1 -4
  11. package/dist/cjs/actions/getNameServiceAddress.js +1 -2
  12. package/dist/cjs/actions/getQuote.d.ts +2 -5
  13. package/dist/cjs/actions/getQuote.js +2 -3
  14. package/dist/cjs/actions/getRelayedTransactionStatus.d.ts +1 -4
  15. package/dist/cjs/actions/getRelayedTransactionStatus.js +3 -4
  16. package/dist/cjs/actions/getRelayerQuote.d.ts +16 -11
  17. package/dist/cjs/actions/getRelayerQuote.js +18 -35
  18. package/dist/cjs/actions/getRelayerQuote.js.map +1 -1
  19. package/dist/cjs/actions/getRoutes.d.ts +2 -5
  20. package/dist/cjs/actions/getRoutes.js +3 -4
  21. package/dist/cjs/actions/getStatus.d.ts +2 -5
  22. package/dist/cjs/actions/getStatus.js +2 -3
  23. package/dist/cjs/actions/getStepTransaction.d.ts +2 -5
  24. package/dist/cjs/actions/getStepTransaction.js +2 -3
  25. package/dist/cjs/actions/getToken.d.ts +1 -4
  26. package/dist/cjs/actions/getToken.js +2 -3
  27. package/dist/cjs/actions/getTokenBalance.d.ts +1 -4
  28. package/dist/cjs/actions/getTokenBalance.js +1 -2
  29. package/dist/cjs/actions/getTokenBalances.d.ts +1 -4
  30. package/dist/cjs/actions/getTokenBalances.js +1 -2
  31. package/dist/cjs/actions/getTokenBalancesByChain.d.ts +1 -4
  32. package/dist/cjs/actions/getTokenBalancesByChain.js +1 -2
  33. package/dist/cjs/actions/getTokens.d.ts +1 -4
  34. package/dist/cjs/actions/getTokens.js +1 -2
  35. package/dist/cjs/actions/getTools.d.ts +1 -4
  36. package/dist/cjs/actions/getTools.js +1 -2
  37. package/dist/cjs/actions/getTransactionHistory.d.ts +1 -4
  38. package/dist/cjs/actions/getTransactionHistory.js +1 -2
  39. package/dist/cjs/actions/index.d.ts +4 -5
  40. package/dist/cjs/actions/index.js +4 -5
  41. package/dist/cjs/actions/index.js.map +1 -1
  42. package/dist/cjs/actions/patchContractCalls.d.ts +1 -4
  43. package/dist/cjs/actions/patchContractCalls.js +1 -2
  44. package/dist/cjs/actions/relayTransaction.d.ts +1 -4
  45. package/dist/cjs/actions/relayTransaction.js +3 -5
  46. package/dist/cjs/actions/relayTransaction.js.map +1 -1
  47. package/dist/cjs/client/createClient.d.ts +1 -4
  48. package/dist/cjs/client/createClient.js +2 -3
  49. package/dist/cjs/client/createClient.js.map +1 -1
  50. package/dist/cjs/client/findProvider.d.ts +1 -4
  51. package/dist/cjs/client/findProvider.js +1 -2
  52. package/dist/cjs/client/getClientStorage.d.ts +1 -4
  53. package/dist/cjs/client/getClientStorage.js +1 -2
  54. package/dist/cjs/core/BaseStepExecutionTask.d.ts +1 -4
  55. package/dist/cjs/core/BaseStepExecutionTask.js +1 -2
  56. package/dist/cjs/core/BaseStepExecutor.d.ts +4 -7
  57. package/dist/cjs/core/BaseStepExecutor.js +3 -4
  58. package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
  59. package/dist/cjs/core/StatusManager.d.ts +1 -3
  60. package/dist/cjs/core/StatusManager.js +1 -2
  61. package/dist/cjs/core/StatusManager.js.map +1 -1
  62. package/dist/cjs/core/TaskPipeline.d.ts +1 -4
  63. package/dist/cjs/core/TaskPipeline.js +1 -2
  64. package/dist/cjs/core/TaskPipeline.js.map +1 -1
  65. package/dist/cjs/core/actionMessages.d.ts +1 -4
  66. package/dist/cjs/core/actionMessages.js +1 -2
  67. package/dist/cjs/core/execution.d.ts +1 -4
  68. package/dist/cjs/core/execution.js +1 -2
  69. package/dist/cjs/core/execution.js.map +1 -1
  70. package/dist/cjs/core/executionState.d.ts +1 -3
  71. package/dist/cjs/core/executionState.js +1 -2
  72. package/dist/cjs/core/prepareRestart.d.ts +1 -4
  73. package/dist/cjs/core/prepareRestart.js +1 -2
  74. package/dist/cjs/core/storage.d.ts +1 -4
  75. package/dist/cjs/core/storage.js +1 -2
  76. package/dist/cjs/core/storage.js.map +1 -1
  77. package/dist/cjs/core/tasks/CheckBalanceTask.d.ts +1 -4
  78. package/dist/cjs/core/tasks/CheckBalanceTask.js +1 -2
  79. package/dist/cjs/core/tasks/CheckBalanceTask.js.map +1 -1
  80. package/dist/cjs/core/tasks/PrepareTransactionTask.d.ts +1 -4
  81. package/dist/cjs/core/tasks/PrepareTransactionTask.js +2 -3
  82. package/dist/cjs/core/tasks/PrepareTransactionTask.js.map +1 -1
  83. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.d.ts +1 -4
  84. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +2 -3
  85. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  86. package/dist/cjs/core/tasks/helpers/checkBalance.d.ts +1 -4
  87. package/dist/cjs/core/tasks/helpers/checkBalance.js +2 -3
  88. package/dist/cjs/core/tasks/helpers/getStepStatusRequest.d.ts +1 -4
  89. package/dist/cjs/core/tasks/helpers/getStepStatusRequest.js +1 -2
  90. package/dist/cjs/core/tasks/helpers/getTransactionRequestData.d.ts +1 -4
  91. package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js +1 -2
  92. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.d.ts +1 -4
  93. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.js +1 -2
  94. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.js.map +1 -1
  95. package/dist/cjs/core/tasks/helpers/stepComparison.d.ts +2 -5
  96. package/dist/cjs/core/tasks/helpers/stepComparison.js +2 -3
  97. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +1 -3
  98. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js +3 -4
  99. package/dist/cjs/core/transactionState.d.ts +2 -5
  100. package/dist/cjs/core/transactionState.js +1 -2
  101. package/dist/cjs/core/utils.d.ts +1 -4
  102. package/dist/cjs/core/utils.js +1 -2
  103. package/dist/cjs/errors/SDKError.d.ts +2 -5
  104. package/dist/cjs/errors/SDKError.js +1 -2
  105. package/dist/cjs/errors/SDKError.js.map +1 -1
  106. package/dist/cjs/errors/baseError.d.ts +1 -4
  107. package/dist/cjs/errors/baseError.js +1 -2
  108. package/dist/cjs/errors/baseError.js.map +1 -1
  109. package/dist/cjs/errors/constants.d.ts +1 -4
  110. package/dist/cjs/errors/constants.js +1 -2
  111. package/dist/cjs/errors/errors.d.ts +2 -5
  112. package/dist/cjs/errors/errors.js +1 -2
  113. package/dist/cjs/errors/errors.js.map +1 -1
  114. package/dist/cjs/errors/httpError.d.ts +2 -4
  115. package/dist/cjs/errors/httpError.js +1 -2
  116. package/dist/cjs/errors/httpError.js.map +1 -1
  117. package/dist/cjs/errors/utils/baseErrorRootCause.d.ts +1 -4
  118. package/dist/cjs/errors/utils/baseErrorRootCause.js +1 -2
  119. package/dist/cjs/errors/utils/rootCause.d.ts +1 -4
  120. package/dist/cjs/errors/utils/rootCause.js +1 -2
  121. package/dist/cjs/index.d.ts +17 -16
  122. package/dist/cjs/index.js +24 -21
  123. package/dist/cjs/types/actions.d.ts +1 -3
  124. package/dist/cjs/types/core.d.ts +1 -4
  125. package/dist/cjs/types/execution.d.ts +2 -5
  126. package/dist/cjs/types/request.d.ts +1 -4
  127. package/dist/cjs/utils/abort.d.ts +1 -4
  128. package/dist/cjs/utils/abort.js +1 -2
  129. package/dist/cjs/utils/checkPackageUpdates.d.ts +1 -4
  130. package/dist/cjs/utils/checkPackageUpdates.js +2 -3
  131. package/dist/cjs/utils/convertQuoteToRoute.d.ts +1 -3
  132. package/dist/cjs/utils/convertQuoteToRoute.js +2 -3
  133. package/dist/cjs/utils/decode.d.ts +1 -4
  134. package/dist/cjs/utils/decode.js +1 -2
  135. package/dist/cjs/utils/fetchTxErrorDetails.d.ts +1 -4
  136. package/dist/cjs/utils/fetchTxErrorDetails.js +4 -2
  137. package/dist/cjs/utils/fetchTxErrorDetails.js.map +1 -1
  138. package/dist/cjs/utils/formatUnits.d.ts +1 -4
  139. package/dist/cjs/utils/formatUnits.js +1 -2
  140. package/dist/cjs/utils/getTransactionMessage.d.ts +1 -4
  141. package/dist/cjs/utils/getTransactionMessage.js +1 -2
  142. package/dist/cjs/utils/isGaslessStep.d.ts +13 -0
  143. package/dist/cjs/utils/isGaslessStep.js +20 -0
  144. package/dist/cjs/utils/isGaslessStep.js.map +1 -0
  145. package/dist/cjs/utils/isHex.d.ts +1 -4
  146. package/dist/cjs/utils/isHex.js +1 -2
  147. package/dist/cjs/utils/isRoutesRequest.d.ts +1 -4
  148. package/dist/cjs/utils/isRoutesRequest.js +1 -2
  149. package/dist/cjs/utils/isStep.d.ts +1 -4
  150. package/dist/cjs/utils/isStep.js +1 -2
  151. package/dist/cjs/utils/isToken.d.ts +1 -4
  152. package/dist/cjs/utils/isToken.js +1 -2
  153. package/dist/cjs/utils/lru.d.ts +1 -4
  154. package/dist/cjs/utils/lru.js +1 -2
  155. package/dist/cjs/utils/lru.js.map +1 -1
  156. package/dist/cjs/utils/parseUnits.d.ts +1 -4
  157. package/dist/cjs/utils/parseUnits.js +1 -2
  158. package/dist/cjs/utils/request.d.ts +2 -5
  159. package/dist/cjs/utils/request.js +3 -4
  160. package/dist/cjs/utils/sleep.d.ts +1 -4
  161. package/dist/cjs/utils/sleep.js +1 -2
  162. package/dist/cjs/utils/toQueryString.d.ts +1 -4
  163. package/dist/cjs/utils/toQueryString.js +1 -2
  164. package/dist/cjs/utils/waitForResult.d.ts +1 -4
  165. package/dist/cjs/utils/waitForResult.js +1 -2
  166. package/dist/cjs/utils/withDedupe.d.ts +1 -3
  167. package/dist/cjs/utils/withDedupe.js +1 -2
  168. package/dist/cjs/utils/withDedupe.js.map +1 -1
  169. package/dist/cjs/utils/withTimeout.d.ts +1 -4
  170. package/dist/cjs/utils/withTimeout.js +1 -2
  171. package/dist/cjs/version.d.ts +1 -4
  172. package/dist/cjs/version.js +2 -3
  173. package/dist/cjs/version.js.map +1 -1
  174. package/dist/esm/actions/getChains.d.ts +0 -2
  175. package/dist/esm/actions/getChains.d.ts.map +1 -1
  176. package/dist/esm/actions/getChains.js +1 -2
  177. package/dist/esm/actions/getConnections.d.ts +0 -2
  178. package/dist/esm/actions/getConnections.d.ts.map +1 -1
  179. package/dist/esm/actions/getConnections.js +1 -2
  180. package/dist/esm/actions/getContractCallsQuote.d.ts +0 -2
  181. package/dist/esm/actions/getContractCallsQuote.d.ts.map +1 -1
  182. package/dist/esm/actions/getContractCallsQuote.js +2 -3
  183. package/dist/esm/actions/getGasRecommendation.d.ts +0 -2
  184. package/dist/esm/actions/getGasRecommendation.d.ts.map +1 -1
  185. package/dist/esm/actions/getGasRecommendation.js +2 -3
  186. package/dist/esm/actions/getNameServiceAddress.d.ts +0 -2
  187. package/dist/esm/actions/getNameServiceAddress.d.ts.map +1 -1
  188. package/dist/esm/actions/getNameServiceAddress.js +1 -2
  189. package/dist/esm/actions/getQuote.d.ts +1 -3
  190. package/dist/esm/actions/getQuote.d.ts.map +1 -1
  191. package/dist/esm/actions/getQuote.js +2 -3
  192. package/dist/esm/actions/getRelayedTransactionStatus.d.ts +0 -2
  193. package/dist/esm/actions/getRelayedTransactionStatus.d.ts.map +1 -1
  194. package/dist/esm/actions/getRelayedTransactionStatus.js +3 -4
  195. package/dist/esm/actions/getRelayerQuote.d.ts +16 -10
  196. package/dist/esm/actions/getRelayerQuote.d.ts.map +1 -1
  197. package/dist/esm/actions/getRelayerQuote.js +18 -35
  198. package/dist/esm/actions/getRelayerQuote.js.map +1 -1
  199. package/dist/esm/actions/getRoutes.d.ts +1 -3
  200. package/dist/esm/actions/getRoutes.d.ts.map +1 -1
  201. package/dist/esm/actions/getRoutes.js +3 -4
  202. package/dist/esm/actions/getStatus.d.ts +1 -3
  203. package/dist/esm/actions/getStatus.d.ts.map +1 -1
  204. package/dist/esm/actions/getStatus.js +2 -3
  205. package/dist/esm/actions/getStepTransaction.d.ts +1 -3
  206. package/dist/esm/actions/getStepTransaction.d.ts.map +1 -1
  207. package/dist/esm/actions/getStepTransaction.js +2 -3
  208. package/dist/esm/actions/getToken.d.ts +0 -2
  209. package/dist/esm/actions/getToken.d.ts.map +1 -1
  210. package/dist/esm/actions/getToken.js +2 -3
  211. package/dist/esm/actions/getTokenBalance.d.ts +0 -2
  212. package/dist/esm/actions/getTokenBalance.d.ts.map +1 -1
  213. package/dist/esm/actions/getTokenBalance.js +1 -2
  214. package/dist/esm/actions/getTokenBalances.d.ts +0 -2
  215. package/dist/esm/actions/getTokenBalances.d.ts.map +1 -1
  216. package/dist/esm/actions/getTokenBalances.js +1 -2
  217. package/dist/esm/actions/getTokenBalancesByChain.d.ts +0 -2
  218. package/dist/esm/actions/getTokenBalancesByChain.d.ts.map +1 -1
  219. package/dist/esm/actions/getTokenBalancesByChain.js +1 -2
  220. package/dist/esm/actions/getTokens.d.ts +0 -2
  221. package/dist/esm/actions/getTokens.d.ts.map +1 -1
  222. package/dist/esm/actions/getTokens.js +1 -2
  223. package/dist/esm/actions/getTools.d.ts +0 -2
  224. package/dist/esm/actions/getTools.d.ts.map +1 -1
  225. package/dist/esm/actions/getTools.js +1 -2
  226. package/dist/esm/actions/getTransactionHistory.d.ts +0 -2
  227. package/dist/esm/actions/getTransactionHistory.d.ts.map +1 -1
  228. package/dist/esm/actions/getTransactionHistory.js +1 -2
  229. package/dist/esm/actions/index.d.ts +3 -3
  230. package/dist/esm/actions/index.d.ts.map +1 -1
  231. package/dist/esm/actions/index.js +4 -5
  232. package/dist/esm/actions/index.js.map +1 -1
  233. package/dist/esm/actions/patchContractCalls.d.ts +0 -2
  234. package/dist/esm/actions/patchContractCalls.d.ts.map +1 -1
  235. package/dist/esm/actions/patchContractCalls.js +1 -2
  236. package/dist/esm/actions/relayTransaction.d.ts +0 -2
  237. package/dist/esm/actions/relayTransaction.d.ts.map +1 -1
  238. package/dist/esm/actions/relayTransaction.js +3 -5
  239. package/dist/esm/actions/relayTransaction.js.map +1 -1
  240. package/dist/esm/client/createClient.d.ts +0 -2
  241. package/dist/esm/client/createClient.d.ts.map +1 -1
  242. package/dist/esm/client/createClient.js +2 -3
  243. package/dist/esm/client/findProvider.d.ts +0 -2
  244. package/dist/esm/client/findProvider.d.ts.map +1 -1
  245. package/dist/esm/client/findProvider.js +1 -2
  246. package/dist/esm/client/getClientStorage.d.ts +0 -2
  247. package/dist/esm/client/getClientStorage.d.ts.map +1 -1
  248. package/dist/esm/client/getClientStorage.js +1 -2
  249. package/dist/esm/core/BaseStepExecutionTask.d.ts +0 -2
  250. package/dist/esm/core/BaseStepExecutionTask.d.ts.map +1 -1
  251. package/dist/esm/core/BaseStepExecutionTask.js +1 -2
  252. package/dist/esm/core/BaseStepExecutor.d.ts +3 -5
  253. package/dist/esm/core/BaseStepExecutor.d.ts.map +1 -1
  254. package/dist/esm/core/BaseStepExecutor.js +3 -4
  255. package/dist/esm/core/BaseStepExecutor.js.map +1 -1
  256. package/dist/esm/core/StatusManager.d.ts +1 -2
  257. package/dist/esm/core/StatusManager.d.ts.map +1 -1
  258. package/dist/esm/core/StatusManager.js +1 -2
  259. package/dist/esm/core/StatusManager.js.map +1 -1
  260. package/dist/esm/core/TaskPipeline.d.ts +0 -2
  261. package/dist/esm/core/TaskPipeline.d.ts.map +1 -1
  262. package/dist/esm/core/TaskPipeline.js +1 -2
  263. package/dist/esm/core/TaskPipeline.js.map +1 -1
  264. package/dist/esm/core/actionMessages.d.ts +0 -2
  265. package/dist/esm/core/actionMessages.d.ts.map +1 -1
  266. package/dist/esm/core/actionMessages.js +1 -2
  267. package/dist/esm/core/execution.d.ts +0 -2
  268. package/dist/esm/core/execution.d.ts.map +1 -1
  269. package/dist/esm/core/execution.js +1 -2
  270. package/dist/esm/core/executionState.d.ts +1 -2
  271. package/dist/esm/core/executionState.d.ts.map +1 -1
  272. package/dist/esm/core/executionState.js +1 -2
  273. package/dist/esm/core/prepareRestart.d.ts +0 -2
  274. package/dist/esm/core/prepareRestart.d.ts.map +1 -1
  275. package/dist/esm/core/prepareRestart.js +1 -2
  276. package/dist/esm/core/storage.d.ts +0 -2
  277. package/dist/esm/core/storage.d.ts.map +1 -1
  278. package/dist/esm/core/storage.js +1 -2
  279. package/dist/esm/core/storage.js.map +1 -1
  280. package/dist/esm/core/tasks/CheckBalanceTask.d.ts +0 -2
  281. package/dist/esm/core/tasks/CheckBalanceTask.d.ts.map +1 -1
  282. package/dist/esm/core/tasks/CheckBalanceTask.js +1 -2
  283. package/dist/esm/core/tasks/CheckBalanceTask.js.map +1 -1
  284. package/dist/esm/core/tasks/PrepareTransactionTask.d.ts +0 -2
  285. package/dist/esm/core/tasks/PrepareTransactionTask.d.ts.map +1 -1
  286. package/dist/esm/core/tasks/PrepareTransactionTask.js +2 -3
  287. package/dist/esm/core/tasks/PrepareTransactionTask.js.map +1 -1
  288. package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts +0 -2
  289. package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -1
  290. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +2 -3
  291. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  292. package/dist/esm/core/tasks/helpers/checkBalance.d.ts +0 -2
  293. package/dist/esm/core/tasks/helpers/checkBalance.d.ts.map +1 -1
  294. package/dist/esm/core/tasks/helpers/checkBalance.js +2 -3
  295. package/dist/esm/core/tasks/helpers/getStepStatusRequest.d.ts +0 -2
  296. package/dist/esm/core/tasks/helpers/getStepStatusRequest.d.ts.map +1 -1
  297. package/dist/esm/core/tasks/helpers/getStepStatusRequest.js +1 -2
  298. package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts +0 -2
  299. package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts.map +1 -1
  300. package/dist/esm/core/tasks/helpers/getTransactionRequestData.js +1 -2
  301. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.d.ts +0 -2
  302. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.d.ts.map +1 -1
  303. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.js +1 -2
  304. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.js.map +1 -1
  305. package/dist/esm/core/tasks/helpers/stepComparison.d.ts +1 -3
  306. package/dist/esm/core/tasks/helpers/stepComparison.d.ts.map +1 -1
  307. package/dist/esm/core/tasks/helpers/stepComparison.js +2 -3
  308. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +1 -2
  309. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -1
  310. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js +3 -4
  311. package/dist/esm/core/transactionState.d.ts +1 -3
  312. package/dist/esm/core/transactionState.d.ts.map +1 -1
  313. package/dist/esm/core/transactionState.js +1 -2
  314. package/dist/esm/core/utils.d.ts +0 -2
  315. package/dist/esm/core/utils.d.ts.map +1 -1
  316. package/dist/esm/core/utils.js +1 -2
  317. package/dist/esm/errors/SDKError.d.ts +1 -3
  318. package/dist/esm/errors/SDKError.d.ts.map +1 -1
  319. package/dist/esm/errors/SDKError.js +1 -2
  320. package/dist/esm/errors/SDKError.js.map +1 -1
  321. package/dist/esm/errors/baseError.d.ts +0 -2
  322. package/dist/esm/errors/baseError.d.ts.map +1 -1
  323. package/dist/esm/errors/baseError.js +1 -2
  324. package/dist/esm/errors/baseError.js.map +1 -1
  325. package/dist/esm/errors/constants.d.ts +0 -2
  326. package/dist/esm/errors/constants.d.ts.map +1 -1
  327. package/dist/esm/errors/constants.js +1 -2
  328. package/dist/esm/errors/errors.d.ts +1 -3
  329. package/dist/esm/errors/errors.d.ts.map +1 -1
  330. package/dist/esm/errors/errors.js +1 -2
  331. package/dist/esm/errors/errors.js.map +1 -1
  332. package/dist/esm/errors/httpError.d.ts +2 -3
  333. package/dist/esm/errors/httpError.d.ts.map +1 -1
  334. package/dist/esm/errors/httpError.js +1 -2
  335. package/dist/esm/errors/httpError.js.map +1 -1
  336. package/dist/esm/errors/utils/baseErrorRootCause.d.ts +0 -2
  337. package/dist/esm/errors/utils/baseErrorRootCause.d.ts.map +1 -1
  338. package/dist/esm/errors/utils/baseErrorRootCause.js +1 -2
  339. package/dist/esm/errors/utils/rootCause.d.ts +0 -2
  340. package/dist/esm/errors/utils/rootCause.d.ts.map +1 -1
  341. package/dist/esm/errors/utils/rootCause.js +1 -2
  342. package/dist/esm/index.d.ts +17 -16
  343. package/dist/esm/index.js +23 -22
  344. package/dist/esm/types/actions.d.ts +1 -2
  345. package/dist/esm/types/actions.d.ts.map +1 -1
  346. package/dist/esm/types/core.d.ts +0 -2
  347. package/dist/esm/types/core.d.ts.map +1 -1
  348. package/dist/esm/types/execution.d.ts +1 -3
  349. package/dist/esm/types/execution.d.ts.map +1 -1
  350. package/dist/esm/types/request.d.ts +0 -2
  351. package/dist/esm/types/request.d.ts.map +1 -1
  352. package/dist/esm/utils/abort.d.ts +0 -2
  353. package/dist/esm/utils/abort.d.ts.map +1 -1
  354. package/dist/esm/utils/abort.js +1 -2
  355. package/dist/esm/utils/checkPackageUpdates.d.ts +0 -2
  356. package/dist/esm/utils/checkPackageUpdates.d.ts.map +1 -1
  357. package/dist/esm/utils/checkPackageUpdates.js +2 -3
  358. package/dist/esm/utils/convertQuoteToRoute.d.ts +1 -2
  359. package/dist/esm/utils/convertQuoteToRoute.d.ts.map +1 -1
  360. package/dist/esm/utils/convertQuoteToRoute.js +2 -3
  361. package/dist/esm/utils/decode.d.ts +0 -2
  362. package/dist/esm/utils/decode.d.ts.map +1 -1
  363. package/dist/esm/utils/decode.js +1 -2
  364. package/dist/esm/utils/fetchTxErrorDetails.d.ts +0 -2
  365. package/dist/esm/utils/fetchTxErrorDetails.d.ts.map +1 -1
  366. package/dist/esm/utils/fetchTxErrorDetails.js +4 -2
  367. package/dist/esm/utils/fetchTxErrorDetails.js.map +1 -1
  368. package/dist/esm/utils/formatUnits.d.ts +0 -2
  369. package/dist/esm/utils/formatUnits.d.ts.map +1 -1
  370. package/dist/esm/utils/formatUnits.js +1 -2
  371. package/dist/esm/utils/getTransactionMessage.d.ts +0 -2
  372. package/dist/esm/utils/getTransactionMessage.d.ts.map +1 -1
  373. package/dist/esm/utils/getTransactionMessage.js +1 -2
  374. package/dist/esm/utils/isGaslessStep.d.ts +14 -0
  375. package/dist/esm/utils/isGaslessStep.d.ts.map +1 -0
  376. package/dist/esm/utils/isGaslessStep.js +18 -0
  377. package/dist/esm/utils/isGaslessStep.js.map +1 -0
  378. package/dist/esm/utils/isHex.d.ts +0 -2
  379. package/dist/esm/utils/isHex.d.ts.map +1 -1
  380. package/dist/esm/utils/isHex.js +1 -2
  381. package/dist/esm/utils/isRoutesRequest.d.ts +0 -2
  382. package/dist/esm/utils/isRoutesRequest.d.ts.map +1 -1
  383. package/dist/esm/utils/isRoutesRequest.js +1 -2
  384. package/dist/esm/utils/isStep.d.ts +0 -2
  385. package/dist/esm/utils/isStep.d.ts.map +1 -1
  386. package/dist/esm/utils/isStep.js +1 -2
  387. package/dist/esm/utils/isToken.d.ts +0 -2
  388. package/dist/esm/utils/isToken.d.ts.map +1 -1
  389. package/dist/esm/utils/isToken.js +1 -2
  390. package/dist/esm/utils/lru.d.ts +0 -2
  391. package/dist/esm/utils/lru.d.ts.map +1 -1
  392. package/dist/esm/utils/lru.js +1 -2
  393. package/dist/esm/utils/lru.js.map +1 -1
  394. package/dist/esm/utils/parseUnits.d.ts +0 -2
  395. package/dist/esm/utils/parseUnits.d.ts.map +1 -1
  396. package/dist/esm/utils/parseUnits.js +1 -2
  397. package/dist/esm/utils/request.d.ts +1 -3
  398. package/dist/esm/utils/request.d.ts.map +1 -1
  399. package/dist/esm/utils/request.js +3 -4
  400. package/dist/esm/utils/sleep.d.ts +0 -2
  401. package/dist/esm/utils/sleep.d.ts.map +1 -1
  402. package/dist/esm/utils/sleep.js +1 -2
  403. package/dist/esm/utils/toQueryString.d.ts +0 -2
  404. package/dist/esm/utils/toQueryString.d.ts.map +1 -1
  405. package/dist/esm/utils/toQueryString.js +1 -2
  406. package/dist/esm/utils/waitForResult.d.ts +0 -2
  407. package/dist/esm/utils/waitForResult.d.ts.map +1 -1
  408. package/dist/esm/utils/waitForResult.js +1 -2
  409. package/dist/esm/utils/withDedupe.d.ts +1 -2
  410. package/dist/esm/utils/withDedupe.d.ts.map +1 -1
  411. package/dist/esm/utils/withDedupe.js +1 -2
  412. package/dist/esm/utils/withTimeout.d.ts +0 -2
  413. package/dist/esm/utils/withTimeout.d.ts.map +1 -1
  414. package/dist/esm/utils/withTimeout.js +1 -2
  415. package/dist/esm/version.d.ts +1 -3
  416. package/dist/esm/version.d.ts.map +1 -1
  417. package/dist/esm/version.js +2 -3
  418. package/dist/esm/version.js.map +1 -1
  419. package/package.json +2 -2
  420. package/src/actions/getRelayerQuote.ts +26 -76
  421. package/src/actions/index.ts +3 -1
  422. package/src/actions/relayTransaction.ts +1 -9
  423. package/src/core/tasks/CheckBalanceTask.ts +1 -1
  424. package/src/index.ts +2 -2
  425. package/src/types/core.ts +3 -2
  426. package/src/utils/fetchTxErrorDetails.ts +16 -0
  427. package/src/utils/isGaslessStep.ts +21 -0
  428. package/src/version.ts +1 -1
@@ -1,6 +1,5 @@
1
1
  import { Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, LiFiStepExtended } from "../types/core.js";
2
2
  import { ChainId, LiFiStep } from "@lifi/types";
3
- //#region src/core/StatusManager.d.ts
4
3
  type ActionProps = {
5
4
  step: LiFiStepExtended;
6
5
  type: ExecutionActionType;
@@ -77,5 +76,4 @@ export declare class StatusManager {
77
76
  */
78
77
  private deliverLateTransactionData;
79
78
  }
80
- //#endregion
81
- //# sourceMappingURL=StatusManager.d.ts.map
79
+ export {};
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_core_actionMessages = require("./actionMessages.js");
3
3
  const require_core_executionState = require("./executionState.js");
4
4
  const require_core_transactionState = require("./transactionState.js");
5
- //#region src/core/StatusManager.ts
5
+ // src/core/StatusManager.ts
6
6
  /**
7
7
  * A write is transaction data when it changes one of these fields. `txLink`,
8
8
  * `signedAt` and `callCount` travel with such a write but never trigger one:
@@ -255,7 +255,6 @@ var StatusManager = class {
255
255
  }
256
256
  }
257
257
  };
258
- //#endregion
259
258
  exports.StatusManager = StatusManager;
260
259
 
261
260
  //# sourceMappingURL=StatusManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatusManager.js","names":["hasOpenTransaction","TRANSACTION_ACTION_TYPES","hasStepOpenTransaction","getActionMessage","CLEARED_TRANSACTION_FIELDS","executionState"],"sources":["../../../src/core/StatusManager.ts"],"sourcesContent":["import type { ChainId, LiFiStep } from '@lifi/types'\nimport type {\n Execution,\n ExecutionAction,\n ExecutionActionStatus,\n ExecutionActionType,\n LiFiStepExtended,\n RouteExtended,\n UpdateRouteHook,\n} from '../types/core.js'\nimport { getActionMessage } from './actionMessages.js'\nimport { executionState } from './executionState.js'\nimport {\n CLEARED_TRANSACTION_FIELDS,\n hasOpenTransaction,\n hasStepOpenTransaction,\n TRANSACTION_ACTION_TYPES,\n} from './transactionState.js'\n\ntype ActionProps = {\n step: LiFiStepExtended\n type: ExecutionActionType\n chainId: ChainId\n status: ExecutionActionStatus\n}\n\n/**\n * The route and hook of an execution that `stopRouteExecution` ended. A task\n * that was still running (e.g. waiting in the wallet prompt) writes its\n * transaction data later; without these the write would never reach the\n * integrator, and a resume of the stored route would sign again.\n * `startCount` is `executionState.startCount` at the stop.\n */\ntype StoppedExecution = {\n route: RouteExtended\n updateRouteHook?: UpdateRouteHook\n startCount: number\n}\n\n/**\n * A write is transaction data when it changes one of these fields. `txLink`,\n * `signedAt` and `callCount` travel with such a write but never trigger one:\n * the status poll rewrites `txLink` every few seconds, and `callCount` comes\n * only with a `taskId`.\n */\nconst TRANSACTION_KEYS = ['txHash', 'txHex', 'taskId', 'txFinal'] as const\n\ntype TransactionFields = Pick<\n ExecutionAction,\n (typeof TRANSACTION_KEYS)[number]\n>\n\nconst readTransaction = (action: ExecutionAction): TransactionFields => ({\n txHash: action.txHash,\n txHex: action.txHex,\n taskId: action.taskId,\n txFinal: action.txFinal,\n})\n\n/** True when the write changed a transaction field, also to `undefined`. */\nconst changesTransaction = (\n before: TransactionFields,\n action: ExecutionAction\n): boolean => TRANSACTION_KEYS.some((key) => action[key] !== before[key])\n\n/**\n * Copies a late transaction into the route of a newer execution of the same\n * route id, running or ended. The step's objects are changed in place: a\n * running executor holds them, so its selector and its pre-sign guard see\n * the transaction. Returns true when something changed.\n */\nconst mergeLateTransaction = (\n liveRoute: RouteExtended,\n lateStep: LiFiStepExtended,\n lateAction: ExecutionAction\n): boolean => {\n // Cleared or final: the newer execution needs nothing from it.\n if (!hasOpenTransaction(lateAction)) {\n return false\n }\n const liveStep = liveRoute.steps.find(\n (routeStep) => routeStep.id === lateStep.id\n )\n if (!liveStep) {\n return false\n }\n if (!liveStep.execution) {\n liveStep.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [structuredClone(lateAction)],\n }\n } else {\n const liveAction = liveStep.execution.actions.find(\n (action) => action.type === lateAction.type\n )\n if (!liveAction) {\n liveStep.execution.actions.push(structuredClone(lateAction))\n } else if (hasOpenTransaction(liveAction)) {\n // The live action already has an open transaction (its own, or one\n // merged earlier); it is kept.\n return false\n } else {\n // Every field of `CLEARED_TRANSACTION_FIELDS`, so a stale `txFinal`\n // goes and the action is open. `txType` goes with them: the live one\n // described no open transaction.\n Object.assign(liveAction, {\n txHash: lateAction.txHash,\n txLink: lateAction.txLink,\n txHex: lateAction.txHex,\n txFinal: lateAction.txFinal,\n taskId: lateAction.taskId,\n callCount: lateAction.callCount,\n txType: lateAction.txType,\n })\n }\n }\n // `signedAt` is the signing time of the step's own transaction: an\n // allowance does not set it, and a write without one keeps the live time.\n const signedAt = lateStep.execution?.signedAt\n if (\n TRANSACTION_ACTION_TYPES.includes(lateAction.type) &&\n signedAt !== undefined\n ) {\n liveStep.execution.signedAt = signedAt\n }\n return true\n}\n\n/**\n * Manages status updates of a route and provides various functions for tracking actions.\n */\nexport class StatusManager {\n private readonly routeId: string\n private shouldUpdate = true\n private stoppedExecution?: StoppedExecution\n\n constructor(routeId: string) {\n this.routeId = routeId\n }\n\n /**\n * Initializes the execution object of a Step.\n * @param step The current step in execution\n * @returns The initialized execution object for this step\n */\n initializeExecution = (step: LiFiStepExtended): Execution => {\n if (!step.execution) {\n step.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [],\n }\n this.updateStepInRoute(step)\n }\n\n // Change status to PENDING after resuming from FAILED\n if (step.execution.status === 'FAILED') {\n step.execution.startedAt = Date.now()\n step.execution.status = 'PENDING'\n // Keep the signing time while a signed transaction may still land: the\n // resume path uses it to decide when stored bytes are too old to resend\n // or old enough to be declared dropped.\n if (!hasStepOpenTransaction(step)) {\n step.execution.signedAt = undefined\n }\n step.execution.error = undefined\n this.updateStepInRoute(step)\n }\n\n return step.execution\n }\n\n /**\n * Updates the execution object of a Step.\n * @param step The current step in execution\n * @param execution Partial execution data to merge\n * @returns The step with the updated execution object\n */\n updateExecution(\n step: LiFiStepExtended,\n execution: Partial<Execution>\n ): LiFiStep {\n if (!step.execution) {\n throw Error(\"Can't update empty execution.\")\n }\n step.execution = {\n ...step.execution,\n ...execution,\n }\n this.updateStepInRoute(step)\n return step\n }\n\n /**\n * Finds an action of the specified type in the step's execution\n * @param step The step to search in\n * @param type The action type to find\n * @returns The found action or undefined if not found\n */\n findAction(\n step: LiFiStepExtended,\n type: ExecutionActionType\n ): ExecutionAction | undefined {\n if (!step.execution?.actions) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const action = step.execution.actions.find((p) => p.type === type)\n\n return action\n }\n\n /**\n * Create and push a new action into the execution.\n * Caller is responsible for ensuring an action of this type does not already exist.\n * @param step The step that should contain the new action.\n * @param type Type of the action.\n * @param chainId Chain Id of the action.\n * @param status The initial status for the new action.\n * @returns The created action.\n */\n createAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const newAction: ExecutionAction = {\n type,\n message: getActionMessage(type, status),\n status,\n chainId,\n }\n\n step.execution.actions.push(newAction)\n this.updateStepInRoute(step)\n return newAction\n }\n\n /**\n * Find an existing action by type and update it, or create a new one if none exists.\n * @param step The step that should contain the action.\n * @param type Type of the action. Used to identify already existing actions.\n * @param chainId Chain Id of the action (used when creating).\n * @param status The status to set on the found or newly created action.\n * @returns The updated or newly created action.\n */\n initializeAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n const action = this.findAction(step, type)\n\n if (action) {\n return this.updateAction(step, type, status, {\n error: undefined,\n // A final outcome is dead. A new attempt starts without its data, so\n // the pre-sign guard does not mistake it for an open transaction (the\n // route was run again without `prepareRestart`, e.g. `executeRoute`).\n ...(action.status === 'FAILED' &&\n action.txFinal === true &&\n CLEARED_TRANSACTION_FIELDS),\n })\n }\n\n return this.createAction({ step, type, chainId, status })\n }\n\n /**\n * Update an action object.\n * @param step The step where the action should be updated\n * @param type The action type to update\n * @param status The status the action gets.\n * @param [params] Additional parameters to append to the action.\n * @returns The updated action\n */\n updateAction = (\n step: LiFiStepExtended,\n type: ExecutionActionType,\n status: ExecutionActionStatus,\n params?: Partial<ExecutionAction & { signedAt?: number }>\n ): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Can't update an empty step execution.\")\n }\n const currentAction = this.findAction(step, type)\n\n if (!currentAction) {\n throw new Error(\"Can't find an action for the given type.\")\n }\n // Read before the write: after a stop, only a write that changes the\n // transaction reaches the integrator.\n const transactionBefore = this.shouldUpdate\n ? undefined\n : readTransaction(currentAction)\n\n switch (status) {\n case 'CANCELLED':\n break\n case 'FAILED':\n step.execution.status = 'FAILED'\n if (params?.error) {\n step.execution.error = params.error\n }\n break\n case 'DONE':\n break\n case 'PENDING':\n step.execution.status = 'PENDING'\n if (params?.signedAt) {\n step.execution.signedAt = params.signedAt\n }\n break\n case 'RESET_REQUIRED':\n case 'MESSAGE_REQUIRED':\n case 'ACTION_REQUIRED':\n step.execution.status = 'ACTION_REQUIRED'\n break\n default:\n break\n }\n\n currentAction.status = status\n currentAction.message = getActionMessage(type, status)\n // set extra parameters or overwrite the standard params set in the switch statement\n if (params) {\n const { signedAt: _signedAt, ...rest } = params\n Object.assign(currentAction, rest)\n }\n // Sort actions, the ones with DONE status go first\n step.execution.actions = [\n ...step.execution.actions.filter((action) => action.status === 'DONE'),\n ...step.execution.actions.filter((action) => action.status !== 'DONE'),\n ]\n if (\n transactionBefore &&\n changesTransaction(transactionBefore, currentAction)\n ) {\n this.deliverLateTransactionData(step, currentAction)\n } else {\n this.updateStepInRoute(step) // updates the step in the route\n }\n return currentAction\n }\n\n updateStepInRoute = (step: LiFiStep): LiFiStep => {\n if (!this.shouldUpdate) {\n return step\n }\n const data = executionState.get(this.routeId)\n\n if (!data) {\n throw new Error('Execution data not found.')\n }\n\n const stepIndex = data.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n\n if (stepIndex === -1) {\n throw new Error(\"Couldn't find a step to update.\")\n }\n\n // A shallow copy on purpose: the route's step must keep sharing the\n // step's `execution` object. `mergeLateTransaction` changes the live\n // route in place, and the running sign task's check after the wallet\n // must see the merge (pinned by the stop-and-resume race test in\n // `sdk-provider-ethereum/src/core/flows/reload.unit.spec.ts`).\n data.route.steps[stepIndex] = { ...data.route.steps[stepIndex], ...step }\n\n data.executionOptions?.updateRouteHook?.(data.route)\n return data.route.steps[stepIndex]\n }\n\n allowUpdates(value: boolean): void {\n this.shouldUpdate = value\n if (value) {\n this.stoppedExecution = undefined\n return\n }\n // `stopRouteExecution` turns updates off right before it deletes the\n // execution state, so the state is still here to keep.\n const data = executionState.get(this.routeId)\n if (data) {\n this.stoppedExecution = {\n route: data.route,\n updateRouteHook: data.executionOptions?.updateRouteHook,\n startCount: executionState.startCount(this.routeId),\n }\n }\n }\n\n /**\n * A write of transaction data after `stopRouteExecution`. With a newer\n * execution of the same route id running, the transaction is merged into\n * it. If no execution of the route started since the stop, the kept route\n * is updated and the kept hook is called. If a newer execution started and\n * ended since the stop, the transaction is merged into the route of the\n * last ended execution, and its hook is called.\n */\n private deliverLateTransactionData(\n step: LiFiStepExtended,\n lateAction: ExecutionAction\n ): void {\n const stopped = this.stoppedExecution\n if (!stopped) {\n return\n }\n // A late write must never fail the task that made it: its catch block\n // would mark the action FAILED while the transaction may still land.\n try {\n // Always a newer execution: `stopRouteExecution` deleted this one.\n const live = executionState.get(this.routeId)\n if (live) {\n if (mergeLateTransaction(live.route, step, lateAction)) {\n live.executionOptions?.updateRouteHook?.(live.route)\n }\n return\n }\n // A newer execution started and ended since the stop: the integrator\n // stored its route, which the kept one would roll back. The late\n // transaction goes into that route instead. With the records of the\n // route freed (no run in flight, `startCount` 0) the write is dropped.\n if (executionState.startCount(this.routeId) !== stopped.startCount) {\n const ended = executionState.lastEnded(this.routeId)\n if (ended && mergeLateTransaction(ended.route, step, lateAction)) {\n ended.updateRouteHook?.(ended.route)\n }\n return\n }\n const stepIndex = stopped.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n if (stepIndex === -1) {\n return\n }\n stopped.route.steps[stepIndex] = {\n ...stopped.route.steps[stepIndex],\n ...step,\n }\n stopped.updateRouteHook?.(stopped.route)\n } catch (error) {\n // Not rethrown, see above. The integrator's hook can throw here, so\n // the error is reported in development, as other swallowed errors are.\n if (process.env.NODE_ENV === 'development') {\n console.debug('Delivering late transaction data failed.', error)\n }\n }\n }\n}\n"],"mappings":";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eAC3B,QAAQ,MAAM,4CAA4C,KAAK;EAEnE;CACF;AACF"}
1
+ {"version":3,"file":"StatusManager.js","names":["hasOpenTransaction","TRANSACTION_ACTION_TYPES","hasStepOpenTransaction","getActionMessage","CLEARED_TRANSACTION_FIELDS","executionState"],"sources":["../../../src/core/StatusManager.ts"],"sourcesContent":["import type { ChainId, LiFiStep } from '@lifi/types'\nimport type {\n Execution,\n ExecutionAction,\n ExecutionActionStatus,\n ExecutionActionType,\n LiFiStepExtended,\n RouteExtended,\n UpdateRouteHook,\n} from '../types/core.js'\nimport { getActionMessage } from './actionMessages.js'\nimport { executionState } from './executionState.js'\nimport {\n CLEARED_TRANSACTION_FIELDS,\n hasOpenTransaction,\n hasStepOpenTransaction,\n TRANSACTION_ACTION_TYPES,\n} from './transactionState.js'\n\ntype ActionProps = {\n step: LiFiStepExtended\n type: ExecutionActionType\n chainId: ChainId\n status: ExecutionActionStatus\n}\n\n/**\n * The route and hook of an execution that `stopRouteExecution` ended. A task\n * that was still running (e.g. waiting in the wallet prompt) writes its\n * transaction data later; without these the write would never reach the\n * integrator, and a resume of the stored route would sign again.\n * `startCount` is `executionState.startCount` at the stop.\n */\ntype StoppedExecution = {\n route: RouteExtended\n updateRouteHook?: UpdateRouteHook\n startCount: number\n}\n\n/**\n * A write is transaction data when it changes one of these fields. `txLink`,\n * `signedAt` and `callCount` travel with such a write but never trigger one:\n * the status poll rewrites `txLink` every few seconds, and `callCount` comes\n * only with a `taskId`.\n */\nconst TRANSACTION_KEYS = ['txHash', 'txHex', 'taskId', 'txFinal'] as const\n\ntype TransactionFields = Pick<\n ExecutionAction,\n (typeof TRANSACTION_KEYS)[number]\n>\n\nconst readTransaction = (action: ExecutionAction): TransactionFields => ({\n txHash: action.txHash,\n txHex: action.txHex,\n taskId: action.taskId,\n txFinal: action.txFinal,\n})\n\n/** True when the write changed a transaction field, also to `undefined`. */\nconst changesTransaction = (\n before: TransactionFields,\n action: ExecutionAction\n): boolean => TRANSACTION_KEYS.some((key) => action[key] !== before[key])\n\n/**\n * Copies a late transaction into the route of a newer execution of the same\n * route id, running or ended. The step's objects are changed in place: a\n * running executor holds them, so its selector and its pre-sign guard see\n * the transaction. Returns true when something changed.\n */\nconst mergeLateTransaction = (\n liveRoute: RouteExtended,\n lateStep: LiFiStepExtended,\n lateAction: ExecutionAction\n): boolean => {\n // Cleared or final: the newer execution needs nothing from it.\n if (!hasOpenTransaction(lateAction)) {\n return false\n }\n const liveStep = liveRoute.steps.find(\n (routeStep) => routeStep.id === lateStep.id\n )\n if (!liveStep) {\n return false\n }\n if (!liveStep.execution) {\n liveStep.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [structuredClone(lateAction)],\n }\n } else {\n const liveAction = liveStep.execution.actions.find(\n (action) => action.type === lateAction.type\n )\n if (!liveAction) {\n liveStep.execution.actions.push(structuredClone(lateAction))\n } else if (hasOpenTransaction(liveAction)) {\n // The live action already has an open transaction (its own, or one\n // merged earlier); it is kept.\n return false\n } else {\n // Every field of `CLEARED_TRANSACTION_FIELDS`, so a stale `txFinal`\n // goes and the action is open. `txType` goes with them: the live one\n // described no open transaction.\n Object.assign(liveAction, {\n txHash: lateAction.txHash,\n txLink: lateAction.txLink,\n txHex: lateAction.txHex,\n txFinal: lateAction.txFinal,\n taskId: lateAction.taskId,\n callCount: lateAction.callCount,\n txType: lateAction.txType,\n })\n }\n }\n // `signedAt` is the signing time of the step's own transaction: an\n // allowance does not set it, and a write without one keeps the live time.\n const signedAt = lateStep.execution?.signedAt\n if (\n TRANSACTION_ACTION_TYPES.includes(lateAction.type) &&\n signedAt !== undefined\n ) {\n liveStep.execution.signedAt = signedAt\n }\n return true\n}\n\n/**\n * Manages status updates of a route and provides various functions for tracking actions.\n */\nexport class StatusManager {\n private readonly routeId: string\n private shouldUpdate = true\n private stoppedExecution?: StoppedExecution\n\n constructor(routeId: string) {\n this.routeId = routeId\n }\n\n /**\n * Initializes the execution object of a Step.\n * @param step The current step in execution\n * @returns The initialized execution object for this step\n */\n initializeExecution = (step: LiFiStepExtended): Execution => {\n if (!step.execution) {\n step.execution = {\n startedAt: Date.now(),\n status: 'PENDING',\n actions: [],\n }\n this.updateStepInRoute(step)\n }\n\n // Change status to PENDING after resuming from FAILED\n if (step.execution.status === 'FAILED') {\n step.execution.startedAt = Date.now()\n step.execution.status = 'PENDING'\n // Keep the signing time while a signed transaction may still land: the\n // resume path uses it to decide when stored bytes are too old to resend\n // or old enough to be declared dropped.\n if (!hasStepOpenTransaction(step)) {\n step.execution.signedAt = undefined\n }\n step.execution.error = undefined\n this.updateStepInRoute(step)\n }\n\n return step.execution\n }\n\n /**\n * Updates the execution object of a Step.\n * @param step The current step in execution\n * @param execution Partial execution data to merge\n * @returns The step with the updated execution object\n */\n updateExecution(\n step: LiFiStepExtended,\n execution: Partial<Execution>\n ): LiFiStep {\n if (!step.execution) {\n throw Error(\"Can't update empty execution.\")\n }\n step.execution = {\n ...step.execution,\n ...execution,\n }\n this.updateStepInRoute(step)\n return step\n }\n\n /**\n * Finds an action of the specified type in the step's execution\n * @param step The step to search in\n * @param type The action type to find\n * @returns The found action or undefined if not found\n */\n findAction(\n step: LiFiStepExtended,\n type: ExecutionActionType\n ): ExecutionAction | undefined {\n if (!step.execution?.actions) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const action = step.execution.actions.find((p) => p.type === type)\n\n return action\n }\n\n /**\n * Create and push a new action into the execution.\n * Caller is responsible for ensuring an action of this type does not already exist.\n * @param step The step that should contain the new action.\n * @param type Type of the action.\n * @param chainId Chain Id of the action.\n * @param status The initial status for the new action.\n * @returns The created action.\n */\n createAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Execution hasn't been initialized.\")\n }\n\n const newAction: ExecutionAction = {\n type,\n message: getActionMessage(type, status),\n status,\n chainId,\n }\n\n step.execution.actions.push(newAction)\n this.updateStepInRoute(step)\n return newAction\n }\n\n /**\n * Find an existing action by type and update it, or create a new one if none exists.\n * @param step The step that should contain the action.\n * @param type Type of the action. Used to identify already existing actions.\n * @param chainId Chain Id of the action (used when creating).\n * @param status The status to set on the found or newly created action.\n * @returns The updated or newly created action.\n */\n initializeAction = ({\n step,\n type,\n chainId,\n status,\n }: ActionProps): ExecutionAction => {\n const action = this.findAction(step, type)\n\n if (action) {\n return this.updateAction(step, type, status, {\n error: undefined,\n // A final outcome is dead. A new attempt starts without its data, so\n // the pre-sign guard does not mistake it for an open transaction (the\n // route was run again without `prepareRestart`, e.g. `executeRoute`).\n ...(action.status === 'FAILED' &&\n action.txFinal === true &&\n CLEARED_TRANSACTION_FIELDS),\n })\n }\n\n return this.createAction({ step, type, chainId, status })\n }\n\n /**\n * Update an action object.\n * @param step The step where the action should be updated\n * @param type The action type to update\n * @param status The status the action gets.\n * @param [params] Additional parameters to append to the action.\n * @returns The updated action\n */\n updateAction = (\n step: LiFiStepExtended,\n type: ExecutionActionType,\n status: ExecutionActionStatus,\n params?: Partial<ExecutionAction & { signedAt?: number }>\n ): ExecutionAction => {\n if (!step.execution) {\n throw new Error(\"Can't update an empty step execution.\")\n }\n const currentAction = this.findAction(step, type)\n\n if (!currentAction) {\n throw new Error(\"Can't find an action for the given type.\")\n }\n // Read before the write: after a stop, only a write that changes the\n // transaction reaches the integrator.\n const transactionBefore = this.shouldUpdate\n ? undefined\n : readTransaction(currentAction)\n\n switch (status) {\n case 'CANCELLED':\n break\n case 'FAILED':\n step.execution.status = 'FAILED'\n if (params?.error) {\n step.execution.error = params.error\n }\n break\n case 'DONE':\n break\n case 'PENDING':\n step.execution.status = 'PENDING'\n if (params?.signedAt) {\n step.execution.signedAt = params.signedAt\n }\n break\n case 'RESET_REQUIRED':\n case 'MESSAGE_REQUIRED':\n case 'ACTION_REQUIRED':\n step.execution.status = 'ACTION_REQUIRED'\n break\n default:\n break\n }\n\n currentAction.status = status\n currentAction.message = getActionMessage(type, status)\n // set extra parameters or overwrite the standard params set in the switch statement\n if (params) {\n const { signedAt: _signedAt, ...rest } = params\n Object.assign(currentAction, rest)\n }\n // Sort actions, the ones with DONE status go first\n step.execution.actions = [\n ...step.execution.actions.filter((action) => action.status === 'DONE'),\n ...step.execution.actions.filter((action) => action.status !== 'DONE'),\n ]\n if (\n transactionBefore &&\n changesTransaction(transactionBefore, currentAction)\n ) {\n this.deliverLateTransactionData(step, currentAction)\n } else {\n this.updateStepInRoute(step) // updates the step in the route\n }\n return currentAction\n }\n\n updateStepInRoute = (step: LiFiStep): LiFiStep => {\n if (!this.shouldUpdate) {\n return step\n }\n const data = executionState.get(this.routeId)\n\n if (!data) {\n throw new Error('Execution data not found.')\n }\n\n const stepIndex = data.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n\n if (stepIndex === -1) {\n throw new Error(\"Couldn't find a step to update.\")\n }\n\n // A shallow copy on purpose: the route's step must keep sharing the\n // step's `execution` object. `mergeLateTransaction` changes the live\n // route in place, and the running sign task's check after the wallet\n // must see the merge (pinned by the stop-and-resume race test in\n // `sdk-provider-ethereum/src/core/flows/reload.unit.spec.ts`).\n data.route.steps[stepIndex] = { ...data.route.steps[stepIndex], ...step }\n\n data.executionOptions?.updateRouteHook?.(data.route)\n return data.route.steps[stepIndex]\n }\n\n allowUpdates(value: boolean): void {\n this.shouldUpdate = value\n if (value) {\n this.stoppedExecution = undefined\n return\n }\n // `stopRouteExecution` turns updates off right before it deletes the\n // execution state, so the state is still here to keep.\n const data = executionState.get(this.routeId)\n if (data) {\n this.stoppedExecution = {\n route: data.route,\n updateRouteHook: data.executionOptions?.updateRouteHook,\n startCount: executionState.startCount(this.routeId),\n }\n }\n }\n\n /**\n * A write of transaction data after `stopRouteExecution`. With a newer\n * execution of the same route id running, the transaction is merged into\n * it. If no execution of the route started since the stop, the kept route\n * is updated and the kept hook is called. If a newer execution started and\n * ended since the stop, the transaction is merged into the route of the\n * last ended execution, and its hook is called.\n */\n private deliverLateTransactionData(\n step: LiFiStepExtended,\n lateAction: ExecutionAction\n ): void {\n const stopped = this.stoppedExecution\n if (!stopped) {\n return\n }\n // A late write must never fail the task that made it: its catch block\n // would mark the action FAILED while the transaction may still land.\n try {\n // Always a newer execution: `stopRouteExecution` deleted this one.\n const live = executionState.get(this.routeId)\n if (live) {\n if (mergeLateTransaction(live.route, step, lateAction)) {\n live.executionOptions?.updateRouteHook?.(live.route)\n }\n return\n }\n // A newer execution started and ended since the stop: the integrator\n // stored its route, which the kept one would roll back. The late\n // transaction goes into that route instead. With the records of the\n // route freed (no run in flight, `startCount` 0) the write is dropped.\n if (executionState.startCount(this.routeId) !== stopped.startCount) {\n const ended = executionState.lastEnded(this.routeId)\n if (ended && mergeLateTransaction(ended.route, step, lateAction)) {\n ended.updateRouteHook?.(ended.route)\n }\n return\n }\n const stepIndex = stopped.route.steps.findIndex(\n (routeStep) => routeStep.id === step.id\n )\n if (stepIndex === -1) {\n return\n }\n stopped.route.steps[stepIndex] = {\n ...stopped.route.steps[stepIndex],\n ...step,\n }\n stopped.updateRouteHook?.(stopped.route)\n } catch (error) {\n // Not rethrown, see above. The integrator's hook can throw here, so\n // the error is reported in development, as other swallowed errors are.\n if (process.env.NODE_ENV === 'development') {\n console.debug('Delivering late transaction data failed.', error)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AA6CA,MAAM,mBAAmB;CAAC;CAAU;CAAS;CAAU;AAAS;AAOhE,MAAM,mBAAmB,YAAgD;CACvE,QAAQ,OAAO;CACf,OAAO,OAAO;CACd,QAAQ,OAAO;CACf,SAAS,OAAO;AAClB;;AAGA,MAAM,sBACJ,QACA,WACY,iBAAiB,MAAM,QAAQ,OAAO,SAAS,OAAO,IAAI;;;;;;;AAQxE,MAAM,wBACJ,WACA,UACA,eACY;CAEZ,IAAI,CAACA,8BAAAA,mBAAmB,UAAU,GAChC,OAAO;CAET,MAAM,WAAW,UAAU,MAAM,MAC9B,cAAc,UAAU,OAAO,SAAS,EAC3C;CACA,IAAI,CAAC,UACH,OAAO;CAET,IAAI,CAAC,SAAS,WACZ,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AAe,WAAW,KAAK,OAAO;EACpD;CAEJ;;;;;;;;;CAUQ,2BACN,MACA,YACM;EACN,MAAM,UAAU,KAAK;EACrB,IAAI,CAAC,SACH;EAIF,IAAI;GAEF,MAAM,OAAOA,4BAAAA,eAAe,IAAI,KAAK,OAAO;GAC5C,IAAI,MAAM;IACR,IAAI,qBAAqB,KAAK,OAAO,MAAM,UAAU,GACnD,KAAK,kBAAkB,kBAAkB,KAAK,KAAK;IAErD;GACF;GAKA,IAAIA,4BAAAA,eAAe,WAAW,KAAK,OAAO,MAAM,QAAQ,YAAY;IAClE,MAAM,QAAQA,4BAAAA,eAAe,UAAU,KAAK,OAAO;IACnD,IAAI,SAAS,qBAAqB,MAAM,OAAO,MAAM,UAAU,GAC7D,MAAM,kBAAkB,MAAM,KAAK;IAErC;GACF;GACA,MAAM,YAAY,QAAQ,MAAM,MAAM,WACnC,cAAc,UAAU,OAAO,KAAK,EACvC;GACA,IAAI,cAAc,IAChB;GAEF,QAAQ,MAAM,MAAM,aAAa;IAC/B,GAAG,QAAQ,MAAM,MAAM;IACvB,GAAG;GACL;GACA,QAAQ,kBAAkB,QAAQ,KAAK;EACzC,SAAS,OAAO;GAGd,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,MAAM,4CAA4C,KAAK;EAEnE;CACF;AACF"}
@@ -1,10 +1,7 @@
1
1
  import { StepExecutorContext, TaskResult } from "../types/execution.js";
2
2
  import { BaseStepExecutionTask } from "./BaseStepExecutionTask.js";
3
- //#region src/core/TaskPipeline.d.ts
4
3
  export declare class TaskPipeline {
5
4
  private readonly tasks;
6
5
  constructor(tasks: BaseStepExecutionTask[]);
7
6
  run(context: StepExecutorContext): Promise<TaskResult>;
8
- }
9
- //#endregion
10
- //# sourceMappingURL=TaskPipeline.d.ts.map
7
+ }
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/core/TaskPipeline.ts
2
+ // src/core/TaskPipeline.ts
3
3
  var TaskPipeline = class {
4
4
  tasks;
5
5
  constructor(tasks) {
@@ -15,7 +15,6 @@ var TaskPipeline = class {
15
15
  return { status: "COMPLETED" };
16
16
  }
17
17
  };
18
- //#endregion
19
18
  exports.TaskPipeline = TaskPipeline;
20
19
 
21
20
  //# sourceMappingURL=TaskPipeline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskPipeline.js","names":[],"sources":["../../../src/core/TaskPipeline.ts"],"sourcesContent":["import type { StepExecutorContext, TaskResult } from '../types/execution.js'\nimport type { BaseStepExecutionTask } from './BaseStepExecutionTask.js'\n\nexport class TaskPipeline {\n private readonly tasks: BaseStepExecutionTask[]\n\n constructor(tasks: BaseStepExecutionTask[]) {\n this.tasks = tasks\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n for (const task of this.tasks) {\n const shouldRun = await task.shouldRun(context)\n if (!shouldRun) {\n continue\n }\n const result = await task.run(context)\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n if (result.context && typeof result.context === 'object') {\n Object.assign(context, result.context)\n }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;AAGA,IAAa,eAAb,MAA0B;CACxB;CAEA,YAAY,OAAgC;EAC1C,KAAK,QAAQ;CACf;CAEA,MAAM,IAAI,SAAmD;EAC3D,KAAK,MAAM,QAAQ,KAAK,OAAO;GAE7B,IAAI,CAAC,MADmB,KAAK,UAAU,OAAO,GAE5C;GAEF,MAAM,SAAS,MAAM,KAAK,IAAI,OAAO;GACrC,IAAI,OAAO,WAAW,UACpB,OAAO,EAAE,QAAQ,SAAS;GAE5B,IAAI,OAAO,WAAW,OAAO,OAAO,YAAY,UAC9C,OAAO,OAAO,SAAS,OAAO,OAAO;EAEzC;EAEA,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
1
+ {"version":3,"file":"TaskPipeline.js","names":[],"sources":["../../../src/core/TaskPipeline.ts"],"sourcesContent":["import type { StepExecutorContext, TaskResult } from '../types/execution.js'\nimport type { BaseStepExecutionTask } from './BaseStepExecutionTask.js'\n\nexport class TaskPipeline {\n private readonly tasks: BaseStepExecutionTask[]\n\n constructor(tasks: BaseStepExecutionTask[]) {\n this.tasks = tasks\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n for (const task of this.tasks) {\n const shouldRun = await task.shouldRun(context)\n if (!shouldRun) {\n continue\n }\n const result = await task.run(context)\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n if (result.context && typeof result.context === 'object') {\n Object.assign(context, result.context)\n }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;AAGA,IAAa,eAAb,MAA0B;CACP;CAEjB,YAAY,OAAgC;EAC1C,KAAK,QAAQ;CACf;CAEA,MAAM,IAAI,SAAmD;EAC3D,KAAK,MAAM,QAAQ,KAAK,OAAO;GAE7B,IAAI,CAAC,MADmB,KAAK,UAAU,OAAO,GAE5C;GAEF,MAAM,SAAS,MAAM,KAAK,IAAI,OAAO;GACrC,IAAI,OAAO,WAAW,UACpB,OAAO,EAAE,QAAQ,SAAS;GAE5B,IAAI,OAAO,WAAW,OAAO,OAAO,YAAY,UAC9C,OAAO,OAAO,SAAS,OAAO,OAAO;EAEzC;EAEA,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
@@ -1,7 +1,4 @@
1
1
  import { ExecutionActionStatus, ExecutionActionType } from "../types/core.js";
2
2
  import { StatusMessage, Substatus } from "@lifi/types";
3
- //#region src/core/actionMessages.d.ts
4
3
  export declare function getActionMessage(type: ExecutionActionType, status: ExecutionActionStatus): string | undefined;
5
- export declare function getSubstatusMessage(status: StatusMessage, substatus?: Substatus): string | undefined;
6
- //#endregion
7
- //# sourceMappingURL=actionMessages.d.ts.map
4
+ export declare function getSubstatusMessage(status: StatusMessage, substatus?: Substatus): string | undefined;
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/core/actionMessages.ts
2
+ // src/core/actionMessages.ts
3
3
  const actionMessages = {
4
4
  CHECK_ALLOWANCE: {
5
5
  STARTED: "Checking token allowance",
@@ -74,7 +74,6 @@ function getSubstatusMessage(status, substatus) {
74
74
  if (!substatus) return;
75
75
  return substatusMessages[status][substatus];
76
76
  }
77
- //#endregion
78
77
  exports.getActionMessage = getActionMessage;
79
78
  exports.getSubstatusMessage = getSubstatusMessage;
80
79
 
@@ -1,6 +1,5 @@
1
1
  import { ExecutionOptions, RouteExtended, SDKClient } from "../types/core.js";
2
2
  import { Route } from "@lifi/types";
3
- //#region src/core/execution.d.ts
4
3
  /**
5
4
  * Execute a route.
6
5
  * @param client - The SDK client.
@@ -41,6 +40,4 @@ export declare const getActiveRoutes: () => RouteExtended[];
41
40
  * @param routeId - A route id.
42
41
  * @returns The updated route.
43
42
  */
44
- export declare const getActiveRoute: (routeId: string) => RouteExtended | undefined;
45
- //#endregion
46
- //# sourceMappingURL=execution.d.ts.map
43
+ export declare const getActiveRoute: (routeId: string) => RouteExtended | undefined;
@@ -3,7 +3,7 @@ require("../errors/constants.js");
3
3
  const require_errors_errors = require("../errors/errors.js");
4
4
  const require_core_executionState = require("./executionState.js");
5
5
  const require_core_prepareRestart = require("./prepareRestart.js");
6
- //#region src/core/execution.ts
6
+ // src/core/execution.ts
7
7
  /**
8
8
  * Execute a route.
9
9
  * @param client - The SDK client.
@@ -152,7 +152,6 @@ const getActiveRoutes = () => {
152
152
  const getActiveRoute = (routeId) => {
153
153
  return require_core_executionState.executionState.get(routeId)?.route;
154
154
  };
155
- //#endregion
156
155
  exports.executeRoute = executeRoute;
157
156
  exports.getActiveRoute = getActiveRoute;
158
157
  exports.getActiveRoutes = getActiveRoutes;
@@ -1 +1 @@
1
- {"version":3,"file":"execution.js","names":["executionState","ProviderError","ExecuteStepRetryError"],"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 // Restart from a copy: the caller's route (e.g. an integrator's store) must\n // only change through `updateRouteHook`.\n const restartRoute = structuredClone<RouteExtended>(route)\n prepareRestart(restartRoute)\n\n return executeRoute(client, restartRoute, executionOptions)\n}\n\n/**\n * True while `route` is the execution registered for its id. A stopped run\n * keeps going until its step ends; it must not stop or delete a newer\n * execution of the same route.\n */\nconst ownsExecution = (route: RouteExtended): boolean =>\n executionState.get(route.id)?.route === route\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. A newer execution of the\n // same route id is not ours, also when our executor ignored the stop.\n if (!execution || execution.route !== route) {\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 // A stop during the await did not reach this executor, and a newer\n // execution of the route may run now: do not start the step.\n if (!ownsExecution(route)) {\n return route\n }\n // In flight until the step settles, the retry included: a stop keeps\n // the records a late write of this run needs (`executionState`).\n executionState.retain(route.id)\n // Taken from this execution, not looked up again for the retry: a\n // newer execution of the route id has its own.\n const { signal } = execution.abortController\n let executedStep: LiFiStepExtended\n try {\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 try {\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n undefined,\n signal\n )\n } catch (e) {\n if (e instanceof ExecuteStepRetryError) {\n // A stop ended this run while its first attempt ran: the replay\n // would be new work on a stopped executor.\n if (!stepExecutor.allowExecution) {\n return route\n }\n step.execution = undefined\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n e.retryParams,\n signal\n )\n } else {\n throw e\n }\n }\n } finally {\n executionState.release(route.id)\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' && ownsExecution(route)) {\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 if (ownsExecution(route)) {\n stopRouteExecution(route)\n }\n throw e\n }\n }\n\n // Clean up after the execution\n if (ownsExecution(route)) {\n executionState.delete(route.id)\n }\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 // The abort can run before or after the two steps above: its listeners\n // only clear timers, drop the shared poll and reject promises, and the\n // tasks handle the rejections after this function returns. The\n // `setInteraction` loop must run before `executionState.delete`, because\n // `StatusManager.allowUpdates(false)` keeps the route and hook from the\n // execution state.\n execution.abortController.abort()\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":";;;;;;;;;;;;;;AAqBA,MAAa,eAAe,OAC1B,QACA,OACA,qBAC2B;CAE3B,MAAM,cAAc,gBAAuB,KAAK;CAEhD,IAAI,mBAAmBA,4BAAAA,eAAe,IAAI,YAAY,EAAE,CAAC,EAAE;CAE3D,IAAI,kBACF,OAAO;CAGT,4BAAA,eAAe,OAAO;EAAE,OAAO;EAAa;CAAiB,CAAC;CAC9D,mBAAmB,aAAa,QAAQ,WAAW;CACnD,4BAAA,eAAe,OAAO;EACpB,OAAO;EACP,SAAS;CACX,CAAC;CAED,OAAO;AACT;;;;;;;;;AAUA,MAAa,cAAc,OACzB,QACA,OACA,qBAC2B;CAC3B,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,EAAE;CAE7C,IAAI,WAIE;MAAA,CAHoB,UAAU,UAAU,MACzC,aAAa,CAAC,SAAS,cAEP,GAAG;GAEpB,qBAAqB,OAAO,EAC1B,qBAAqB,kBAAkB,oBACzC,CAAC;GACD,IAAI,CAAC,UAAU,SAEb,MAAM,IAAI,MAAM,oCAAoC;GAEtD,OAAO,UAAU;EACnB;;CAKF,MAAM,eAAe,gBAA+B,KAAK;CACzD,4BAAA,eAAe,YAAY;CAE3B,OAAO,aAAa,QAAQ,cAAc,gBAAgB;AAC5D;;;;;;AAOA,MAAM,iBAAiB,UACrBA,4BAAAA,eAAe,IAAI,MAAM,EAAE,CAAC,EAAE,UAAU;AAE1C,MAAM,eAAe,OACnB,QACA,UAC2B;CAE3B,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,QAAQ,SAAS;EACvD,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AAK,GAClE,mBAAmB,KAAK;GAI1B,IAAI,CAAC,aAAa,gBAChB,OAAO;EAEX,SAAS,GAAG;GACV,IAAI,cAAc,KAAK,GACrB,mBAAmB,KAAK;GAE1B,MAAM;EACR;CACF;CAGA,IAAI,cAAc,KAAK,GACrB,4BAAA,eAAe,OAAO,MAAM,EAAE;CAEhC,OAAO;AACT;;;;;;AAOA,MAAa,wBACX,OACA,YACS;CACT,MAAM,YAAYF,4BAAAA,eAAe,IAAI,MAAM,EAAE;CAC7C,IAAI,CAAC,WACH;CAGF,IAAI,yBAAyB,SAC3B,KAAK,MAAM,YAAY,UAAU,WAC/B,SAAS,eAAe;EACtB,kBAAkB,CAAC,SAAS;EAC5B,cAAc;CAChB,CAAC;CAIL,UAAU,mBAAmB;EAC3B,GAAG,UAAU;EACb,GAAG;CACL;AACF;;;;;;AAOA,MAAa,sBAAsB,UAAwB;CACzD,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,EAAE;CAC7C,IAAI,CAAC,WACH,OAAO;CAGT,KAAK,MAAM,YAAY,UAAU,WAC/B,SAAS,eAAe;EACtB,kBAAkB;EAClB,cAAc;EACd,gBAAgB;CAClB,CAAC;CAEH,4BAAA,eAAe,OAAO,MAAM,EAAE;CAO9B,UAAU,gBAAgB,MAAM;CAChC,OAAO,UAAU;AACnB;;;;;AAMA,MAAa,wBAAyC;CACpD,OAAO,OAAO,OAAOA,4BAAAA,eAAe,KAAK,CAAC,CACvC,KAAK,SAAS,MAAM,KAAK,CAAC,CAC1B,OAAO,OAAO;AACnB;;;;;;AAOA,MAAa,kBAAkB,YAA+C;CAC5E,OAAOA,4BAAAA,eAAe,IAAI,OAAO,CAAC,EAAE;AACtC"}
1
+ {"version":3,"file":"execution.js","names":["executionState","prepareRestart","ProviderError","ExecuteStepRetryError"],"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 // Restart from a copy: the caller's route (e.g. an integrator's store) must\n // only change through `updateRouteHook`.\n const restartRoute = structuredClone<RouteExtended>(route)\n prepareRestart(restartRoute)\n\n return executeRoute(client, restartRoute, executionOptions)\n}\n\n/**\n * True while `route` is the execution registered for its id. A stopped run\n * keeps going until its step ends; it must not stop or delete a newer\n * execution of the same route.\n */\nconst ownsExecution = (route: RouteExtended): boolean =>\n executionState.get(route.id)?.route === route\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. A newer execution of the\n // same route id is not ours, also when our executor ignored the stop.\n if (!execution || execution.route !== route) {\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 // A stop during the await did not reach this executor, and a newer\n // execution of the route may run now: do not start the step.\n if (!ownsExecution(route)) {\n return route\n }\n // In flight until the step settles, the retry included: a stop keeps\n // the records a late write of this run needs (`executionState`).\n executionState.retain(route.id)\n // Taken from this execution, not looked up again for the retry: a\n // newer execution of the route id has its own.\n const { signal } = execution.abortController\n let executedStep: LiFiStepExtended\n try {\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 try {\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n undefined,\n signal\n )\n } catch (e) {\n if (e instanceof ExecuteStepRetryError) {\n // A stop ended this run while its first attempt ran: the replay\n // would be new work on a stopped executor.\n if (!stepExecutor.allowExecution) {\n return route\n }\n step.execution = undefined\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n e.retryParams,\n signal\n )\n } else {\n throw e\n }\n }\n } finally {\n executionState.release(route.id)\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' && ownsExecution(route)) {\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 if (ownsExecution(route)) {\n stopRouteExecution(route)\n }\n throw e\n }\n }\n\n // Clean up after the execution\n if (ownsExecution(route)) {\n executionState.delete(route.id)\n }\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 // The abort can run before or after the two steps above: its listeners\n // only clear timers, drop the shared poll and reject promises, and the\n // tasks handle the rejections after this function returns. The\n // `setInteraction` loop must run before `executionState.delete`, because\n // `StatusManager.allowUpdates(false)` keeps the route and hook from the\n // execution state.\n execution.abortController.abort()\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":";;;;;;;;;;;;;;AAqBA,MAAa,eAAe,OAC1B,QACA,OACA,qBAC2B;CAE3B,MAAM,cAAc,gBAAuB,KAAK;CAEhD,IAAI,mBAAmBA,4BAAAA,eAAe,IAAI,YAAY,EAAE,CAAC,EAAE;CAE3D,IAAI,kBACF,OAAO;CAGTA,4BAAAA,eAAe,OAAO;EAAE,OAAO;EAAa;CAAiB,CAAC;CAC9D,mBAAmB,aAAa,QAAQ,WAAW;CACnDA,4BAAAA,eAAe,OAAO;EACpB,OAAO;EACP,SAAS;CACX,CAAC;CAED,OAAO;AACT;;;;;;;;;AAUA,MAAa,cAAc,OACzB,QACA,OACA,qBAC2B;CAC3B,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,EAAE;CAE7C,IAAI,WAIE;MAAA,CAHoB,UAAU,UAAU,MACzC,aAAa,CAAC,SAAS,cAEP,GAAG;GAEpB,qBAAqB,OAAO,EAC1B,qBAAqB,kBAAkB,oBACzC,CAAC;GACD,IAAI,CAAC,UAAU,SAEb,MAAM,IAAI,MAAM,oCAAoC;GAEtD,OAAO,UAAU;EACnB;;CAKF,MAAM,eAAe,gBAA+B,KAAK;CACzDC,4BAAAA,eAAe,YAAY;CAE3B,OAAO,aAAa,QAAQ,cAAc,gBAAgB;AAC5D;;;;;;AAOA,MAAM,iBAAiB,UACrBD,4BAAAA,eAAe,IAAI,MAAM,EAAE,CAAC,EAAE,UAAU;AAE1C,MAAM,eAAe,OACnB,QACA,UAC2B;CAE3B,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,Q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W,WAAW,UAAU,cAAc,KAAK,GAClE,mBAAmB,KAAK;GAI1B,IAAI,CAAC,aAAa,gBAChB,OAAO;EAEX,SAAS,GAAG;GACV,IAAI,cAAc,KAAK,GACrB,mBAAmB,KAAK;GAE1B,MAAM;EACR;CACF;CAGA,IAAI,cAAc,KAAK,GACrBA,4BAAAA,eAAe,OAAO,MAAM,EAAE;CAEhC,OAAO;AACT;;;;;;AAOA,MAAa,wBACX,OACA,YACS;CACT,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,EAAE;CAC7C,IAAI,CAAC,WACH;CAGF,IAAI,yBAAyB,SAC3B,KAAK,MAAM,YAAY,UAAU,WAC/B,SAAS,eAAe;EACtB,kBAAkB,CAAC,SAAS;EAC5B,cAAc;CAChB,CAAC;CAIL,UAAU,mBAAmB;EAC3B,GAAG,UAAU;EACb,GAAG;CACL;AACF;;;;;;AAOA,MAAa,sBAAsB,UAAwB;CACzD,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,EAAE;CAC7C,IAAI,CAAC,WACH,OAAO;CAGT,KAAK,MAAM,YAAY,UAAU,WAC/B,SAAS,eAAe;EACtB,kBAAkB;EAClB,cAAc;EACd,gBAAgB;CAClB,CAAC;CAEHA,4BAAAA,eAAe,OAAO,MAAM,EAAE;CAO9B,UAAU,gBAAgB,MAAM;CAChC,OAAO,UAAU;AACnB;;;;;AAMA,MAAa,wBAAyC;CACpD,OAAO,OAAO,OAAOA,4BAAAA,eAAe,KAAK,CAAC,CACvC,KAAK,SAAS,MAAM,KAAK,CAAC,CAC1B,OAAO,OAAO;AACnB;;;;;;AAOA,MAAa,kBAAkB,YAA+C;CAC5E,OAAOA,4BAAAA,eAAe,IAAI,OAAO,CAAC,EAAE;AACtC"}
@@ -1,5 +1,4 @@
1
1
  import { ExecutionOptions, RouteExtended, StepExecutor, UpdateRouteHook } from "../types/core.js";
2
- //#region src/core/executionState.d.ts
3
2
  interface ExecutionData {
4
3
  route: RouteExtended;
5
4
  executors: StepExecutor[];
@@ -47,5 +46,4 @@ interface ExecutionState {
47
46
  lastEnded(routeId: string): EndedExecution | undefined;
48
47
  }
49
48
  export declare const executionState: ExecutionState;
50
- //#endregion
51
- //# sourceMappingURL=executionState.d.ts.map
49
+ export {};
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/core/executionState.ts
2
+ // src/core/executionState.ts
3
3
  /**
4
4
  * The last start number given to any route id. A number is never given
5
5
  * twice, so a route id whose records were freed and that started again never
@@ -66,7 +66,6 @@ const executionState = {
66
66
  return this.ended[routeId];
67
67
  }
68
68
  };
69
- //#endregion
70
69
  exports.executionState = executionState;
71
70
 
72
71
  //# sourceMappingURL=executionState.js.map
@@ -1,5 +1,2 @@
1
1
  import { RouteExtended } from "../types/core.js";
2
- //#region src/core/prepareRestart.d.ts
3
- export declare const prepareRestart: (route: RouteExtended) => void;
4
- //#endregion
5
- //# sourceMappingURL=prepareRestart.d.ts.map
2
+ export declare const prepareRestart: (route: RouteExtended) => void;
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_core_actionMessages = require("./actionMessages.js");
3
3
  const require_core_transactionState = require("./transactionState.js");
4
- //#region src/core/prepareRestart.ts
4
+ // src/core/prepareRestart.ts
5
5
  const RESTART_ACTION_TYPES = [
6
6
  "SWAP",
7
7
  "CROSS_CHAIN",
@@ -23,7 +23,6 @@ const prepareRestart = (route) => {
23
23
  step.transactionRequest = void 0;
24
24
  }
25
25
  };
26
- //#endregion
27
26
  exports.prepareRestart = prepareRestart;
28
27
 
29
28
  //# sourceMappingURL=prepareRestart.js.map
@@ -1,4 +1,3 @@
1
- //#region src/core/storage.d.ts
2
1
  export interface SDKStorage {
3
2
  get(key: string): string | null | Promise<string | null>;
4
3
  set(key: string, value: string): void | Promise<void>;
@@ -15,6 +14,4 @@ export declare class InMemoryStorage implements SDKStorage {
15
14
  set(key: string, value: string): void;
16
15
  remove(key: string): void;
17
16
  }
18
- export declare function createDefaultStorage(): SDKStorage;
19
- //#endregion
20
- //# sourceMappingURL=storage.d.ts.map
17
+ export declare function createDefaultStorage(): SDKStorage;
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/core/storage.ts
2
+ // src/core/storage.ts
3
3
  var LocalStorageAdapter = class {
4
4
  get(key) {
5
5
  return window.localStorage.getItem(key);
@@ -27,7 +27,6 @@ function createDefaultStorage() {
27
27
  if (typeof window !== "undefined" && window.localStorage) return new LocalStorageAdapter();
28
28
  return new InMemoryStorage();
29
29
  }
30
- //#endregion
31
30
  exports.InMemoryStorage = InMemoryStorage;
32
31
  exports.LocalStorageAdapter = LocalStorageAdapter;
33
32
  exports.createDefaultStorage = createDefaultStorage;
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","names":[],"sources":["../../../src/core/storage.ts"],"sourcesContent":["export interface SDKStorage {\n get(key: string): string | null | Promise<string | null>\n set(key: string, value: string): void | Promise<void>\n remove(key: string): void | Promise<void>\n}\n\nexport class LocalStorageAdapter implements SDKStorage {\n get(key: string): string | null {\n return window.localStorage.getItem(key)\n }\n\n set(key: string, value: string): void {\n window.localStorage.setItem(key, value)\n }\n\n remove(key: string): void {\n window.localStorage.removeItem(key)\n }\n}\n\nexport class InMemoryStorage implements SDKStorage {\n private store = new Map<string, string>()\n\n get(key: string): string | null {\n return this.store.get(key) ?? null\n }\n\n set(key: string, value: string): void {\n this.store.set(key, value)\n }\n\n remove(key: string): void {\n this.store.delete(key)\n }\n}\n\nexport function createDefaultStorage(): SDKStorage {\n if (typeof window !== 'undefined' && window.localStorage) {\n return new LocalStorageAdapter()\n }\n return new InMemoryStorage()\n}\n"],"mappings":";;AAMA,IAAa,sBAAb,MAAuD;CACrD,IAAI,KAA4B;EAC9B,OAAO,OAAO,aAAa,QAAQ,GAAG;CACxC;CAEA,IAAI,KAAa,OAAqB;EACpC,OAAO,aAAa,QAAQ,KAAK,KAAK;CACxC;CAEA,OAAO,KAAmB;EACxB,OAAO,aAAa,WAAW,GAAG;CACpC;AACF;AAEA,IAAa,kBAAb,MAAmD;CACjD,wBAAgB,IAAI,IAAoB;CAExC,IAAI,KAA4B;EAC9B,OAAO,KAAK,MAAM,IAAI,GAAG,KAAK;CAChC;CAEA,IAAI,KAAa,OAAqB;EACpC,KAAK,MAAM,IAAI,KAAK,KAAK;CAC3B;CAEA,OAAO,KAAmB;EACxB,KAAK,MAAM,OAAO,GAAG;CACvB;AACF;AAEA,SAAgB,uBAAmC;CACjD,IAAI,OAAO,WAAW,eAAe,OAAO,cAC1C,OAAO,IAAI,oBAAoB;CAEjC,OAAO,IAAI,gBAAgB;AAC7B"}
1
+ {"version":3,"file":"storage.js","names":[],"sources":["../../../src/core/storage.ts"],"sourcesContent":["export interface SDKStorage {\n get(key: string): string | null | Promise<string | null>\n set(key: string, value: string): void | Promise<void>\n remove(key: string): void | Promise<void>\n}\n\nexport class LocalStorageAdapter implements SDKStorage {\n get(key: string): string | null {\n return window.localStorage.getItem(key)\n }\n\n set(key: string, value: string): void {\n window.localStorage.setItem(key, value)\n }\n\n remove(key: string): void {\n window.localStorage.removeItem(key)\n }\n}\n\nexport class InMemoryStorage implements SDKStorage {\n private store = new Map<string, string>()\n\n get(key: string): string | null {\n return this.store.get(key) ?? null\n }\n\n set(key: string, value: string): void {\n this.store.set(key, value)\n }\n\n remove(key: string): void {\n this.store.delete(key)\n }\n}\n\nexport function createDefaultStorage(): SDKStorage {\n if (typeof window !== 'undefined' && window.localStorage) {\n return new LocalStorageAdapter()\n }\n return new InMemoryStorage()\n}\n"],"mappings":";;AAMA,IAAa,sBAAb,MAAuD;CACrD,IAAI,KAA4B;EAC9B,OAAO,OAAO,aAAa,QAAQ,GAAG;CACxC;CAEA,IAAI,KAAa,OAAqB;EACpC,OAAO,aAAa,QAAQ,KAAK,KAAK;CACxC;CAEA,OAAO,KAAmB;EACxB,OAAO,aAAa,WAAW,GAAG;CACpC;AACF;AAEA,IAAa,kBAAb,MAAmD;CACzC,wBAAQ,IAAI,IAAoB;CAExC,IAAI,KAA4B;EAC9B,OAAO,KAAK,MAAM,IAAI,GAAG,KAAK;CAChC;CAEA,IAAI,KAAa,OAAqB;EACpC,KAAK,MAAM,IAAI,KAAK,KAAK;CAC3B;CAEA,OAAO,KAAmB;EACxB,KAAK,MAAM,OAAO,GAAG;CACvB;AACF;AAEA,SAAgB,uBAAmC;CACjD,IAAI,OAAO,WAAW,eAAe,OAAO,cAC1C,OAAO,IAAI,oBAAoB;CAEjC,OAAO,IAAI,gBAAgB;AAC7B"}
@@ -1,7 +1,6 @@
1
1
  import { StepExecutorContext, TaskResult } from "../../types/execution.js";
2
2
  import { BaseStepExecutionTask } from "../BaseStepExecutionTask.js";
3
3
  import { CheckBalanceOptions } from "./helpers/checkBalance.js";
4
- //#region src/core/tasks/CheckBalanceTask.d.ts
5
4
  export declare class CheckBalanceTask extends BaseStepExecutionTask {
6
5
  /**
7
6
  * Per-step options hook for chain-specific subclasses (e.g. skip the
@@ -12,6 +11,4 @@ export declare class CheckBalanceTask extends BaseStepExecutionTask {
12
11
  */
13
12
  protected getCheckBalanceOptions(_context: StepExecutorContext): Promise<CheckBalanceOptions>;
14
13
  run(context: StepExecutorContext): Promise<TaskResult>;
15
- }
16
- //#endregion
17
- //# sourceMappingURL=CheckBalanceTask.d.ts.map
14
+ }
@@ -3,7 +3,7 @@ require("../../errors/constants.js");
3
3
  const require_errors_errors = require("../../errors/errors.js");
4
4
  const require_core_BaseStepExecutionTask = require("../BaseStepExecutionTask.js");
5
5
  const require_core_tasks_helpers_checkBalance = require("./helpers/checkBalance.js");
6
- //#region src/core/tasks/CheckBalanceTask.ts
6
+ // src/core/tasks/CheckBalanceTask.ts
7
7
  var CheckBalanceTask = class extends require_core_BaseStepExecutionTask.BaseStepExecutionTask {
8
8
  /**
9
9
  * Per-step options hook for chain-specific subclasses (e.g. skip the
@@ -30,7 +30,6 @@ var CheckBalanceTask = class extends require_core_BaseStepExecutionTask.BaseStep
30
30
  return { status: "COMPLETED" };
31
31
  }
32
32
  };
33
- //#endregion
34
33
  exports.CheckBalanceTask = CheckBalanceTask;
35
34
 
36
35
  //# sourceMappingURL=CheckBalanceTask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckBalanceTask.js","names":["BaseStepExecutionTask","TransactionError","checkBalance"],"sources":["../../../../src/core/tasks/CheckBalanceTask.ts"],"sourcesContent":["import { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport {\n type CheckBalanceOptions,\n checkBalance,\n} from './helpers/checkBalance.js'\n\nexport class CheckBalanceTask extends BaseStepExecutionTask {\n /**\n * Per-step options hook for chain-specific subclasses (e.g. skip the\n * gas check for smart-contract wallets or relayed steps). Default `{}`\n * keeps behavior unchanged for every provider that doesn't override.\n * Resolved lazily inside `run()` — pipelines that resume past\n * `CheckBalance` pay no cost.\n */\n protected getCheckBalanceOptions(\n _context: StepExecutorContext\n ): Promise<CheckBalanceOptions> {\n return Promise.resolve({})\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const { client, step, statusManager, isBridgeExecution } = context\n\n statusManager.initializeAction({\n step,\n type: isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const walletAddress = step.action.fromAddress\n if (!walletAddress) {\n throw new TransactionError(\n LiFiErrorCode.InternalError,\n 'The wallet address is undefined.'\n )\n }\n\n const options = await this.getCheckBalanceOptions(context)\n await checkBalance(client, walletAddress, step, options)\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;;;;;AASA,IAAa,mBAAb,cAAsCA,mCAAAA,sBAAsB;;;;;;;;CAQ1D,uBACE,UAC8B;EAC9B,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;CAEA,MAAM,IAAI,SAAmD;EAC3D,MAAM,EAAE,QAAQ,MAAM,eAAe,sBAAsB;EAE3D,cAAc,iBAAiB;GAC7B;GACA,MAAM,oBAAoB,gBAAgB;GAC1C,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,gBAAgB,KAAK,OAAO;EAClC,IAAI,CAAC,eACH,MAAM,IAAIC,sBAAAA,iBAAAA,KAER,kCACF;EAGF,MAAM,UAAU,MAAM,KAAK,uBAAuB,OAAO;EACzD,MAAMC,wCAAAA,aAAa,QAAQ,eAAe,MAAM,OAAO;EACvD,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
1
+ {"version":3,"file":"CheckBalanceTask.js","names":["BaseStepExecutionTask","TransactionError","checkBalance"],"sources":["../../../../src/core/tasks/CheckBalanceTask.ts"],"sourcesContent":["import { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport {\n checkBalance,\n type CheckBalanceOptions,\n} from './helpers/checkBalance.js'\n\nexport class CheckBalanceTask extends BaseStepExecutionTask {\n /**\n * Per-step options hook for chain-specific subclasses (e.g. skip the\n * gas check for smart-contract wallets or relayed steps). Default `{}`\n * keeps behavior unchanged for every provider that doesn't override.\n * Resolved lazily inside `run()` — pipelines that resume past\n * `CheckBalance` pay no cost.\n */\n protected getCheckBalanceOptions(\n _context: StepExecutorContext\n ): Promise<CheckBalanceOptions> {\n return Promise.resolve({})\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const { client, step, statusManager, isBridgeExecution } = context\n\n statusManager.initializeAction({\n step,\n type: isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const walletAddress = step.action.fromAddress\n if (!walletAddress) {\n throw new TransactionError(\n LiFiErrorCode.InternalError,\n 'The wallet address is undefined.'\n )\n }\n\n const options = await this.getCheckBalanceOptions(context)\n await checkBalance(client, walletAddress, step, options)\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;;;;;AASA,IAAa,mBAAb,cAAsCA,mCAAAA,sBAAsB;;;;;;;;CAQhD,uBACR,UAC8B;EAC9B,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;CAEA,MAAM,IAAI,SAAmD;EAC3D,MAAM,EAAE,QAAQ,MAAM,eAAe,sBAAsB;EAE3D,cAAc,iBAAiB;GAC7B;GACA,MAAM,oBAAoB,gBAAgB;GAC1C,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,gBAAgB,KAAK,OAAO;EAClC,IAAI,CAAC,eACH,MAAM,IAAIC,sBAAAA,iBAAAA,KAER,kCACF;EAGF,MAAM,UAAU,MAAM,KAAK,uBAAuB,OAAO;EACzD,MAAMC,wCAAAA,aAAa,QAAQ,eAAe,MAAM,OAAO;EACvD,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { StepExecutorContext, TaskResult } from "../../types/execution.js";
2
2
  import { BaseStepExecutionTask } from "../BaseStepExecutionTask.js";
3
- //#region src/core/tasks/PrepareTransactionTask.d.ts
4
3
  export declare class PrepareTransactionTask extends BaseStepExecutionTask {
5
4
  /**
6
5
  * Whether `run()` has to fetch a fresh transaction request. The default asks
@@ -10,6 +9,4 @@ export declare class PrepareTransactionTask extends BaseStepExecutionTask {
10
9
  */
11
10
  protected shouldRefetchTransaction(context: StepExecutorContext): boolean;
12
11
  run(context: StepExecutorContext): Promise<TaskResult>;
13
- }
14
- //#endregion
15
- //# sourceMappingURL=PrepareTransactionTask.d.ts.map
12
+ }
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_actions_getStepTransaction = require("../../actions/getStepTransaction.js");
2
3
  require("../../errors/constants.js");
3
4
  const require_errors_errors = require("../../errors/errors.js");
4
- const require_actions_getStepTransaction = require("../../actions/getStepTransaction.js");
5
5
  const require_core_BaseStepExecutionTask = require("../BaseStepExecutionTask.js");
6
6
  const require_core_tasks_helpers_stepComparison = require("./helpers/stepComparison.js");
7
- //#region src/core/tasks/PrepareTransactionTask.ts
7
+ // src/core/tasks/PrepareTransactionTask.ts
8
8
  var PrepareTransactionTask = class extends require_core_BaseStepExecutionTask.BaseStepExecutionTask {
9
9
  /**
10
10
  * Whether `run()` has to fetch a fresh transaction request. The default asks
@@ -34,7 +34,6 @@ var PrepareTransactionTask = class extends require_core_BaseStepExecutionTask.Ba
34
34
  return { status: "COMPLETED" };
35
35
  }
36
36
  };
37
- //#endregion
38
37
  exports.PrepareTransactionTask = PrepareTransactionTask;
39
38
 
40
39
  //# sourceMappingURL=PrepareTransactionTask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","getStepTransaction","stepComparison"],"sources":["../../../../src/core/tasks/PrepareTransactionTask.ts"],"sourcesContent":["import { getStepTransaction } from '../../actions/getStepTransaction.js'\nimport { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport { stepComparison } from './helpers/stepComparison.js'\n\nexport class PrepareTransactionTask extends BaseStepExecutionTask {\n /**\n * Whether `run()` has to fetch a fresh transaction request. The default asks\n * only when the step carries none, which keeps every existing provider\n * unchanged. Chains whose payload cannot be reused override it — see\n * `StellarPrepareTransactionTask`.\n */\n protected shouldRefetchTransaction(context: StepExecutorContext): boolean {\n return !context.step.transactionRequest\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const {\n client,\n step,\n statusManager,\n allowUserInteraction,\n executionOptions,\n isBridgeExecution,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n if (this.shouldRefetchTransaction(context)) {\n const { execution, ...stepBase } = step\n const updatedStep = await getStepTransaction(client, stepBase)\n const comparedStep = await stepComparison(\n statusManager,\n step,\n updatedStep,\n allowUserInteraction,\n executionOptions\n )\n Object.assign(step, {\n ...comparedStep,\n execution: step.execution,\n })\n }\n\n if (!step.transactionRequest?.data) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request data is not found.'\n )\n }\n\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,yBAAb,cAA4CA,mCAAAA,sBAAsB;;;;;;;CAOhE,yBAAmC,SAAuC;EACxE,OAAO,CAAC,QAAQ,KAAK;CACvB;CAEA,MAAM,IAAI,SAAmD;EAC3D,MAAM,EACJ,QACA,MACA,eACA,sBACA,kBACA,sBACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EAEA,IAAI,CAAC,QACH,MAAM,IAAIC,sBAAAA,iBAAAA,MAER,kDACF;EAGF,IAAI,KAAK,yBAAyB,OAAO,GAAG;GAC1C,MAAM,EAAE,WAAW,GAAG,aAAa;GACnC,MAAM,cAAc,MAAMC,mCAAAA,mBAAmB,QAAQ,QAAQ;GAC7D,MAAM,eAAe,MAAMC,0CAAAA,eACzB,eACA,MACA,aACA,sBACA,gBACF;GACA,OAAO,OAAO,MAAM;IAClB,GAAG;IACH,WAAW,KAAK;GAClB,CAAC;EACH;EAEA,IAAI,CAAC,KAAK,oBAAoB,MAC5B,MAAM,IAAIF,sBAAAA,iBAAAA,MAER,uEACF;EAGF,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;EAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
1
+ {"version":3,"file":"PrepareTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","getStepTransaction","stepComparison"],"sources":["../../../../src/core/tasks/PrepareTransactionTask.ts"],"sourcesContent":["import { getStepTransaction } from '../../actions/getStepTransaction.js'\nimport { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport { stepComparison } from './helpers/stepComparison.js'\n\nexport class PrepareTransactionTask extends BaseStepExecutionTask {\n /**\n * Whether `run()` has to fetch a fresh transaction request. The default asks\n * only when the step carries none, which keeps every existing provider\n * unchanged. Chains whose payload cannot be reused override it — see\n * `StellarPrepareTransactionTask`.\n */\n protected shouldRefetchTransaction(context: StepExecutorContext): boolean {\n return !context.step.transactionRequest\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const {\n client,\n step,\n statusManager,\n allowUserInteraction,\n executionOptions,\n isBridgeExecution,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n if (this.shouldRefetchTransaction(context)) {\n const { execution, ...stepBase } = step\n const updatedStep = await getStepTransaction(client, stepBase)\n const comparedStep = await stepComparison(\n statusManager,\n step,\n updatedStep,\n allowUserInteraction,\n executionOptions\n )\n Object.assign(step, {\n ...comparedStep,\n execution: step.execution,\n })\n }\n\n if (!step.transactionRequest?.data) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request data is not found.'\n )\n }\n\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,yBAAb,cAA4CA,mCAAAA,sBAAsB;;;;;;;CAOtD,yBAAyB,SAAuC;EACxE,OAAO,CAAC,QAAQ,KAAK;CACvB;CAEA,MAAM,IAAI,SAAmD;EAC3D,MAAM,EACJ,QACA,MACA,eACA,sBACA,kBACA,sBACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EAEA,IAAI,CAAC,QACH,MAAM,IAAIC,sBAAAA,iBAAAA,MAER,kDACF;EAGF,IAAI,KAAK,yBAAyB,OAAO,GAAG;GAC1C,MAAM,EAAE,WAAW,GAAG,aAAa;GACnC,MAAM,cAAc,MAAMC,mCAAAA,mBAAmB,QAAQ,QAAQ;GAC7D,MAAM,eAAe,MAAMC,0CAAAA,eACzB,eACA,MACA,aACA,sBACA,gBACF;GACA,OAAO,OAAO,MAAM;IAClB,GAAG;IACH,WAAW,KAAK;GAClB,CAAC;EACH;EAEA,IAAI,CAAC,KAAK,oBAAoB,MAC5B,MAAM,IAAIF,sBAAAA,iBAAAA,MAER,uEACF;EAGF,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;EAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
@@ -1,11 +1,8 @@
1
1
  import { ExecutionActionType } from "../../types/core.js";
2
2
  import { StepExecutorContext, TaskResult } from "../../types/execution.js";
3
3
  import { BaseStepExecutionTask } from "../BaseStepExecutionTask.js";
4
- //#region src/core/tasks/WaitForTransactionStatusTask.d.ts
5
4
  export declare class WaitForTransactionStatusTask extends BaseStepExecutionTask {
6
5
  readonly actionType: ExecutionActionType;
7
6
  constructor(actionType: ExecutionActionType);
8
7
  run(context: StepExecutorContext): Promise<TaskResult>;
9
- }
10
- //#endregion
11
- //# sourceMappingURL=WaitForTransactionStatusTask.d.ts.map
8
+ }
@@ -2,10 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../errors/constants.js");
3
3
  const require_errors_errors = require("../../errors/errors.js");
4
4
  const require_utils_abort = require("../../utils/abort.js");
5
- const require_core_BaseStepExecutionTask = require("../BaseStepExecutionTask.js");
6
5
  const require_utils_getTransactionMessage = require("../../utils/getTransactionMessage.js");
6
+ const require_core_BaseStepExecutionTask = require("../BaseStepExecutionTask.js");
7
7
  const require_core_tasks_helpers_waitForTransactionStatus = require("./helpers/waitForTransactionStatus.js");
8
- //#region src/core/tasks/WaitForTransactionStatusTask.ts
8
+ // src/core/tasks/WaitForTransactionStatusTask.ts
9
9
  var WaitForTransactionStatusTask = class extends require_core_BaseStepExecutionTask.BaseStepExecutionTask {
10
10
  actionType;
11
11
  constructor(actionType) {
@@ -59,7 +59,6 @@ var WaitForTransactionStatusTask = class extends require_core_BaseStepExecutionT
59
59
  }
60
60
  }
61
61
  };
62
- //#endregion
63
62
  exports.WaitForTransactionStatusTask = WaitForTransactionStatusTask;
64
63
 
65
64
  //# sourceMappingURL=WaitForTransactionStatusTask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WaitForTransactionStatusTask.js","names":["BaseStepExecutionTask","waitForTransactionStatus","isAbortError","getTransactionFailedMessage","TransactionError"],"sources":["../../../../src/core/tasks/WaitForTransactionStatusTask.ts"],"sourcesContent":["import type { ExtendedTransactionInfo, FullStatusData } from '@lifi/types'\nimport { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { ExecutionActionType } from '../../types/core.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { isAbortError } from '../../utils/abort.js'\nimport { getTransactionFailedMessage } from '../../utils/getTransactionMessage.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport { waitForTransactionStatus } from './helpers/waitForTransactionStatus.js'\n\nexport class WaitForTransactionStatusTask extends BaseStepExecutionTask {\n readonly actionType: ExecutionActionType\n\n constructor(actionType: ExecutionActionType) {\n super()\n this.actionType = actionType\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const {\n client,\n step,\n statusManager,\n pollingIntervalMs,\n toChain,\n isBridgeExecution,\n signal,\n } = context\n\n // At this point, we should have a txHash or taskId\n // taskId is used for custom integrations that don't use the standard transaction hash\n let transactionHash: string | undefined\n try {\n const swapOrBridgeAction = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n transactionHash = swapOrBridgeAction?.txHash || swapOrBridgeAction?.taskId\n\n // Wait for the transaction status on the destination chain\n if (!transactionHash) {\n throw new Error('Transaction hash is undefined.')\n }\n\n const action = statusManager.initializeAction({\n step,\n type: this.actionType,\n chainId:\n this.actionType === 'RECEIVING_CHAIN'\n ? step.action.toChainId\n : step.action.fromChainId,\n status: 'PENDING',\n })\n\n const statusResponse = (await waitForTransactionStatus(\n client,\n statusManager,\n transactionHash,\n step,\n action.type,\n pollingIntervalMs,\n signal\n )) as FullStatusData\n\n const statusReceiving =\n statusResponse.receiving as ExtendedTransactionInfo\n\n // Update action status\n statusManager.updateAction(step, action.type, 'DONE', {\n chainId: statusReceiving?.chainId || toChain.id,\n substatus: statusResponse.substatus,\n substatusMessage: statusResponse.substatusMessage,\n txHash: statusReceiving?.txHash,\n txLink:\n statusReceiving?.txLink ||\n `${toChain.metamask.blockExplorerUrls[0]}tx/${statusReceiving?.txHash}`,\n })\n\n // Update execution status\n statusManager.updateExecution(step, {\n status: 'DONE',\n ...(statusResponse.sending.amount && {\n fromAmount: statusResponse.sending.amount,\n }),\n ...(statusReceiving?.amount && { toAmount: statusReceiving.amount }),\n ...(statusReceiving?.token && { toToken: statusReceiving.token }),\n internalTxLink: statusResponse?.lifiExplorerLink,\n externalTxLink: statusResponse?.bridgeExplorerLink,\n gasCosts: [\n {\n amount: statusResponse.sending.gasAmount,\n amountUSD: statusResponse.sending.gasAmountUSD,\n token: statusResponse.sending.gasToken,\n estimate: statusResponse.sending.gasUsed,\n limit: statusResponse.sending.gasUsed,\n price: statusResponse.sending.gasPrice,\n type: 'SEND',\n },\n ],\n })\n\n return { status: 'COMPLETED' }\n } catch (e: any) {\n // `stopRouteExecution` ended the wait; the outcome of the transaction is\n // still unknown. Pause like a stopped step, with no write: the stored\n // action keeps its hash, and a resume waits for it again.\n if (signal?.aborted && isAbortError(e)) {\n return { status: 'PAUSED' }\n }\n const htmlMessage = await getTransactionFailedMessage(\n client,\n step,\n `${toChain.metamask.blockExplorerUrls[0]}tx/${transactionHash}`\n )\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n htmlMessage ??\n 'Failed while waiting for status of destination chain transaction.',\n e\n )\n }\n }\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,+BAAb,cAAkDA,mCAAAA,sBAAsB;CACtE;CAEA,YAAY,YAAiC;EAC3C,MAAM;EACN,KAAK,aAAa;CACpB;CAEA,MAAM,IAAI,SAAmD;EAC3D,MAAM,EACJ,QACA,MACA,eACA,mBACA,SACA,mBACA,WACE;EAIJ,IAAI;EACJ,IAAI;GACF,MAAM,qBAAqB,cAAc,WACvC,MACA,oBAAoB,gBAAgB,MACtC;GACA,kBAAkB,oBAAoB,UAAU,oBAAoB;GAGpE,IAAI,CAAC,iBACH,MAAM,IAAI,MAAM,gCAAgC;GAGlD,MAAM,SAAS,cAAc,iBAAiB;IAC5C;IACA,MAAM,KAAK;IACX,SACE,KAAK,eAAe,oBAChB,KAAK,OAAO,YACZ,KAAK,OAAO;IAClB,QAAQ;GACV,CAAC;GAED,MAAM,iBAAkB,MAAMC,oDAAAA,yBAC5B,QACA,eACA,iBACA,MACA,OAAO,MACP,mBACA,MACF;GAEA,MAAM,kBACJ,eAAe;GAGjB,cAAc,aAAa,MAAM,OAAO,MAAM,QAAQ;IACpD,SAAS,iBAAiB,WAAW,QAAQ;IAC7C,WAAW,eAAe;IAC1B,kBAAkB,eAAe;IACjC,QAAQ,iBAAiB;IACzB,QACE,iBAAiB,UACjB,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,iBAAiB;GACnE,CAAC;GAGD,cAAc,gBAAgB,MAAM;IAClC,QAAQ;IACR,GAAI,eAAe,QAAQ,UAAU,EACnC,YAAY,eAAe,QAAQ,OACrC;IACA,GAAI,iBAAiB,UAAU,EAAE,UAAU,gBAAgB,OAAO;IAClE,GAAI,iBAAiB,SAAS,EAAE,SAAS,gBAAgB,MAAM;IAC/D,gBAAgB,gBAAgB;IAChC,gBAAgB,gBAAgB;IAChC,UAAU,CACR;KACE,QAAQ,eAAe,QAAQ;KAC/B,WAAW,eAAe,QAAQ;KAClC,OAAO,eAAe,QAAQ;KAC9B,UAAU,eAAe,QAAQ;KACjC,OAAO,eAAe,QAAQ;KAC9B,OAAO,eAAe,QAAQ;KAC9B,MAAM;IACR,CACF;GACF,CAAC;GAED,OAAO,EAAE,QAAQ,YAAY;EAC/B,SAAS,GAAQ;GAIf,IAAI,QAAQ,WAAWC,oBAAAA,aAAa,CAAC,GACnC,OAAO,EAAE,QAAQ,SAAS;GAE5B,MAAM,cAAc,MAAMC,oCAAAA,4BACxB,QACA,MACA,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,iBAChD;GACA,MAAM,IAAIC,sBAAAA,iBAAAA,MAER,eACE,qEACF,CACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"WaitForTransactionStatusTask.js","names":["BaseStepExecutionTask","waitForTransactionStatus","isAbortError","getTransactionFailedMessage","TransactionError"],"sources":["../../../../src/core/tasks/WaitForTransactionStatusTask.ts"],"sourcesContent":["import type { ExtendedTransactionInfo, FullStatusData } from '@lifi/types'\nimport { LiFiErrorCode } from '../../errors/constants.js'\nimport { TransactionError } from '../../errors/errors.js'\nimport type { ExecutionActionType } from '../../types/core.js'\nimport type { StepExecutorContext, TaskResult } from '../../types/execution.js'\nimport { isAbortError } from '../../utils/abort.js'\nimport { getTransactionFailedMessage } from '../../utils/getTransactionMessage.js'\nimport { BaseStepExecutionTask } from '../BaseStepExecutionTask.js'\nimport { waitForTransactionStatus } from './helpers/waitForTransactionStatus.js'\n\nexport class WaitForTransactionStatusTask extends BaseStepExecutionTask {\n readonly actionType: ExecutionActionType\n\n constructor(actionType: ExecutionActionType) {\n super()\n this.actionType = actionType\n }\n\n async run(context: StepExecutorContext): Promise<TaskResult> {\n const {\n client,\n step,\n statusManager,\n pollingIntervalMs,\n toChain,\n isBridgeExecution,\n signal,\n } = context\n\n // At this point, we should have a txHash or taskId\n // taskId is used for custom integrations that don't use the standard transaction hash\n let transactionHash: string | undefined\n try {\n const swapOrBridgeAction = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n transactionHash = swapOrBridgeAction?.txHash || swapOrBridgeAction?.taskId\n\n // Wait for the transaction status on the destination chain\n if (!transactionHash) {\n throw new Error('Transaction hash is undefined.')\n }\n\n const action = statusManager.initializeAction({\n step,\n type: this.actionType,\n chainId:\n this.actionType === 'RECEIVING_CHAIN'\n ? step.action.toChainId\n : step.action.fromChainId,\n status: 'PENDING',\n })\n\n const statusResponse = (await waitForTransactionStatus(\n client,\n statusManager,\n transactionHash,\n step,\n action.type,\n pollingIntervalMs,\n signal\n )) as FullStatusData\n\n const statusReceiving =\n statusResponse.receiving as ExtendedTransactionInfo\n\n // Update action status\n statusManager.updateAction(step, action.type, 'DONE', {\n chainId: statusReceiving?.chainId || toChain.id,\n substatus: statusResponse.substatus,\n substatusMessage: statusResponse.substatusMessage,\n txHash: statusReceiving?.txHash,\n txLink:\n statusReceiving?.txLink ||\n `${toChain.metamask.blockExplorerUrls[0]}tx/${statusReceiving?.txHash}`,\n })\n\n // Update execution status\n statusManager.updateExecution(step, {\n status: 'DONE',\n ...(statusResponse.sending.amount && {\n fromAmount: statusResponse.sending.amount,\n }),\n ...(statusReceiving?.amount && { toAmount: statusReceiving.amount }),\n ...(statusReceiving?.token && { toToken: statusReceiving.token }),\n internalTxLink: statusResponse?.lifiExplorerLink,\n externalTxLink: statusResponse?.bridgeExplorerLink,\n gasCosts: [\n {\n amount: statusResponse.sending.gasAmount,\n amountUSD: statusResponse.sending.gasAmountUSD,\n token: statusResponse.sending.gasToken,\n estimate: statusResponse.sending.gasUsed,\n limit: statusResponse.sending.gasUsed,\n price: statusResponse.sending.gasPrice,\n type: 'SEND',\n },\n ],\n })\n\n return { status: 'COMPLETED' }\n } catch (e: any) {\n // `stopRouteExecution` ended the wait; the outcome of the transaction is\n // still unknown. Pause like a stopped step, with no write: the stored\n // action keeps its hash, and a resume waits for it again.\n if (signal?.aborted && isAbortError(e)) {\n return { status: 'PAUSED' }\n }\n const htmlMessage = await getTransactionFailedMessage(\n client,\n step,\n `${toChain.metamask.blockExplorerUrls[0]}tx/${transactionHash}`\n )\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n htmlMessage ??\n 'Failed while waiting for status of destination chain transaction.',\n e\n )\n }\n }\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,+BAAb,cAAkDA,mCAAAA,sBAAsB;CAC7D;CAET,YAAY,YAAiC;EAC3C,MAAM;EACN,KAAK,aAAa;CACpB;CAEA,MAAM,IAAI,SAAmD;EAC3D,MAAM,EACJ,QACA,MACA,eACA,mBACA,SACA,mBACA,WACE;EAIJ,IAAI;EACJ,IAAI;GACF,MAAM,qBAAqB,cAAc,WACvC,MACA,oBAAoB,gBAAgB,MACtC;GACA,kBAAkB,oBAAoB,UAAU,oBAAoB;GAGpE,IAAI,CAAC,iBACH,MAAM,IAAI,MAAM,gCAAgC;GAGlD,MAAM,SAAS,cAAc,iBAAiB;IAC5C;IACA,MAAM,KAAK;IACX,SACE,KAAK,eAAe,oBAChB,KAAK,OAAO,YACZ,KAAK,OAAO;IAClB,QAAQ;GACV,CAAC;GAED,MAAM,iBAAkB,MAAMC,oDAAAA,yBAC5B,QACA,eACA,iBACA,MACA,OAAO,MACP,mBACA,MACF;GAEA,MAAM,kBACJ,eAAe;GAGjB,cAAc,aAAa,MAAM,OAAO,MAAM,QAAQ;IACpD,SAAS,iBAAiB,WAAW,QAAQ;IAC7C,WAAW,eAAe;IAC1B,kBAAkB,eAAe;IACjC,QAAQ,iBAAiB;IACzB,QACE,iBAAiB,UACjB,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,iBAAiB;GACnE,CAAC;GAGD,cAAc,gBAAgB,MAAM;IAClC,QAAQ;IACR,GAAI,eAAe,QAAQ,UAAU,EACnC,YAAY,eAAe,QAAQ,OACrC;IACA,GAAI,iBAAiB,UAAU,EAAE,UAAU,gBAAgB,OAAO;IAClE,GAAI,iBAAiB,SAAS,EAAE,SAAS,gBAAgB,MAAM;IAC/D,gBAAgB,gBAAgB;IAChC,gBAAgB,gBAAgB;IAChC,UAAU,CACR;KACE,QAAQ,eAAe,QAAQ;KAC/B,WAAW,eAAe,QAAQ;KAClC,OAAO,eAAe,QAAQ;KAC9B,UAAU,eAAe,QAAQ;KACjC,OAAO,eAAe,QAAQ;KAC9B,OAAO,eAAe,QAAQ;KAC9B,MAAM;IACR,CACF;GACF,CAAC;GAED,OAAO,EAAE,QAAQ,YAAY;EAC/B,SAAS,GAAQ;GAIf,IAAI,QAAQ,WAAWC,oBAAAA,aAAa,CAAC,GACnC,OAAO,EAAE,QAAQ,SAAS;GAE5B,MAAM,cAAc,MAAMC,oCAAAA,4BACxB,QACA,MACA,GAAG,QAAQ,SAAS,kBAAkB,GAAG,KAAK,iBAChD;GACA,MAAM,IAAIC,sBAAAA,iBAAAA,MAER,eACE,qEACF,CACF;EACF;CACF;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { SDKClient } from "../../../types/core.js";
2
2
  import { LiFiStep } from "@lifi/types";
3
- //#region src/core/tasks/helpers/checkBalance.d.ts
4
3
  export type CheckBalanceOptions = {
5
4
  /**
6
5
  * Set to `false` when outer-tx gas is paid by something other than
@@ -23,6 +22,4 @@ export type CheckBalanceOptions = {
23
22
  * BalanceError("Could not read wallet balance.") if the balance can't be read
24
23
  * after retries.
25
24
  */
26
- export declare const checkBalance: (client: SDKClient, walletAddress: string, step: LiFiStep, options?: CheckBalanceOptions) => Promise<void>;
27
- //#endregion
28
- //# sourceMappingURL=checkBalance.d.ts.map
25
+ export declare const checkBalance: (client: SDKClient, walletAddress: string, step: LiFiStep, options?: CheckBalanceOptions) => Promise<void>;
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_errors_errors = require("../../../errors/errors.js");
3
- const require_utils_sleep = require("../../../utils/sleep.js");
4
3
  const require_utils_formatUnits = require("../../../utils/formatUnits.js");
4
+ const require_utils_sleep = require("../../../utils/sleep.js");
5
5
  const require_utils_withTimeout = require("../../../utils/withTimeout.js");
6
- //#region src/core/tasks/helpers/checkBalance.ts
6
+ // src/core/tasks/helpers/checkBalance.ts
7
7
  const MAX_ATTEMPTS = 6;
8
8
  const BACKOFF_BASE_MS = 150;
9
9
  const OVERALL_TIMEOUT_MS = 1e4;
@@ -105,7 +105,6 @@ const checkBalance = async (client, walletAddress, step, options = {}) => {
105
105
  errorInstance: new require_errors_errors.BalanceError("Could not read wallet balance.")
106
106
  }).finally(() => controller.abort());
107
107
  };
108
- //#endregion
109
108
  exports.checkBalance = checkBalance;
110
109
 
111
110
  //# sourceMappingURL=checkBalance.js.map