@lifi/widget 1.26.1 → 1.26.2

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.
@@ -13,7 +13,7 @@ exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open, onC
13
13
  setDrawerOpen(false);
14
14
  openRef.current = false;
15
15
  onClose === null || onClose === void 0 ? void 0 : onClose();
16
- }, []);
16
+ }, [onClose]);
17
17
  (0, react_1.useImperativeHandle)(ref, () => ({
18
18
  isOpen: () => openRef.current,
19
19
  open: () => {
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.26.1";
2
+ export declare const version = "1.26.2";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/widget';
5
- exports.version = '1.26.1';
5
+ exports.version = '1.26.2';
@@ -20,6 +20,7 @@ const utils_1 = require("../utils");
20
20
  const useWidgetEvents_1 = require("./useWidgetEvents");
21
21
  const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }) => {
22
22
  const lifi = (0, providers_1.useLiFi)();
23
+ const queryClient = (0, react_query_1.useQueryClient)();
23
24
  const { account, switchChain } = (0, providers_1.useWallet)();
24
25
  const resumedAfterMount = (0, react_1.useRef)(false);
25
26
  const emitter = (0, useWidgetEvents_1.useWidgetEvents)();
@@ -77,6 +78,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
77
78
  if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
78
79
  throw Error('Execution route not found.');
79
80
  }
81
+ queryClient.removeQueries(['routes']);
80
82
  return lifi.executeRoute(account.signer, routeExecution.route, {
81
83
  updateCallback,
82
84
  switchChainHook,
@@ -3,7 +3,7 @@ import type { ExchangeRateUpdateParams, Route } from '@lifi/sdk';
3
3
  export interface ExchangeRateBottomSheetBase {
4
4
  isOpen(): void;
5
5
  open(resolver: (value: boolean) => void, data: ExchangeRateUpdateParams): void;
6
- close(value?: boolean): void;
6
+ close(value?: boolean, bottomSheetClose?: boolean): void;
7
7
  }
8
8
  interface ExchangeRateBottomSheetProps {
9
9
  data?: ExchangeRateUpdateParams;
@@ -24,7 +24,12 @@ exports.ExchangeRateBottomSheet = (0, react_1.forwardRef)(({ onContinue, onCance
24
24
  var _a;
25
25
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false);
26
26
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
27
- }, []);
27
+ }, [onCancel, ref]);
28
+ const handleClose = (0, react_1.useCallback)(() => {
29
+ var _a;
30
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false, false);
31
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
32
+ }, [onCancel, ref]);
28
33
  (0, react_1.useImperativeHandle)(ref, () => ({
29
34
  isOpen: () => { var _a; return (_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen(); },
30
35
  open: (resolver, data) => {
@@ -33,13 +38,15 @@ exports.ExchangeRateBottomSheet = (0, react_1.forwardRef)(({ onContinue, onCance
33
38
  resolverRef.current = resolver;
34
39
  (_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open();
35
40
  },
36
- close: (value = false) => {
41
+ close: (value = false, bottomSheetClose = true) => {
37
42
  var _a, _b;
38
43
  (_a = resolverRef.current) === null || _a === void 0 ? void 0 : _a.call(resolverRef, value);
39
- (_b = bottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
44
+ if (bottomSheetClose) {
45
+ (_b = bottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
46
+ }
40
47
  },
41
48
  }), []);
42
- return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: bottomSheetRef, onClose: handleCancel }, { children: (0, jsx_runtime_1.jsx)(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
49
+ return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: bottomSheetRef, onClose: handleClose }, { children: (0, jsx_runtime_1.jsx)(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
43
50
  });
44
51
  const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
45
52
  const { t } = (0, react_i18next_1.useTranslation)();
@@ -82,6 +82,6 @@ const SwapPage = () => {
82
82
  enableLoading: true }), status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleRemoveRoute, sx: {
83
83
  minWidth: 48,
84
84
  marginLeft: 1,
85
- } }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, {}) })) }))) : null] }))] })) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null, route ? ((0, jsx_runtime_1.jsx)(TokenValueBottomSheet_1.TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? (0, jsx_runtime_1.jsx)(ExchangeRateBottomSheet_1.ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef }) : null] }));
85
+ } }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, {}) })) }))) : null] }))] })) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null, route ? ((0, jsx_runtime_1.jsx)(TokenValueBottomSheet_1.TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? ((0, jsx_runtime_1.jsx)(ExchangeRateBottomSheet_1.ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef })) : null] }));
86
86
  };
87
87
  exports.SwapPage = SwapPage;
@@ -11,12 +11,12 @@ const BottomSheet_1 = require("../../components/BottomSheet");
11
11
  const hooks_1 = require("../../hooks");
12
12
  const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
