@lifi/widget 1.2.1 → 1.5.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.
Files changed (36) hide show
  1. package/AppDrawer.style.d.ts +1 -1
  2. package/AppProvider.js +2 -0
  3. package/components/Header/Header.js +5 -1
  4. package/components/Header/Header.style.d.ts +1 -3
  5. package/components/Header/Header.style.js +5 -4
  6. package/components/Header/WalletHeader.js +2 -2
  7. package/components/LiFiLogo.js +1 -1
  8. package/components/{PoweredBy.d.ts → PoweredBy/PoweredBy.d.ts} +0 -0
  9. package/components/PoweredBy/PoweredBy.js +12 -0
  10. package/components/PoweredBy/PoweredBy.style.d.ts +12 -0
  11. package/components/PoweredBy/PoweredBy.style.js +9 -0
  12. package/components/PoweredBy/index.d.ts +1 -0
  13. package/components/PoweredBy/index.js +1 -0
  14. package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  15. package/components/SwapButton/SwapButton.js +9 -2
  16. package/components/SwapButton/SwapButton.style.d.ts +1 -1
  17. package/components/SwapInput/SwapInput.style.d.ts +1 -1
  18. package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  19. package/components/TokenList/TokenList.js +5 -2
  20. package/config/sentry.d.ts +1 -0
  21. package/config/sentry.js +20 -0
  22. package/config/version.d.ts +2 -0
  23. package/config/version.js +2 -0
  24. package/hooks/index.d.ts +1 -0
  25. package/hooks/index.js +1 -0
  26. package/hooks/useTelemetry.d.ts +1 -0
  27. package/hooks/useTelemetry.js +10 -0
  28. package/index.js +2 -0
  29. package/package.json +17 -14
  30. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  31. package/pages/SwapPage/ExecutionItem.style.d.ts +1 -1
  32. package/pages/SwapPage/SwapPage.style.d.ts +1 -1
  33. package/pages/SwapRoutesPage/SwapRoutesPage.js +3 -0
  34. package/providers/WalletProvider/WalletProvider.js +31 -31
  35. package/types/widget.d.ts +6 -10
  36. package/components/PoweredBy.js +0 -14
