@lifi/widget 2.0.0-beta.1 → 2.0.0-beta.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 (283) hide show
  1. package/App.d.ts +4 -3
  2. package/AppDrawer.d.ts +1 -1
  3. package/AppDrawer.js +2 -1
  4. package/AppProvider.js +1 -1
  5. package/README.md +11 -12
  6. package/cjs/App.d.ts +4 -3
  7. package/cjs/AppDrawer.d.ts +1 -1
  8. package/cjs/AppDrawer.js +2 -1
  9. package/cjs/AppProvider.js +1 -1
  10. package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -2
  11. package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
  12. package/cjs/components/ChainSelect/useChainSelect.js +6 -0
  13. package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
  14. package/cjs/components/GasMessage/GasMessage.js +1 -6
  15. package/cjs/components/Header/Header.js +2 -2
  16. package/cjs/components/Header/Header.style.d.ts +10 -3
  17. package/cjs/components/Header/Header.style.js +3 -0
  18. package/cjs/components/Header/NavigationHeader.js +23 -7
  19. package/cjs/components/Header/NavigationTabs.d.ts +1 -0
  20. package/cjs/components/Header/NavigationTabs.js +26 -0
  21. package/cjs/components/Header/NavigationTabs.style.d.ts +34 -0
  22. package/cjs/components/Header/NavigationTabs.style.js +61 -0
  23. package/cjs/components/Header/WalletHeader.d.ts +1 -0
  24. package/cjs/components/Header/WalletHeader.js +16 -9
  25. package/cjs/components/Header/useHeaderActionStore.js +0 -1
  26. package/cjs/components/Insurance/Insurance.js +2 -2
  27. package/cjs/components/Insurance/InsuranceCard.js +34 -12
  28. package/cjs/components/Insurance/InsuranceCollapsed.js +9 -11
  29. package/cjs/components/Insurance/index.d.ts +1 -0
  30. package/cjs/components/Insurance/index.js +1 -0
  31. package/cjs/components/Insurance/types.d.ts +12 -9
  32. package/cjs/components/NFT/NFT.js +2 -2
  33. package/cjs/components/NFT/types.d.ts +1 -1
  34. package/cjs/components/PoweredBy/PoweredBy.js +2 -3
  35. package/cjs/components/SelectChainAndToken.js +8 -7
  36. package/cjs/components/SelectTokenButton/SelectTokenButton.js +6 -3
  37. package/cjs/components/SendToWallet/SendToWallet.js +2 -2
  38. package/cjs/components/SmallAvatar.d.ts +1 -1
  39. package/cjs/components/Step/CircularProgress.d.ts +1 -2
  40. package/cjs/components/Step/Step.js +15 -5
  41. package/cjs/components/Step/StepList.d.ts +1 -2
  42. package/cjs/components/StepActions/StepActions.js +4 -20
  43. package/cjs/components/SwapButton/SwapButton.js +16 -4
  44. package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
  45. package/cjs/components/SwapInput/SwapInput.js +2 -2
  46. package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
  47. package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -2
  48. package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -3
  49. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  50. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  51. package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
  52. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
  53. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  54. package/cjs/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
  55. package/cjs/components/Token/Token.js +1 -1
  56. package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  57. package/cjs/components/TokenList/TokenList.js +9 -4
  58. package/cjs/components/TokenList/TokenList.style.d.ts +5 -2
  59. package/cjs/components/TokenList/TokenList.style.js +20 -1
  60. package/cjs/components/TokenList/TokenListItem.d.ts +1 -1
  61. package/cjs/components/TokenList/TokenListItem.js +28 -5
  62. package/cjs/components/TokenList/VirtualizedTokenList.js +3 -3
  63. package/cjs/components/TokenList/types.d.ts +6 -3
  64. package/cjs/config/theme.js +15 -3
  65. package/cjs/config/version.d.ts +1 -1
  66. package/cjs/config/version.js +1 -1
  67. package/cjs/hooks/index.d.ts +2 -1
  68. package/cjs/hooks/index.js +2 -1
  69. package/cjs/hooks/useContentHeight.js +3 -5
  70. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  71. package/cjs/hooks/useFundsSufficiency.js +2 -2
  72. package/cjs/hooks/useGasRefuel.d.ts +1 -1
  73. package/cjs/hooks/useGasRefuel.js +5 -15
  74. package/cjs/hooks/useGasSufficiency.js +12 -3
  75. package/cjs/hooks/useInitializer.js +0 -1
  76. package/cjs/hooks/useProcessMessage.d.ts +2 -1
  77. package/cjs/hooks/useProcessMessage.js +27 -9
  78. package/cjs/hooks/useRouteExecution.js +6 -5
  79. package/cjs/hooks/useSwapOnly.d.ts +1 -0
  80. package/cjs/hooks/useSwapOnly.js +9 -0
  81. package/cjs/hooks/useSwapRoutes.d.ts +1 -2
  82. package/cjs/hooks/useSwapRoutes.js +32 -18
  83. package/cjs/hooks/useToken.d.ts +1 -1
  84. package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
  85. package/cjs/hooks/useTokenBalance.js +6 -7
  86. package/cjs/hooks/useTokenBalances.d.ts +5 -5
  87. package/cjs/hooks/useTokenBalances.js +4 -19
  88. package/cjs/hooks/useTokenSearch.d.ts +2 -2
  89. package/cjs/hooks/useTokens.d.ts +2 -2
  90. package/cjs/i18n/bn.json +8 -0
  91. package/cjs/i18n/en.json +30 -5
  92. package/cjs/i18n/fr.json +8 -0
  93. package/cjs/i18n/id.json +22 -7
  94. package/cjs/i18n/ko.json +22 -7
  95. package/cjs/i18n/pt.json +32 -7
  96. package/cjs/i18n/th.json +21 -6
  97. package/cjs/i18n/uk.json +43 -18
  98. package/cjs/i18n/zh.json +23 -8
  99. package/cjs/icons/InsuraceLogo.d.ts +1 -1
  100. package/cjs/icons/LiFiFullLogo.d.ts +1 -1
  101. package/cjs/icons/LiFiLogo.d.ts +1 -1
  102. package/cjs/icons/LiFiToolLogo.d.ts +1 -1
  103. package/cjs/index.d.ts +1 -1
  104. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
  105. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
  106. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
  107. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
  108. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
  109. package/cjs/pages/SettingsPage/LanguageSelect.js +1 -1
  110. package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -2
  111. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  112. package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -2
  113. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
  114. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
  115. package/cjs/pages/SwapPage/StatusBottomSheet.js +15 -9
  116. package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  117. package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
  118. package/cjs/pages/SwapPage/SwapPage.js +31 -10
  119. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +7 -12
  120. package/cjs/pages/SwapPage/utils.d.ts +2 -0
  121. package/cjs/pages/SwapPage/utils.js +10 -0
  122. package/cjs/providers/I18nProvider/I18nProvider.js +3 -3
  123. package/cjs/providers/SDKProvider/SDKProvider.js +2 -0
  124. package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
  125. package/cjs/providers/WalletProvider/WalletProvider.js +77 -49
  126. package/cjs/providers/WalletProvider/types.d.ts +3 -5
  127. package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -1
  128. package/cjs/stores/StoreProvider.d.ts +2 -2
  129. package/cjs/stores/StoreProvider.js +3 -2
  130. package/cjs/stores/routes/RouteExecutionStore.d.ts +1 -1
  131. package/cjs/stores/routes/RouteExecutionStore.js +0 -1
  132. package/cjs/stores/settings/index.d.ts +1 -0
  133. package/cjs/stores/settings/index.js +1 -0
  134. package/cjs/stores/settings/types.d.ts +11 -0
  135. package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  136. package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
  137. package/cjs/types/events.d.ts +9 -1
  138. package/cjs/types/events.js +1 -0
  139. package/cjs/types/token.d.ts +2 -2
  140. package/cjs/types/widget.d.ts +13 -8
  141. package/cjs/types/widget.js +4 -2
  142. package/cjs/utils/format.d.ts +1 -1
  143. package/cjs/utils/format.js +7 -12
  144. package/cjs/utils/wallet.d.ts +1 -1
  145. package/cjs/utils/wallet.js +3 -3
  146. package/components/ChainSelect/ChainSelect.d.ts +1 -2
  147. package/components/ChainSelect/ChainSelect.style.js +1 -1
  148. package/components/ChainSelect/useChainSelect.js +7 -1
  149. package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
  150. package/components/GasMessage/GasMessage.js +2 -7
  151. package/components/Header/Header.js +3 -3
  152. package/components/Header/Header.style.d.ts +10 -3
  153. package/components/Header/Header.style.js +3 -0
  154. package/components/Header/NavigationHeader.js +23 -7
  155. package/components/Header/NavigationTabs.d.ts +1 -0
  156. package/components/Header/NavigationTabs.js +22 -0
  157. package/components/Header/NavigationTabs.style.d.ts +34 -0
  158. package/components/Header/NavigationTabs.style.js +58 -0
  159. package/components/Header/WalletHeader.d.ts +1 -0
  160. package/components/Header/WalletHeader.js +14 -8
  161. package/components/Header/useHeaderActionStore.js +0 -1
  162. package/components/Insurance/Insurance.js +2 -2
  163. package/components/Insurance/InsuranceCard.js +37 -15
  164. package/components/Insurance/InsuranceCollapsed.js +9 -11
  165. package/components/Insurance/index.d.ts +1 -0
  166. package/components/Insurance/index.js +1 -0
  167. package/components/Insurance/types.d.ts +12 -9
  168. package/components/NFT/NFT.js +2 -2
  169. package/components/NFT/types.d.ts +1 -1
  170. package/components/PoweredBy/PoweredBy.js +2 -3
  171. package/components/SelectChainAndToken.js +9 -8
  172. package/components/SelectTokenButton/SelectTokenButton.js +7 -4
  173. package/components/SendToWallet/SendToWallet.js +2 -2
  174. package/components/SmallAvatar.d.ts +1 -1
  175. package/components/Step/CircularProgress.d.ts +1 -2
  176. package/components/Step/Step.js +16 -6
  177. package/components/Step/StepList.d.ts +1 -2
  178. package/components/StepActions/StepActions.js +4 -20
  179. package/components/SwapButton/SwapButton.js +16 -4
  180. package/components/SwapInput/FormPriceHelperText.js +2 -2
  181. package/components/SwapInput/SwapInput.js +3 -3
  182. package/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
  183. package/components/SwapInput/SwapInputEndAdornment.js +2 -2
  184. package/components/SwapRouteCard/SwapRouteCard.js +21 -5
  185. package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  186. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  187. package/components/SwapRoutes/SwapRoutes.js +1 -1
  188. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
  189. package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  190. package/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
  191. package/components/Token/Token.js +1 -1
  192. package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  193. package/components/TokenList/TokenList.js +10 -5
  194. package/components/TokenList/TokenList.style.d.ts +5 -2
  195. package/components/TokenList/TokenList.style.js +21 -2
  196. package/components/TokenList/TokenListItem.d.ts +1 -1
  197. package/components/TokenList/TokenListItem.js +32 -9
  198. package/components/TokenList/VirtualizedTokenList.js +3 -3
  199. package/components/TokenList/types.d.ts +6 -3
  200. package/config/theme.js +15 -3
  201. package/config/version.d.ts +1 -1
  202. package/config/version.js +1 -1
  203. package/hooks/index.d.ts +2 -1
  204. package/hooks/index.js +2 -1
  205. package/hooks/useContentHeight.js +4 -6
  206. package/hooks/useFeaturedTokens.d.ts +1 -1
  207. package/hooks/useFundsSufficiency.js +2 -2
  208. package/hooks/useGasRefuel.d.ts +1 -1
  209. package/hooks/useGasRefuel.js +5 -15
  210. package/hooks/useGasSufficiency.js +13 -4
  211. package/hooks/useInitializer.js +0 -1
  212. package/hooks/useProcessMessage.d.ts +2 -1
  213. package/hooks/useProcessMessage.js +27 -9
  214. package/hooks/useRouteExecution.js +6 -5
  215. package/hooks/useSwapOnly.d.ts +1 -0
  216. package/hooks/useSwapOnly.js +5 -0
  217. package/hooks/useSwapRoutes.d.ts +1 -2
  218. package/hooks/useSwapRoutes.js +32 -18
  219. package/hooks/useToken.d.ts +1 -1
  220. package/hooks/useTokenAddressBalance.d.ts +2 -2
  221. package/hooks/useTokenBalance.js +6 -7
  222. package/hooks/useTokenBalances.d.ts +5 -5
  223. package/hooks/useTokenBalances.js +4 -19
  224. package/hooks/useTokenSearch.d.ts +2 -2
  225. package/hooks/useTokens.d.ts +2 -2
  226. package/i18n/bn.json +8 -0
  227. package/i18n/en.json +30 -5
  228. package/i18n/fr.json +8 -0
  229. package/i18n/id.json +22 -7
  230. package/i18n/ko.json +22 -7
  231. package/i18n/pt.json +32 -7
  232. package/i18n/th.json +21 -6
  233. package/i18n/uk.json +43 -18
  234. package/i18n/zh.json +23 -8
  235. package/icons/InsuraceLogo.d.ts +1 -1
  236. package/icons/LiFiFullLogo.d.ts +1 -1
  237. package/icons/LiFiLogo.d.ts +1 -1
  238. package/icons/LiFiToolLogo.d.ts +1 -1
  239. package/index.d.ts +1 -1
  240. package/package.json +13 -13
  241. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
  242. package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
  243. package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
  244. package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
  245. package/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
  246. package/pages/SettingsPage/LanguageSelect.js +1 -1
  247. package/pages/SettingsPage/SettingsPage.d.ts +1 -2
  248. package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  249. package/pages/SettingsPage/SlippageInput.d.ts +1 -2
  250. package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
  251. package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
  252. package/pages/SwapPage/StatusBottomSheet.js +18 -12
  253. package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  254. package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
  255. package/pages/SwapPage/SwapPage.js +33 -12
  256. package/pages/SwapPage/TokenValueBottomSheet.js +8 -13
  257. package/pages/SwapPage/utils.d.ts +2 -0
  258. package/pages/SwapPage/utils.js +6 -0
  259. package/providers/I18nProvider/I18nProvider.js +3 -3
  260. package/providers/SDKProvider/SDKProvider.js +2 -0
  261. package/providers/SwapFormProvider/FormUpdater.js +3 -0
  262. package/providers/WalletProvider/WalletProvider.js +78 -50
  263. package/providers/WalletProvider/types.d.ts +3 -5
  264. package/providers/WidgetProvider/WidgetProvider.js +2 -2
  265. package/stores/StoreProvider.d.ts +2 -2
  266. package/stores/StoreProvider.js +3 -2
  267. package/stores/routes/RouteExecutionStore.d.ts +1 -1
  268. package/stores/routes/RouteExecutionStore.js +0 -1
  269. package/stores/settings/index.d.ts +1 -0
  270. package/stores/settings/index.js +1 -0
  271. package/stores/settings/types.d.ts +11 -0
  272. package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  273. package/stores/settings/useSplitSubvariantStore.js +37 -0
  274. package/tsconfig.cjs.tsbuildinfo +1 -1
  275. package/types/events.d.ts +9 -1
  276. package/types/events.js +1 -0
  277. package/types/token.d.ts +2 -2
  278. package/types/widget.d.ts +13 -8
  279. package/types/widget.js +4 -2
  280. package/utils/format.d.ts +1 -1
  281. package/utils/format.js +5 -10
  282. package/utils/wallet.d.ts +1 -1
  283. package/utils/wallet.js +1 -1
