@lifi/widget 2.2.0-beta.2 → 2.2.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/components/GasMessage/GasMessage.js +1 -1
- package/cjs/components/GasMessage/GasMessage.style.js +1 -1
- package/cjs/components/TokenList/useTokenSelect.js +9 -0
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/pages/TransactionPage/StartTransactionButton.js +1 -1
- package/cjs/types/events.d.ts +10 -2
- package/cjs/types/events.js +2 -0
- package/components/GasMessage/GasMessage.js +1 -1
- package/components/GasMessage/GasMessage.style.js +1 -1
- package/components/TokenList/useTokenSelect.js +9 -0
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/package.json +4 -4
- package/pages/TransactionPage/StartTransactionButton.js +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +10 -2
- package/types/events.js +2 -0
|
@@ -4,9 +4,9 @@ exports.GasMessage = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const hooks_1 = require("../../hooks");
|
|
7
|
+
const providers_1 = require("../../providers");
|
|
7
8
|
const FundsSufficiencyMessage_1 = require("./FundsSufficiencyMessage");
|
|
8
9
|
const GasSufficiencyMessage_1 = require("./GasSufficiencyMessage");
|
|
9
|
-
const providers_1 = require("../../providers");
|
|
10
10
|
const GasMessage = ({ route, ...props }) => {
|
|
11
11
|
const { insufficientGas } = (0, hooks_1.useGasSufficiency)(route);
|
|
12
12
|
const { insufficientFunds } = (0, hooks_1.useFundsSufficiency)(route);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InfoMessageSwitch = exports.InfoMessageCardTitle = exports.InfoMessageCard = exports.WarningMessageCardTitle = exports.WarningMessageCard = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
|
-
const styles_1 = require("@mui/material/styles");
|
|
6
5
|
const Switch_1 = require("@mui/material/Switch");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
7
|
const Switch_2 = require("../Switch");
|
|
8
8
|
const MessageCard = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
9
9
|
borderRadius: theme.shape.borderRadius,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useTokenSelect = void 0;
|
|
4
|
+
const widget_1 = require("@lifi/widget");
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
6
7
|
const providers_1 = require("../../providers");
|
|
@@ -9,6 +10,7 @@ const useTokenSelect = (formType, onClick) => {
|
|
|
9
10
|
const { field: { onChange, onBlur }, } = (0, react_hook_form_1.useController)({ name: tokenKey });
|
|
10
11
|
const { setValue, getValues } = (0, react_hook_form_1.useFormContext)();
|
|
11
12
|
const { subvariant } = (0, providers_1.useWidgetConfig)();
|
|
13
|
+
const emitter = (0, widget_1.useWidgetEvents)();
|
|
12
14
|
return (0, react_1.useCallback)((tokenAddress, chainId) => {
|
|
13
15
|
onChange(tokenAddress);
|
|
14
16
|
onBlur();
|
|
@@ -32,6 +34,13 @@ const useTokenSelect = (formType, onClick) => {
|
|
|
32
34
|
shouldTouch: true,
|
|
33
35
|
});
|
|
34
36
|
}
|
|
37
|
+
const eventToEmit = formType === 'from'
|
|
38
|
+
? widget_1.WidgetEvent.SourceChainTokenSelected
|
|
39
|
+
: widget_1.WidgetEvent.DestinationChainTokenSelected;
|
|
40
|
+
emitter.emit(eventToEmit, {
|
|
41
|
+
chainId: selectedChainId,
|
|
42
|
+
tokenAddress,
|
|
43
|
+
});
|
|
35
44
|
onClick?.();
|
|
36
45
|
}, [formType, getValues, onBlur, onChange, onClick, setValue, subvariant]);
|
|
37
46
|
};
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.2.0
|
|
2
|
+
export declare const version = "2.2.0";
|
package/cjs/config/version.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StartInsurableTransactionButton = exports.StartTransactionButton = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const providers_1 = require("../../providers");
|
|
6
5
|
const DefaultTransactionButton_1 = require("../../components/DefaultTransactionButton");
|
|
7
6
|
const hooks_1 = require("../../hooks");
|
|
7
|
+
const providers_1 = require("../../providers");
|
|
8
8
|
const stores_1 = require("../../stores");
|
|
9
9
|
const StartTransactionButton = ({ onClick, route, text, loading, }) => {
|
|
10
10
|
const { sdkConfig } = (0, providers_1.useWidgetConfig)();
|
package/cjs/types/events.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { Process, Route } from '@lifi/sdk';
|
|
1
|
+
import type { ChainId, Process, Route } from '@lifi/sdk';
|
|
2
2
|
export declare enum WidgetEvent {
|
|
3
3
|
RouteExecutionStarted = "routeExecutionStarted",
|
|
4
4
|
RouteExecutionUpdated = "routeExecutionUpdated",
|
|
5
5
|
RouteExecutionCompleted = "routeExecutionCompleted",
|
|
6
6
|
RouteExecutionFailed = "routeExecutionFailed",
|
|
7
7
|
RouteHighValueLoss = "routeHighValueLoss",
|
|
8
|
-
RouteContactSupport = "routeContactSupport"
|
|
8
|
+
RouteContactSupport = "routeContactSupport",
|
|
9
|
+
SourceChainTokenSelected = "sourceChainTokenSelected",
|
|
10
|
+
DestinationChainTokenSelected = "destinationChainTokenSelected"
|
|
9
11
|
}
|
|
10
12
|
export type WidgetEvents = {
|
|
11
13
|
routeExecutionStarted: Route;
|
|
@@ -14,6 +16,8 @@ export type WidgetEvents = {
|
|
|
14
16
|
routeExecutionFailed: RouteExecutionUpdate;
|
|
15
17
|
routeHighValueLoss: RouteHighValueLossUpdate;
|
|
16
18
|
routeContactSupport: RouteContactSupport;
|
|
19
|
+
sourceChainTokenSelected: ChainTokenSelected;
|
|
20
|
+
destinationChainTokenSelected: ChainTokenSelected;
|
|
17
21
|
};
|
|
18
22
|
export interface RouteContactSupport {
|
|
19
23
|
supportId?: string;
|
|
@@ -28,3 +32,7 @@ export interface RouteExecutionUpdate {
|
|
|
28
32
|
route: Route;
|
|
29
33
|
process: Process;
|
|
30
34
|
}
|
|
35
|
+
export interface ChainTokenSelected {
|
|
36
|
+
chainId: ChainId;
|
|
37
|
+
tokenAddress: string;
|
|
38
|
+
}
|
package/cjs/types/events.js
CHANGED
|
@@ -9,4 +9,6 @@ var WidgetEvent;
|
|
|
9
9
|
WidgetEvent["RouteExecutionFailed"] = "routeExecutionFailed";
|
|
10
10
|
WidgetEvent["RouteHighValueLoss"] = "routeHighValueLoss";
|
|
11
11
|
WidgetEvent["RouteContactSupport"] = "routeContactSupport";
|
|
12
|
+
WidgetEvent["SourceChainTokenSelected"] = "sourceChainTokenSelected";
|
|
13
|
+
WidgetEvent["DestinationChainTokenSelected"] = "destinationChainTokenSelected";
|
|
12
14
|
})(WidgetEvent || (exports.WidgetEvent = WidgetEvent = {}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Collapse } from '@mui/material';
|
|
3
3
|
import { useFundsSufficiency, useGasSufficiency } from '../../hooks';
|
|
4
|
+
import { useWidgetConfig } from '../../providers';
|
|
4
5
|
import { FundsSufficiencyMessage } from './FundsSufficiencyMessage';
|
|
5
6
|
import { GasSufficiencyMessage } from './GasSufficiencyMessage';
|
|
6
|
-
import { useWidgetConfig } from '../../providers';
|
|
7
7
|
export const GasMessage = ({ route, ...props }) => {
|
|
8
8
|
const { insufficientGas } = useGasSufficiency(route);
|
|
9
9
|
const { insufficientFunds } = useFundsSufficiency(route);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Box } from '@mui/material';
|
|
2
|
-
import { alpha, darken, lighten, styled } from '@mui/material/styles';
|
|
3
2
|
import { switchClasses } from '@mui/material/Switch';
|
|
3
|
+
import { alpha, darken, lighten, styled } from '@mui/material/styles';
|
|
4
4
|
import { Switch } from '../Switch';
|
|
5
5
|
const MessageCard = styled(Box)(({ theme }) => ({
|
|
6
6
|
borderRadius: theme.shape.borderRadius,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WidgetEvent, useWidgetEvents } from '@lifi/widget';
|
|
1
2
|
import { useCallback } from 'react';
|
|
2
3
|
import { useController, useFormContext } from 'react-hook-form';
|
|
3
4
|
import { FormKeyHelper, useWidgetConfig } from '../../providers';
|
|
@@ -6,6 +7,7 @@ export const useTokenSelect = (formType, onClick) => {
|
|
|
6
7
|
const { field: { onChange, onBlur }, } = useController({ name: tokenKey });
|
|
7
8
|
const { setValue, getValues } = useFormContext();
|
|
8
9
|
const { subvariant } = useWidgetConfig();
|
|
10
|
+
const emitter = useWidgetEvents();
|
|
9
11
|
return useCallback((tokenAddress, chainId) => {
|
|
10
12
|
onChange(tokenAddress);
|
|
11
13
|
onBlur();
|
|
@@ -29,6 +31,13 @@ export const useTokenSelect = (formType, onClick) => {
|
|
|
29
31
|
shouldTouch: true,
|
|
30
32
|
});
|
|
31
33
|
}
|
|
34
|
+
const eventToEmit = formType === 'from'
|
|
35
|
+
? WidgetEvent.SourceChainTokenSelected
|
|
36
|
+
: WidgetEvent.DestinationChainTokenSelected;
|
|
37
|
+
emitter.emit(eventToEmit, {
|
|
38
|
+
chainId: selectedChainId,
|
|
39
|
+
tokenAddress,
|
|
40
|
+
});
|
|
32
41
|
onClick?.();
|
|
33
42
|
}, [formType, getValues, onBlur, onChange, onClick, setValue, subvariant]);
|
|
34
43
|
};
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.2.0
|
|
2
|
+
export declare const version = "2.2.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '2.2.0
|
|
2
|
+
export const version = '2.2.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "2.2.0
|
|
3
|
+
"version": "2.2.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",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@ethersproject/address": "^5.7.0",
|
|
44
44
|
"@ethersproject/experimental": "^5.7.0",
|
|
45
45
|
"@ethersproject/providers": "^5.7.2",
|
|
46
|
-
"@lifi/sdk": "^2.2.0
|
|
47
|
-
"@lifi/wallet-management": "^2.2.0
|
|
46
|
+
"@lifi/sdk": "^2.2.0",
|
|
47
|
+
"@lifi/wallet-management": "^2.2.0",
|
|
48
48
|
"@mui/icons-material": "^5.13.7",
|
|
49
49
|
"@mui/lab": "^5.0.0-alpha.135",
|
|
50
50
|
"@mui/material": "^5.13.7",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"react": "^18.2.0",
|
|
59
59
|
"react-dom": "^18.2.0",
|
|
60
60
|
"react-hook-form": "^7.45.1",
|
|
61
|
-
"react-i18next": "^13.0.
|
|
61
|
+
"react-i18next": "^13.0.2",
|
|
62
62
|
"react-intersection-observer": "^9.5.2",
|
|
63
63
|
"react-router-dom": "^6.14.1",
|
|
64
64
|
"react-timer-hook": "^3.0.6",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useWidgetConfig } from '../../providers';
|
|
3
2
|
import { DefaultTransactionButton } from '../../components/DefaultTransactionButton';
|
|
4
3
|
import { useFundsSufficiency, useGasSufficiency, useRoutes } from '../../hooks';
|
|
4
|
+
import { useWidgetConfig } from '../../providers';
|
|
5
5
|
import { useRouteExecutionStore } from '../../stores';
|
|
6
6
|
export const StartTransactionButton = ({ onClick, route, text, loading, }) => {
|
|
7
7
|
const { sdkConfig } = useWidgetConfig();
|