@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
package/package.json CHANGED
@@ -1,110 +1,52 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "2.3.1",
4
3
  "description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
5
- "main": "./dist/cjs/index.js",
6
- "module": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "scripts": {
9
- "watch": "tsc -w -p ./tsconfig.json",
10
- "build": "yarn clean && tsc --project ./tsconfig.json && tsc --project ./tsconfig.cjs.json",
11
- "clean": "node tools/cleanup",
12
- "package": "npm run build && npm pack",
13
- "test": "vitest --run --dangerouslyIgnoreUnhandledErrors",
14
- "test:unit": "yarn test .unit.spec.ts",
15
- "test:cov": "yarn test --coverage",
16
- "test:e2e": "yarn test -c vitest.e2e.config.ts",
17
- "addscope": "node tools/packagejson name @lifi/sdk",
18
- "pre-commit": "lint-staged",
19
- "pre-push": "yarn types:check && yarn build && yarn test:unit",
20
- "lint": "eslint --ext .tsx --ext .ts ./src",
21
- "lint:fix": "eslint --ext .tsx --ext .ts ./src --fix",
22
- "types:check": "tsc --noEmit",
23
- "prettier:fix": "prettier --write ./src/.",
24
- "use:npmReadme": "mv 'README.md' 'git.README.md' && mv 'npm.README.md' 'README.md'",
25
- "use:gitReadme": "mv 'README.md' 'npm.README.md' && mv 'git.README.md' 'README.md'",
26
- "prepublishOnly": "run-s build use:npmReadme && pinst --enable",
27
- "postpublish": "npm run use:gitReadme && pinst --enable",
28
- "prepare": "husky install",
29
- "release": "standard-version -a",
30
- "release:beta": "standard-version -a --prerelease beta --skip.changelog"
31
- },
32
- "standard-version": {
33
- "scripts": {
34
- "postbump": "node scripts/version.js && git add ."
35
- }
36
- },
37
- "lint-staged": {
38
- "src/**/*.{ts,tsx}": [
39
- "yarn run lint:fix",
40
- "yarn run prettier:fix"
41
- ]
4
+ "dependencies": {
5
+ "@lifi/types": "^9.0.0-alpha.15",
6
+ "@solana/web3.js": "^1.78.4",
7
+ "eth-rpc-errors": "^4.0.3",
8
+ "viem": "^1.10.4"
42
9
  },
10
+ "version": "3.0.0-alpha.10",
43
11
  "files": [
44
- "dist"
12
+ "dist",
13
+ "!dist/**/*.tsbuildinfo"
45
14
  ],
46
- "publishConfig": {
47
- "access": "public"
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/types/index.d.ts",
18
+ "import": "./dist/esm/index.js",
19
+ "default": "./dist/cjs/index.js"
20
+ },
21
+ "./package.json": "./package.json"
48
22
  },
49
- "author": "Max Klenk <max@li.finance>",
23
+ "main": "./dist/cjs/index.js",
24
+ "module": "./dist/esm/index.js",
25
+ "types": "./dist/types/index.d.ts",
26
+ "typings": "./dist/types/index.d.ts",
50
27
  "license": "Apache-2.0",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+ssh://git@github.com/lifinance/sdk.git"
