@lifi/sdk 3.0.0-alpha.6 → 3.0.0-alpha.60

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 (482) hide show
  1. package/package.json +40 -88
  2. package/src/_cjs/config.js +90 -0
  3. package/src/_cjs/config.js.map +1 -0
  4. package/{dist/cjs → src/_cjs}/constants.js +3 -5
  5. package/src/_cjs/constants.js.map +1 -0
  6. package/src/_cjs/core/BaseStepExecutor.js +55 -0
  7. package/src/_cjs/core/BaseStepExecutor.js.map +1 -0
  8. package/src/_cjs/core/EVM/EVM.js +43 -0
  9. package/src/_cjs/core/EVM/EVM.js.map +1 -0
  10. package/src/_cjs/core/EVM/EVMStepExecutor.js +304 -0
  11. package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -0
  12. package/{dist/cjs/types → src/_cjs/core/EVM}/abi.js +1 -0
  13. package/src/_cjs/core/EVM/abi.js.map +1 -0
  14. package/{dist/cjs/execution → src/_cjs/core/EVM}/checkAllowance.js +19 -12
  15. package/src/_cjs/core/EVM/checkAllowance.js.map +1 -0
  16. package/{dist/cjs/allowance → src/_cjs/core/EVM}/getAllowance.js +13 -17
  17. package/src/_cjs/core/EVM/getAllowance.js.map +1 -0
  18. package/src/_cjs/core/EVM/getENSAddress.js +20 -0
  19. package/src/_cjs/core/EVM/getENSAddress.js.map +1 -0
  20. package/{dist/cjs/balance/getBalance.js → src/_cjs/core/EVM/getEVMBalance.js} +20 -22
  21. package/src/_cjs/core/EVM/getEVMBalance.js.map +1 -0
  22. package/{dist/cjs/execution → src/_cjs/core/EVM}/multisig.js +7 -11
  23. package/src/_cjs/core/EVM/multisig.js.map +1 -0
  24. package/src/_cjs/core/EVM/publicClient.js +43 -0
  25. package/src/_cjs/core/EVM/publicClient.js.map +1 -0
  26. package/{dist/cjs/allowance → src/_cjs/core/EVM}/setAllowance.js +11 -12
  27. package/src/_cjs/core/EVM/setAllowance.js.map +1 -0
  28. package/src/_cjs/core/EVM/switchChain.js +38 -0
  29. package/src/_cjs/core/EVM/switchChain.js.map +1 -0
  30. package/src/_cjs/core/EVM/types.js +9 -0
  31. package/src/_cjs/core/EVM/types.js.map +1 -0
  32. package/{dist/cjs/utils/getMaxPriorityFeePerGas.js → src/_cjs/core/EVM/utils.js} +13 -3
  33. package/src/_cjs/core/EVM/utils.js.map +1 -0
  34. package/src/_cjs/core/Solana/Solana.js +38 -0
  35. package/src/_cjs/core/Solana/Solana.js.map +1 -0
  36. package/src/_cjs/core/Solana/SolanaStepExecutor.js +174 -0
  37. package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -0
  38. package/src/_cjs/core/Solana/connection.js +19 -0
  39. package/src/_cjs/core/Solana/connection.js.map +1 -0
  40. package/src/_cjs/core/Solana/getSNSAddress.js +26 -0
  41. package/src/_cjs/core/Solana/getSNSAddress.js.map +1 -0
  42. package/src/_cjs/core/Solana/getSolanaBalance.js +60 -0
  43. package/src/_cjs/core/Solana/getSolanaBalance.js.map +1 -0
  44. package/src/_cjs/core/Solana/isAddress.js +15 -0
  45. package/src/_cjs/core/Solana/isAddress.js.map +1 -0
  46. package/src/_cjs/core/Solana/types.js +10 -0
  47. package/src/_cjs/core/Solana/types.js.map +1 -0
  48. package/src/_cjs/core/StatusManager.js +167 -0
  49. package/src/_cjs/core/StatusManager.js.map +1 -0
  50. package/{dist/cjs/execution → src/_cjs/core}/checkBalance.js +6 -6
  51. package/src/_cjs/core/checkBalance.js.map +1 -0
  52. package/src/_cjs/core/execution.js +134 -0
  53. package/src/_cjs/core/execution.js.map +1 -0
  54. package/src/_cjs/core/executionState.js +29 -0
  55. package/src/_cjs/core/executionState.js.map +1 -0
  56. package/src/_cjs/core/index.js +7 -0
  57. package/src/_cjs/core/index.js.map +1 -0
  58. package/src/_cjs/core/prepareRestart.js +23 -0
  59. package/src/_cjs/core/prepareRestart.js.map +1 -0
  60. package/src/_cjs/core/provider.js +15 -0
  61. package/src/_cjs/core/provider.js.map +1 -0
  62. package/src/_cjs/core/rpc.js +18 -0
  63. package/src/_cjs/core/rpc.js.map +1 -0
  64. package/src/_cjs/core/stepComparison.js +25 -0
  65. package/src/_cjs/core/stepComparison.js.map +1 -0
  66. package/{dist/cjs/allowance → src/_cjs/core}/types.js +1 -0
  67. package/src/_cjs/core/types.js.map +1 -0
  68. package/{dist/cjs/execution → src/_cjs/core}/utils.js +2 -11
  69. package/src/_cjs/core/utils.js.map +1 -0
  70. package/{dist/cjs/execution → src/_cjs/core}/waitForReceivingTransaction.js +13 -14
  71. package/src/_cjs/core/waitForReceivingTransaction.js.map +1 -0
  72. package/src/_cjs/createConfig.js +32 -0
  73. package/src/_cjs/createConfig.js.map +1 -0
  74. package/src/_cjs/helpers.js +57 -0
  75. package/src/_cjs/helpers.js.map +1 -0
  76. package/src/_cjs/index.js +23 -0
  77. package/src/_cjs/index.js.map +1 -0
  78. package/src/_cjs/package.json +1 -0
  79. package/src/_cjs/request.js +66 -0
  80. package/src/_cjs/request.js.map +1 -0
  81. package/src/_cjs/services/api.js +309 -0
  82. package/src/_cjs/services/api.js.map +1 -0
  83. package/src/_cjs/services/balance.js +49 -0
  84. package/src/_cjs/services/balance.js.map +1 -0
  85. package/src/_cjs/services/getNameServiceAddress.js +29 -0
  86. package/src/_cjs/services/getNameServiceAddress.js.map +1 -0
  87. package/{dist/cjs → src/_cjs}/typeguards.js +1 -0
  88. package/src/_cjs/typeguards.js.map +1 -0
  89. package/src/_cjs/types/index.js +5 -0
  90. package/src/_cjs/types/index.js.map +1 -0
  91. package/{dist/cjs/types/internal.types.js → src/_cjs/types/internal.js} +1 -0
  92. package/src/_cjs/types/internal.js.map +1 -0
  93. package/{dist/cjs → src/_cjs}/utils/errors.js +26 -3
  94. package/src/_cjs/utils/errors.js.map +1 -0
  95. package/src/_cjs/utils/getTransactionMessage.js +31 -0
  96. package/src/_cjs/utils/getTransactionMessage.js.map +1 -0
  97. package/src/_cjs/utils/index.js +9 -0
  98. package/src/_cjs/utils/index.js.map +1 -0
  99. package/{dist/cjs → src/_cjs}/utils/median.js +1 -0
  100. package/src/_cjs/utils/median.js.map +1 -0
  101. package/src/_cjs/utils/parseBackendError.js +27 -0
  102. package/src/_cjs/utils/parseBackendError.js.map +1 -0
  103. package/src/_cjs/utils/parseError.js +69 -0
  104. package/src/_cjs/utils/parseError.js.map +1 -0
  105. package/{dist/cjs → src/_cjs}/utils/utils.js +5 -11
  106. package/src/_cjs/utils/utils.js.map +1 -0
  107. package/{dist/cjs → src/_cjs}/version.js +2 -1
  108. package/src/_cjs/version.js.map +1 -0
  109. package/src/_esm/config.js +87 -0
  110. package/src/_esm/config.js.map +1 -0
  111. package/{dist → src/_esm}/constants.js +2 -4
  112. package/src/_esm/constants.js.map +1 -0
  113. package/src/_esm/core/BaseStepExecutor.js +52 -0
  114. package/src/_esm/core/BaseStepExecutor.js.map +1 -0
  115. package/src/_esm/core/EVM/EVM.js +39 -0
  116. package/src/_esm/core/EVM/EVM.js.map +1 -0
  117. package/src/_esm/core/EVM/EVMStepExecutor.js +329 -0
  118. package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -0
  119. package/{dist/types → src/_esm/core/EVM}/abi.js +1 -0
  120. package/src/_esm/core/EVM/abi.js.map +1 -0
  121. package/{dist/execution → src/_esm/core/EVM}/checkAllowance.js +14 -5
  122. package/src/_esm/core/EVM/checkAllowance.js.map +1 -0
  123. package/{dist/allowance → src/_esm/core/EVM}/getAllowance.js +19 -6
  124. package/src/_esm/core/EVM/getAllowance.js.map +1 -0
  125. package/src/_esm/core/EVM/getENSAddress.js +17 -0
  126. package/src/_esm/core/EVM/getENSAddress.js.map +1 -0
  127. package/{dist/balance/getBalance.js → src/_esm/core/EVM/getEVMBalance.js} +10 -12
  128. package/src/_esm/core/EVM/getEVMBalance.js.map +1 -0
  129. package/{dist/execution → src/_esm/core/EVM}/multisig.js +5 -6
  130. package/src/_esm/core/EVM/multisig.js.map +1 -0
  131. package/src/_esm/core/EVM/publicClient.js +46 -0
  132. package/src/_esm/core/EVM/publicClient.js.map +1 -0
  133. package/{dist/allowance → src/_esm/core/EVM}/setAllowance.js +23 -4
  134. package/src/_esm/core/EVM/setAllowance.js.map +1 -0
  135. package/{dist/execution → src/_esm/core/EVM}/switchChain.js +7 -4
  136. package/src/_esm/core/EVM/switchChain.js.map +1 -0
  137. package/src/_esm/core/EVM/types.js +6 -0
  138. package/src/_esm/core/EVM/types.js.map +1 -0
  139. package/{dist/utils/getMaxPriorityFeePerGas.js → src/_esm/core/EVM/utils.js} +12 -1
  140. package/src/_esm/core/EVM/utils.js.map +1 -0
  141. package/src/_esm/core/Solana/Solana.js +34 -0
  142. package/src/_esm/core/Solana/Solana.js.map +1 -0
  143. package/src/_esm/core/Solana/SolanaStepExecutor.js +176 -0
  144. package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -0
  145. package/src/_esm/core/Solana/connection.js +20 -0
  146. package/src/_esm/core/Solana/connection.js.map +1 -0
  147. package/src/_esm/core/Solana/getSNSAddress.js +26 -0
  148. package/src/_esm/core/Solana/getSNSAddress.js.map +1 -0
  149. package/src/_esm/core/Solana/getSolanaBalance.js +56 -0
  150. package/src/_esm/core/Solana/getSolanaBalance.js.map +1 -0
  151. package/src/_esm/core/Solana/isAddress.js +11 -0
  152. package/src/_esm/core/Solana/isAddress.js.map +1 -0
  153. package/src/_esm/core/Solana/types.js +7 -0
  154. package/src/_esm/core/Solana/types.js.map +1 -0
  155. package/src/_esm/core/StatusManager.js +203 -0
  156. package/src/_esm/core/StatusManager.js.map +1 -0
  157. package/{dist/execution → src/_esm/core}/checkBalance.js +4 -3
  158. package/src/_esm/core/checkBalance.js.map +1 -0
  159. package/src/_esm/core/execution.js +172 -0
  160. package/src/_esm/core/execution.js.map +1 -0
  161. package/src/_esm/core/executionState.js +26 -0
  162. package/src/_esm/core/executionState.js.map +1 -0
  163. package/src/_esm/core/index.js +4 -0
  164. package/src/_esm/core/index.js.map +1 -0
  165. package/src/_esm/core/prepareRestart.js +64 -0
  166. package/src/_esm/core/prepareRestart.js.map +1 -0
  167. package/src/_esm/core/provider.js +11 -0
  168. package/src/_esm/core/provider.js.map +1 -0
  169. package/src/_esm/core/rpc.js +14 -0
  170. package/src/_esm/core/rpc.js.map +1 -0
  171. package/{dist/execution → src/_esm/core}/stepComparison.js +7 -5
  172. package/src/_esm/core/stepComparison.js.map +1 -0
  173. package/src/_esm/core/types.js +2 -0
  174. package/src/_esm/core/types.js.map +1 -0
  175. package/{dist/execution → src/_esm/core}/utils.js +4 -3
  176. package/src/_esm/core/utils.js.map +1 -0
  177. package/{dist/execution → src/_esm/core}/waitForReceivingTransaction.js +11 -9
  178. package/src/_esm/core/waitForReceivingTransaction.js.map +1 -0
  179. package/src/_esm/createConfig.js +28 -0
  180. package/src/_esm/createConfig.js.map +1 -0
  181. package/{dist → src/_esm}/helpers.js +5 -17
  182. package/src/_esm/helpers.js.map +1 -0
  183. package/src/_esm/index.js +14 -0
  184. package/src/_esm/index.js.map +1 -0
  185. package/src/_esm/package.json +1 -0
  186. package/{dist → src/_esm}/request.js +23 -13
  187. package/src/_esm/request.js.map +1 -0
  188. package/src/_esm/services/api.js +378 -0
  189. package/src/_esm/services/api.js.map +1 -0
  190. package/src/_esm/services/balance.js +65 -0
  191. package/src/_esm/services/balance.js.map +1 -0
  192. package/src/_esm/services/getNameServiceAddress.js +25 -0
  193. package/src/_esm/services/getNameServiceAddress.js.map +1 -0
  194. package/{dist → src/_esm}/typeguards.js +1 -0
  195. package/src/_esm/typeguards.js.map +1 -0
  196. package/src/_esm/types/index.js +2 -0
  197. package/src/_esm/types/index.js.map +1 -0
  198. package/src/_esm/types/internal.js +2 -0
  199. package/src/_esm/types/internal.js.map +1 -0
  200. package/{dist → src/_esm}/utils/errors.js +26 -0
  201. package/src/_esm/utils/errors.js.map +1 -0
  202. package/src/_esm/utils/getTransactionMessage.js +28 -0
  203. package/src/_esm/utils/getTransactionMessage.js.map +1 -0
  204. package/src/_esm/utils/index.js +6 -0
  205. package/src/_esm/utils/index.js.map +1 -0
  206. package/{dist → src/_esm}/utils/median.js +1 -0
  207. package/src/_esm/utils/median.js.map +1 -0
  208. package/src/_esm/utils/parseBackendError.js +24 -0
  209. package/src/_esm/utils/parseBackendError.js.map +1 -0
  210. package/{dist → src/_esm}/utils/parseError.js +6 -53
  211. package/src/_esm/utils/parseError.js.map +1 -0
  212. package/{dist → src/_esm}/utils/utils.js +2 -1
  213. package/src/_esm/utils/utils.js.map +1 -0
  214. package/src/_esm/version.js +3 -0
  215. package/src/_esm/version.js.map +1 -0
  216. package/src/_types/config.d.ts +15 -0
  217. package/src/_types/config.d.ts.map +1 -0
  218. package/{dist/cjs → src/_types}/constants.d.ts +2 -4
  219. package/src/_types/constants.d.ts.map +1 -0
  220. package/src/_types/core/BaseStepExecutor.d.ts +13 -0
  221. package/src/_types/core/BaseStepExecutor.d.ts.map +1 -0
  222. package/src/_types/core/EVM/EVM.d.ts +3 -0
  223. package/src/_types/core/EVM/EVM.d.ts.map +1 -0
  224. package/src/_types/core/EVM/EVMStepExecutor.d.ts +17 -0
  225. package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -0
  226. package/{dist/cjs/types → src/_types/core/EVM}/abi.d.ts +1 -0
  227. package/src/_types/core/EVM/abi.d.ts.map +1 -0
  228. package/src/_types/core/EVM/checkAllowance.d.ts +6 -0
  229. package/src/_types/core/EVM/checkAllowance.d.ts.map +1 -0
  230. package/{dist/cjs/allowance → src/_types/core/EVM}/getAllowance.d.ts +15 -1
  231. package/src/_types/core/EVM/getAllowance.d.ts.map +1 -0
  232. package/src/_types/core/EVM/getENSAddress.d.ts +2 -0
  233. package/src/_types/core/EVM/getENSAddress.d.ts.map +1 -0
  234. package/src/_types/core/EVM/getEVMBalance.d.ts +3 -0
  235. package/src/_types/core/EVM/getEVMBalance.d.ts.map +1 -0
  236. package/src/_types/core/EVM/multisig.d.ts +6 -0
  237. package/src/_types/core/EVM/multisig.d.ts.map +1 -0
  238. package/src/_types/core/EVM/publicClient.d.ts +8 -0
  239. package/src/_types/core/EVM/publicClient.d.ts.map +1 -0
  240. package/src/_types/core/EVM/setAllowance.d.ts +25 -0
  241. package/src/_types/core/EVM/setAllowance.d.ts.map +1 -0
  242. package/{dist/cjs/execution → src/_types/core/EVM}/switchChain.d.ts +5 -4
  243. package/src/_types/core/EVM/switchChain.d.ts.map +1 -0
  244. package/src/_types/core/EVM/types.d.ts +55 -0
  245. package/src/_types/core/EVM/types.d.ts.map +1 -0
  246. package/src/_types/core/EVM/utils.d.ts +10 -0
  247. package/src/_types/core/EVM/utils.d.ts.map +1 -0
  248. package/src/_types/core/Solana/Solana.d.ts +3 -0
  249. package/src/_types/core/Solana/Solana.d.ts.map +1 -0
  250. package/src/_types/core/Solana/SolanaStepExecutor.d.ts +13 -0
  251. package/src/_types/core/Solana/SolanaStepExecutor.d.ts.map +1 -0
  252. package/src/_types/core/Solana/connection.d.ts +8 -0
  253. package/src/_types/core/Solana/connection.d.ts.map +1 -0
  254. package/src/_types/core/Solana/getSNSAddress.d.ts +2 -0
  255. package/src/_types/core/Solana/getSNSAddress.d.ts.map +1 -0
  256. package/src/_types/core/Solana/getSolanaBalance.d.ts +3 -0
  257. package/src/_types/core/Solana/getSolanaBalance.d.ts.map +1 -0
  258. package/src/_types/core/Solana/isAddress.d.ts +2 -0
  259. package/src/_types/core/Solana/isAddress.d.ts.map +1 -0
  260. package/src/_types/core/Solana/types.d.ts +13 -0
  261. package/src/_types/core/Solana/types.d.ts.map +1 -0
  262. package/{dist/cjs/execution → src/_types/core}/StatusManager.d.ts +15 -28
  263. package/src/_types/core/StatusManager.d.ts.map +1 -0
  264. package/src/_types/core/checkBalance.d.ts +3 -0
  265. package/src/_types/core/checkBalance.d.ts.map +1 -0
  266. package/src/_types/core/execution.d.ts +42 -0
  267. package/src/_types/core/execution.d.ts.map +1 -0
  268. package/src/_types/core/executionState.d.ts +17 -0
  269. package/src/_types/core/executionState.d.ts.map +1 -0
  270. package/src/_types/core/index.d.ts +4 -0
  271. package/src/_types/core/index.d.ts.map +1 -0
  272. package/src/_types/core/prepareRestart.d.ts +3 -0
  273. package/src/_types/core/prepareRestart.d.ts.map +1 -0
  274. package/src/_types/core/provider.d.ts +3 -0
  275. package/src/_types/core/provider.d.ts.map +1 -0
  276. package/src/_types/core/rpc.d.ts +4 -0
  277. package/src/_types/core/rpc.d.ts.map +1 -0
  278. package/{dist/execution → src/_types/core}/stepComparison.d.ts +7 -4
  279. package/src/_types/core/stepComparison.d.ts.map +1 -0
  280. package/src/_types/core/types.d.ts +81 -0
  281. package/src/_types/core/types.d.ts.map +1 -0
  282. package/{dist/execution → src/_types/core}/utils.d.ts +3 -2
  283. package/src/_types/core/utils.d.ts.map +1 -0
  284. package/src/_types/core/waitForReceivingTransaction.d.ts +4 -0
  285. package/src/_types/core/waitForReceivingTransaction.d.ts.map +1 -0
  286. package/src/_types/createConfig.d.ts +4 -0
  287. package/src/_types/createConfig.d.ts.map +1 -0
  288. package/{dist → src/_types}/helpers.d.ts +4 -3
  289. package/src/_types/helpers.d.ts.map +1 -0
  290. package/src/_types/index.d.ts +15 -0
  291. package/src/_types/index.d.ts.map +1 -0
  292. package/{dist → src/_types}/request.d.ts +1 -0
  293. package/src/_types/request.d.ts.map +1 -0
  294. package/src/_types/services/api.d.ts +89 -0
  295. package/src/_types/services/api.d.ts.map +1 -0
  296. package/src/_types/services/balance.d.ts +30 -0
  297. package/src/_types/services/balance.d.ts.map +1 -0
  298. package/src/_types/services/getNameServiceAddress.d.ts +3 -0
  299. package/src/_types/services/getNameServiceAddress.d.ts.map +1 -0
  300. package/{dist/cjs → src/_types}/typeguards.d.ts +3 -2
  301. package/src/_types/typeguards.d.ts.map +1 -0
  302. package/src/_types/types/index.d.ts +2 -0
  303. package/src/_types/types/index.d.ts.map +1 -0
  304. package/src/_types/types/internal.d.ts +59 -0
  305. package/src/_types/types/internal.d.ts.map +1 -0
  306. package/{dist → src/_types}/utils/errors.d.ts +3 -1
  307. package/src/_types/utils/errors.d.ts.map +1 -0
  308. package/src/_types/utils/getTransactionMessage.d.ts +4 -0
  309. package/src/_types/utils/getTransactionMessage.d.ts.map +1 -0
  310. package/src/_types/utils/index.d.ts +6 -0
  311. package/src/_types/utils/index.d.ts.map +1 -0
  312. package/{dist/cjs → src/_types}/utils/median.d.ts +1 -0
  313. package/src/_types/utils/median.d.ts.map +1 -0
  314. package/src/_types/utils/parseBackendError.d.ts +3 -0
  315. package/src/_types/utils/parseBackendError.d.ts.map +1 -0
  316. package/{dist → src/_types}/utils/parseError.d.ts +4 -6
  317. package/src/_types/utils/parseError.d.ts.map +1 -0
  318. package/{dist → src/_types}/utils/utils.d.ts +1 -0
  319. package/src/_types/utils/utils.d.ts.map +1 -0
  320. package/src/_types/version.d.ts +3 -0
  321. package/src/_types/version.d.ts.map +1 -0
  322. package/src/config.ts +91 -0
  323. package/src/constants.ts +4 -0
  324. package/src/core/BaseStepExecutor.ts +40 -0
  325. package/src/core/EVM/EVM.ts +47 -0
  326. package/src/core/EVM/EVMStepExecutor.ts +503 -0
  327. package/src/core/EVM/abi.ts +47 -0
  328. package/src/core/EVM/checkAllowance.ts +168 -0
  329. package/src/core/EVM/getAllowance.ts +144 -0
  330. package/src/core/EVM/getENSAddress.ts +18 -0
  331. package/src/core/EVM/getEVMBalance.ts +118 -0
  332. package/src/core/EVM/multisig.ts +53 -0
  333. package/src/core/EVM/publicClient.ts +54 -0
  334. package/src/core/EVM/setAllowance.ts +144 -0
  335. package/src/core/EVM/switchChain.ts +77 -0
  336. package/src/core/EVM/types.ts +73 -0
  337. package/src/core/EVM/utils.ts +48 -0
  338. package/src/core/Solana/Solana.ts +41 -0
  339. package/src/core/Solana/SolanaStepExecutor.ts +272 -0
  340. package/src/core/Solana/connection.ts +20 -0
  341. package/src/core/Solana/getSNSAddress.ts +33 -0
  342. package/src/core/Solana/getSolanaBalance.ts +72 -0
  343. package/src/core/Solana/isAddress.ts +10 -0
  344. package/src/core/Solana/types.ts +18 -0
  345. package/src/core/StatusManager.ts +231 -0
  346. package/src/core/checkBalance.ts +48 -0
  347. package/src/core/execution.ts +210 -0
  348. package/src/core/executionState.ts +44 -0
  349. package/src/core/index.ts +3 -0
  350. package/src/core/prepareRestart.ts +82 -0
  351. package/src/core/provider.ts +12 -0
  352. package/src/core/rpc.ts +15 -0
  353. package/src/core/stepComparison.ts +51 -0
  354. package/src/core/types.ts +118 -0
  355. package/src/core/utils.ts +105 -0
  356. package/src/core/waitForReceivingTransaction.ts +74 -0
  357. package/src/createConfig.ts +33 -0
  358. package/src/helpers.ts +83 -0
  359. package/src/index.ts +18 -0
  360. package/src/request.ts +79 -0
  361. package/src/services/api.ts +509 -0
  362. package/src/services/balance.ts +93 -0
  363. package/src/services/getNameServiceAddress.ts +30 -0
  364. package/src/typeguards.ts +89 -0
  365. package/src/types/index.ts +1 -0
  366. package/src/types/internal.ts +62 -0
  367. package/src/utils/errors.ts +232 -0
  368. package/src/utils/getTransactionMessage.ts +46 -0
  369. package/src/utils/index.ts +5 -0
  370. package/src/utils/median.ts +11 -0
  371. package/src/utils/parseBackendError.ts +50 -0
  372. package/src/utils/parseError.ts +210 -0
  373. package/src/utils/utils.ts +48 -0
  374. package/src/version.ts +2 -0
  375. package/dist/LiFi.d.ts +0 -175
  376. package/dist/LiFi.js +0 -250
  377. package/dist/allowance/getAllowance.d.ts +0 -6
  378. package/dist/allowance/index.d.ts +0 -3
  379. package/dist/allowance/index.js +0 -3
  380. package/dist/allowance/setAllowance.d.ts +0 -6
  381. package/dist/allowance/types.d.ts +0 -27
  382. package/dist/allowance/types.js +0 -1
  383. package/dist/balance/getBalance.d.ts +0 -2
  384. package/dist/balance/getTokenBalance.d.ts +0 -8
  385. package/dist/balance/getTokenBalance.js +0 -27
  386. package/dist/balance/index.d.ts +0 -2
  387. package/dist/balance/index.js +0 -2
  388. package/dist/cjs/LiFi.d.ts +0 -175
  389. package/dist/cjs/LiFi.js +0 -280
  390. package/dist/cjs/allowance/index.d.ts +0 -3
  391. package/dist/cjs/allowance/index.js +0 -19
  392. package/dist/cjs/allowance/setAllowance.d.ts +0 -6
  393. package/dist/cjs/allowance/types.d.ts +0 -27
  394. package/dist/cjs/balance/getBalance.d.ts +0 -2
  395. package/dist/cjs/balance/getTokenBalance.d.ts +0 -8
  396. package/dist/cjs/balance/getTokenBalance.js +0 -33
  397. package/dist/cjs/balance/index.d.ts +0 -2
  398. package/dist/cjs/balance/index.js +0 -18
  399. package/dist/cjs/connectors.d.ts +0 -8
  400. package/dist/cjs/connectors.js +0 -75
  401. package/dist/cjs/execution/RouteExecutionManager.d.ts +0 -59
  402. package/dist/cjs/execution/RouteExecutionManager.js +0 -202
  403. package/dist/cjs/execution/StatusManager.js +0 -171
  404. package/dist/cjs/execution/StepExecutionManager.d.ts +0 -7
  405. package/dist/cjs/execution/StepExecutionManager.js +0 -272
  406. package/dist/cjs/execution/StepExecutor.d.ts +0 -15
  407. package/dist/cjs/execution/StepExecutor.js +0 -62
  408. package/dist/cjs/execution/checkAllowance.d.ts +0 -4
  409. package/dist/cjs/execution/checkBalance.d.ts +0 -2
  410. package/dist/cjs/execution/index.d.ts +0 -1
  411. package/dist/cjs/execution/index.js +0 -17
  412. package/dist/cjs/execution/multisig.d.ts +0 -4
  413. package/dist/cjs/execution/prepareRestart.d.ts +0 -3
  414. package/dist/cjs/execution/prepareRestart.js +0 -65
  415. package/dist/cjs/execution/stepComparison.d.ts +0 -14
  416. package/dist/cjs/execution/stepComparison.js +0 -37
  417. package/dist/cjs/execution/switchChain.js +0 -54
  418. package/dist/cjs/execution/utils.d.ts +0 -12
  419. package/dist/cjs/execution/waitForReceivingTransaction.d.ts +0 -3
  420. package/dist/cjs/helpers.d.ts +0 -18
  421. package/dist/cjs/helpers.js +0 -84
  422. package/dist/cjs/index.d.ts +0 -5
  423. package/dist/cjs/index.js +0 -24
  424. package/dist/cjs/request.d.ts +0 -9
  425. package/dist/cjs/request.js +0 -60
  426. package/dist/cjs/services/ApiService.d.ts +0 -17
  427. package/dist/cjs/services/ApiService.js +0 -326
  428. package/dist/cjs/services/ChainsService.d.ts +0 -11
  429. package/dist/cjs/services/ChainsService.js +0 -39
  430. package/dist/cjs/services/ConfigService.d.ts +0 -23
  431. package/dist/cjs/services/ConfigService.js +0 -101
  432. package/dist/cjs/types/index.d.ts +0 -4
  433. package/dist/cjs/types/index.js +0 -22
  434. package/dist/cjs/types/internal.types.d.ts +0 -145
  435. package/dist/cjs/utils/errors.d.ts +0 -107
  436. package/dist/cjs/utils/getMaxPriorityFeePerGas.d.ts +0 -2
  437. package/dist/cjs/utils/index.d.ts +0 -5
  438. package/dist/cjs/utils/index.js +0 -21
  439. package/dist/cjs/utils/parseError.d.ts +0 -37
  440. package/dist/cjs/utils/parseError.js +0 -157
  441. package/dist/cjs/utils/utils.d.ts +0 -10
  442. package/dist/cjs/version.d.ts +0 -2
  443. package/dist/connectors.d.ts +0 -8
  444. package/dist/connectors.js +0 -41
  445. package/dist/constants.d.ts +0 -6
  446. package/dist/execution/RouteExecutionManager.d.ts +0 -59
  447. package/dist/execution/RouteExecutionManager.js +0 -195
  448. package/dist/execution/StatusManager.d.ts +0 -67
  449. package/dist/execution/StatusManager.js +0 -167
  450. package/dist/execution/StepExecutionManager.d.ts +0 -7
  451. package/dist/execution/StepExecutionManager.js +0 -265
  452. package/dist/execution/StepExecutor.d.ts +0 -15
  453. package/dist/execution/StepExecutor.js +0 -58
  454. package/dist/execution/checkAllowance.d.ts +0 -4
  455. package/dist/execution/checkBalance.d.ts +0 -2
  456. package/dist/execution/index.d.ts +0 -1
  457. package/dist/execution/index.js +0 -1
  458. package/dist/execution/multisig.d.ts +0 -4
  459. package/dist/execution/prepareRestart.d.ts +0 -3
  460. package/dist/execution/prepareRestart.js +0 -61
  461. package/dist/execution/switchChain.d.ts +0 -21
  462. package/dist/execution/waitForReceivingTransaction.d.ts +0 -3
  463. package/dist/index.d.ts +0 -5
  464. package/dist/index.js +0 -6
  465. package/dist/services/ApiService.d.ts +0 -17
  466. package/dist/services/ApiService.js +0 -321
  467. package/dist/services/ChainsService.d.ts +0 -11
  468. package/dist/services/ChainsService.js +0 -33
  469. package/dist/services/ConfigService.d.ts +0 -23
  470. package/dist/services/ConfigService.js +0 -99
  471. package/dist/typeguards.d.ts +0 -4
  472. package/dist/types/abi.d.ts +0 -5
  473. package/dist/types/index.d.ts +0 -4
  474. package/dist/types/index.js +0 -4
  475. package/dist/types/internal.types.d.ts +0 -145
  476. package/dist/types/internal.types.js +0 -1
  477. package/dist/utils/getMaxPriorityFeePerGas.d.ts +0 -2
  478. package/dist/utils/index.d.ts +0 -5
  479. package/dist/utils/index.js +0 -5
  480. package/dist/utils/median.d.ts +0 -1
  481. package/dist/version.d.ts +0 -2
  482. package/dist/version.js +0 -2