package/cjs/i18n/zh.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "done": "已完成",
13
13
  "getGas": "开始兑换燃气费",
14
14
  "hide": "隐藏",
15
+ "learnMore": "了解更多",
15
16
  "lifiSwap": "LI.FI兑换",
16
17
  "light": "浅色主题",
17
18
  "max": "最大",
@@ -29,6 +30,7 @@
29
30
  "startSwap": "开始兑换",
30
31
  "swap": "兑换",
31
32
  "tryAgain": "重试",
33
+ "viewCoverage": "查看我们的覆盖范围",
32
34
  "viewOnExplorer": "在区块链浏览器上查看"
33
35
  },
34
36
  "format": {
@@ -104,14 +106,22 @@
104
106
  "gasFeeEstimated": "预估燃气费",
105
107
  "gasFeePaid": "已支付燃气费",
106
108
  "inProgress": "进行中",
109
+ "insurance": {
110
+ "bridgeExploits": "跨链桥故障、被黑或者被利用漏洞",
111
+ "insure": "为跨链代币提供100%的保障",
112
+ "insured": "您已经对100%的跨链代币投保:",
113
+ "slippageError": "目标链代币的滑点错误"
114
+ },
107
115
  "info": {
108
116
  "message": {
117
+ "autoRefuel": "您在 {{chainName}} 链上的燃气费很低。如果启用该选项,您将获得足够的燃气费完成此次兑换。",
109
118
  "emptyActiveSwaps": "正在进行的兑换将在这里显示。一旦完成,你可在兑换记录中找到它们。",
110
119
  "emptySwapHistory": "兑换记录只存储在本地,如果你清除浏览器数据,他们将被删除。",
111
120
  "emptyTokenList": "我们无法在 {{chainName}} 链上找到这些代币,或者你的钱包内没有这些代币。请再次搜索或者选择其他链再试一次。",
112
121
  "routeNotFound": "试试另一个代币组合。"
113
122
  },
114
123
  "title": {
124
+ "autoRefuel": "获得燃气费",
115
125
  "emptyActiveSwaps": "没有正在进行的兑换",
116
126
  "emptySwapHistory": "没有兑换记录",
117
127
  "routeNotFound": "没有可用的路由"
@@ -154,6 +164,7 @@
154
164
  "quotedAmount": "报价金额",
155
165
  "rateChange": "波动率",
156
166
  "receiving": "接收",
167
+ "refuelStepDetails": "通过 {{tool}} 获取燃气费",
157
168
  "routes": "你会收到",
158
169
  "selectChain": "网络",
159
170
  "selectChainAndToken": "选择链和代币",
@@ -162,6 +173,7 @@
162
173
  "sendToWallet": "发送到另外的钱包",
163
174
  "sentToAddress": "发送到{{address}}",
164
175
  "stepBridge": "跨链",
176
+ "stepDetails": "通过 LI.FI {{tool}}",
165
177
  "stepSwap": "兑换",
166
178
  "stepSwapAndBridge": "兑换和跨链",
167
179
  "success": {
@@ -180,11 +192,13 @@
180
192
  "swapStepDetails": "通过{{tool}}在{{chain}}链上兑换代币",
181
193
  "swapping": "兑换中",
182
194
  "tags": {
183
- "ALTERNATIVE": "可用",
184
- "CHEAPEST": "便宜",
185
- "FASTEST": "快捷",
186
- "RECOMMENDED": "推荐",
187
- "SAFEST": "安全"
195
+ "cheapest": "便宜的",
196
+ "fastest": "快速的",
197
+ "insurable": "可保性",
198
+ "insurance": "保险",
199
+ "insured": "受保的",
200
+ "recommended": "建议的",
201
+ "safest": "最佳/安全"
188
202
  },
189
203
  "to": "到",
190
204
  "tokenOnChain": "{{chainName}}链上的{{tokenSymbol}}",
@@ -197,8 +211,8 @@
197
211
  "deleteActiveSwaps": "正在进行的兑换记录只存储在本地,如果删除它们,我们将无法恢复这些记录。",
198
212
  "deleteSwapHistory": "兑换记录只存储在本地,如果你删除它,我们将无法恢复这些记录。",
199
213
  "highValueLoss": "收到的代币的价值明显低于要被兑换的代币和交易成本。",
200
- "insufficientFunds": "你没有足够的资金来执行这笔兑换。",
201
- "insufficientGas": "你至少需要:",
214
+ "insufficientFunds": "你没有足够的资金来完成这笔交易。",
215
+ "insufficientGas": "您没有足够的燃气费来完成此次交易。您至少需要添加:",
202
216
  "rateChanged": "兑换比例已经改变,如果继续兑换,您将接受新的兑换比例。",
203
217
  "resetSettings": "这将重置您的路由优先级,滑点,燃气费,选中的跨链桥和链上交易所。"
204
218
  },
@@ -207,13 +221,14 @@
207
221
  "deleteSwap": "确定要删除这个兑换记录?",
208
222
  "deleteSwapHistory": "确定要清空兑换记录?",
209
223
  "highValueLoss": "大额资金损失",
210
- "insufficientGas": "燃料费不足",
224
+ "insufficientGas": "燃气费不足",
211
225
  "rateChanged": "兑换比例变动",
212
226
  "resetSettings": "确定要恢复默认设置吗?"
213
227
  }
214
228
  }
215
229
  },
