@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
package/hooks/useSwapRoutes.js
CHANGED
|
@@ -12,6 +12,7 @@ import { LifiErrorCode } from '@lifi/sdk';
|
|
|
12
12
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
13
13
|
import Big from 'big.js';
|
|
14
14
|
import { useWatch } from 'react-hook-form';
|
|
15
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
15
16
|
import { useDebouncedWatch, useToken } from '.';
|
|
16
17
|
import { SwapFormKey, useLiFi, useWallet, useWidgetConfig } from '../providers';
|
|
17
18
|
import { useSettings } from '../stores';
|
|
@@ -28,36 +29,47 @@ export const useSwapRoutes = () => {
|
|
|
28
29
|
'enabledBridges',
|
|
29
30
|
'enabledExchanges',
|
|
30
31
|
]);
|
|
31
|
-
const [
|
|
32
|
+
const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount], 320);
|
|
33
|
+
const [fromChainId, fromTokenAddress, toAddress, toTokenAmount, toChainId, toContractAddress, toContractCallData, toContractGasLimit, toTokenAddress,] = useWatch({
|
|
32
34
|
name: [
|
|
33
35
|
SwapFormKey.FromChain,
|
|
34
36
|
SwapFormKey.FromToken,
|
|
37
|
+
SwapFormKey.ToAddress,
|
|
38
|
+
SwapFormKey.ToAmount,
|
|
35
39
|
SwapFormKey.ToChain,
|
|
40
|
+
SwapFormKey.ToContractAddress,
|
|
41
|
+
SwapFormKey.ToContractCallData,
|
|
42
|
+
SwapFormKey.ToContractGasLimit,
|
|
36
43
|
SwapFormKey.ToToken,
|
|
37
|
-
SwapFormKey.ToAddress,
|
|
38
44
|
],
|
|
39
45
|
});
|
|
40
|
-
const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount], 320);
|
|
41
46
|
const { token: fromToken } = useToken(fromChainId, fromTokenAddress);
|
|
42
47
|
const { token: toToken } = useToken(toChainId, toTokenAddress);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
const hasAmount = (!isNaN(fromTokenAmount) && Number(fromTokenAmount) > 0) ||
|
|
49
|
+
(!isNaN(toTokenAmount) && Number(toTokenAmount) > 0);
|
|
50
|
+
const contractCallQuoteEnabled = variant === 'nft'
|
|
51
|
+
? Boolean(toContractAddress && toContractCallData && toContractGasLimit)
|
|
52
|
+
: true;
|
|
53
|
+
const isEnabled = !isNaN(fromChainId) &&
|
|
46
54
|
!isNaN(toChainId) &&
|
|
47
55
|
Boolean(fromToken === null || fromToken === void 0 ? void 0 : fromToken.address) &&
|
|
48
56
|
Boolean(toToken === null || toToken === void 0 ? void 0 : toToken.address) &&
|
|
49
|
-
!isNaN(
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
!Number.isNaN(slippage) &&
|
|
58
|
+
hasAmount &&
|
|
59
|
+
contractCallQuoteEnabled;
|
|
52
60
|
const queryKey = [
|
|
53
61
|
'routes',
|
|
54
62
|
account.address,
|
|
55
63
|
fromChainId,
|
|
56
64
|
fromToken === null || fromToken === void 0 ? void 0 : fromToken.address,
|
|
57
65
|
fromTokenAmount,
|
|
66
|
+
toAddress,
|
|
58
67
|
toChainId,
|
|
59
68
|
toToken === null || toToken === void 0 ? void 0 : toToken.address,
|
|
60
|
-
|
|
69
|
+
toTokenAmount,
|
|
70
|
+
toContractAddress,
|
|
71
|
+
toContractCallData,
|
|
72
|
+
toContractGasLimit,
|
|
61
73
|
slippage,
|
|
62
74
|
enabledBridges,
|
|
63
75
|
enabledExchanges,
|
|
@@ -69,20 +81,58 @@ export const useSwapRoutes = () => {
|
|
|
69
81
|
const refetchInterval = previousDataUpdatedAt
|
|
70
82
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
71
83
|
: refetchTime;
|
|
72
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress,
|
|
73
|
-
var _c, _d;
|
|
84
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = 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* () {
|
|
85
|
+
var _c, _d, _e;
|
|
74
86
|
let toWalletAddress;
|
|
75
87
|
try {
|
|
76
88
|
toWalletAddress =
|
|
77
89
|
(_c = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _c !== void 0 ? _c : (isAddress(toAddress) ? toAddress : fromAddress);
|
|
78
90
|
}
|
|
79
|
-
catch (
|
|
91
|
+
catch (_f) {
|
|
80
92
|
toWalletAddress = isAddress(toAddress) ? toAddress : fromAddress;
|
|
81
93
|
}
|
|
82
|
-
const fromAmount = Big(fromTokenAmount)
|
|
94
|
+
const fromAmount = Big(fromTokenAmount || 0)
|
|
83
95
|
.mul(Math.pow(10, ((_d = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _d !== void 0 ? _d : 0)))
|
|
84
96
|
.toString();
|
|
97
|
+
// const toAmount = Big(toTokenAmount || 0)
|
|
98
|
+
// .mul(10 ** (toToken?.decimals ?? 0))
|
|
99
|
+
// .toString();
|
|
85
100
|
const formattedSlippage = parseFloat(slippage) / 100;
|
|
101
|
+
if (variant === 'nft') {
|
|
102
|
+
const contractCallQuote = yield lifi.getContractCallQuote({
|
|
103
|
+
fromAddress,
|
|
104
|
+
fromChain: fromChainId,
|
|
105
|
+
fromToken: fromTokenAddress,
|
|
106
|
+
toAmount: toTokenAmount,
|
|
107
|
+
toChain: toChainId,
|
|
108
|
+
toToken: toTokenAddress,
|
|
109
|
+
toContractAddress,
|
|
110
|
+
toContractCallData,
|
|
111
|
+
toContractGasLimit,
|
|
112
|
+
// toFallbackAddress: toAddress,
|
|
113
|
+
slippage: formattedSlippage,
|
|
114
|
+
}, { signal });
|
|
115
|
+
contractCallQuote.estimate.toAmount = toTokenAmount;
|
|
116
|
+
contractCallQuote.estimate.toAmountMin = toTokenAmount;
|
|
117
|
+
contractCallQuote.action.toToken = toToken;
|
|
118
|
+
const route = {
|
|
119
|
+
id: uuidv4(),
|
|
120
|
+
fromChainId: contractCallQuote.action.fromChainId,
|
|
121
|
+
fromAmountUSD: contractCallQuote.estimate.fromAmountUSD || '',
|
|
122
|
+
fromAmount: contractCallQuote.action.fromAmount,
|
|
123
|
+
fromToken: contractCallQuote.action.fromToken,
|
|
124
|
+
fromAddress: contractCallQuote.action.fromAddress,
|
|
125
|
+
toChainId: contractCallQuote.action.toChainId,
|
|
126
|
+
toAmountUSD: contractCallQuote.estimate.toAmountUSD || '',
|
|
127
|
+
toAmount: toTokenAmount,
|
|
128
|
+
toAmountMin: toTokenAmount,
|
|
129
|
+
toToken: toToken,
|
|
130
|
+
toAddress: toAddress,
|
|
131
|
+
gasCostUSD: (_e = contractCallQuote.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].amountUSD,
|
|
132
|
+
steps: [contractCallQuote],
|
|
133
|
+
};
|
|
134
|
+
return { routes: [route] };
|
|
135
|
+
}
|
|
86
136
|
return lifi.getRoutes({
|
|
87
137
|
fromChainId,
|
|
88
138
|
fromAmount,
|
package/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/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/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/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { App } from './App';
|
|
2
2
|
import { AppDrawer } from './AppDrawer';
|
|
3
3
|
import './fonts/inter.css';
|
|
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
|
// ClassNameGenerator.configure((componentName) =>
|
|
7
9
|
// componentName.replace('Mui', 'LiFi'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.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",
|
|
@@ -39,31 +39,33 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@emotion/react": "^11.10.5",
|
|
41
41
|
"@emotion/styled": "^11.10.5",
|
|
42
|
+
"@ethersproject/abstract-signer": "^5.7.0",
|
|
42
43
|
"@ethersproject/address": "^5.7.0",
|
|
43
44
|
"@ethersproject/experimental": "^5.7.0",
|
|
44
45
|
"@ethersproject/providers": "^5.7.2",
|
|
45
46
|
"@lifi/sdk": "^1.7.2",
|
|
46
|
-
"@lifi/wallet-management": "^1.2.
|
|
47
|
+
"@lifi/wallet-management": "^1.2.4",
|
|
47
48
|
"@mui/icons-material": "^5.11.0",
|
|
48
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
49
|
-
"@mui/material": "^5.11.
|
|
50
|
-
"@sentry/integrations": "^7.
|
|
51
|
-
"@sentry/react": "^7.
|
|
52
|
-
"@sentry/tracing": "^7.
|
|
53
|
-
"@tanstack/react-query": "^4.20.
|
|
54
|
-
"@tanstack/react-virtual": "^3.0.0-beta.
|
|
49
|
+
"@mui/lab": "^5.0.0-alpha.114",
|
|
50
|
+
"@mui/material": "^5.11.3",
|
|
51
|
+
"@sentry/integrations": "^7.29.0",
|
|
52
|
+
"@sentry/react": "^7.29.0",
|
|
53
|
+
"@sentry/tracing": "^7.29.0",
|
|
54
|
+
"@tanstack/react-query": "^4.20.9",
|
|
55
|
+
"@tanstack/react-virtual": "^3.0.0-beta.34",
|
|
55
56
|
"big.js": "^6.2.1",
|
|
56
|
-
"i18next": "22.4.
|
|
57
|
+
"i18next": "^22.4.8",
|
|
57
58
|
"i18next-browser-languagedetector": "^7.0.1",
|
|
58
59
|
"microdiff": "^1.3.1",
|
|
59
60
|
"mitt": "^3.0.0",
|
|
60
61
|
"react": "^18.2.0",
|
|
61
62
|
"react-dom": "^18.2.0",
|
|
62
|
-
"react-hook-form": "^7.
|
|
63
|
+
"react-hook-form": "^7.41.5",
|
|
63
64
|
"react-i18next": "^12.1.1",
|
|
64
|
-
"react-router-dom": "^6.
|
|
65
|
+
"react-router-dom": "^6.6.1",
|
|
65
66
|
"react-timer-hook": "^3.0.5",
|
|
66
|
-
"
|
|
67
|
+
"uuid": "^9.0.0",
|
|
68
|
+
"zustand": "^4.2.0"
|
|
67
69
|
},
|
|
68
70
|
"peerDependencies": {
|
|
69
71
|
"@types/react": "^18.0.0",
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { ActiveSwaps } from '../../components/ActiveSwaps';
|
|
4
|
+
import { ContractComponent } from '../../components/ContractComponent';
|
|
4
5
|
import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
|
|
5
6
|
import { SelectChainAndToken } from '../../components/SelectChainAndToken';
|
|
6
7
|
import { SendToWallet, SendToWalletButton, } from '../../components/SendToWallet';
|
|
7
8
|
import { SwapInput } from '../../components/SwapInput';
|
|
8
9
|
import { SwapRoutes } from '../../components/SwapRoutes';
|
|
9
10
|
import { useExpandableVariant } from '../../hooks';
|
|
11
|
+
import { useWidgetConfig } from '../../providers';
|
|
10
12
|
import { FormContainer } from './MainPage.style';
|
|
11
13
|
import { MainSwapButton } from './MainSwapButton';
|
|
12
14
|
export const MainPage = () => {
|
|
13
15
|
const expandable = useExpandableVariant();
|
|
14
|
-
|
|
16
|
+
const { variant } = useWidgetConfig();
|
|
17
|
+
const nft = variant === 'nft';
|
|
18
|
+
return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), nft ? _jsx(ContractComponent, { mx: 3, mt: 1, mb: 1 }) : null, _jsx(SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), !nft ? _jsx(SwapInput, { formType: "from", mx: 3, mb: 3 }) : null, !expandable ? _jsx(SwapRoutes, { mx: 3, mb: 3 }) : null, _jsx(GasSufficiencyMessage, { mx: 3, mb: 3 }), _jsxs(Box, Object.assign({ mx: 3, mb: 1 }, { children: [_jsx(SendToWallet, { mb: 3 }), _jsxs(Box, Object.assign({ sx: { display: 'flex' } }, { children: [_jsx(MainSwapButton, {}), _jsx(SendToWalletButton, {})] }))] }))] })));
|
|
15
19
|
};
|
|
@@ -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
|
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export var SwapFormKey;
|
|
2
2
|
(function (SwapFormKey) {
|
|
3
|
+
SwapFormKey["ContractOutputsToken"] = "contractOutputsToken";
|
|
3
4
|
SwapFormKey["FromAmount"] = "fromAmount";
|
|
4
5
|
SwapFormKey["FromChain"] = "fromChain";
|
|
5
6
|
SwapFormKey["FromToken"] = "fromToken";
|
|
6
7
|
SwapFormKey["ToAddress"] = "toAddress";
|
|
8
|
+
SwapFormKey["ToAmount"] = "toAmount";
|
|
7
9
|
SwapFormKey["ToChain"] = "toChain";
|
|
10
|
+
SwapFormKey["ToContractAddress"] = "toContractAddress";
|
|
11
|
+
SwapFormKey["ToContractCallData"] = "toContractCallData";
|
|
12
|
+
SwapFormKey["ToContractGasLimit"] = "ToContractGasLimit";
|
|
8
13
|
SwapFormKey["ToToken"] = "toToken";
|
|
9
14
|
SwapFormKey["TokenSearchFilter"] = "tokenSearchFilter";
|
|
10
15
|
})(SwapFormKey || (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;
|