@lifi/widget 1.13.7 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/config/lifi.js +3 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/providers/WalletProvider/WalletProvider.js +2 -2
- package/cjs/providers/WidgetProvider/WidgetProvider.js +4 -0
- package/cjs/stores/route/useRouteStore.js +36 -0
- package/config/lifi.js +3 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/package.json +2 -2
- package/providers/WalletProvider/WalletProvider.js +2 -2
- package/providers/WidgetProvider/WidgetProvider.js +5 -1
- package/stores/route/useRouteStore.js +36 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
package/cjs/config/lifi.js
CHANGED
|
@@ -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
|
};
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.14.0";
|
package/cjs/config/version.js
CHANGED
|
@@ -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:
|
|
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:
|
|
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
|
}));
|
package/config/lifi.js
CHANGED
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.14.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.14.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.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
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@emotion/styled": "^11.10.0",
|
|
41
41
|
"@ethersproject/experimental": "^5.7.0",
|
|
42
42
|
"@ethersproject/providers": "^5.7.0",
|
|
43
|
-
"@lifi/sdk": "^1.1
|
|
43
|
+
"@lifi/sdk": "^1.2.1",
|
|
44
44
|
"@lifi/wallet-management": "^1.1.7",
|
|
45
45
|
"@mui/icons-material": "^5.8.4",
|
|
46
46
|
"@mui/lab": "^5.0.0-alpha.95",
|
|
@@ -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:
|
|
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:
|
|
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
|
}));
|