216
230
  "tooltip": {
231
+ "additionalProviderFee": "跨链和交易所的手续费。",
217
232
  "estimatedNetworkFee": "预估网络手续费。",
218
233
  "estimatedTime": "预计兑换的执行时间(分钟)。",
219
234
  "notFound": {
@@ -1,2 +1,2 @@
1
1
  import type { SVGProps } from 'react';
2
- export declare const InsuraceLogo: (props: SVGProps<SVGSVGElement>) => JSX.Element;
2
+ export declare const InsuraceLogo: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import type { SVGProps } from 'react';
2
- export declare const LiFiFullLogo: (props: SVGProps<SVGSVGElement>) => JSX.Element;
2
+ export declare const LiFiFullLogo: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import type { SVGProps } from 'react';
2
- export declare const LiFiLogo: (props: SVGProps<SVGSVGElement>) => JSX.Element;
2
+ export declare const LiFiLogo: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import type { SVGProps } from 'react';
2
- export declare const LiFiToolLogo: (props: SVGProps<SVGSVGElement>) => JSX.Element;
2
+ export declare const LiFiToolLogo: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
package/cjs/index.d.ts CHANGED
@@ -6,4 +6,4 @@ export * from './config/version';
6
6
  export { useWidgetEvents, widgetEvents } from './hooks';
7
7
  export { useWallet } from './providers/WalletProvider';
8
8
  export * from './types';
9
- export declare const LiFiWidget: import("react").FC<import("./types").WidgetProps>;
9
+ export declare const LiFiWidget: import("react").ForwardRefExoticComponent<import("./types").WidgetDrawerProps & import("./types").WidgetConfig & import("./types").WidgetConfigPartialProps & import("react").RefAttributes<import("./AppDrawer").WidgetDrawer>>;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const ActiveSwapsPage: () => JSX.Element;
1
+ export declare const ActiveSwapsPage: () => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const SearchTokenInput: () => JSX.Element;
1
+ export declare const SearchTokenInput: () => import("react/jsx-runtime").JSX.Element;
@@ -15,9 +15,11 @@ const SelectTokenPage = ({ formType }) => {
15
15
  const headerRef = (0, react_1.useRef)(null);
16
16
  const contentHeight = (0, hooks_1.useContentHeight)();
17
17
  const [tokenListHeight, setTokenListHeight] = (0, react_1.useState)(0);
18
+ const swapOnly = (0, hooks_1.useSwapOnly)();
18
19
  (0, react_1.useLayoutEffect)(() => {
19
20
  setTokenListHeight(Math.max(contentHeight - (headerRef.current?.offsetHeight ?? 0), minTokenListHeight));
20
21
  }, [contentHeight]);
21
- return ((0, jsx_runtime_1.jsxs)(material_1.Container, { disableGutters: true, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { pt: 1, pb: 2, px: 3, ref: headerRef, children: [(0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) })] }), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: tokenListHeight, onClick: navigateBack, formType: formType })] }));
22
+ const hideChainSelect = swapOnly && formType === 'to';
23
+ return ((0, jsx_runtime_1.jsxs)(material_1.Container, { disableGutters: true, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { pt: 1, pb: 2, px: 3, ref: headerRef, children: [!hideChainSelect ? (0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }) : null, (0, jsx_runtime_1.jsx)(material_1.Box, { mt: !hideChainSelect ? 2 : 0, children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) })] }), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: tokenListHeight, onClick: navigateBack, formType: formType })] }));
22
24
  };
