@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
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const HeaderAppBar: import("@emotion/styled").StyledComponent<
|
|
2
|
+
export declare const HeaderAppBar: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
classes?: Partial<import("@mui/material").AppBarClasses> | undefined;
|
|
4
4
|
color?: import("@mui/types").OverridableStringUnion<"transparent" | import("@mui/material").PropTypes.Color, import("@mui/material").AppBarPropsColorOverrides> | undefined;
|
|
5
5
|
enableColorOnDark?: boolean | undefined;
|
|
6
6
|
position?: "fixed" | "absolute" | "relative" | "static" | "sticky" | undefined;
|
|
7
7
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
8
|
-
} &
|
|
8
|
+
} & Omit<{
|
|
9
|
+
children?: import("react").ReactNode;
|
|
10
|
+
classes?: Partial<import("@mui/material").PaperClasses> | undefined;
|
|
11
|
+
elevation?: number | undefined;
|
|
12
|
+
square?: boolean | undefined;
|
|
13
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
14
|
+
variant?: import("@mui/types").OverridableStringUnion<"outlined" | "elevation", import("@mui/material").PaperPropsVariantOverrides> | undefined;
|
|
15
|
+
}, "classes" | "color" | "position"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & {
|
|
9
16
|
ref?: ((instance: HTMLElement | null) => void) | import("react").RefObject<HTMLElement> | null | undefined;
|
|
10
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "
|
|
17
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "color" | "children" | "sx" | "position" | "variant" | "square" | "elevation" | "enableColorOnDark"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
11
18
|
export declare const Container: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
12
19
|
children?: import("react").ReactNode;
|
|
13
20
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -7,12 +7,15 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
|
8
8
|
import { useNavigateBack } from '../../hooks';
|
|
9
9
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
10
|
+
import { HiddenUI } from '../../types';
|
|
10
11
|
import { backButtonRoutes, navigationRoutes, navigationRoutesValues, } from '../../utils';
|
|
11
12
|
import { HeaderAppBar } from './Header.style';
|
|
13
|
+
import { NavigationTabs } from './NavigationTabs';
|
|
14
|
+
import { WalletMenuButton } from './WalletHeader';
|
|
12
15
|
import { useHeaderActionStore } from './useHeaderActionStore';
|
|
13
16
|
export const NavigationHeader = () => {
|
|
14
17
|
const { t } = useTranslation();
|
|
15
|
-
const { variant } = useWidgetConfig();
|
|
18
|
+
const { variant, subvariant, hiddenUI } = useWidgetConfig();
|
|
16
19
|
const { navigate, navigateBack } = useNavigateBack();
|
|
17
20
|
const { account } = useWallet();
|
|
18
21
|
const { element } = useHeaderActionStore();
|
|
@@ -22,6 +25,7 @@ export const NavigationHeader = () => {
|
|
|
22
25
|
: pathname;
|
|
23
26
|
const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
|
|
24
27
|
const hasPath = navigationRoutesValues.includes(path);
|
|
28
|
+
const splitSubvariant = subvariant === 'split' && !hasPath;
|
|
25
29
|
const handleHeaderTitle = () => {
|
|
26
30
|
switch (path) {
|
|
27
31
|
case navigationRoutes.selectWallet:
|
|
@@ -34,8 +38,12 @@ export const NavigationHeader = () => {
|
|
|
34
38
|
return t(`settings.enabledExchanges`);
|
|
35
39
|
case navigationRoutes.swapHistory:
|
|
36
40
|
return t(`header.swapHistory`);
|
|
37
|
-
case navigationRoutes.fromToken:
|
|
41
|
+
case navigationRoutes.fromToken: {
|
|
42
|
+
if (variant === 'nft') {
|
|
43
|
+
return t(`header.payWith`);
|
|
44
|
+
}
|
|
38
45
|
return t(`header.from`);
|
|
46
|
+
}
|
|
39
47
|
case navigationRoutes.toToken:
|
|
40
48
|
return t(`header.to`);
|
|
41
49
|
case navigationRoutes.fromChain:
|
|
@@ -46,10 +54,18 @@ export const NavigationHeader = () => {
|
|
|
46
54
|
return t(`header.routes`);
|
|
47
55
|
case navigationRoutes.activeSwaps:
|
|
48
56
|
return t(`header.activeSwaps`);
|
|
49
|
-
case navigationRoutes.swapExecution:
|
|
57
|
+
case navigationRoutes.swapExecution: {
|
|
58
|
+
if (variant === 'nft') {
|
|
59
|
+
return t(`header.purchase`);
|
|
60
|
+
}
|
|
50
61
|
return t(`header.swap`);
|
|
51
|
-
|
|
62
|
+
}
|
|
63
|
+
case navigationRoutes.swapDetails: {
|
|
64
|
+
if (variant === 'nft') {
|
|
65
|
+
return t(`header.purchaseDetails`);
|
|
66
|
+
}
|
|
52
67
|
return t(`header.swapDetails`);
|
|
68
|
+
}
|
|
53
69
|
default: {
|
|
54
70
|
switch (variant) {
|
|
55
71
|
case 'nft':
|
|
@@ -62,7 +78,7 @@ export const NavigationHeader = () => {
|
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
80
|
};
|
|
65
|
-
return (_jsxs(HeaderAppBar, { elevation: 0, children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: _jsx(ArrowBackIcon, {}) })) : null, _jsx(Typography, { fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true, children: handleHeaderTitle() }), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(Tooltip, { title: t(`header.swapHistory`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory), children: _jsx(ReceiptLongIcon, {}) }) })) : null, _jsx(Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", onClick: () => navigate(navigationRoutes.settings), sx: {
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsxs(HeaderAppBar, { elevation: 0, children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: _jsx(ArrowBackIcon, {}) })) : null, splitSubvariant ? (_jsx(Box, { flex: 1, children: !hiddenUI?.includes(HiddenUI.WalletMenu) ? (_jsx(WalletMenuButton, {})) : null })) : (_jsx(Typography, { fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true, children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive && !hiddenUI?.includes(HiddenUI.History) ? (_jsx(Tooltip, { title: t(`header.swapHistory`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory), children: _jsx(ReceiptLongIcon, {}) }) })) : null, _jsx(Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", onClick: () => navigate(navigationRoutes.settings), sx: {
|
|
82
|
+
marginRight: -1.25,
|
|
83
|
+
}, children: _jsx(SettingsIcon, {}) }) })] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] }), splitSubvariant ? _jsx(NavigationTabs, {}) : null] }));
|
|
68
84
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NavigationTabs: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { SwapFormKey } from '../../providers';
|
|
5
|
+
import { useSplitSubvariantStore } from '../../stores';
|
|
6
|
+
import { HeaderAppBar } from './Header.style';
|
|
7
|
+
import { NavbarTab, NavbarTabs } from './NavigationTabs.style';
|
|
8
|
+
export const NavigationTabs = () => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const [state, setState] = useSplitSubvariantStore((state) => [
|
|
11
|
+
state.state,
|
|
12
|
+
state.setState,
|
|
13
|
+
]);
|
|
14
|
+
const { setValue } = useFormContext();
|
|
15
|
+
const handleChange = (_, value) => {
|
|
16
|
+
setValue(SwapFormKey.FromAmount, '');
|
|
17
|
+
setValue(SwapFormKey.FromToken, '');
|
|
18
|
+
setValue(SwapFormKey.ToToken, '');
|
|
19
|
+
setState(value === 0 ? 'swap' : 'bridge');
|
|
20
|
+
};
|
|
21
|
+
return (_jsx(HeaderAppBar, { elevation: 0, sx: { py: 1 }, children: _jsxs(NavbarTabs, { value: state === 'swap' ? 0 : 1, onChange: handleChange, "aria-label": "tabs", indicatorColor: "primary", children: [_jsx(NavbarTab, { label: t('header.swap'), disableRipple: true }), _jsx(NavbarTab, { label: t('header.bridge'), disableRipple: true })] }) }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StyledComponent } from '@emotion/styled';
|
|
3
|
+
import type { TabsProps } from '@mui/material';
|
|
4
|
+
export declare const NavbarTabs: StyledComponent<TabsProps>;
|
|
5
|
+
export declare const NavbarTab: StyledComponent<{
|
|
6
|
+
children?: null | undefined;
|
|
7
|
+
classes?: Partial<import("@mui/material").TabClasses> | undefined;
|
|
8
|
+
disabled?: boolean | undefined;
|
|
9
|
+
disableFocusRipple?: boolean | undefined;
|
|
10
|
+
icon?: string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
11
|
+
iconPosition?: "bottom" | "top" | "end" | "start" | undefined;
|
|
12
|
+
label?: import("react").ReactNode;
|
|
13
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
14
|
+
value?: any;
|
|
15
|
+
wrapped?: boolean | undefined;
|
|
16
|
+
} & Omit<{
|
|
17
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
18
|
+
centerRipple?: boolean | undefined;
|
|
19
|
+
children?: import("react").ReactNode;
|
|
20
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
disableRipple?: boolean | undefined;
|
|
23
|
+
disableTouchRipple?: boolean | undefined;
|
|
24
|
+
focusRipple?: boolean | undefined;
|
|
25
|
+
focusVisibleClassName?: string | undefined;
|
|
26
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
27
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
28
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
29
|
+
tabIndex?: number | undefined;
|
|
30
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
31
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
32
|
+
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
33
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
34
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "label" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "value" | "icon" | "iconPosition" | "wrapped"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Tab, Tabs, tabClasses, tabsClasses } from '@mui/material';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
3
|
+
export const NavbarTabs = styled(Tabs)(({ theme }) => ({
|
|
4
|
+
backgroundColor: theme.palette.mode === 'dark'
|
|
5
|
+
? theme.palette.common.white
|
|
6
|
+
: alpha(theme.palette.common.black, 0.04),
|
|
7
|
+
borderRadius: theme.shape.borderRadius,
|
|
8
|
+
padding: theme.spacing(0.5),
|
|
9
|
+
flex: 1,
|
|
10
|
+
display: 'flex',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
height: 56,
|
|
13
|
+
[`.${tabsClasses.flexContainer}`]: {
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
},
|
|
16
|
+
[`.${tabsClasses.scroller}`]: {
|
|
17
|
+
overflow: 'initial !important',
|
|
18
|
+
},
|
|
19
|
+
[`.${tabsClasses.indicator}`]: {
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
top: '50%',
|
|
22
|
+
transform: 'translateY(-50%)',
|
|
23
|
+
height: 48,
|
|
24
|
+
backgroundColor: theme.palette.mode === 'dark'
|
|
25
|
+
? theme.palette.common.black
|
|
26
|
+
: theme.palette.common.white,
|
|
27
|
+
borderRadius: theme.shape.borderRadiusSecondary,
|
|
28
|
+
boxShadow: `0px 2px 4px ${alpha(theme.palette.common.black, 0.04)}`,
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
export const NavbarTab = styled(Tab, {
|
|
32
|
+
shouldForwardProp: (prop) => prop !== 'isDarkMode',
|
|
33
|
+
})(({ theme }) => ({
|
|
34
|
+
zIndex: 1,
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flex: 1,
|
|
37
|
+
justifyContent: 'center',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
textTransform: 'none',
|
|
41
|
+
height: 48,
|
|
42
|
+
minHeight: 48,
|
|
43
|
+
fontSize: '1rem',
|
|
44
|
+
fontWeight: 700,
|
|
45
|
+
color: theme.palette.mode === 'dark'
|
|
46
|
+
? theme.palette.common.white
|
|
47
|
+
: theme.palette.common.black,
|
|
48
|
+
textDecoration: 'none',
|
|
49
|
+
[`&.${tabClasses.selected}`]: {
|
|
50
|
+
color: theme.palette.mode === 'dark'
|
|
51
|
+
? theme.palette.common.white
|
|
52
|
+
: theme.palette.common.black,
|
|
53
|
+
backgroundColor: 'transparent',
|
|
54
|
+
},
|
|
55
|
+
[`.${tabClasses.iconWrapper}`]: {
|
|
56
|
+
margin: theme.spacing(0, 1, 0, 0),
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
@@ -10,34 +10,39 @@ import { useTranslation } from 'react-i18next';
|
|
|
10
10
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
11
11
|
import { useChain } from '../../hooks';
|
|
12
12
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
13
|
-
import { navigationRoutes,
|
|
13
|
+
import { navigationRoutes, shortenAddress } from '../../utils';
|
|
14
14
|
import { HeaderAppBar, WalletButton } from './Header.style';
|
|
15
15
|
import { WalletMenu } from './WalletMenu';
|
|
16
16
|
export const WalletHeader = () => {
|
|
17
|
+
return (_jsx(HeaderAppBar, { elevation: 0, sx: { justifyContent: 'flex-end' }, children: _jsx(WalletMenuButton, {}) }));
|
|
18
|
+
};
|
|
19
|
+
export const WalletMenuButton = () => {
|
|
17
20
|
const { account } = useWallet();
|
|
18
|
-
return
|
|
21
|
+
return account.isActive ? _jsx(ConnectedButton, {}) : _jsx(ConnectButton, {});
|
|
19
22
|
};
|
|
20
23
|
const ConnectButton = () => {
|
|
21
24
|
const { t } = useTranslation();
|
|
22
25
|
const { pathname } = useLocation();
|
|
23
|
-
const
|
|
26
|
+
const { walletManagement, subvariant } = useWidgetConfig();
|
|
24
27
|
const { connect: connectWallet } = useWallet();
|
|
25
28
|
const navigate = useNavigate();
|
|
26
29
|
const connect = async () => {
|
|
27
|
-
if (
|
|
30
|
+
if (walletManagement) {
|
|
28
31
|
await connectWallet();
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
31
34
|
navigate(navigationRoutes.selectWallet);
|
|
32
35
|
};
|
|
33
|
-
return (_jsx(WalletButton, { endIcon: _jsx(WalletIcon, {}), onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined, sx: {
|
|
34
|
-
marginRight: -1.25,
|
|
36
|
+
return (_jsx(WalletButton, { endIcon: subvariant !== 'split' ? _jsx(WalletIcon, {}) : undefined, startIcon: subvariant === 'split' ? _jsx(WalletIcon, {}) : undefined, onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined, sx: {
|
|
37
|
+
marginRight: subvariant === 'split' ? 0 : -1.25,
|
|
38
|
+
marginLeft: subvariant === 'split' ? -1.25 : 0,
|
|
35
39
|
}, children: t(`button.connectWallet`) }));
|
|
36
40
|
};
|
|
37
41
|
const ConnectedButton = () => {
|
|
38
42
|
const { t } = useTranslation();
|
|
43
|
+
const { subvariant } = useWidgetConfig();
|
|
39
44
|
const { account, disconnect } = useWallet();
|
|
40
|
-
const walletAddress =
|
|
45
|
+
const walletAddress = shortenAddress(account.address);
|
|
41
46
|
const { chain } = useChain(account.chainId);
|
|
42
47
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
43
48
|
const handleClick = (event) => {
|
|
@@ -55,7 +60,8 @@ const ConnectedButton = () => {
|
|
|
55
60
|
handleClose();
|
|
56
61
|
};
|
|
57
62
|
return (_jsxs(_Fragment, { children: [_jsx(WalletButton, { endIcon: _jsx(ExpandMoreIcon, {}), startIcon: _jsx(Avatar, { src: chain?.logoURI, alt: chain?.key, sx: { width: 24, height: 24 }, children: chain?.name[0] }), sx: {
|
|
58
|
-
marginRight: -1.25,
|
|
63
|
+
marginRight: subvariant === 'split' ? 0 : -1.25,
|
|
64
|
+
marginLeft: subvariant === 'split' ? -1 : 0,
|
|
59
65
|
}, onClick: handleClick, children: walletAddress }), _jsxs(WalletMenu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, children: [_jsxs(MenuItem, { onClick: handleCopyAddress, children: [_jsx(ContentCopyIcon, {}), t(`button.copyAddress`)] }), _jsxs(MenuItem, { component: "a", onClick: handleClose, href: `${chain?.metamask.blockExplorerUrls[0]}address/${account.address}`, target: "_blank", children: [_jsx(OpenInNewIcon, {}), t(`button.viewOnExplorer`)] }), _jsx(Button, { onClick: handleDisconnect, fullWidth: true, startIcon: _jsx(PowerSettingsNewIcon, {}), sx: {
|
|
60
66
|
marginTop: 1,
|
|
61
67
|
}, children: t(`button.disconnect`) })] })] }));
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { RouteExecutionStatus } from '../../stores';
|
|
3
3
|
import { InsuranceCard } from './InsuranceCard';
|
|
4
4
|
import { InsuranceCollapsed } from './InsuranceCollapsed';
|
|
5
|
-
export const Insurance = ({ status, insurableRouteId,
|
|
6
|
-
return status === RouteExecutionStatus.Idle ? (_jsx(InsuranceCollapsed, {
|
|
5
|
+
export const Insurance = ({ status, insurableRouteId, onChange, ...props }) => {
|
|
6
|
+
return status === RouteExecutionStatus.Idle ? (_jsx(InsuranceCollapsed, { status: status, insurableRouteId: insurableRouteId, onChange: onChange, ...props })) : (_jsx(InsuranceCard, { status: status, ...props }));
|
|
7
7
|
};
|
|
@@ -1,22 +1,44 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
3
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
2
4
|
import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
|
|
3
|
-
import { Box, Link, Typography } from '@mui/material';
|
|
4
|
-
import {
|
|
5
|
+
import { Box, Collapse, Link, Typography } from '@mui/material';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
5
8
|
import { InsuraceLogo } from '../../icons';
|
|
6
9
|
import { RouteExecutionStatus } from '../../stores';
|
|
7
|
-
import { Card, CardLabel, CardLabelTypography } from '../Card';
|
|
10
|
+
import { Card, CardIconButton, CardLabel, CardLabelTypography } from '../Card';
|
|
8
11
|
import { Switch } from '../Switch';
|
|
9
|
-
export const InsuranceCard = ({ status, feeAmountUsd, insuranceCoverageId, onChange, ...props }) => {
|
|
12
|
+
export const InsuranceCard = ({ status, feeAmountUsd, insuredAmount, insuredTokenSymbol, insuranceCoverageId, onChange, ...props }) => {
|
|
10
13
|
const { t } = useTranslation();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const [enabled, setEnabled] = useState(false);
|
|
15
|
+
const [cardExpanded, setCardExpanded] = useState(status === RouteExecutionStatus.Idle);
|
|
16
|
+
const handleExpand = (e) => {
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
setCardExpanded((expanded) => !expanded);
|
|
19
|
+
};
|
|
20
|
+
const handleSwitch = (_, checked) => {
|
|
21
|
+
setEnabled(checked);
|
|
22
|
+
onChange?.(checked);
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs(Card, { selectionColor: "secondary", indented: true, ...props, children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", children: [_jsxs(CardLabel, { type: 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), _jsx(CardLabelTypography, { type: "icon", children: status === RouteExecutionStatus.Idle
|
|
25
|
+
? t('swap.tags.insurance')
|
|
26
|
+
: t('swap.tags.insured') })] }), status === RouteExecutionStatus.Idle ? (_jsx(Switch, { onChange: handleSwitch, value: enabled })) : (_jsx(Box, { my: -0.5, children: _jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }) }))] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: _jsxs(Box, { mt: 2, children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [_jsx(Typography, { fontSize: 24, fontWeight: 700, lineHeight: 1, children: t('format.currency', {
|
|
27
|
+
value: feeAmountUsd,
|
|
28
|
+
}) }), _jsx(InsuraceLogo, {})] }), _jsxs(Box, { children: [_jsx(Typography, { fontSize: 14, children: _jsx(Trans, { children: status === RouteExecutionStatus.Idle
|
|
29
|
+
? t('swap.insurance.insure', {
|
|
30
|
+
amount: insuredAmount,
|
|
31
|
+
tokenSymbol: insuredTokenSymbol,
|
|
32
|
+
})
|
|
33
|
+
: t('swap.insurance.insured', {
|
|
34
|
+
amount: insuredAmount,
|
|
35
|
+
tokenSymbol: insuredTokenSymbol,
|
|
36
|
+
}) }) }), _jsx(Collapse, { timeout: 225, in: enabled || status !== RouteExecutionStatus.Idle, mountOnEnter: true, unmountOnExit: true, children: _jsxs(Box, { sx: {
|
|
37
|
+
listStyleType: 'disc',
|
|
38
|
+
pl: 2,
|
|
39
|
+
}, children: [_jsx(Typography, { fontSize: 14, display: "list-item", children: t('swap.insurance.bridgeExploits') }), _jsx(Typography, { fontSize: 14, display: "list-item", children: t('swap.insurance.slippageError') })] }) }), _jsx(Link, { href: status === RouteExecutionStatus.Idle
|
|
40
|
+
? 'https://docs.insurace.io/landing-page/documentation/cover-products/bridge-cover/li.fi'
|
|
41
|
+
: `https://app.insurace.io/bridge-cover?search=${insuranceCoverageId}`, target: "_blank", underline: "none", color: "text.primary", children: _jsx(Typography, { pt: 0.5, color: "primary", fontSize: 14, fontWeight: 600, children: status === RouteExecutionStatus.Idle
|
|
42
|
+
? t('button.learnMore')
|
|
43
|
+
: t('button.viewCoverage') }) })] })] }) })] }));
|
|
22
44
|
};
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Collapse } from '@mui/material';
|
|
3
|
-
import { useState } from 'react';
|
|
4
3
|
import { useSwapRoutes } from '../../hooks';
|
|
5
4
|
import { RouteExecutionStatus, useRouteExecutionStore, useSetExecutableRoute, } from '../../stores';
|
|
5
|
+
import { formatTokenAmount } from '../../utils';
|
|
6
6
|
import { InsuranceCard } from './InsuranceCard';
|
|
7
|
-
export const InsuranceCollapsed = ({ status, insurableRouteId,
|
|
8
|
-
const [insuredRoute, setInsuredRoute] = useState();
|
|
7
|
+
export const InsuranceCollapsed = ({ status, insurableRouteId, onChange, ...props }) => {
|
|
9
8
|
const setExecutableRoute = useSetExecutableRoute();
|
|
10
9
|
const routeExecution = useRouteExecutionStore((state) => state.routes[insurableRouteId]);
|
|
11
|
-
useSwapRoutes({
|
|
10
|
+
const { routes } = useSwapRoutes({
|
|
12
11
|
insurableRoute: routeExecution?.route,
|
|
13
|
-
onSettled(data) {
|
|
14
|
-
if (data?.routes?.[0]) {
|
|
15
|
-
setInsuredRoute(data.routes[0]);
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
12
|
});
|
|
19
|
-
const
|
|
13
|
+
const insuredRoute = routes?.[0];
|
|
14
|
+
const toggleInsurance = (checked) => {
|
|
20
15
|
if (insuredRoute) {
|
|
21
16
|
if (checked) {
|
|
22
17
|
setExecutableRoute(insuredRoute, insurableRouteId);
|
|
@@ -24,5 +19,8 @@ export const InsuranceCollapsed = ({ status, insurableRouteId, insuranceCoverage
|
|
|
24
19
|
onChange?.(checked ? insuredRoute.id : insurableRouteId);
|
|
25
20
|
}
|
|
26
21
|
};
|
|
27
|
-
|
|
22
|
+
if (!insuredRoute) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return (_jsx(Collapse, { timeout: 225, in: insuredRoute.insurance.state === 'INSURED', unmountOnExit: true, mountOnEnter: true, appear: status === RouteExecutionStatus.Idle, children: _jsx(InsuranceCard, { ...props, status: status, insuredAmount: formatTokenAmount(insuredRoute.toAmountMin, insuredRoute.toToken.decimals), insuredTokenSymbol: insuredRoute.toToken.symbol, onChange: toggleInsurance }) }));
|
|
28
26
|
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { BoxProps } from '@mui/material';
|
|
3
2
|
import type { RouteExecutionStatus } from '../../stores';
|
|
4
|
-
export interface
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export interface InsuredAmount {
|
|
4
|
+
insuredAmount: string;
|
|
5
|
+
insuredTokenSymbol: string;
|
|
6
|
+
}
|
|
7
|
+
interface Insurance extends InsuredAmount {
|
|
8
|
+
feeAmountUsd: string;
|
|
7
9
|
insuranceCoverageId?: string;
|
|
8
10
|
status?: RouteExecutionStatus;
|
|
11
|
+
}
|
|
12
|
+
export interface InsuranceProps extends Insurance, Omit<BoxProps, 'onChange'> {
|
|
13
|
+
insurableRouteId: string;
|
|
9
14
|
onChange?: (routeId: string) => void;
|
|
10
15
|
}
|
|
11
|
-
export interface InsuranceCardProps {
|
|
12
|
-
|
|
13
|
-
status?: RouteExecutionStatus;
|
|
14
|
-
insuranceCoverageId?: string;
|
|
15
|
-
onChange?: (_: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
|
|
16
|
+
export interface InsuranceCardProps extends Insurance, Omit<BoxProps, 'onChange'> {
|
|
17
|
+
onChange?: (checked: boolean) => void;
|
|
16
18
|
}
|
|
19
|
+
export {};
|
package/components/NFT/NFT.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
import { SwapFormKey } from '../../providers';
|
|
7
7
|
import { Token } from '../Token';
|
|
8
8
|
import { PreviewAvatar } from './NFT.style';
|
|
9
|
-
export const NFT = ({ imageUrl, isLoading,
|
|
9
|
+
export const NFT = ({ imageUrl, isLoading, collectionName, assetName, owner, token, contract, ...props }) => {
|
|
10
10
|
const { t } = useTranslation();
|
|
11
11
|
const { setValue } = useFormContext();
|
|
12
12
|
useEffect(() => {
|
|
@@ -21,5 +21,5 @@ export const NFT = ({ imageUrl, isLoading, collectonName, assetName, owner, toke
|
|
|
21
21
|
setValue(SwapFormKey.ToContractGasLimit, contract.gasLimit);
|
|
22
22
|
}
|
|
23
23
|
}, [contract, setValue, token]);
|
|
24
|
-
return (_jsxs(Box, { p: 2, children: [_jsxs(Box, { display: "flex", children: [isLoading ? (_jsx(Skeleton, { width: 96, height: 96, variant: "rectangular", sx: { borderRadius: 1 } })) : (_jsx(PreviewAvatar, { src: imageUrl })), _jsxs(Box, { ml: 2, children: [isLoading ? (_jsx(Skeleton, { width: 144, height: 21, variant: "text" })) : (_jsx(Typography, { fontSize: 14, color: "text.secondary", children:
|
|
24
|
+
return (_jsxs(Box, { p: 2, children: [_jsxs(Box, { display: "flex", children: [isLoading ? (_jsx(Skeleton, { width: 96, height: 96, variant: "rectangular", sx: { borderRadius: 1 } })) : (_jsx(PreviewAvatar, { src: imageUrl })), _jsxs(Box, { ml: 2, children: [isLoading ? (_jsx(Skeleton, { width: 144, height: 21, variant: "text" })) : (_jsx(Typography, { fontSize: 14, color: "text.secondary", children: collectionName })), isLoading ? (_jsx(Skeleton, { width: 112, height: 27, variant: "text" })) : (_jsx(Typography, { fontSize: 18, fontWeight: 600, children: assetName })), isLoading ? (_jsx(Skeleton, { width: 128, height: 21, variant: "text" })) : owner ? (_jsxs(Typography, { fontSize: 14, color: "text.secondary", children: [t('swap.ownedBy'), ' ', _jsx(Link, { href: owner.url, target: "_blank", underline: "none", color: "primary", children: owner.name })] })) : null] })] }), _jsx(Token, { token: token, isLoading: isLoading, mt: 2 })] }));
|
|
25
25
|
};
|
|
@@ -5,7 +5,6 @@ import { version } from '../../config/version';
|
|
|
5
5
|
import { useWidgetConfig } from '../../providers';
|
|
6
6
|
import { HiddenUI } from '../../types';
|
|
7
7
|
import { navigationRoutes } from '../../utils';
|
|
8
|
-
import { LiFiLogo } from '../LiFiLogo';
|
|
9
8
|
import { Link } from './PoweredBy.style';
|
|
10
9
|
export const PoweredBy = () => {
|
|
11
10
|
const { hiddenUI } = useWidgetConfig();
|
|
@@ -14,9 +13,9 @@ export const PoweredBy = () => {
|
|
|
14
13
|
pathname.includes(navigationRoutes.toToken)) {
|
|
15
14
|
return null;
|
|
16
15
|
}
|
|
17
|
-
return (_jsx(Box, { px: 3,
|
|
16
|
+
return (_jsx(Box, { px: 3, pt: 1, pb: hiddenUI?.includes(HiddenUI.PoweredBy) ? 1 : 2, sx: {
|
|
18
17
|
display: 'flex',
|
|
19
18
|
alignItems: 'flex-end',
|
|
20
19
|
justifyContent: 'flex-end',
|
|
21
|
-
}, children: !hiddenUI?.includes(HiddenUI.PoweredBy) ? (_jsx(Tooltip, { title: `v${version}`, placement: "top", enterDelay:
|
|
20
|
+
}, children: !hiddenUI?.includes(HiddenUI.PoweredBy) ? (_jsx(Tooltip, { title: `v${version}`, placement: "top", enterDelay: 1000, arrow: true, children: _jsxs(Link, { href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary", children: [_jsx(Typography, { color: "text.secondary", fontSize: 12, fontWeight: 500, px: 0.5, children: "Powered by" }), _jsx(Typography, { color: "text.primary", fontSize: 12, fontWeight: 500, children: "LI.FI" })] }) })) : null }));
|
|
22
21
|
};
|
|
@@ -4,10 +4,10 @@ import { useWatch } from 'react-hook-form';
|
|
|
4
4
|
import { ReverseTokensButton } from '../components/ReverseTokensButton';
|
|
5
5
|
import { SelectTokenButton } from '../components/SelectTokenButton';
|
|
6
6
|
import { SwapFormKey, useWidgetConfig } from '../providers';
|
|
7
|
-
import { DisabledUI } from '../types';
|
|
7
|
+
import { DisabledUI, HiddenUI } from '../types';
|
|
8
8
|
export const SelectChainAndToken = (props) => {
|
|
9
9
|
const prefersNarrowView = useMediaQuery((theme) => theme.breakpoints.down('sm'));
|
|
10
|
-
const { disabledUI, variant } = useWidgetConfig();
|
|
10
|
+
const { disabledUI, hiddenUI, variant } = useWidgetConfig();
|
|
11
11
|
const [fromChain, toChain, fromToken, toToken] = useWatch({
|
|
12
12
|
name: [
|
|
13
13
|
SwapFormKey.FromChain,
|
|
@@ -16,19 +16,20 @@ export const SelectChainAndToken = (props) => {
|
|
|
16
16
|
SwapFormKey.ToToken,
|
|
17
17
|
],
|
|
18
18
|
});
|
|
19
|
-
const
|
|
19
|
+
const hiddenReverse = variant === 'refuel' ||
|
|
20
20
|
disabledUI?.includes(DisabledUI.FromToken) ||
|
|
21
|
-
disabledUI?.includes(DisabledUI.ToToken)
|
|
22
|
-
|
|
21
|
+
disabledUI?.includes(DisabledUI.ToToken) ||
|
|
22
|
+
hiddenUI?.includes(HiddenUI.ToToken);
|
|
23
|
+
const hiddenToToken = variant === 'nft' || hiddenUI?.includes(HiddenUI.ToToken);
|
|
23
24
|
const isCompact = fromChain &&
|
|
24
25
|
toChain &&
|
|
25
26
|
fromToken &&
|
|
26
27
|
toToken &&
|
|
27
28
|
!prefersNarrowView &&
|
|
28
|
-
!
|
|
29
|
-
return (_jsxs(Box, { sx: { display: 'flex', flexDirection: isCompact ? 'row' : 'column' }, ...props, children: [_jsx(SelectTokenButton, { formType: "from", compact: isCompact }), !
|
|
29
|
+
!hiddenToToken;
|
|
30
|
+
return (_jsxs(Box, { sx: { display: 'flex', flexDirection: isCompact ? 'row' : 'column' }, ...props, children: [_jsx(SelectTokenButton, { formType: "from", compact: isCompact }), !hiddenToToken ? (_jsx(Box, { sx: {
|
|
30
31
|
display: 'flex',
|
|
31
32
|
justifyContent: 'center',
|
|
32
33
|
alignItems: 'center',
|
|
33
|
-
}, m: !
|
|
34
|
+
}, m: !hiddenReverse ? -1.125 : 1, children: !hiddenReverse ? (_jsx(ReverseTokensButton, { vertical: !isCompact })) : null })) : null, !hiddenToToken ? (_jsx(SelectTokenButton, { formType: "to", compact: isCompact })) : null] }));
|
|
34
35
|
};
|
|
@@ -3,7 +3,7 @@ import { Skeleton } from '@mui/material';
|
|
|
3
3
|
import { useWatch } from 'react-hook-form';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { useNavigate } from 'react-router-dom';
|
|
6
|
-
import { useChain, useToken } from '../../hooks';
|
|
6
|
+
import { useChain, useSwapOnly, useToken } from '../../hooks';
|
|
7
7
|
import { SwapFormKeyHelper, useWidgetConfig } from '../../providers';
|
|
8
8
|
import { navigationRoutes } from '../../utils';
|
|
9
9
|
import { Card, CardTitle } from '../Card';
|
|
@@ -13,6 +13,7 @@ export const SelectTokenButton = ({ formType, compact }) => {
|
|
|
13
13
|
const { t } = useTranslation();
|
|
14
14
|
const navigate = useNavigate();
|
|
15
15
|
const { disabledUI, variant } = useWidgetConfig();
|
|
16
|
+
const swapOnly = useSwapOnly();
|
|
16
17
|
const tokenKey = SwapFormKeyHelper.getTokenKey(formType);
|
|
17
18
|
const [chainId, tokenAddress] = useWatch({
|
|
18
19
|
name: [SwapFormKeyHelper.getChainKey(formType), tokenKey],
|
|
@@ -29,10 +30,12 @@ export const SelectTokenButton = ({ formType, compact }) => {
|
|
|
29
30
|
const isSelected = !!(chain && token);
|
|
30
31
|
const onClick = !disabledUI?.includes(tokenKey) ? handleClick : undefined;
|
|
31
32
|
const defaultPlaceholder = formType === 'to' && variant === 'refuel'
|
|
32
|
-
? t(
|
|
33
|
-
:
|
|
33
|
+
? t('swap.selectChain')
|
|
34
|
+
: formType === 'to' && swapOnly
|
|
35
|
+
? t('swap.selectToken')
|
|
36
|
+
: t('swap.selectChainAndToken');
|
|
34
37
|
const cardTitle = formType === 'from' && variant === 'nft'
|
|
35
|
-
? t(`
|
|
38
|
+
? t(`header.payWith`)
|
|
36
39
|
: t(`swap.${formType}`);
|
|
37
40
|
return (_jsxs(Card, { flex: 1, onClick: onClick, children: [_jsx(CardTitle, { children: cardTitle }), chainId && tokenAddress && (isChainLoading || isTokenLoading) ? (_jsx(SelectTokenCardHeader, { avatar: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }), title: _jsx(Skeleton, { variant: "text", width: 64, height: 24 }), subheader: _jsx(Skeleton, { variant: "text", width: 64, height: 16 }), compact: compact })) : (_jsx(SelectTokenCardHeader, { avatar: isSelected ? (_jsx(TokenAvatar, { token: token, chain: chain })) : (_jsx(TokenAvatarDefault, {})), title: isSelected ? token.symbol : defaultPlaceholder, subheader: isSelected ? t(`swap.onChain`, { chainName: chain.name }) : null, selected: isSelected, compact: compact }))] }));
|
|
38
41
|
};
|
|
@@ -12,7 +12,7 @@ import { FormControl, Input } from './SendToWallet.style';
|
|
|
12
12
|
export const SendToWallet = forwardRef((props, ref) => {
|
|
13
13
|
const { t } = useTranslation();
|
|
14
14
|
const { trigger, getValues, clearErrors } = useFormContext();
|
|
15
|
-
const { account
|
|
15
|
+
const { account } = useWallet();
|
|
16
16
|
const { disabledUI, hiddenUI, requiredUI, toAddress } = useWidgetConfig();
|
|
17
17
|
const { showSendToWallet, showSendToWalletDirty, setSendToWallet } = useSendToWalletStore();
|
|
18
18
|
const { showDestinationWallet } = useSettings(['showDestinationWallet']);
|
|
@@ -30,7 +30,7 @@ export const SendToWallet = forwardRef((props, ref) => {
|
|
|
30
30
|
if (!value) {
|
|
31
31
|
return true;
|
|
32
32
|
}
|
|
33
|
-
const address = await provider?.resolveName(value);
|
|
33
|
+
const address = await account.signer?.provider?.resolveName(value);
|
|
34
34
|
return (isAddress(address || value) ||
|
|
35
35
|
t('swap.error.title.walletAddressInvalid'));
|
|
36
36
|
}
|