@lifi/widget 1.2.2 → 1.4.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.
@@ -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
  }
@@ -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,6 +15,7 @@ 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
21
  import { ButtonTooltip } from './ButtonTooltip';
@@ -26,8 +26,7 @@ export const SwapButton = () => {
26
26
  const { t } = useTranslation();
27
27
  const { getChainById } = useChains();
28
28
  const config = useWidgetConfig();
29
- const { connect: walletConnect } = useWallet();
30
- const { account, switchChain } = useWallet();
29
+ const { account, switchChain, connect: walletConnect } = useWallet();
31
30
  const [currentRoute] = useCurrentRoute();
32
31
  const setExecutableRoute = useSetExecutableRoute();
33
32
  const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
@@ -38,7 +37,7 @@ export const SwapButton = () => {
38
37
  const isCurrentChainMatch = ((_a = getChainById(chainId || ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) === account.chainId;
39
38
  const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
40
39
  if (!account.isActive) {
41
- if (config.disableInternalWalletManagement) {
40
+ if (config.walletManagement) {
42
41
  yield walletConnect();
43
42
  }
44
43
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.2.2",
3
+ "version": "1.4.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,22 @@
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",
44
+ "@lifi/wallet-management": "^1.0.4",
45
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",
46
+ "@mui/icons-material": "^5.8.4",
47
+ "@mui/lab": "^5.0.0-alpha.87",
48
+ "@mui/material": "^5.8.5",
49
49
  "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",
50
+ "i18next": "^21.8.11",
51
+ "immer": "^9.0.15",
52
+ "react": "^18.2.0",
53
+ "react-dom": "^18.2.0",
54
+ "react-hook-form": "^7.33.0",
55
+ "react-i18next": "^11.17.3",
56
56
  "react-query": "^4.0.0-beta.23",
57
- "react-resize-detector": "^7.1.1",
57
+ "react-resize-detector": "^7.1.2",
58
58
  "react-router-dom": "^6.3.0",
59
59
  "react-timer-hook": "^3.0.5",
60
60
  "react-virtual": "^2.10.4",
@@ -32,95 +32,75 @@ export const WalletProvider = ({ children }) => {
32
32
  const [account, setAccount] = useState({});
33
33
  useEffect(() => {
34
34
  var _a;
35
- console.log('walletProvider: signer changed', (_a = config.externalWalletManagementSettings) === null || _a === void 0 ? void 0 : _a.signer);
35
+ console.log('WalletProvider: signer changed.', (_a = config.walletManagement) === null || _a === void 0 ? void 0 : _a.signer);
36
36
  const updateSigner = () => __awaiter(void 0, void 0, void 0, function* () {
37
37
  var _b;
38
- const account = yield extractAccountFromSigner((_b = config.externalWalletManagementSettings) === null || _b === void 0 ? void 0 : _b.signer);
38
+ const account = yield extractAccountFromSigner((_b = config.walletManagement) === null || _b === void 0 ? void 0 : _b.signer);
39
39
  setAccount(account);
40
- console.log('walletProvider: signer changed account', account);
40
+ console.log('WalletProvider: signer changed account.', account);
41
41
  });
42
42
  updateSigner();
43
- }, [(_a = config.externalWalletManagementSettings) === null || _a === void 0 ? void 0 : _a.signer]);
43
+ }, [(_a = config.walletManagement) === null || _a === void 0 ? void 0 : _a.signer]);
44
44
  const connect = useCallback((wallet) => __awaiter(void 0, void 0, void 0, function* () {
45
- if (config.disableInternalWalletManagement) {
46
- const signer = yield config.externalWalletManagementSettings.connect();
45
+ if (config.walletManagement) {
46
+ const signer = yield config.walletManagement.connect();
47
47
  const account = yield extractAccountFromSigner(signer);
48
48
  setAccount(account);
49
49
  return;
50
50
  }
51
51
  yield walletManagementConnect(wallet);
52
- }), [
53
- config.disableInternalWalletManagement,
54
- config.externalWalletManagementSettings,
55
- walletManagementConnect,
56
- ]);
52
+ }), [config.walletManagement, walletManagementConnect]);
57
53
  const disconnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
58
- if (config.disableInternalWalletManagement) {
59
- yield config.externalWalletManagementSettings.disconnect();
54
+ if (config.walletManagement) {
55
+ yield config.walletManagement.disconnect();
60
56
  setAccount({});
61
57
  return;
62
58
  }
63
59
  yield walletManagementDisconnect();
64
- }), [
65
- config.disableInternalWalletManagement,
66
- config.externalWalletManagementSettings,
67
- walletManagementDisconnect,
68
- ]);
60
+ }), [config.walletManagement, walletManagementDisconnect]);
69
61
  // only for injected wallets