23
25
  exports.SelectTokenPage = SelectTokenPage;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const SelectWalletPage: () => JSX.Element;
1
+ export declare const SelectWalletPage: () => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const GasPriceSelect: () => JSX.Element;
1
+ export declare const GasPriceSelect: () => import("react/jsx-runtime").JSX.Element;
@@ -27,7 +27,7 @@ const LanguageSelect = () => {
27
27
  if (filteredLanguages.length <= 1) {
28
28
  return null;
29
29
  }
30
- const value = filteredLanguages.includes(language || i18n.resolvedLanguage)
30
+ const value = filteredLanguages.includes(language || i18n.resolvedLanguage || '')
31
31
  ? language || i18n.resolvedLanguage
32
32
  : languages?.default || languages?.allow?.[0];
33
33
  return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { mb: 2, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`language.title`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { fullWidth: true, children: (0, jsx_runtime_1.jsx)(Select_1.Select, { MenuProps: { elevation: 2 }, value: value, onChange: handleChangeLanguage, IconComponent: KeyboardArrowDown_1.default, dense: true, children: filteredLanguages.map((lng) => {
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const SettingsPage: () => JSX.Element;
1
+ export declare const SettingsPage: () => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const ShowDestinationWallet: () => JSX.Element | null;
1
+ export declare const ShowDestinationWallet: () => import("react/jsx-runtime").JSX.Element | null;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const SlippageInput: () => JSX.Element;
1
+ export declare const SlippageInput: () => import("react/jsx-runtime").JSX.Element;
@@ -10,16 +10,20 @@ const react_i18next_1 = require("react-i18next");
10
10
  const react_router_dom_1 = require("react-router-dom");
11
11
  const shallow_1 = require("zustand/shallow");
12
12
  const Card_1 = require("../../components/Card");
13
+ const ContractComponent_1 = require("../../components/ContractComponent");
13
14
  const Dialog_1 = require("../../components/Dialog");
14
15
  const Header_1 = require("../../components/Header");
15
16
  const Insurance_1 = require("../../components/Insurance");
16
17
  const Step_1 = require("../../components/Step");
17
18
  const hooks_1 = require("../../hooks");
19
+ const providers_1 = require("../../providers");
18
20
  const stores_1 = require("../../stores");
21
+ const utils_1 = require("../../utils");
19
22
  const SwapDetailsPage_style_1 = require("./SwapDetailsPage.style");
20
23
  const SwapDetailsPage = () => {
21
24
  const { t, i18n } = (0, react_i18next_1.useTranslation)();
22
25
  const { navigateBack } = (0, hooks_1.useNavigateBack)();
26
+ const { variant } = (0, providers_1.useWidgetConfig)();
23
27
  const { state } = (0, react_router_dom_1.useLocation)();
24
28
  const [routeExecution, deleteRoute] = (0, stores_1.useRouteExecutionStore)((store) => [store.routes[state?.routeId], store.deleteRoute], shallow_1.shallow);
25
29
  const [open, setOpen] = (0, react_1.useState)(false);
@@ -53,9 +57,9 @@ const SwapDetailsPage = () => {
53
57
  justifyContent: 'space-between',
54
58
  }, pb: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }).format(startedAt) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: new Intl.DateTimeFormat(i18n.language, {
55
59
  timeStyle: 'short',
56
- }).format(startedAt) })] }), (0, Step_1.getStepList)(routeExecution?.route), routeExecution?.route?.insurance?.state === 'INSURED' ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: routeExecution.status, feeAmountUsd: routeExecution.route.insurance.feeAmountUsd, insurableRouteId: routeExecution.route.id, insuranceCoverageId: insuranceCoverageId })) : null, (0, jsx_runtime_1.jsxs)(Card_1.Card, { mt: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
60
+ }).format(startedAt) })] }), (0, Step_1.getStepList)(routeExecution?.route), variant === 'nft' ? (0, jsx_runtime_1.jsx)(ContractComponent_1.ContractComponent, { mt: 2 }) : null, routeExecution?.route?.insurance?.state === 'INSURED' ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: routeExecution.status, feeAmountUsd: routeExecution.route.insurance.feeAmountUsd, insuredAmount: (0, utils_1.formatTokenAmount)(routeExecution.route.toAmountMin, routeExecution.route.toToken.decimals), insuredTokenSymbol: routeExecution.route.toToken.symbol, insurableRouteId: routeExecution.route.id, insuranceCoverageId: insuranceCoverageId })) : null, (0, jsx_runtime_1.jsxs)(Card_1.Card, { mt: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
57
61
  display: 'flex',
58
62
  flex: 1,
59
- }, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { flex: 1, children: t('swap.supportId') }), (0, jsx_runtime_1.jsx)(material_1.Box, { mr: 1, mt: 1, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", onClick: copySupportId, children: (0, jsx_runtime_1.jsx)(ContentCopyRounded_1.default, { fontSize: "small" }) }) })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' }, children: supportId })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsx)(material_1.Button, { href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true, children: t('button.contactSupport') }) }), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, { open: open, onClose: toggleDialog, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteSwap') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: toggleDialog, children: t('button.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: handleDeleteRoute, autoFocus: true, children: t('button.delete') })] })] })] }));
63
+ }, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { flex: 1, children: t('swap.supportId') }), (0, jsx_runtime_1.jsx)(material_1.Box, { mr: 1, mt: 1, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", onClick: copySupportId, children: (0, jsx_runtime_1.jsx)(ContentCopyRounded_1.default, { fontSize: "small" }) }) })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' }, children: supportId })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsx)(material_1.Button, { href: "https://discord.gg/lifi", target: "_blank", rel: "nofollow noreferrer", fullWidth: true, children: t('button.contactSupport') }) }), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, { open: open, onClose: toggleDialog, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteSwap') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: toggleDialog, children: t('button.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: handleDeleteRoute, autoFocus: true, children: t('button.delete') })] })] })] }));
60
64
  };
61
65
  exports.SwapDetailsPage = SwapDetailsPage;
@@ -47,7 +47,7 @@ const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
47
47
  const { t } = (0, react_i18next_1.useTranslation)();
48
48
  const ref = (0, react_1.useRef)();
49
49
  (0, hooks_1.useSetContentHeight)(ref);
50
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { p: 3, ref: ref, children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.IconCircle, { status: "warning", mb: 1, children: (0, jsx_runtime_1.jsx)(WarningRounded_1.default, { color: "warning" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, fontSize: 18, fontWeight: 700, children: t('swap.warning.title.rateChanged') })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: t('swap.warning.message.rateChanged') }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.quotedAmount') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { fontWeight: 600, children: [t('format.number', {
50
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { p: 3, ref: ref, children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.CenterContainer, { children: [(0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.IconCircle, { status: "warning", mb: 1, children: (0, jsx_runtime_1.jsx)(WarningRounded_1.default, { color: "warning" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, fontSize: 18, fontWeight: 700, children: t('swap.warning.title.rateChanged') })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: t('swap.warning.message.rateChanged') }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.quotedAmount') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { fontWeight: 600, children: [t('format.number', {
51
51
  value: (0, utils_1.formatTokenAmount)(data?.oldToAmount, data?.toToken.decimals, 5),
52
52
  }), ' ', data?.toToken.symbol] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.currentAmount') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { fontWeight: 600, children: [t('format.number', {
53
53
  value: (0, utils_1.formatTokenAmount)(data?.newToAmount, data?.toToken.decimals, 5),
@@ -23,6 +23,7 @@ const StatusBottomSheet = ({ status, route, }) => {
23
23
  const ref = (0, react_1.useRef)(null);
24
24
  const { getChainById } = (0, hooks_1.useChains)();
25
25
  const { setValue } = (0, react_hook_form_1.useFormContext)();
26
+ const { variant, contractComponent, contractCompactComponent } = (0, providers_1.useWidgetConfig)();
26
27
  const toToken = {
27
28
  ...(route.steps.at(-1)?.execution?.toToken ?? route.toToken),
28
29
  amount: route.steps.at(-1)?.execution?.toAmount ??
@@ -33,6 +34,7 @@ const StatusBottomSheet = ({ status, route, }) => {
33
34
  const clearFromAmount = () => {
34
35
  refetchAllBalances();
35
36
  setValue(providers_1.SwapFormKey.FromAmount, '');
37
+ setValue(providers_1.SwapFormKey.ToAmount, '');
36
38
  };
37
39
  const handleDone = () => {
38
40
  clearFromAmount();
@@ -71,13 +73,16 @@ const StatusBottomSheet = ({ status, route, }) => {
71
73
  let handlePrimaryButton = handleDone;
72
74
  switch (status) {
73
75
  case stores_1.RouteExecutionStatus.Done: {
74
- title = t('swap.success.title.swapSuccessful');
76
+ title =
77
+ variant === 'nft'
78
+ ? t('swap.success.title.purchaseSuccessful')
79
+ : t('swap.success.title.swapSuccessful');
75
80
  if (token) {
76
81
  primaryMessage = t('swap.success.message.swapSuccessful', {
77
- amount: token.amount,
82
+ amount: (0, utils_1.formatTokenAmount)(token.amount),
78
83
  tokenSymbol: token.symbol,
79
84
  chainName: getChainById(token.chainId)?.name,
80
- walletAddress: (0, utils_1.shortenWalletAddress)(route.toAddress),
85
+ walletAddress: (0, utils_1.shortenAddress)(route.toAddress),
81
86
  });
82
87
  }
83
88
  handlePrimaryButton = handleDone;
@@ -91,10 +96,10 @@ const StatusBottomSheet = ({ status, route, }) => {
91
96
  });
92
97
  if (token) {
93
98
  secondaryMessage = t('swap.success.message.swapSuccessful', {
94
- amount: token.amount,
99
+ amount: (0, utils_1.formatTokenAmount)(token.amount),
95
100
  tokenSymbol: token.symbol,
96
101
  chainName: getChainById(token.chainId)?.name,
97
- walletAddress: (0, utils_1.shortenWalletAddress)(route.toAddress),
102
+ walletAddress: (0, utils_1.shortenAddress)(route.toAddress),
98
103
  });
99
104
  }
100
105
  handlePrimaryButton = handlePartialDone;
@@ -108,10 +113,10 @@ const StatusBottomSheet = ({ status, route, }) => {
108
113
  });
109
114
  if (token) {
110
115
  secondaryMessage = t('swap.success.message.swapSuccessful', {
111
- amount: token.amount,
116
+ amount: (0, utils_1.formatTokenAmount)(token.amount),
112
117
  tokenSymbol: token.symbol,
113
118
  chainName: getChainById(token.chainId)?.name,
114
- walletAddress: (0, utils_1.shortenWalletAddress)(route.toAddress),
119
+ walletAddress: (0, utils_1.shortenAddress)(route.toAddress),
115
120
  });
116
121
  }
117
122
  break;
@@ -142,8 +147,9 @@ const StatusBottomSheet = ({ status, route, }) => {
142
147
  ref.current?.open();
143
148
  }
144
149
  }, [refetch, refetchNewBalance, status]);
145
- return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, { ref: ref, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { p: 3, children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, { status: status, mb: 1, children: [status === stores_1.RouteExecutionStatus.Idle ? ((0, jsx_runtime_1.jsx)(InfoRounded_1.default, { color: "primary" })) : null, status === stores_1.RouteExecutionStatus.Done ? ((0, jsx_runtime_1.jsx)(Done_1.default, { color: "success" })) : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Partial) ||
146
- (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Refunded) ? ((0, jsx_runtime_1.jsx)(WarningRounded_1.default, { color: "warning" })) : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Failed) ? ((0, jsx_runtime_1.jsx)(ErrorRounded_1.default, { color: "error" })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, fontSize: 18, fontWeight: 700, children: title }), (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done) ? ((0, jsx_runtime_1.jsx)(Token_1.Token, { token: toToken, py: 1, disableDescription: true })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: primaryMessage }), secondaryMessage ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: secondaryMessage })) : null, (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsxs)(material_1.Button, { variant: "contained", fullWidth: true, onClick: handlePrimaryButton, children: [status === stores_1.RouteExecutionStatus.Idle ? t('button.ok') : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done)
150
+ const showContractComponent = variant === 'nft' && (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done);
151
+ return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, { ref: ref, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { p: 3, children: [!showContractComponent ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.CenterContainer, { children: (0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, { status: status, mb: 1, children: [status === stores_1.RouteExecutionStatus.Idle ? ((0, jsx_runtime_1.jsx)(InfoRounded_1.default, { color: "primary" })) : null, status === stores_1.RouteExecutionStatus.Done ? ((0, jsx_runtime_1.jsx)(Done_1.default, { color: "success" })) : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Partial) ||
152
+ (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Refunded) ? ((0, jsx_runtime_1.jsx)(WarningRounded_1.default, { color: "warning" })) : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Failed) ? ((0, jsx_runtime_1.jsx)(ErrorRounded_1.default, { color: "error" })) : null] }) })) : null, (0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.CenterContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, fontSize: 18, fontWeight: 700, children: title }) }), showContractComponent ? (contractCompactComponent || contractComponent) : ((0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.CenterContainer, { children: (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done) ? ((0, jsx_runtime_1.jsx)(Token_1.Token, { token: toToken, py: 1, disableDescription: true })) : null })), !showContractComponent ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: primaryMessage })) : null, secondaryMessage ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: secondaryMessage })) : null, (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsxs)(material_1.Button, { variant: "contained", fullWidth: true, onClick: handlePrimaryButton, children: [status === stores_1.RouteExecutionStatus.Idle ? t('button.ok') : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done)
147
153
  ? t('button.done')
148
154
  : null, status === stores_1.RouteExecutionStatus.Failed
149
155
  ? t('button.seeDetails')
@@ -2,7 +2,7 @@
2
2
  import type { Theme } from '@mui/material';
3
3
  import { RouteExecutionStatus } from '../../stores';
4
4
  type StatusColor = RouteExecutionStatus | 'warning';
5
- export declare const IconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
5
+ export declare const CenterContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
6
6
  children?: import("react").ReactNode;
7
7
  component?: import("react").ElementType<any> | undefined;
8
8
  ref?: import("react").Ref<unknown> | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IconCircle = exports.IconContainer = void 0;
3
+ exports.IconCircle = exports.CenterContainer = void 0;
4
4
  const material_1 = require("@mui/material");
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const stores_1 = require("../../stores");
@@ -18,7 +18,7 @@ const getStatusColor = (status, theme) => {
18
18
  return { color: theme.palette.primary.main, alpha: 0.12, darken: 0 };
19
19
  }
20
20
  };
21
- exports.IconContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
21
+ exports.CenterContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
22
22
  display: 'grid',
23
23
  placeItems: 'center',
24
24
  position: 'relative',
@@ -8,20 +8,25 @@ const react_1 = require("react");
8
8
  const react_hook_form_1 = require("react-hook-form");
9
9
  const react_i18next_1 = require("react-i18next");
10
10
  const react_router_dom_1 = require("react-router-dom");
11
+ const ContractComponent_1 = require("../../components/ContractComponent");
11
12
  const GasMessage_1 = require("../../components/GasMessage");
12
13
  const Insurance_1 = require("../../components/Insurance");
13
14
  const Step_1 = require("../../components/Step");
14
15
  const hooks_1 = require("../../hooks");
15
16
  const providers_1 = require("../../providers");
16
17
  const stores_1 = require("../../stores");
18
+ const events_1 = require("../../types/events");
19
+ const utils_1 = require("../../utils");
17
20
  const ExchangeRateBottomSheet_1 = require("./ExchangeRateBottomSheet");
18
21
  const StartSwapButton_1 = require("./StartSwapButton");
19
22
  const StatusBottomSheet_1 = require("./StatusBottomSheet");
20
23
  const SwapPage_style_1 = require("./SwapPage.style");
21
24
  const TokenValueBottomSheet_1 = require("./TokenValueBottomSheet");
25
+ const utils_2 = require("./utils");
22
26
  const SwapPage = () => {
23
27
  const { t } = (0, react_i18next_1.useTranslation)();
24
28
  const { setValue } = (0, react_hook_form_1.useFormContext)();
29
+ const emitter = (0, hooks_1.useWidgetEvents)();
25
30
  const { navigateBack } = (0, hooks_1.useNavigateBack)();
26
31
  const { variant, insurance } = (0, providers_1.useWidgetConfig)();
27
32
  const { state } = (0, react_router_dom_1.useLocation)();
@@ -29,21 +34,32 @@ const SwapPage = () => {
29
34
  const [routeId, setRouteId] = (0, react_1.useState)(stateRouteId);
30
35
  const tokenValueBottomSheetRef = (0, react_1.useRef)(null);
31
36
  const exchangeRateBottomSheetRef = (0, react_1.useRef)(null);
37
+ const onAcceptExchangeRateUpdate = (resolver, data) => {
38
+ exchangeRateBottomSheetRef.current?.open(resolver, data);
39
+ };
32
40
  const { route, status, executeRoute, restartRoute, deleteRoute } = (0, hooks_1.useRouteExecution)({
33
41
  routeId: routeId,
34
- onAcceptExchangeRateUpdate: exchangeRateBottomSheetRef.current?.open,
42
+ onAcceptExchangeRateUpdate,
35
43
  });
36
- const handleExecuteRoute = (0, react_1.useCallback)(() => {
44
+ const tokenValueLossThresholdExceeded = (0, TokenValueBottomSheet_1.getTokenValueLossThreshold)(route);
45
+ const handleExecuteRoute = () => {
37
46
  if (tokenValueBottomSheetRef.current?.isOpen()) {
47
+ if (route) {
48
+ emitter.emit(events_1.WidgetEvent.RouteHighValueLoss, {
49
+ fromAmountUsd: route.fromAmountUSD,
50
+ gasCostUSD: route.gasCostUSD,
51
+ toAmountUSD: route.toAmountUSD,
52
+ valueLoss: (0, utils_2.calcValueLoss)(route),
53
+ });
54
+ }
38
55
  tokenValueBottomSheetRef.current?.close();
39
56
  }
40
57
  executeRoute();
41
58
  setValue(providers_1.SwapFormKey.FromAmount, '');
42
- }, [executeRoute, setValue]);
59
+ };
43
60
  const handleSwapClick = async () => {
44
61
  if (status === stores_1.RouteExecutionStatus.Idle) {
45
- const thresholdExceeded = (0, TokenValueBottomSheet_1.getTokenValueLossThreshold)(route);
46
- if (thresholdExceeded) {
62
+ if (tokenValueLossThresholdExceeded && variant !== 'nft') {
47
63
  tokenValueBottomSheetRef.current?.open();
48
64
  }
49
65
  else {
@@ -61,9 +77,14 @@ const SwapPage = () => {
61
77
  const getSwapButtonText = () => {
62
78
  switch (status) {
63
79
  case stores_1.RouteExecutionStatus.Idle:
64
- return variant !== 'refuel'
65
- ? t(`button.startSwap`)
66
- : t(`button.startGasSwap`);
80
+ switch (variant) {
81
+ case 'nft':
82
+ return t('button.buyNow');
83
+ case 'refuel':
84
+ return t('button.startGasSwap');
85
+ default:
86
+ return t('button.startSwap');
87
+ }
67
88
  case stores_1.RouteExecutionStatus.Failed:
68
89
  return t('button.tryAgain');
69
90
  default:
@@ -81,10 +102,10 @@ const SwapPage = () => {
81
102
  const insuranceCoverageId = route?.steps[0].execution?.process
82
103
  .filter((process) => process.type !== 'TOKEN_ALLOWANCE')
83
104
  .find((process) => process.txHash)?.txHash ?? route?.fromAddress;
84
- return ((0, jsx_runtime_1.jsxs)(SwapPage_style_1.Container, { children: [(0, Step_1.getStepList)(route), insuranceAvailable ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route?.insurance.feeAmountUsd, insuranceCoverageId: insuranceCoverageId, onChange: setRouteId })) : null, status === stores_1.RouteExecutionStatus.Idle ||
105
+ return ((0, jsx_runtime_1.jsxs)(SwapPage_style_1.Container, { children: [(0, Step_1.getStepList)(route), variant === 'nft' ? (0, jsx_runtime_1.jsx)(ContractComponent_1.ContractComponent, { mt: 2 }) : null, route && insuranceAvailable ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route.insurance.feeAmountUsd, insuredAmount: (0, utils_1.formatTokenAmount)(route.toAmountMin, route.toToken.decimals), insuredTokenSymbol: route.toToken.symbol, insuranceCoverageId: insuranceCoverageId, onChange: setRouteId })) : null, status === stores_1.RouteExecutionStatus.Idle ||
85
106
  status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GasMessage_1.GasMessage, { mt: 2, route: route }), (0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, display: "flex", children: [(0, jsx_runtime_1.jsx)(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, route: route, insurableRouteId: stateRouteId }), status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleRemoveRoute, sx: {
86
107
  minWidth: 48,
87
108
  marginLeft: 1,
88
- }, children: (0, jsx_runtime_1.jsx)(Delete_1.default, {}) }) })) : null] })] })) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null, route ? ((0, jsx_runtime_1.jsx)(TokenValueBottomSheet_1.TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? ((0, jsx_runtime_1.jsx)(ExchangeRateBottomSheet_1.ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef })) : null] }));
109
+ }, children: (0, jsx_runtime_1.jsx)(Delete_1.default, {}) }) })) : null] })] })) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null, route && tokenValueLossThresholdExceeded && variant !== 'nft' ? ((0, jsx_runtime_1.jsx)(TokenValueBottomSheet_1.TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? ((0, jsx_runtime_1.jsx)(ExchangeRateBottomSheet_1.ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef })) : null] }));
89
110
  };
