@lifi/widget 1.10.2 → 1.11.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 +6 -10
- package/AppDrawer.js +1 -1
- package/AppDrawer.style.d.ts +1 -1
- package/AppDrawer.style.js +0 -1
- package/AppProvider.d.ts +1 -0
- package/AppProvider.js +5 -2
- package/components/AppContainer.d.ts +10 -0
- package/components/AppContainer.js +4 -7
- package/components/Card/Card.d.ts +11 -5
- package/components/Card/Card.js +29 -5
- package/components/Card/index.d.ts +0 -1
- package/components/Card/index.js +0 -1
- package/components/Dialog.d.ts +3 -0
- package/components/Dialog.js +23 -0
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.d.ts +6 -0
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +48 -0
- package/components/{InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.style.d.ts → GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts} +0 -0
- package/components/{InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.style.js → GasSufficiencyMessage/GasSufficiencyMessage.style.js} +1 -0
- package/components/GasSufficiencyMessage/index.d.ts +1 -0
- package/components/GasSufficiencyMessage/index.js +1 -0
- package/components/Header/Header.js +5 -6
- package/components/Header/Header.style.js +2 -1
- package/components/Header/NavigationHeader.js +27 -23
- package/components/Header/WalletHeader.js +4 -4
- package/components/Header/index.d.ts +1 -0
- package/components/Header/index.js +1 -0
- package/components/Header/types.d.ts +9 -0
- package/components/Header/types.js +1 -0
- package/components/Header/useHeaderActionStore.d.ts +6 -0
- package/components/Header/useHeaderActionStore.js +21 -0
- package/components/PoweredBy/PoweredBy.js +0 -1
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +14 -2
- package/components/ReverseTokensButton/ReverseTokensButton.js +5 -7
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.js +4 -2
- package/components/SelectTokenButton/SelectTokenButton.js +9 -7
- package/components/SelectTokenButton/SelectTokenButton.style.d.ts +3 -10
- package/components/SelectTokenButton/SelectTokenButton.style.js +0 -7
- package/components/SmallAvatar.d.ts +16 -0
- package/components/SmallAvatar.js +8 -0
- package/{pages/SwapPage → components/Step}/CircularProgress.d.ts +0 -0
- package/{pages/SwapPage → components/Step}/CircularProgress.js +0 -0
- package/{pages/SwapPage → components/Step}/CircularProgress.style.d.ts +0 -0
- package/{pages/SwapPage → components/Step}/CircularProgress.style.js +0 -0
- package/components/Step/Step.d.ts +7 -0
- package/{pages/SwapPage/StepItem.js → components/Step/Step.js} +6 -6
- package/{pages/SwapPage/ExecutionItem.d.ts → components/Step/StepProcess.d.ts} +1 -1
- package/{pages/SwapPage/ExecutionItem.js → components/Step/StepProcess.js} +2 -2
- package/{pages/SwapPage/ExecutionItem.style.d.ts → components/Step/StepProcess.style.d.ts} +1 -1
- package/{pages/SwapPage/ExecutionItem.style.js → components/Step/StepProcess.style.js} +0 -0
- package/{pages/SwapPage → components/Step}/StepTimer.d.ts +0 -0
- package/{pages/SwapPage → components/Step}/StepTimer.js +0 -0
- package/components/Step/index.d.ts +1 -0
- package/components/Step/index.js +1 -0
- package/components/Step/utils.d.ts +6 -0
- package/components/Step/utils.js +89 -0
- package/components/StepActions/StepActions.js +17 -7
- package/components/StepActions/StepActions.style.js +2 -2
- package/{pages/SwapPage → components/StepDivider}/StepDivider.d.ts +0 -0
- package/{pages/SwapPage → components/StepDivider}/StepDivider.js +0 -0
- package/{pages/SwapPage → components/StepDivider}/StepDivider.style.d.ts +0 -0
- package/{pages/SwapPage → components/StepDivider}/StepDivider.style.js +0 -0
- package/components/StepDivider/index.d.ts +1 -0
- package/components/StepDivider/index.js +1 -0
- package/components/SwapButton/SwapButton.js +9 -12
- package/components/SwapButton/SwapButton.style.d.ts +1 -1
- package/components/SwapButton/SwapButton.style.js +1 -5
- package/components/SwapButton/types.d.ts +2 -0
- package/components/SwapInProgress/SwapInProgress.js +9 -6
- package/components/SwapInProgress/SwapInProgress.style.d.ts +9 -21
- package/components/SwapInProgress/SwapInProgress.style.js +5 -6
- package/components/SwapInput/FormPriceHelperText.js +1 -1
- package/components/SwapInput/SwapInput.js +4 -5
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.style.js +0 -2
- package/components/SwapRouteCard/SwapRouteCard.js +15 -15
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +0 -20
- package/components/SwapRouteCard/SwapRouteCard.style.js +7 -54
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +6 -10
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +3 -3
- package/components/SwapRouteCard/types.d.ts +0 -3
- package/components/{StepToken.d.ts → Token/Token.d.ts} +2 -1
- package/components/Token/Token.js +31 -0
- package/components/Token/Token.style.d.ts +24 -0
- package/components/Token/Token.style.js +31 -0
- package/components/Token/index.d.ts +2 -0
- package/components/Token/index.js +2 -0
- package/components/TokenAvatar/TokenAvatar.d.ts +7 -0
- package/components/TokenAvatar/TokenAvatar.js +8 -0
- package/components/TokenAvatar/TokenAvatar.style.d.ts +1 -0
- package/components/TokenAvatar/TokenAvatar.style.js +16 -0
- package/components/TokenAvatar/index.d.ts +2 -0
- package/components/TokenAvatar/index.js +2 -0
- package/components/TokenList/TokenList.js +2 -2
- package/components/TokenList/TokenList.style.js +1 -1
- package/components/TokenList/TokenListItem.d.ts +1 -0
- package/components/TokenList/TokenListItem.js +13 -7
- package/components/TokenList/types.d.ts +1 -0
- package/config/queryClient.d.ts +1 -1
- package/config/queryClient.js +1 -1
- package/config/sentry.js +1 -1
- package/config/theme.js +14 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -1
- package/hooks/index.js +1 -1
- package/hooks/useChains.d.ts +8 -8
- package/hooks/useChains.js +1 -1
- package/hooks/useContentHeight.js +1 -1
- package/hooks/useGasSufficiency.d.ts +15 -0
- package/hooks/useGasSufficiency.js +91 -0
- package/hooks/useRouteExecution.d.ts +3 -3
- package/hooks/useRouteExecution.js +23 -19
- package/hooks/useScrollableContainer.js +1 -1
- package/hooks/useSwapRoutes.d.ts +1 -1
- package/hooks/useSwapRoutes.js +2 -14
- package/hooks/useTelemetry.js +11 -3
- package/hooks/useTokenBalance.js +5 -5
- package/hooks/useTokenBalances.d.ts +2 -2
- package/hooks/useTokenBalances.js +8 -10
- package/hooks/useTokens.js +1 -1
- package/hooks/useTools.d.ts +10 -1
- package/hooks/useTools.js +13 -3
- package/i18n/en/translation.json +18 -9
- package/i18n/index.d.ts +12 -3
- package/icons/LiFiToolLogo.svg +6 -0
- package/index.js +0 -2
- package/package.json +9 -9
- package/pages/MainPage/MainPage.js +2 -3
- package/pages/MainPage/MainSwapButton.js +6 -7
- package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.d.ts +0 -0
- package/pages/MainPage/SwapRoutes.js +36 -0
- package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.style.d.ts +0 -0
- package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.style.js +4 -0
- package/pages/SelectTokenPage/ChainSelect.js +2 -2
- package/pages/SelectTokenPage/SearchTokenInput.js +2 -2
- package/pages/SelectWalletPage/SelectWalletPage.js +4 -23
- package/pages/SelectWalletPage/SelectWalletPage.style.js +1 -1
- package/pages/SettingsPage/AdvancedPreferences.js +1 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/EnabledBridgesSelect.js +7 -4
- package/pages/SettingsPage/EnabledExchangesSelect.js +7 -4
- package/pages/SettingsPage/GasPriceSelect.js +2 -2
- package/pages/SettingsPage/RoutePrioritySelect.js +2 -2
- package/pages/SettingsPage/SlippageInput.js +3 -3
- package/pages/SwapDetailsPage/SwapDetailsPage.d.ts +2 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.js +63 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.style.d.ts +11 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.style.js +5 -0
- package/pages/SwapDetailsPage/index.d.ts +1 -0
- package/pages/SwapDetailsPage/index.js +1 -0
- package/pages/SwapHistoryPage/SwapHistoryEmpty.d.ts +2 -0
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +14 -0
- package/pages/SwapHistoryPage/SwapHistoryItem.d.ts +5 -0
- package/pages/SwapHistoryPage/SwapHistoryItem.js +23 -0
- package/pages/SwapHistoryPage/SwapHistoryPage.d.ts +2 -0
- package/pages/SwapHistoryPage/SwapHistoryPage.js +14 -0
- package/pages/SwapHistoryPage/index.d.ts +1 -0
- package/pages/SwapHistoryPage/index.js +1 -0
- package/pages/SwapPage/StatusBottomSheet.js +4 -4
- package/pages/SwapPage/SwapPage.js +13 -10
- package/pages/SwapPage/SwapPage.style.d.ts +0 -33
- package/pages/SwapPage/SwapPage.style.js +2 -9
- package/pages/SwapPage/utils.js +1 -1
- package/pages/SwapRoutesPage/SwapRoutesPage.js +14 -7
- package/pages/SwapRoutesPage/SwapRoutesPage.style.js +1 -1
- package/providers/WalletProvider/WalletProvider.js +7 -26
- package/providers/WalletProvider/types.d.ts +0 -1
- package/providers/WidgetProvider/WidgetProvider.js +1 -1
- package/stores/route/index.d.ts +1 -1
- package/stores/route/index.js +1 -1
- package/stores/route/types.d.ts +2 -4
- package/stores/route/useExecutingRoutes.d.ts +2 -1
- package/stores/route/useExecutingRoutes.js +4 -2
- package/stores/route/useRouteStore.d.ts +4 -1
- package/stores/route/useRouteStore.js +23 -24
- package/stores/route/useSwapHistory.d.ts +2 -0
- package/stores/route/useSwapHistory.js +11 -0
- package/stores/settings/useSettingsStore.d.ts +13 -0
- package/types/widget.d.ts +3 -4
- package/utils/index.d.ts +6 -0
- package/utils/index.js +6 -0
- package/utils/navigationRoutes.d.ts +13 -0
- package/utils/navigationRoutes.js +12 -0
- package/components/Card/CardContainer.d.ts +0 -11
- package/components/Card/CardContainer.js +0 -16
- package/components/InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.d.ts +0 -3
- package/components/InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.js +0 -31
- package/components/InsufficientGasOrFundsMessage/index.d.ts +0 -1
- package/components/InsufficientGasOrFundsMessage/index.js +0 -1
- package/components/StepToken.js +0 -21
- package/components/SwapRoutes/SwapRoutes.js +0 -32
- package/components/SwapRoutes/SwapRoutesUpdateProgress.d.ts +0 -3
- package/components/SwapRoutes/SwapRoutesUpdateProgress.js +0 -24
- package/components/SwapRoutes/index.d.ts +0 -1
- package/components/SwapRoutes/index.js +0 -1
- package/hooks/useHasSufficientBalance.d.ts +0 -5
- package/hooks/useHasSufficientBalance.js +0 -72
- package/pages/SwapPage/StepItem.d.ts +0 -7
- package/stores/route/useCurrentRoute.d.ts +0 -2
- package/stores/route/useCurrentRoute.js +0 -5
- package/utils/routes.d.ts +0 -11
- package/utils/routes.js +0 -10
|
@@ -6,7 +6,7 @@ export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
9
|
-
size?: "small" | "
|
|
9
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
10
10
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
11
11
|
} & Omit<{
|
|
12
12
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IconButton as MuiIconButton } from '@mui/material';
|
|
2
|
-
import { darken, styled } from '@mui/material/styles';
|
|
2
|
+
import { darken, lighten, styled } from '@mui/material/styles';
|
|
3
3
|
export const IconButton = styled(MuiIconButton)(({ theme }) => ({
|
|
4
4
|
backgroundColor: theme.palette.background.paper,
|
|
5
5
|
border: `1px solid`,
|
|
@@ -9,6 +9,8 @@ export const IconButton = styled(MuiIconButton)(({ theme }) => ({
|
|
|
9
9
|
zIndex: 1200,
|
|
10
10
|
padding: theme.spacing(0.5),
|
|
11
11
|
'&:hover': {
|
|
12
|
-
backgroundColor:
|
|
12
|
+
backgroundColor: theme.palette.mode === 'light'
|
|
13
|
+
? darken(theme.palette.background.paper, 0.02)
|
|
14
|
+
: lighten(theme.palette.background.paper, 0.02),
|
|
13
15
|
},
|
|
14
16
|
}));
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { KeyboardArrowRight as KeyboardArrowRightIcon } from '@mui/icons-material';
|
|
3
|
-
import {
|
|
3
|
+
import { Skeleton } from '@mui/material';
|
|
4
4
|
import { useWatch } from 'react-hook-form';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { useNavigate } from 'react-router-dom';
|
|
7
7
|
import { useChain, useToken } from '../../hooks';
|
|
8
8
|
import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
|
|
9
|
-
import {
|
|
10
|
-
import { CardTitle } from '../Card';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { navigationRoutes } from '../../utils';
|
|
10
|
+
import { Card, CardTitle } from '../Card';
|
|
11
|
+
import { TokenAvatar } from '../TokenAvatar';
|
|
12
|
+
import { SelectTokenCardHeader } from './SelectTokenButton.style';
|
|
13
13
|
export const SelectTokenButton = ({ formType, compact }) => {
|
|
14
14
|
const { t } = useTranslation();
|
|
15
15
|
const navigate = useNavigate();
|
|
@@ -22,8 +22,10 @@ export const SelectTokenButton = ({ formType, compact }) => {
|
|
|
22
22
|
const { chain, isLoading: isChainLoading } = useChain(chainId);
|
|
23
23
|
const { token, isLoading: isTokenLoading } = useToken(chainId, tokenAddress);
|
|
24
24
|
const handleClick = () => {
|
|
25
|
-
navigate(formType === 'from'
|
|
25
|
+
navigate(formType === 'from'
|
|
26
|
+
? navigationRoutes.fromToken
|
|
27
|
+
: navigationRoutes.toToken);
|
|
26
28
|
};
|
|
27
29
|
const isSelected = !!(chain && token);
|
|
28
|
-
return (
|
|
30
|
+
return (_jsxs(Card, Object.assign({ flex: 1, onClick: handleClick }, { children: [_jsx(CardTitle, { children: t(`swap.${formType}`) }), 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 }) : null, action: !compact ? _jsx(KeyboardArrowRightIcon, {}) : null, title: isSelected ? token.symbol : t(`swap.selectChainAndToken`), subheader: isSelected ? `on ${chain.name}` : null, selected: isSelected, compact: compact }))] })));
|
|
29
31
|
};
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const Card: import("@emotion/styled").StyledComponent<Omit<import("@mui/material").PaperProps<"div", {}>, "classes"> & {
|
|
3
|
-
classes?: Partial<import("@mui/material").CardClasses> | undefined;
|
|
4
|
-
raised?: boolean | undefined;
|
|
5
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
6
|
-
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
7
|
-
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
8
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "ref" | "key" | "variant" | "square" | "elevation" | "raised"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
9
2
|
export declare const SelectTokenCardHeader: import("@emotion/styled").StyledComponent<{
|
|
10
3
|
action?: import("react").ReactNode;
|
|
11
4
|
avatar?: import("react").ReactNode;
|
|
12
|
-
classes?: Partial<import("@mui/material").CardHeaderClasses> | undefined;
|
|
5
|
+
classes?: Partial<import("@mui/material/CardHeader").CardHeaderClasses> | undefined;
|
|
13
6
|
disableTypography?: boolean | undefined;
|
|
14
7
|
subheader?: import("react").ReactNode;
|
|
15
8
|
subheaderTypographyProps?: import("@mui/material").TypographyProps<"span", {
|
|
16
9
|
component?: "span" | undefined;
|
|
17
10
|
}> | undefined;
|
|
18
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
11
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
19
12
|
title?: import("react").ReactNode;
|
|
20
13
|
titleTypographyProps?: import("@mui/material").TypographyProps<"span", {
|
|
21
14
|
component?: "span" | undefined;
|
|
22
15
|
}> | undefined;
|
|
23
16
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
24
17
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
25
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "title" | "action" | "sx" | "avatar" | "disableTypography" | "subheader" | "subheaderTypographyProps" | "titleTypographyProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
18
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "title" | "action" | "sx" | "avatar" | "disableTypography" | "subheader" | "subheaderTypographyProps" | "titleTypographyProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
26
19
|
selected?: boolean | undefined;
|
|
27
20
|
compact?: boolean | undefined;
|
|
28
21
|
}, {}, {}>;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { Card as MuiCard } from '@mui/material';
|
|
2
1
|
import { cardHeaderClasses } from '@mui/material/CardHeader';
|
|
3
2
|
import { styled } from '@mui/material/styles';
|
|
4
3
|
import { CardHeader } from '../Card';
|
|
5
|
-
export const Card = styled(MuiCard)(({ theme }) => ({
|
|
6
|
-
borderRadius: 0,
|
|
7
|
-
'&:hover': {
|
|
8
|
-
cursor: 'pointer',
|
|
9
|
-
},
|
|
10
|
-
}));
|
|
11
4
|
export const SelectTokenCardHeader = styled(CardHeader, {
|
|
12
5
|
shouldForwardProp: (prop) => !['selected', 'compact'].includes(prop),
|
|
13
6
|
})(({ theme, selected, compact }) => ({
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const SmallAvatar: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
alt?: string | undefined;
|
|
4
|
+
children?: import("react").ReactNode;
|
|
5
|
+
classes?: Partial<import("@mui/material").AvatarClasses> | undefined;
|
|
6
|
+
imgProps?: (import("react").ImgHTMLAttributes<HTMLImageElement> & {
|
|
7
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
8
|
+
}) | undefined;
|
|
9
|
+
sizes?: string | undefined;
|
|
10
|
+
src?: string | undefined;
|
|
11
|
+
srcSet?: string | undefined;
|
|
12
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
13
|
+
variant?: "square" | "circular" | "rounded" | undefined;
|
|
14
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
15
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
16
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "alt" | "src" | "sizes" | "srcSet" | "imgProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Avatar } from '@mui/material';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
export const SmallAvatar = styled(Avatar)(({ theme }) => ({
|
|
4
|
+
background: theme.palette.background.paper,
|
|
5
|
+
width: 16,
|
|
6
|
+
height: 16,
|
|
7
|
+
border: `2px solid ${theme.palette.background.paper}`,
|
|
8
|
+
}));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import {
|
|
4
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
5
5
|
import { StepActions } from '../../components/StepActions';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { Token } from '../../components/Token';
|
|
7
|
+
import { StepProcess } from './StepProcess';
|
|
8
8
|
import { StepTimer } from './StepTimer';
|
|
9
|
-
export const
|
|
9
|
+
export const Step = ({ step, fromToken, toToken }) => {
|
|
10
10
|
var _a, _b;
|
|
11
11
|
const { t } = useTranslation();
|
|
12
12
|
const stepHasError = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.process.some((process) => process.status === 'FAILED');
|
|
@@ -22,8 +22,8 @@ export const StepItem = ({ step, fromToken, toToken }) => {
|
|
|
22
22
|
return t('swap.stepSwap');
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
return (_jsxs(
|
|
25
|
+
return (_jsxs(Card, Object.assign({ variant: stepHasError ? 'error' : 'default' }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
26
26
|
display: 'flex',
|
|
27
27
|
flex: 1,
|
|
28
|
-
} }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: getCardTitle() })), _jsx(CardTitle, Object.assign({ sx: { fontWeight: 500 } }, { children: _jsx(StepTimer, { step: step }) }))] })), _jsxs(Box, Object.assign({ py: 1 }, { children: [fromToken ? _jsx(
|
|
28
|
+
} }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: getCardTitle() })), _jsx(CardTitle, Object.assign({ sx: { fontWeight: 500 } }, { children: _jsx(StepTimer, { step: step }) }))] })), _jsxs(Box, Object.assign({ py: 1 }, { children: [fromToken ? _jsx(Token, { token: fromToken, px: 2, py: 1 }) : null, _jsx(StepActions, { step: step, px: 2, py: 1, dense: true }), (_b = step.execution) === null || _b === void 0 ? void 0 : _b.process.map((process, index) => (_jsx(StepProcess, { step: step, process: process }, index))), toToken ? _jsx(Token, { token: toToken, px: 2, py: 1 }) : null] }))] })));
|
|
29
29
|
};
|
|
@@ -4,9 +4,9 @@ import { Box, Link, Typography } from '@mui/material';
|
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { useChains } from '../../hooks';
|
|
6
6
|
import { CircularProgress } from './CircularProgress';
|
|
7
|
-
import { LinkButton } from './
|
|
7
|
+
import { LinkButton } from './StepProcess.style';
|
|
8
8
|
import { getProcessMessage } from './utils';
|
|
9
|
-
export const
|
|
9
|
+
export const StepProcess = ({ step, process }) => {
|
|
10
10
|
const { t } = useTranslation();
|
|
11
11
|
const { getChainById } = useChains();
|
|
12
12
|
const { title, message } = getProcessMessage(t, getChainById, step, process);
|
|
@@ -6,7 +6,7 @@ export declare const LinkButton: import("@emotion/styled").StyledComponent<{
|
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
9
|
-
size?: "small" | "
|
|
9
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
10
10
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
11
11
|
} & Omit<{
|
|
12
12
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Step';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Step';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EVMChain, Process, Step } from '@lifi/sdk';
|
|
2
|
+
import { TFunction } from 'react-i18next';
|
|
3
|
+
export declare function getProcessMessage(t: TFunction<'translation', undefined>, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
|
|
4
|
+
title?: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { LifiErrorCode, MetaMaskProviderErrorCode, } from '@lifi/sdk';
|
|
2
|
+
import { formatTokenAmount } from '../../utils';
|
|
3
|
+
const formatProcessMessage = (initialMessage, args = {}) => {
|
|
4
|
+
return Object.keys(args).reduce((message, key) => {
|
|
5
|
+
return message.replace(`{${key}}`, args[key]);
|
|
6
|
+
}, initialMessage);
|
|
7
|
+
};
|
|
8
|
+
const processMessages = {
|
|
9
|
+
TOKEN_ALLOWANCE: {
|
|
10
|
+
STARTED: (t) => t(`swap.process.tokenAllowance.started`),
|
|
11
|
+
PENDING: (t) => t(`swap.process.tokenAllowance.pending`),
|
|
12
|
+
DONE: (t) => t(`swap.process.tokenAllowance.done`),
|
|
13
|
+
},
|
|
14
|
+
SWITCH_CHAIN: {
|
|
15
|
+
PENDING: (t) => t(`swap.process.switchChain.pending`),
|
|
16
|
+
DONE: (t) => t(`swap.process.switchChain.done`),
|
|
17
|
+
},
|
|
18
|
+
SWAP: {
|
|
19
|
+
STARTED: (t) => t(`swap.process.swap.started`),
|
|
20
|
+
ACTION_REQUIRED: (t) => t(`swap.process.swap.actionRequired`),
|
|
21
|
+
PENDING: (t) => t(`swap.process.swap.pending`),
|
|
22
|
+
DONE: (t) => t(`swap.process.swap.done`),
|
|
23
|
+
},
|
|
24
|
+
CROSS_CHAIN: {
|
|
25
|
+
STARTED: (t) => t(`swap.process.crossChain.started`),
|
|
26
|
+
ACTION_REQUIRED: (t) => t(`swap.process.crossChain.actionRequired`),
|
|
27
|
+
PENDING: (t) => t(`swap.process.crossChain.pending`),
|
|
28
|
+
DONE: (t) => t(`swap.process.crossChain.done`),
|
|
29
|
+
},
|
|
30
|
+
RECEIVING_CHAIN: {
|
|
31
|
+
PENDING: (t) => t(`swap.process.receivingChain.pending`),
|
|
32
|
+
DONE: (t) => t(`swap.process.receivingChain.done`),
|
|
33
|
+
},
|
|
34
|
+
TRANSACTION: {},
|
|
35
|
+
};
|
|
36
|
+
export function getProcessMessage(t, getChainById, step, process) {
|
|
37
|
+
var _a, _b, _c, _d;
|
|
38
|
+
if (process.error && process.status === 'FAILED') {
|
|
39
|
+
const getTransactionNotSentMessage = () => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
return t(`swap.error.message.transactionNotSent`, {
|
|
42
|
+
amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
|
|
43
|
+
tokenSymbol: step.action.fromToken.symbol,
|
|
44
|
+
chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
let title = '';
|
|
48
|
+
let message = '';
|
|
49
|
+
switch (process.error.code) {
|
|
50
|
+
case LifiErrorCode.ChainSwitchError:
|
|
51
|
+
title = t(`swap.error.title.chainSwitch`);
|
|
52
|
+
message = getTransactionNotSentMessage();
|
|
53
|
+
break;
|
|
54
|
+
case LifiErrorCode.TransactionFailed:
|
|
55
|
+
title = t(`swap.error.title.transactionFailed`);
|
|
56
|
+
message = t(`swap.error.message.transactionFailed`);
|
|
57
|
+
break;
|
|
58
|
+
case LifiErrorCode.TransactionUnderpriced:
|
|
59
|
+
title = t(`swap.error.title.transactionUnderpriced`);
|
|
60
|
+
message = getTransactionNotSentMessage();
|
|
61
|
+
break;
|
|
62
|
+
case LifiErrorCode.TransactionUnprepared:
|
|
63
|
+
title = t(`swap.error.title.transactionUnprepared`);
|
|
64
|
+
message = getTransactionNotSentMessage();
|
|
65
|
+
break;
|
|
66
|
+
case LifiErrorCode.SlippageError:
|
|
67
|
+
title = t(`swap.error.title.slippageTooLarge`);
|
|
68
|
+
message = t(`swap.error.message.slippageTooLarge`);
|
|
69
|
+
break;
|
|
70
|
+
case MetaMaskProviderErrorCode.userRejectedRequest:
|
|
71
|
+
title = t(`swap.error.title.userRejectedSignatureRequest`);
|
|
72
|
+
message = t(`swap.error.message.signatureRequired`, {
|
|
73
|
+
amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
|
|
74
|
+
tokenSymbol: step.action.fromToken.symbol,
|
|
75
|
+
chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
title = t(`swap.error.title.unknown`);
|
|
80
|
+
if (process.txLink) {
|
|
81
|
+
message = t(`swap.error.message.transactionFailed`);
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
return { title, message };
|
|
86
|
+
}
|
|
87
|
+
const title = (_d = (_c = processMessages[process.type])[process.status]) === null || _d === void 0 ? void 0 : _d.call(_c, t);
|
|
88
|
+
return { title };
|
|
89
|
+
}
|
|
@@ -11,12 +11,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { ArrowForward as ArrowForwardIcon } from '@mui/icons-material';
|
|
14
|
-
import { Box, Step as MuiStep, Stepper, Typography } from '@mui/material';
|
|
14
|
+
import { Box, Step as MuiStep, Stepper, Typography, } from '@mui/material';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { useChains } from '../../hooks';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
17
|
+
import { ReactComponent as LiFiToolLogo } from '../../icons/LiFiToolLogo.svg';
|
|
18
|
+
import { formatTokenAmount } from '../../utils';
|
|
19
|
+
import { SmallAvatar } from '../SmallAvatar';
|
|
20
|
+
import { StepAvatar, StepConnector, StepContent, StepLabel, } from './StepActions.style';
|
|
20
21
|
export const StepActions = (_a) => {
|
|
21
22
|
var _b;
|
|
22
23
|
var { step, dense } = _a, other = __rest(_a, ["step", "dense"]);
|
|
@@ -24,12 +25,21 @@ export const StepActions = (_a) => {
|
|
|
24
25
|
? CrossStepDetailsLabel
|
|
25
26
|
: SwapStepDetailsLabel;
|
|
26
27
|
const isFullView = !dense && ((_b = step.includedSteps) === null || _b === void 0 ? void 0 : _b.length) > 1;
|
|
27
|
-
|
|
28
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
29
|
+
const StepIconComponent = ({ icon }) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const tool = (_a = step.includedSteps) === null || _a === void 0 ? void 0 : _a[Number(icon) - 1];
|
|
32
|
+
return tool ? (_jsx(SmallAvatar, Object.assign({ src: tool.toolDetails.logoURI, alt: tool.toolDetails.name, sx: {
|
|
33
|
+
boxSizing: 'content-box',
|
|
34
|
+
} }, { children: tool.toolDetails.name[0] }))) : null;
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs(Box, Object.assign({}, other, { children: [_jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mb: isFullView ? 1.5 : 0 }, { children: [_jsx(StepAvatar, Object.assign({ variant: step.type === 'lifi' ? 'square' : 'circular', src: step.type !== 'lifi' ? step.toolDetails.logoURI : undefined, alt: step.toolDetails.name }, { children: step.type === 'lifi' ? _jsx(LiFiToolLogo, {}) : step.toolDetails.name[0] })), _jsx(Typography, Object.assign({ ml: 2, fontSize: 18, fontWeight: "500", textTransform: "capitalize" }, { children: step.type === 'lifi'
|
|
28
37
|
? 'LI.FI Smart Contract'
|
|
29
|
-
: step.toolDetails.name }))] })), isFullView ? (_jsx(Stepper, Object.assign({ orientation: "vertical", connector: _jsx(StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step) => (_jsxs(MuiStep, Object.assign({ expanded: true }, { children: [_jsx(StepLabel, Object.assign({ StepIconComponent:
|
|
38
|
+
: step.toolDetails.name }))] })), isFullView ? (_jsx(Stepper, Object.assign({ orientation: "vertical", connector: _jsx(StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step) => (_jsxs(MuiStep, Object.assign({ expanded: true }, { children: [_jsx(StepLabel, Object.assign({ StepIconComponent: StepIconComponent }, { children: step.type === 'cross' || step.type === 'lifi' ? (_jsx(CrossStepDetailsLabel, { step: step })) : (_jsx(SwapStepDetailsLabel, { step: step })) })), _jsx(StepContent, { children: _jsx(StepDetailsContent, { step: step }) })] }), step.id))) }))) : (_jsxs(Box, Object.assign({ ml: 6 }, { children: [_jsx(StepDetailsLabel, { step: step }), _jsx(StepDetailsContent, { step: step })] })))] })));
|
|
30
39
|
};
|
|
31
40
|
export const StepDetailsContent = ({ step }) => {
|
|
32
|
-
|
|
41
|
+
var _a, _b;
|
|
42
|
+
return (_jsxs(Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex" }, { children: [formatTokenAmount(step.estimate.fromAmount, step.action.fromToken.decimals), ' ', step.action.fromToken.symbol, _jsx(ArrowForwardIcon, { sx: { fontSize: 18, paddingX: 0.5 } }), formatTokenAmount((_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount, step.action.toToken.decimals), ' ', step.action.toToken.symbol] })));
|
|
33
43
|
};
|
|
34
44
|
export const CrossStepDetailsLabel = ({ step }) => {
|
|
35
45
|
var _a, _b;
|
|
@@ -30,8 +30,8 @@ export const StepLabel = styled(MuiStepLabel, {
|
|
|
30
30
|
})(({ theme }) => ({
|
|
31
31
|
padding: 0,
|
|
32
32
|
[`.${stepLabelClasses.iconContainer}`]: {
|
|
33
|
-
paddingLeft: theme.spacing(
|
|
34
|
-
paddingRight: theme.spacing(
|
|
33
|
+
paddingLeft: theme.spacing(0.75),
|
|
34
|
+
paddingRight: theme.spacing(2.75),
|
|
35
35
|
},
|
|
36
36
|
[`&.${stepLabelClasses.disabled}`]: {
|
|
37
37
|
cursor: 'inherit',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StepDivider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StepDivider';
|
|
@@ -12,20 +12,20 @@ import { ChainId } from '@lifi/sdk';
|
|
|
12
12
|
import { useWatch } from 'react-hook-form';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
14
|
import { useNavigate } from 'react-router-dom';
|
|
15
|
-
import { useChains,
|
|
15
|
+
import { useChains, useGasSufficiency } from '../../hooks';
|
|
16
16
|
import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
|
|
17
17
|
import { useWallet } from '../../providers/WalletProvider';
|
|
18
18
|
import { useWidgetConfig } from '../../providers/WidgetProvider';
|
|
19
|
-
import {
|
|
19
|
+
import { navigationRoutes } from '../../utils';
|
|
20
20
|
import { Button } from './SwapButton.style';
|
|
21
|
-
export const SwapButton = ({ onClick, text, loading, }) => {
|
|
21
|
+
export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
22
22
|
var _a;
|
|
23
23
|
const navigate = useNavigate();
|
|
24
24
|
const { t } = useTranslation();
|
|
25
25
|
const { getChainById } = useChains();
|
|
26
26
|
const config = useWidgetConfig();
|
|
27
27
|
const { account, switchChain, connect: walletConnect } = useWallet();
|
|
28
|
-
const {
|
|
28
|
+
const { insufficientFunds, insufficientGas } = useGasSufficiency(currentRoute);
|
|
29
29
|
const [chainId] = useWatch({
|
|
30
30
|
name: [SwapFormKeyHelper.getChainKey('from')],
|
|
31
31
|
});
|
|
@@ -36,7 +36,7 @@ export const SwapButton = ({ onClick, text, loading, }) => {
|
|
|
36
36
|
yield walletConnect();
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
|
-
navigate(
|
|
39
|
+
navigate(navigationRoutes.selectWallet);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
else if (!isCurrentChainMatch) {
|
|
@@ -52,15 +52,12 @@ export const SwapButton = ({ onClick, text, loading, }) => {
|
|
|
52
52
|
if (!isCurrentChainMatch) {
|
|
53
53
|
return t(`button.switchChain`);
|
|
54
54
|
}
|
|
55
|
-
return text || t(`button.
|
|
55
|
+
return text || t(`button.reviewSwap`);
|
|
56
56
|
}
|
|
57
57
|
return t(`button.connectWallet`);
|
|
58
58
|
};
|
|
59
|
-
return (_jsx(Button, Object.assign({ variant: "contained",
|
|
59
|
+
return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
|
|
60
60
|
// loading={isLoading || isFetching}
|
|
61
|
-
disabled: (
|
|
62
|
-
|
|
63
|
-
!hasGasOnCrossChain ||
|
|
64
|
-
loading) &&
|
|
65
|
-
isCurrentChainMatch }, { children: getButtonText() })));
|
|
61
|
+
disabled: (insufficientFunds || !!insufficientGas.length || loading) &&
|
|
62
|
+
isCurrentChainMatch, fullWidth: true }, { children: getButtonText() })));
|
|
66
63
|
};
|
|
@@ -24,7 +24,7 @@ export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
|
24
24
|
endIcon?: import("react").ReactNode;
|
|
25
25
|
fullWidth?: boolean | undefined;
|
|
26
26
|
href?: string | undefined;
|
|
27
|
-
size?: "small" | "
|
|
27
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
28
28
|
startIcon?: import("react").ReactNode;
|
|
29
29
|
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
30
30
|
variant?: "text" | "outlined" | "contained" | undefined;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { LoadingButton } from '@mui/lab';
|
|
2
2
|
import { loadingButtonClasses } from '@mui/lab/LoadingButton';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { getContrastAlphaColor } from '../../utils
|
|
4
|
+
import { getContrastAlphaColor } from '../../utils';
|
|
5
5
|
export const Button = styled(LoadingButton)(({ theme }) => ({
|
|
6
|
-
textTransform: 'none',
|
|
7
|
-
borderRadius: theme.shape.borderRadiusSecondary,
|
|
8
|
-
padding: theme.spacing(1.25, 2),
|
|
9
|
-
fontSize: '1rem',
|
|
10
6
|
[`&.${loadingButtonClasses.loading}`]: {
|
|
11
7
|
color: 'transparent',
|
|
12
8
|
},
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ArrowForward as ArrowForwardIcon, KeyboardArrowRight as KeyboardArrowRightIcon, } from '@mui/icons-material';
|
|
3
|
-
import {
|
|
3
|
+
import { Box, Stack } from '@mui/material';
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { useNavigate } from 'react-router-dom';
|
|
7
|
+
import { useWallet } from '../../providers/WalletProvider';
|
|
7
8
|
import { useExecutingRoutes } from '../../stores';
|
|
8
|
-
import {
|
|
9
|
+
import { navigationRoutes } from '../../utils';
|
|
9
10
|
import { CardTitle } from '../Card';
|
|
10
|
-
import {
|
|
11
|
+
import { TokenAvatar, TokenAvatarGroup } from '../TokenAvatar';
|
|
12
|
+
import { ProgressCard, RouteCard } from './SwapInProgress.style';
|
|
11
13
|
export const SwapInProgress = (props) => {
|
|
12
14
|
const { t } = useTranslation();
|
|
13
15
|
const navigate = useNavigate();
|
|
14
|
-
const
|
|
16
|
+
const { account } = useWallet();
|
|
17
|
+
const executingRoutes = useExecutingRoutes(account.address);
|
|
15
18
|
const handleCardClick = useCallback((routeId) => {
|
|
16
|
-
navigate(
|
|
19
|
+
navigate(navigationRoutes.swap, { state: { routeId } });
|
|
17
20
|
}, [navigate]);
|
|
18
21
|
if (!(executingRoutes === null || executingRoutes === void 0 ? void 0 : executingRoutes.length)) {
|
|
19
22
|
return null;
|
|
20
23
|
}
|
|
21
|
-
return (_jsxs(
|
|
24
|
+
return (_jsxs(ProgressCard, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.inProgress') }), _jsx(Stack, Object.assign({ spacing: 2, py: 2 }, { children: executingRoutes.map(({ route, status }) => (_jsx(RouteCard, { onClick: () => handleCardClick(route.id), avatar: _jsxs(TokenAvatarGroup, Object.assign({ total: 2 }, { children: [_jsx(TokenAvatar, { token: route.fromToken }), _jsx(TokenAvatar, { token: route.toToken })] })), action: _jsx(KeyboardArrowRightIcon, {}), title: _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [route.fromToken.symbol, _jsx(ArrowForwardIcon, { fontSize: "small", sx: { paddingX: 0.5 } }), route.toToken.symbol] })) }, route.id))) }))] })));
|
|
22
25
|
};
|