@@ -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" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
5
+ color?: "inherit" | "success" | "error" | "warning" | "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 = () => (_jsxs(HeaderContainer, { children: [_jsx(WalletHeader, {}), _jsx(NavigationHeader, {})] }));
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(pt !== null && pt !== void 0 ? pt : 0, 3, 0, 3),
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, pt: 1.5 }, { children: walletAddress ? (_jsxs(_Fragment, { children: [_jsxs(Box, Object.assign({ sx: {
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.disableInternalWalletManagement) {
37
+ if (config.walletManagement) {
38
38
  yield walletConnect();
39
39
  return;
40
40
  }
@@ -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
  };
@@ -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,9 @@
1
+ import { Link as MuiLink } from '@mui/material';
2
+ import { styled } from '@mui/material/styles';
3
+ export const Link = styled(MuiLink)(({ theme }) => ({
4
+ display: 'flex',
5
+ alignItems: 'center',
6
+ ':hover': {
7
+ color: theme.palette.primary.main,
8
+ },
9
+ }));
@@ -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" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
5
+ color?: "inherit" | "default" | "success" | "error" | "warning" | "info" | "primary" | "secondary" | undefined;
6
6
  disabled?: boolean | undefined;
7
7
  disableFocusRipple?: boolean | undefined;
8
8
  edge?: false | "end" | "start" | undefined;
@@ -15,6 +15,7 @@ import { useNavigate } from 'react-router-dom';
15
15
  import { useChains, useHasSufficientBalance, useSwapRoutes } from '../../hooks';
16
16
  import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
17
17
  import { useWallet } from '../../providers/WalletProvider';
18
+ import { useWidgetConfig } from '../../providers/WidgetProvider';
18
19
  import { useCurrentRoute, useSetExecutableRoute } from '../../stores';
19
20
  import { routes } from '../../utils/routes';
20
21
  import { ButtonTooltip } from './ButtonTooltip';
@@ -24,7 +25,8 @@ export const SwapButton = () => {
24
25
  const navigate = useNavigate();
25
26
  const { t } = useTranslation();
26
27
  const { getChainById } = useChains();
27
- const { account, switchChain } = useWallet();
28
+ const config = useWidgetConfig();
29
+ const { account, switchChain, connect: walletConnect } = useWallet();
28
30
  const [currentRoute] = useCurrentRoute();
29
31
  const setExecutableRoute = useSetExecutableRoute();
30
32
  const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
@@ -35,7 +37,12 @@ export const SwapButton = () => {
35
37
  const isCurrentChainMatch = ((_a = getChainById(chainId || ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) === account.chainId;
36
38
  const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
37
39
  if (!account.isActive) {
38
- navigate(routes.selectWallet);
40
+ if (config.walletManagement) {
41
+ yield walletConnect();
42
+ }
43
+ else {
44
+ navigate(routes.selectWallet);
45
+ }
39
46
  }
40
47
  else if (!isCurrentChainMatch) {
41
48
  yield switchChain(chainId);
@@ -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" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
20
+ color?: "inherit" | "success" | "error" | "warning" | "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" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
7
+ color?: "success" | "error" | "warning" | "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" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
5
+ color?: "inherit" | "success" | "error" | "warning" | "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;
@@ -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,
17
+ environment: process.env.NODE_ENV,
18
+ release: version,
19
+ });
20
+ };
@@ -0,0 +1,2 @@
1
+ export declare const name = "@lifi/widget";
2
+ export declare const version = "1.5.0";
@@ -0,0 +1,2 @@
1
+ export const name = '@lifi/widget';
2
+ export const version = '1.5.0';
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';
@@ -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 (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/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.2.1",
3
+ "version": "1.5.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.2",
42
+ "@ethersproject/experimental": "^5.6.3",
43
43
  "@ethersproject/providers": "^5.6.8",
44
- "@lifi/wallet-management": "^1.0.3",
45
- "@lifinance/sdk": "^1.0.0-beta.11",
46
- "@mui/icons-material": "^5.8.3",
47
- "@mui/lab": "^5.0.0-alpha.85",
48
- "@mui/material": "^5.8.3",
44
+ "@lifi/wallet-management": "^1.0.4",
45
+ "@lifinance/sdk": "^1.0.0-beta.12",
46
+ "@mui/icons-material": "^5.8.4",
47
+ "@mui/lab": "^5.0.0-alpha.88",
48
+ "@mui/material": "^5.8.6",
49
+ "@sentry/integrations": "^7.4.0",
50
+ "@sentry/react": "^7.4.0",
51
+ "@sentry/tracing": "^7.4.0",
49
52
  "big.js": "^6.2.0",
50
- "i18next": "^21.8.9",
51
- "immer": "^9.0.14",
52
- "react": "^18.1.0",
53
- "react-dom": "^18.1.0",
54
- "react-hook-form": "^7.32.0",
55
- "react-i18next": "^11.17.1",
53
+ "i18next": "^21.8.11",
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.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",
@@ -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" | "error" | "primary" | "secondary" | "info" | "warning" | "standard" | undefined;
5
+ color?: "success" | "error" | "warning" | "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" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
5
+ color?: "inherit" | "default" | "success" | "error" | "warning" | "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" | "error" | "primary" | "secondary" | "info" | "warning" | undefined;
15
+ color?: "inherit" | "success" | "error" | "warning" | "info" | "primary" | "secondary" | undefined;
16
16
  disabled?: boolean | undefined;
17
17
  disableElevation?: boolean | undefined;
18
18
  disableFocusRipple?: boolean | undefined;
@@ -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))) })));
@@ -30,69 +30,69 @@ export const WalletProvider = ({ children }) => {
30
30
  const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, } = useLifiWalletManagement();
31
31
  const [account, setAccount] = useState({});
32
32
  const connect = useCallback((wallet) => __awaiter(void 0, void 0, void 0, function* () {
33
- if (config.disableInternalWalletManagement) {
34
- const signer = yield config.walletCallbacks.connect();
33
+ if (config.walletManagement) {
34
+ const signer = yield config.walletManagement.connect();
35
35
  const account = yield extractAccountFromSigner(signer);
36
36
  setAccount(account);
37
37
  return;
38
38
  }
39
39
  yield walletManagementConnect(wallet);
40
- }), [
41
- config.disableInternalWalletManagement,
42
- config.walletCallbacks,
43
- walletManagementConnect,
44
- ]);
40
+ }), [config.walletManagement, walletManagementConnect]);
45
41
  const disconnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
46
- if (config.disableInternalWalletManagement) {
47
- yield config.walletCallbacks.disconnect();
42
+ if (config.walletManagement) {
43
+ yield config.walletManagement.disconnect();
48
44
  setAccount({});
49
45
  return;
50
46
  }
51
47
  yield walletManagementDisconnect();
52
- }), [
53
- config.disableInternalWalletManagement,
54
- config.walletCallbacks,
55
- walletManagementDisconnect,
56
- ]);
48
+ }), [config.walletManagement, walletManagementDisconnect]);
57
49
  // only for injected wallets