31
+ },
51
32
  "keywords": [
52
- "sdk",
53
- "ethereum",
54
- "dapp",
55
33
  "bridge",
56
- "swap",
57
- "web3",
58
- "lifi",
59
- "ethers",
34
+ "bridge-aggregation",
60
35
  "cross-chain",
61
- "defi",
62
- "web3-react",
63
36
  "cross-chain-applications",
64
37
  "cross-chain-bridge",
65
- "bridge-aggregation",
38
+ "dapp",
39
+ "defi",
40
+ "ethereum",
41
+ "ethers",
42
+ "lifi",
43
+ "metamask",
66
44
  "multi-chain",
67
- "metamask"
68
- ],
69
- "homepage": "https://github.com/lifinance/sdk",
70
- "repository": {
71
- "type": "git",
72
- "url": "git+ssh://git@github.com/lifinance/sdk.git"
73
- },
74
- "bugs": {
75
- "url": "https://github.com/lifinance/sdk/issues"
76
- },
77
- "dependencies": {
78
- "@ethersproject/abi": "^5.7.0",
79
- "@ethersproject/contracts": "^5.7.0",
80
- "@lifi/types": "^8.4.0",
81
- "bignumber.js": "^9.1.1",
82
- "eth-rpc-errors": "^4.0.3",
83
- "ethers": "^5.7.2"
84
- },
85
- "devDependencies": {
86
- "@commitlint/cli": "^17.6.7",
87
- "@commitlint/config-conventional": "^17.6.7",
88
- "@mswjs/interceptors": "^0.22.16",
89
- "@typescript-eslint/eslint-plugin": "^6.1.0",
90
- "@typescript-eslint/parser": "^6.1.0",
91
- "@vitest/coverage-c8": "^0.33.0",
92
- "cross-fetch": "^4.0.0",
93
- "eslint": "^8.45.0",
94
- "eslint-config-prettier": "^8.8.0",
95
- "eslint-plugin-prettier": "^5.0.0",
96
- "husky": "^8.0.3",
97
- "lint-staged": "^13.2.3",
98
- "msw": "1.0.1",
99
- "npm-run-all": "^4.1.5",
100
- "pinst": "^3.0.0",
101
- "prettier": "^3.0.0",
102
- "standard-version": "^9.5.0",
103
- "typescript": "^5.1.6",
104
- "vitest": "^0.33.0"
105
- },
106
- "directories": {
107
- "test": "test"
108
- },
109
- "packageManager": "yarn@3.6.1"
45
+ "sdk",
46
+ "swap",
47
+ "viem",
48
+ "wagmi",
49
+ "web3",
50
+ "web3-react"
51
+ ]
110
52
  }
