@lifi/sdk 2.3.1 → 3.0.0-alpha.10

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 (379) hide show
  1. package/dist/cjs/LiFi.js +222 -250
  2. package/dist/cjs/LiFi.js.map +1 -0
  3. package/dist/cjs/allowance/getAllowance.js +82 -0
  4. package/dist/cjs/allowance/getAllowance.js.map +1 -0
  5. package/dist/cjs/allowance/index.js +5 -16
  6. package/dist/cjs/allowance/index.js.map +1 -0
  7. package/dist/cjs/allowance/setAllowance.js +71 -0
  8. package/dist/cjs/allowance/setAllowance.js.map +1 -0
  9. package/dist/cjs/{types/internal.types.js → allowance/types.js} +1 -0
  10. package/dist/cjs/allowance/types.js.map +1 -0
  11. package/dist/cjs/balance/getBalance.js +97 -0
  12. package/dist/cjs/balance/getBalance.js.map +1 -0
  13. package/dist/cjs/balance/getTokenBalance.js +7 -10
  14. package/dist/cjs/balance/getTokenBalance.js.map +1 -0
  15. package/dist/cjs/balance/index.js +4 -24
  16. package/dist/cjs/balance/index.js.map +1 -0
  17. package/dist/cjs/connectors.js +28 -48
  18. package/dist/cjs/connectors.js.map +1 -0
  19. package/dist/cjs/constants.js +7 -0
  20. package/dist/cjs/constants.js.map +1 -0
  21. package/dist/cjs/execution/BaseStepExecutor.js +54 -0
  22. package/dist/cjs/execution/BaseStepExecutor.js.map +1 -0
  23. package/dist/cjs/execution/EVMStepExecutor.js +271 -0
  24. package/dist/cjs/execution/EVMStepExecutor.js.map +1 -0
  25. package/dist/cjs/execution/RouteExecutionManager.js +196 -197
  26. package/dist/cjs/execution/RouteExecutionManager.js.map +1 -0
  27. package/dist/cjs/execution/StatusManager.js +142 -136
  28. package/dist/cjs/execution/StatusManager.js.map +1 -0
  29. package/dist/cjs/execution/StepExecutionManager.js +220 -233
  30. package/dist/cjs/execution/StepExecutionManager.js.map +1 -0
  31. package/dist/cjs/execution/checkAllowance.js +76 -0
  32. package/dist/cjs/execution/checkAllowance.js.map +1 -0
  33. package/dist/cjs/execution/checkBalance.js +42 -0
  34. package/dist/cjs/execution/checkBalance.js.map +1 -0
  35. package/dist/cjs/execution/index.js +4 -15
  36. package/dist/cjs/execution/index.js.map +1 -0
  37. package/dist/cjs/execution/multisig.js +13 -17
  38. package/dist/cjs/execution/multisig.js.map +1 -0
  39. package/dist/cjs/execution/prepareRestart.js +23 -0
  40. package/dist/cjs/execution/prepareRestart.js.map +1 -0
  41. package/dist/cjs/execution/stepComparison.js +5 -17
  42. package/dist/cjs/execution/stepComparison.js.map +1 -0
  43. package/dist/cjs/execution/switchChain.js +10 -22
  44. package/dist/cjs/execution/switchChain.js.map +1 -0
  45. package/dist/cjs/execution/types.js +3 -0
  46. package/dist/cjs/execution/types.js.map +1 -0
  47. package/dist/cjs/execution/utils.js +12 -67
  48. package/dist/cjs/execution/utils.js.map +1 -0
  49. package/dist/cjs/execution/waitForReceivingTransaction.js +56 -0
  50. package/dist/cjs/execution/waitForReceivingTransaction.js.map +1 -0
  51. package/dist/cjs/helpers.js +12 -58
  52. package/dist/cjs/helpers.js.map +1 -0
  53. package/dist/cjs/index.js +16 -22
  54. package/dist/cjs/index.js.map +1 -0
  55. package/dist/cjs/package.json +1 -0
  56. package/dist/cjs/providers/EVM.js +35 -0
  57. package/dist/cjs/providers/EVM.js.map +1 -0
  58. package/dist/cjs/providers/Solana.js +38 -0
  59. package/dist/cjs/providers/Solana.js.map +1 -0
  60. package/dist/cjs/providers/index.js +5 -0
  61. package/dist/cjs/providers/index.js.map +1 -0
  62. package/dist/cjs/providers/types.js +9 -0
  63. package/dist/cjs/providers/types.js.map +1 -0
  64. package/dist/cjs/request.js +10 -13
  65. package/dist/cjs/request.js.map +1 -0
  66. package/dist/cjs/services/ApiService.js +70 -86
  67. package/dist/cjs/services/ApiService.js.map +1 -0
  68. package/dist/cjs/services/ChainsService.js +19 -9
  69. package/dist/cjs/services/ChainsService.js.map +1 -0
  70. package/dist/cjs/services/ConfigService.js +94 -67
  71. package/dist/cjs/services/ConfigService.js.map +1 -0
  72. package/dist/cjs/typeguards.js +1 -0
  73. package/dist/cjs/typeguards.js.map +1 -0
  74. package/dist/cjs/types/abi.js +46 -0
  75. package/dist/cjs/types/abi.js.map +1 -0
  76. package/dist/cjs/types/index.js +4 -20
  77. package/dist/cjs/types/index.js.map +1 -0
  78. package/dist/cjs/types/internal.js +3 -0
  79. package/dist/cjs/types/internal.js.map +1 -0
  80. package/dist/cjs/utils/errors.js +63 -40
  81. package/dist/cjs/utils/errors.js.map +1 -0
  82. package/dist/cjs/utils/getMaxPriorityFeePerGas.js +23 -0
  83. package/dist/cjs/utils/getMaxPriorityFeePerGas.js.map +1 -0
  84. package/dist/cjs/utils/index.js +9 -0
  85. package/dist/cjs/utils/index.js.map +1 -0
  86. package/dist/cjs/utils/median.js +16 -0
  87. package/dist/cjs/utils/median.js.map +1 -0
  88. package/dist/cjs/utils/parseError.js +55 -92
  89. package/dist/cjs/utils/parseError.js.map +1 -0
  90. package/dist/cjs/utils/utils.js +10 -85
  91. package/dist/cjs/utils/utils.js.map +1 -0
  92. package/dist/cjs/version.js +2 -1
  93. package/dist/cjs/version.js.map +1 -0
  94. package/dist/esm/LiFi.js +375 -0
  95. package/dist/esm/LiFi.js.map +1 -0
  96. package/dist/esm/allowance/getAllowance.js +79 -0
  97. package/dist/esm/allowance/getAllowance.js.map +1 -0
  98. package/dist/esm/allowance/index.js +4 -0
  99. package/dist/esm/allowance/index.js.map +1 -0
  100. package/dist/esm/allowance/setAllowance.js +67 -0
  101. package/dist/esm/allowance/setAllowance.js.map +1 -0
  102. package/dist/esm/allowance/types.js +2 -0
  103. package/dist/esm/allowance/types.js.map +1 -0
  104. package/dist/esm/balance/getBalance.js +93 -0
  105. package/dist/esm/balance/getBalance.js.map +1 -0
  106. package/dist/{balance → esm/balance}/getTokenBalance.js +5 -4
  107. package/dist/esm/balance/getTokenBalance.js.map +1 -0
  108. package/dist/esm/balance/index.js +3 -0
  109. package/dist/esm/balance/index.js.map +1 -0
  110. package/dist/esm/connectors.js +42 -0
  111. package/dist/esm/connectors.js.map +1 -0
  112. package/dist/esm/constants.js +7 -0
  113. package/dist/esm/constants.js.map +1 -0
  114. package/dist/esm/execution/BaseStepExecutor.js +51 -0
  115. package/dist/esm/execution/BaseStepExecutor.js.map +1 -0
  116. package/dist/esm/execution/EVMStepExecutor.js +299 -0
  117. package/dist/esm/execution/EVMStepExecutor.js.map +1 -0
  118. package/dist/esm/execution/RouteExecutionManager.js +268 -0
  119. package/dist/esm/execution/RouteExecutionManager.js.map +1 -0
  120. package/dist/esm/execution/StatusManager.js +216 -0
  121. package/dist/esm/execution/StatusManager.js.map +1 -0
  122. package/dist/esm/execution/StepExecutionManager.js +280 -0
  123. package/dist/esm/execution/StepExecutionManager.js.map +1 -0
  124. package/dist/esm/execution/checkAllowance.js +74 -0
  125. package/dist/esm/execution/checkAllowance.js.map +1 -0
  126. package/dist/esm/execution/checkBalance.js +39 -0
  127. package/dist/esm/execution/checkBalance.js.map +1 -0
  128. package/dist/esm/execution/index.js +3 -0
  129. package/dist/esm/execution/index.js.map +1 -0
  130. package/dist/esm/execution/multisig.js +26 -0
  131. package/dist/esm/execution/multisig.js.map +1 -0
  132. package/dist/esm/execution/prepareRestart.js +64 -0
  133. package/dist/esm/execution/prepareRestart.js.map +1 -0
  134. package/dist/{execution → esm/execution}/stepComparison.js +5 -4
  135. package/dist/esm/execution/stepComparison.js.map +1 -0
  136. package/dist/{execution → esm/execution}/switchChain.js +19 -12
  137. package/dist/esm/execution/switchChain.js.map +1 -0
  138. package/dist/esm/execution/types.js +2 -0
  139. package/dist/esm/execution/types.js.map +1 -0
  140. package/dist/esm/execution/utils.js +80 -0
  141. package/dist/esm/execution/utils.js.map +1 -0
  142. package/dist/esm/execution/waitForReceivingTransaction.js +52 -0
  143. package/dist/esm/execution/waitForReceivingTransaction.js.map +1 -0
  144. package/dist/{helpers.js → esm/helpers.js} +9 -37
  145. package/dist/esm/helpers.js.map +1 -0
  146. package/dist/esm/index.js +10 -0
  147. package/dist/esm/index.js.map +1 -0
  148. package/dist/esm/package.json +1 -0
  149. package/dist/esm/providers/EVM.js +30 -0
  150. package/dist/esm/providers/EVM.js.map +1 -0
  151. package/dist/esm/providers/Solana.js +34 -0
  152. package/dist/esm/providers/Solana.js.map +1 -0
  153. package/dist/esm/providers/index.js +2 -0
  154. package/dist/esm/providers/index.js.map +1 -0
  155. package/dist/esm/providers/types.js +6 -0
  156. package/dist/esm/providers/types.js.map +1 -0
  157. package/dist/{request.js → esm/request.js} +6 -5
  158. package/dist/esm/request.js.map +1 -0
  159. package/dist/{services → esm/services}/ApiService.js +29 -26
  160. package/dist/esm/services/ApiService.js.map +1 -0
  161. package/dist/{services → esm/services}/ChainsService.js +16 -4
  162. package/dist/esm/services/ChainsService.js.map +1 -0
  163. package/dist/esm/services/ConfigService.js +143 -0
  164. package/dist/esm/services/ConfigService.js.map +1 -0
  165. package/dist/{typeguards.js → esm/typeguards.js} +1 -0
  166. package/dist/esm/typeguards.js.map +1 -0
  167. package/dist/esm/types/abi.js +43 -0
  168. package/dist/esm/types/abi.js.map +1 -0
  169. package/dist/esm/types/index.js +3 -0
  170. package/dist/esm/types/index.js.map +1 -0
  171. package/dist/esm/types/internal.js +2 -0
  172. package/dist/esm/types/internal.js.map +1 -0
  173. package/dist/{utils → esm/utils}/errors.js +61 -35
  174. package/dist/esm/utils/errors.js.map +1 -0
  175. package/dist/esm/utils/getMaxPriorityFeePerGas.js +19 -0
  176. package/dist/esm/utils/getMaxPriorityFeePerGas.js.map +1 -0
  177. package/dist/esm/utils/index.js +6 -0
  178. package/dist/esm/utils/index.js.map +1 -0
  179. package/dist/esm/utils/median.js +12 -0
  180. package/dist/esm/utils/median.js.map +1 -0
  181. package/dist/{utils → esm/utils}/parseError.js +45 -41
  182. package/dist/esm/utils/parseError.js.map +1 -0
  183. package/dist/esm/utils/utils.js +38 -0
  184. package/dist/esm/utils/utils.js.map +1 -0
  185. package/dist/esm/version.js +3 -0
  186. package/dist/esm/version.js.map +1 -0
  187. package/dist/types/LiFi.d.ts +179 -0
  188. package/dist/types/LiFi.d.ts.map +1 -0
  189. package/dist/types/allowance/getAllowance.d.ts +7 -0
  190. package/dist/types/allowance/getAllowance.d.ts.map +1 -0
  191. package/dist/types/allowance/index.d.ts +4 -0
  192. package/dist/types/allowance/index.d.ts.map +1 -0
  193. package/dist/types/allowance/setAllowance.d.ts +7 -0
  194. package/dist/types/allowance/setAllowance.d.ts.map +1 -0
  195. package/dist/types/allowance/types.d.ts +28 -0
  196. package/dist/types/allowance/types.d.ts.map +1 -0
  197. package/dist/types/balance/getBalance.d.ts +3 -0
  198. package/dist/types/balance/getBalance.d.ts.map +1 -0
  199. package/dist/{balance → types/balance}/getTokenBalance.d.ts +3 -2
  200. package/dist/types/balance/getTokenBalance.d.ts.map +1 -0
  201. package/dist/types/balance/index.d.ts +3 -0
  202. package/dist/types/balance/index.d.ts.map +1 -0
  203. package/dist/types/connectors.d.ts +9 -0
  204. package/dist/types/connectors.d.ts.map +1 -0
  205. package/dist/types/constants.d.ts +7 -0
  206. package/dist/types/constants.d.ts.map +1 -0
  207. package/dist/types/execution/BaseStepExecutor.d.ts +13 -0
  208. package/dist/types/execution/BaseStepExecutor.d.ts.map +1 -0
  209. package/dist/types/execution/EVMStepExecutor.d.ts +14 -0
  210. package/dist/types/execution/EVMStepExecutor.d.ts.map +1 -0
  211. package/dist/types/execution/RouteExecutionManager.d.ts +61 -0
  212. package/dist/types/execution/RouteExecutionManager.d.ts.map +1 -0
  213. package/dist/types/execution/StatusManager.d.ts +69 -0
  214. package/dist/types/execution/StatusManager.d.ts.map +1 -0
  215. package/dist/types/execution/StepExecutionManager.d.ts +8 -0
  216. package/dist/types/execution/StepExecutionManager.d.ts.map +1 -0
  217. package/dist/types/execution/checkAllowance.d.ts +6 -0
  218. package/dist/types/execution/checkAllowance.d.ts.map +1 -0
  219. package/dist/types/execution/checkBalance.d.ts +3 -0
  220. package/dist/types/execution/checkBalance.d.ts.map +1 -0
  221. package/dist/types/execution/index.d.ts +3 -0
  222. package/dist/types/execution/index.d.ts.map +1 -0
  223. package/dist/types/execution/multisig.d.ts +5 -0
  224. package/dist/types/execution/multisig.d.ts.map +1 -0
  225. package/dist/types/execution/prepareRestart.d.ts +3 -0
  226. package/dist/types/execution/prepareRestart.d.ts.map +1 -0
  227. package/dist/{execution → types/execution}/stepComparison.d.ts +6 -4
  228. package/dist/types/execution/stepComparison.d.ts.map +1 -0
  229. package/dist/types/execution/switchChain.d.ts +23 -0
  230. package/dist/types/execution/switchChain.d.ts.map +1 -0
  231. package/dist/types/execution/types.d.ts +83 -0
  232. package/dist/types/execution/types.d.ts.map +1 -0
  233. package/dist/types/execution/utils.d.ts +13 -0
  234. package/dist/types/execution/utils.d.ts.map +1 -0
  235. package/dist/types/execution/waitForReceivingTransaction.d.ts +4 -0
  236. package/dist/types/execution/waitForReceivingTransaction.d.ts.map +1 -0
  237. package/dist/types/helpers.d.ts +19 -0
  238. package/dist/types/helpers.d.ts.map +1 -0
  239. package/dist/types/index.d.ts +9 -3
  240. package/dist/types/index.d.ts.map +1 -0
  241. package/dist/types/providers/EVM.d.ts +11 -0
  242. package/dist/types/providers/EVM.d.ts.map +1 -0
  243. package/dist/types/providers/Solana.d.ts +10 -0
  244. package/dist/types/providers/Solana.d.ts.map +1 -0
  245. package/dist/types/providers/index.d.ts +2 -0
  246. package/dist/types/providers/index.d.ts.map +1 -0
  247. package/dist/types/providers/types.d.ts +13 -0
  248. package/dist/types/providers/types.d.ts.map +1 -0
  249. package/dist/{request.d.ts → types/request.d.ts} +1 -0
  250. package/dist/types/request.d.ts.map +1 -0
  251. package/dist/{cjs → types}/services/ApiService.d.ts +5 -5
  252. package/dist/types/services/ApiService.d.ts.map +1 -0
  253. package/dist/{services → types/services}/ChainsService.d.ts +3 -2
  254. package/dist/types/services/ChainsService.d.ts.map +1 -0
  255. package/dist/{services → types/services}/ConfigService.d.ts +10 -6
  256. package/dist/types/services/ConfigService.d.ts.map +1 -0
  257. package/dist/{cjs → types}/typeguards.d.ts +3 -2
  258. package/dist/types/typeguards.d.ts.map +1 -0
  259. package/dist/types/types/abi.d.ts +6 -0
  260. package/dist/types/types/abi.d.ts.map +1 -0
  261. package/dist/types/types/index.d.ts +3 -0
  262. package/dist/types/types/index.d.ts.map +1 -0
  263. package/dist/types/types/internal.d.ts +61 -0
  264. package/dist/types/types/internal.d.ts.map +1 -0
  265. package/dist/{cjs → types}/utils/errors.d.ts +16 -14
  266. package/dist/types/utils/errors.d.ts.map +1 -0
  267. package/dist/types/utils/getMaxPriorityFeePerGas.d.ts +3 -0
  268. package/dist/types/utils/getMaxPriorityFeePerGas.d.ts.map +1 -0
  269. package/dist/types/utils/index.d.ts +6 -0
  270. package/dist/types/utils/index.d.ts.map +1 -0
  271. package/dist/types/utils/median.d.ts +2 -0
  272. package/dist/types/utils/median.d.ts.map +1 -0
  273. package/dist/{utils → types/utils}/parseError.d.ts +7 -6
  274. package/dist/types/utils/parseError.d.ts.map +1 -0
  275. package/dist/types/utils/utils.d.ts +11 -0
  276. package/dist/types/utils/utils.d.ts.map +1 -0
  277. package/dist/types/version.d.ts +3 -0
  278. package/dist/types/version.d.ts.map +1 -0
  279. package/package.json +37 -95
  280. package/dist/LiFi.d.ts +0 -164
  281. package/dist/LiFi.js +0 -235
  282. package/dist/allowance/checkAllowance.d.ts +0 -4
  283. package/dist/allowance/checkAllowance.js +0 -96
  284. package/dist/allowance/index.d.ts +0 -2
  285. package/dist/allowance/index.js +0 -2
  286. package/dist/allowance/tokenApproval.d.ts +0 -22
  287. package/dist/allowance/tokenApproval.js +0 -59
  288. package/dist/allowance/utils.d.ts +0 -14
  289. package/dist/allowance/utils.js +0 -72
  290. package/dist/balance/checkBalance.d.ts +0 -3
  291. package/dist/balance/checkBalance.js +0 -38
  292. package/dist/balance/index.d.ts +0 -13
  293. package/dist/balance/index.js +0 -10
  294. package/dist/balance/utils.d.ts +0 -6
  295. package/dist/balance/utils.js +0 -143
  296. package/dist/cjs/LiFi.d.ts +0 -164
  297. package/dist/cjs/allowance/checkAllowance.d.ts +0 -4
  298. package/dist/cjs/allowance/checkAllowance.js +0 -103
  299. package/dist/cjs/allowance/index.d.ts +0 -2
  300. package/dist/cjs/allowance/tokenApproval.d.ts +0 -22
  301. package/dist/cjs/allowance/tokenApproval.js +0 -69
  302. package/dist/cjs/allowance/utils.d.ts +0 -14
  303. package/dist/cjs/allowance/utils.js +0 -82
  304. package/dist/cjs/balance/checkBalance.d.ts +0 -3
  305. package/dist/cjs/balance/checkBalance.js +0 -45
  306. package/dist/cjs/balance/getTokenBalance.d.ts +0 -8
  307. package/dist/cjs/balance/index.d.ts +0 -13
  308. package/dist/cjs/balance/utils.d.ts +0 -6
  309. package/dist/cjs/balance/utils.js +0 -150
  310. package/dist/cjs/connectors.d.ts +0 -6
  311. package/dist/cjs/execution/RouteExecutionManager.d.ts +0 -65
  312. package/dist/cjs/execution/StatusManager.d.ts +0 -68
  313. package/dist/cjs/execution/StepExecutionManager.d.ts +0 -7
  314. package/dist/cjs/execution/StepExecutor.d.ts +0 -15
  315. package/dist/cjs/execution/StepExecutor.js +0 -62
  316. package/dist/cjs/execution/index.d.ts +0 -1
  317. package/dist/cjs/execution/multisig.d.ts +0 -3
  318. package/dist/cjs/execution/stepComparison.d.ts +0 -14
  319. package/dist/cjs/execution/switchChain.d.ts +0 -16
  320. package/dist/cjs/execution/utils.d.ts +0 -6
  321. package/dist/cjs/helpers.d.ts +0 -28
  322. package/dist/cjs/index.d.ts +0 -5
  323. package/dist/cjs/request.d.ts +0 -9
  324. package/dist/cjs/services/ChainsService.d.ts +0 -11
  325. package/dist/cjs/services/ConfigService.d.ts +0 -23
  326. package/dist/cjs/types/ERC20.d.ts +0 -22
  327. package/dist/cjs/types/ERC20.js +0 -53
  328. package/dist/cjs/types/index.d.ts +0 -4
  329. package/dist/cjs/types/internal.types.d.ts +0 -151
  330. package/dist/cjs/utils/getProvider.d.ts +0 -3
  331. package/dist/cjs/utils/getProvider.js +0 -11
  332. package/dist/cjs/utils/multicall.d.ts +0 -10
  333. package/dist/cjs/utils/multicall.js +0 -68
  334. package/dist/cjs/utils/multicallAbi.json +0 -313
  335. package/dist/cjs/utils/parseError.d.ts +0 -37
  336. package/dist/cjs/utils/preRestart.d.ts +0 -3
  337. package/dist/cjs/utils/preRestart.js +0 -56
  338. package/dist/cjs/utils/utils.d.ts +0 -25
  339. package/dist/cjs/version.d.ts +0 -2
  340. package/dist/connectors.d.ts +0 -6
  341. package/dist/connectors.js +0 -57
  342. package/dist/execution/RouteExecutionManager.d.ts +0 -65
  343. package/dist/execution/RouteExecutionManager.js +0 -213
  344. package/dist/execution/StatusManager.d.ts +0 -68
  345. package/dist/execution/StatusManager.js +0 -168
  346. package/dist/execution/StepExecutionManager.d.ts +0 -7
  347. package/dist/execution/StepExecutionManager.js +0 -267
  348. package/dist/execution/StepExecutor.d.ts +0 -15
  349. package/dist/execution/StepExecutor.js +0 -58
  350. package/dist/execution/index.d.ts +0 -1
  351. package/dist/execution/index.js +0 -1
  352. package/dist/execution/multisig.d.ts +0 -3
  353. package/dist/execution/multisig.js +0 -27
  354. package/dist/execution/switchChain.d.ts +0 -16
  355. package/dist/execution/utils.d.ts +0 -6
  356. package/dist/execution/utils.js +0 -122
  357. package/dist/helpers.d.ts +0 -28
  358. package/dist/index.d.ts +0 -5
  359. package/dist/index.js +0 -6
  360. package/dist/services/ApiService.d.ts +0 -17
  361. package/dist/services/ConfigService.js +0 -101
  362. package/dist/typeguards.d.ts +0 -4
  363. package/dist/types/ERC20.d.ts +0 -22
  364. package/dist/types/ERC20.js +0 -50
  365. package/dist/types/index.js +0 -4
  366. package/dist/types/internal.types.d.ts +0 -151
  367. package/dist/types/internal.types.js +0 -1
  368. package/dist/utils/errors.d.ts +0 -106
  369. package/dist/utils/getProvider.d.ts +0 -3
  370. package/dist/utils/getProvider.js +0 -7
  371. package/dist/utils/multicall.d.ts +0 -10
  372. package/dist/utils/multicall.js +0 -61
  373. package/dist/utils/multicallAbi.json +0 -313
  374. package/dist/utils/preRestart.d.ts +0 -3
  375. package/dist/utils/preRestart.js +0 -52
  376. package/dist/utils/utils.d.ts +0 -25
  377. package/dist/utils/utils.js +0 -99
  378. package/dist/version.d.ts +0 -2
  379. package/dist/version.js +0 -2