13
13
  exports.TokenValueBottomSheet = (0, react_1.forwardRef)(({ route, onContinue, onCancel }, ref) => {
14
- const handleCancel = (0, react_1.useCallback)(() => {
14
+ const handleCancel = () => {
15
15
  var _a;
16
16
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
17
17
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
18
- }, []);
19
- return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref, onClose: handleCancel }, { children: (0, jsx_runtime_1.jsx)(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
18
+ };
19
+ return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref, onClose: onCancel }, { children: (0, jsx_runtime_1.jsx)(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
20
20
  });
21
21
  const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
22
22
  const { t } = (0, react_i18next_1.useTranslation)();
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Drawer } from '@mui/material';
3
- import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
3
+ import { forwardRef, useCallback, useImperativeHandle, useRef, useState, } from 'react';
4
4
  import { getScrollableContainer } from '../../hooks';
5
5
  import { backdropProps, modalProps, paperProps } from '../Dialog';
6
6
  export const BottomSheet = forwardRef(({ elementRef, children, open, onClose }, ref) => {
@@ -10,7 +10,7 @@ export const BottomSheet = forwardRef(({ elementRef, children, open, onClose },
10
10
  setDrawerOpen(false);
11
11
  openRef.current = false;
12
12
  onClose === null || onClose === void 0 ? void 0 : onClose();
13
- }, []);
13
+ }, [onClose]);
14
14
  useImperativeHandle(ref, () => ({
15
15
  isOpen: () => openRef.current,
16
16
  open: () => {
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.26.1";
2
+ export declare const version = "1.26.2";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.26.1';
2
+ export const version = '1.26.2';
@@ -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 { useMutation } from '@tanstack/react-query';
10
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
11
11
  import { useCallback, useEffect, useRef } from 'react';
12
12
  import shallow from 'zustand/shallow';
13
13
  import { useLiFi, useWallet } from '../providers';
@@ -17,6 +17,7 @@ import { deepClone } from '../utils';
17
17
  import { useWidgetEvents } from './useWidgetEvents';
18
18
  export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }) => {
19
19
  const lifi = useLiFi();
20
+ const queryClient = useQueryClient();
20
21
  const { account, switchChain } = useWallet();
21
22
  const resumedAfterMount = useRef(false);
22
23
  const emitter = useWidgetEvents();
@@ -74,6 +75,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
74
75
  if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
75
76
  throw Error('Execution route not found.');
76
77
  }
78
+ queryClient.removeQueries(['routes']);
77
79
  return lifi.executeRoute(account.signer, routeExecution.route, {
78
80
  updateCallback,
79
81
  switchChainHook,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.26.1",
3
+ "version": "1.26.2",
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
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -50,7 +50,7 @@
50
50
  "@sentry/integrations": "^7.21.1",
51
51
  "@sentry/react": "^7.21.1",
52
52
  "@sentry/tracing": "^7.21.1",
53
- "@tanstack/react-query": "^4.16.1",
53
+ "@tanstack/react-query": "^4.18.0",
54
54
  "@tanstack/react-virtual": "^3.0.0-beta.23",
55
55
  "big.js": "^6.2.1",
56
56
  "i18next": "22.0.4",
@@ -60,7 +60,7 @@
60
60
  "mitt": "^3.0.0",
61
61
  "react": "^18.2.0",
62
62
  "react-dom": "^18.2.0",
63
- "react-hook-form": "^7.39.5",
63
+ "react-hook-form": "^7.39.7",
64
64
  "react-i18next": "^12.0.0",
65
65
  "react-router-dom": "^6.4.3",
66
66
  "react-timer-hook": "^3.0.5",
@@ -3,7 +3,7 @@ import type { ExchangeRateUpdateParams, Route } from '@lifi/sdk';
3
3
  export interface ExchangeRateBottomSheetBase {
4
4
  isOpen(): void;
5
5
  open(resolver: (value: boolean) => void, data: ExchangeRateUpdateParams): void;
6
- close(value?: boolean): void;
6
+ close(value?: boolean, bottomSheetClose?: boolean): void;
7
7
  }
8
8
  interface ExchangeRateBottomSheetProps {
9
9
  data?: ExchangeRateUpdateParams;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { WarningRounded as WarningIcon } from '@mui/icons-material';
3
3
  import { Box, Button, Typography } from '@mui/material';
4
4
  import Big from 'big.js';
5
- import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
5
+ import { forwardRef, useCallback, useImperativeHandle, useRef, useState, } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { BottomSheet } from '../../components/BottomSheet';
8
8
  import { useSetContentHeight } from '../../hooks';
@@ -21,7 +21,12 @@ export const ExchangeRateBottomSheet = forwardRef(({ onContinue, onCancel }, ref
21
21
  var _a;
22
22
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false);
23
23
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
24
- }, []);
24
+ }, [onCancel, ref]);
25
+ const handleClose = useCallback(() => {
26
+ var _a;
27
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false, false);
28
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
29
+ }, [onCancel, ref]);
25
30
  useImperativeHandle(ref, () => ({
26
31
  isOpen: () => { var _a; return (_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen(); },
27
32
  open: (resolver, data) => {
@@ -30,13 +35,15 @@ export const ExchangeRateBottomSheet = forwardRef(({ onContinue, onCancel }, ref
30
35
  resolverRef.current = resolver;
31
36
  (_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open();
32
37
  },
33
- close: (value = false) => {
38
+ close: (value = false, bottomSheetClose = true) => {
34
39
  var _a, _b;
35
40
  (_a = resolverRef.current) === null || _a === void 0 ? void 0 : _a.call(resolverRef, value);
36
- (_b = bottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
41
+ if (bottomSheetClose) {
42
+ (_b = bottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
43
+ }
37
44
  },
38
45
  }), []);
39
- return (_jsx(BottomSheet, Object.assign({ ref: bottomSheetRef, onClose: handleCancel }, { children: _jsx(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
46
+ return (_jsx(BottomSheet, Object.assign({ ref: bottomSheetRef, onClose: handleClose }, { children: _jsx(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
40
47
  });
41
48
  const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
42
49
  const { t } = useTranslation();
@@ -1,16 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /* eslint-disable consistent-return */
3
- import { Done as DoneIcon, ErrorRounded as ErrorIcon, InfoRounded as InfoIcon, WarningRounded as WarningIcon } from '@mui/icons-material';
3
+ import { Done as DoneIcon, ErrorRounded as ErrorIcon, InfoRounded as InfoIcon, WarningRounded as WarningIcon, } from '@mui/icons-material';
4
4
  import { Box, Button, Typography } from '@mui/material';
5
5
  import { useEffect, useRef } from 'react';
6
6
  import { useFormContext } from 'react-hook-form';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { BottomSheet } from '../../components/BottomSheet';
9
9
  import { Token } from '../../components/Token';
10
- import { getProcessMessage, useChains, useNavigateBack, useTokenBalance } from '../../hooks';
10
+ import { getProcessMessage, useChains, useNavigateBack, useTokenBalance, } from '../../hooks';
11
11
  import { SwapFormKey } from '../../providers';
12
12
  import { RouteExecutionStatus } from '../../stores';
13
- import { formatTokenAmount, hasEnumFlag, navigationRoutes, shortenWalletAddress } from '../../utils';
13
+ import { formatTokenAmount, hasEnumFlag, navigationRoutes, shortenWalletAddress, } from '../../utils';
14
14
  import { IconCircle, IconContainer } from './StatusBottomSheet.style';
15
15
  export const StatusBottomSheet = ({ status, route, }) => {
16
16
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
@@ -23,7 +23,7 @@ import { RouteExecutionStatus } from '../../stores';
23
23
  import { ExchangeRateBottomSheet } from './ExchangeRateBottomSheet';
24
24
  import { StatusBottomSheet } from './StatusBottomSheet';
25
25
  import { Container } from './SwapPage.style';
26
- import { getTokenValueLossThreshold, TokenValueBottomSheet } from './TokenValueBottomSheet';
26
+ import { getTokenValueLossThreshold, TokenValueBottomSheet, } from './TokenValueBottomSheet';
27
27
  export const SwapPage = () => {
28
28
  var _a;
29
29
  const { t } = useTranslation();
@@ -79,5 +79,5 @@ export const SwapPage = () => {
79
79
  enableLoading: true }), status === RouteExecutionStatus.Failed ? (_jsx(Tooltip, Object.assign({ title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: _jsx(Button, Object.assign({ onClick: handleRemoveRoute, sx: {
80
80
  minWidth: 48,
81
81
  marginLeft: 1,
82
- } }, { children: _jsx(DeleteIcon, {}) })) }))) : null] }))] })) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null, route ? (_jsx(TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? _jsx(ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef }) : null] }));
82
+ } }, { children: _jsx(DeleteIcon, {}) })) }))) : null] }))] })) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null, route ? (_jsx(TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? (_jsx(ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef })) : null] }));
83
83
  };
@@ -2,18 +2,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { WarningRounded as WarningIcon } from '@mui/icons-material';
3
3
  import { Box, Button, Typography } from '@mui/material';
4
4
  import Big from 'big.js';
5
- import { forwardRef, useCallback, useRef } from 'react';
5
+ import { forwardRef, useRef } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { BottomSheet } from '../../components/BottomSheet';
8
8
  import { useSetContentHeight } from '../../hooks';
9
9
  import { IconCircle, IconContainer } from './StatusBottomSheet.style';
10
10
  export const TokenValueBottomSheet = forwardRef(({ route, onContinue, onCancel }, ref) => {
11
- const handleCancel = useCallback(() => {
11
+ const handleCancel = () => {
12
12
  var _a;
13
13
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
14
14
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
15
- }, []);
16
- return (_jsx(BottomSheet, Object.assign({ ref: ref, onClose: handleCancel }, { children: _jsx(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
15
+ };
16
+ return (_jsx(BottomSheet, Object.assign({ ref: ref, onClose: onCancel }, { children: _jsx(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
17
17
  });
18
18
  const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
19
19
  const { t } = useTranslation();