90
111
  exports.SwapPage = SwapPage;
@@ -4,12 +4,12 @@ exports.getTokenValueLossThreshold = exports.TokenValueBottomSheet = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const WarningRounded_1 = require("@mui/icons-material/WarningRounded");
6
6
  const material_1 = require("@mui/material");
7
- const big_js_1 = require("big.js");
8
7
  const react_1 = require("react");
9
8
  const react_i18next_1 = require("react-i18next");
10
9
  const BottomSheet_1 = require("../../components/BottomSheet");
11
10
  const hooks_1 = require("../../hooks");
12
11
  const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
12
+ const utils_1 = require("./utils");
13
13
  exports.TokenValueBottomSheet = (0, react_1.forwardRef)(({ route, onContinue, onCancel }, ref) => {
14
14
  const handleCancel = () => {
15
15
  ref.current?.close();
@@ -21,23 +21,18 @@ const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
21
21
  const { t } = (0, react_i18next_1.useTranslation)();
22
22
  const ref = (0, react_1.useRef)();
23
23
  (0, hooks_1.useSetContentHeight)(ref);
24
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { p: 3, ref: ref, children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.IconCircle, { status: "warning", mb: 1, children: (0, jsx_runtime_1.jsx)(WarningRounded_1.default, { color: "warning" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, fontSize: 18, fontWeight: 700, children: t('swap.warning.title.highValueLoss') })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: t('swap.warning.message.highValueLoss') }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.swapping') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 600, children: t('format.currency', { value: route.fromAmountUSD }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.gasCost') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 600, children: t('format.currency', { value: route.gasCostUSD }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.receiving') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 600, children: t('format.currency', { value: route.toAmountUSD }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.valueLoss') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { fontWeight: 600, children: [(0, big_js_1.default)(route.toAmountUSD || 0)
25
- .div((0, big_js_1.default)(route.fromAmountUSD || 0).plus((0, big_js_1.default)(route.gasCostUSD || 0)))
26
- .minus(1)
27
- .mul(100)
28
- .round(2, big_js_1.default.roundUp)
29
- .toString(), "%"] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", mt: 3, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: onCancel, fullWidth: true, children: t('button.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", p: 1 }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: onContinue, fullWidth: true, children: t('button.continue') })] })] }));
24
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { p: 3, ref: ref, children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.CenterContainer, { children: [(0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.IconCircle, { status: "warning", mb: 1, children: (0, jsx_runtime_1.jsx)(WarningRounded_1.default, { color: "warning" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, fontSize: 18, fontWeight: 700, children: t('swap.warning.title.highValueLoss') })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { py: 1, children: t('swap.warning.message.highValueLoss') }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.swapping') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 600, children: t('format.currency', { value: route.fromAmountUSD }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.gasCost') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 600, children: t('format.currency', { value: route.gasCostUSD }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.receiving') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 600, children: t('format.currency', { value: route.toAmountUSD }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", mt: 0.25, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.valueLoss') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 600, children: (0, utils_1.calcValueLoss)(route) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", mt: 3, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: onCancel, fullWidth: true, children: t('button.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", p: 1 }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: onContinue, fullWidth: true, children: t('button.continue') })] })] }));
30
25
  };
