@lifi/widget 1.27.2 → 1.28.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.
- package/AppRoutes.js +15 -33
- package/README.md +1 -1
- package/cjs/AppRoutes.js +15 -33
- package/cjs/components/ContractComponent/ContractComponent.d.ts +3 -0
- package/cjs/components/ContractComponent/ContractComponent.js +14 -0
- package/cjs/components/ContractComponent/index.d.ts +1 -0
- package/cjs/components/ContractComponent/index.js +17 -0
- package/cjs/components/Header/NavigationHeader.js +10 -2
- package/cjs/components/Header/WalletHeader.js +1 -1
- package/cjs/components/NFT/NFT.d.ts +4 -0
- package/cjs/components/NFT/NFT.js +41 -0
- package/cjs/components/NFT/NFT.style.d.ts +16 -0
- package/cjs/components/NFT/NFT.style.js +11 -0
- package/cjs/components/NFT/index.d.ts +2 -0
- package/cjs/components/NFT/index.js +18 -0
- package/cjs/components/NFT/types.d.ts +15 -0
- package/cjs/components/NFT/types.js +2 -0
- package/cjs/components/Select.d.ts +1 -1
- package/cjs/components/SelectChainAndToken.js +12 -2
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +5 -2
- package/cjs/components/StepActions/StepActions.d.ts +6 -7
- package/cjs/components/StepActions/StepActions.js +41 -12
- package/cjs/components/StepActions/types.d.ts +5 -0
- package/cjs/components/SwapInput/SwapInput.d.ts +2 -1
- package/cjs/components/SwapInput/SwapInput.js +15 -3
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +3 -1
- package/cjs/components/Token/Token.d.ts +1 -1
- package/cjs/components/Token/Token.js +12 -12
- package/cjs/components/TokenAvatar/TokenAvatar.d.ts +5 -3
- package/cjs/components/TokenAvatar/TokenAvatar.js +10 -9
- package/cjs/components/TokenList/TokenList.style.js +6 -0
- package/cjs/components/TokenList/VirtualizedTokenList.js +4 -2
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useSwapRoutes.d.ts +5 -2
- package/cjs/hooks/useSwapRoutes.js +64 -14
- package/cjs/hooks/useToken.d.ts +1 -1
- package/cjs/hooks/useTokenSearch.d.ts +1 -1
- package/cjs/i18n/en.json +9 -5
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +4 -1
- package/cjs/pages/MainPage/MainPage.js +5 -1
- package/cjs/providers/SwapFormProvider/types.d.ts +10 -0
- package/cjs/providers/SwapFormProvider/types.js +5 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +1 -1
- package/cjs/stores/routes/useRouteExecutionStore.d.ts +1 -1
- package/cjs/stores/settings/useSettingsStore.d.ts +1 -1
- package/cjs/types/widget.d.ts +9 -4
- package/cjs/types/widget.js +2 -0
- package/components/ContractComponent/ContractComponent.d.ts +3 -0
- package/components/ContractComponent/ContractComponent.js +10 -0
- package/components/ContractComponent/index.d.ts +1 -0
- package/components/ContractComponent/index.js +1 -0
- package/components/Header/NavigationHeader.js +12 -4
- package/components/Header/WalletHeader.js +1 -1
- package/components/NFT/NFT.d.ts +4 -0
- package/components/NFT/NFT.js +37 -0
- package/components/NFT/NFT.style.d.ts +16 -0
- package/components/NFT/NFT.style.js +8 -0
- package/components/NFT/index.d.ts +2 -0
- package/components/NFT/index.js +2 -0
- package/components/NFT/types.d.ts +15 -0
- package/components/NFT/types.js +1 -0
- package/components/Select.d.ts +1 -1
- package/components/SelectChainAndToken.js +12 -2
- package/components/SelectTokenButton/SelectTokenButton.js +5 -2
- package/components/StepActions/StepActions.d.ts +6 -7
- package/components/StepActions/StepActions.js +40 -12
- package/components/StepActions/types.d.ts +5 -0
- package/components/SwapInput/SwapInput.d.ts +2 -1
- package/components/SwapInput/SwapInput.js +15 -3
- package/components/SwapRouteCard/SwapRouteCard.js +3 -1
- package/components/Token/Token.d.ts +1 -1
- package/components/Token/Token.js +13 -13
- package/components/TokenAvatar/TokenAvatar.d.ts +5 -3
- package/components/TokenAvatar/TokenAvatar.js +10 -9
- package/components/TokenList/TokenList.style.js +6 -0
- package/components/TokenList/VirtualizedTokenList.js +4 -2
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useSwapRoutes.d.ts +5 -2
- package/hooks/useSwapRoutes.js +64 -14
- package/hooks/useToken.d.ts +1 -1
- package/hooks/useTokenSearch.d.ts +1 -1
- package/i18n/en.json +9 -5
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +15 -13
- package/pages/MainPage/MainPage.js +5 -1
- package/providers/SwapFormProvider/types.d.ts +10 -0
- package/providers/SwapFormProvider/types.js +5 -0
- package/stores/chains/useChainOrderStore.d.ts +1 -1
- package/stores/routes/useRouteExecutionStore.d.ts +1 -1
- package/stores/settings/useSettingsStore.d.ts +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +9 -4
- package/types/widget.js +2 -0
|
@@ -23,34 +23,34 @@ const TokenAvatar_1 = require("../TokenAvatar");
|
|
|
23
23
|
const Token_style_1 = require("./Token.style");
|
|
24
24
|
const Token = (_a) => {
|
|
25
25
|
var { token } = _a, other = __rest(_a, ["token"]);
|
|
26
|
-
if (!token.priceUSD || !token.logoURI) {
|
|
26
|
+
if (!(token === null || token === void 0 ? void 0 : token.priceUSD) || !token.logoURI) {
|
|
27
27
|
return (0, jsx_runtime_1.jsx)(exports.TokenFallback, Object.assign({ token: token }, other));
|
|
28
28
|
}
|
|
29
29
|
return (0, jsx_runtime_1.jsx)(exports.TokenBase, Object.assign({ token: token }, other));
|
|
30
30
|
};
|
|
31
31
|
exports.Token = Token;
|
|
32
32
|
const TokenFallback = (_a) => {
|
|
33
|
-
var { token, connected, step, disableDescription } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription"]);
|
|
34
|
-
const { token: chainToken, isLoading } = (0, hooks_1.useToken)(token.chainId, token.address);
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(exports.TokenBase, Object.assign({ token: Object.assign(Object.assign({}, token), chainToken), isLoading: isLoading }, other)));
|
|
33
|
+
var { token, connected, step, disableDescription, isLoading } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription", "isLoading"]);
|
|
34
|
+
const { token: chainToken, isLoading: isLoadingToken } = (0, hooks_1.useToken)(token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address);
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(exports.TokenBase, Object.assign({ token: Object.assign(Object.assign({}, token), chainToken), isLoading: isLoading || isLoadingToken }, other)));
|
|
36
36
|
};
|
|
37
37
|
exports.TokenFallback = TokenFallback;
|
|
38
38
|
const TokenBase = (_a) => {
|
|
39
39
|
var { token, connected, step, disableDescription, isLoading } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription", "isLoading"]);
|
|
40
40
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
41
|
-
const { chain } = (0, hooks_1.useChain)(token.chainId);
|
|
42
|
-
const formattedTokenAmount = (0, utils_1.formatTokenAmount)(token.amount, token.decimals);
|
|
43
|
-
const formattedTokenPrice = (0, utils_1.formatTokenPrice)(formattedTokenAmount, token.priceUSD);
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ flex: 1 }, other, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", flex: 1, alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatar, { token: token, chain: chain, sx: { marginRight: 2 } }), (0, jsx_runtime_1.jsx)(TextFitter_1.TextFitter, Object.assign({ height: 30, textStyle: {
|
|
41
|
+
const { chain } = (0, hooks_1.useChain)(token === null || token === void 0 ? void 0 : token.chainId);
|
|
42
|
+
const formattedTokenAmount = (0, utils_1.formatTokenAmount)(token === null || token === void 0 ? void 0 : token.amount, token === null || token === void 0 ? void 0 : token.decimals);
|
|
43
|
+
const formattedTokenPrice = (0, utils_1.formatTokenPrice)(formattedTokenAmount, token === null || token === void 0 ? void 0 : token.priceUSD);
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ flex: 1 }, other, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", flex: 1, alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatar, { token: token, chain: chain, isLoading: isLoading, sx: { marginRight: 2 } }), isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 112, height: 32, variant: "text" })) : ((0, jsx_runtime_1.jsx)(TextFitter_1.TextFitter, Object.assign({ height: 30, textStyle: {
|
|
45
45
|
fontWeight: 700,
|
|
46
46
|
} }, { children: t('format.number', {
|
|
47
47
|
value: formattedTokenAmount,
|
|
48
|
-
}) }))] })), (0, jsx_runtime_1.jsxs)(Token_style_1.TextSecondaryContainer, Object.assign({ connected: connected, component: "span" }, { children: [(0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected }, { children: t(`format.currency`, {
|
|
48
|
+
}) })))] })), (0, jsx_runtime_1.jsxs)(Token_style_1.TextSecondaryContainer, Object.assign({ connected: connected, component: "span" }, { children: [isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 48, height: 12, variant: "rounded", sx: { marginTop: 0.5 } })) : ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected }, { children: t(`format.currency`, {
|
|
49
49
|
value: formattedTokenPrice,
|
|
50
|
-
}) })), !disableDescription ? ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected, px: 0.5, dot: true }, { children: "\u2022" }))) : null, !step && !disableDescription ? ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
51
|
-
tokenSymbol: token.symbol,
|
|
50
|
+
}) }))), !disableDescription ? ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected, px: 0.5, dot: true }, { children: "\u2022" }))) : null, !step && !disableDescription ? (isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 96, height: 12, variant: "rounded", sx: { marginTop: 0.5 } })) : ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
51
|
+
tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
|
|
52
52
|
chainName: chain === null || chain === void 0 ? void 0 : chain.name,
|
|
53
|
-
}) }))) : null, step ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", alignItems: "flex-end", height: 12, mt: 0.5 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ pr: 0.75 }, { children: (0, jsx_runtime_1.jsx)(SmallAvatar_1.SmallAvatar, Object.assign({ src: step.toolDetails.logoURI, alt: step.toolDetails.name, sx: {
|
|
53
|
+
}) })))) : null, step ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", alignItems: "flex-end", height: 12, mt: 0.5 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ pr: 0.75 }, { children: (0, jsx_runtime_1.jsx)(SmallAvatar_1.SmallAvatar, Object.assign({ src: step.toolDetails.logoURI, alt: step.toolDetails.name, sx: {
|
|
54
54
|
border: 0,
|
|
55
55
|
marginBottom: -0.25,
|
|
56
56
|
} }, { children: step.toolDetails.name[0] })) })), (0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: true }, { children: step.toolDetails.name }))] }))) : null] }))] })));
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
import type { Chain, Token } from '@lifi/sdk';
|
|
3
3
|
import type { SxProps, Theme } from '@mui/material';
|
|
4
4
|
export declare const TokenAvatarFallback: React.FC<{
|
|
5
|
-
token
|
|
5
|
+
token?: Token;
|
|
6
|
+
isLoading?: boolean;
|
|
6
7
|
sx?: SxProps<Theme>;
|
|
7
8
|
}>;
|
|
8
9
|
export declare const TokenAvatarBase: React.FC<{
|
|
9
|
-
token
|
|
10
|
+
token?: Token;
|
|
10
11
|
chain?: Chain;
|
|
11
12
|
isLoading?: boolean;
|
|
12
13
|
sx?: SxProps<Theme>;
|
|
13
14
|
}>;
|
|
14
15
|
export declare const TokenAvatar: React.FC<{
|
|
15
|
-
token
|
|
16
|
+
token?: Token;
|
|
16
17
|
chain?: Chain;
|
|
18
|
+
isLoading?: boolean;
|
|
17
19
|
sx?: SxProps<Theme>;
|
|
18
20
|
}>;
|
|
19
21
|
export declare const TokenAvatarDefault: React.FC<{
|
|
@@ -6,21 +6,22 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const hooks_1 = require("../../hooks");
|
|
7
7
|
const SmallAvatar_1 = require("../SmallAvatar");
|
|
8
8
|
const TokenAvatar_style_1 = require("./TokenAvatar.style");
|
|
9
|
-
const TokenAvatarFallback = ({ token, sx }) => {
|
|
10
|
-
const { chain } = (0, hooks_1.useChain)(token.chainId);
|
|
11
|
-
const { token: chainToken, isLoading } = (0, hooks_1.useToken)(token.chainId, token.address);
|
|
12
|
-
return ((0, jsx_runtime_1.jsx)(exports.TokenAvatarBase, { token: chainToken !== null && chainToken !== void 0 ? chainToken : token, isLoading: isLoading, chain: chain, sx: sx }));
|
|
9
|
+
const TokenAvatarFallback = ({ token, isLoading, sx }) => {
|
|
10
|
+
const { chain } = (0, hooks_1.useChain)(token === null || token === void 0 ? void 0 : token.chainId);
|
|
11
|
+
const { token: chainToken, isLoading: isLoadingToken } = (0, hooks_1.useToken)(token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address);
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(exports.TokenAvatarBase, { token: chainToken !== null && chainToken !== void 0 ? chainToken : token, isLoading: isLoading || isLoadingToken, chain: chain, sx: sx }));
|
|
13
13
|
};
|
|
14
14
|
exports.TokenAvatarFallback = TokenAvatarFallback;
|
|
15
15
|
const TokenAvatarBase = ({ token, chain, isLoading, sx }) => {
|
|
16
|
-
|
|
16
|
+
var _a;
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Badge, Object.assign({ overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: chain && !isLoading ? ((0, jsx_runtime_1.jsx)(SmallAvatar_1.SmallAvatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] }))) : ((0, jsx_runtime_1.jsx)(SmallAvatar_1.SmallAvatarSkeleton, {})), sx: sx }, { children: isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 32, height: 32, variant: "circular" })) : ((0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: token === null || token === void 0 ? void 0 : token.logoURI, alt: token === null || token === void 0 ? void 0 : token.symbol }, { children: (_a = token === null || token === void 0 ? void 0 : token.symbol) === null || _a === void 0 ? void 0 : _a[0] }))) })));
|
|
17
18
|
};
|
|
18
19
|
exports.TokenAvatarBase = TokenAvatarBase;
|
|
19
|
-
const TokenAvatar = ({ token, chain, sx }) => {
|
|
20
|
-
if (!chain || !token.logoURI) {
|
|
21
|
-
return (0, jsx_runtime_1.jsx)(exports.TokenAvatarFallback, { token: token, sx: sx });
|
|
20
|
+
const TokenAvatar = ({ token, chain, isLoading, sx }) => {
|
|
21
|
+
if (!chain || !(token === null || token === void 0 ? void 0 : token.logoURI)) {
|
|
22
|
+
return (0, jsx_runtime_1.jsx)(exports.TokenAvatarFallback, { token: token, isLoading: isLoading, sx: sx });
|
|
22
23
|
}
|
|
23
|
-
return (0, jsx_runtime_1.jsx)(exports.TokenAvatarBase, { token: token, chain: chain, sx: sx });
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(exports.TokenAvatarBase, { token: token, chain: chain, isLoading: isLoading, sx: sx }));
|
|
24
25
|
};
|
|
25
26
|
exports.TokenAvatar = TokenAvatar;
|
|
26
27
|
const TokenAvatarDefault = ({ sx }) => {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ListItem = exports.ListItemButton = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const ListItemSecondaryAction_1 = require("@mui/material/ListItemSecondaryAction");
|
|
6
|
+
const ListItemText_1 = require("@mui/material/ListItemText");
|
|
6
7
|
const styles_1 = require("@mui/material/styles");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
exports.ListItemButton = (0, styles_1.styled)(material_1.ListItemButton)(({ theme }) => ({
|
|
@@ -26,4 +27,9 @@ exports.ListItem = (0, styles_1.styled)(material_1.ListItem)(({ theme }) => ({
|
|
|
26
27
|
[`.${ListItemSecondaryAction_1.listItemSecondaryActionClasses.root}`]: {
|
|
27
28
|
right: theme.spacing(3),
|
|
28
29
|
},
|
|
30
|
+
[`& .${ListItemText_1.listItemTextClasses.primary}, & .${ListItemText_1.listItemTextClasses.secondary}`]: {
|
|
31
|
+
textOverflow: 'ellipsis',
|
|
32
|
+
overflow: 'hidden',
|
|
33
|
+
whiteSpace: 'nowrap',
|
|
34
|
+
},
|
|
29
35
|
}));
|
|
@@ -39,8 +39,10 @@ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef,
|
|
|
39
39
|
getItemKey: (index) => { var _a; return (_a = tokens[index].address) !== null && _a !== void 0 ? _a : index; },
|
|
40
40
|
});
|
|
41
41
|
(0, react_1.useEffect)(() => {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (getVirtualItems().length) {
|
|
43
|
+
scrollToIndex(0, { align: 'start' });
|
|
44
|
+
}
|
|
45
|
+
}, [scrollToIndex, chainId, getVirtualItems]);
|
|
44
46
|
if (isLoading) {
|
|
45
47
|
return ((0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ disablePadding: true }, { children: Array.from({ length: 3 }).map((_, index) => (
|
|
46
48
|
// eslint-disable-next-line react/no-array-index-key
|
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.28.1";
|
package/cjs/config/version.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { Route } from '@lifi/sdk';
|
|
1
2
|
export declare const useSwapRoutes: () => {
|
|
2
|
-
routes:
|
|
3
|
+
routes: Route[] | undefined;
|
|
3
4
|
isLoading: boolean;
|
|
4
5
|
isFetching: boolean;
|
|
5
6
|
isFetched: boolean;
|
|
6
7
|
dataUpdatedAt: number;
|
|
7
8
|
refetchTime: number;
|
|
8
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/sdk").RoutesResponse
|
|
9
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/sdk").RoutesResponse | {
|
|
10
|
+
routes: Route[];
|
|
11
|
+
}, any>>;
|
|
9
12
|
};
|
|
@@ -15,6 +15,7 @@ const sdk_1 = require("@lifi/sdk");
|
|
|
15
15
|
const react_query_1 = require("@tanstack/react-query");
|
|
16
16
|
const big_js_1 = require("big.js");
|
|
17
17
|
const react_hook_form_1 = require("react-hook-form");
|
|
18
|
+
const uuid_1 = require("uuid");
|
|
18
19
|
const _1 = require(".");
|
|
19
20
|
const providers_1 = require("../providers");
|
|
20
21
|
const stores_1 = require("../stores");
|
|
@@ -31,36 +32,47 @@ const useSwapRoutes = () => {
|
|
|
31
32
|
'enabledBridges',
|
|
32
33
|
'enabledExchanges',
|
|
33
34
|
]);
|
|
34
|
-
const [
|
|
35
|
+
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 320);
|
|
36
|
+
const [fromChainId, fromTokenAddress, toAddress, toTokenAmount, toChainId, toContractAddress, toContractCallData, toContractGasLimit, toTokenAddress,] = (0, react_hook_form_1.useWatch)({
|
|
35
37
|
name: [
|
|
36
38
|
providers_1.SwapFormKey.FromChain,
|
|
37
39
|
providers_1.SwapFormKey.FromToken,
|
|
40
|
+
providers_1.SwapFormKey.ToAddress,
|
|
41
|
+
providers_1.SwapFormKey.ToAmount,
|
|
38
42
|
providers_1.SwapFormKey.ToChain,
|
|
43
|
+
providers_1.SwapFormKey.ToContractAddress,
|
|
44
|
+
providers_1.SwapFormKey.ToContractCallData,
|
|
45
|
+
providers_1.SwapFormKey.ToContractGasLimit,
|
|
39
46
|
providers_1.SwapFormKey.ToToken,
|
|
40
|
-
providers_1.SwapFormKey.ToAddress,
|
|
41
47
|
],
|
|
42
48
|
});
|
|
43
|
-
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 320);
|
|
44
49
|
const { token: fromToken } = (0, _1.useToken)(fromChainId, fromTokenAddress);
|
|
45
50
|
const { token: toToken } = (0, _1.useToken)(toChainId, toTokenAddress);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const hasAmount = (!isNaN(fromTokenAmount) && Number(fromTokenAmount) > 0) ||
|
|
52
|
+
(!isNaN(toTokenAmount) && Number(toTokenAmount) > 0);
|
|
53
|
+
const contractCallQuoteEnabled = variant === 'nft'
|
|
54
|
+
? Boolean(toContractAddress && toContractCallData && toContractGasLimit)
|
|
55
|
+
: true;
|
|
56
|
+
const isEnabled = !isNaN(fromChainId) &&
|
|
49
57
|
!isNaN(toChainId) &&
|
|
50
58
|
Boolean(fromToken === null || fromToken === void 0 ? void 0 : fromToken.address) &&
|
|
51
59
|
Boolean(toToken === null || toToken === void 0 ? void 0 : toToken.address) &&
|
|
52
|
-
!isNaN(
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
!Number.isNaN(slippage) &&
|
|
61
|
+
hasAmount &&
|
|
62
|
+
contractCallQuoteEnabled;
|
|
55
63
|
const queryKey = [
|
|
56
64
|
'routes',
|
|
57
65
|
account.address,
|
|
58
66
|
fromChainId,
|
|
59
67
|
fromToken === null || fromToken === void 0 ? void 0 : fromToken.address,
|
|
60
68
|
fromTokenAmount,
|
|
69
|
+
toAddress,
|
|
61
70
|
toChainId,
|
|
62
71
|
toToken === null || toToken === void 0 ? void 0 : toToken.address,
|
|
63
|
-
|
|
72
|
+
toTokenAmount,
|
|
73
|
+
toContractAddress,
|
|
74
|
+
toContractCallData,
|
|
75
|
+
toContractGasLimit,
|
|
64
76
|
slippage,
|
|
65
77
|
enabledBridges,
|
|
66
78
|
enabledExchanges,
|
|
@@ -72,20 +84,58 @@ const useSwapRoutes = () => {
|
|
|
72
84
|
const refetchInterval = previousDataUpdatedAt
|
|
73
85
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
74
86
|
: refetchTime;
|
|
75
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress,
|
|
76
|
-
var _c, _d;
|
|
87
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
var _c, _d, _e;
|
|
77
89
|
let toWalletAddress;
|
|
78
90
|
try {
|
|
79
91
|
toWalletAddress =
|
|
80
92
|
(_c = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _c !== void 0 ? _c : ((0, address_1.isAddress)(toAddress) ? toAddress : fromAddress);
|
|
81
93
|
}
|
|
82
|
-
catch (
|
|
94
|
+
catch (_f) {
|
|
83
95
|
toWalletAddress = (0, address_1.isAddress)(toAddress) ? toAddress : fromAddress;
|
|
84
96
|
}
|
|
85
|
-
const fromAmount = (0, big_js_1.default)(fromTokenAmount)
|
|
97
|
+
const fromAmount = (0, big_js_1.default)(fromTokenAmount || 0)
|
|
86
98
|
.mul(Math.pow(10, ((_d = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _d !== void 0 ? _d : 0)))
|
|
87
99
|
.toString();
|
|
100
|
+
// const toAmount = Big(toTokenAmount || 0)
|
|
101
|
+
// .mul(10 ** (toToken?.decimals ?? 0))
|
|
102
|
+
// .toString();
|
|
88
103
|
const formattedSlippage = parseFloat(slippage) / 100;
|
|
104
|
+
if (variant === 'nft') {
|
|
105
|
+
const contractCallQuote = yield lifi.getContractCallQuote({
|
|
106
|
+
fromAddress,
|
|
107
|
+
fromChain: fromChainId,
|
|
108
|
+
fromToken: fromTokenAddress,
|
|
109
|
+
toAmount: toTokenAmount,
|
|
110
|
+
toChain: toChainId,
|
|
111
|
+
toToken: toTokenAddress,
|
|
112
|
+
toContractAddress,
|
|
113
|
+
toContractCallData,
|
|
114
|
+
toContractGasLimit,
|
|
115
|
+
// toFallbackAddress: toAddress,
|
|
116
|
+
slippage: formattedSlippage,
|
|
117
|
+
}, { signal });
|
|
118
|
+
contractCallQuote.estimate.toAmount = toTokenAmount;
|
|
119
|
+
contractCallQuote.estimate.toAmountMin = toTokenAmount;
|
|
120
|
+
contractCallQuote.action.toToken = toToken;
|
|
121
|
+
const route = {
|
|
122
|
+
id: (0, uuid_1.v4)(),
|
|
123
|
+
fromChainId: contractCallQuote.action.fromChainId,
|
|
124
|
+
fromAmountUSD: contractCallQuote.estimate.fromAmountUSD || '',
|
|
125
|
+
fromAmount: contractCallQuote.action.fromAmount,
|
|
126
|
+
fromToken: contractCallQuote.action.fromToken,
|
|
127
|
+
fromAddress: contractCallQuote.action.fromAddress,
|
|
128
|
+
toChainId: contractCallQuote.action.toChainId,
|
|
129
|
+
toAmountUSD: contractCallQuote.estimate.toAmountUSD || '',
|
|
130
|
+
toAmount: toTokenAmount,
|
|
131
|
+
toAmountMin: toTokenAmount,
|
|
132
|
+
toToken: toToken,
|
|
133
|
+
toAddress: toAddress,
|
|
134
|
+
gasCostUSD: (_e = contractCallQuote.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].amountUSD,
|
|
135
|
+
steps: [contractCallQuote],
|
|
136
|
+
};
|
|
137
|
+
return { routes: [route] };
|
|
138
|
+
}
|
|
89
139
|
return lifi.getRoutes({
|
|
90
140
|
fromChainId,
|
|
91
141
|
fromAmount,
|
package/cjs/hooks/useToken.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Token } from '../types';
|
|
2
|
-
export declare const useTokenSearch: (chainId
|
|
2
|
+
export declare const useTokenSearch: (chainId?: number, token?: string, enabled?: boolean) => {
|
|
3
3
|
token: Token | undefined;
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
};
|
package/cjs/i18n/en.json
CHANGED
|
@@ -29,10 +29,11 @@
|
|
|
29
29
|
},
|
|
30
30
|
"format": {
|
|
31
31
|
"currency": "{{value, currency(currency: USD)}}",
|
|
32
|
-
"number": "{{value, number(maximumFractionDigits:
|
|
32
|
+
"number": "{{value, number(maximumFractionDigits: 9)}}"
|
|
33
33
|
},
|
|
34
34
|
"header": {
|
|
35
35
|
"activeSwaps": "Active swaps",
|
|
36
|
+
"checkout": "Checkout",
|
|
36
37
|
"from": "Swap from",
|
|
37
38
|
"gas": "Gas",
|
|
38
39
|
"gasSwap": "Gas swap",
|
|
@@ -74,8 +75,8 @@
|
|
|
74
75
|
"message": {
|
|
75
76
|
"slippageThreshold": "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote.",
|
|
76
77
|
"transactionFailed": "Please check the block explorer for more information.",
|
|
77
|
-
"transactionNotSent": "Transaction was not sent. {{amount, number(maximumFractionDigits:
|
|
78
|
-
"transactionRejected": "Your signature is required to complete the transaction. {{amount, number(maximumFractionDigits:
|
|
78
|
+
"transactionNotSent": "Transaction was not sent. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
|
|
79
|
+
"transactionRejected": "Your signature is required to complete the transaction. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
|
|
79
80
|
"unknown": "Please try again or contact support."
|
|
80
81
|
},
|
|
81
82
|
"title": {
|
|
@@ -115,8 +116,11 @@
|
|
|
115
116
|
"routeNotFound": "No routes available"
|
|
116
117
|
}
|
|
117
118
|
},
|
|
119
|
+
"nftStepDetails": "Purchase NFT via {{tool}}",
|
|
118
120
|
"onChain": "on {{chainName}}",
|
|
119
121
|
"otherTokens": "Other tokens",
|
|
122
|
+
"ownedBy": "Owned by",
|
|
123
|
+
"payWith": "Pay with",
|
|
120
124
|
"process": {
|
|
121
125
|
"crossChain": {
|
|
122
126
|
"actionRequired": "Please sign the transaction",
|
|
@@ -162,7 +166,7 @@
|
|
|
162
166
|
"success": {
|
|
163
167
|
"message": {
|
|
164
168
|
"swapPartiallySuccessful": "We've tried to complete the swap, but {{tool}} ran out of liquidity for {{tokenSymbol}} token.",
|
|
165
|
-
"swapSuccessful": "There are now {{amount, number(maximumFractionDigits:
|
|
169
|
+
"swapSuccessful": "There are now {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} in {{walletAddress}} wallet on {{chainName}} chain."
|
|
166
170
|
},
|
|
167
171
|
"title": {
|
|
168
172
|
"gasSwapSuccessful": "Gas swap successful",
|
|
@@ -183,7 +187,7 @@
|
|
|
183
187
|
},
|
|
184
188
|
"to": "To",
|
|
185
189
|
"tokenOnChain": "{{tokenSymbol}} on {{chainName}}",
|
|
186
|
-
"tokenOnChainAmount": "{{amount, number(maximumFractionDigits:
|
|
190
|
+
"tokenOnChainAmount": "{{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} on {{chainName}}",
|
|
187
191
|
"tokenSearch": "Search your token",
|
|
188
192
|
"valueLoss": "Value loss",
|
|
189
193
|
"walletAddressOrEns": "Wallet address or ENS name",
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './fonts/inter.css';
|
|
3
3
|
export type { WidgetDrawer } from './AppDrawer';
|
|
4
|
+
export * from './components/NFT';
|
|
4
5
|
export { useWidgetEvents, widgetEvents } from './hooks';
|
|
6
|
+
export { useWallet } from './providers/WalletProvider';
|
|
5
7
|
export * from './types';
|
|
6
8
|
export declare const LiFiWidget: import("react").FC<import("./types").WidgetProps>;
|
|
7
9
|
/**
|
package/cjs/index.js
CHANGED
|
@@ -14,13 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.LiFiWidgetDrawer = exports.LiFiWidget = exports.widgetEvents = exports.useWidgetEvents = void 0;
|
|
17
|
+
exports.LiFiWidgetDrawer = exports.LiFiWidget = exports.useWallet = exports.widgetEvents = exports.useWidgetEvents = void 0;
|
|
18
18
|
const App_1 = require("./App");
|
|
19
19
|
const AppDrawer_1 = require("./AppDrawer");
|
|
20
20
|
require("./fonts/inter.css");
|
|
21
|
+
__exportStar(require("./components/NFT"), exports);
|
|
21
22
|
var hooks_1 = require("./hooks");
|
|
22
23
|
Object.defineProperty(exports, "useWidgetEvents", { enumerable: true, get: function () { return hooks_1.useWidgetEvents; } });
|
|
23
24
|
Object.defineProperty(exports, "widgetEvents", { enumerable: true, get: function () { return hooks_1.widgetEvents; } });
|
|
25
|
+
var WalletProvider_1 = require("./providers/WalletProvider");
|
|
26
|
+
Object.defineProperty(exports, "useWallet", { enumerable: true, get: function () { return WalletProvider_1.useWallet; } });
|
|
24
27
|
__exportStar(require("./types"), exports);
|
|
25
28
|
// ClassNameGenerator.configure((componentName) =>
|
|
26
29
|
// componentName.replace('Mui', 'LiFi'),
|
|
@@ -4,16 +4,20 @@ exports.MainPage = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const ActiveSwaps_1 = require("../../components/ActiveSwaps");
|
|
7
|
+
const ContractComponent_1 = require("../../components/ContractComponent");
|
|
7
8
|
const GasSufficiencyMessage_1 = require("../../components/GasSufficiencyMessage");
|
|
8
9
|
const SelectChainAndToken_1 = require("../../components/SelectChainAndToken");
|
|
9
10
|
const SendToWallet_1 = require("../../components/SendToWallet");
|
|
10
11
|
const SwapInput_1 = require("../../components/SwapInput");
|
|
11
12
|
const SwapRoutes_1 = require("../../components/SwapRoutes");
|
|
12
13
|
const hooks_1 = require("../../hooks");
|
|
14
|
+
const providers_1 = require("../../providers");
|
|
13
15
|
const MainPage_style_1 = require("./MainPage.style");
|
|
14
16
|
const MainSwapButton_1 = require("./MainSwapButton");
|
|
15
17
|
const MainPage = () => {
|
|
16
18
|
const expandable = (0, hooks_1.useExpandableVariant)();
|
|
17
|
-
|
|
19
|
+
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
20
|
+
const nft = variant === 'nft';
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), nft ? (0, jsx_runtime_1.jsx)(ContractComponent_1.ContractComponent, { mx: 3, mt: 1, mb: 1 }) : null, (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), !nft ? (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from", mx: 3, mb: 3 }) : null, !expandable ? (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 3 }) : null, (0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mx: 3, mb: 1 }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex' } }, { children: [(0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWalletButton, {})] }))] }))] })));
|
|
18
22
|
};
|
|
19
23
|
exports.MainPage = MainPage;
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
export declare enum SwapFormKey {
|
|
2
|
+
ContractOutputsToken = "contractOutputsToken",
|
|
2
3
|
FromAmount = "fromAmount",
|
|
3
4
|
FromChain = "fromChain",
|
|
4
5
|
FromToken = "fromToken",
|
|
5
6
|
ToAddress = "toAddress",
|
|
7
|
+
ToAmount = "toAmount",
|
|
6
8
|
ToChain = "toChain",
|
|
9
|
+
ToContractAddress = "toContractAddress",
|
|
10
|
+
ToContractCallData = "toContractCallData",
|
|
11
|
+
ToContractGasLimit = "ToContractGasLimit",
|
|
7
12
|
ToToken = "toToken",
|
|
8
13
|
TokenSearchFilter = "tokenSearchFilter"
|
|
9
14
|
}
|
|
10
15
|
export type SwapFormValues = {
|
|
16
|
+
[SwapFormKey.ContractOutputsToken]: string;
|
|
11
17
|
[SwapFormKey.FromAmount]: string;
|
|
12
18
|
[SwapFormKey.FromChain]: number;
|
|
13
19
|
[SwapFormKey.FromToken]: string;
|
|
14
20
|
[SwapFormKey.ToAddress]: string;
|
|
21
|
+
[SwapFormKey.ToAmount]: string;
|
|
15
22
|
[SwapFormKey.ToChain]: number;
|
|
23
|
+
[SwapFormKey.ToContractAddress]: string;
|
|
24
|
+
[SwapFormKey.ToContractCallData]: string;
|
|
25
|
+
[SwapFormKey.ToContractGasLimit]: string;
|
|
16
26
|
[SwapFormKey.ToToken]: string;
|
|
17
27
|
[SwapFormKey.TokenSearchFilter]: string;
|
|
18
28
|
};
|
|
@@ -3,11 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SwapFormKeyHelper = exports.SwapFormKey = void 0;
|
|
4
4
|
var SwapFormKey;
|
|
5
5
|
(function (SwapFormKey) {
|
|
6
|
+
SwapFormKey["ContractOutputsToken"] = "contractOutputsToken";
|
|
6
7
|
SwapFormKey["FromAmount"] = "fromAmount";
|
|
7
8
|
SwapFormKey["FromChain"] = "fromChain";
|
|
8
9
|
SwapFormKey["FromToken"] = "fromToken";
|
|
9
10
|
SwapFormKey["ToAddress"] = "toAddress";
|
|
11
|
+
SwapFormKey["ToAmount"] = "toAmount";
|
|
10
12
|
SwapFormKey["ToChain"] = "toChain";
|
|
13
|
+
SwapFormKey["ToContractAddress"] = "toContractAddress";
|
|
14
|
+
SwapFormKey["ToContractCallData"] = "toContractCallData";
|
|
15
|
+
SwapFormKey["ToContractGasLimit"] = "ToContractGasLimit";
|
|
11
16
|
SwapFormKey["ToToken"] = "toToken";
|
|
12
17
|
SwapFormKey["TokenSearchFilter"] = "tokenSearchFilter";
|
|
13
18
|
})(SwapFormKey = exports.SwapFormKey || (exports.SwapFormKey = {}));
|
|
@@ -6,7 +6,7 @@ export declare const useChainOrderStore: import("zustand").UseBoundStore<Omit<im
|
|
|
6
6
|
chainOrder: number[];
|
|
7
7
|
}>>) => void;
|
|
8
8
|
clearStorage: () => void;
|
|
9
|
-
rehydrate: () => Promise<void>;
|
|
9
|
+
rehydrate: () => void | Promise<void>;
|
|
10
10
|
hasHydrated: () => boolean;
|
|
11
11
|
onHydrate: (fn: (state: ChainOrderStore) => void) => () => void;
|
|
12
12
|
onFinishHydration: (fn: (state: ChainOrderStore) => void) => () => void;
|
|
@@ -5,7 +5,7 @@ export declare const useRouteExecutionStore: import("zustand").UseBoundStore<Omi
|
|
|
5
5
|
routes: Partial<Record<string, import("./types").RouteExecution>>;
|
|
6
6
|
}>>) => void;
|
|
7
7
|
clearStorage: () => void;
|
|
8
|
-
rehydrate: () => Promise<void>;
|
|
8
|
+
rehydrate: () => void | Promise<void>;
|
|
9
9
|
hasHydrated: () => boolean;
|
|
10
10
|
onHydrate: (fn: (state: RouteExecutionStore) => void) => () => void;
|
|
11
11
|
onFinishHydration: (fn: (state: RouteExecutionStore) => void) => () => void;
|
|
@@ -20,7 +20,7 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<impo
|
|
|
20
20
|
_enabledExchanges?: Record<string, boolean> | undefined;
|
|
21
21
|
}>>) => void;
|
|
22
22
|
clearStorage: () => void;
|
|
23
|
-
rehydrate: () => Promise<void>;
|
|
23
|
+
rehydrate: () => void | Promise<void>;
|
|
24
24
|
hasHydrated: () => boolean;
|
|
25
25
|
onHydrate: (fn: (state: SettingsStore) => void) => () => void;
|
|
26
26
|
onFinishHydration: (fn: (state: SettingsStore) => void) => () => void;
|
package/cjs/types/widget.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Components, PaletteMode, PaletteOptions, Shape, Theme } from '@mui
|
|
|
4
4
|
import type { TypographyOptions } from '@mui/material/styles/createTypography';
|
|
5
5
|
import type { CSSProperties, ReactNode, RefObject } from 'react';
|
|
6
6
|
import type { LanguageKey, LanguageResources } from '../providers';
|
|
7
|
-
export type WidgetVariant = 'default' | 'expandable' | 'drawer' | 'refuel';
|
|
7
|
+
export type WidgetVariant = 'default' | 'expandable' | 'drawer' | 'refuel' | 'nft';
|
|
8
8
|
export declare enum DisabledUI {
|
|
9
9
|
FromAmount = "fromAmount",
|
|
10
10
|
FromToken = "fromToken",
|
|
@@ -37,10 +37,14 @@ export interface WidgetWalletManagement {
|
|
|
37
37
|
export interface SDKConfig extends Omit<ConfigUpdate, 'defaultExecutionSettings' | 'defaultRouteOptions' | 'disableVersionCheck'> {
|
|
38
38
|
defaultRouteOptions?: Omit<RouteOptions, 'bridges' | 'exchanges'>;
|
|
39
39
|
}
|
|
40
|
+
export interface WidgetContractTool {
|
|
41
|
+
logoURI: string;
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
40
44
|
export interface WidgetContract {
|
|
41
|
-
address
|
|
42
|
-
callData
|
|
43
|
-
gasLimit
|
|
45
|
+
address?: string;
|
|
46
|
+
callData?: string;
|
|
47
|
+
gasLimit?: string;
|
|
44
48
|
approvalAddress?: string;
|
|
45
49
|
outputToken?: string;
|
|
46
50
|
fallbackAddress?: string;
|
|
@@ -56,6 +60,7 @@ export interface WidgetConfig {
|
|
|
56
60
|
contract?: WidgetContract;
|
|
57
61
|
contractComponent?: ReactNode;
|
|
58
62
|
contractCompactComponent?: ReactNode;
|
|
63
|
+
contractTool?: WidgetContractTool;
|
|
59
64
|
fee?: number;
|
|
60
65
|
integrator?: string;
|
|
61
66
|
referrer?: string;
|
package/cjs/types/widget.js
CHANGED
|
@@ -11,7 +11,9 @@ var DisabledUI;
|
|
|
11
11
|
var HiddenUI;
|
|
12
12
|
(function (HiddenUI) {
|
|
13
13
|
HiddenUI["Appearance"] = "appearance";
|
|
14
|
+
// FromAmount = 'fromAmount',
|
|
14
15
|
HiddenUI["Language"] = "language";
|
|
15
16
|
HiddenUI["PoweredBy"] = "poweredBy";
|
|
16
17
|
HiddenUI["ToAddress"] = "toAddress";
|
|
18
|
+
// ToToken = 'toToken',
|
|
17
19
|
})(HiddenUI = exports.HiddenUI || (exports.HiddenUI = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useWidgetConfig } from '../../providers';
|
|
3
|
+
import { Card } from '../Card';
|
|
4
|
+
export const ContractComponent = (props) => {
|
|
5
|
+
const { contractComponent } = useWidgetConfig();
|
|
6
|
+
if (!contractComponent) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return (_jsx(Card, Object.assign({ flex: 1 }, props, { children: contractComponent })));
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContractComponent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContractComponent';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ArrowBack as ArrowBackIcon, ReceiptLongRounded as HistoryIcon, SettingsOutlined as SettingsIcon } from '@mui/icons-material';
|
|
2
|
+
import { ArrowBack as ArrowBackIcon, ReceiptLongRounded as HistoryIcon, SettingsOutlined as SettingsIcon, } from '@mui/icons-material';
|
|
3
3
|
import { Box, IconButton, Tooltip, Typography } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
|
6
6
|
import { useNavigateBack } from '../../hooks';
|
|
7
7
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
8
|
-
import { backButtonRoutes, navigationRoutes, navigationRoutesValues } from '../../utils';
|
|
8
|
+
import { backButtonRoutes, navigationRoutes, navigationRoutesValues, } from '../../utils';
|
|
9
9
|
import { HeaderAppBar } from './Header.style';
|
|
10
10
|
import { useHeaderActionStore } from './useHeaderActionStore';
|
|
11
11
|
export const NavigationHeader = () => {
|
|
@@ -44,8 +44,16 @@ export const NavigationHeader = () => {
|
|
|
44
44
|
return t(`header.swap`);
|
|
45
45
|
case navigationRoutes.swapDetails:
|
|
46
46
|
return t(`header.swapDetails`);
|
|
47
|
-
default:
|
|
48
|
-
|
|
47
|
+
default: {
|
|
48
|
+
switch (variant) {
|
|
49
|
+
case 'nft':
|
|
50
|
+
return t(`header.checkout`);
|
|
51
|
+
case 'refuel':
|
|
52
|
+
return t(`header.gas`);
|
|
53
|
+
default:
|
|
54
|
+
return t(`header.swap`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
};
|
|
51
59
|
return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", edge: "start", onClick: navigateBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(Tooltip, Object.assign({ title: t(`header.swapHistory`), enterDelay: 400, arrow: true }, { children: _jsx(IconButton, Object.assign({ size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory) }, { children: _jsx(HistoryIcon, {}) })) }))) : null, _jsx(Tooltip, Object.assign({ title: t(`header.settings`), enterDelay: 400, arrow: true }, { children: _jsx(IconButton, Object.assign({ size: "medium", onClick: () => navigate(navigationRoutes.settings), sx: {
|
|
@@ -62,5 +62,5 @@ const ConnectedButton = () => {
|
|
|
62
62
|
});
|
|
63
63
|
return (_jsxs(_Fragment, { children: [_jsx(WalletButton, Object.assign({ endIcon: _jsx(ExpandMoreIcon, {}), startIcon: _jsx(Avatar, Object.assign({ src: chain === null || chain === void 0 ? void 0 : chain.logoURI, alt: chain === null || chain === void 0 ? void 0 : chain.key, sx: { width: 24, height: 24 } }, { children: chain === null || chain === void 0 ? void 0 : chain.name[0] })), sx: {
|
|
64
64
|
marginRight: -1.25,
|
|
65
|
-
}, onClick: handleClick }, { children: walletAddress })), _jsxs(Menu, Object.assign({ elevation: 2, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose }, { children: [_jsxs(MenuItem, Object.assign({ onClick: handleCopyAddress, disableRipple: true
|
|
65
|
+
}, onClick: handleClick }, { children: walletAddress })), _jsxs(Menu, Object.assign({ elevation: 2, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose }, { children: [_jsxs(MenuItem, Object.assign({ onClick: handleCopyAddress, disableRipple: true }, { children: [_jsx(ContentCopyIcon, {}), t(`button.copyAddress`)] })), _jsxs(MenuItem, Object.assign({ onClick: handleDisconnect, disableRipple: true }, { children: [_jsx(PowerSettingsIcon, {}), t(`button.disconnectWallet`)] }))] }))] }));
|
|
66
66
|
};
|