@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,101 +0,0 @@
1
- import { ChainId, } from '../types';
2
- const DefaultExecutionSettings = {
3
- /* eslint-disable-next-line @typescript-eslint/no-empty-function */
4
- updateRouteHook: () => { },
5
- switchChainHook: () => Promise.resolve(undefined),
6
- acceptExchangeRateUpdateHook: () => Promise.resolve(undefined),
7
- infiniteApproval: false,
8
- executeInBackground: false,
9
- };
10
- class ConfigService {
11
- constructor() {
12
- this.resolveSetupPromise = undefined;
13
- /**
14
- * This call immediately returns the current config. It does not make sure that all chain data is already loaded
15
- * Use this if you need access to basic information like API urls or settings
16
- */
17
- this.getConfig = () => {
18
- return this.config;
19
- };
20
- /**
21
- * This call waits for all setup promises to be done.
22
- * Use this if you need access to chain data (RPCs or multicalls)
23
- */
24
- this.getConfigAsync = async () => {
25
- await this.setupPromise;
26
- return this.config;
27
- };
28
- this.updateConfig = (configUpdate) => {
29
- // API
30
- this.config.apiUrl = configUpdate.apiUrl || this.config.apiUrl;
31
- // RPCS
32
- this.config.rpcs = Object.assign(this.config.rpcs, configUpdate.rpcs);
33
- // MULTICALL
34
- this.config.multicallAddresses = Object.assign(this.config.multicallAddresses, configUpdate.multicallAddresses);
35
- // SETTINGS
36
- this.config.defaultExecutionSettings = Object.assign(this.config.defaultExecutionSettings, configUpdate.defaultExecutionSettings);
37
- // OPTIONS
38
- this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
39
- this.config.apiKey = configUpdate.apiKey || this.config.apiKey;
40
- this.config.userId = configUpdate.userId || this.config.userId;
41
- this.config.integrator = configUpdate.integrator || this.config.integrator;
42
- this.config.defaultRouteOptions.integrator =
43
- configUpdate.integrator ||
44
- configUpdate.defaultRouteOptions?.integrator ||
45
- this.config.integrator;
46
- this.config.widgetVersion =
47
- configUpdate.widgetVersion || this.config.widgetVersion;
48
- this.config.multisigConfig =
49
- configUpdate.multisigConfig || this.config.multisigConfig;
50
- return this.config;
51
- };
52
- this.updateChains = (chains) => {
53
- for (const chain of chains) {
54
- const chainId = chain.id;
55
- // set RPCs if they were not configured by the user before
56
- if (!this.config.rpcs[chainId]?.length) {
57
- this.config.rpcs[chainId] = chain.metamask.rpcUrls;
58
- }
59
- // set multicall addresses if they exist and were not configured by the user before
60
- if (chain.multicallAddress && !this.config.multicallAddresses[chainId]) {
61
- this.config.multicallAddresses[chainId] = chain.multicallAddress;
62
- }
63
- }
64
- this.resolveSetupPromise?.();
65
- return this.config;
66
- };
67
- this.config = ConfigService.getDefaultConfig();
68
- this.setupPromise = new Promise((resolve) => {
69
- this.resolveSetupPromise = resolve;
70
- });
71
- }
72
- static chainIdToObject(val) {
73
- const result = {};
74
- const values = Object.values(ChainId);
75
- values.forEach((chainId) => {
76
- if (typeof chainId !== 'string') {
77
- result[chainId] = val ? JSON.parse(JSON.stringify(val)) : val;
78
- }
79
- });
80
- return result;
81
- }
82
- static getInstance() {
83
- if (!this.instance) {
84
- this.instance = new ConfigService();
85
- }
86
- return this.instance;
87
- }
88
- }
89
- ConfigService.getDefaultConfig = () => {
90
- return {
91
- apiUrl: 'https://li.quest/v1',
92
- rpcs: ConfigService.chainIdToObject([]),
93
- multicallAddresses: ConfigService.chainIdToObject(undefined),
94
- defaultExecutionSettings: DefaultExecutionSettings,
95
- defaultRouteOptions: {
96
- integrator: 'lifi-sdk',
97
- },
98
- integrator: 'lifi-sdk',
99
- };
100
- };
101
- export default ConfigService;
@@ -1,4 +0,0 @@
1
- import { LifiStep, RoutesRequest, StaticToken } from './types';
2
- export declare const isRoutesRequest: (routesRequest: RoutesRequest) => routesRequest is RoutesRequest;
3
- export declare const isStep: (step: LifiStep) => step is LifiStep;
4
- export declare const isToken: (token: StaticToken) => token is StaticToken;
@@ -1,22 +0,0 @@
1
- import { BaseContract, BigNumber, BigNumberish, CallOverrides, ContractTransaction, Overrides } from 'ethers';
2
- export declare const ERC20_ABI: {
3
- name: string;
4
- inputs: {
5
- internalType: string;
6
- name: string;
7
- type: string;
8
- }[];
9
- outputs: {
10
- internalType: string;
11
- name: string;
12
- type: string;
13
- }[];
14
- stateMutability: string;
15
- type: string;
16
- }[];
17
- export interface ERC20Contract extends BaseContract {
18
- allowance(owner: string, spender: string, overrides?: CallOverrides): Promise<BigNumber>;
19
- approve(spender: string, amount: BigNumberish, overrides?: Overrides & {
20
- from?: string | Promise<string>;
21
- }): Promise<ContractTransaction>;
22
- }
@@ -1,50 +0,0 @@
1
- export const ERC20_ABI = [
2
- {
3
- name: 'approve',
4
- inputs: [
5
- {
6
- internalType: 'address',
7
- name: 'spender',
8
- type: 'address',
9
- },
10
- {
11
- internalType: 'uint256',
12
- name: 'amount',
13
- type: 'uint256',
14
- },
15
- ],
16
- outputs: [
17
- {
18
- internalType: 'bool',
19
- name: '',
20
- type: 'bool',
21
- },
22
- ],
23
- stateMutability: 'nonpayable',
24
- type: 'function',
25
- },
26
- {
27
- name: 'allowance',
28
- inputs: [
29
- {
30
- internalType: 'address',
31
- name: 'owner',
32
- type: 'address',
33
- },
34
- {
35
- internalType: 'address',
36
- name: 'spender',
37
- type: 'address',
38
- },
39
- ],
40
- outputs: [
41
- {
42
- internalType: 'uint256',
43
- name: '',
44
- type: 'uint256',
45
- },
46
- ],
47
- stateMutability: 'view',
48
- type: 'function',
49
- },
50
- ];
@@ -1,4 +0,0 @@
1
- export * from '@lifi/types';
2
- export { LifiError } from '../utils/errors';
3
- export * from './ERC20';
4
- export * from './internal.types';
@@ -1,151 +0,0 @@
1
- import { TransactionRequest } from '@ethersproject/abstract-provider';
2
- import { LifiStep, Route, RouteOptions, Token } from '@lifi/types';
3
- import BigNumber from 'bignumber.js';
4
- import { Signer } from 'ethers';
5
- import { ChainId } from '.';
6
- import { StatusManager } from '../execution/StatusManager';
7
- import { StepExecutor } from '../execution/StepExecutor';
8
- export interface TokenWithAmounts extends Token {
9
- amount?: BigNumber;
10
- amountRendered?: string;
11
- }
12
- export type ParsedReceipt = {
13
- fromAmount?: string;
14
- toAmount: string;
15
- gasUsed: string;
16
- gasPrice: string;
17
- gasFee: string;
18
- toTokenAddress?: string;
19
- };
20
- export interface ExecutionParams {
21
- signer: Signer;
22
- step: LifiStep;
23
- statusManager: StatusManager;
24
- settings: InternalExecutionSettings;
25
- }
26
- export type UpdateRouteHook = (updatedRoute: Route) => void;
27
- export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequest) => Promise<TransactionRequest>;
28
- export type Config = {
29
- apiUrl: string;
30
- apiKey?: string;
31
- rpcs: Record<ChainId, string[]>;
32
- multicallAddresses: Record<ChainId, string | undefined>;
33
- defaultExecutionSettings: InternalExecutionSettings;
34
- defaultRouteOptions: RouteOptions;
35
- disableVersionCheck?: boolean;
36
- userId?: string;
37
- integrator: string;
38
- widgetVersion?: string;
39
- multisigConfig?: MultisigConfig;
40
- };
41
- export interface MultisigTxDetails {
42
- status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
43
- txHash?: string;
44
- }
45
- export interface MultisigTransactionResponse {
46
- hash: string;
47
- }
48
- export interface BaseTransaction {
49
- to: string;
50
- value: string;
51
- data: string;
52
- }
53
- export interface MultisigConfig {
54
- isMultisigSigner?: boolean;
55
- getMultisigTransactionDetails?: (txHash: string, fromChainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
56
- sendBatchTransaction?: (batchTransactions: BaseTransaction[]) => Promise<MultisigTransactionResponse>;
57
- shouldBatchTransactions?: boolean;
58
- }
59
- export type ConfigUpdate = {
60
- apiUrl?: string;
61
- apiKey?: string;
62
- rpcs?: Record<number, string[]>;
63
- multicallAddresses?: Record<number, string | undefined>;
64
- defaultExecutionSettings?: ExecutionSettings;
65
- defaultRouteOptions?: RouteOptions;
66
- disableVersionCheck?: boolean;
67
- userId?: string;
68
- integrator: string;
69
- widgetVersion?: string;
70
- multisigConfig?: MultisigConfig;
71
- };
72
- export type SwitchChainHook = (requiredChainId: number) => Promise<Signer | undefined>;
73
- export interface AcceptSlippageUpdateHookParams {
74
- toToken: Token;
75
- oldToAmount: string;
76
- newToAmount: string;
77
- oldSlippage: number;
78
- newSlippage: number;
79
- }
80
- export type AcceptSlippageUpdateHook = (params: AcceptSlippageUpdateHookParams) => Promise<boolean | undefined>;
81
- export interface ExchangeRateUpdateParams {
82
- toToken: Token;
83
- oldToAmount: string;
84
- newToAmount: string;
85
- }
86
- export type AcceptExchangeRateUpdateHook = (params: ExchangeRateUpdateParams) => Promise<boolean | undefined>;
87
- export interface RouteExecutionData {
88
- route: Route;
89
- executors: StepExecutor[];
90
- settings: InternalExecutionSettings;
91
- }
92
- export type ExecutionSettings = Partial<InternalExecutionSettings>;
93
- export interface InternalExecutionSettings {
94
- acceptExchangeRateUpdateHook: AcceptExchangeRateUpdateHook;
95
- switchChainHook: SwitchChainHook;
96
- updateRouteHook: UpdateRouteHook;
97
- updateTransactionRequestHook?: TransactionRequestUpdateHook;
98
- executeInBackground: boolean;
99
- infiniteApproval: boolean;
100
- }
101
- export type RouteExecutionDictionary = Partial<Record<string, RouteExecutionData>>;
102
- export type RouteExecutionPromiseDictionary = Partial<Record<string, Promise<Route>>>;
103
- export type RevokeTokenData = {
104
- token: Token;
105
- approvalAddress: string;
106
- };
107
- export interface InteractionSettings {
108
- allowInteraction?: boolean;
109
- allowUpdates?: boolean;
110
- stopExecution?: boolean;
111
- }
112
- export interface TenderlyResponse {
113
- hash: string;
114
- block_hash: string;
115
- block_number: number;
116
- from: string;
117
- gas: number;
118
- gas_price: number;
119
- gas_fee_cap: number;
120
- gas_tip_cap: number;
121
- cumulative_gas_used: number;
122
- gas_used: number;
123
- effective_gas_price: number;
124
- input: string;
125
- nonce: number;
126
- to: string;
127
- index: number;
128
- value: string;
129
- access_list: any;
130
- status: boolean;
131
- addresses: string[];
132
- contract_ids: string[];
133
- network_id: string;
134
- timestamp: string;
135
- function_selector: string;
136
- l1_block_number: number;
137
- l1_timestamp: number;
138
- deposit_tx: boolean;
139
- system_tx: boolean;
140
- mint: number;
141
- sig: Signature;
142
- error_message: string;
143
- method: string;
144
- decoded_input: any;
145
- call_trace: any;
146
- }
147
- export interface Signature {
148
- v: string;
149
- r: string;
150
- s: string;
151
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,106 +0,0 @@
1
- declare enum ErrorType {
2
- RPCError = "RPCError",
3
- ProviderError = "ProviderError",
4
- ServerError = "ServerError",
5
- TransactionError = "TransactionError",
6
- ValidationError = "ValidationError",
7
- NotFoundError = "NotFoundError",
8
- UnknownError = "UnknownError",
9
- SlippageError = "SlippageError"
10
- }
11
- export declare enum LifiErrorCode {
12
- InternalError = 1000,
13
- ValidationError = 1001,
14
- TransactionUnderpriced = 1002,
15
- TransactionFailed = 1003,
16
- Timeout = 1004,
17
- ProviderUnavailable = 1005,
18
- NotFound = 1006,
19
- ChainSwitchError = 1007,
20
- TransactionUnprepared = 1008,
21
- GasLimitError = 1009,
22
- TransactionCanceled = 1010,
23
- SlippageError = 1011,
24
- TransactionRejected = 1012,
25
- BalanceError = 1013,
26
- AllowanceRequired = 1014,
27
- InsufficientFunds = 1015
28
- }
29
- export declare enum EthersErrorType {
30
- ActionRejected = "ACTION_REJECTED",
31
- CallExecption = "CALL_EXCEPTION",
32
- InsufficientFunds = "INSUFFICIENT_FUNDS"
33
- }
34
- export declare enum EthersErrorMessage {
35
- ERC20Allowance = "ERC20: transfer amount exceeds allowance",
36
- LowGas = "intrinsic gas too low",
37
- OutOfGas = "out of gas",
38
- Underpriced = "underpriced",
39
- LowReplacementFee = "replacement fee too low"
40
- }
41
- export declare enum ErrorMessage {
42
- UnknownError = "Unknown error occurred.",
43
- SlippageError = "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote.",
44
- GasLimitLow = "Gas limit is too low.",
45
- TransactionUnderpriced = "Transaction is underpriced.",
46
- Default = "Something went wrong."
47
- }
48
- export declare enum MetaMaskRPCErrorCode {
49
- invalidInput = -32000,
50
- resourceNotFound = -32001,
51
- resourceUnavailable = -32002,
52
- transactionRejected = -32003,
53
- methodNotSupported = -32004,
54
- limitExceeded = -32005,
55
- parse = -32700,
56
- invalidRequest = -32600,
57
- methodNotFound = -32601,
58
- invalidParams = -32602,
59
- internal = -32603
60
- }
61
- export declare enum MetaMaskProviderErrorCode {
62
- userRejectedRequest = 4001,
63
- unauthorized = 4100,
64
- unsupportedMethod = 4200,
65
- disconnected = 4900,
66
- chainDisconnected = 4901
67
- }
68
- export type ErrorCode = LifiErrorCode | MetaMaskRPCErrorCode | MetaMaskProviderErrorCode;
69
- export declare class LifiError extends Error {
70
- code: ErrorCode;
71
- htmlMessage?: string;
72
- constructor(type: ErrorType, code: number, message: string, htmlMessage?: string, stack?: string);
73
- }
74
- export declare class RPCError extends LifiError {
75
- constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
76
- }
77
- export declare class ProviderError extends LifiError {
78
- constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
79
- }
80
- export declare class ServerError extends LifiError {
81
- constructor(message: string, htmlMessage?: string, stack?: string);
82
- }
83
- export declare class ValidationError extends LifiError {
84
- constructor(message: string, htmlMessage?: string, stack?: string);
85
- }
86
- export declare class TransactionError extends LifiError {
87
- constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
88
- }
89
- export declare class SlippageError extends LifiError {
90
- constructor(message: string, htmlMessage?: string, stack?: string);
91
- }
92
- export declare class BalanceError extends LifiError {
93
- constructor(message: string, htmlMessage?: string, stack?: string);
94
- }
95
- export declare class NotFoundError extends LifiError {
96
- constructor(message: string, htmlMessage?: string, stack?: string);
97
- }
98
- export declare class UnknownError extends LifiError {
99
- constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
100
- }
101
- export declare class HTTPError extends Error {
102
- response: Response;
103
- status: number;
104
- constructor(response: Response);
105
- }
106
- export {};
@@ -1,3 +0,0 @@
1
- import { Provider } from '@ethersproject/abstract-provider';
2
- import { Signer } from 'ethers';
3
- export declare const getProvider: (signer: Signer) => Provider;
@@ -1,7 +0,0 @@
1
- import { LifiErrorCode, ProviderError } from './errors';
2
- export const getProvider = (signer) => {
3
- if (!signer.provider) {
4
- throw new ProviderError(LifiErrorCode.ProviderUnavailable, 'No provider available in signer.');
5
- }
6
- return signer.provider;
7
- };
@@ -1,10 +0,0 @@
1
- import { Fragment, JsonFragment } from '@ethersproject/abi';
2
- export type MultiCallData = {
3
- address: string;
4
- name: string;
5
- params?: any[];
6
- };
7
- export declare const fetchDataUsingMulticall: (calls: Array<MultiCallData>, abi: ReadonlyArray<Fragment | JsonFragment | string>, chainId: number, multicallAddress: string, requireSuccess?: boolean) => Promise<{
8
- data: unknown;
9
- blockNumber: number;
10
- }[]>;
@@ -1,61 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { Contract } from '@ethersproject/contracts';
3
- import { getRpcProvider } from '../connectors';
4
- import { splitListIntoChunks } from './utils';
5
- import MULTICALL_ABI from './multicallAbi.json';
6
- const MAX_MULTICALL_SIZE = 100;
7
- export const fetchDataUsingMulticall = async (calls, abi, chainId, multicallAddress, requireSuccess = false) => {
8
- // 1. create contract using multicall contract address and abi...
9
- const provider = await getRpcProvider(chainId);
10
- const multicallContract = new Contract(multicallAddress, MULTICALL_ABI, provider);
11
- const abiInterface = new Interface(abi);
12
- // split up lists into chunks to stay below multicall limit
13
- const chunkedList = splitListIntoChunks(calls, MAX_MULTICALL_SIZE);
14
- const chunkedResults = await Promise.all(chunkedList.map(async (chunkedCalls) => {
15
- const callData = chunkedCalls.map((call) => [
16
- call.address.toLowerCase(),
17
- abiInterface.encodeFunctionData(call.name, call.params),
18
- ]);
19
- try {
20
- // 3. get bytes array from multicall contract by process aggregate method...
21
- const { blockNumber, returnData } = await multicallContract.tryBlockAndAggregate(requireSuccess, callData);
22
- // 4. decode bytes array to useful data array...
23
- return returnData
24
- .map(({ success, returnData }, i) => {
25
- if (!success) {
26
- // requested function failed
27
- console.error(`Multicall unsuccessful for address "${chunkedCalls[i].address}", ` +
28
- `function "${chunkedCalls[i].name}", chainId "${chainId}"`);
29
- return [];
30
- }
31
- if (returnData.toString() === '0x') {
32
- // requested function does probably not exist
33
- console.error(`Multicall no response for address "${chunkedCalls[i].address}", ` +
34
- `function "${chunkedCalls[i].name}", chainId "${chainId}"`);
35
- return [];
36
- }
37
- try {
38
- return abiInterface.decodeFunctionResult(chunkedCalls[i].name, returnData);
39
- }
40
- catch (e) {
41
- // requested function returns other data than expected
42
- console.error(`Multicall parsing unsuccessful for address "${chunkedCalls[i].address}", ` +
43
- `function "${chunkedCalls[i].name}", chainId "${chainId}"`);
44
- return [];
45
- }
46
- })
47
- .map((data) => {
48
- return {
49
- data: data[0],
50
- blockNumber: blockNumber.toNumber(),
51
- };
52
- });
53
- }
54
- catch (e) {
55
- // whole rpc call failed, probably an rpc issue
56
- console.error(`Multicall failed on chainId "${chainId}"`, chunkedList, e);
57
- return [];
58
- }
59
- }));
60
- return chunkedResults.flat();
61
- };