@lifi/widget 2.4.6 → 2.5.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 +2 -2
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +1 -1
- package/cjs/hooks/index.js +1 -1
- package/cjs/hooks/useFromTokenSufficiency.d.ts +5 -0
- package/cjs/hooks/{useFundsSufficiency.js → useFromTokenSufficiency.js} +6 -6
- package/cjs/hooks/useGasSufficiency.js +14 -8
- package/cjs/i18n/pt.json +2 -1
- package/cjs/i18n/tr.json +2 -1
- package/cjs/i18n/uk.json +2 -1
- package/cjs/pages/TransactionPage/StartTransactionButton.js +3 -3
- package/cjs/providers/SDKProvider/SDKProvider.js +5 -4
- package/cjs/types/widget.d.ts +2 -1
- package/components/GasMessage/GasMessage.js +3 -3
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -1
- package/hooks/index.js +1 -1
- package/hooks/useFromTokenSufficiency.d.ts +5 -0
- package/hooks/{useFundsSufficiency.js → useFromTokenSufficiency.js} +4 -4
- package/hooks/useGasSufficiency.js +14 -8
- package/i18n/pt.json +2 -1
- package/i18n/tr.json +2 -1
- package/i18n/uk.json +2 -1
- package/package.json +10 -10
- package/pages/TransactionPage/StartTransactionButton.js +4 -4
- package/providers/SDKProvider/SDKProvider.js +5 -4
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +2 -1
- package/cjs/hooks/useFundsSufficiency.d.ts +0 -5
- package/hooks/useFundsSufficiency.d.ts +0 -5
|
@@ -9,10 +9,10 @@ const FundsSufficiencyMessage_1 = require("./FundsSufficiencyMessage");
|
|
|
9
9
|
const GasSufficiencyMessage_1 = require("./GasSufficiencyMessage");
|
|
10
10
|
const GasMessage = ({ route, ...props }) => {
|
|
11
11
|
const { insufficientGas } = (0, hooks_1.useGasSufficiency)(route);
|
|
12
|
-
const {
|
|
12
|
+
const { insufficientFromToken } = (0, hooks_1.useFromTokenSufficiency)(route);
|
|
13
13
|
const { sdkConfig } = (0, providers_1.useWidgetConfig)();
|
|
14
14
|
const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
|
|
15
15
|
const validInsufficientGas = insufficientGas?.length && !isMultisigSigner;
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: Boolean(
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: Boolean(insufficientFromToken || validInsufficientGas), unmountOnExit: true, mountOnEnter: true, children: (0, jsx_runtime_1.jsx)(material_1.Box, { ...props, children: insufficientFromToken ? ((0, jsx_runtime_1.jsx)(FundsSufficiencyMessage_1.FundsSufficiencyMessage, {})) : validInsufficientGas ? ((0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
|
|
17
17
|
};
|
|
18
18
|
exports.GasMessage = GasMessage;
|
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
|
+
export declare const version = "2.5.0";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from './useDebouncedWatch';
|
|
|
5
5
|
export * from './useDefaultElementId';
|
|
6
6
|
export * from './useExpandableVariant';
|
|
7
7
|
export * from './useFeaturedTokens';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './useFromTokenSufficiency';
|
|
9
9
|
export * from './useGasRecommendation';
|
|
10
10
|
export * from './useGasRefuel';
|
|
11
11
|
export * from './useGasSufficiency';
|
package/cjs/hooks/index.js
CHANGED
|
@@ -21,7 +21,7 @@ __exportStar(require("./useDebouncedWatch"), exports);
|
|
|
21
21
|
__exportStar(require("./useDefaultElementId"), exports);
|
|
22
22
|
__exportStar(require("./useExpandableVariant"), exports);
|
|
23
23
|
__exportStar(require("./useFeaturedTokens"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
24
|
+
__exportStar(require("./useFromTokenSufficiency"), exports);
|
|
25
25
|
__exportStar(require("./useGasRecommendation"), exports);
|
|
26
26
|
__exportStar(require("./useGasRefuel"), exports);
|
|
27
27
|
__exportStar(require("./useGasSufficiency"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useFromTokenSufficiency = void 0;
|
|
4
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
5
|
const big_js_1 = require("big.js");
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
@@ -9,7 +9,7 @@ const stores_1 = require("../stores");
|
|
|
9
9
|
const useGetTokenBalancesWithRetry_1 = require("./useGetTokenBalancesWithRetry");
|
|
10
10
|
const useTokenAddressBalance_1 = require("./useTokenAddressBalance");
|
|
11
11
|
const refetchInterval = 30000;
|
|
12
|
-
const
|
|
12
|
+
const useFromTokenSufficiency = (route) => {
|
|
13
13
|
const { account } = (0, providers_1.useWallet)();
|
|
14
14
|
const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(account.signer?.provider);
|
|
15
15
|
const [fromChainId, fromTokenAddress, fromAmount] = (0, react_hook_form_1.useWatch)({
|
|
@@ -22,8 +22,8 @@ const useFundsSufficiency = (route) => {
|
|
|
22
22
|
tokenAddress = route.fromToken.address;
|
|
23
23
|
}
|
|
24
24
|
const { token, isLoading } = (0, useTokenAddressBalance_1.useTokenAddressBalance)(chainId, tokenAddress);
|
|
25
|
-
const { data:
|
|
26
|
-
'
|
|
25
|
+
const { data: insufficientFromToken, isInitialLoading } = (0, react_query_1.useQuery)([
|
|
26
|
+
'from-token-sufficiency-check',
|
|
27
27
|
account.address,
|
|
28
28
|
chainId,
|
|
29
29
|
tokenAddress,
|
|
@@ -62,8 +62,8 @@ const useFundsSufficiency = (route) => {
|
|
|
62
62
|
keepPreviousData: true,
|
|
63
63
|
});
|
|
64
64
|
return {
|
|
65
|
-
|
|
65
|
+
insufficientFromToken,
|
|
66
66
|
isInitialLoading,
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
|
-
exports.
|
|
69
|
+
exports.useFromTokenSufficiency = useFromTokenSufficiency;
|
|
@@ -30,21 +30,27 @@ const useGasSufficiency = (route) => {
|
|
|
30
30
|
const gasCostAmount = step.estimate.gasCosts
|
|
31
31
|
.reduce((amount, gasCost) => amount.plus((0, big_js_1.default)(gasCost.amount || 0)), (0, big_js_1.default)(0))
|
|
32
32
|
.div(10 ** token.decimals);
|
|
33
|
-
const groupedGasCost = groupedGasCosts[token.chainId];
|
|
34
|
-
const gasAmount = groupedGasCost
|
|
35
|
-
? groupedGasCost.gasAmount.plus(gasCostAmount)
|
|
36
|
-
: gasCostAmount;
|
|
37
33
|
groupedGasCosts[token.chainId] = {
|
|
38
|
-
gasAmount,
|
|
39
|
-
|
|
34
|
+
gasAmount: groupedGasCosts[token.chainId]?.gasAmount.plus(gasCostAmount) ?? gasCostAmount,
|
|
35
|
+
token,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Add fees paid in native tokens to gas sufficiency check (included: false)
|
|
39
|
+
const nonIncludedFeeCosts = step.estimate.feeCosts?.filter((feeCost) => !feeCost.included);
|
|
40
|
+
if (nonIncludedFeeCosts?.length) {
|
|
41
|
+
const { token } = nonIncludedFeeCosts[0];
|
|
42
|
+
const feeCostAmount = nonIncludedFeeCosts
|
|
43
|
+
.reduce((amount, feeCost) => amount.plus((0, big_js_1.default)(feeCost.amount || 0)), (0, big_js_1.default)(0))
|
|
44
|
+
.div(10 ** token.decimals);
|
|
45
|
+
groupedGasCosts[token.chainId] = {
|
|
46
|
+
gasAmount: groupedGasCosts[token.chainId]?.gasAmount.plus(feeCostAmount) ?? feeCostAmount,
|
|
40
47
|
token,
|
|
41
48
|
};
|
|
42
|
-
return groupedGasCosts;
|
|
43
49
|
}
|
|
44
50
|
return groupedGasCosts;
|
|
45
51
|
}, {});
|
|
46
52
|
if (route.fromToken.address === gasCosts[route.fromChainId]?.token.address) {
|
|
47
|
-
gasCosts[route.fromChainId].tokenAmount = gasCosts[route.fromChainId]
|
|
53
|
+
gasCosts[route.fromChainId].tokenAmount = gasCosts[route.fromChainId].gasAmount.plus((0, big_js_1.default)(route.fromAmount).div(10 ** route.fromToken.decimals));
|
|
48
54
|
}
|
|
49
55
|
const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
50
56
|
if (!tokenBalances?.length) {
|
package/cjs/i18n/pt.json
CHANGED
|
@@ -255,7 +255,8 @@
|
|
|
255
255
|
},
|
|
256
256
|
"routePriority": "Prioridade de rota / caminho",
|
|
257
257
|
"showDestinationWallet": "Mostrar carteira de destino",
|
|
258
|
-
"slippage": "Derrapagem"
|
|
258
|
+
"slippage": "Derrapagem",
|
|
259
|
+
"resetSettings": "Você está usando a configuração personalizada que limita a quantidade de rotas disponíveis."
|
|
259
260
|
},
|
|
260
261
|
"wallet": {
|
|
261
262
|
"extensionNotFound": "Por favor, certifique-se de que apenas a extensão do navegador da {{name}} está ativa antes de escolher esta carteira."
|
package/cjs/i18n/tr.json
CHANGED
|
@@ -255,7 +255,8 @@
|
|
|
255
255
|
},
|
|
256
256
|
"routePriority": "Rota önceliği",
|
|
257
257
|
"showDestinationWallet": "Hedef Adresi Göster",
|
|
258
|
-
"slippage": "Sapma toleransı"
|
|
258
|
+
"slippage": "Sapma toleransı",
|
|
259
|
+
"resetSettings": "Kullanılabilir rotaların sayısını sınırlayan özel bir ayar kullanıyorsunuz."
|
|
259
260
|
},
|
|
260
261
|
"wallet": {
|
|
261
262
|
"extensionNotFound": "Lütfen bu cüzdanı seçmeden önce yalnızca {{name}} tarayıcı uzantısının etkin olduğundan emin olun."
|
package/cjs/i18n/uk.json
CHANGED
|
@@ -255,7 +255,8 @@
|
|
|
255
255
|
},
|
|
256
256
|
"routePriority": "Пріоритет маршруту",
|
|
257
257
|
"showDestinationWallet": "Показати цільовий гаманець",
|
|
258
|
-
"slippage": "Прослизання"
|
|
258
|
+
"slippage": "Прослизання",
|
|
259
|
+
"resetSettings": "Ви використовуєте налаштування які можуть обмежувати кількість доступних маршрутів."
|
|
259
260
|
},
|
|
260
261
|
"wallet": {
|
|
261
262
|
"extensionNotFound": "Перш ніж вибрати цей гаманець, переконайтеся, що в браузері активне лише розширення {{name}}."
|
|
@@ -10,9 +10,9 @@ const StartTransactionButton = ({ onClick, route, text, loading, }) => {
|
|
|
10
10
|
const { sdkConfig } = (0, providers_1.useWidgetConfig)();
|
|
11
11
|
const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
|
|
12
12
|
const { insufficientGas, isInitialLoading: isGasSufficiencyLoading } = (0, hooks_1.useGasSufficiency)(route);
|
|
13
|
-
const {
|
|
14
|
-
const shouldDisableButton = !isMultisigSigner && (
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(DefaultTransactionButton_1.DefaultTransactionButton, { onClick: onClick, text: text, disabled: shouldDisableButton, loading:
|
|
13
|
+
const { insufficientFromToken, isInitialLoading: isFromTokenSufficiencyLoading, } = (0, hooks_1.useFromTokenSufficiency)(route);
|
|
14
|
+
const shouldDisableButton = !isMultisigSigner && (insufficientFromToken || !!insufficientGas?.length);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(DefaultTransactionButton_1.DefaultTransactionButton, { onClick: onClick, text: text, disabled: shouldDisableButton, loading: isFromTokenSufficiencyLoading || isGasSufficiencyLoading || loading }));
|
|
16
16
|
};
|
|
17
17
|
exports.StartTransactionButton = StartTransactionButton;
|
|
18
18
|
const StartInsurableTransactionButton = ({ onClick, text, route, loading, disabled, insurableRouteId }) => {
|
|
@@ -11,16 +11,17 @@ const SDKContext = (0, react_1.createContext)(null);
|
|
|
11
11
|
const useLiFi = () => (0, react_1.useContext)(SDKContext);
|
|
12
12
|
exports.useLiFi = useLiFi;
|
|
13
13
|
const SDKProvider = ({ children, }) => {
|
|
14
|
-
const { sdkConfig,
|
|
14
|
+
const { sdkConfig, integrator, apiKey, fee, referrer, routePriority, slippage, } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
15
15
|
const value = (0, react_1.useMemo)(() => {
|
|
16
16
|
const config = {
|
|
17
17
|
...sdkConfig,
|
|
18
|
+
apiKey,
|
|
18
19
|
integrator: integrator ?? window.location.hostname,
|
|
19
20
|
defaultRouteOptions: {
|
|
20
|
-
fee,
|
|
21
21
|
integrator: integrator ?? window.location.hostname,
|
|
22
|
+
fee,
|
|
22
23
|
referrer,
|
|
23
|
-
routePriority,
|
|
24
|
+
order: routePriority,
|
|
24
25
|
slippage,
|
|
25
26
|
...sdkConfig?.defaultRouteOptions,
|
|
26
27
|
},
|
|
@@ -34,7 +35,7 @@ const SDKProvider = ({ children, }) => {
|
|
|
34
35
|
}
|
|
35
36
|
lifi.setConfig(config);
|
|
36
37
|
return lifi;
|
|
37
|
-
}, [fee, integrator, referrer, routePriority, sdkConfig, slippage]);
|
|
38
|
+
}, [apiKey, fee, integrator, referrer, routePriority, sdkConfig, slippage]);
|
|
38
39
|
return (0, jsx_runtime_1.jsx)(SDKContext.Provider, { value: value, children: children });
|
|
39
40
|
};
|
|
40
41
|
exports.SDKProvider = SDKProvider;
|
package/cjs/types/widget.d.ts
CHANGED
|
@@ -72,8 +72,9 @@ export interface WidgetConfig {
|
|
|
72
72
|
contractSecondaryComponent?: ReactNode;
|
|
73
73
|
contractCompactComponent?: ReactNode;
|
|
74
74
|
contractTool?: WidgetContractTool;
|
|
75
|
-
fee?: number;
|
|
76
75
|
integrator: string;
|
|
76
|
+
apiKey?: string;
|
|
77
|
+
fee?: number;
|
|
77
78
|
referrer?: string;
|
|
78
79
|
routePriority?: Order;
|
|
79
80
|
slippage?: number;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Collapse } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { useFromTokenSufficiency, useGasSufficiency } from '../../hooks';
|
|
4
4
|
import { useWidgetConfig } from '../../providers';
|
|
5
5
|
import { FundsSufficiencyMessage } from './FundsSufficiencyMessage';
|
|
6
6
|
import { GasSufficiencyMessage } from './GasSufficiencyMessage';
|
|
7
7
|
export const GasMessage = ({ route, ...props }) => {
|
|
8
8
|
const { insufficientGas } = useGasSufficiency(route);
|
|
9
|
-
const {
|
|
9
|
+
const { insufficientFromToken } = useFromTokenSufficiency(route);
|
|
10
10
|
const { sdkConfig } = useWidgetConfig();
|
|
11
11
|
const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
|
|
12
12
|
const validInsufficientGas = insufficientGas?.length && !isMultisigSigner;
|
|
13
|
-
return (_jsx(Collapse, { timeout: 225, in: Boolean(
|
|
13
|
+
return (_jsx(Collapse, { timeout: 225, in: Boolean(insufficientFromToken || validInsufficientGas), unmountOnExit: true, mountOnEnter: true, children: _jsx(Box, { ...props, children: insufficientFromToken ? (_jsx(FundsSufficiencyMessage, {})) : validInsufficientGas ? (_jsx(GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
|
|
14
14
|
};
|
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
|
+
export declare const version = "2.5.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '2.
|
|
2
|
+
export const version = '2.5.0';
|
package/hooks/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from './useDebouncedWatch';
|
|
|
5
5
|
export * from './useDefaultElementId';
|
|
6
6
|
export * from './useExpandableVariant';
|
|
7
7
|
export * from './useFeaturedTokens';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './useFromTokenSufficiency';
|
|
9
9
|
export * from './useGasRecommendation';
|
|
10
10
|
export * from './useGasRefuel';
|
|
11
11
|
export * from './useGasSufficiency';
|
package/hooks/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export * from './useDebouncedWatch';
|
|
|
5
5
|
export * from './useDefaultElementId';
|
|
6
6
|
export * from './useExpandableVariant';
|
|
7
7
|
export * from './useFeaturedTokens';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './useFromTokenSufficiency';
|
|
9
9
|
export * from './useGasRecommendation';
|
|
10
10
|
export * from './useGasRefuel';
|
|
11
11
|
export * from './useGasSufficiency';
|
|
@@ -6,7 +6,7 @@ import { isRouteDone } from '../stores';
|
|
|
6
6
|
import { useGetTokenBalancesWithRetry } from './useGetTokenBalancesWithRetry';
|
|
7
7
|
import { useTokenAddressBalance } from './useTokenAddressBalance';
|
|
8
8
|
const refetchInterval = 30000;
|
|
9
|
-
export const
|
|
9
|
+
export const useFromTokenSufficiency = (route) => {
|
|
10
10
|
const { account } = useWallet();
|
|
11
11
|
const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(account.signer?.provider);
|
|
12
12
|
const [fromChainId, fromTokenAddress, fromAmount] = useWatch({
|
|
@@ -19,8 +19,8 @@ export const useFundsSufficiency = (route) => {
|
|
|
19
19
|
tokenAddress = route.fromToken.address;
|
|
20
20
|
}
|
|
21
21
|
const { token, isLoading } = useTokenAddressBalance(chainId, tokenAddress);
|
|
22
|
-
const { data:
|
|
23
|
-
'
|
|
22
|
+
const { data: insufficientFromToken, isInitialLoading } = useQuery([
|
|
23
|
+
'from-token-sufficiency-check',
|
|
24
24
|
account.address,
|
|
25
25
|
chainId,
|
|
26
26
|
tokenAddress,
|
|
@@ -59,7 +59,7 @@ export const useFundsSufficiency = (route) => {
|
|
|
59
59
|
keepPreviousData: true,
|
|
60
60
|
});
|
|
61
61
|
return {
|
|
62
|
-
|
|
62
|
+
insufficientFromToken,
|
|
63
63
|
isInitialLoading,
|
|
64
64
|
};
|
|
65
65
|
};
|
|
@@ -27,21 +27,27 @@ export const useGasSufficiency = (route) => {
|
|
|
27
27
|
const gasCostAmount = step.estimate.gasCosts
|
|
28
28
|
.reduce((amount, gasCost) => amount.plus(Big(gasCost.amount || 0)), Big(0))
|
|
29
29
|
.div(10 ** token.decimals);
|
|
30
|
-
const groupedGasCost = groupedGasCosts[token.chainId];
|
|
31
|
-
const gasAmount = groupedGasCost
|
|
32
|
-
? groupedGasCost.gasAmount.plus(gasCostAmount)
|
|
33
|
-
: gasCostAmount;
|
|
34
30
|
groupedGasCosts[token.chainId] = {
|
|
35
|
-
gasAmount,
|
|
36
|
-
|
|
31
|
+
gasAmount: groupedGasCosts[token.chainId]?.gasAmount.plus(gasCostAmount) ?? gasCostAmount,
|
|
32
|
+
token,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Add fees paid in native tokens to gas sufficiency check (included: false)
|
|
36
|
+
const nonIncludedFeeCosts = step.estimate.feeCosts?.filter((feeCost) => !feeCost.included);
|
|
37
|
+
if (nonIncludedFeeCosts?.length) {
|
|
38
|
+
const { token } = nonIncludedFeeCosts[0];
|
|
39
|
+
const feeCostAmount = nonIncludedFeeCosts
|
|
40
|
+
.reduce((amount, feeCost) => amount.plus(Big(feeCost.amount || 0)), Big(0))
|
|
41
|
+
.div(10 ** token.decimals);
|
|
42
|
+
groupedGasCosts[token.chainId] = {
|
|
43
|
+
gasAmount: groupedGasCosts[token.chainId]?.gasAmount.plus(feeCostAmount) ?? feeCostAmount,
|
|
37
44
|
token,
|
|
38
45
|
};
|
|
39
|
-
return groupedGasCosts;
|
|
40
46
|
}
|
|
41
47
|
return groupedGasCosts;
|
|
42
48
|
}, {});
|
|
43
49
|
if (route.fromToken.address === gasCosts[route.fromChainId]?.token.address) {
|
|
44
|
-
gasCosts[route.fromChainId].tokenAmount = gasCosts[route.fromChainId]
|
|
50
|
+
gasCosts[route.fromChainId].tokenAmount = gasCosts[route.fromChainId].gasAmount.plus(Big(route.fromAmount).div(10 ** route.fromToken.decimals));
|
|
45
51
|
}
|
|
46
52
|
const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
47
53
|
if (!tokenBalances?.length) {
|
package/i18n/pt.json
CHANGED
|
@@ -255,7 +255,8 @@
|
|
|
255
255
|
},
|
|
256
256
|
"routePriority": "Prioridade de rota / caminho",
|
|
257
257
|
"showDestinationWallet": "Mostrar carteira de destino",
|
|
258
|
-
"slippage": "Derrapagem"
|
|
258
|
+
"slippage": "Derrapagem",
|
|
259
|
+
"resetSettings": "Você está usando a configuração personalizada que limita a quantidade de rotas disponíveis."
|
|
259
260
|
},
|
|
260
261
|
"wallet": {
|
|
261
262
|
"extensionNotFound": "Por favor, certifique-se de que apenas a extensão do navegador da {{name}} está ativa antes de escolher esta carteira."
|
package/i18n/tr.json
CHANGED
|
@@ -255,7 +255,8 @@
|
|
|
255
255
|
},
|
|
256
256
|
"routePriority": "Rota önceliği",
|
|
257
257
|
"showDestinationWallet": "Hedef Adresi Göster",
|
|
258
|
-
"slippage": "Sapma toleransı"
|
|
258
|
+
"slippage": "Sapma toleransı",
|
|
259
|
+
"resetSettings": "Kullanılabilir rotaların sayısını sınırlayan özel bir ayar kullanıyorsunuz."
|
|
259
260
|
},
|
|
260
261
|
"wallet": {
|
|
261
262
|
"extensionNotFound": "Lütfen bu cüzdanı seçmeden önce yalnızca {{name}} tarayıcı uzantısının etkin olduğundan emin olun."
|
package/i18n/uk.json
CHANGED
|
@@ -255,7 +255,8 @@
|
|
|
255
255
|
},
|
|
256
256
|
"routePriority": "Пріоритет маршруту",
|
|
257
257
|
"showDestinationWallet": "Показати цільовий гаманець",
|
|
258
|
-
"slippage": "Прослизання"
|
|
258
|
+
"slippage": "Прослизання",
|
|
259
|
+
"resetSettings": "Ви використовуєте налаштування які можуть обмежувати кількість доступних маршрутів."
|
|
259
260
|
},
|
|
260
261
|
"wallet": {
|
|
261
262
|
"extensionNotFound": "Перш ніж вибрати цей гаманець, переконайтеся, що в браузері активне лише розширення {{name}}."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.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,13 +43,13 @@
|
|
|
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.4.
|
|
47
|
-
"@lifi/wallet-management": "^2.3.
|
|
48
|
-
"@mui/icons-material": "^5.14.
|
|
49
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
50
|
-
"@mui/material": "^5.14.
|
|
51
|
-
"@tanstack/react-query": "^4.35.
|
|
52
|
-
"@tanstack/react-virtual": "^3.0.0-beta.
|
|
46
|
+
"@lifi/sdk": "^2.4.1",
|
|
47
|
+
"@lifi/wallet-management": "^2.3.5",
|
|
48
|
+
"@mui/icons-material": "^5.14.11",
|
|
49
|
+
"@mui/lab": "^5.0.0-alpha.146",
|
|
50
|
+
"@mui/material": "^5.14.11",
|
|
51
|
+
"@tanstack/react-query": "^4.35.7",
|
|
52
|
+
"@tanstack/react-virtual": "^3.0.0-beta.61",
|
|
53
53
|
"big.js": "^6.2.1",
|
|
54
54
|
"i18next": "^23.5.1",
|
|
55
55
|
"i18next-browser-languagedetector": "^7.1.0",
|
|
@@ -57,13 +57,13 @@
|
|
|
57
57
|
"mitt": "^3.0.1",
|
|
58
58
|
"react": "^18.2.0",
|
|
59
59
|
"react-dom": "^18.2.0",
|
|
60
|
-
"react-hook-form": "^7.
|
|
60
|
+
"react-hook-form": "^7.47.0",
|
|
61
61
|
"react-i18next": "^13.2.2",
|
|
62
62
|
"react-intersection-observer": "^9.5.2",
|
|
63
63
|
"react-router-dom": "^6.16.0",
|
|
64
64
|
"react-timer-hook": "^3.0.7",
|
|
65
65
|
"uuid": "^9.0.1",
|
|
66
|
-
"zustand": "^4.4.
|
|
66
|
+
"zustand": "^4.4.2"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@types/react": "^18.0.0",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DefaultTransactionButton } from '../../components/DefaultTransactionButton';
|
|
3
|
-
import {
|
|
3
|
+
import { useFromTokenSufficiency, useGasSufficiency, useRoutes, } from '../../hooks';
|
|
4
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();
|
|
8
8
|
const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
|
|
9
9
|
const { insufficientGas, isInitialLoading: isGasSufficiencyLoading } = useGasSufficiency(route);
|
|
10
|
-
const {
|
|
11
|
-
const shouldDisableButton = !isMultisigSigner && (
|
|
12
|
-
return (_jsx(DefaultTransactionButton, { onClick: onClick, text: text, disabled: shouldDisableButton, loading:
|
|
10
|
+
const { insufficientFromToken, isInitialLoading: isFromTokenSufficiencyLoading, } = useFromTokenSufficiency(route);
|
|
11
|
+
const shouldDisableButton = !isMultisigSigner && (insufficientFromToken || !!insufficientGas?.length);
|
|
12
|
+
return (_jsx(DefaultTransactionButton, { onClick: onClick, text: text, disabled: shouldDisableButton, loading: isFromTokenSufficiencyLoading || isGasSufficiencyLoading || loading }));
|
|
13
13
|
};
|
|
14
14
|
export const StartInsurableTransactionButton = ({ onClick, text, route, loading, disabled, insurableRouteId }) => {
|
|
15
15
|
const routeExecution = useRouteExecutionStore((state) => state.routes[insurableRouteId]);
|
|
@@ -7,16 +7,17 @@ let lifi;
|
|
|
7
7
|
const SDKContext = createContext(null);
|
|
8
8
|
export const useLiFi = () => useContext(SDKContext);
|
|
9
9
|
export const SDKProvider = ({ children, }) => {
|
|
10
|
-
const { sdkConfig,
|
|
10
|
+
const { sdkConfig, integrator, apiKey, fee, referrer, routePriority, slippage, } = useWidgetConfig();
|
|
11
11
|
const value = useMemo(() => {
|
|
12
12
|
const config = {
|
|
13
13
|
...sdkConfig,
|
|
14
|
+
apiKey,
|
|
14
15
|
integrator: integrator ?? window.location.hostname,
|
|
15
16
|
defaultRouteOptions: {
|
|
16
|
-
fee,
|
|
17
17
|
integrator: integrator ?? window.location.hostname,
|
|
18
|
+
fee,
|
|
18
19
|
referrer,
|
|
19
|
-
routePriority,
|
|
20
|
+
order: routePriority,
|
|
20
21
|
slippage,
|
|
21
22
|
...sdkConfig?.defaultRouteOptions,
|
|
22
23
|
},
|
|
@@ -30,6 +31,6 @@ export const SDKProvider = ({ children, }) => {
|
|
|
30
31
|
}
|
|
31
32
|
lifi.setConfig(config);
|
|
32
33
|
return lifi;
|
|
33
|
-
}, [fee, integrator, referrer, routePriority, sdkConfig, slippage]);
|
|
34
|
+
}, [apiKey, fee, integrator, referrer, routePriority, sdkConfig, slippage]);
|
|
34
35
|
return _jsx(SDKContext.Provider, { value: value, children: children });
|
|
35
36
|
};
|