@lifi/widget 1.13.6 → 1.14.1

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.
@@ -15,7 +15,7 @@ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef,
15
15
  const { getVirtualItems, getTotalSize, scrollToIndex } = (0, react_virtual_1.useVirtualizer)({
16
16
  count: tokens.length,
17
17
  getScrollElement: () => scrollElementRef.current,
18
- overscan: 5,
18
+ overscan: 10,
19
19
  paddingEnd: 12,
20
20
  estimateSize: (index) => {
21
21
  var _a, _b;
@@ -5,7 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.updateLiFiConfig = exports.LiFi = void 0;
7
7
  const sdk_1 = __importDefault(require("@lifi/sdk"));
8
- exports.LiFi = new sdk_1.default();
8
+ exports.LiFi = new sdk_1.default({
9
+ disableVersionCheck: true,
10
+ });
9
11
  const updateLiFiConfig = (configUpdate) => {
10
12
  exports.LiFi.setConfig(configUpdate);
11
13
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTheme = void 0;
4
+ const colors_1 = require("@mui/material/colors");
4
5
  const DialogActions_1 = require("@mui/material/DialogActions");
5
6
  const styles_1 = require("@mui/material/styles");
6
7
  const palette = {
@@ -122,9 +123,9 @@ const createTheme = (mode, theme = {}) => {
122
123
  },
123
124
  }, contained: {
124
125
  '&:hover': {
125
- color: (0, styles_1.getContrastRatio)('rgb(0, 0, 0)', primaryMainColor) >= 3
126
- ? 'rgb(0, 0, 0)'
127
- : 'rgb(255, 255, 255)',
126
+ color: (0, styles_1.getContrastRatio)(colors_1.common.white, primaryMainColor) >= 3
127
+ ? colors_1.common.white
128
+ : colors_1.common.black,
128
129
  },
129
130
  } }),
130
131
  },
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.13.6";
2
+ export declare const version = "1.14.1";
@@ -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.13.6';
5
+ exports.version = '1.14.1';
@@ -92,10 +92,10 @@ exports.WalletProvider = WalletProvider;
92
92
  const extractAccountFromSigner = (signer) => __awaiter(void 0, void 0, void 0, function* () {
93
93
  try {
94
94
  return {
95
- address: (yield (signer === null || signer === void 0 ? void 0 : signer.getAddress())) || undefined,
95
+ address: yield (signer === null || signer === void 0 ? void 0 : signer.getAddress()),
96
96
  isActive: (signer && !!(yield signer.getAddress()) === null) || !!signer,
97
97
  signer,
98
- chainId: (yield (signer === null || signer === void 0 ? void 0 : signer.getChainId())) || undefined,
98
+ chainId: yield (signer === null || signer === void 0 ? void 0 : signer.getChainId()),
99
99
  };
100
100
  }
101
101
  catch (error) {
@@ -16,6 +16,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
16
16
  const sdk_1 = require("@lifi/sdk");
17
17
  const react_1 = require("react");
18
18
  const lifi_1 = require("../../config/lifi");
19
+ const version_1 = require("../../config/version");
19
20
  const stub = () => {
20
21
  throw new Error('You forgot to wrap your component in <WidgetProvider>.');
21
22
  };
@@ -63,6 +64,9 @@ const WidgetProvider = (_a) => {
63
64
  },
64
65
  });
65
66
  }, [integrator]);
67
+ (0, react_1.useEffect)(() => {
68
+ (0, sdk_1.checkPackageUpdates)(version_1.name, version_1.version);
69
+ }, []);
66
70
  return ((0, jsx_runtime_1.jsx)(WidgetContext.Provider, Object.assign({ value: value }, { children: children })));
67
71
  };
68
72
  exports.WidgetProvider = WidgetProvider;