@@ -0,0 +1,503 @@
1
+ import type {
2
+ ExtendedTransactionInfo,
3
+ FullStatusData,
4
+ Process,
5
+ } from '@lifi/types'
6
+ import type {
7
+ Address,
8
+ Hash,
9
+ PublicClient,
10
+ ReplacementReason,
11
+ SendTransactionParameters,
12
+ WalletClient,
13
+ } from 'viem'
14
+ import { publicActions } from 'viem'
15
+ import { config } from '../../config.js'
16
+ import { getStepTransaction } from '../../services/api.js'
17
+ import {
18
+ LiFiErrorCode,
19
+ TransactionError,
20
+ ValidationError,
21
+ getTransactionFailedMessage,
22
+ isZeroAddress,
23
+ parseError,
24
+ } from '../../utils/index.js'
25
+ import { BaseStepExecutor } from '../BaseStepExecutor.js'
26
+ import { checkBalance } from '../checkBalance.js'
27
+ import { stepComparison } from '../stepComparison.js'
28
+ import type {
29
+ LiFiStepExtended,
30
+ StepExecutorOptions,
31
+ TransactionParameters,
32
+ } from '../types.js'
33
+ import { getSubstatusMessage } from '../utils.js'
34
+ import { waitForReceivingTransaction } from '../waitForReceivingTransaction.js'
35
+ import { checkAllowance } from './checkAllowance.js'
36
+ import { updateMultisigRouteProcess } from './multisig.js'
37
+ import { switchChain } from './switchChain.js'
38
+ import type { MultisigConfig, MultisigTransaction } from './types.js'
39
+ import { getMaxPriorityFeePerGas, retryCount, retryDelay } from './utils.js'
40
+
41
+ export interface EVMStepExecutorOptions extends StepExecutorOptions {
42
+ walletClient: WalletClient
43
+ multisig?: MultisigConfig
44
+ }
45
+
46
+ export class EVMStepExecutor extends BaseStepExecutor {
47
+ private walletClient: WalletClient
48
+ private multisig?: MultisigConfig
49
+
50
+ constructor(options: EVMStepExecutorOptions) {
51
+ super(options)
52
+ this.walletClient = options.walletClient
53
+ this.multisig = options.multisig
54
+ }
55
+
56
+ // Ensure that we are using the right chain and wallet when executing transactions.
57
+ checkWalletClient = async (
58
+ step: LiFiStepExtended,
59
+ process?: Process
60
+ ): Promise<WalletClient | undefined> => {
61
+ const updatedWalletClient = await switchChain(
62
+ this.walletClient,
63
+ this.statusManager,
64
+ step,
65
+ this.allowUserInteraction,
66
+ this.executionOptions?.switchChainHook
67
+ )
68
+ if (updatedWalletClient) {
69
+ this.walletClient = updatedWalletClient
70
+ }
71
+
72
+ // Prevent execution of the quote by wallet different from the one which requested the quote
73
+ if (this.walletClient.account?.address !== step.action.fromAddress) {
74
+ let processToUpdate = process
75
+ if (!processToUpdate) {
76
+ // We need to create some process if we don't have one so we can show the error
77
+ processToUpdate = this.statusManager.findOrCreateProcess(
78
+ step,
79
+ 'TRANSACTION'
80
+ )
81
+ }
82
+ const errorMessage =
83
+ 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'
84
+ this.statusManager.updateProcess(step, processToUpdate.type, 'FAILED', {
85
+ error: {
86
+ code: LiFiErrorCode.WalletChangedDuringExecution,
87
+ message: errorMessage,
88
+ },
89
+ })
90
+ this.statusManager.updateExecution(step, 'FAILED')
91
+ throw new TransactionError(
92
+ LiFiErrorCode.WalletChangedDuringExecution,
93
+ errorMessage
94
+ )
95
+ }
96
+ return updatedWalletClient
97
+ }
98
+
99
+ executeStep = async (step: LiFiStepExtended): Promise<LiFiStepExtended> => {
100
+ step.execution = this.statusManager.initExecutionObject(step)
101
+
102
+ // Find if it's bridging and the step is waiting for a transaction on the receiving chain
103
+ const recievingChainProcess = step.execution?.process.find(
104
+ (process) => process.type === 'RECEIVING_CHAIN'
105
+ )
106
+
107
+ // Make sure that the chain is still correct
108
+ // If the step is waiting for a transaction on the receiving chain, we do not switch the chain
109
+ // All changes are already done from the source chain
110
+ // Return the step
111
+ if (recievingChainProcess?.substatus !== 'WAIT_DESTINATION_TRANSACTION') {
112
+ const updatedWalletClient = await this.checkWalletClient(step)
113
+ if (!updatedWalletClient) {
114
+ return step
115
+ }
116
+ }
117
+
118
+ const isMultisigWalletClient = !!this.multisig?.isMultisigWalletClient
119
+ const multisigBatchTransactions: MultisigTransaction[] = []
120
+
121
+ const shouldBatchTransactions =
122
+ this.multisig?.shouldBatchTransactions &&
123
+ !!this.multisig.sendBatchTransaction
124
+
125
+ const fromChain = await config.getChainById(step.action.fromChainId)
126
+ const toChain = await config.getChainById(step.action.toChainId)
127
+
128
+ const isBridgeExecution = fromChain.id !== toChain.id
129
+ const currentProcessType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
130
+
131
+ // STEP 1: Check allowance
132
+ const existingProcess = step.execution.process.find(
133
+ (p) => p.type === currentProcessType
134
+ )
135
+
136
+ // Check token approval only if fromToken is not the native token => no approval needed in that case
137
+ const checkForAllowance =
138
+ !existingProcess?.txHash &&
139
+ !isZeroAddress(step.action.fromToken.address) &&
140
+ (shouldBatchTransactions || !isMultisigWalletClient)
141
+
142
+ if (checkForAllowance) {
143
+ const data = await checkAllowance(
144
+ fromChain,
145
+ step,
146
+ this.walletClient,
147
+ this.statusManager,
148
+ this.executionOptions,
149
+ this.allowUserInteraction,
150
+ shouldBatchTransactions
151
+ )
152
+
153
+ if (data) {
154
+ // allowance doesn't need value
155
+ const baseTransaction: MultisigTransaction = {
156
+ to: step.action.fromToken.address,
157
+ data,
158
+ }
159
+
160
+ multisigBatchTransactions.push(baseTransaction)
161
+ }
162
+ }
163
+
164
+ // STEP 2: Get transaction
165
+ let process = this.statusManager.findOrCreateProcess(
166
+ step,
167
+ currentProcessType
168
+ )
169
+
170
+ if (process.status !== 'DONE') {
171
+ const multisigProcess = step.execution.process.find(
172
+ (p) => !!p.multisigTxHash
173
+ )
174
+
175
+ try {
176
+ if (isMultisigWalletClient && multisigProcess) {
177
+ const multisigTxHash = multisigProcess.multisigTxHash as Hash
178
+ if (!multisigTxHash) {
179
+ throw new ValidationError(
180
+ 'Multisig internal transaction hash is undefined.'
181
+ )
182
+ }
183
+ await updateMultisigRouteProcess(
184
+ multisigTxHash,
185
+ step,
186
+ process.type,
187
+ fromChain,
188
+ this.statusManager,
189
+ this.multisig
190
+ )
191
+ }
192
+
193
+ let txHash: Hash
194
+ if (process.txHash) {
195
+ // Make sure that the chain is still correct
196
+ const updatedWalletClient = await this.checkWalletClient(
197
+ step,
198
+ process
199
+ )
200
+ if (!updatedWalletClient) {
201
+ return step
202
+ }
203
+
204
+ // Wait for exiting transaction
205
+ txHash = process.txHash as Hash
206
+ } else {
207
+ process = this.statusManager.updateProcess(
208
+ step,
209
+ process.type,
210
+ 'STARTED'
211
+ )
212
+
213
+ // Check balance
214
+ await checkBalance(this.walletClient.account!.address, step)
215
+
216
+ // Create new transaction
217
+ if (!step.transactionRequest) {
218
+ const { execution, ...stepBase } = step
219
+ const updatedStep = await getStepTransaction(stepBase)
220
+ const comparedStep = await stepComparison(
221
+ this.statusManager,
222
+ step,
223
+ updatedStep,
224
+ this.allowUserInteraction,
225
+ this.executionOptions
226
+ )
227
+ step = {
228
+ ...comparedStep,
229
+ execution: step.execution,
230
+ }
231
+ }
232
+
233
+ if (!step.transactionRequest) {
234
+ throw new TransactionError(
235
+ LiFiErrorCode.TransactionUnprepared,
236
+ 'Unable to prepare transaction.'
237
+ )
238
+ }
239
+
240
+ // STEP 3: Send the transaction
241
+ // Make sure that the chain is still correct
242
+ const updatedWalletClient = await this.checkWalletClient(
243
+ step,
244
+ process
245
+ )
246
+ if (!updatedWalletClient) {
247
+ return step
248
+ }
249
+
250
+ process = this.statusManager.updateProcess(
251
+ step,
252
+ process.type,
253
+ 'ACTION_REQUIRED'
254
+ )
255
+
256
+ if (!this.allowUserInteraction) {
257
+ return step
258
+ }
259
+
260
+ let transactionRequest: TransactionParameters = {
261
+ to: step.transactionRequest.to as Hash,
262
+ from: step.transactionRequest.from as Hash,
263
+ data: step.transactionRequest.data as Hash,
264
+ value: step.transactionRequest.value
265
+ ? BigInt(step.transactionRequest.value as string)
266
+ : undefined,
267
+ gas: step.transactionRequest.gasLimit
268
+ ? BigInt(step.transactionRequest.gasLimit as string)
269
+ : undefined,
270
+ // gasPrice: step.transactionRequest.gasPrice
271
+ // ? BigInt(step.transactionRequest.gasPrice as string)
272
+ // : undefined,
273
+ // maxFeePerGas: step.transactionRequest.maxFeePerGas
274
+ // ? BigInt(step.transactionRequest.maxFeePerGas as string)
275
+ // : undefined,
276
+ maxPriorityFeePerGas:
277
+ this.walletClient.account?.type === 'local'
278
+ ? await getMaxPriorityFeePerGas(
279
+ this.walletClient.extend(publicActions) as PublicClient
280
+ )
281
+ : step.transactionRequest.maxPriorityFeePerGas
282
+ ? BigInt(
283
+ step.transactionRequest.maxPriorityFeePerGas as string
284
+ )
285
+ : undefined,
286
+ }
287
+
288
+ if (this.executionOptions?.updateTransactionRequestHook) {
289
+ const customizedTransactionRequest: TransactionParameters =
290
+ await this.executionOptions.updateTransactionRequestHook({
291
+ requestType: 'transaction',
292
+ ...transactionRequest,
293
+ })
294
+
295
+ transactionRequest = {
296
+ ...transactionRequest,
297
+ ...customizedTransactionRequest,
298
+ }
299
+ }
300
+
301
+ if (shouldBatchTransactions && this.multisig?.sendBatchTransaction) {
302
+ if (transactionRequest.to && transactionRequest.data) {
303
+ const populatedTransaction: MultisigTransaction = {
304
+ value: transactionRequest.value,
305
+ to: transactionRequest.to,
306
+ data: transactionRequest.data,
307
+ }
308
+ multisigBatchTransactions.push(populatedTransaction)
309
+
310
+ txHash = await this.multisig?.sendBatchTransaction(
311
+ multisigBatchTransactions
312
+ )
313
+ } else {
314
+ throw new TransactionError(
315
+ LiFiErrorCode.TransactionUnprepared,
316
+ 'Unable to prepare transaction.'
317
+ )
318
+ }
319
+ } else {
320
+ txHash = await this.walletClient.sendTransaction({
321
+ to: transactionRequest.to as Address,
322
+ account: this.walletClient.account!,
323
+ data: transactionRequest.data,
324
+ value: transactionRequest.value,
325
+ gas: transactionRequest.gas,
326
+ gasPrice: transactionRequest.gasPrice,
327
+ maxFeePerGas: transactionRequest.maxFeePerGas,
328
+ maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,
329
+ chain: null,
330
+ } as SendTransactionParameters)
331
+ }
332
+
333
+ // STEP 4: Wait for the transaction
334
+ if (isMultisigWalletClient) {
335
+ process = this.statusManager.updateProcess(
336
+ step,
337
+ process.type,
338
+ 'ACTION_REQUIRED',
339
+ {
340
+ multisigTxHash: txHash,
341
+ }
342
+ )
343
+ } else {
344
+ process = this.statusManager.updateProcess(
345
+ step,
346
+ process.type,
347
+ 'PENDING',
348
+ {
349
+ txHash: txHash,
350
+ txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
351
+ }
352
+ )
353
+ }
354
+ }
355
+
356
+ let replacementReason: ReplacementReason | undefined
357
+ const transactionReceipt = await this.walletClient
358
+ .extend(publicActions)
359
+ .waitForTransactionReceipt({
360
+ hash: txHash,
361
+ onReplaced: (response) => {
362
+ replacementReason = response.reason
363
+ this.statusManager.updateProcess(step, process.type, 'PENDING', {
364
+ txHash: response.transaction.hash,
365
+ txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.hash}`,
366
+ })
367
+ },
368
+ retryCount,
369
+ retryDelay,
370
+ })
371
+
372
+ if (transactionReceipt.status === 'reverted') {
373
+ throw new TransactionError(
374
+ LiFiErrorCode.TransactionFailed,
375
+ 'Transaction was reverted.'
376
+ )
377
+ }
378
+ if (replacementReason === 'cancelled') {
379
+ throw new TransactionError(
380
+ LiFiErrorCode.TransactionCanceled,
381
+ 'User canceled transaction.'
382
+ )
383
+ }
384
+
385
+ // if it's multisig wallet client and the process is in ACTION_REQUIRED
386
+ // then signatures are still needed
387
+ if (isMultisigWalletClient && process.status === 'ACTION_REQUIRED') {
388
+ await updateMultisigRouteProcess(
389
+ transactionReceipt.transactionHash,
390
+ step,
391
+ process.type,
392
+ fromChain,
393
+ this.statusManager,
394
+ this.multisig
395
+ )
396
+ }
397
+
398
+ if (!isMultisigWalletClient) {
399
+ process = this.statusManager.updateProcess(
400
+ step,
401
+ process.type,
402
+ 'PENDING',
403
+ {
404
+ txHash: transactionReceipt.transactionHash,
405
+ txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transactionReceipt.transactionHash}`,
406
+ }
407
+ )
408
+ }
409
+
410
+ if (isBridgeExecution) {
411
+ process = this.statusManager.updateProcess(step, process.type, 'DONE')
412
+ }
413
+ } catch (e: any) {
414
+ const error = await parseError(e, step, process)
415
+ process = this.statusManager.updateProcess(
416
+ step,
417
+ process.type,
418
+ 'FAILED',
419
+ {
420
+ error: {
421
+ message: error.message,
422
+ htmlMessage: error.htmlMessage,
423
+ code: error.code,
424
+ },
425
+ }
426
+ )
427
+ this.statusManager.updateExecution(step, 'FAILED')
428
+ throw error
429
+ }
430
+ }
431
+
432
+ // STEP 5: Wait for the receiving chain
433
+ const processTxHash = process.txHash
434
+ if (isBridgeExecution) {
435
+ process = this.statusManager.findOrCreateProcess(
436
+ step,
437
+ 'RECEIVING_CHAIN',
438
+ 'PENDING'
439
+ )
440
+ }
441
+ let statusResponse: FullStatusData
442
+
443
+ try {
444
+ if (!processTxHash) {
445
+ throw new Error('Transaction hash is undefined.')
446
+ }
447
+ statusResponse = (await waitForReceivingTransaction(
448
+ processTxHash,
449
+ this.statusManager,
450
+ process.type,
451
+ step
452
+ )) as FullStatusData
453
+
454
+ const statusReceiving =
455
+ statusResponse.receiving as ExtendedTransactionInfo
456
+
457
+ process = this.statusManager.updateProcess(step, process.type, 'DONE', {
458
+ substatus: statusResponse.substatus,
459
+ substatusMessage:
460
+ statusResponse.substatusMessage ||
461
+ getSubstatusMessage(statusResponse.status, statusResponse.substatus),
462
+ txHash: statusReceiving?.txHash,
463
+ txLink: `${toChain.metamask.blockExplorerUrls[0]}tx/${statusReceiving?.txHash}`,
464
+ })
465
+
466
+ this.statusManager.updateExecution(step, 'DONE', {
467
+ fromAmount: statusResponse.sending.amount,
468
+ toAmount: statusReceiving?.amount,
469
+ toToken: statusReceiving?.token,
470
+ gasCosts: [
471
+ {
472
+ amount: statusResponse.sending.gasAmount,
473
+ amountUSD: statusResponse.sending.gasAmountUSD,
474
+ token: statusResponse.sending.gasToken,
475
+ estimate: statusResponse.sending.gasUsed,
476
+ limit: statusResponse.sending.gasUsed,
477
+ price: statusResponse.sending.gasPrice,
478
+ type: 'SEND',
479
+ },
480
+ ],
481
+ })
482
+ } catch (e: unknown) {
483
+ const htmlMessage = await getTransactionFailedMessage(
484
+ step,
485
+ process.txLink
486
+ )
487
+
488
+ process = this.statusManager.updateProcess(step, process.type, 'FAILED', {
489
+ error: {
490
+ code: LiFiErrorCode.TransactionFailed,
491
+ message: 'Failed while waiting for receiving chain.',
492
+ htmlMessage,
493
+ },
494
+ })
495
+ this.statusManager.updateExecution(step, 'FAILED')
496
+ console.warn(e)
497
+ throw e
498
+ }
499
+
500
+ // DONE
501
+ return step
502
+ }
503
+ }
@@ -0,0 +1,47 @@
1
+ import type { Abi } from 'viem'
2
+
3
+ export const approveAbi: Abi = [
4
+ {
5
+ name: 'approve',
6
+ inputs: [
7
+ { internalType: 'address', name: 'spender', type: 'address' },
8
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
9
+ ],
10
+ outputs: [{ internalType: 'bool', name: 'approved', type: 'bool' }],
11
+ stateMutability: 'nonpayable',
12
+ type: 'function',
13
+ },
14
+ ]
15
+
16
+ export const allowanceAbi: Abi = [
17
+ {
18
+ name: 'allowance',
19
+ inputs: [
20
+ { internalType: 'address', name: 'owner', type: 'address' },
21
+ { internalType: 'address', name: 'spender', type: 'address' },
22
+ ],
23
+ outputs: [{ internalType: 'uint256', name: 'allowance', type: 'uint256' }],
24
+ stateMutability: 'view',
25
+ type: 'function',
26
+ },
27
+ ]
28
+
29
+ export const getEthBalanceAbi: Abi = [
30
+ {
31
+ inputs: [{ name: '_owner', type: 'address' }],
32
+ name: 'getEthBalance',
33
+ outputs: [{ name: 'balance', type: 'uint256' }],
34
+ type: 'function',
35
+ stateMutability: 'view',
36
+ },
37
+ ]
38
+
39
+ export const balanceOfAbi: Abi = [
40
+ {
41
+ inputs: [{ name: '_owner', type: 'address' }],
42
+ name: 'balanceOf',
43
+ outputs: [{ name: 'balance', type: 'uint256' }],
44
+ type: 'function',
45
+ stateMutability: 'view',
46
+ },
47
+ ]