@@ -1,213 +0,0 @@
1
- import ConfigService from '../services/ConfigService';
2
- import { ValidationError } from '../utils/errors';
3
- import { handlePreRestart } from '../utils/preRestart';
4
- import { StatusManager } from './StatusManager';
5
- import { StepExecutor } from './StepExecutor';
6
- export class RouteExecutionManager {
7
- constructor(configUpdate) {
8
- this.executionDictionary = {};
9
- this.executionPromiseDictionary = {};
10
- /**
11
- * Execute a route.
12
- * @param {Signer} signer - The signer required to send the transactions.
13
- * @param {Route} route - The route that should be executed. Cannot be an active route.
14
- * @param {ExecutionSettings} settings - An object containing settings and callbacks.
15
- * @return {Promise<Route>} The executed route.
16
- * @throws {LifiError} Throws a LifiError if the execution fails.
17
- */
18
- this.executeRoute = async (signer, route, settings) => {
19
- // Deep clone to prevent side effects
20
- const clonedRoute = structuredClone(route);
21
- let executionPromise = this.executionPromiseDictionary[clonedRoute.id];
22
- // Check if route is already running
23
- if (executionPromise) {
24
- return executionPromise;
25
- }
26
- executionPromise = this.executeSteps(signer, clonedRoute, settings);
27
- this.executionPromiseDictionary[clonedRoute.id] = executionPromise;
28
- return executionPromise;
29
- };
30
- /**
31
- * Resume the execution of a route that has been stopped or had an error while executing.
32
- * @param {Signer} signer - The signer required to send the transactions.
33
- * @param {Route} route - The route that is to be executed. Cannot be an active route.
34
- * @param {ExecutionSettings} settings - An object containing settings and callbacks.
35
- * @return {Promise<Route>} The executed route.
36
- * @throws {LifiError} Throws a LifiError if the execution fails.
37
- */
38
- this.resumeRoute = async (signer, route, settings) => {
39
- // Deep clone to prevent side effects
40
- const clonedRoute = structuredClone(route);
41
- const execution = this.executionDictionary[clonedRoute.id];
42
- if (execution) {
43
- const executionHalted = execution.executors.some((executor) => executor.executionStopped);
44
- if (!executionHalted) {
45
- // Check if we want to resume route execution in the background
46
- this.updateRouteExecution(route, {
47
- executeInBackground: settings?.executeInBackground,
48
- });
49
- const executionPromise = this.executionPromiseDictionary[clonedRoute.id];
50
- return executionPromise ?? clonedRoute;
51
- }
52
- }
53
- await handlePreRestart(clonedRoute, signer);
54
- const executionPromise = this.executeSteps(signer, clonedRoute, settings);
55
- this.executionPromiseDictionary[clonedRoute.id] = executionPromise;
56
- return executionPromise;
57
- };
58
- this.executeSteps = async (signer, route, settings) => {
59
- const config = this.configService.getConfig();
60
- const execution = {
61
- route,
62
- executors: [],
63
- settings: { ...config.defaultExecutionSettings, ...settings },
64
- };
65
- this.executionDictionary[route.id] = execution;
66
- const statusManager = new StatusManager(route, execution.settings, (route) => {
67
- if (this.executionDictionary[route.id]) {
68
- execution.route = route;
69
- }
70
- });
71
- // Loop over steps and execute them
72
- for (let index = 0; index < route.steps.length; index++) {
73
- const execution = this.executionDictionary[route.id];
74
- // Check if execution has stopped in the meantime
75
- if (!execution) {
76
- break;
77
- }
78
- const step = route.steps[index];
79
- const previousStep = route.steps[index - 1];
80
- // Check if the step is already done
81
- //
82
- if (step.execution?.status === 'DONE') {
83
- continue;
84
- }
85
- // Update amount using output of previous execution. In the future this should be handled by calling `updateRoute`
86
- if (previousStep?.execution?.toAmount) {
87
- step.action.fromAmount = previousStep.execution.toAmount;
88
- }
89
- try {
90
- const stepExecutor = new StepExecutor(statusManager, execution.settings);
91
- execution.executors.push(stepExecutor);
92
- // Check if we want to execute this step in the background
93
- this.updateRouteExecution(route, execution.settings);
94
- const executedStep = await stepExecutor.executeStep(signer, step);
95
- // We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it
96
- if (executedStep.execution?.status !== 'DONE') {
97
- this.stopExecution(route);
98
- }
99
- // Execution stopped during the current step, we don't want to continue to the next step so we return already
100
- if (stepExecutor.executionStopped) {
101
- return route;
102
- }
103
- }
104
- catch (e) {
105
- this.stopExecution(route);
106
- throw e;
107
- }
108
- }
109
- // Clean up after the execution
110
- delete this.executionDictionary[route.id];
111
- return route;
112
- };
113
- /**
114
- * Updates route execution to background or foreground state.
115
- * @param {Route} route - A route that is currently in execution.
116
- * @param {boolean} settings - An object with execution settings.
117
- */
118
- this.updateRouteExecution = (route, settings) => {
119
- const execution = this.executionDictionary[route.id];
120
- if (!execution) {
121
- return;
122
- }
123
- for (const executor of execution.executors) {
124
- executor.setInteraction({
125
- allowInteraction: !settings.executeInBackground,
126
- allowUpdates: true,
127
- });
128
- }
129
- // Update active route settings so we know what the current state of execution is
130
- execution.settings = {
131
- ...execution.settings,
132
- ...settings,
133
- };
134
- };
135
- /**
136
- * Update the ExecutionSettings for an active route.
137
- * @param {ExecutionSettings} settings - An object with execution settings.
138
- * @param {Route} route - The active route that gets the new execution settings.
139
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
140
- */
141
- this.updateExecutionSettings = (settings, route) => {
142
- const execution = this.executionDictionary[route.id];
143
- if (!execution) {
144
- throw new ValidationError("Can't set ExecutionSettings for the inactive route.");
145
- }
146
- const config = this.configService.getConfig();
147
- execution.settings = {
148
- ...config.defaultExecutionSettings,
149
- ...settings,
150
- };
151
- };
152
- /**
153
- * Executes a route until a user interaction is necessary (signing transactions, etc.) and then halts until the route is resumed.
154
- * @param {Route} route - A route that is currently in execution.
155
- * @deprecated use updateRouteExecution instead.
156
- */
157
- this.moveExecutionToBackground = (route) => {
158
- const execution = this.executionDictionary[route.id];
159
- if (!execution) {
160
- return;
161
- }
162
- for (const executor of execution.executors) {
163
- executor.setInteraction({ allowInteraction: false, allowUpdates: true });
164
- }
165
- execution.settings = {
166
- ...execution.settings,
167
- executeInBackground: true,
168
- };
169
- };
170
- /**
171
- * Stops the execution of an active route.
172
- * @param {Route} route - A route that is currently in execution.
173
- * @return {Route} The stopped route.
174
- */
175
- this.stopExecution = (route) => {
176
- const execution = this.executionDictionary[route.id];
177
- if (!execution) {
178
- return route;
179
- }
180
- for (const executor of execution.executors) {
181
- executor.setInteraction({
182
- allowInteraction: false,
183
- allowUpdates: false,
184
- stopExecution: true,
185
- });
186
- }
187
- delete this.executionDictionary[route.id];
188
- return route;
189
- };
190
- /**
191
- * Get the list of active routes.
192
- * @return {Route[]} A list of routes.
193
- */
194
- this.getActiveRoutes = () => {
195
- return Object.values(this.executionDictionary)
196
- .map((dict) => dict?.route)
197
- .filter(Boolean);
198
- };
199
- /**
200
- * Return the current route information for given route. The route has to be active.
201
- * @param {Route} route - A route object.
202
- * @return {Route} The updated route.
203
- */
204
- this.getActiveRoute = (route) => {
205
- return this.executionDictionary[route.id]?.route;
206
- };
207
- this.configService = ConfigService.getInstance();
208
- if (configUpdate) {
209
- // Update API urls before we request chains
210
- this.configService.updateConfig(configUpdate);
211
- }
212
- }
213
- }
@@ -1,68 +0,0 @@
1
- import { Execution, InternalExecutionSettings, LifiStep, Process, ProcessType, Route, Status, Token } from '../types';
2
- interface Receipt {
3
- fromAmount?: string;
4
- toAmount?: string;
5
- toToken?: Token;
6
- gasPrice?: string;
7
- gasUsed?: string;
8
- gasToken?: Token;
9
- gasAmount?: string;
10
- gasAmountUSD?: string;
11
- }
12
- type InternalUpdateRouteCallback = (route: Route) => void;
13
- type OptionalParameters = Partial<Pick<Process, 'doneAt' | 'failedAt' | 'txHash' | 'txLink' | 'error' | 'substatus' | 'substatusMessage' | 'multisigTxHash'>>;
14
- /**
15
- * Manages status updates of a route and provides various functions for tracking processes
16
- * @param {Route} route The route this StatusManger belongs to.
17
- * @param {InternalExecutionSettings} settings The ExecutionSettings for this route.
18
- * @param {InternalUpdateRouteCallback} internalUpdateRouteCallback Internal callback to propage route changes.
19
- * @return {StatusManager} An instance of StatusManager.
20
- */
21
- export declare class StatusManager {
22
- private readonly route;
23
- private readonly settings;
24
- private readonly internalUpdateRouteCallback;
25
- private shouldUpdate;
26
- constructor(route: Route, settings: InternalExecutionSettings, internalUpdateRouteCallback: InternalUpdateRouteCallback);
27
- /**
28
- * Initializes the execution object of a Step.
29
- * @param {LifiStep} step The current step in execution
30
- * @return {Execution} The initialized execution object for this step and a function to update this step
31
- */
32
- initExecutionObject: (step: LifiStep) => Execution;
33
- /**
34
- * Updates the execution object of a Step.
35
- * @param {LifiStep} step The current step in execution
36
- * @param {Status} status The status for the execution
37
- * @param {Receipt} receipt Optional. Information about received tokens
38
- * @return {Step} The step with the updated execution object
39
- */
40
- updateExecution(step: LifiStep, status: Status, receipt?: Receipt): LifiStep;
41
- /**
42
- * Create and push a new process into the execution.
43
- * @param {ProcessType} type Type of the process. Used to identify already existing processes.
44
- * @param {LifiStep} step The step that should contain the new process.
45
- * @param {Status} status By default created procces is set to the STARTED status. We can override new process with the needed status.
46
- * @return {Process}
47
- */
48
- findOrCreateProcess: (step: LifiStep, type: ProcessType, status?: Status) => Process;
49
- /**
50
- * Update a process object.
51
- * @param {LifiStep} step The step where the process should be updated
52
- * @param {ProcessType} type The process type to update
53
- * @param {Status} status The status the process gets.
54
- * @param {object} [params] Additional parameters to append to the process.
55
- * @return {Process} The update process
56
- */
57
- updateProcess: (step: LifiStep, type: ProcessType, status: Status, params?: OptionalParameters) => Process;
58
- /**
59
- * Remove a process from the execution
60
- * @param {LifiStep} step The step where the process should be removed from
61
- * @param {ProcessType} type The process type to remove
62
- * @return {void}
63
- */
64
- removeProcess: (step: LifiStep, type: ProcessType) => void;
65
- updateStepInRoute: (step: LifiStep) => LifiStep;
66
- allowUpdates(value: boolean): void;
67
- }
68
- export {};
@@ -1,168 +0,0 @@
1
- import { emptyExecution, } from '../types';
2
- import { getProcessMessage } from './utils';
3
- /**
4
- * Manages status updates of a route and provides various functions for tracking processes
5
- * @param {Route} route The route this StatusManger belongs to.
6
- * @param {InternalExecutionSettings} settings The ExecutionSettings for this route.
7
- * @param {InternalUpdateRouteCallback} internalUpdateRouteCallback Internal callback to propage route changes.
8
- * @return {StatusManager} An instance of StatusManager.
9
- */
10
- export class StatusManager {
11
- constructor(route, settings, internalUpdateRouteCallback) {
12
- this.shouldUpdate = true;
13
- /**
14
- * Initializes the execution object of a Step.
15
- * @param {LifiStep} step The current step in execution
16
- * @return {Execution} The initialized execution object for this step and a function to update this step
17
- */
18
- this.initExecutionObject = (step) => {
19
- const currentExecution = step.execution || structuredClone(emptyExecution);
20
- if (!step.execution) {
21
- step.execution = currentExecution;
22
- step.execution.status = 'PENDING';
23
- this.updateStepInRoute(step);
24
- }
25
- // Change status to PENDING after resuming from FAILED
26
- if (currentExecution.status === 'FAILED') {
27
- currentExecution.status = 'PENDING';
28
- this.updateStepInRoute(step);
29
- }
30
- return currentExecution;
31
- };
32
- /**
33
- * Create and push a new process into the execution.
34
- * @param {ProcessType} type Type of the process. Used to identify already existing processes.
35
- * @param {LifiStep} step The step that should contain the new process.
36
- * @param {Status} status By default created procces is set to the STARTED status. We can override new process with the needed status.
37
- * @return {Process}
38
- */
39
- this.findOrCreateProcess = (step, type, status) => {
40
- if (!step.execution?.process) {
41
- throw new Error("Execution hasn't been initialized.");
42
- }
43
- const process = step.execution.process.find((p) => p.type === type);
44
- if (process) {
45
- if (status && process.status !== status) {
46
- process.status = status;
47
- this.updateStepInRoute(step);
48
- }
49
- return process;
50
- }
51
- const newProcess = {
52
- type: type,
53
- startedAt: Date.now(),
54
- message: getProcessMessage(type, status ?? 'STARTED'),
55
- status: status ?? 'STARTED',
56
- };
57
- step.execution.process.push(newProcess);
58
- this.updateStepInRoute(step);
59
- return newProcess;
60
- };
61
- /**
62
- * Update a process object.
63
- * @param {LifiStep} step The step where the process should be updated
64
- * @param {ProcessType} type The process type to update
65
- * @param {Status} status The status the process gets.
66
- * @param {object} [params] Additional parameters to append to the process.
67
- * @return {Process} The update process
68
- */
69
- this.updateProcess = (step, type, status, params) => {
70
- if (!step.execution) {
71
- throw new Error("Can't update an empty step execution.");
72
- }
73
- const currentProcess = step?.execution?.process.find((p) => p.type === type);
74
- if (!currentProcess) {
75
- throw new Error("Can't find a process for the given type.");
76
- }
77
- switch (status) {
78
- case 'CANCELLED':
79
- currentProcess.doneAt = Date.now();
80
- break;
81
- case 'FAILED':
82
- currentProcess.doneAt = Date.now();
83
- step.execution.status = 'FAILED';
84
- break;
85
- case 'DONE':
86
- currentProcess.doneAt = Date.now();
87
- break;
88
- case 'PENDING':
89
- step.execution.status = 'PENDING';
90
- break;
91
- case 'ACTION_REQUIRED':
92
- step.execution.status = 'ACTION_REQUIRED';
93
- break;
94
- default:
95
- break;
96
- }
97
- currentProcess.status = status;
98
- currentProcess.message = getProcessMessage(type, status);
99
- // set extra parameters or overwritte the standard params set in the switch statement
100
- if (params) {
101
- for (const [key, value] of Object.entries(params)) {
102
- currentProcess[key] = value;
103
- }
104
- }
105
- // Sort processes, the ones with DONE status go first
106
- step.execution.process = [
107
- ...step?.execution?.process.filter((process) => process.status === 'DONE'),
108
- ...step?.execution?.process.filter((process) => process.status !== 'DONE'),
109
- ];
110
- this.updateStepInRoute(step); // updates the step in the route
111
- return currentProcess;
112
- };
113
- /**
114
- * Remove a process from the execution
115
- * @param {LifiStep} step The step where the process should be removed from
116
- * @param {ProcessType} type The process type to remove
117
- * @return {void}
118
- */
119
- this.removeProcess = (step, type) => {
120
- if (!step.execution) {
121
- throw new Error("Execution hasn't been initialized.");
122
- }
123
- const index = step.execution.process.findIndex((p) => p.type === type);
124
- step.execution.process.splice(index, 1);
125
- this.updateStepInRoute(step);
126
- };
127
- this.updateStepInRoute = (step) => {
128
- if (!this.shouldUpdate) {
129
- return step;
130
- }
131
- const stepIndex = this.route.steps.findIndex((routeStep) => routeStep.id === step.id);
132
- if (stepIndex === -1) {
133
- throw new Error("Couldn't find a step to update.");
134
- }
135
- this.route.steps[stepIndex] = Object.assign(this.route.steps[stepIndex], step);
136
- this.settings.updateRouteHook(this.route);
137
- this.internalUpdateRouteCallback(this.route);
138
- return this.route.steps[stepIndex];
139
- };
140
- this.route = route;
141
- this.settings = settings;
142
- this.internalUpdateRouteCallback = internalUpdateRouteCallback;
143
- }
144
- /**
145
- * Updates the execution object of a Step.
146
- * @param {LifiStep} step The current step in execution
147
- * @param {Status} status The status for the execution
148
- * @param {Receipt} receipt Optional. Information about received tokens
149
- * @return {Step} The step with the updated execution object
150
- */
151
- updateExecution(step, status, receipt) {
152
- if (!step.execution) {
153
- throw Error("Can't update empty execution.");
154
- }
155
- step.execution.status = status;
156
- if (receipt) {
157
- step.execution = {
158
- ...step.execution,
159
- ...receipt,
160
- };
161
- }
162
- this.updateStepInRoute(step);
163
- return step;
164
- }
165
- allowUpdates(value) {
166
- this.shouldUpdate = value;
167
- }
168
- }
@@ -1,7 +0,0 @@
1
- import { Execution } from '@lifi/types';
2
- import { ExecutionParams } from '../types';
3
- export declare class StepExecutionManager {
4
- allowUserInteraction: boolean;
5
- allowInteraction: (value: boolean) => void;
6
- execute: ({ signer, step, statusManager, settings, }: ExecutionParams) => Promise<Execution>;
7
- }