58
50
  const switchChain = useCallback((chainId) => __awaiter(void 0, void 0, void 0, function* () {
59
- if (config.disableInternalWalletManagement) {
60
- const signer = yield config.walletCallbacks.switchChain(chainId);
51
+ if (config.walletManagement) {
52
+ const signer = yield config.walletManagement.switchChain(chainId);
61
53
  const account = yield extractAccountFromSigner(signer);
62
54
  setAccount(account);
63
55
  }
64
56
  return walletSwitchChain(chainId);
65
- }), [config.disableInternalWalletManagement, config.walletCallbacks]);
57
+ }), [config.walletManagement]);
66
58
  const addChain = useCallback((chainId) => __awaiter(void 0, void 0, void 0, function* () {
67
- if (config.disableInternalWalletManagement) {
68
- return config.walletCallbacks.addChain(chainId);
59
+ if (config.walletManagement) {
60
+ return config.walletManagement.addChain(chainId);
69
61
  }
70
62
  return walletAddChain(chainId);
71
- }), [config.disableInternalWalletManagement, config.walletCallbacks]);
63
+ }), [config.walletManagement]);
72
64
  const addToken = useCallback((chainId, token) => __awaiter(void 0, void 0, void 0, function* () {
73
- if (config.disableInternalWalletManagement) {
74
- return config.walletCallbacks.addToken(token, chainId);
65
+ if (config.walletManagement) {
66
+ return config.walletManagement.addToken(token, chainId);
75
67
  }
76
68
  return switchChainAndAddToken(chainId, token);
77
- }), [config.disableInternalWalletManagement, config.walletCallbacks]);
69
+ }), [config.walletManagement]);
78
70
  const attemptEagerConnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
79
- if (config.disableInternalWalletManagement) {
80
- const signer = yield config.walletCallbacks.provideSigner();
81
- const account = yield extractAccountFromSigner(signer);
82
- console.log(account);
83
- setAccount((oldAccount) => (Object.assign({}, account)));
71
+ if (config.walletManagement) {
72
+ try {
73
+ const signer = yield config.walletManagement.getSigner();
74
+ const account = yield extractAccountFromSigner(signer);
75
+ setAccount(() => (Object.assign({}, account)));
76
+ }
77
+ catch (e) {
78
+ console.warn('WalletProvider: attempted eager connect.', e);
79
+ }
84
80
  }
85
- }), [config.disableInternalWalletManagement, config.walletCallbacks]);
81
+ }), [config.walletManagement]);
86
82
  // keep account information up to date
87
83
  useEffect(() => {
88
84
  const updateAccount = () => __awaiter(void 0, void 0, void 0, function* () {
89
- if (!config.disableInternalWalletManagement) {
85
+ if (config.walletManagement) {
86
+ const account = yield extractAccountFromSigner(config.walletManagement.signer);
87
+ setAccount(account);
88
+ }
89
+ else {
90
90
  const account = yield extractAccountFromSigner(signer);
91
91
  setAccount(account);
92
92
  }
93
93
  });
94
94
  updateAccount();
95
- }, [signer, config.disableInternalWalletManagement]);
95
+ }, [signer, config.walletManagement]);
96
96
  const value = useMemo(() => ({
97
97
  connect,
98
98
  disconnect,
package/types/widget.d.ts CHANGED
@@ -9,13 +9,14 @@ export declare type ThemeConfig = {
9
9
  shape?: Shape;
10
10
  typography?: TypographyOptions;
11
11
  };
12
- export interface WidgetWalletCallbacks {
12
+ export interface WidgetWalletManagement {
13
13
  connect(): Promise<Signer>;
14
14
  disconnect(): Promise<void>;
15
- provideSigner(): Promise<Signer | undefined>;
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>;
19
+ signer?: Signer;
19
20
  }
20
21
  interface WidgetConfigBase {
21
22
  fromAmount?: number;
@@ -24,6 +25,8 @@ interface WidgetConfigBase {
24
25
  theme?: ThemeConfig;
25
26
  appearance?: Appearance;
26
27
  disableAppearance?: boolean;
28
+ disableTelemetry?: boolean;
29
+ walletManagement?: WidgetWalletManagement;
27
30
  }
28
31
  declare type WidgetFromTokenConfig = {
29
32
  fromChain: `${ChainKey}` | number;
@@ -39,12 +42,5 @@ declare type WidgetToTokenConfig = {
39
42
  toChain?: never;
40
43
  toToken?: never;
41
44
  };
42
- declare type WidgetWalletManagementConfig = {
43
- disableInternalWalletManagement: true;
44
- walletCallbacks: WidgetWalletCallbacks;
45
- } | {
46
- disableInternalWalletManagement?: false;
47
- walletCallbacks?: never;
48
- };
49
- export declare type WidgetConfig = WidgetConfigBase & WidgetFromTokenConfig & WidgetToTokenConfig & WidgetWalletManagementConfig;
45
+ export declare type WidgetConfig = WidgetConfigBase & WidgetFromTokenConfig & WidgetToTokenConfig;
50
46
  export {};
@@ -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
- };