@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,22 +0,0 @@
1
- import { Token } from '@lifi/types';
2
- import { Signer } from 'ethers';
3
- import { RevokeTokenData } from '../types';
4
- export interface ApproveTokenRequest {
5
- signer: Signer;
6
- token: Token;
7
- approvalAddress: string;
8
- amount: string;
9
- infiniteApproval?: boolean;
10
- }
11
- export interface RevokeApprovalRequest {
12
- signer: Signer;
13
- token: Token;
14
- approvalAddress: string;
15
- }
16
- export declare const getTokenApproval: (signer: Signer, token: Token, approvalAddress: string) => Promise<string | undefined>;
17
- export declare const bulkGetTokenApproval: (signer: Signer, tokenData: RevokeTokenData[]) => Promise<{
18
- token: Token;
19
- approval: string | undefined;
20
- }[]>;
21
- export declare const approveToken: ({ signer, token, approvalAddress, amount, infiniteApproval, }: ApproveTokenRequest) => Promise<void>;
22
- export declare const revokeTokenApproval: ({ signer, token, approvalAddress, }: RevokeApprovalRequest) => Promise<void>;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.revokeTokenApproval = exports.approveToken = exports.bulkGetTokenApproval = exports.getTokenApproval = void 0;
7
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
- const ethers_1 = require("ethers");
9
- const helpers_1 = require("../helpers");
10
- const utils_1 = require("../utils/utils");
11
- const utils_2 = require("./utils");
12
- const getTokenApproval = async (signer, token, approvalAddress) => {
13
- // native token don't need approval
14
- if ((0, utils_1.isNativeTokenAddress)(token.address)) {
15
- return;
16
- }
17
- const approved = await (0, utils_2.getApproved)(signer, token.address, approvalAddress);
18
- return approved.toFixed(0);
19
- };
20
- exports.getTokenApproval = getTokenApproval;
21
- const bulkGetTokenApproval = async (signer, tokenData) => {
22
- // filter out native tokens
23
- const filteredTokenData = tokenData.filter(({ token }) => !(0, utils_1.isNativeTokenAddress)(token.address));
24
- // group by chain
25
- const tokenDataByChain = (0, utils_2.groupByChain)(filteredTokenData);
26
- const approvalPromises = Object.keys(tokenDataByChain).map(async (chainId) => {
27
- const parsedChainId = Number.parseInt(chainId);
28
- // get allowances for current chain and token list
29
- return (0, utils_2.getAllowanceViaMulticall)(signer, parsedChainId, tokenDataByChain[parsedChainId]);
30
- });
31
- const approvalsByChain = await Promise.all(approvalPromises);
32
- const approvals = approvalsByChain.flat();
33
- return tokenData.map(({ token }) => {
34
- // native token don't need approval
35
- if ((0, utils_1.isNativeTokenAddress)(token.address)) {
36
- return { token, approval: undefined };
37
- }
38
- const approved = approvals.find((approval) => (0, helpers_1.isSameToken)(approval.token, token));
39
- return { token, approval: approved?.approvedAmount.toString() };
40
- });
41
- };
42
- exports.bulkGetTokenApproval = bulkGetTokenApproval;
43
- const approveToken = async ({ signer, token, approvalAddress, amount, infiniteApproval = false, }) => {
44
- // native token don't need approval
45
- if ((0, utils_1.isNativeTokenAddress)(token.address)) {
46
- return;
47
- }
48
- const approvedAmount = await (0, utils_2.getApproved)(signer, token.address, approvalAddress);
49
- if (new bignumber_js_1.default(amount).gt(approvedAmount)) {
50
- const approvalAmount = infiniteApproval
51
- ? ethers_1.constants.MaxUint256.toString()
52
- : amount;
53
- const approveTx = await (0, utils_2.setApproval)(signer, token.address, approvalAddress, approvalAmount);
54
- await approveTx.wait();
55
- }
56
- };
57
- exports.approveToken = approveToken;
58
- const revokeTokenApproval = async ({ signer, token, approvalAddress, }) => {
59
- // native token don't need approval
60
- if ((0, utils_1.isNativeTokenAddress)(token.address)) {
61
- return;
62
- }
63
- const approvedAmount = await (0, utils_2.getApproved)(signer, token.address, approvalAddress);
64
- if (!approvedAmount.isZero()) {
65
- const approveTx = await (0, utils_2.setApproval)(signer, token.address, approvalAddress, '0');
66
- await approveTx.wait();
67
- }
68
- };
69
- exports.revokeTokenApproval = revokeTokenApproval;
@@ -1,14 +0,0 @@
1
- import { ChainId, Token } from '@lifi/types';
2
- import BigNumber from 'bignumber.js';
3
- import { ContractTransaction, PopulatedTransaction, Signer } from 'ethers';
4
- import { RevokeTokenData } from '../types';
5
- export declare const getApproved: (signer: Signer, tokenAddress: string, contractAddress: string) => Promise<BigNumber>;
6
- export declare const setApproval: (signer: Signer, tokenAddress: string, contractAddress: string, amount: string, returnPopulatedTransaction?: boolean) => Promise<ContractTransaction | PopulatedTransaction>;
7
- export declare const getAllowanceViaMulticall: (signer: Signer, chainId: ChainId, tokenData: RevokeTokenData[]) => Promise<{
8
- token: Token;
9
- approvalAddress: string;
10
- approvedAmount: BigNumber;
11
- }[]>;
12
- export declare const groupByChain: (tokenDataList: RevokeTokenData[]) => {
13
- [chainId: number]: RevokeTokenData[];
14
- };
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.groupByChain = exports.getAllowanceViaMulticall = exports.setApproval = exports.getApproved = void 0;
7
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
- const ethers_1 = require("ethers");
9
- const ChainsService_1 = __importDefault(require("../services/ChainsService"));
10
- const types_1 = require("../types");
11
- const errors_1 = require("../utils/errors");
12
- const multicall_1 = require("../utils/multicall");
13
- const getApproved = async (signer, tokenAddress, contractAddress) => {
14
- const signerAddress = await signer.getAddress();
15
- const erc20 = new ethers_1.Contract(tokenAddress, types_1.ERC20_ABI, signer);
16
- try {
17
- const approved = await erc20.allowance(signerAddress, contractAddress);
18
- return new bignumber_js_1.default(approved.toString());
19
- }
20
- catch (e) {
21
- return new bignumber_js_1.default(0);
22
- }
23
- };
24
- exports.getApproved = getApproved;
25
- const setApproval = async (signer, tokenAddress, contractAddress, amount, returnPopulatedTransaction) => {
26
- const erc20 = new ethers_1.Contract(tokenAddress, types_1.ERC20_ABI, signer);
27
- if (returnPopulatedTransaction) {
28
- return erc20.populateTransaction.approve(contractAddress, amount);
29
- }
30
- const transactionRequest = await erc20.populateTransaction.approve(contractAddress, amount);
31
- try {
32
- const estimatedGasLimit = await signer.estimateGas(transactionRequest);
33
- if (estimatedGasLimit) {
34
- const formattedGasLimit = ethers_1.ethers.BigNumber.from(`${(BigInt(estimatedGasLimit.toString()) * 125n) / 100n}`);
35
- transactionRequest.gasLimit = formattedGasLimit;
36
- }
37
- }
38
- catch (error) { }
39
- return signer.sendTransaction(transactionRequest);
40
- };
41
- exports.setApproval = setApproval;
42
- const getAllowanceViaMulticall = async (signer, chainId, tokenData) => {
43
- const chainsService = ChainsService_1.default.getInstance();
44
- const chain = await chainsService.getChainById(chainId);
45
- if (!chain.multicallAddress) {
46
- throw new errors_1.ServerError(`No multicall address configured for chainId ${chainId}.`);
47
- }
48
- const ownerAddress = await signer.getAddress();
49
- const calls = [];
50
- tokenData.map(({ token, approvalAddress }) => {
51
- calls.push({
52
- address: token.address,
53
- name: 'allowance',
54
- params: [ownerAddress, approvalAddress],
55
- });
56
- });
57
- const result = await (0, multicall_1.fetchDataUsingMulticall)(calls, types_1.ERC20_ABI, chainId, chain.multicallAddress);
58
- if (!result.length) {
59
- throw new errors_1.ServerError(`Couldn't load allowance from chainId ${chainId} using multicall.`);
60
- }
61
- const parsedResult = result.map(({ data }) => ({
62
- approvalAmount: data ?? new bignumber_js_1.default(0),
63
- }));
64
- return tokenData.map(({ token, approvalAddress }, i) => ({
65
- token,
66
- approvalAddress,
67
- approvedAmount: parsedResult[i].approvalAmount,
68
- }));
69
- };
70
- exports.getAllowanceViaMulticall = getAllowanceViaMulticall;
71
- const groupByChain = (tokenDataList) => {
72
- // group by chain
73
- const tokenDataByChain = {};
74
- tokenDataList.forEach((tokenData) => {
75
- if (!tokenDataByChain[tokenData.token.chainId]) {
76
- tokenDataByChain[tokenData.token.chainId] = [];
77
- }
78
- tokenDataByChain[tokenData.token.chainId].push(tokenData);
79
- });
80
- return tokenDataByChain;
81
- };
82
- exports.groupByChain = groupByChain;
@@ -1,3 +0,0 @@
1
- import { ethers } from 'ethers';
2
- import { LifiStep } from '..';
3
- export declare const checkBalance: (signer: ethers.Signer, step: LifiStep, depth?: number) => Promise<void>;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.checkBalance = void 0;
7
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
- const errors_1 = require("../utils/errors");
9
- const getTokenBalance_1 = require("./getTokenBalance");
10
- const checkBalance = async (signer, step, depth = 0) => {
11
- const tokenAmount = await (0, getTokenBalance_1.getTokenBalance)(await signer.getAddress(), step.action.fromToken);
12
- if (tokenAmount) {
13
- const currentBalance = new bignumber_js_1.default(tokenAmount.amount).shiftedBy(tokenAmount.decimals);
14
- const neededBalance = new bignumber_js_1.default(step.action.fromAmount);
15
- if (currentBalance.lt(neededBalance)) {
16
- if (depth <= 3) {
17
- await new Promise((resolve) => {
18
- setTimeout(resolve, 200);
19
- });
20
- await (0, exports.checkBalance)(signer, step, depth + 1);
21
- }
22
- else if (neededBalance.multipliedBy(1 - step.action.slippage).lte(currentBalance)) {
23
- // adjust amount in slippage limits
24
- step.action.fromAmount = currentBalance.toFixed(0);
25
- }
26
- else {
27
- const neeeded = neededBalance.shiftedBy(-tokenAmount.decimals).toFixed();
28
- const current = currentBalance
29
- .shiftedBy(-tokenAmount.decimals)
30
- .toFixed();
31
- let errorMessage = `Your ${tokenAmount.symbol} balance is too low, ` +
32
- `you try to transfer ${neeeded} ${tokenAmount.symbol}, ` +
33
- `but your wallet only holds ${current} ${tokenAmount.symbol}. ` +
34
- `No funds have been sent. `;
35
- if (!currentBalance.isZero()) {
36
- errorMessage +=
37
- `If the problem consists, please delete this transfer and ` +
38
- `start a new one with a maximum of ${current} ${tokenAmount.symbol}.`;
39
- }
40
- throw new errors_1.BalanceError('The balance is too low.', errorMessage);
41
- }
42
- }
43
- }
44
- };
45
- exports.checkBalance = checkBalance;
@@ -1,8 +0,0 @@
1
- import { Token, TokenAmount } from '@lifi/types';
2
- export declare const getTokenBalance: (walletAddress: string, token: Token) => Promise<TokenAmount | null>;
3
- export declare const getTokenBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
4
- export declare const getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
5
- [chainId: number]: Token[];
6
- }) => Promise<{
7
- [chainId: number]: TokenAmount[];
8
- }>;
@@ -1,13 +0,0 @@
1
- export * from './checkBalance';
2
- export * from './getTokenBalance';
3
- declare const _default: {
4
- checkBalance: (signer: import("ethers").Signer, step: import("@lifi/types").LifiStep, depth?: number) => Promise<void>;
5
- getTokenBalance: (walletAddress: string, token: import("@lifi/types").Token) => Promise<import("@lifi/types").TokenAmount | null>;
6
- getTokenBalances: (walletAddress: string, tokens: import("@lifi/types").Token[]) => Promise<import("@lifi/types").TokenAmount[]>;
7
- getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
8
- [chainId: number]: import("@lifi/types").Token[];
9
- }) => Promise<{
10
- [chainId: number]: import("@lifi/types").TokenAmount[];
11
- }>;
12
- };
13
- export default _default;
@@ -1,6 +0,0 @@
1
- import { Token, TokenAmount } from '@lifi/types';
2
- export declare const getBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
3
- declare const _default: {
4
- getBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
5
- };
6
- export default _default;
@@ -1,150 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getBalances = void 0;
7
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
- const ethers_1 = require("ethers");
9
- const connectors_1 = require("../connectors");
10
- const multicall_1 = require("../utils/multicall");
11
- const utils_1 = require("../utils/utils");
12
- const balanceAbi = [
13
- {
14
- constant: true,
15
- inputs: [{ name: 'who', type: 'address' }],
16
- name: 'balanceOf',
17
- outputs: [{ name: '', type: 'uint256' }],
18
- payable: false,
19
- stateMutability: 'view',
20
- type: 'function',
21
- },
22
- {
23
- constant: true,
24
- inputs: [{ name: 'addr', type: 'address' }],
25
- name: 'getEthBalance',
26
- outputs: [{ name: 'balance', type: 'uint256' }],
27
- payable: false,
28
- stateMutability: 'view',
29
- type: 'function',
30
- },
31
- ];
32
- const getBalances = async (walletAddress, tokens) => {
33
- if (tokens.length === 0) {
34
- return [];
35
- }
36
- const { chainId } = tokens[0];
37
- tokens.forEach((token) => {
38
- if (token.chainId !== chainId) {
39
- // eslint-disable-next-line no-console
40
- console.warn(`Requested tokens have to be on the same chain.`);
41
- return [];
42
- }
43
- });
44
- if ((await (0, connectors_1.getMulticallAddress)(chainId)) && tokens.length > 1) {
45
- return getBalancesFromProviderUsingMulticall(walletAddress, tokens);
46
- }
47
- else {
48
- return getBalancesFromProvider(walletAddress, tokens);
49
- }
50
- };
51
- exports.getBalances = getBalances;
52
- const getBalancesFromProviderUsingMulticall = async (walletAddress, tokens) => {
53
- // Configuration
54
- const { chainId } = tokens[0];
55
- const multicallAddress = await (0, connectors_1.getMulticallAddress)(chainId);
56
- if (!multicallAddress) {
57
- throw new Error('No multicallAddress found for the given chain.');
58
- }
59
- return executeMulticall(walletAddress, tokens, multicallAddress, chainId);
60
- };
61
- const executeMulticall = async (walletAddress, tokens, multicallAddress, chainId) => {
62
- // Collect calls we want to make
63
- const calls = [];
64
- tokens.map((token) => {
65
- if ((0, utils_1.isZeroAddress)(token.address)) {
66
- calls.push({
67
- address: multicallAddress,
68
- name: 'getEthBalance',
69
- params: [walletAddress],
70
- });
71
- }
72
- else {
73
- calls.push({
74
- address: token.address,
75
- name: 'balanceOf',
76
- params: [walletAddress],
77
- });
78
- }
79
- });
80
- const res = await fetchViaMulticall(calls, balanceAbi, chainId, multicallAddress);
81
- if (!res.length) {
82
- return [];
83
- }
84
- return tokens.map((token, i) => {
85
- const amount = new bignumber_js_1.default(res[i].amount.toString() || '0')
86
- .shiftedBy(-token.decimals)
87
- .toFixed();
88
- return {
89
- ...token,
90
- amount: amount || '0',
91
- blockNumber: res[i].blockNumber,
92
- };
93
- });
94
- };
95
- const fetchViaMulticall = async (calls, abi, chainId, multicallAddress) => {
96
- const result = await (0, multicall_1.fetchDataUsingMulticall)(calls, abi, chainId, multicallAddress);
97
- return result.map(({ data, blockNumber }) => ({
98
- amount: data ? data : new bignumber_js_1.default(0),
99
- blockNumber,
100
- }));
101
- };
102
- const getBalancesFromProvider = async (walletAddress, tokens) => {
103
- const chainId = tokens[0].chainId;
104
- const rpc = await (0, connectors_1.getRpcProvider)(chainId);
105
- const tokenAmountPromises = tokens.map(async (token) => {
106
- let amount = '0';
107
- let blockNumber;
108
- try {
109
- const balance = await getBalanceFromProvider(walletAddress, token.address, chainId, rpc);
110
- amount = new bignumber_js_1.default(balance.amount.toString())
111
- .shiftedBy(-token.decimals)
112
- .toString();
113
- blockNumber = balance.blockNumber;
114
- }
115
- catch (e) {
116
- // eslint-disable-next-line no-console
117
- console.warn(e);
118
- }
119
- return {
120
- ...token,
121
- amount,
122
- blockNumber,
123
- };
124
- });
125
- return Promise.all(tokenAmountPromises);
126
- };
127
- const getBalanceFromProvider = async (walletAddress, assetId, chainId, provider) => {
128
- const blockNumber = await getCurrentBlockNumber(chainId);
129
- let balance;
130
- if ((0, utils_1.isZeroAddress)(assetId)) {
131
- balance = await provider.getBalance(walletAddress, blockNumber);
132
- }
133
- else {
134
- const contract = new ethers_1.ethers.Contract(assetId, ['function balanceOf(address owner) view returns (uint256)'], provider);
135
- balance = await contract.balanceOf(walletAddress, {
136
- blockTag: blockNumber,
137
- });
138
- }
139
- return {
140
- amount: balance,
141
- blockNumber,
142
- };
143
- };
144
- const getCurrentBlockNumber = async (chainId) => {
145
- const rpc = await (0, connectors_1.getRpcProvider)(chainId);
146
- return rpc.getBlockNumber();
147
- };
148
- exports.default = {
149
- getBalances: exports.getBalances,
150
- };
@@ -1,6 +0,0 @@
1
- import { FallbackProvider } from '@ethersproject/providers';
2
- import { ChainId } from './types';
3
- export declare const getRpcUrl: (chainId: ChainId, archive?: boolean) => Promise<string>;
4
- export declare const getRpcUrls: (chainId: ChainId, archive?: boolean) => Promise<string[]>;
5
- export declare const getRpcProvider: (chainId: number, archive?: boolean) => Promise<FallbackProvider>;
6
- export declare const getMulticallAddress: (chainId: ChainId) => Promise<string | undefined>;
@@ -1,65 +0,0 @@
1
- import { Route } from '@lifi/types';
2
- import { Signer } from 'ethers';
3
- import ConfigService from '../services/ConfigService';
4
- import { ConfigUpdate, ExecutionSettings } from '../types';
5
- export declare class RouteExecutionManager {
6
- private executionDictionary;
7
- private executionPromiseDictionary;
8
- protected configService: ConfigService;
9
- constructor(configUpdate: ConfigUpdate);
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
- executeRoute: (signer: Signer, route: Route, settings?: ExecutionSettings) => Promise<Route>;
19
- /**
20
- * Resume the execution of a route that has been stopped or had an error while executing.
21
- * @param {Signer} signer - The signer required to send the transactions.
22
- * @param {Route} route - The route that is to be executed. Cannot be an active route.
23
- * @param {ExecutionSettings} settings - An object containing settings and callbacks.
24
- * @return {Promise<Route>} The executed route.
25
- * @throws {LifiError} Throws a LifiError if the execution fails.
26
- */
27
- resumeRoute: (signer: Signer, route: Route, settings?: ExecutionSettings) => Promise<Route>;
28
- private executeSteps;
29
- /**
30
- * Updates route execution to background or foreground state.
31
- * @param {Route} route - A route that is currently in execution.
32
- * @param {boolean} settings - An object with execution settings.
33
- */
34
- updateRouteExecution: (route: Route, settings: Pick<ExecutionSettings, 'executeInBackground'>) => void;
35
- /**
36
- * Update the ExecutionSettings for an active route.
37
- * @param {ExecutionSettings} settings - An object with execution settings.
38
- * @param {Route} route - The active route that gets the new execution settings.
39
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
40
- */
41
- updateExecutionSettings: (settings: ExecutionSettings, route: Route) => void;
42
- /**
43
- * Executes a route until a user interaction is necessary (signing transactions, etc.) and then halts until the route is resumed.
44
- * @param {Route} route - A route that is currently in execution.
45
- * @deprecated use updateRouteExecution instead.
46
- */
47
- moveExecutionToBackground: (route: Route) => void;
48
- /**
49
- * Stops the execution of an active route.
50
- * @param {Route} route - A route that is currently in execution.
51
- * @return {Route} The stopped route.
52
- */
53
- stopExecution: (route: Route) => Route;
54
- /**
55
- * Get the list of active routes.
56
- * @return {Route[]} A list of routes.
57
- */
58
- getActiveRoutes: () => Route[];
59
- /**
60
- * Return the current route information for given route. The route has to be active.
61
- * @param {Route} route - A route object.
62
- * @return {Route} The updated route.
63
- */
64
- getActiveRoute: (route: Route) => Route | undefined;
65
- }
@@ -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,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
- }
@@ -1,15 +0,0 @@
1
- import { Signer } from 'ethers';
2
- import { InteractionSettings, InternalExecutionSettings, LifiStep } from '../types';
3
- import { StatusManager } from './StatusManager';
4
- import { StepExecutionManager } from './StepExecutionManager';
5
- export declare class StepExecutor {
6
- stepExecutionManager: StepExecutionManager;
7
- statusManager: StatusManager;
8
- settings: InternalExecutionSettings;
9
- allowUserInteraction: boolean;
10
- executionStopped: boolean;
11
- constructor(statusManager: StatusManager, settings: InternalExecutionSettings);
12
- setInteraction: (settings?: InteractionSettings) => void;
13
- checkChain: () => never;
14
- executeStep: (signer: Signer, step: LifiStep) => Promise<LifiStep>;
15
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StepExecutor = void 0;
4
- const StepExecutionManager_1 = require("./StepExecutionManager");
5
- const switchChain_1 = require("./switchChain");
6
- // Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
7
- const defaultInteractionSettings = {
8
- allowInteraction: true,
9
- allowUpdates: true,
10
- stopExecution: false,
11
- };
12
- class StepExecutor {
13
- constructor(statusManager, settings) {
14
- this.allowUserInteraction = true;
15
- this.executionStopped = false;
16
- this.setInteraction = (settings) => {
17
- const interactionSettings = {
18
- ...defaultInteractionSettings,
19
- ...settings,
20
- };
21
- this.allowUserInteraction = interactionSettings.allowInteraction;
22
- this.stepExecutionManager.allowInteraction(interactionSettings.allowInteraction);
23
- this.statusManager.allowUpdates(interactionSettings.allowUpdates);
24
- this.executionStopped = interactionSettings.stopExecution;
25
- };
26
- // TODO: add checkChain method and update signer inside executors
27
- // This can come in handy when we execute multiple routes simultaneously and
28
- // should be sure that we are on the right chain when waiting for transactions.
29
- this.checkChain = () => {
30
- throw new Error('checkChain is not implemented.');
31
- };
32
- this.executeStep = async (signer, step) => {
33
- // Make sure that the chain is still correct
34
- // Find if it's bridging and the step is waiting for a transaction on the receiving chain
35
- const recievingChainProcess = step.execution?.process.find((process) => process.type === 'RECEIVING_CHAIN');
36
- // If the step is waiting for a transaction on the receiving chain, we do not switch the chain
37
- // All changes are already done from the source chain
38
- // Return the step
39
- if (recievingChainProcess?.substatus !== 'WAIT_DESTINATION_TRANSACTION' ||
40
- !recievingChainProcess) {
41
- const updatedSigner = await (0, switchChain_1.switchChain)(signer, this.statusManager, step, this.settings.switchChainHook, this.allowUserInteraction);
42
- if (!updatedSigner) {
43
- // Chain switch was not successful, stop execution here
44
- return step;
45
- }
46
- signer = updatedSigner;
47
- }
48
- const parameters = {
49
- signer,
50
- step,
51
- settings: this.settings,
52
- statusManager: this.statusManager,
53
- };
54
- await this.stepExecutionManager.execute(parameters);
55
- return step;
56
- };
57
- this.stepExecutionManager = new StepExecutionManager_1.StepExecutionManager();
58
- this.statusManager = statusManager;
59
- this.settings = settings;
60
- }
61
- }
62
- exports.StepExecutor = StepExecutor;
@@ -1 +0,0 @@
1
- export * from './StatusManager';
@@ -1,3 +0,0 @@
1
- import { ExtendedChain, LifiStep, Process } from '@lifi/types';
2
- import { StatusManager } from '.';
3
- export declare const updateMultisigRouteProcess: (internalTxHash: string, step: LifiStep, statusManager: StatusManager, process: Process, fromChain: ExtendedChain) => Promise<void>;