package/dist/LiFi.d.ts DELETED
@@ -1,164 +0,0 @@
1
- import { FallbackProvider } from '@ethersproject/providers';
2
- import { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
3
- import { Signer } from 'ethers';
4
- import { ApproveTokenRequest, RevokeApprovalRequest } from './allowance';
5
- import { RouteExecutionManager } from './execution/RouteExecutionManager';
6
- import { Config, ConfigUpdate, RevokeTokenData } from './types';
7
- export declare class LiFi extends RouteExecutionManager {
8
- private chainsService;
9
- constructor(configUpdate: ConfigUpdate);
10
- /**
11
- * Get the current configuration of the SDK
12
- * @return {Config} - The config object
13
- */
14
- getConfig: () => Config;
15
- /**
16
- * Get the SDK configuration after all setup calls are finished
17
- * @return {Promise<Config>} - The config object
18
- */
19
- getConfigAsync: () => Promise<Config>;
20
- /**
21
- * Get an instance of a provider for a specific chain
22
- * @param {number} chainId - Id of the chain the provider is for
23
- * @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
24
- * @return {FallbackProvider} The provider for the given chain
25
- */
26
- getRpcProvider: (chainId: number, archive?: boolean) => Promise<FallbackProvider>;
27
- /**
28
- * Set a new confuration for the SDK
29
- * @param {ConfigUpdate} configUpdate - An object containing the configuration fields that should be updated.
30
- * @return {Config} The renewed config object
31
- */
32
- setConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
33
- /**
34
- * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
35
- * @param {PossibilitiesRequest} request - Object defining preferences regarding chain, exchanges and bridges
36
- * @return {Promise<PossibilitiesResponse>} Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
37
- * @throws {LifiError} Throws a LifiError if request fails.
38
- * @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
39
- */
40
- getPossibilities: (request?: PossibilitiesRequest, options?: RequestOptions) => Promise<PossibilitiesResponse>;
41
- /**
42
- * Fetch information about a Token
43
- * @param {ChainKey | ChainId} chain - Id or key of the chain that contains the token
44
- * @param {string} token - Address or symbol of the token on the requested chain
45
- * @throws {LifiError} - Throws a LifiError if request fails
46
- */
47
- getToken: (chain: ChainKey | ChainId, token: string, options?: RequestOptions) => Promise<Token>;
48
- /**
49
- * Get a quote for a token transfer
50
- * @param {QuoteRequest} request - The configuration of the requested quote
51
- * @throws {LifiError} - Throws a LifiError if request fails
52
- */
53
- getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
54
- /**
55
- * Get a quote for a destination contract call
56
- * @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
57
- * @throws {LifiError} - Throws a LifiError if request fails
58
- */
59
- getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
60
- /**
61
- * Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
62
- * @param {GetStatusRequest} request - Configuration of the requested status
63
- * @throws {LifiError} - Throws a LifiError if request fails
64
- */
65
- getStatus: (request: GetStatusRequest, options?: RequestOptions) => Promise<StatusResponse>;
66
- /**
67
- * Get the available tools to bridge and swap tokens.
68
- * @param {ToolsRequest?} request - The configuration of the requested tools
69
- * @returns The tools that are available on the requested chains
70
- */
71
- getTools: (request?: ToolsRequest, options?: RequestOptions) => Promise<ToolsResponse>;
72
- /**
73
- * Get all known tokens.
74
- * @param {TokensRequest?} request - The configuration of the requested tokens
75
- * @returns The tokens that are available on the requested chains
76
- */
77
- getTokens: (request?: TokensRequest, options?: RequestOptions) => Promise<TokensResponse>;
78
- /**
79
- * Get all available chains
80
- * @return {Promise<Chain[]>} A list of all available chains
81
- * @throws {LifiError} Throws a LifiError if request fails.
82
- */
83
- getChains: () => Promise<ExtendedChain[]>;
84
- /**
85
- * Get a set of routes for a request that describes a transfer of tokens.
86
- * @param {RoutesRequest} request - A description of the transfer.
87
- * @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
88
- * @throws {LifiError} Throws a LifiError if request fails.
89
- */
90
- getRoutes: (request: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
91
- /**
92
- * Get the transaction data for a single step of a route
93
- * @param {LifiStep} step - The step object.
94
- * @return {Promise<LifiStep>} The step populated with the transaction data.
95
- * @throws {LifiError} Throws a LifiError if request fails.
96
- */
97
- getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
98
- /**
99
- * Get gas recommendation for a certain chain
100
- * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
101
- * @throws {LifiError} Throws a LifiError if request fails.
102
- */
103
- getGasRecommendation: (request: GasRecommendationRequest, options?: RequestOptions) => Promise<GasRecommendationResponse>;
104
- /**
105
- * Returns the balances of a specific token a wallet holds across all aggregated chains.
106
- * @param {string} walletAddress - A wallet address.
107
- * @param {Token} token - A Token object.
108
- * @return {Promise<TokenAmount | null>} An object containing the token and the amounts on different chains.
109
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
110
- */
111
- getTokenBalance: (walletAddress: string, token: Token) => Promise<TokenAmount | null>;
112
- /**
113
- * Returns the balances for a list tokens a wallet holds across all aggregated chains.
114
- * @param {string} walletAddress - A wallet address.
115
- * @param {Token[]} tokens - A list of Token objects.
116
- * @return {Promise<TokenAmount[]>} A list of objects containing the tokens and the amounts on different chains.
117
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
118
- */
119
- getTokenBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
120
- /**
121
- * This method queries the balances of tokens for a specific list of chains for a given wallet.
122
- * @param {string} walletAddress - A walletaddress.
123
- * @param {{ [chainId: number]: Token[] }} tokensByChain - A list of Token objects organized by chain ids.
124
- * @return {Promise<{ [chainId: number]: TokenAmount[] }>} A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.
125
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
126
- */
127
- getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
128
- [chainId: number]: Token[];
129
- }) => Promise<{
130
- [chainId: number]: TokenAmount[];
131
- }>;
132
- /**
133
- * Get the current approval for a certain token.
134
- * @param signer - The signer owning the token
135
- * @param token - The token that should be checked
136
- * @param approvalAddress - The address that has be approved
137
- */
138
- getTokenApproval: (signer: Signer, token: Token, approvalAddress: string) => Promise<string | undefined>;
139
- /**
140
- * Get the current approval for a list of token / approval address pairs.
141
- * @param signer - The signer owning the tokens
142
- * @param tokenData - A list of token and approval address pairs
143
- */
144
- bulkGetTokenApproval: (signer: Signer, tokenData: RevokeTokenData[]) => Promise<{
145
- token: Token;
146
- approval: string | undefined;
147
- }[]>;
148
- /**
149
- * Set approval for a certain token and amount.
150
- * @param { ApproveTokenRequest } request - The approval request
151
- */
152
- approveToken: (request: ApproveTokenRequest) => Promise<void>;
153
- /**
154
- * Revoke approval for a certain token.
155
- * @param { RevokeApprovalRequest } request - The revoke request
156
- */
157
- revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<void>;
158
- /**
159
- * Get all the available connections for swap/bridging tokens
160
- * @param connectionRequest ConnectionsRequest
161
- * @returns ConnectionsResponse
162
- */
163
- getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
164
- }
package/dist/LiFi.js DELETED
@@ -1,235 +0,0 @@
1
- import { approveToken, bulkGetTokenApproval, getTokenApproval, revokeTokenApproval, } from './allowance';
2
- import * as balance from './balance';
3
- import { getRpcProvider } from './connectors';
4
- import { RouteExecutionManager } from './execution/RouteExecutionManager';
5
- import { checkPackageUpdates } from './helpers';
6
- import ApiService from './services/ApiService';
7
- import ChainsService from './services/ChainsService';
8
- import { isToken } from './typeguards';
9
- import { ValidationError } from './utils/errors';
10
- import { name, version } from './version';
11
- export class LiFi extends RouteExecutionManager {
12
- constructor(configUpdate) {
13
- super(configUpdate);
14
- /**
15
- * Get the current configuration of the SDK
16
- * @return {Config} - The config object
17
- */
18
- this.getConfig = () => {
19
- return this.configService.getConfig();
20
- };
21
- /**
22
- * Get the SDK configuration after all setup calls are finished
23
- * @return {Promise<Config>} - The config object
24
- */
25
- this.getConfigAsync = () => {
26
- return this.configService.getConfigAsync();
27
- };
28
- /**
29
- * Get an instance of a provider for a specific chain
30
- * @param {number} chainId - Id of the chain the provider is for
31
- * @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
32
- * @return {FallbackProvider} The provider for the given chain
33
- */
34
- this.getRpcProvider = (chainId, archive = false) => {
35
- return getRpcProvider(chainId, archive);
36
- };
37
- /**
38
- * Set a new confuration for the SDK
39
- * @param {ConfigUpdate} configUpdate - An object containing the configuration fields that should be updated.
40
- * @return {Config} The renewed config object
41
- */
42
- this.setConfig = (configUpdate) => {
43
- return this.configService.updateConfig(configUpdate);
44
- };
45
- /**
46
- * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
47
- * @param {PossibilitiesRequest} request - Object defining preferences regarding chain, exchanges and bridges
48
- * @return {Promise<PossibilitiesResponse>} Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
49
- * @throws {LifiError} Throws a LifiError if request fails.
50
- * @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
51
- */
52
- this.getPossibilities = async (request, options) => {
53
- return ApiService.getPossibilities(request, options);
54
- };
55
- /**
56
- * Fetch information about a Token
57
- * @param {ChainKey | ChainId} chain - Id or key of the chain that contains the token
58
- * @param {string} token - Address or symbol of the token on the requested chain
59
- * @throws {LifiError} - Throws a LifiError if request fails
60
- */
61
- this.getToken = async (chain, token, options) => {
62
- return ApiService.getToken(chain, token, options);
63
- };
64
- /**
65
- * Get a quote for a token transfer
66
- * @param {QuoteRequest} request - The configuration of the requested quote
67
- * @throws {LifiError} - Throws a LifiError if request fails
68
- */
69
- this.getQuote = async (request, options) => {
70
- return ApiService.getQuote(request, options);
71
- };
72
- /**
73
- * Get a quote for a destination contract call
74
- * @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
75
- * @throws {LifiError} - Throws a LifiError if request fails
76
- */
77
- this.getContractCallQuote = async (request, options) => {
78
- return ApiService.getContractCallQuote(request, options);
79
- };
80
- /**
81
- * Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
82
- * @param {GetStatusRequest} request - Configuration of the requested status
83
- * @throws {LifiError} - Throws a LifiError if request fails
84
- */
85
- this.getStatus = async (request, options) => {
86
- return ApiService.getStatus(request, options);
87
- };
88
- /**
89
- * Get the available tools to bridge and swap tokens.
90
- * @param {ToolsRequest?} request - The configuration of the requested tools
91
- * @returns The tools that are available on the requested chains
92
- */
93
- this.getTools = async (request, options) => {
94
- return ApiService.getTools(request || {}, options);
95
- };
96
- /**
97
- * Get all known tokens.
98
- * @param {TokensRequest?} request - The configuration of the requested tokens
99
- * @returns The tokens that are available on the requested chains
100
- */
101
- this.getTokens = async (request, options) => {
102
- return ApiService.getTokens(request || {}, options);
103
- };
104
- /**
105
- * Get all available chains
106
- * @return {Promise<Chain[]>} A list of all available chains
107
- * @throws {LifiError} Throws a LifiError if request fails.
108
- */
109
- this.getChains = async () => {
110
- return this.chainsService.getChains();
111
- };
112
- /**
113
- * Get a set of routes for a request that describes a transfer of tokens.
114
- * @param {RoutesRequest} request - A description of the transfer.
115
- * @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
116
- * @throws {LifiError} Throws a LifiError if request fails.
117
- */
118
- this.getRoutes = async (request, options) => {
119
- return ApiService.getRoutes(request, options);
120
- };
121
- /**
122
- * Get the transaction data for a single step of a route
123
- * @param {LifiStep} step - The step object.
124
- * @return {Promise<LifiStep>} The step populated with the transaction data.
125
- * @throws {LifiError} Throws a LifiError if request fails.
126
- */
127
- this.getStepTransaction = async (step, options) => {
128
- return ApiService.getStepTransaction(step, options);
129
- };
130
- /**
131
- * Get gas recommendation for a certain chain
132
- * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
133
- * @throws {LifiError} Throws a LifiError if request fails.
134
- */
135
- this.getGasRecommendation = async (request, options) => {
136
- return ApiService.getGasRecommendation(request, options);
137
- };
138
- /**
139
- * Returns the balances of a specific token a wallet holds across all aggregated chains.
140
- * @param {string} walletAddress - A wallet address.
141
- * @param {Token} token - A Token object.
142
- * @return {Promise<TokenAmount | null>} An object containing the token and the amounts on different chains.
143
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
144
- */
145
- this.getTokenBalance = async (walletAddress, token) => {
146
- if (!walletAddress) {
147
- throw new ValidationError('Missing walletAddress.');
148
- }
149
- if (!isToken(token)) {
150
- throw new ValidationError(`Invalid token passed: address "${token.address}" on chainId "${token.chainId}"`);
151
- }
152
- return balance.getTokenBalance(walletAddress, token);
153
- };
154
- /**
155
- * Returns the balances for a list tokens a wallet holds across all aggregated chains.
156
- * @param {string} walletAddress - A wallet address.
157
- * @param {Token[]} tokens - A list of Token objects.
158
- * @return {Promise<TokenAmount[]>} A list of objects containing the tokens and the amounts on different chains.
159
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
160
- */
161
- this.getTokenBalances = async (walletAddress, tokens) => {
162
- if (!walletAddress) {
163
- throw new ValidationError('Missing walletAddress.');
164
- }
165
- const invalidTokens = tokens.filter((token) => !isToken(token));
166
- if (invalidTokens.length) {
167
- throw new ValidationError(`Invalid token passed: address "${invalidTokens[0].address}" on chainId "${invalidTokens[0].chainId}"`);
168
- }
169
- return balance.getTokenBalances(walletAddress, tokens);
170
- };
171
- /**
172
- * This method queries the balances of tokens for a specific list of chains for a given wallet.
173
- * @param {string} walletAddress - A walletaddress.
174
- * @param {{ [chainId: number]: Token[] }} tokensByChain - A list of Token objects organized by chain ids.
175
- * @return {Promise<{ [chainId: number]: TokenAmount[] }>} A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.
176
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
177
- */
178
- this.getTokenBalancesForChains = async (walletAddress, tokensByChain) => {
179
- if (!walletAddress) {
180
- throw new ValidationError('Missing walletAddress.');
181
- }
182
- const tokenList = Object.values(tokensByChain).flat();
183
- const invalidTokens = tokenList.filter((token) => !isToken(token));
184
- if (invalidTokens.length) {
185
- throw new ValidationError(`Invalid token passed: address "${invalidTokens[0].address}" on chainId "${invalidTokens[0].chainId}"`);
186
- }
187
- return balance.getTokenBalancesForChains(walletAddress, tokensByChain);
188
- };
189
- /**
190
- * Get the current approval for a certain token.
191
- * @param signer - The signer owning the token
192
- * @param token - The token that should be checked
193
- * @param approvalAddress - The address that has be approved
194
- */
195
- this.getTokenApproval = async (signer, token, approvalAddress) => {
196
- return getTokenApproval(signer, token, approvalAddress);
197
- };
198
- /**
199
- * Get the current approval for a list of token / approval address pairs.
200
- * @param signer - The signer owning the tokens
201
- * @param tokenData - A list of token and approval address pairs
202
- */
203
- this.bulkGetTokenApproval = async (signer, tokenData) => {
204
- return bulkGetTokenApproval(signer, tokenData);
205
- };
206
- /**
207
- * Set approval for a certain token and amount.
208
- * @param { ApproveTokenRequest } request - The approval request
209
- */
210
- this.approveToken = (request) => {
211
- return approveToken(request);
212
- };
213
- /**
214
- * Revoke approval for a certain token.
215
- * @param { RevokeApprovalRequest } request - The revoke request
216
- */
217
- this.revokeTokenApproval = (request) => {
218
- return revokeTokenApproval(request);
219
- };
220
- /**
221
- * Get all the available connections for swap/bridging tokens
222
- * @param connectionRequest ConnectionsRequest
223
- * @returns ConnectionsResponse
224
- */
225
- this.getConnections = async (connectionRequest) => {
226
- const connections = await ApiService.getAvailableConnections(connectionRequest);
227
- return connections;
228
- };
229
- this.chainsService = ChainsService.getInstance();
230
- this.chainsService.getChains().then((chains) => {
231
- this.configService.updateChains(chains);
232
- });
233
- checkPackageUpdates(name, version, configUpdate.disableVersionCheck);
234
- }
235
- }
@@ -1,4 +0,0 @@
1
- import { PopulatedTransaction, Signer } from 'ethers';
2
- import { StatusManager } from '../execution/StatusManager';
3
- import { Chain, InternalExecutionSettings, LifiStep } from '../types';
4
- export declare const checkAllowance: (signer: Signer, step: LifiStep, statusManager: StatusManager, settings: InternalExecutionSettings, chain: Chain, allowUserInteraction?: boolean, shouldBatchTransactions?: boolean) => Promise<void | PopulatedTransaction>;
@@ -1,96 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- import { constants, } from 'ethers';
3
- import { getApproved, setApproval } from '../allowance/utils';
4
- import { getProvider } from '../utils/getProvider';
5
- import { parseError } from '../utils/parseError';
6
- export const checkAllowance = async (signer, step, statusManager, settings, chain, allowUserInteraction = false, shouldBatchTransactions = false) => {
7
- // Ask the user to set an allowance
8
- let allowanceProcess = statusManager.findOrCreateProcess(step, 'TOKEN_ALLOWANCE');
9
- // Check allowance
10
- try {
11
- if (allowanceProcess.txHash && allowanceProcess.status !== 'DONE') {
12
- if (allowanceProcess.status !== 'PENDING') {
13
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'PENDING');
14
- }
15
- await getProvider(signer).waitForTransaction(allowanceProcess.txHash);
16
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
17
- }
18
- else {
19
- const approvalRequest = {
20
- from: step.action.fromToken.address,
21
- to: step.estimate.approvalAddress,
22
- };
23
- if (settings.updateTransactionRequestHook) {
24
- const config = await settings.updateTransactionRequestHook(approvalRequest);
25
- approvalRequest.gasLimit = config.gasLimit;
26
- approvalRequest.gasPrice = config.gasPrice;
27
- approvalRequest.maxFeePerGas = config.maxFeePerGas;
28
- approvalRequest.maxPriorityFeePerGas = config.maxPriorityFeePerGas;
29
- }
30
- if (!approvalRequest.from) {
31
- throw new Error('Missing Signer address');
32
- }
33
- if (!approvalRequest.to) {
34
- throw new Error('Missing ERC20 contract address');
35
- }
36
- const approved = await getApproved(signer, approvalRequest.from, approvalRequest.to);
37
- if (new BigNumber(step.action.fromAmount).gt(approved)) {
38
- if (!allowUserInteraction) {
39
- return;
40
- }
41
- const approvalAmount = settings.infiniteApproval
42
- ? constants.MaxUint256.toString()
43
- : step.action.fromAmount;
44
- if (shouldBatchTransactions) {
45
- const populatedTransaction = await setApproval(signer, step.action.fromToken.address, step.estimate.approvalAddress, approvalAmount, true);
46
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
47
- return populatedTransaction;
48
- }
49
- const approveTx = (await setApproval(signer, step.action.fromToken.address, step.estimate.approvalAddress, approvalAmount));
50
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'PENDING', {
51
- txHash: approveTx.hash,
52
- txLink: chain.metamask.blockExplorerUrls[0] + 'tx/' + approveTx.hash,
53
- });
54
- // Wait for the transcation
55
- await approveTx.wait();
56
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
57
- }
58
- else {
59
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
60
- }
61
- }
62
- }
63
- catch (e) {
64
- if (e.code === 'TRANSACTION_REPLACED' && e.replacement) {
65
- await transactionReplaced(e.replacement, allowanceProcess, step, chain, statusManager);
66
- }
67
- else {
68
- const error = await parseError(e, step, allowanceProcess);
69
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'FAILED', {
70
- error: {
71
- message: error.message,
72
- htmlMessage: error.htmlMessage,
73
- code: error.code,
74
- },
75
- });
76
- statusManager.updateExecution(step, 'FAILED');
77
- throw error;
78
- }
79
- }
80
- };
81
- const transactionReplaced = async (replacementTx, allowanceProcess, step, chain, statusManager) => {
82
- try {
83
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'PENDING', {
84
- txHash: replacementTx.hash,
85
- txLink: chain.metamask.blockExplorerUrls[0] + 'tx/' + replacementTx.hash,
86
- });
87
- await replacementTx.wait();
88
- allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
89
- }
90
- catch (e) {
91
- if (e.code === 'TRANSACTION_REPLACED' && e.replacement) {
92
- await transactionReplaced(e.replacement, allowanceProcess, step, chain, statusManager);
93
- }
94
- throw e;
95
- }
96
- };
@@ -1,2 +0,0 @@
1
- export * from './checkAllowance';
2
- export * from './tokenApproval';
@@ -1,2 +0,0 @@
1
- export * from './checkAllowance';
2
- export * from './tokenApproval';