@lifi/widget 1.2.2 → 1.6.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/AppDrawer.style.d.ts +1 -1
- package/AppProvider.js +2 -0
- package/components/Header/Header.js +5 -1
- package/components/Header/Header.style.d.ts +1 -3
- package/components/Header/Header.style.js +5 -4
- package/components/Header/WalletHeader.js +2 -2
- package/components/LiFiLogo.js +1 -1
- package/components/{PoweredBy.d.ts → PoweredBy/PoweredBy.d.ts} +0 -0
- package/components/PoweredBy/PoweredBy.js +12 -0
- package/components/PoweredBy/PoweredBy.style.d.ts +12 -0
- package/components/PoweredBy/PoweredBy.style.js +9 -0
- package/components/PoweredBy/index.d.ts +1 -0
- package/components/PoweredBy/index.js +1 -0
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/SwapButton/SwapButton.js +11 -24
- package/components/SwapButton/SwapButton.style.d.ts +1 -1
- package/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/TokenList/TokenList.js +5 -2
- package/config/sentry.d.ts +1 -0
- package/config/sentry.js +20 -0
- package/config/version.d.ts +2 -0
- package/config/version.js +2 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useRouteExecution.js +9 -3
- package/hooks/useSwapRoutes.js +1 -1
- package/hooks/useTelemetry.d.ts +1 -0
- package/hooks/useTelemetry.js +10 -0
- package/i18n/en/translation.json +16 -6
- package/i18n/index.d.ts +14 -4
- package/index.js +2 -0
- package/package.json +17 -14
- package/pages/MainPage/InsufficientGasOrFundsMessage.d.ts +2 -0
- package/pages/MainPage/InsufficientGasOrFundsMessage.js +28 -0
- package/pages/MainPage/InsufficientGasOrFundsMessage.style.d.ts +9 -0
- package/pages/MainPage/InsufficientGasOrFundsMessage.style.js +9 -0
- package/pages/MainPage/MainPage.js +2 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SwapPage/ExecutionItem.style.d.ts +1 -1
- package/pages/SwapPage/SwapPage.style.d.ts +1 -1
- package/pages/SwapPage/utils.js +4 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.js +3 -0
- package/providers/WalletProvider/WalletProvider.js +25 -53
- package/types/widget.d.ts +5 -10
- package/components/PoweredBy.js +0 -14
package/AppDrawer.style.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const DrawerButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "success" | "
|
|
5
|
+
color?: "inherit" | "success" | "warning" | "error" | "info" | "primary" | "secondary" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
package/AppProvider.js
CHANGED
|
@@ -5,12 +5,14 @@ import { Fragment } from 'react';
|
|
|
5
5
|
import { QueryClientProvider } from 'react-query';
|
|
6
6
|
import { MemoryRouter, useInRouterContext } from 'react-router-dom';
|
|
7
7
|
import { queryClient } from './config/queryClient';
|
|
8
|
+
import { useTelemetry } from './hooks';
|
|
8
9
|
import { SwapFormProvider } from './providers/SwapFormProvider';
|
|
9
10
|
import { ThemeProvider } from './providers/ThemeProvider';
|
|
10
11
|
import { WalletProvider } from './providers/WalletProvider';
|
|
11
12
|
import { WidgetProvider } from './providers/WidgetProvider';
|
|
12
13
|
const QueryProvider = QueryClientProvider;
|
|
13
14
|
export const AppProvider = ({ children, config, }) => {
|
|
15
|
+
useTelemetry(config === null || config === void 0 ? void 0 : config.disableTelemetry);
|
|
14
16
|
const inRouterContext = useInRouterContext();
|
|
15
17
|
const Router = inRouterContext ? Fragment : MemoryRouter;
|
|
16
18
|
return (_jsx(WidgetProvider, Object.assign({ config: config }, { children: _jsx(ThemeProvider, { children: _jsx(QueryProvider, Object.assign({ client: queryClient }, { children: _jsx(Router, { children: _jsx(WalletProvider, { children: _jsx(SwapFormProvider, { children: children }) }) }) })) }) })));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useWidgetConfig } from '@lifi/widget/providers/WidgetProvider';
|
|
2
3
|
import { useLocation } from 'react-router-dom';
|
|
3
4
|
import { ElementId } from '../../utils/elements';
|
|
4
5
|
import { routes } from '../../utils/routes';
|
|
@@ -14,4 +15,7 @@ const HeaderContainer = ({ children }) => {
|
|
|
14
15
|
const { pathname } = useLocation();
|
|
15
16
|
return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
16
17
|
};
|
|
17
|
-
export const Header = () =>
|
|
18
|
+
export const Header = () => {
|
|
19
|
+
const { walletManagement } = useWidgetConfig();
|
|
20
|
+
return (_jsxs(HeaderContainer, { children: [!walletManagement ? _jsx(WalletHeader, {}) : null, _jsx(NavigationHeader, {})] }));
|
|
21
|
+
};
|
|
@@ -7,9 +7,7 @@ export declare const HeaderAppBar: import("@emotion/styled").StyledComponent<Omi
|
|
|
7
7
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
8
8
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, keyof import("react").HTMLAttributes<HTMLElement> | "key"> & {
|
|
9
9
|
ref?: ((instance: HTMLElement | null) => void) | import("react").RefObject<HTMLElement> | null | undefined;
|
|
10
|
-
}, 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" | "position" | "variant" | "square" | "elevation" | "enableColorOnDark"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme
|
|
11
|
-
pt?: number | undefined;
|
|
12
|
-
}, {}, {}>;
|
|
10
|
+
}, 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" | "position" | "variant" | "square" | "elevation" | "enableColorOnDark"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
13
11
|
export declare const Container: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
14
12
|
children?: import("react").ReactNode;
|
|
15
13
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { AppBar, Box } from '@mui/material';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
|
-
export const HeaderAppBar = styled(AppBar
|
|
4
|
-
shouldForwardProp: (prop) => prop !== 'pt',
|
|
5
|
-
})(({ theme, pt }) => ({
|
|
3
|
+
export const HeaderAppBar = styled(AppBar)(({ theme }) => ({
|
|
6
4
|
backgroundColor: theme.palette.background.default,
|
|
7
5
|
color: theme.palette.text.primary,
|
|
8
6
|
flexDirection: 'row',
|
|
9
7
|
alignItems: 'center',
|
|
10
8
|
position: 'relative',
|
|
11
9
|
minHeight: 48,
|
|
12
|
-
padding: theme.spacing(
|
|
10
|
+
padding: theme.spacing(0, 3, 0, 3),
|
|
11
|
+
':first-of-type': {
|
|
12
|
+
paddingTop: theme.spacing(1.5),
|
|
13
|
+
},
|
|
13
14
|
}));
|
|
14
15
|
export const Container = styled(Box, {
|
|
15
16
|
shouldForwardProp: (prop) => prop !== 'sticky',
|
|
@@ -22,7 +22,7 @@ export const WalletHeader = () => {
|
|
|
22
22
|
const walletAddress = account.address
|
|
23
23
|
? `${account.address.substring(0, 7)}...${account.address.substring(account.address.length - 7)}`
|
|
24
24
|
: null;
|
|
25
|
-
return (_jsx(HeaderAppBar, Object.assign({ elevation: 0
|
|
25
|
+
return (_jsx(HeaderAppBar, Object.assign({ elevation: 0 }, { children: walletAddress ? (_jsxs(_Fragment, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
26
26
|
display: 'flex',
|
|
27
27
|
flex: 1,
|
|
28
28
|
flexDirection: 'column',
|
|
@@ -34,7 +34,7 @@ const ConnectButton = () => {
|
|
|
34
34
|
const { connect: walletConnect } = useWallet();
|
|
35
35
|
const navigate = useNavigate();
|
|
36
36
|
const connect = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
if (config.
|
|
37
|
+
if (config.walletManagement) {
|
|
38
38
|
yield walletConnect();
|
|
39
39
|
return;
|
|
40
40
|
}
|
package/components/LiFiLogo.js
CHANGED
|
@@ -3,5 +3,5 @@ import { ReactComponent as LiFiFullLogo } from '../icons/LiFiFullLogo.svg';
|
|
|
3
3
|
import { ReactComponent as LiFiIconLogo } from '../icons/LiFiLogo.svg';
|
|
4
4
|
export const LiFiLogo = ({ variant = 'icon', style }) => {
|
|
5
5
|
const Component = variant === 'icon' ? LiFiIconLogo : LiFiFullLogo;
|
|
6
|
-
return _jsx(Component, { style: style, fill: "currentColor" });
|
|
6
|
+
return _jsx(Component, { style: style, fill: "currentColor", color: "currentColor" });
|
|
7
7
|
};
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Typography } from '@mui/material';
|
|
3
|
+
import { LiFiLogo } from '../LiFiLogo';
|
|
4
|
+
import { Link } from './PoweredBy.style';
|
|
5
|
+
export const PoweredBy = () => {
|
|
6
|
+
return (_jsx(Box, Object.assign({ px: 3, pt: 2, pb: 2, sx: {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
alignItems: 'flex-end',
|
|
9
|
+
justifyContent: 'flex-end',
|
|
10
|
+
flex: 1,
|
|
11
|
+
} }, { children: _jsxs(Link, Object.assign({ href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary" }, { children: [_jsx(Typography, Object.assign({ color: "text.secondary", fontSize: 12, px: 0.5 }, { children: "Powered by" })), _jsx(LiFiLogo, { variant: "full", style: { height: 16, width: 42 } })] })) })));
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Link: import("@emotion/styled").StyledComponent<Omit<import("@mui/material").LinkBaseProps, "classes"> & {
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
classes?: Partial<import("@mui/material").LinkClasses> | undefined;
|
|
5
|
+
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<import("csstype").Property.Color | import("csstype").Property.Color[] | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<import("csstype").Property.Color | import("csstype").Property.Color[] | undefined>);
|
|
6
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
7
|
+
TypographyClasses?: (Partial<import("@mui/material").TypographyClasses> & Partial<import("@mui/material").ClassNameMap<never>>) | undefined;
|
|
8
|
+
underline?: "none" | "always" | "hover" | undefined;
|
|
9
|
+
variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | "@supports (font-variation-settings: normal)" | undefined;
|
|
10
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "key" | keyof import("react").AnchorHTMLAttributes<HTMLAnchorElement>> & {
|
|
11
|
+
ref?: ((instance: HTMLAnchorElement | null) => void) | import("react").RefObject<HTMLAnchorElement> | null | undefined;
|
|
12
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "p" | "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" | "key" | "download" | "href" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "referrerPolicy" | "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" | "variant" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping" | "underline" | "TypographyClasses"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PoweredBy } from './PoweredBy';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PoweredBy } from './PoweredBy';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "default" | "success" | "
|
|
5
|
+
color?: "inherit" | "default" | "success" | "warning" | "error" | "info" | "primary" | "secondary" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
@@ -8,7 +8,6 @@ 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 { useWidgetConfig } from '@lifi/widget/providers/WidgetProvider';
|
|
12
11
|
import { ChainId } from '@lifinance/sdk';
|
|
13
12
|
import { useWatch } from 'react-hook-form';
|
|
14
13
|
import { useTranslation } from 'react-i18next';
|
|
@@ -16,9 +15,9 @@ import { useNavigate } from 'react-router-dom';
|
|
|
16
15
|
import { useChains, useHasSufficientBalance, useSwapRoutes } from '../../hooks';
|
|
17
16
|
import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
|
|
18
17
|
import { useWallet } from '../../providers/WalletProvider';
|
|
18
|
+
import { useWidgetConfig } from '../../providers/WidgetProvider';
|
|
19
19
|
import { useCurrentRoute, useSetExecutableRoute } from '../../stores';
|
|
20
20
|
import { routes } from '../../utils/routes';
|
|
21
|
-
import { ButtonTooltip } from './ButtonTooltip';
|
|
22
21
|
import { Button } from './SwapButton.style';
|
|
23
22
|
export const SwapButton = () => {
|
|
24
23
|
var _a;
|
|
@@ -26,8 +25,7 @@ export const SwapButton = () => {
|
|
|
26
25
|
const { t } = useTranslation();
|
|
27
26
|
const { getChainById } = useChains();
|
|
28
27
|
const config = useWidgetConfig();
|
|
29
|
-
const { connect: walletConnect } = useWallet();
|
|
30
|
-
const { account, switchChain } = useWallet();
|
|
28
|
+
const { account, switchChain, connect: walletConnect } = useWallet();
|
|
31
29
|
const [currentRoute] = useCurrentRoute();
|
|
32
30
|
const setExecutableRoute = useSetExecutableRoute();
|
|
33
31
|
const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
|
|
@@ -38,7 +36,7 @@ export const SwapButton = () => {
|
|
|
38
36
|
const isCurrentChainMatch = ((_a = getChainById(chainId || ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) === account.chainId;
|
|
39
37
|
const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
38
|
if (!account.isActive) {
|
|
41
|
-
if (config.
|
|
39
|
+
if (config.walletManagement) {
|
|
42
40
|
yield walletConnect();
|
|
43
41
|
}
|
|
44
42
|
else {
|
|
@@ -62,27 +60,16 @@ export const SwapButton = () => {
|
|
|
62
60
|
if (!isCurrentChainMatch) {
|
|
63
61
|
return t(`button.switchChain`);
|
|
64
62
|
}
|
|
65
|
-
if (!hasSufficientBalance) {
|
|
66
|
-
return t(`swap.insufficientFunds`);
|
|
67
|
-
}
|
|
68
|
-
if (!hasGasBalanceOnStartChain) {
|
|
69
|
-
return t(`swap.insufficientGasOnStartChain`);
|
|
70
|
-
}
|
|
71
|
-
if (!hasGasOnCrossChain) {
|
|
72
|
-
return t(`swap.insufficientGasOnDestinationChain`);
|
|
73
|
-
}
|
|
74
63
|
return t(`button.swap`);
|
|
75
64
|
}
|
|
76
65
|
return t(`button.connectWallet`);
|
|
77
66
|
};
|
|
78
|
-
return (_jsx(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
isFetching) &&
|
|
87
|
-
isCurrentChainMatch }, { children: getButtonText() })) })));
|
|
67
|
+
return (_jsx(Button, Object.assign({ variant: "contained", disableElevation: true, fullWidth: true, color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
|
|
68
|
+
// loading={isLoading || isFetching}
|
|
69
|
+
disabled: (!hasSufficientBalance ||
|
|
70
|
+
!hasGasBalanceOnStartChain ||
|
|
71
|
+
!hasGasOnCrossChain ||
|
|
72
|
+
isLoading ||
|
|
73
|
+
isFetching) &&
|
|
74
|
+
isCurrentChainMatch }, { children: getButtonText() })));
|
|
88
75
|
};
|
|
@@ -17,7 +17,7 @@ export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
|
17
17
|
} & Omit<{
|
|
18
18
|
children?: import("react").ReactNode;
|
|
19
19
|
classes?: Partial<import("@mui/material/Button").ButtonClasses> | undefined;
|
|
20
|
-
color?: "inherit" | "success" | "
|
|
20
|
+
color?: "inherit" | "success" | "warning" | "error" | "info" | "primary" | "secondary" | undefined;
|
|
21
21
|
disabled?: boolean | undefined;
|
|
22
22
|
disableElevation?: boolean | undefined;
|
|
23
23
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -4,7 +4,7 @@ export declare const minInputFontSize = 14;
|
|
|
4
4
|
export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
5
5
|
children?: import("react").ReactNode;
|
|
6
6
|
classes?: Partial<import("@mui/material").FormControlClasses> | undefined;
|
|
7
|
-
color?: "success" | "
|
|
7
|
+
color?: "success" | "warning" | "error" | "info" | "primary" | "secondary" | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
error?: boolean | undefined;
|
|
10
10
|
fullWidth?: boolean | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "success" | "
|
|
5
|
+
color?: "inherit" | "success" | "warning" | "error" | "info" | "primary" | "secondary" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -47,10 +47,13 @@ export const TokenList = ({ formType, height, onClick, }) => {
|
|
|
47
47
|
setValue(SwapFormKeyHelper.getTokenKey(formType), tokenAddress);
|
|
48
48
|
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
49
49
|
const oppositeFormType = formType === 'from' ? 'to' : 'from';
|
|
50
|
-
const [selectedOppositeToken] = getValues([
|
|
50
|
+
const [selectedOppositeToken, selectedOppositeChain, selectedChain] = getValues([
|
|
51
51
|
SwapFormKeyHelper.getTokenKey(oppositeFormType),
|
|
52
|
+
SwapFormKeyHelper.getChainKey(oppositeFormType),
|
|
53
|
+
SwapFormKeyHelper.getChainKey(formType),
|
|
52
54
|
]);
|
|
53
|
-
if (selectedOppositeToken === tokenAddress
|
|
55
|
+
if (selectedOppositeToken === tokenAddress &&
|
|
56
|
+
selectedOppositeChain === selectedChain) {
|
|
54
57
|
setValue(SwapFormKeyHelper.getTokenKey(oppositeFormType), '');
|
|
55
58
|
}
|
|
56
59
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const initSentry: (enabled?: boolean) => void;
|
package/config/sentry.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CaptureConsole } from '@sentry/integrations';
|
|
2
|
+
import * as Sentry from '@sentry/react';
|
|
3
|
+
import { BrowserTracing } from '@sentry/tracing';
|
|
4
|
+
import { version } from './version';
|
|
5
|
+
export const initSentry = (enabled) => {
|
|
6
|
+
Sentry.init({
|
|
7
|
+
dsn: 'https://bc1312161bf948db9b9c82618035ec22@o1302189.ingest.sentry.io/6539228',
|
|
8
|
+
integrations: [
|
|
9
|
+
new BrowserTracing(),
|
|
10
|
+
new CaptureConsole({
|
|
11
|
+
levels: ['error'],
|
|
12
|
+
}),
|
|
13
|
+
],
|
|
14
|
+
sampleRate: 1,
|
|
15
|
+
tracesSampleRate: 0.2,
|
|
16
|
+
enabled: enabled && process.env.NODE_ENV === 'production',
|
|
17
|
+
environment: process.env.NODE_ENV,
|
|
18
|
+
release: version,
|
|
19
|
+
});
|
|
20
|
+
};
|
package/hooks/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './useHasSufficientBalance';
|
|
|
6
6
|
export * from './useRouteExecution';
|
|
7
7
|
export * from './useScrollableContainer';
|
|
8
8
|
export * from './useSwapRoutes';
|
|
9
|
+
export * from './useTelemetry';
|
|
9
10
|
export * from './useToken';
|
|
10
11
|
export * from './useTokenBalance';
|
|
11
12
|
export * from './useTokenBalances';
|
package/hooks/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from './useHasSufficientBalance';
|
|
|
6
6
|
export * from './useRouteExecution';
|
|
7
7
|
export * from './useScrollableContainer';
|
|
8
8
|
export * from './useSwapRoutes';
|
|
9
|
+
export * from './useTelemetry';
|
|
9
10
|
export * from './useToken';
|
|
10
11
|
export * from './useTokenBalance';
|
|
11
12
|
export * from './useTokenBalances';
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { useCallback, useEffect } from 'react';
|
|
10
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
11
11
|
import { useMutation } from 'react-query';
|
|
12
12
|
import shallow from 'zustand/shallow';
|
|
13
13
|
import { LiFi } from '../lifi';
|
|
@@ -16,6 +16,7 @@ import { useRouteStore } from '../stores';
|
|
|
16
16
|
import { deepClone } from '../utils/deepClone';
|
|
17
17
|
export const useRouteExecution = (routeId) => {
|
|
18
18
|
const { account, switchChain } = useWallet();
|
|
19
|
+
const resumedAfterMount = useRef(false);
|
|
19
20
|
const { route, status } = useRouteStore((state) => { var _a; return (_a = state.routes[routeId]) !== null && _a !== void 0 ? _a : {}; });
|
|
20
21
|
const [updateRoute, restartRoute, removeRoute] = useRouteStore((state) => [state.updateRoute, state.restartRoute, state.removeRoute], shallow);
|
|
21
22
|
const updateCallback = (updatedRoute) => {
|
|
@@ -116,12 +117,17 @@ export const useRouteExecution = (routeId) => {
|
|
|
116
117
|
const isDone = route.steps.every((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE'; });
|
|
117
118
|
const isFailed = route.steps.some((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
|
|
118
119
|
const alreadyStarted = route.steps.some((step) => step.execution);
|
|
119
|
-
if (!isDone &&
|
|
120
|
+
if (!isDone &&
|
|
121
|
+
!isFailed &&
|
|
122
|
+
alreadyStarted &&
|
|
123
|
+
account.signer &&
|
|
124
|
+
!resumedAfterMount.current) {
|
|
125
|
+
resumedAfterMount.current = true;
|
|
120
126
|
resumeRoute();
|
|
121
127
|
}
|
|
122
128
|
return () => LiFi.moveExecutionToBackground(route);
|
|
123
129
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
|
-
}, []);
|
|
130
|
+
}, [account.signer]);
|
|
125
131
|
return {
|
|
126
132
|
executeRoute,
|
|
127
133
|
restartRoute: restartRouteMutation,
|
package/hooks/useSwapRoutes.js
CHANGED
|
@@ -35,7 +35,7 @@ export const useSwapRoutes = () => {
|
|
|
35
35
|
SwapFormKey.ToToken,
|
|
36
36
|
],
|
|
37
37
|
});
|
|
38
|
-
const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount],
|
|
38
|
+
const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount], 250);
|
|
39
39
|
const { token } = useToken(fromChainId, fromTokenAddress);
|
|
40
40
|
const isEnabled = Boolean(account.address) &&
|
|
41
41
|
!isNaN(fromChainId) &&
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useTelemetry: (disabled?: boolean) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { initSentry } from '../config/sentry';
|
|
3
|
+
export const useTelemetry = (disabled) => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (process.env.NODE_ENV === 'production' && disabled) {
|
|
6
|
+
console.warn('Enable crash reports and diagnostic data to be collected. This helps us to better understand how the widget is performing and where improvements need to be made.');
|
|
7
|
+
initSentry(false);
|
|
8
|
+
}
|
|
9
|
+
}, [disabled]);
|
|
10
|
+
};
|
package/i18n/en/translation.json
CHANGED
|
@@ -46,10 +46,6 @@
|
|
|
46
46
|
"selectChainAndToken": "Select chain and token",
|
|
47
47
|
"inProgress": "In progress",
|
|
48
48
|
"couldntFindTokens": "We couldn't find tokens on this chain or you don't have any.",
|
|
49
|
-
"insufficientFunds": "Insufficient funds",
|
|
50
|
-
"insufficientGasOnStartChain": "Insufficient gas on start chain",
|
|
51
|
-
"insufficientGasOnDestinationChain": "Insufficient gas on destination chain",
|
|
52
|
-
"insufficientGasOnDestinationChainTooltip": "The selected route requires a swap on the chain you are transferring to. You need to have gas on that chain to pay for the transaction there.",
|
|
53
49
|
"stepSwap": "Swap",
|
|
54
50
|
"stepBridge": "Bridge",
|
|
55
51
|
"stepSwapAndBridge": "Swap and bridge",
|
|
@@ -72,6 +68,18 @@
|
|
|
72
68
|
"fundsReceived": "You now have {{amount}} {{tokenSymbol}} in your wallet on {{chainName}} chain."
|
|
73
69
|
}
|
|
74
70
|
},
|
|
71
|
+
"warning": {
|
|
72
|
+
"title": {
|
|
73
|
+
"insufficientFunds": "Insufficient funds",
|
|
74
|
+
"insufficientGasOnStartChain": "Insufficient gas on start chain",
|
|
75
|
+
"insufficientGasOnDestinationChain": "Insufficient gas on destination chain"
|
|
76
|
+
},
|
|
77
|
+
"message": {
|
|
78
|
+
"insufficientFunds": "You don't have enough funds in this account.",
|
|
79
|
+
"insufficientGasOnStartChain": "The selected route requires a swap on the chain you are transferring from. You need to have gas on that chain to pay for the transaction there.",
|
|
80
|
+
"insufficientGasOnDestinationChain": "The selected route requires a swap on the chain you are transferring to. You need to have gas on that chain to pay for the transaction there."
|
|
81
|
+
}
|
|
82
|
+
},
|
|
75
83
|
"error": {
|
|
76
84
|
"title": {
|
|
77
85
|
"chainSwitch": "Chain switch required.",
|
|
@@ -79,12 +87,14 @@
|
|
|
79
87
|
"transactionUnderpriced": "Transaction is underpriced.",
|
|
80
88
|
"transactionUnprepared": "Unable to prepare transaction.",
|
|
81
89
|
"unknown": "Something went wrong.",
|
|
82
|
-
"userRejectedSignatureRequest": "Signature required."
|
|
90
|
+
"userRejectedSignatureRequest": "Signature required.",
|
|
91
|
+
"slippageTooLarge": "Slippage too large."
|
|
83
92
|
},
|
|
84
93
|
"message": {
|
|
85
94
|
"signatureRequired": "Your signature is required to complete the transaction. {{amount}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
|
|
86
95
|
"transactionFailed": "Please check the block explorer for more information.",
|
|
87
|
-
"transactionNotSent": "Transaction was not sent, your funds are still in your wallet ({{amount}} {{tokenSymbol}} on {{chainName}})."
|
|
96
|
+
"transactionNotSent": "Transaction was not sent, your funds are still in your wallet ({{amount}} {{tokenSymbol}} on {{chainName}}).",
|
|
97
|
+
"slippageTooLarge": "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote."
|
|
88
98
|
}
|
|
89
99
|
},
|
|
90
100
|
"process": {
|
package/i18n/index.d.ts
CHANGED
|
@@ -49,10 +49,6 @@ export declare const resources: {
|
|
|
49
49
|
selectChainAndToken: string;
|
|
50
50
|
inProgress: string;
|
|
51
51
|
couldntFindTokens: string;
|
|
52
|
-
insufficientFunds: string;
|
|
53
|
-
insufficientGasOnStartChain: string;
|
|
54
|
-
insufficientGasOnDestinationChain: string;
|
|
55
|
-
insufficientGasOnDestinationChainTooltip: string;
|
|
56
52
|
stepSwap: string;
|
|
57
53
|
stepBridge: string;
|
|
58
54
|
stepSwapAndBridge: string;
|
|
@@ -75,6 +71,18 @@ export declare const resources: {
|
|
|
75
71
|
fundsReceived: string;
|
|
76
72
|
};
|
|
77
73
|
};
|
|
74
|
+
warning: {
|
|
75
|
+
title: {
|
|
76
|
+
insufficientFunds: string;
|
|
77
|
+
insufficientGasOnStartChain: string;
|
|
78
|
+
insufficientGasOnDestinationChain: string;
|
|
79
|
+
};
|
|
80
|
+
message: {
|
|
81
|
+
insufficientFunds: string;
|
|
82
|
+
insufficientGasOnStartChain: string;
|
|
83
|
+
insufficientGasOnDestinationChain: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
78
86
|
error: {
|
|
79
87
|
title: {
|
|
80
88
|
chainSwitch: string;
|
|
@@ -83,11 +91,13 @@ export declare const resources: {
|
|
|
83
91
|
transactionUnprepared: string;
|
|
84
92
|
unknown: string;
|
|
85
93
|
userRejectedSignatureRequest: string;
|
|
94
|
+
slippageTooLarge: string;
|
|
86
95
|
};
|
|
87
96
|
message: {
|
|
88
97
|
signatureRequired: string;
|
|
89
98
|
transactionFailed: string;
|
|
90
99
|
transactionNotSent: string;
|
|
100
|
+
slippageTooLarge: string;
|
|
91
101
|
};
|
|
92
102
|
};
|
|
93
103
|
process: {
|
package/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { App } from './App';
|
|
2
2
|
import { AppDrawer } from './AppDrawer';
|
|
3
|
+
import { initSentry } from './config/sentry';
|
|
3
4
|
import './fonts/inter.css';
|
|
4
5
|
import { configureReactI18next } from './i18n';
|
|
5
6
|
export * from './types';
|
|
7
|
+
initSentry(true);
|
|
6
8
|
configureReactI18next();
|
|
7
9
|
// ClassNameGenerator.configure((componentName) => componentName.replace('Mui', ''));
|
|
8
10
|
export const LiFiWidget = App;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./index.js",
|
|
@@ -39,22 +39,25 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@emotion/react": "^11.9.3",
|
|
41
41
|
"@emotion/styled": "^11.9.3",
|
|
42
|
-
"@ethersproject/experimental": "^5.6.
|
|
42
|
+
"@ethersproject/experimental": "^5.6.3",
|
|
43
43
|
"@ethersproject/providers": "^5.6.8",
|
|
44
|
-
"@lifi/wallet-management": "^1.0.
|
|
45
|
-
"@lifinance/sdk": "^1.0.0-beta.
|
|
46
|
-
"@mui/icons-material": "^5.8.
|
|
47
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
48
|
-
"@mui/material": "^5.8.
|
|
44
|
+
"@lifi/wallet-management": "^1.0.4",
|
|
45
|
+
"@lifinance/sdk": "^1.0.0-beta.13",
|
|
46
|
+
"@mui/icons-material": "^5.8.4",
|
|
47
|
+
"@mui/lab": "^5.0.0-alpha.89",
|
|
48
|
+
"@mui/material": "^5.8.7",
|
|
49
|
+
"@sentry/integrations": "^7.5.0",
|
|
50
|
+
"@sentry/react": "^7.5.0",
|
|
51
|
+
"@sentry/tracing": "^7.5.0",
|
|
49
52
|
"big.js": "^6.2.0",
|
|
50
|
-
"i18next": "^21.8.
|
|
51
|
-
"immer": "^9.0.
|
|
52
|
-
"react": "^18.
|
|
53
|
-
"react-dom": "^18.
|
|
54
|
-
"react-hook-form": "^7.
|
|
55
|
-
"react-i18next": "^11.17.
|
|
53
|
+
"i18next": "^21.8.12",
|
|
54
|
+
"immer": "^9.0.15",
|
|
55
|
+
"react": "^18.2.0",
|
|
56
|
+
"react-dom": "^18.2.0",
|
|
57
|
+
"react-hook-form": "^7.33.1",
|
|
58
|
+
"react-i18next": "^11.17.4",
|
|
56
59
|
"react-query": "^4.0.0-beta.23",
|
|
57
|
-
"react-resize-detector": "^7.1.
|
|
60
|
+
"react-resize-detector": "^7.1.2",
|
|
58
61
|
"react-router-dom": "^6.3.0",
|
|
59
62
|
"react-timer-hook": "^3.0.5",
|
|
60
63
|
"react-virtual": "^2.10.4",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { CardTitle } from '../../components/Card';
|
|
5
|
+
import { useHasSufficientBalance } from '../../hooks';
|
|
6
|
+
import { MessageCard } from './InsufficientGasOrFundsMessage.style';
|
|
7
|
+
export const InsufficientGasOrFundsMessage = () => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
const { hasGasBalanceOnStartChain, hasGasOnCrossChain, hasSufficientBalance, } = useHasSufficientBalance();
|
|
10
|
+
if (hasSufficientBalance && hasGasBalanceOnStartChain && hasGasOnCrossChain) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
let title;
|
|
14
|
+
let message;
|
|
15
|
+
if (!hasSufficientBalance) {
|
|
16
|
+
title = t(`swap.warning.title.insufficientFunds`);
|
|
17
|
+
message = t(`swap.warning.message.insufficientFunds`);
|
|
18
|
+
}
|
|
19
|
+
if (!hasGasBalanceOnStartChain) {
|
|
20
|
+
title = t(`swap.warning.title.insufficientGasOnStartChain`);
|
|
21
|
+
message = t(`swap.warning.message.insufficientGasOnStartChain`);
|
|
22
|
+
}
|
|
23
|
+
if (!hasGasOnCrossChain) {
|
|
24
|
+
title = t(`swap.warning.title.insufficientGasOnDestinationChain`);
|
|
25
|
+
message = t(`swap.warning.message.insufficientGasOnDestinationChain`);
|
|
26
|
+
}
|
|
27
|
+
return (_jsxs(MessageCard, Object.assign({ mx: 3, mb: 3 }, { children: [_jsx(CardTitle, { children: title }), _jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: 2, pt: 1 }, { children: message }))] })));
|
|
28
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const MessageCard: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
component?: import("react").ElementType<any> | undefined;
|
|
5
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
6
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
7
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
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").Theme>, {}, {}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Box } from '@mui/material';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
3
|
+
export const MessageCard = styled(Box)(({ theme }) => ({
|
|
4
|
+
backgroundColor: theme.palette.mode === 'light'
|
|
5
|
+
? theme.palette.warning.light
|
|
6
|
+
: alpha(theme.palette.warning.dark, 0.69),
|
|
7
|
+
borderRadius: theme.shape.borderRadius,
|
|
8
|
+
position: 'relative',
|
|
9
|
+
}));
|
|
@@ -5,7 +5,8 @@ import { SwapButton } from '../../components/SwapButton';
|
|
|
5
5
|
import { SwapInProgress } from '../../components/SwapInProgress';
|
|
6
6
|
import { SwapInput } from '../../components/SwapInput';
|
|
7
7
|
import { SwapRoutes } from '../../components/SwapRoutes';
|
|
8
|
+
import { InsufficientGasOrFundsMessage } from './InsufficientGasOrFundsMessage';
|
|
8
9
|
import { FormContainer } from './MainPage.style';
|
|
9
10
|
export const MainPage = () => {
|
|
10
|
-
return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(SwapInProgress, { mx: 3, mt: 2, mb: 1 }), _jsx(SelectChainAndToken, { mt: 2, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), _jsx(SwapRoutes, { mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 1 }, { children: _jsx(SwapButton, {}) }))] })));
|
|
11
|
+
return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(SwapInProgress, { mx: 3, mt: 2, mb: 1 }), _jsx(SelectChainAndToken, { mt: 2, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), _jsx(SwapRoutes, { mx: 3, mb: 3 }), _jsx(InsufficientGasOrFundsMessage, {}), _jsx(Box, Object.assign({ mx: 3, mb: 1 }, { children: _jsx(SwapButton, {}) }))] })));
|
|
11
12
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ToggleButtonClasses> | undefined;
|
|
5
|
-
color?: "success" | "
|
|
5
|
+
color?: "success" | "warning" | "error" | "info" | "primary" | "secondary" | "standard" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
fullWidth?: boolean | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const LinkButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "default" | "success" | "
|
|
5
|
+
color?: "inherit" | "default" | "success" | "warning" | "error" | "info" | "primary" | "secondary" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
@@ -12,7 +12,7 @@ export declare const Container: import("@emotion/styled").StyledComponent<{
|
|
|
12
12
|
export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
13
13
|
children?: import("react").ReactNode;
|
|
14
14
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
15
|
-
color?: "inherit" | "success" | "
|
|
15
|
+
color?: "inherit" | "success" | "warning" | "error" | "info" | "primary" | "secondary" | undefined;
|
|
16
16
|
disabled?: boolean | undefined;
|
|
17
17
|
disableElevation?: boolean | undefined;
|
|
18
18
|
disableFocusRipple?: boolean | undefined;
|
package/pages/SwapPage/utils.js
CHANGED
|
@@ -63,6 +63,10 @@ export function getProcessMessage(t, getChainById, step, process) {
|
|
|
63
63
|
title = t(`swap.error.title.transactionUnprepared`);
|
|
64
64
|
message = getTransactionNotSentMessage();
|
|
65
65
|
break;
|
|
66
|
+
case LifiErrorCode.SlippageError:
|
|
67
|
+
title = t(`swap.error.title.slippageTooLarge`);
|
|
68
|
+
message = t(`swap.error.message.slippageTooLarge`);
|
|
69
|
+
break;
|
|
66
70
|
case MetaMaskProviderErrorCode.userRejectedRequest:
|
|
67
71
|
title = t(`swap.error.title.userRejectedSignatureRequest`);
|
|
68
72
|
message = t(`swap.error.message.signatureRequired`, {
|
|
@@ -19,6 +19,9 @@ export const SwapRoutesPage = () => {
|
|
|
19
19
|
setExecutableRoute(route);
|
|
20
20
|
navigate(routes.swap, { state: { routeId: route.id }, replace: true });
|
|
21
21
|
};
|
|
22
|
+
// A route for this transaction does not exist yet possibly due to liquidity issues or because the amount of tokens you are sending is below the bridge minimum amount.
|
|
23
|
+
// Please try again later or change the tokens you intend to swap.
|
|
24
|
+
// If the problem persists, come to our Discord and leave a message in the support channel.
|
|
22
25
|
return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2 }, { children: isLoading || isFetching
|
|
23
26
|
? Array.from({ length: 3 }).map((_, index) => (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 196, sx: { borderRadius: 1 } }, index)))
|
|
24
27
|
: swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route, index) => (_jsx(SwapRouteCard, { route: route, active: (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.id) === route.id, onClick: () => handleRouteClick(route) }, route.id))) })));
|
|
@@ -26,101 +26,73 @@ const initialContext = {
|
|
|
26
26
|
const WalletContext = createContext(initialContext);
|
|
27
27
|
export const useWallet = () => useContext(WalletContext);
|
|
28
28
|
export const WalletProvider = ({ children }) => {
|
|
29
|
-
var _a;
|
|
30
29
|
const config = useWidgetConfig();
|
|
31
30
|
const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, } = useLifiWalletManagement();
|
|
32
31
|
const [account, setAccount] = useState({});
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
var _a;
|
|
35
|
-
console.log('walletProvider: signer changed', (_a = config.externalWalletManagementSettings) === null || _a === void 0 ? void 0 : _a.signer);
|
|
36
|
-
const updateSigner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
var _b;
|
|
38
|
-
const account = yield extractAccountFromSigner((_b = config.externalWalletManagementSettings) === null || _b === void 0 ? void 0 : _b.signer);
|
|
39
|
-
setAccount(account);
|
|
40
|
-
console.log('walletProvider: signer changed account', account);
|
|
41
|
-
});
|
|
42
|
-
updateSigner();
|
|
43
|
-
}, [(_a = config.externalWalletManagementSettings) === null || _a === void 0 ? void 0 : _a.signer]);
|
|
44
32
|
const connect = useCallback((wallet) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
if (config.
|
|
46
|
-
const signer = yield config.
|
|
33
|
+
if (config.walletManagement) {
|
|
34
|
+
const signer = yield config.walletManagement.connect();
|
|
47
35
|
const account = yield extractAccountFromSigner(signer);
|
|
48
36
|
setAccount(account);
|
|
49
37
|
return;
|
|
50
38
|
}
|
|
51
39
|
yield walletManagementConnect(wallet);
|
|
52
|
-
}), [
|
|
53
|
-
config.disableInternalWalletManagement,
|
|
54
|
-
config.externalWalletManagementSettings,
|
|
55
|
-
walletManagementConnect,
|
|
56
|
-
]);
|
|
40
|
+
}), [config.walletManagement, walletManagementConnect]);
|
|
57
41
|
const disconnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
-
if (config.
|
|
59
|
-
yield config.
|
|
42
|
+
if (config.walletManagement) {
|
|
43
|
+
yield config.walletManagement.disconnect();
|
|
60
44
|
setAccount({});
|
|
61
45
|
return;
|
|
62
46
|
}
|
|
63
47
|
yield walletManagementDisconnect();
|
|
64
|
-
}), [
|
|
65
|
-
config.disableInternalWalletManagement,
|
|
66
|
-
config.externalWalletManagementSettings,
|
|
67
|
-
walletManagementDisconnect,
|
|
68
|
-
]);
|
|
48
|
+
}), [config.walletManagement, walletManagementDisconnect]);
|
|
69
49
|
// only for injected wallets
|
|
70
50
|
const switchChain = useCallback((chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
if (config.
|
|
72
|
-
const signer = yield config.
|
|
51
|
+
if (config.walletManagement) {
|
|
52
|
+
const signer = yield config.walletManagement.switchChain(chainId);
|
|
73
53
|
const account = yield extractAccountFromSigner(signer);
|
|
74
54
|
setAccount(account);
|
|
75
55
|
}
|
|
76
56
|
return walletSwitchChain(chainId);
|
|
77
|
-
}), [
|
|
78
|
-
config.disableInternalWalletManagement,
|
|
79
|
-
config.externalWalletManagementSettings,
|
|
80
|
-
]);
|
|
57
|
+
}), [config.walletManagement]);
|
|
81
58
|
const addChain = useCallback((chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
-
if (config.
|
|
83
|
-
return config.
|
|
59
|
+
if (config.walletManagement) {
|
|
60
|
+
return config.walletManagement.addChain(chainId);
|
|
84
61
|
}
|
|
85
62
|
return walletAddChain(chainId);
|
|
86
|
-
}), [
|
|
87
|
-
config.disableInternalWalletManagement,
|
|
88
|
-
config.externalWalletManagementSettings,
|
|
89
|
-
]);
|
|
63
|
+
}), [config.walletManagement]);
|
|
90
64
|
const addToken = useCallback((chainId, token) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
-
if (config.
|
|
92
|
-
return config.
|
|
65
|
+
if (config.walletManagement) {
|
|
66
|
+
return config.walletManagement.addToken(token, chainId);
|
|
93
67
|
}
|
|
94
68
|
return switchChainAndAddToken(chainId, token);
|
|
95
|
-
}), [
|
|
96
|
-
config.disableInternalWalletManagement,
|
|
97
|
-
config.externalWalletManagementSettings,
|
|
98
|
-
]);
|
|
69
|
+
}), [config.walletManagement]);
|
|
99
70
|
const attemptEagerConnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
-
if (config.
|
|
71
|
+
if (config.walletManagement) {
|
|
101
72
|
try {
|
|
102
|
-
const signer = yield config.
|
|
73
|
+
const signer = yield config.walletManagement.getSigner();
|
|
103
74
|
const account = yield extractAccountFromSigner(signer);
|
|
104
75
|
setAccount(() => (Object.assign({}, account)));
|
|
105
76
|
}
|
|
106
77
|
catch (e) {
|
|
107
|
-
console.warn('attempted
|
|
78
|
+
console.warn('WalletProvider: attempted eager connect.', e);
|
|
108
79
|
}
|
|
109
80
|
}
|
|
110
|
-
}), [
|
|
111
|
-
config.disableInternalWalletManagement,
|
|
112
|
-
config.externalWalletManagementSettings,
|
|
113
|
-
]);
|
|
81
|
+
}), [config.walletManagement]);
|
|
114
82
|
// keep account information up to date
|
|
115
83
|
useEffect(() => {
|
|
116
84
|
const updateAccount = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
-
if (
|
|
85
|
+
if (config.walletManagement) {
|
|
86
|
+
const account = yield extractAccountFromSigner(config.walletManagement.signer);
|
|
87
|
+
setAccount(account);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
118
90
|
const account = yield extractAccountFromSigner(signer);
|
|
119
91
|
setAccount(account);
|
|
120
92
|
}
|
|
121
93
|
});
|
|
122
94
|
updateAccount();
|
|
123
|
-
}, [signer, config.
|
|
95
|
+
}, [signer, config.walletManagement]);
|
|
124
96
|
const value = useMemo(() => ({
|
|
125
97
|
connect,
|
|
126
98
|
disconnect,
|
package/types/widget.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export declare type ThemeConfig = {
|
|
|
9
9
|
shape?: Shape;
|
|
10
10
|
typography?: TypographyOptions;
|
|
11
11
|
};
|
|
12
|
-
export interface
|
|
12
|
+
export interface WidgetWalletManagement {
|
|
13
13
|
connect(): Promise<Signer>;
|
|
14
14
|
disconnect(): Promise<void>;
|
|
15
|
-
|
|
15
|
+
getSigner(): Promise<Signer | undefined>;
|
|
16
16
|
switchChain(reqChainId: number): Promise<Signer>;
|
|
17
17
|
addToken(token: Token, chainId: number): Promise<void>;
|
|
18
18
|
addChain(chainId: number): Promise<boolean>;
|
|
@@ -25,6 +25,8 @@ interface WidgetConfigBase {
|
|
|
25
25
|
theme?: ThemeConfig;
|
|
26
26
|
appearance?: Appearance;
|
|
27
27
|
disableAppearance?: boolean;
|
|
28
|
+
disableTelemetry?: boolean;
|
|
29
|
+
walletManagement?: WidgetWalletManagement;
|
|
28
30
|
}
|
|
29
31
|
declare type WidgetFromTokenConfig = {
|
|
30
32
|
fromChain: `${ChainKey}` | number;
|
|
@@ -40,12 +42,5 @@ declare type WidgetToTokenConfig = {
|
|
|
40
42
|
toChain?: never;
|
|
41
43
|
toToken?: never;
|
|
42
44
|
};
|
|
43
|
-
declare type
|
|
44
|
-
disableInternalWalletManagement: true;
|
|
45
|
-
externalWalletManagementSettings: WidgetWalletCallbacks;
|
|
46
|
-
} | {
|
|
47
|
-
disableInternalWalletManagement?: false;
|
|
48
|
-
externalWalletManagementSettings?: never;
|
|
49
|
-
};
|
|
50
|
-
export declare type WidgetConfig = WidgetConfigBase & WidgetFromTokenConfig & WidgetToTokenConfig & WidgetWalletManagementConfig;
|
|
45
|
+
export declare type WidgetConfig = WidgetConfigBase & WidgetFromTokenConfig & WidgetToTokenConfig;
|
|
51
46
|
export {};
|
package/components/PoweredBy.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Link, Typography } from '@mui/material';
|
|
3
|
-
import { LiFiLogo } from './LiFiLogo';
|
|
4
|
-
export const PoweredBy = () => {
|
|
5
|
-
return (_jsx(Box, Object.assign({ px: 3, pt: 2, pb: 2, sx: {
|
|
6
|
-
display: 'flex',
|
|
7
|
-
alignItems: 'flex-end',
|
|
8
|
-
justifyContent: 'flex-end',
|
|
9
|
-
flex: 1,
|
|
10
|
-
} }, { children: _jsxs(Link, Object.assign({ sx: {
|
|
11
|
-
display: 'flex',
|
|
12
|
-
alignItems: 'center',
|
|
13
|
-
}, href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary" }, { children: [_jsx(Typography, Object.assign({ color: "text.secondary", fontSize: 12, px: 0.5 }, { children: "Powered by" })), _jsx(LiFiLogo, { variant: "full", style: { height: 16, width: 42 } })] })) })));
|
|
14
|
-
};
|