@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.
- package/App.d.ts +4 -3
- package/AppDrawer.d.ts +1 -1
- package/AppDrawer.js +2 -1
- package/AppProvider.js +1 -1
- package/README.md +11 -12
- package/cjs/App.d.ts +4 -3
- package/cjs/AppDrawer.d.ts +1 -1
- package/cjs/AppDrawer.js +2 -1
- package/cjs/AppProvider.js +1 -1
- package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -2
- package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
- package/cjs/components/ChainSelect/useChainSelect.js +6 -0
- package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
- package/cjs/components/GasMessage/GasMessage.js +1 -6
- package/cjs/components/Header/Header.js +2 -2
- package/cjs/components/Header/Header.style.d.ts +10 -3
- package/cjs/components/Header/Header.style.js +3 -0
- package/cjs/components/Header/NavigationHeader.js +23 -7
- package/cjs/components/Header/NavigationTabs.d.ts +1 -0
- package/cjs/components/Header/NavigationTabs.js +26 -0
- package/cjs/components/Header/NavigationTabs.style.d.ts +34 -0
- package/cjs/components/Header/NavigationTabs.style.js +61 -0
- package/cjs/components/Header/WalletHeader.d.ts +1 -0
- package/cjs/components/Header/WalletHeader.js +16 -9
- package/cjs/components/Header/useHeaderActionStore.js +0 -1
- package/cjs/components/Insurance/Insurance.js +2 -2
- package/cjs/components/Insurance/InsuranceCard.js +34 -12
- package/cjs/components/Insurance/InsuranceCollapsed.js +9 -11
- package/cjs/components/Insurance/index.d.ts +1 -0
- package/cjs/components/Insurance/index.js +1 -0
- package/cjs/components/Insurance/types.d.ts +12 -9
- package/cjs/components/NFT/NFT.js +2 -2
- package/cjs/components/NFT/types.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.js +2 -3
- package/cjs/components/SelectChainAndToken.js +8 -7
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +6 -3
- package/cjs/components/SendToWallet/SendToWallet.js +2 -2
- package/cjs/components/SmallAvatar.d.ts +1 -1
- package/cjs/components/Step/CircularProgress.d.ts +1 -2
- package/cjs/components/Step/Step.js +15 -5
- package/cjs/components/Step/StepList.d.ts +1 -2
- package/cjs/components/StepActions/StepActions.js +4 -20
- package/cjs/components/SwapButton/SwapButton.js +16 -4
- package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
- package/cjs/components/SwapInput/SwapInput.js +2 -2
- package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
- package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -3
- package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
- package/cjs/components/Token/Token.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
- package/cjs/components/TokenList/TokenList.js +9 -4
- package/cjs/components/TokenList/TokenList.style.d.ts +5 -2
- package/cjs/components/TokenList/TokenList.style.js +20 -1
- package/cjs/components/TokenList/TokenListItem.d.ts +1 -1
- package/cjs/components/TokenList/TokenListItem.js +28 -5
- package/cjs/components/TokenList/VirtualizedTokenList.js +3 -3
- package/cjs/components/TokenList/types.d.ts +6 -3
- package/cjs/config/theme.js +15 -3
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +2 -1
- package/cjs/hooks/index.js +2 -1
- package/cjs/hooks/useContentHeight.js +3 -5
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFundsSufficiency.js +2 -2
- package/cjs/hooks/useGasRefuel.d.ts +1 -1
- package/cjs/hooks/useGasRefuel.js +5 -15
- package/cjs/hooks/useGasSufficiency.js +12 -3
- package/cjs/hooks/useInitializer.js +0 -1
- package/cjs/hooks/useProcessMessage.d.ts +2 -1
- package/cjs/hooks/useProcessMessage.js +27 -9
- package/cjs/hooks/useRouteExecution.js +6 -5
- package/cjs/hooks/useSwapOnly.d.ts +1 -0
- package/cjs/hooks/useSwapOnly.js +9 -0
- package/cjs/hooks/useSwapRoutes.d.ts +1 -2
- package/cjs/hooks/useSwapRoutes.js +32 -18
- package/cjs/hooks/useToken.d.ts +1 -1
- package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
- package/cjs/hooks/useTokenBalance.js +6 -7
- package/cjs/hooks/useTokenBalances.d.ts +5 -5
- package/cjs/hooks/useTokenBalances.js +4 -19
- package/cjs/hooks/useTokenSearch.d.ts +2 -2
- package/cjs/hooks/useTokens.d.ts +2 -2
- package/cjs/i18n/bn.json +8 -0
- package/cjs/i18n/en.json +30 -5
- package/cjs/i18n/fr.json +8 -0
- package/cjs/i18n/id.json +22 -7
- package/cjs/i18n/ko.json +22 -7
- package/cjs/i18n/pt.json +32 -7
- package/cjs/i18n/th.json +21 -6
- package/cjs/i18n/uk.json +43 -18
- package/cjs/i18n/zh.json +23 -8
- package/cjs/icons/InsuraceLogo.d.ts +1 -1
- package/cjs/icons/LiFiFullLogo.d.ts +1 -1
- package/cjs/icons/LiFiLogo.d.ts +1 -1
- package/cjs/icons/LiFiToolLogo.d.ts +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
- package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
- package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
- package/cjs/pages/SettingsPage/LanguageSelect.js +1 -1
- package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -2
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -2
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +15 -9
- package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
- package/cjs/pages/SwapPage/SwapPage.js +31 -10
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +7 -12
- package/cjs/pages/SwapPage/utils.d.ts +2 -0
- package/cjs/pages/SwapPage/utils.js +10 -0
- package/cjs/providers/I18nProvider/I18nProvider.js +3 -3
- package/cjs/providers/SDKProvider/SDKProvider.js +2 -0
- package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +77 -49
- package/cjs/providers/WalletProvider/types.d.ts +3 -5
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -1
- package/cjs/stores/StoreProvider.d.ts +2 -2
- package/cjs/stores/StoreProvider.js +3 -2
- package/cjs/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/cjs/stores/routes/RouteExecutionStore.js +0 -1
- package/cjs/stores/settings/index.d.ts +1 -0
- package/cjs/stores/settings/index.js +1 -0
- package/cjs/stores/settings/types.d.ts +11 -0
- package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
- package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
- package/cjs/types/events.d.ts +9 -1
- package/cjs/types/events.js +1 -0
- package/cjs/types/token.d.ts +2 -2
- package/cjs/types/widget.d.ts +13 -8
- package/cjs/types/widget.js +4 -2
- package/cjs/utils/format.d.ts +1 -1
- package/cjs/utils/format.js +7 -12
- package/cjs/utils/wallet.d.ts +1 -1
- package/cjs/utils/wallet.js +3 -3
- package/components/ChainSelect/ChainSelect.d.ts +1 -2
- package/components/ChainSelect/ChainSelect.style.js +1 -1
- package/components/ChainSelect/useChainSelect.js +7 -1
- package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
- package/components/GasMessage/GasMessage.js +2 -7
- package/components/Header/Header.js +3 -3
- package/components/Header/Header.style.d.ts +10 -3
- package/components/Header/Header.style.js +3 -0
- package/components/Header/NavigationHeader.js +23 -7
- package/components/Header/NavigationTabs.d.ts +1 -0
- package/components/Header/NavigationTabs.js +22 -0
- package/components/Header/NavigationTabs.style.d.ts +34 -0
- package/components/Header/NavigationTabs.style.js +58 -0
- package/components/Header/WalletHeader.d.ts +1 -0
- package/components/Header/WalletHeader.js +14 -8
- package/components/Header/useHeaderActionStore.js +0 -1
- package/components/Insurance/Insurance.js +2 -2
- package/components/Insurance/InsuranceCard.js +37 -15
- package/components/Insurance/InsuranceCollapsed.js +9 -11
- package/components/Insurance/index.d.ts +1 -0
- package/components/Insurance/index.js +1 -0
- package/components/Insurance/types.d.ts +12 -9
- package/components/NFT/NFT.js +2 -2
- package/components/NFT/types.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.js +2 -3
- package/components/SelectChainAndToken.js +9 -8
- package/components/SelectTokenButton/SelectTokenButton.js +7 -4
- package/components/SendToWallet/SendToWallet.js +2 -2
- package/components/SmallAvatar.d.ts +1 -1
- package/components/Step/CircularProgress.d.ts +1 -2
- package/components/Step/Step.js +16 -6
- package/components/Step/StepList.d.ts +1 -2
- package/components/StepActions/StepActions.js +4 -20
- package/components/SwapButton/SwapButton.js +16 -4
- package/components/SwapInput/FormPriceHelperText.js +2 -2
- package/components/SwapInput/SwapInput.js +3 -3
- package/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
- package/components/SwapInput/SwapInputEndAdornment.js +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +21 -5
- package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/components/SwapRoutes/SwapRoutes.js +1 -1
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
- package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
- package/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
- package/components/Token/Token.js +1 -1
- package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
- package/components/TokenList/TokenList.js +10 -5
- package/components/TokenList/TokenList.style.d.ts +5 -2
- package/components/TokenList/TokenList.style.js +21 -2
- package/components/TokenList/TokenListItem.d.ts +1 -1
- package/components/TokenList/TokenListItem.js +32 -9
- package/components/TokenList/VirtualizedTokenList.js +3 -3
- package/components/TokenList/types.d.ts +6 -3
- package/config/theme.js +15 -3
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +2 -1
- package/hooks/useContentHeight.js +4 -6
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFundsSufficiency.js +2 -2
- package/hooks/useGasRefuel.d.ts +1 -1
- package/hooks/useGasRefuel.js +5 -15
- package/hooks/useGasSufficiency.js +13 -4
- package/hooks/useInitializer.js +0 -1
- package/hooks/useProcessMessage.d.ts +2 -1
- package/hooks/useProcessMessage.js +27 -9
- package/hooks/useRouteExecution.js +6 -5
- package/hooks/useSwapOnly.d.ts +1 -0
- package/hooks/useSwapOnly.js +5 -0
- package/hooks/useSwapRoutes.d.ts +1 -2
- package/hooks/useSwapRoutes.js +32 -18
- package/hooks/useToken.d.ts +1 -1
- package/hooks/useTokenAddressBalance.d.ts +2 -2
- package/hooks/useTokenBalance.js +6 -7
- package/hooks/useTokenBalances.d.ts +5 -5
- package/hooks/useTokenBalances.js +4 -19
- package/hooks/useTokenSearch.d.ts +2 -2
- package/hooks/useTokens.d.ts +2 -2
- package/i18n/bn.json +8 -0
- package/i18n/en.json +30 -5
- package/i18n/fr.json +8 -0
- package/i18n/id.json +22 -7
- package/i18n/ko.json +22 -7
- package/i18n/pt.json +32 -7
- package/i18n/th.json +21 -6
- package/i18n/uk.json +43 -18
- package/i18n/zh.json +23 -8
- package/icons/InsuraceLogo.d.ts +1 -1
- package/icons/LiFiFullLogo.d.ts +1 -1
- package/icons/LiFiLogo.d.ts +1 -1
- package/icons/LiFiToolLogo.d.ts +1 -1
- package/index.d.ts +1 -1
- package/package.json +13 -13
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
- package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
- package/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
- package/pages/SettingsPage/LanguageSelect.js +1 -1
- package/pages/SettingsPage/SettingsPage.d.ts +1 -2
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
- package/pages/SettingsPage/SlippageInput.d.ts +1 -2
- package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
- package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
- package/pages/SwapPage/StatusBottomSheet.js +18 -12
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
- package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
- package/pages/SwapPage/SwapPage.js +33 -12
- package/pages/SwapPage/TokenValueBottomSheet.js +8 -13
- package/pages/SwapPage/utils.d.ts +2 -0
- package/pages/SwapPage/utils.js +6 -0
- package/providers/I18nProvider/I18nProvider.js +3 -3
- package/providers/SDKProvider/SDKProvider.js +2 -0
- package/providers/SwapFormProvider/FormUpdater.js +3 -0
- package/providers/WalletProvider/WalletProvider.js +78 -50
- package/providers/WalletProvider/types.d.ts +3 -5
- package/providers/WidgetProvider/WidgetProvider.js +2 -2
- package/stores/StoreProvider.d.ts +2 -2
- package/stores/StoreProvider.js +3 -2
- package/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/stores/routes/RouteExecutionStore.js +0 -1
- package/stores/settings/index.d.ts +1 -0
- package/stores/settings/index.js +1 -0
- package/stores/settings/types.d.ts +11 -0
- package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
- package/stores/settings/useSplitSubvariantStore.js +37 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +9 -1
- package/types/events.js +1 -0
- package/types/token.d.ts +2 -2
- package/types/widget.d.ts +13 -8
- package/types/widget.js +4 -2
- package/utils/format.d.ts +1 -1
- package/utils/format.js +5 -10
- package/utils/wallet.d.ts +1 -1
- 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
|
-
"
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
"
|
|
187
|
-
"
|
|
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;
|
package/cjs/icons/LiFiLogo.d.ts
CHANGED
|
@@ -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").
|
|
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
|
-
|
|
2
|
-
export declare const ActiveSwapsPage: () => JSX.Element;
|
|
1
|
+
export declare const ActiveSwapsPage: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
export declare const SelectWalletPage: () => JSX.Element;
|
|
1
|
+
export declare const SelectWalletPage: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
2
|
-
export declare const SettingsPage: () => JSX.Element;
|
|
1
|
+
export declare const SettingsPage: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const ShowDestinationWallet: () => JSX.Element | null;
|
|
1
|
+
export declare const ShowDestinationWallet: () => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
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.
|
|
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.
|
|
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 =
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
146
|
-
|
|
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
|
|
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.
|
|
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.
|
|
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
|
|
42
|
+
onAcceptExchangeRateUpdate,
|
|
35
43
|
});
|
|
36
|
-
const
|
|
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
|
-
}
|
|
59
|
+
};
|
|
43
60
|
const handleSwapClick = async () => {
|
|
44
61
|
if (status === stores_1.RouteExecutionStatus.Idle) {
|
|
45
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
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.
|
|
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 = (
|
|
36
|
-
const toAmountUSD = (
|
|
37
|
-
const gasCostUSD = (
|
|
38
|
-
if (fromAmountUSD
|
|
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
|
|
36
|
+
return toAmountUSD / (fromAmountUSD + gasCostUSD) < 0.9;
|
|
42
37
|
};
|
|
43
38
|
exports.getTokenValueLossThreshold = getTokenValueLossThreshold;
|
|
@@ -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,
|
|
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 && !
|
|
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
|
-
}, [
|
|
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
|
]);
|