31
26
  const getTokenValueLossThreshold = (route) => {
32
27
  if (!route) {
33
28
  return false;
34
29
  }
35
- const fromAmountUSD = (0, big_js_1.default)(route?.fromAmountUSD || 0);
36
- const toAmountUSD = (0, big_js_1.default)(route?.toAmountUSD || 0);
37
- const gasCostUSD = (0, big_js_1.default)(route?.gasCostUSD || 0);
38
- if (fromAmountUSD.eq(0) && toAmountUSD.eq(0)) {
30
+ const fromAmountUSD = Number(route.fromAmountUSD || 0);
31
+ const toAmountUSD = Number(route.toAmountUSD || 0);
32
+ const gasCostUSD = Number(route.gasCostUSD || 0);
33
+ if (!fromAmountUSD && !toAmountUSD) {
39
34
  return false;
40
35
  }
41
- return toAmountUSD.div(fromAmountUSD.plus(gasCostUSD)).lt(0.9);
36
+ return toAmountUSD / (fromAmountUSD + gasCostUSD) < 0.9;
42
37
  };
43
38
  exports.getTokenValueLossThreshold = getTokenValueLossThreshold;
@@ -0,0 +1,2 @@
1
+ import type { Route } from '@lifi/sdk';
2
+ export declare const calcValueLoss: (route: Route) => string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcValueLoss = void 0;
4
+ const calcValueLoss = (route) => {
5
+ return `${((Number(route.toAmountUSD || 0) /
6
+ (Number(route.fromAmountUSD || 0) + Number(route.gasCostUSD || 0)) -
7
+ 1) *
8
+ 100).toFixed(2)}%`;
9
+ };
10
+ exports.calcValueLoss = calcValueLoss;
@@ -11,7 +11,7 @@ const stores_1 = require("../../stores");
11
11
  const utils_1 = require("../../utils");
12
12
  const WidgetProvider_1 = require("../WidgetProvider");
13
13
  const I18nProvider = ({ children, }) => {
14
- const { languageResources, languages, disableI18n } = (0, WidgetProvider_1.useWidgetConfig)();
14
+ const { languageResources, languages, disableLanguageDetector } = (0, WidgetProvider_1.useWidgetConfig)();
15
15
  const { language } = (0, stores_1.useSettings)(['language']);
16
16
  const i18n = (0, react_1.useMemo)(() => {
17
17
  let resources = Object.keys(supportedLanguages)
@@ -50,12 +50,12 @@ const I18nProvider = ({ children, }) => {
50
50
  caches: [],
51
51
  },
52
52
  });
53
- if (!language && !languages?.default && !disableI18n) {
53
+ if (!language && !languages?.default && !disableLanguageDetector) {
54
54
  i18n = i18n.use(i18next_browser_languagedetector_1.default);
55
55
  }
56
56
  i18n.use(react_i18next_1.initReactI18next).init();
57
57
  return i18n;
58
- }, [disableI18n, language, languageResources, languages]);
58
+ }, [disableLanguageDetector, language, languageResources, languages]);
59
59
  return (0, jsx_runtime_1.jsx)(react_i18next_1.I18nextProvider, { i18n: i18n, children: children });