@@ -54,4 +54,40 @@ exports.useRouteStore = (0, zustand_1.default)()((0, middleware_1.persist)((0, i
54
54
  })), {
55
55
  name: 'li.fi-widget-routes',
56
56
  partialize: (state) => ({ routes: state.routes }),
57
+ merge: (persistedState, currentState) => {
58
+ const state = Object.assign(Object.assign({}, currentState), persistedState);
59
+ try {
60
+ const routeString = localStorage.getItem('routes');
61
+ if (routeString) {
62
+ const routes = JSON.parse(routeString);
63
+ routes.forEach((route) => {
64
+ if (state.routes[route.id]) {
65
+ return;
66
+ }
67
+ state.routes[route.id] = {
68
+ route,
69
+ status: 'idle',
70
+ };
71
+ const isFailed = route.steps.some((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
72
+ if (isFailed) {
73
+ state.routes[route.id].status = 'error';
74
+ return;
75
+ }
76
+ const isDone = route.steps.every((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE'; });
77
+ if (isDone) {
78
+ state.routes[route.id].status = 'success';
79
+ return;
80
+ }
81
+ const isLoading = route.steps.some((step) => step.execution);
82
+ if (isLoading) {
83
+ state.routes[route.id].status = 'loading';
84
+ }
85
+ });
86
+ }
87
+ }
88
+ catch (error) {
89
+ console.log(error);
90
+ }
91
+ return state;
92
+ },
57
93
  }));
@@ -1,3 +1,3 @@
1
1
  import type { Theme } from '@mui/material';
2
2
  export declare const getContrastAlphaColor: (theme: Theme, alpha: string | number) => string;
3
- export declare const getContrastTextColor: (theme: Theme, background?: string) => "rgb(0, 0, 0)" | "rgb(255, 255, 255)";
3
+ export declare const getContrastTextColor: (theme: Theme, background?: string) => "#fff" | "#000";
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getContrastTextColor = exports.getContrastAlphaColor = void 0;
4
+ const colors_1 = require("@mui/material/colors");
4
5
  const styles_1 = require("@mui/material/styles");
5
6
  const getContrastAlphaColor = (theme, alpha) => theme.palette.mode === 'light'
6
7
  ? `rgb(0 0 0 / ${alpha})`
7
8
  : `rgb(255 255 255 / ${alpha})`;
8
9
  exports.getContrastAlphaColor = getContrastAlphaColor;
9
- const getContrastTextColor = (theme, background) => (0, styles_1.getContrastRatio)('rgb(0, 0, 0)', background !== null && background !== void 0 ? background : theme.palette.primary.main) >=
10
- 3
11
- ? 'rgb(0, 0, 0)'
12
- : 'rgb(255, 255, 255)';
10
+ const getContrastTextColor = (theme, background) => (0, styles_1.getContrastRatio)(colors_1.common.white, background !== null && background !== void 0 ? background : theme.palette.primary.main) >= 3
11
+ ? colors_1.common.white
12
+ : colors_1.common.black;
13
13
  exports.getContrastTextColor = getContrastTextColor;
@@ -12,7 +12,7 @@ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollEleme
12
12
  const { getVirtualItems, getTotalSize, scrollToIndex } = useVirtualizer({
13
13
  count: tokens.length,
14
14
  getScrollElement: () => scrollElementRef.current,
15
- overscan: 5,
15
+ overscan: 10,
16
16
  paddingEnd: 12,
17
17
  estimateSize: (index) => {
18
18
  var _a, _b;
package/config/lifi.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import LIFI from '@lifi/sdk';
2
- export const LiFi = new LIFI();
2
+ export const LiFi = new LIFI({
3
+ disableVersionCheck: true,
4
+ });
3
5
  export const updateLiFiConfig = (configUpdate) => {
4
6
  LiFi.setConfig(configUpdate);
5
7
  };
package/config/theme.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { common } from '@mui/material/colors';
1
2
  import { dialogActionsClasses } from '@mui/material/DialogActions';
2
3
  import { alpha, createTheme as createMuiTheme, darken, getContrastRatio, lighten, } from '@mui/material/styles';
3
4
  const palette = {
@@ -119,9 +120,9 @@ export const createTheme = (mode, theme = {}) => {
119
120
  },
120
121
  }, contained: {
121
122
  '&:hover': {
122
- color: getContrastRatio('rgb(0, 0, 0)', primaryMainColor) >= 3
123
- ? 'rgb(0, 0, 0)'
124
- : 'rgb(255, 255, 255)',
123
+ color: getContrastRatio(common.white, primaryMainColor) >= 3
124
+ ? common.white
125
+ : common.black,
125
126
  },
126
127
  } }),
127
128
  },
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.13.6";
2
+ export declare const version = "1.14.1";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.13.6';
2
+ export const version = '1.14.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.13.6",
3
+ "version": "1.14.1",
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",
@@ -38,10 +38,10 @@
38
38
  "dependencies": {
39
39
  "@emotion/react": "^11.10.0",
40
40
  "@emotion/styled": "^11.10.0",
41
- "@ethersproject/experimental": "^5.6.3",
42
- "@ethersproject/providers": "^5.6.8",
43
- "@lifi/sdk": "^1.1.6",
44
- "@lifi/wallet-management": "^1.1.6",
41
+ "@ethersproject/experimental": "^5.7.0",
42
+ "@ethersproject/providers": "^5.7.0",
43
+ "@lifi/sdk": "^1.2.1",
44
+ "@lifi/wallet-management": "^1.1.7",
45
45
  "@mui/icons-material": "^5.8.4",
46
46
  "@mui/lab": "^5.0.0-alpha.95",
47
47
  "@mui/material": "^5.10.1",
@@ -59,7 +59,7 @@
59
59
  "react-i18next": "^11.18.4",
60
60
  "react-router-dom": "^6.3.0",
61
61
  "react-timer-hook": "^3.0.5",
62
- "zustand": "^4.1.0"
62
+ "zustand": "^4.1.1"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@types/react": "^18.0.0",
@@ -87,10 +87,10 @@ export const WalletProvider = ({ children, walletManagement }) => {
87
87
  export const extractAccountFromSigner = (signer) => __awaiter(void 0, void 0, void 0, function* () {
88
88
  try {
89
89
  return {
90
- address: (yield (signer === null || signer === void 0 ? void 0 : signer.getAddress())) || undefined,
90
+ address: yield (signer === null || signer === void 0 ? void 0 : signer.getAddress()),
91
91
  isActive: (signer && !!(yield signer.getAddress()) === null) || !!signer,
92
92
  signer,
93
- chainId: (yield (signer === null || signer === void 0 ? void 0 : signer.getChainId())) || undefined,
93
+ chainId: yield (signer === null || signer === void 0 ? void 0 : signer.getChainId()),
94
94
  };
95
95
  }
96
96
  catch (error) {
@@ -10,9 +10,10 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { getChainByKey } from '@lifi/sdk';
13
+ import { checkPackageUpdates, getChainByKey } from '@lifi/sdk';
14
14
  import { createContext, useContext, useEffect, useMemo } from 'react';
15
15
  import { updateLiFiConfig } from '../../config/lifi';
16
+ import { name, version } from '../../config/version';
16
17
  const stub = () => {
17
18
  throw new Error('You forgot to wrap your component in <WidgetProvider>.');
18
19
  };
@@ -59,5 +60,8 @@ export const WidgetProvider = (_a) => {
59
60
  },
60
61
  });
61
62
  }, [integrator]);
63
+ useEffect(() => {
64
+ checkPackageUpdates(name, version);
65
+ }, []);
62
66
  return (_jsx(WidgetContext.Provider, Object.assign({ value: value }, { children: children })));
63
67
  };
@@ -48,4 +48,40 @@ export const useRouteStore = create()(persist(immer((set) => ({
48
48
  })), {
49
49
  name: 'li.fi-widget-routes',
50
50
  partialize: (state) => ({ routes: state.routes }),
51
+ merge: (persistedState, currentState) => {
52
+ const state = Object.assign(Object.assign({}, currentState), persistedState);
53
+ try {
54
+ const routeString = localStorage.getItem('routes');
55
+ if (routeString) {
56
+ const routes = JSON.parse(routeString);
57
+ routes.forEach((route) => {
58
+ if (state.routes[route.id]) {
59
+ return;
60
+ }
61
+ state.routes[route.id] = {
62
+ route,
63
+ status: 'idle',
64
+ };
65
+ const isFailed = route.steps.some((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
66
+ if (isFailed) {
67
+ state.routes[route.id].status = 'error';
68
+ return;
69
+ }
70
+ const isDone = route.steps.every((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE'; });
71
+ if (isDone) {
72
+ state.routes[route.id].status = 'success';
73
+ return;
74
+ }
75
+ const isLoading = route.steps.some((step) => step.execution);
76
+ if (isLoading) {
77
+ state.routes[route.id].status = 'loading';
78
+ }
79
+ });
80
+ }
81
+ }
82
+ catch (error) {
83
+ console.log(error);
84
+ }
85
+ return state;
86
+ },
51
87
  }));