70
62
  const switchChain = useCallback((chainId) => __awaiter(void 0, void 0, void 0, function* () {
71
- if (config.disableInternalWalletManagement) {
72
- const signer = yield config.externalWalletManagementSettings.switchChain(chainId);
63
+ if (config.walletManagement) {
64
+ const signer = yield config.walletManagement.switchChain(chainId);
73
65
  const account = yield extractAccountFromSigner(signer);
74
66
  setAccount(account);
75
67
  }
76
68
  return walletSwitchChain(chainId);
77
- }), [
78
- config.disableInternalWalletManagement,
79
- config.externalWalletManagementSettings,
80
- ]);
69
+ }), [config.walletManagement]);
81
70
  const addChain = useCallback((chainId) => __awaiter(void 0, void 0, void 0, function* () {
82
- if (config.disableInternalWalletManagement) {
83
- return config.externalWalletManagementSettings.addChain(chainId);
71
+ if (config.walletManagement) {
72
+ return config.walletManagement.addChain(chainId);
84
73
  }
85
74
  return walletAddChain(chainId);
86
- }), [
87
- config.disableInternalWalletManagement,
88
- config.externalWalletManagementSettings,
89
- ]);
75
+ }), [config.walletManagement]);
90
76
  const addToken = useCallback((chainId, token) => __awaiter(void 0, void 0, void 0, function* () {
91
- if (config.disableInternalWalletManagement) {
92
- return config.externalWalletManagementSettings.addToken(token, chainId);
77
+ if (config.walletManagement) {
78
+ return config.walletManagement.addToken(token, chainId);
93
79
  }
94
80
  return switchChainAndAddToken(chainId, token);
95
- }), [
96
- config.disableInternalWalletManagement,
97
- config.externalWalletManagementSettings,
98
- ]);
81
+ }), [config.walletManagement]);
99
82
  const attemptEagerConnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
100
- if (config.disableInternalWalletManagement) {
83
+ if (config.walletManagement) {
101
84
  try {
102
- const signer = yield config.externalWalletManagementSettings.provideSigner();
85
+ const signer = yield config.walletManagement.getSigner();
103
86
  const account = yield extractAccountFromSigner(signer);
104
87
  setAccount(() => (Object.assign({}, account)));
105
88
  }
106
89
  catch (e) {
107
- console.warn('attempted eagerconnect', e);
90
+ console.warn('WalletProvider: attempted eager connect.', e);
108
91
  }
109
92
  }
110
- }), [
111
- config.disableInternalWalletManagement,
112
- config.externalWalletManagementSettings,
113
- ]);
93
+ }), [config.walletManagement]);
114
94
  // keep account information up to date
115
95
  useEffect(() => {
116
96
  const updateAccount = () => __awaiter(void 0, void 0, void 0, function* () {
117
- if (!config.disableInternalWalletManagement) {
97
+ if (!config.walletManagement) {
118
98
  const account = yield extractAccountFromSigner(signer);
119
99
  setAccount(account);
120
100
  }
121
101
  });
122
102
  updateAccount();
123
- }, [signer, config.disableInternalWalletManagement]);
103
+ }, [signer, config.walletManagement]);
124
104
  const value = useMemo(() => ({
125
105
  connect,
126
106
  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 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>;
@@ -25,6 +25,7 @@ interface WidgetConfigBase {
25
25
  theme?: ThemeConfig;
26
26
  appearance?: Appearance;
27
27
  disableAppearance?: boolean;
28
+ walletManagement?: WidgetWalletManagement;
28
29
  }
29
30
  declare type WidgetFromTokenConfig = {
30
31
  fromChain: `${ChainKey}` | number;
@@ -40,12 +41,5 @@ declare type WidgetToTokenConfig = {
40
41
  toChain?: never;
41
42
  toToken?: never;
42
43
  };
43
- declare type WidgetWalletManagementConfig = {
44
- disableInternalWalletManagement: true;
45
- externalWalletManagementSettings: WidgetWalletCallbacks;
46
- } | {
47
- disableInternalWalletManagement?: false;
48
- externalWalletManagementSettings?: never;
49
- };
50
- export declare type WidgetConfig = WidgetConfigBase & WidgetFromTokenConfig & WidgetToTokenConfig & WidgetWalletManagementConfig;
44
+ export declare type WidgetConfig = WidgetConfigBase & WidgetFromTokenConfig & WidgetToTokenConfig;
51
45
  export {};