60
60
  };
61
61
  exports.I18nProvider = I18nProvider;
@@ -4,6 +4,7 @@ exports.SDKProvider = exports.useLiFi = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const sdk_1 = require("@lifi/sdk");
6
6
  const react_1 = require("react");
7
+ const version_1 = require("../../config/version");
7
8
  const WidgetProvider_1 = require("../WidgetProvider");
8
9
  let lifi;
9
10
  const SDKContext = (0, react_1.createContext)(null);
@@ -27,6 +28,7 @@ const SDKProvider = ({ children, }) => {
27
28
  if (!lifi) {
28
29
  lifi = new sdk_1.LiFi({
29
30
  disableVersionCheck: true,
31
+ widgetVersion: version_1.version,
30
32
  ...config,
31
33
  });
32
34
  }
@@ -26,6 +26,7 @@ const FormUpdater = ({ defaultValues }) => {
26
26
  const { isTouched: isToTokenTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.ToToken);
27
27
  const { isTouched: isFromAmountTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.FromAmount);
28
28
  if (!fromChain && !isFromChainTouched && !isFromTokenTouched) {
29
+ resetField(SwapFormProvider_1.SwapFormKey.FromChain, { defaultValue: account.chainId });
29
30
  setValue(SwapFormProvider_1.SwapFormKey.FromChain, account.chainId);
30
31
  setValue(SwapFormProvider_1.SwapFormKey.FromToken, '');
31
32
  if (isFromAmountTouched) {
@@ -33,6 +34,7 @@ const FormUpdater = ({ defaultValues }) => {
33
34
  }
34
35
  }
35
36
  if (!toChain && !isToChainTouched && !isToTokenTouched) {
37
+ resetField(SwapFormProvider_1.SwapFormKey.ToChain, { defaultValue: account.chainId });
36
38
  setValue(SwapFormProvider_1.SwapFormKey.ToChain, account.chainId);
37
39
  setValue(SwapFormProvider_1.SwapFormKey.ToToken, '');
38
40
  }
@@ -43,6 +45,7 @@ const FormUpdater = ({ defaultValues }) => {
43
45
  fromChain,
44
46
  getFieldState,
45
47
  getValues,
48
+ resetField,
46
49
  setValue,
47
50
  toChain,
48
51
  ]);