@lifi/widget 1.15.1 → 1.17.0
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.js +21 -0
- package/AppProvider.d.ts +0 -4
- package/AppProvider.js +2 -10
- package/README.md +1 -1
- package/cjs/App.js +21 -0
- package/cjs/AppProvider.d.ts +0 -4
- package/cjs/AppProvider.js +3 -12
- package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +30 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +40 -0
- package/cjs/components/ActiveSwaps/index.d.ts +2 -0
- package/cjs/components/ActiveSwaps/index.js +18 -0
- package/cjs/components/AppContainer.js +2 -2
- package/cjs/components/Card/Card.d.ts +7 -4
- package/cjs/components/Card/Card.js +38 -28
- package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/cjs/components/ChainSelect/ChainSelect.js +35 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/cjs/components/ChainSelect/ChainSelect.style.js +19 -0
- package/cjs/components/ChainSelect/index.d.ts +2 -0
- package/cjs/components/ChainSelect/index.js +18 -0
- package/cjs/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/cjs/components/ChainSelect/useChainSelect.js +33 -0
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
- package/cjs/components/Header/Header.js +1 -9
- package/cjs/components/Header/NavigationHeader.js +6 -11
- package/cjs/components/Header/useHeaderActionStore.d.ts +0 -2
- package/cjs/components/Header/useHeaderActionStore.js +1 -5
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
- package/cjs/components/SelectChainAndToken.js +5 -5
- package/cjs/components/SendToWallet/SendToWallet.js +6 -6
- package/cjs/components/Step/CircularProgress.js +1 -1
- package/cjs/components/Step/CircularProgress.style.js +1 -1
- package/cjs/components/Step/StepProcess.js +1 -5
- package/cjs/components/Step/StepProcess.style.d.ts +1 -1
- package/cjs/components/Step/StepTimer.d.ts +1 -0
- package/cjs/components/Step/StepTimer.js +6 -6
- package/cjs/components/SwapButton/SwapButton.js +5 -32
- package/cjs/components/SwapButton/types.d.ts +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/cjs/components/TokenList/TokenList.js +7 -3
- package/cjs/components/TokenList/TokenList.style.js +4 -3
- package/cjs/components/TokenList/TokenListItem.js +1 -1
- package/cjs/components/TokenList/TokenNotFound.d.ts +2 -1
- package/cjs/components/TokenList/TokenNotFound.js +12 -2
- package/cjs/components/TokenList/types.d.ts +2 -2
- package/cjs/config/theme.js +24 -23
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +2 -0
- package/cjs/hooks/index.js +2 -0
- package/cjs/hooks/useChains.d.ts +1 -97
- package/cjs/hooks/useChains.js +26 -20
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFeaturedTokens.js +6 -3
- package/cjs/hooks/useGasSufficiency.d.ts +1 -1
- package/cjs/hooks/useGasSufficiency.js +36 -28
- package/cjs/hooks/useInitializer.js +6 -0
- package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
- package/cjs/hooks/useRouteExecution.d.ts +1 -1
- package/cjs/hooks/useRouteExecution.js +26 -35
- package/cjs/hooks/useSwapRoutes.js +10 -11
- package/cjs/hooks/useToken.d.ts +0 -1
- package/cjs/hooks/useToken.js +1 -2
- package/cjs/hooks/useTokenBalances.d.ts +1 -2
- package/cjs/hooks/useTokenBalances.js +5 -6
- package/cjs/hooks/useTokenSearch.js +3 -2
- package/cjs/hooks/useTokens.d.ts +1 -2
- package/cjs/hooks/useTokens.js +32 -9
- package/cjs/hooks/useTools.js +11 -5
- package/cjs/hooks/useWidgetEvents.d.ts +3 -0
- package/cjs/hooks/useWidgetEvents.js +13 -0
- package/cjs/i18n/en/translation.json +14 -10
- package/cjs/i18n/index.d.ts +11 -7
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
- package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/cjs/{components/SwapsInProgress → pages/ActiveSwapsPage}/index.js +1 -1
- package/cjs/pages/MainPage/MainPage.js +2 -3
- package/cjs/pages/MainPage/MainSwapButton.js +3 -1
- package/cjs/pages/MainPage/SwapRoutes.js +4 -1
- package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
- package/cjs/pages/SelectChainPage/index.d.ts +1 -0
- package/cjs/pages/SelectChainPage/index.js +17 -0
- package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +4 -4
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/cjs/pages/SettingsPage/AdvancedPreferences.js +1 -1
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
- package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +6 -2
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +1 -1
- package/cjs/pages/SettingsPage/SlippageInput.js +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +3 -4
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -3
- package/cjs/pages/SwapPage/StatusBottomSheet.js +25 -36
- package/cjs/pages/SwapPage/SwapPage.js +16 -3
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +4 -3
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
- package/cjs/providers/SDKProvider/index.d.ts +1 -0
- package/cjs/providers/SDKProvider/index.js +17 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +4 -30
- package/cjs/providers/SwapFormProvider/types.d.ts +5 -5
- package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
- package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
- package/cjs/providers/TelemetryProvider/index.js +17 -0
- package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/cjs/providers/WalletProvider/WalletProvider.js +59 -1
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -16
- package/cjs/providers/WidgetProvider/index.d.ts +1 -0
- package/cjs/providers/WidgetProvider/index.js +1 -0
- package/cjs/providers/WidgetProvider/utils.d.ts +4 -0
- package/cjs/providers/WidgetProvider/utils.js +13 -0
- package/cjs/providers/index.d.ts +2 -0
- package/cjs/providers/index.js +2 -0
- package/cjs/stores/chains/index.d.ts +3 -0
- package/cjs/stores/chains/index.js +19 -0
- package/cjs/stores/chains/types.d.ts +8 -0
- package/cjs/stores/chains/types.js +2 -0
- package/cjs/stores/chains/useChainOrder.d.ts +1 -0
- package/cjs/stores/chains/useChainOrder.js +12 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
- package/cjs/stores/chains/useChainOrderStore.js +45 -0
- package/cjs/stores/route/index.d.ts +2 -1
- package/cjs/stores/route/index.js +2 -1
- package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
- package/cjs/stores/route/useRouteStore.js +5 -4
- package/cjs/stores/route/utils.d.ts +4 -0
- package/cjs/stores/route/utils.js +21 -0
- package/cjs/stores/settings/index.d.ts +0 -1
- package/cjs/stores/settings/index.js +0 -1
- package/cjs/stores/settings/useAppearance.js +3 -1
- package/cjs/stores/settings/useSettingsStore.js +5 -2
- package/cjs/types/events.d.ts +5 -0
- package/cjs/types/events.js +9 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/widget.d.ts +31 -23
- package/cjs/utils/colors.d.ts +1 -1
- package/cjs/utils/navigationRoutes.d.ts +5 -0
- package/cjs/utils/navigationRoutes.js +31 -4
- package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
- package/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/components/ActiveSwaps/ActiveSwaps.js +26 -0
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
- package/components/ActiveSwaps/index.d.ts +2 -0
- package/components/ActiveSwaps/index.js +2 -0
- package/components/AppContainer.js +1 -1
- package/components/Card/Card.d.ts +7 -4
- package/components/Card/Card.js +39 -29
- package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/components/ChainSelect/ChainSelect.js +31 -0
- package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/components/ChainSelect/ChainSelect.style.js +16 -0
- package/components/ChainSelect/index.d.ts +2 -0
- package/components/ChainSelect/index.js +2 -0
- package/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/components/ChainSelect/useChainSelect.js +29 -0
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
- package/components/Header/Header.js +1 -9
- package/components/Header/NavigationHeader.js +6 -11
- package/components/Header/useHeaderActionStore.d.ts +0 -2
- package/components/Header/useHeaderActionStore.js +0 -3
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.js +1 -0
- package/components/SelectChainAndToken.js +1 -1
- package/components/SendToWallet/SendToWallet.js +6 -6
- package/components/Step/CircularProgress.js +3 -3
- package/components/Step/CircularProgress.style.js +1 -1
- package/components/Step/StepProcess.js +2 -6
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/Step/StepTimer.d.ts +1 -0
- package/components/Step/StepTimer.js +6 -6
- package/components/SwapButton/SwapButton.js +7 -34
- package/components/SwapButton/types.d.ts +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/components/TokenList/TokenList.js +7 -3
- package/components/TokenList/TokenList.style.js +4 -3
- package/components/TokenList/TokenListItem.js +1 -1
- package/components/TokenList/TokenNotFound.d.ts +2 -1
- package/components/TokenList/TokenNotFound.js +12 -2
- package/components/TokenList/types.d.ts +2 -2
- package/config/theme.js +24 -23
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/hooks/useChains.d.ts +1 -97
- package/hooks/useChains.js +26 -20
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFeaturedTokens.js +6 -3
- package/hooks/useGasSufficiency.d.ts +1 -1
- package/hooks/useGasSufficiency.js +32 -24
- package/hooks/useInitializer.js +6 -0
- package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
- package/hooks/useRouteExecution.d.ts +1 -1
- package/hooks/useRouteExecution.js +26 -35
- package/hooks/useSwapRoutes.js +3 -4
- package/hooks/useToken.d.ts +0 -1
- package/hooks/useToken.js +1 -2
- package/hooks/useTokenBalances.d.ts +1 -2
- package/hooks/useTokenBalances.js +4 -5
- package/hooks/useTokenSearch.js +3 -2
- package/hooks/useTokens.d.ts +1 -2
- package/hooks/useTokens.js +32 -9
- package/hooks/useTools.js +11 -5
- package/hooks/useWidgetEvents.d.ts +3 -0
- package/hooks/useWidgetEvents.js +6 -0
- package/i18n/en/translation.json +14 -10
- package/i18n/index.d.ts +11 -7
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +15 -14
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
- package/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/pages/ActiveSwapsPage/index.js +1 -0
- package/pages/MainPage/MainPage.js +2 -3
- package/pages/MainPage/MainSwapButton.js +3 -1
- package/pages/MainPage/SwapRoutes.js +4 -1
- package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/pages/SelectChainPage/SelectChainPage.js +29 -0
- package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
- package/pages/SelectChainPage/index.d.ts +1 -0
- package/pages/SelectChainPage/index.js +1 -0
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
- package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
- package/pages/SettingsPage/GasPriceSelect.js +2 -2
- package/pages/SettingsPage/RoutePrioritySelect.js +7 -3
- package/pages/SettingsPage/ShowDestinationWallet.js +2 -2
- package/pages/SettingsPage/SlippageInput.js +2 -2
- package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -5
- package/pages/SwapHistoryPage/SwapHistoryPage.js +3 -4
- package/pages/SwapPage/StatusBottomSheet.js +27 -38
- package/pages/SwapPage/SwapPage.js +16 -3
- package/pages/SwapRoutesPage/SwapRoutesPage.js +5 -4
- package/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/providers/SDKProvider/SDKProvider.js +19 -0
- package/providers/SDKProvider/index.d.ts +1 -0
- package/providers/SDKProvider/index.js +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +4 -30
- package/providers/SwapFormProvider/types.d.ts +5 -5
- package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
- package/providers/TelemetryProvider/index.d.ts +1 -0
- package/providers/TelemetryProvider/index.js +1 -0
- package/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/providers/WalletProvider/WalletProvider.js +59 -1
- package/providers/WidgetProvider/WidgetProvider.js +3 -18
- package/providers/WidgetProvider/index.d.ts +1 -0
- package/providers/WidgetProvider/index.js +1 -0
- package/providers/WidgetProvider/utils.d.ts +4 -0
- package/providers/WidgetProvider/utils.js +9 -0
- package/providers/index.d.ts +2 -0
- package/providers/index.js +2 -0
- package/stores/chains/index.d.ts +3 -0
- package/stores/chains/index.js +3 -0
- package/stores/chains/types.d.ts +8 -0
- package/stores/chains/types.js +1 -0
- package/stores/chains/useChainOrder.d.ts +1 -0
- package/stores/chains/useChainOrder.js +5 -0
- package/stores/chains/useChainOrderStore.d.ts +19 -0
- package/stores/chains/useChainOrderStore.js +39 -0
- package/stores/route/index.d.ts +2 -1
- package/stores/route/index.js +2 -1
- package/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/stores/route/useExecutingRoutesIds.js +13 -0
- package/stores/route/useRouteStore.js +5 -4
- package/stores/route/utils.d.ts +4 -0
- package/stores/route/utils.js +15 -0
- package/stores/settings/index.d.ts +0 -1
- package/stores/settings/index.js +0 -1
- package/stores/settings/useAppearance.js +3 -1
- package/stores/settings/useSettingsStore.js +5 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +5 -0
- package/types/events.js +6 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/widget.d.ts +31 -23
- package/utils/colors.d.ts +1 -1
- package/utils/navigationRoutes.d.ts +5 -0
- package/utils/navigationRoutes.js +30 -3
- package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/cjs/components/SwapButton/SwapButton.style.js +0 -15
- package/cjs/components/SwapsInProgress/SwapsInProgress.js +0 -29
- package/cjs/components/SwapsInProgress/SwapsInProgress.style.js +0 -17
- package/cjs/components/SwapsInProgress/index.d.ts +0 -1
- package/cjs/config/lifi.d.ts +0 -4
- package/cjs/config/lifi.js +0 -14
- package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -31
- package/cjs/pages/SwapPage/utils.d.ts +0 -6
- package/cjs/pages/SwapPage/utils.js +0 -93
- package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
- package/cjs/stores/route/useExecutingRoutes.js +0 -13
- package/cjs/stores/settings/useSetSettings.d.ts +0 -5
- package/cjs/stores/settings/useSetSettings.js +0 -12
- package/components/Step/utils.js +0 -89
- package/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/components/SwapButton/SwapButton.style.js +0 -12
- package/components/SwapsInProgress/SwapsInProgress.js +0 -25
- package/components/SwapsInProgress/SwapsInProgress.style.js +0 -14
- package/components/SwapsInProgress/index.d.ts +0 -1
- package/components/SwapsInProgress/index.js +0 -1
- package/config/lifi.d.ts +0 -4
- package/config/lifi.js +0 -7
- package/pages/SelectTokenPage/ChainSelect.js +0 -27
- package/pages/SwapPage/utils.d.ts +0 -6
- package/stores/route/useExecutingRoutes.d.ts +0 -2
- package/stores/route/useExecutingRoutes.js +0 -6
- package/stores/settings/useSetSettings.d.ts +0 -5
- package/stores/settings/useSetSettings.js +0 -5
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import type { Theme } from '@mui/material';
|
|
1
2
|
import type { MouseEventHandler } from 'react';
|
|
2
|
-
|
|
3
|
+
declare type CardVariant = 'default' | 'selected' | 'error';
|
|
4
|
+
export declare const Card: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
3
5
|
children?: import("react").ReactNode;
|
|
4
6
|
component?: import("react").ElementType<any> | undefined;
|
|
5
7
|
ref?: import("react").Ref<unknown> | undefined;
|
|
6
|
-
sx?: import("@mui/material").SxProps<
|
|
8
|
+
sx?: import("@mui/material").SxProps<Theme> | undefined;
|
|
7
9
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
8
10
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
9
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<
|
|
10
|
-
variant?:
|
|
11
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
12
|
+
variant?: CardVariant | undefined;
|
|
11
13
|
dense?: boolean | undefined;
|
|
12
14
|
indented?: boolean | undefined;
|
|
13
15
|
onClick?: MouseEventHandler<HTMLDivElement> | undefined;
|
|
14
16
|
}, {}, {}>;
|
|
17
|
+
export {};
|
package/components/Card/Card.js
CHANGED
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
import { Box } from '@mui/material';
|
|
2
|
-
import { darken, lighten, styled } from '@mui/material/styles';
|
|
2
|
+
import { alpha, darken, lighten, styled } from '@mui/material/styles';
|
|
3
|
+
const getBackgroundColor = (theme, variant) => variant === 'selected'
|
|
4
|
+
? theme.palette.mode === 'light'
|
|
5
|
+
? alpha(theme.palette.primary.main, 0.04)
|
|
6
|
+
: alpha(theme.palette.primary.main, 0.42)
|
|
7
|
+
: theme.palette.background.paper;
|
|
3
8
|
export const Card = styled(Box, {
|
|
4
9
|
shouldForwardProp: (prop) => !['dense', 'variant', 'indented'].includes(prop),
|
|
5
|
-
})(({ theme, variant, dense, indented, onClick }) =>
|
|
6
|
-
backgroundColor
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
:
|
|
11
|
-
? theme.palette.
|
|
12
|
-
:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
10
|
+
})(({ theme, variant, dense, indented, onClick }) => {
|
|
11
|
+
const backgroundColor = getBackgroundColor(theme, variant);
|
|
12
|
+
return {
|
|
13
|
+
backgroundColor,
|
|
14
|
+
border: `1px solid`,
|
|
15
|
+
borderColor: variant === 'error'
|
|
16
|
+
? theme.palette.error.main
|
|
17
|
+
: variant === 'selected'
|
|
18
|
+
? theme.palette.primary.main
|
|
19
|
+
: theme.palette.mode === 'light'
|
|
20
|
+
? theme.palette.grey[300]
|
|
21
|
+
: theme.palette.grey[800],
|
|
22
|
+
borderRadius: dense
|
|
23
|
+
? theme.shape.borderRadiusSecondary
|
|
24
|
+
: theme.shape.borderRadius,
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
position: 'relative',
|
|
27
|
+
padding: indented ? theme.spacing(2) : 0,
|
|
28
|
+
boxSizing: 'border-box',
|
|
29
|
+
'&:hover': {
|
|
30
|
+
cursor: onClick ? 'pointer' : 'default',
|
|
31
|
+
backgroundColor: onClick
|
|
32
|
+
? theme.palette.mode === 'light'
|
|
33
|
+
? darken(backgroundColor, 0.02)
|
|
34
|
+
: lighten(backgroundColor, 0.02)
|
|
35
|
+
: theme.palette.background.paper,
|
|
36
|
+
},
|
|
37
|
+
transition: theme.transitions.create(['background-color'], {
|
|
38
|
+
duration: theme.transitions.duration.enteringScreen,
|
|
39
|
+
easing: theme.transitions.easing.easeOut,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar, Box, Skeleton, Typography } from '@mui/material';
|
|
3
|
+
import { useWatch } from 'react-hook-form';
|
|
4
|
+
import { useNavigate } from 'react-router-dom';
|
|
5
|
+
import { SwapFormKeyHelper } from '../../providers';
|
|
6
|
+
import { maxChainToOrder } from '../../stores/chains';
|
|
7
|
+
import { navigationRoutes } from '../../utils';
|
|
8
|
+
import { ChainCard, ChainContainer } from './ChainSelect.style';
|
|
9
|
+
import { useChainSelect } from './useChainSelect';
|
|
10
|
+
export const ChainSelect = ({ formType }) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
const { chains, getChains, setCurrentChain, isLoading } = useChainSelect(formType);
|
|
14
|
+
const [chainId] = useWatch({
|
|
15
|
+
name: [SwapFormKeyHelper.getChainKey(formType)],
|
|
16
|
+
});
|
|
17
|
+
const showAllChains = () => {
|
|
18
|
+
navigate(navigationRoutes[`${formType}Chain`], {
|
|
19
|
+
state: { formType },
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const chainsToHide = ((_a = chains === null || chains === void 0 ? void 0 : chains.length) !== null && _a !== void 0 ? _a : 0) - maxChainToOrder;
|
|
23
|
+
return (_jsxs(ChainContainer, { children: [isLoading
|
|
24
|
+
? Array.from({ length: maxChainToOrder + 1 }).map((_, index) => (_jsx(Skeleton, { variant: "rectangular", width: 56, height: 56, sx: { borderRadius: 1 } }, index)))
|
|
25
|
+
: getChains().map((chain) => (_jsx(ChainCard, Object.assign({ onClick: () => setCurrentChain(chain.id), variant: chainId === chain.id ? 'selected' : 'default' }, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.key, sx: { width: 40, height: 40 } }, { children: chain.name[0] })) }), chain.id))), chainsToHide > 0 ? (_jsx(ChainCard, Object.assign({ onClick: showAllChains }, { children: _jsx(Box, Object.assign({ sx: {
|
|
26
|
+
width: 40,
|
|
27
|
+
height: 40,
|
|
28
|
+
display: 'grid',
|
|
29
|
+
placeItems: 'center',
|
|
30
|
+
} }, { children: _jsxs(Typography, Object.assign({ fontWeight: 500 }, { children: ["+", chainsToHide] })) })) }))) : null] }));
|
|
31
|
+
};
|
package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts}
RENAMED
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const ChainCard: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
component?: import("react").ElementType<any> | undefined;
|
|
5
5
|
ref?: import("react").Ref<unknown> | undefined;
|
|
6
|
-
sx?: import("@mui/material
|
|
6
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
7
7
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
8
8
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
9
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material
|
|
10
|
-
variant?: "default" | "error" | undefined;
|
|
9
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
10
|
+
variant?: ("default" | "error" | "selected") | undefined;
|
|
11
11
|
dense?: boolean | undefined;
|
|
12
12
|
indented?: boolean | undefined;
|
|
13
13
|
onClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
14
14
|
}, {}, {}>;
|
|
15
|
-
export declare const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
subheader?: import("react").ReactNode;
|
|
21
|
-
subheaderTypographyProps?: import("@mui/material").TypographyProps<"span", {
|
|
22
|
-
component?: "span" | undefined;
|
|
23
|
-
}> | undefined;
|
|
24
|
-
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
25
|
-
title?: import("react").ReactNode;
|
|
26
|
-
titleTypographyProps?: import("@mui/material").TypographyProps<"span", {
|
|
27
|
-
component?: "span" | undefined;
|
|
28
|
-
}> | undefined;
|
|
15
|
+
export declare const ChainContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
16
|
+
children?: import("react").ReactNode;
|
|
17
|
+
component?: import("react").ElementType<any> | undefined;
|
|
18
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
19
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
29
20
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
30
21
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
31
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "
|
|
22
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Box } from '@mui/material';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { Card } from '../../components/Card';
|
|
4
|
+
export const ChainCard = styled(Card)({
|
|
5
|
+
display: 'grid',
|
|
6
|
+
placeItems: 'center',
|
|
7
|
+
minWidth: 56,
|
|
8
|
+
height: 56,
|
|
9
|
+
});
|
|
10
|
+
export const ChainContainer = styled(Box)(({ theme }) => ({
|
|
11
|
+
display: 'grid',
|
|
12
|
+
gridTemplateColumns: 'repeat(auto-fit, minmax(56px, 1fr))',
|
|
13
|
+
gridAutoRows: '56px',
|
|
14
|
+
justifyContent: 'space-between',
|
|
15
|
+
gap: theme.spacing(1.5),
|
|
16
|
+
}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EVMChain } from '@lifi/sdk';
|
|
2
|
+
import type { SwapFormType } from '../../providers';
|
|
3
|
+
export declare const useChainSelect: (formType: SwapFormType) => {
|
|
4
|
+
chains: EVMChain[] | undefined;
|
|
5
|
+
getChains: () => EVMChain[];
|
|
6
|
+
setCurrentChain: (chainId: number) => void;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useFormContext } from 'react-hook-form';
|
|
2
|
+
import { useChains } from '../../hooks';
|
|
3
|
+
import { SwapFormKey, SwapFormKeyHelper } from '../../providers';
|
|
4
|
+
import { useChainOrder } from '../../stores/chains';
|
|
5
|
+
export const useChainSelect = (formType) => {
|
|
6
|
+
const { setValue } = useFormContext();
|
|
7
|
+
const { chains, isLoading } = useChains();
|
|
8
|
+
const [chainOrder, setChainOrder] = useChainOrder();
|
|
9
|
+
const chainKey = SwapFormKeyHelper.getChainKey(formType);
|
|
10
|
+
const getChains = () => {
|
|
11
|
+
if (!chains) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const selectedChains = chainOrder
|
|
15
|
+
.map((chainId) => chains.find((chain) => chain.id === chainId))
|
|
16
|
+
.filter((chain) => chain);
|
|
17
|
+
return selectedChains;
|
|
18
|
+
};
|
|
19
|
+
const setCurrentChain = (chainId) => {
|
|
20
|
+
setValue(chainKey, chainId, { shouldDirty: true });
|
|
21
|
+
setValue(SwapFormKeyHelper.getTokenKey(formType), '', {
|
|
22
|
+
shouldDirty: false,
|
|
23
|
+
});
|
|
24
|
+
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
25
|
+
setValue(SwapFormKey.TokenSearchFilter, '');
|
|
26
|
+
setChainOrder(chainId);
|
|
27
|
+
};
|
|
28
|
+
return { chains, getChains, setCurrentChain, isLoading };
|
|
29
|
+
};
|
|
@@ -20,15 +20,15 @@ export const GasSufficiencyMessage = (_a) => {
|
|
|
20
20
|
var { route } = _a, props = __rest(_a, ["route"]);
|
|
21
21
|
const { t } = useTranslation();
|
|
22
22
|
const { insufficientFunds, insufficientGas } = useGasSufficiency(route);
|
|
23
|
-
if (!insufficientFunds && !insufficientGas.length) {
|
|
23
|
+
if (!insufficientFunds && !(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
return (_jsxs(MessageCard, Object.assign({}, props, { children: [_jsx(WarningIcon, { sx: {
|
|
27
27
|
marginTop: 2,
|
|
28
28
|
marginLeft: 2,
|
|
29
|
-
} }), _jsxs(Box, { children: [insufficientGas.length ? (_jsx(CardTitle, { children: t(`swap.warning.title.insufficientGas`) })) : null, insufficientFunds ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length ? 0 : 2, pt: insufficientGas.length ? 1 : 2 }, { children: insufficientFunds
|
|
29
|
+
} }), _jsxs(Box, { children: [(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? (_jsx(CardTitle, { children: t(`swap.warning.title.insufficientGas`) })) : null, insufficientFunds ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 0 : 2, pt: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 1 : 2 }, { children: insufficientFunds
|
|
30
30
|
? t(`swap.warning.message.insufficientFunds`)
|
|
31
|
-
: null }))) : null, insufficientGas.length ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pt: 1 }, { children: t(`swap.warning.message.insufficientGas`) }))) : null, insufficientGas.length
|
|
31
|
+
: null }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pt: 1 }, { children: t(`swap.warning.message.insufficientGas`) }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)
|
|
32
32
|
? insufficientGas.map((item, index) => {
|
|
33
33
|
var _a, _b;
|
|
34
34
|
return (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length - 1 === index ? 2 : 0, pt: 0.5 }, { children: t(`swap.tokenOnChainAmount`, {
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
3
|
import { useWidgetConfig } from '../../providers';
|
|
4
|
-
import { ElementId,
|
|
4
|
+
import { ElementId, stickyHeaderRoutes } from '../../utils';
|
|
5
5
|
import { Container } from './Header.style';
|
|
6
6
|
import { NavigationHeader } from './NavigationHeader';
|
|
7
7
|
import { WalletHeader } from './WalletHeader';
|
|
8
|
-
const stickyHeaderRoutes = [
|
|
9
|
-
navigationRoutes.selectWallet,
|
|
10
|
-
navigationRoutes.settings,
|
|
11
|
-
navigationRoutes.swapRoutes,
|
|
12
|
-
navigationRoutes.swapExecution,
|
|
13
|
-
navigationRoutes.swapHistory,
|
|
14
|
-
navigationRoutes.swapDetails,
|
|
15
|
-
];
|
|
16
8
|
const HeaderContainer = ({ children }) => {
|
|
17
9
|
const { pathname } = useLocation();
|
|
18
10
|
return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
@@ -5,19 +5,9 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
|
6
6
|
import { useNavigateBack } from '../../hooks';
|
|
7
7
|
import { useWallet } from '../../providers';
|
|
8
|
-
import { navigationRoutes, navigationRoutesValues } from '../../utils';
|
|
8
|
+
import { backButtonRoutes, navigationRoutes, navigationRoutesValues, } from '../../utils';
|
|
9
9
|
import { HeaderAppBar } from './Header.style';
|
|
10
10
|
import { useHeaderActionStore } from './useHeaderActionStore';
|
|
11
|
-
const backButtonRoutes = [
|
|
12
|
-
navigationRoutes.selectWallet,
|
|
13
|
-
navigationRoutes.settings,
|
|
14
|
-
navigationRoutes.swapHistory,
|
|
15
|
-
navigationRoutes.fromToken,
|
|
16
|
-
navigationRoutes.toToken,
|
|
17
|
-
navigationRoutes.swapRoutes,
|
|
18
|
-
navigationRoutes.swapExecution,
|
|
19
|
-
navigationRoutes.swapDetails,
|
|
20
|
-
];
|
|
21
11
|
export const NavigationHeader = () => {
|
|
22
12
|
const { t } = useTranslation();
|
|
23
13
|
const { navigate, navigateBack } = useNavigateBack();
|
|
@@ -38,8 +28,13 @@ export const NavigationHeader = () => {
|
|
|
38
28
|
return t(`header.from`);
|
|
39
29
|
case navigationRoutes.toToken:
|
|
40
30
|
return t(`header.to`);
|
|
31
|
+
case navigationRoutes.fromChain:
|
|
32
|
+
case navigationRoutes.toChain:
|
|
33
|
+
return t(`header.selectChain`);
|
|
41
34
|
case navigationRoutes.swapRoutes:
|
|
42
35
|
return t(`header.routes`);
|
|
36
|
+
case navigationRoutes.activeSwaps:
|
|
37
|
+
return t(`header.activeSwaps`);
|
|
43
38
|
case navigationRoutes.swapExecution:
|
|
44
39
|
return t(`header.swap`);
|
|
45
40
|
case navigationRoutes.swapDetails:
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { HeaderActionStore } from './types';
|
|
3
2
|
export declare const useHeaderActionStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<HeaderActionStore>, "setState"> & {
|
|
4
3
|
setState(nextStateOrUpdater: HeaderActionStore | Partial<HeaderActionStore> | ((state: import("immer/dist/internal").WritableDraft<HeaderActionStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
5
4
|
}>;
|
|
6
|
-
export declare const useSetHeaderAction: () => (element?: import("react").ReactNode) => () => void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const Link: import("@emotion/styled").StyledComponent<Omit<import("@mui/material").LinkBaseProps, "classes"> & {
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").LinkClasses> | undefined;
|
|
5
|
-
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<
|
|
5
|
+
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined>);
|
|
6
6
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
7
7
|
TypographyClasses?: (Partial<import("@mui/material").TypographyClasses> & Partial<import("@mui/material").ClassNameMap<never>>) | undefined;
|
|
8
8
|
underline?: "none" | "always" | "hover" | undefined;
|
|
@@ -3,7 +3,7 @@ import { Box, useMediaQuery } from '@mui/material';
|
|
|
3
3
|
import { useWatch } from 'react-hook-form';
|
|
4
4
|
import { ReverseTokensButton } from '../components/ReverseTokensButton';
|
|
5
5
|
import { SelectTokenButton } from '../components/SelectTokenButton';
|
|
6
|
-
import { SwapFormKey } from '../providers
|
|
6
|
+
import { SwapFormKey } from '../providers';
|
|
7
7
|
export const SelectChainAndToken = (props) => {
|
|
8
8
|
const prefersNarrowView = useMediaQuery((theme) => theme.breakpoints.down('sm'));
|
|
9
9
|
const [fromChain, toChain, fromToken, toToken] = useWatch({
|
|
@@ -23,6 +23,12 @@ export const SendToWallet = (props) => {
|
|
|
23
23
|
const { showDestinationWallet } = useSettings(['showDestinationWallet']);
|
|
24
24
|
const { account, provider } = useWallet();
|
|
25
25
|
const { register, trigger, formState: { errors }, } = useFormContext();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
trigger(SwapFormKey.ToAddress);
|
|
28
|
+
}, [account.chainId, trigger]);
|
|
29
|
+
if (!showDestinationWallet) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
26
32
|
const { onChange, onBlur, name, ref } = register(SwapFormKey.ToAddress, {
|
|
27
33
|
validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
34
|
try {
|
|
@@ -39,11 +45,5 @@ export const SendToWallet = (props) => {
|
|
|
39
45
|
}),
|
|
40
46
|
onBlur: () => trigger(SwapFormKey.ToAddress),
|
|
41
47
|
});
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
trigger(SwapFormKey.ToAddress);
|
|
44
|
-
}, [account.chainId, trigger]);
|
|
45
|
-
if (!showDestinationWallet) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
48
|
return (_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.sendToWallet') }), _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(Input, { ref: ref, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns') }), _jsx(FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message }))] }))] })));
|
|
49
49
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Done as DoneIcon, Info as InfoIcon, Warning as WarningIcon
|
|
2
|
+
import { Done as DoneIcon, Info as InfoIcon, Warning as WarningIcon } from '@mui/icons-material';
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
|
-
import { CircularProgress as CircularProgressStyled, CircularProgressPending
|
|
4
|
+
import { CircularProgress as CircularProgressStyled, CircularProgressPending } from './CircularProgress.style';
|
|
5
5
|
export function CircularProgress({ status }) {
|
|
6
6
|
return (_jsxs(Box, Object.assign({ sx: {
|
|
7
7
|
display: 'grid',
|
|
8
8
|
position: 'relative',
|
|
9
9
|
placeItems: 'center',
|
|
10
|
-
} }, { children: [_jsx(CircularProgressStyled, { variant: "determinate", status: status, size: 32, thickness: 3, value: 100 }), status === 'STARTED' || status === 'PENDING' ? (_jsx(CircularProgressPending, { size: 32, thickness: 3 })) : null, status === 'ACTION_REQUIRED' ? (_jsx(InfoIcon, { color: "
|
|
10
|
+
} }, { children: [_jsx(CircularProgressStyled, { variant: "determinate", status: status, size: 32, thickness: 3, value: 100 }), status === 'STARTED' || status === 'PENDING' ? (_jsx(CircularProgressPending, { size: 32, thickness: 3 })) : null, status === 'ACTION_REQUIRED' ? (_jsx(InfoIcon, { color: "info", sx: {
|
|
11
11
|
position: 'absolute',
|
|
12
12
|
fontSize: '1rem',
|
|
13
13
|
} })) : null, status === 'DONE' ? (_jsx(DoneIcon, { color: "success", sx: {
|
|
@@ -18,7 +18,7 @@ const circleAnimation = keyframes({
|
|
|
18
18
|
const getStatusColor = (status, theme) => {
|
|
19
19
|
switch (status) {
|
|
20
20
|
case 'ACTION_REQUIRED':
|
|
21
|
-
return theme.palette.
|
|
21
|
+
return theme.palette.info.main;
|
|
22
22
|
case 'DONE':
|
|
23
23
|
return theme.palette.success.main;
|
|
24
24
|
case 'FAILED':
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Link as LinkIcon } from '@mui/icons-material';
|
|
3
3
|
import { Box, Link, Typography } from '@mui/material';
|
|
4
|
-
import {
|
|
5
|
-
import { useChains } from '../../hooks';
|
|
4
|
+
import { useProcessMessage } from '../../hooks';
|
|
6
5
|
import { CircularProgress } from './CircularProgress';
|
|
7
6
|
import { LinkButton } from './StepProcess.style';
|
|
8
|
-
import { getProcessMessage } from './utils';
|
|
9
7
|
export const StepProcess = ({ step, process }) => {
|
|
10
|
-
const {
|
|
11
|
-
const { getChainById } = useChains();
|
|
12
|
-
const { title, message } = getProcessMessage(t, getChainById, step, process);
|
|
8
|
+
const { title, message } = useProcessMessage(step, process);
|
|
13
9
|
return (_jsxs(Box, Object.assign({ px: 2, py: 1 }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
14
10
|
display: 'flex',
|
|
15
11
|
alignItems: 'center',
|
|
@@ -29,7 +29,7 @@ export declare const LinkButton: import("@emotion/styled").StyledComponent<{
|
|
|
29
29
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & Omit<import("@mui/material").LinkBaseProps, "classes"> & {
|
|
30
30
|
children?: import("react").ReactNode;
|
|
31
31
|
classes?: Partial<import("@mui/material").LinkClasses> | undefined;
|
|
32
|
-
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<
|
|
32
|
+
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined>);
|
|
33
33
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
34
34
|
TypographyClasses?: (Partial<import("@mui/material").TypographyClasses> & Partial<import("@mui/material").ClassNameMap<never>>) | undefined;
|
|
35
35
|
underline?: "none" | "always" | "hover" | undefined;
|
|
@@ -7,7 +7,7 @@ const getExpiryTimestamp = (step) => {
|
|
|
7
7
|
return new Date(((_c = (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.process[0]) === null || _b === void 0 ? void 0 : _b.startedAt) !== null && _c !== void 0 ? _c : Date.now()) +
|
|
8
8
|
step.estimate.executionDuration * 1000);
|
|
9
9
|
};
|
|
10
|
-
export const StepTimer = ({ step }) => {
|
|
10
|
+
export const StepTimer = ({ step, hideInProgress, }) => {
|
|
11
11
|
var _a, _b;
|
|
12
12
|
const { t } = useTranslation();
|
|
13
13
|
const [isExpired, setExpired] = useState(false);
|
|
@@ -26,9 +26,7 @@ export const StepTimer = ({ step }) => {
|
|
|
26
26
|
setExecutionStarted(true);
|
|
27
27
|
restart(getExpiryTimestamp(step));
|
|
28
28
|
}
|
|
29
|
-
const shouldBePaused = step.execution.process.some((process) => process.status === 'ACTION_REQUIRED' ||
|
|
30
|
-
process.status === 'CHAIN_SWITCH_REQUIRED' ||
|
|
31
|
-
process.status === 'FAILED');
|
|
29
|
+
const shouldBePaused = step.execution.process.some((process) => process.status === 'ACTION_REQUIRED' || process.status === 'FAILED');
|
|
32
30
|
if (isRunning && shouldBePaused) {
|
|
33
31
|
pause();
|
|
34
32
|
}
|
|
@@ -50,11 +48,13 @@ export const StepTimer = ({ step }) => {
|
|
|
50
48
|
value: (step.estimate.executionDuration / 60).toFixed(0),
|
|
51
49
|
}) }));
|
|
52
50
|
}
|
|
51
|
+
const isTimerExpired = isExpired || (!minutes && !seconds);
|
|
53
52
|
if (((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE' ||
|
|
54
|
-
((_b = step.execution) === null || _b === void 0 ? void 0 : _b.status) === 'FAILED'
|
|
53
|
+
((_b = step.execution) === null || _b === void 0 ? void 0 : _b.status) === 'FAILED' ||
|
|
54
|
+
(isTimerExpired && hideInProgress)) {
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return isTimerExpired ? (_jsx(_Fragment, { children: t('swap.inProgress') })) : (
|
|
58
58
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
59
59
|
_jsx(_Fragment, { children: `${minutes}:${seconds < 10 ? `0${seconds}` : seconds}` }));
|
|
60
60
|
};
|
|
@@ -8,52 +8,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import {
|
|
12
|
-
import { useFormState, useWatch } from 'react-hook-form';
|
|
11
|
+
import { Button } from '@mui/material';
|
|
13
12
|
import { useTranslation } from 'react-i18next';
|
|
14
13
|
import { useNavigate } from 'react-router-dom';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { useGasSufficiency } from '../../hooks';
|
|
15
|
+
import { useWallet, useWidgetConfig } from '../../providers';
|
|
17
16
|
import { navigationRoutes } from '../../utils';
|
|
18
|
-
|
|
19
|
-
export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
20
|
-
var _a;
|
|
17
|
+
export const SwapButton = ({ onClick, currentRoute, text, disable, }) => {
|
|
21
18
|
const { t } = useTranslation();
|
|
22
19
|
const navigate = useNavigate();
|
|
23
|
-
const { isValid, isValidating } = useFormState();
|
|
24
|
-
const { getChainById } = useChains();
|
|
25
20
|
const config = useWidgetConfig();
|
|
26
|
-
const { account,
|
|
21
|
+
const { account, connect } = useWallet();
|
|
27
22
|
const { insufficientFunds, insufficientGas } = useGasSufficiency(currentRoute);
|
|
28
|
-
const [chainId] = useWatch({
|
|
29
|
-
name: [SwapFormKeyHelper.getChainKey('from')],
|
|
30
|
-
});
|
|
31
|
-
// Allow switching chain only if execution is not started
|
|
32
|
-
const switchChainAllowed = ((_a = getChainById(chainId || ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) !== account.chainId &&
|
|
33
|
-
currentRoute &&
|
|
34
|
-
!currentRoute.steps.some((step) => step.execution);
|
|
35
23
|
const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
24
|
if (!account.isActive) {
|
|
37
25
|
if (config.walletManagement) {
|
|
38
|
-
yield
|
|
26
|
+
yield connect();
|
|
39
27
|
}
|
|
40
28
|
else {
|
|
41
29
|
navigate(navigationRoutes.selectWallet);
|
|
42
30
|
}
|
|
43
31
|
}
|
|
44
|
-
else if (switchChainAllowed) {
|
|
45
|
-
yield switchChain(chainId);
|
|
46
|
-
// check that the current route exists in the up to date route list
|
|
47
|
-
}
|
|
48
32
|
else {
|
|
49
33
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
50
34
|
}
|
|
51
35
|
});
|
|
52
36
|
const getButtonText = () => {
|
|
53
37
|
if (account.isActive) {
|
|
54
|
-
if (switchChainAllowed) {
|
|
55
|
-
return t(`button.switchChain`);
|
|
56
|
-
}
|
|
57
38
|
if (!currentRoute) {
|
|
58
39
|
return t(`button.swap`);
|
|
59
40
|
}
|
|
@@ -61,13 +42,5 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
61
42
|
}
|
|
62
43
|
return t(`button.connectWallet`);
|
|
63
44
|
};
|
|
64
|
-
return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
|
|
65
|
-
// loading={isLoading || isFetching}
|
|
66
|
-
disabled: (insufficientFunds ||
|
|
67
|
-
!!insufficientGas.length ||
|
|
68
|
-
loading ||
|
|
69
|
-
isValidating ||
|
|
70
|
-
!isValid) &&
|
|
71
|
-
currentRoute &&
|
|
72
|
-
!switchChainAllowed, fullWidth: true }, { children: getButtonText() })));
|
|
45
|
+
return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: insufficientFunds || !!(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) || disable, fullWidth: true }, { children: getButtonText() })));
|
|
73
46
|
};
|
|
@@ -35,5 +35,5 @@ export const SwapRouteCard = (_a) => {
|
|
|
35
35
|
justifyContent: 'space-between',
|
|
36
36
|
} }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500", lineHeight: 1, pt: 0.25 }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", lineHeight: 1, mt: 0.5 }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end", lineHeight: 1, pt: 0.25 }, { children: ["~", (route.steps
|
|
37
37
|
.map((step) => step.estimate.executionDuration)
|
|
38
|
-
.reduce((
|
|
38
|
+
.reduce((duration, x) => duration + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end", lineHeight: 1, mt: 0.5 }, { children: t(`swap.minutes`) }))] })] }))] })));
|
|
39
39
|
};
|