@xswap-link/sdk 0.3.5 → 0.4.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/.eslintrc.json +9 -5
- package/CHANGELOG.md +10 -0
- package/README.md +2 -1
- package/dist/index.d.mts +106 -20
- package/dist/index.d.ts +106 -20
- package/dist/index.global.js +963 -164
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +105 -3564
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +105 -3534
- package/dist/index.mjs.map +1 -0
- package/nodemon.json +1 -1
- package/package.json +16 -9
- package/postcss.config.js +8 -1
- package/src/{components → assets}/icons/ArrowDownIcon.tsx +1 -2
- package/src/assets/icons/ArrowDownLongIcon.tsx +12 -0
- package/src/{components → assets}/icons/ArrowLeftIcon.tsx +1 -5
- package/src/{components → assets}/icons/ArrowRightIcon.tsx +1 -5
- package/src/assets/icons/ArrowUpIcon.tsx +12 -0
- package/src/{components → assets}/icons/ArrowUpRightIcon.tsx +1 -5
- package/src/assets/icons/CashbacklIcon.tsx +28 -0
- package/src/{components → assets}/icons/CheckIcon.tsx +1 -5
- package/src/assets/icons/ChevronDownIcon.tsx +12 -0
- package/src/assets/icons/ChevronUpIcon.tsx +7 -0
- package/src/{components → assets}/icons/CircularProgressIcon.tsx +1 -2
- package/src/assets/icons/CloseIcon.tsx +15 -0
- package/src/{components → assets}/icons/CoinsIcon.tsx +0 -2
- package/src/assets/icons/CopyIcon.tsx +15 -0
- package/src/assets/icons/DotGreenIcon.tsx +12 -0
- package/src/{components → assets}/icons/DownArrorIcon.tsx +0 -2
- package/src/{components → assets}/icons/ErrorIcon.tsx +0 -1
- package/src/assets/icons/ErrorModalStatusIcon.tsx +31 -0
- package/src/assets/icons/HelpIcon.tsx +21 -0
- package/src/assets/icons/HistoryGradientBgIcon.tsx +32 -0
- package/src/assets/icons/HistoryIcon.tsx +12 -0
- package/src/{components → assets}/icons/HourGlassIcon.tsx +1 -5
- package/src/assets/icons/Icon.tsx +5 -0
- package/src/{components → assets}/icons/InfoIcon.tsx +0 -1
- package/src/assets/icons/LinkExternalIcon.tsx +15 -0
- package/src/{components → assets}/icons/PercentageIcon.tsx +0 -1
- package/src/assets/icons/RankIcon.tsx +28 -0
- package/src/assets/icons/SettingsGradientBgIcon.tsx +32 -0
- package/src/assets/icons/SettingsIcon.tsx +12 -0
- package/src/{components → assets}/icons/SignIcon.tsx +0 -2
- package/src/{components → assets}/icons/SuccessIcon.tsx +0 -1
- package/src/assets/icons/SuccessModalStatusIcon.tsx +31 -0
- package/src/assets/icons/ThumbUpRoundedIcon.tsx +15 -0
- package/src/{components → assets}/icons/TimerIcon.tsx +0 -1
- package/src/assets/icons/TokensIcon.tsx +16 -0
- package/src/assets/icons/WaitingIcon.tsx +15 -0
- package/src/{components → assets}/icons/XMarkIcon.tsx +1 -5
- package/src/assets/icons/XPowerIcon.tsx +28 -0
- package/src/{components → assets}/icons/index.ts +16 -0
- package/src/components/Alert/index.tsx +1 -1
- package/src/components/Button/index.tsx +57 -0
- package/src/components/MessageBar/SnackMessage.tsx +32 -0
- package/src/components/MessageBar/index.tsx +44 -0
- package/src/components/Modal/index.tsx +52 -0
- package/src/components/PoweredBy/index.tsx +12 -0
- package/src/components/SafeInput/index.tsx +51 -0
- package/src/components/Skeleton/index.tsx +5 -9
- package/src/components/Spinner/index.tsx +6 -8
- package/src/components/Swap/Header/Controls/index.tsx +57 -0
- package/src/components/Swap/Header/index.tsx +16 -0
- package/src/components/Swap/HistoryView/index.tsx +34 -0
- package/src/components/Swap/SettingsView/Delivery/index.tsx +42 -0
- package/src/components/Swap/SettingsView/Slippage/index.tsx +80 -0
- package/src/components/Swap/SettingsView/index.tsx +11 -0
- package/src/components/Swap/SwapView/ConfirmationView/TxOverview/ArrowIcon.tsx +13 -0
- package/src/components/Swap/SwapView/ConfirmationView/TxOverview/Header/index.tsx +37 -0
- package/src/components/Swap/SwapView/ConfirmationView/TxOverview/Steps/index.tsx +145 -0
- package/src/components/Swap/SwapView/ConfirmationView/TxOverview/SwapPanel/index.tsx +61 -0
- package/src/components/Swap/SwapView/ConfirmationView/TxOverview/index.tsx +291 -0
- package/src/components/Swap/SwapView/ConfirmationView/TxResult/TokenItem/index.tsx +24 -0
- package/src/components/Swap/SwapView/ConfirmationView/TxResult/index.tsx +84 -0
- package/src/components/Swap/SwapView/ConfirmationView/index.tsx +17 -0
- package/src/components/Swap/SwapView/FeesPanel/DeliveryInfo/index.tsx +25 -0
- package/src/components/Swap/SwapView/FeesPanel/Fee/index.tsx +18 -0
- package/src/components/Swap/SwapView/FeesPanel/Fees/index.tsx +71 -0
- package/src/components/Swap/SwapView/FeesPanel/index.tsx +67 -0
- package/src/components/Swap/SwapView/SwapButton/index.tsx +154 -0
- package/src/components/Swap/SwapView/SwapPanel/AmountPanel/Balance/index.tsx +23 -0
- package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +56 -0
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/ChainItem/index.tsx +70 -0
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/index.tsx +62 -0
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/index.tsx +74 -0
- package/src/components/Swap/SwapView/SwapPanel/MaxPanel/index.tsx +35 -0
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/QuickPickTokenItem/index.tsx +40 -0
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +62 -0
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +399 -0
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +104 -0
- package/src/components/Swap/SwapView/SwapPanel/index.tsx +42 -0
- package/src/components/Swap/SwapView/index.tsx +20 -0
- package/src/components/Swap/index.tsx +34 -0
- package/src/components/TextInput/index.tsx +67 -0
- package/src/components/Timer/index.tsx +57 -0
- package/src/components/ToggleButton/index.tsx +24 -0
- package/src/components/{UnknownTokenLogo/UnknownTokenLogo.tsx → TokenLogo/Unknown/index.tsx} +3 -4
- package/src/components/TokenLogo/WithChain/index.tsx +34 -0
- package/src/components/TokenLogo/index.tsx +22 -0
- package/src/components/Tooltip/index.tsx +108 -0
- package/src/components/TxConfigForm/index.tsx +63 -42
- package/src/components/TxDataCard/TokenDetails/index.tsx +30 -0
- package/src/components/TxDataCard/TxDataCardUI/index.tsx +133 -0
- package/src/components/TxDataCard/index.tsx +30 -0
- package/src/components/TxStatusButton/index.tsx +64 -108
- package/src/components/global.css +115 -4
- package/src/components/index.ts +18 -1
- package/src/config/fonts.ts +114 -0
- package/src/config/global.d.ts +4 -0
- package/src/config/init.tsx +35 -31
- package/src/constants/crosschainEstimationTimes.ts +52 -0
- package/src/constants/index.ts +8 -0
- package/src/context/GlobalDataProvider.tsx +165 -0
- package/src/context/HistoryProvider.tsx +339 -0
- package/src/context/ModalProvider.tsx +47 -0
- package/src/context/SwapProvider.tsx +664 -0
- package/src/context/TransactionProvider.tsx +86 -0
- package/src/context/TxUIWrapper.tsx +388 -0
- package/src/context/index.ts +5 -0
- package/src/contracts/abi/CustomXSwapRouter.json +953 -0
- package/src/contracts/abi/StakingStableAPR.json +1438 -0
- package/src/contracts/abi/XSwapRouter.json +1242 -0
- package/src/contracts/abi/XSwapTokenFeeDistributor.json +350 -0
- package/src/contracts/abi/index.ts +8 -0
- package/src/contracts/addresses.ts +24 -6
- package/src/fonts/Satoshi-Black.woff2 +0 -0
- package/src/fonts/Satoshi-BlackItalic.woff2 +0 -0
- package/src/fonts/Satoshi-Bold.woff2 +0 -0
- package/src/fonts/Satoshi-BoldItalic.woff2 +0 -0
- package/src/fonts/Satoshi-Light.woff2 +0 -0
- package/src/fonts/Satoshi-LightItalic.woff2 +0 -0
- package/src/fonts/Satoshi-Medium.woff2 +0 -0
- package/src/fonts/Satoshi-MediumItalic.woff2 +0 -0
- package/src/fonts/Satoshi-Regular.woff2 +0 -0
- package/src/fonts/Satoshi-RegularItalic.woff2 +0 -0
- package/src/fonts/Satoshi-Variable.woff2 +0 -0
- package/src/fonts/Satoshi-VariableItalic.woff2 +0 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/networkManagement/clientToSigner.tsx +17 -0
- package/src/hooks/networkManagement/useNetworks.ts +51 -0
- package/src/hooks/useBatchQuery.ts +46 -0
- package/src/hooks/useDebounce.tsx +28 -0
- package/src/hooks/useEvmContractApi.ts +85 -0
- package/src/hooks/usePortal.ts +79 -0
- package/src/hooks/useXPower.ts +58 -0
- package/src/models/Addresses.ts +8 -2
- package/src/models/TokenData.ts +13 -0
- package/src/models/TransactionHistory.ts +2 -0
- package/src/models/TxUIWrapper.ts +51 -0
- package/src/models/XSwapConfig.ts +1 -0
- package/src/models/index.ts +1 -0
- package/src/models/payloads/GetBalancesPayload.ts +3 -0
- package/src/models/payloads/GetFinishedLeaderboardQuestsPayload.ts +3 -0
- package/src/models/payloads/GetLeaderboardChangePayload.ts +4 -0
- package/src/models/payloads/{GetSwapTxPayload.ts → ModalIntegrationPayload.ts} +3 -1
- package/src/models/payloads/index.ts +5 -2
- package/src/services/api.ts +34 -5
- package/src/services/integrations/monitoring.ts +49 -37
- package/src/services/integrations/transactions.ts +50 -6
- package/src/utils/contracts.ts +29 -0
- package/src/utils/index.ts +3 -3
- package/src/utils/numbers.ts +14 -0
- package/src/utils/parseWeb3Error.ts +7 -3
- package/tailwind.config.js +15 -5
- package/tsconfig.json +7 -7
- package/tsup.config.ts +61 -0
- package/xswap.config.ts +1 -0
- package/dist/index.css +0 -1
- package/src/components/TxConfigForm/BalanceComponent.tsx +0 -52
- package/src/components/TxConfigForm/Button.tsx +0 -20
- package/src/components/TxConfigForm/ChainListElement.tsx +0 -36
- package/src/components/TxConfigForm/ConfirmationAmount.tsx +0 -91
- package/src/components/TxConfigForm/ConfirmationView/ErrorView.tsx +0 -38
- package/src/components/TxConfigForm/ConfirmationView/SuccessView.tsx +0 -159
- package/src/components/TxConfigForm/ConfirmationView/index.tsx +0 -149
- package/src/components/TxConfigForm/ConnectWalletPrompt.tsx +0 -21
- package/src/components/TxConfigForm/Description.tsx +0 -17
- package/src/components/TxConfigForm/ErrorField.tsx +0 -19
- package/src/components/TxConfigForm/FeesDetails.tsx +0 -117
- package/src/components/TxConfigForm/Form.tsx +0 -574
- package/src/components/TxConfigForm/History.tsx +0 -131
- package/src/components/TxConfigForm/HistoryCard.tsx +0 -182
- package/src/components/TxConfigForm/PoweredBy.tsx +0 -12
- package/src/components/TxConfigForm/Settings.tsx +0 -143
- package/src/components/TxConfigForm/Summary.tsx +0 -105
- package/src/components/TxConfigForm/SwapPanel.tsx +0 -185
- package/src/components/TxConfigForm/TokenPicker.tsx +0 -176
- package/src/components/TxConfigForm/TopBar.tsx +0 -58
- package/src/components/TxConfigForm/UsdPrice.tsx +0 -44
- package/src/components/icons/ChevronDownIcon.tsx +0 -15
- package/src/components/icons/ChevronUpIcon.tsx +0 -10
- package/src/components/icons/CloseIcon.tsx +0 -15
- package/src/components/icons/HistoryIcon.tsx +0 -16
- package/src/components/icons/SettingsIcon.tsx +0 -16
- /package/src/{components → assets}/icons/ChainlinkCCIPIcon.tsx +0 -0
- /package/src/{components → assets}/icons/SearchIcon.tsx +0 -0
- /package/src/{components → assets}/icons/XSwapBadgeIcon.tsx +0 -0
- /package/src/{components → assets}/icons/XSwapLogo.tsx +0 -0
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { FC, useCallback, useMemo } from "react";
|
|
2
|
-
import { deepMergeObjects, getDate, weiToHumanReadable } from "@src/utils";
|
|
3
|
-
import { Chain, Token, Transaction } from "@src/models";
|
|
4
|
-
import { ArrowRightIcon, ArrowUpRightIcon } from "@src/components/icons";
|
|
5
|
-
import { MINIMUM_DISPLAYED_TOKEN_AMOUNT } from "@src/constants";
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
transaction: Transaction;
|
|
9
|
-
supportedChains: Chain[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const HistoryCard: FC<Props> = ({ transaction, supportedChains }) => {
|
|
13
|
-
const date = getDate(transaction.timestamp);
|
|
14
|
-
|
|
15
|
-
const supportedTokens: Record<string, Record<string, Token>> = useMemo(() => {
|
|
16
|
-
const customTokens = JSON.parse(
|
|
17
|
-
localStorage.getItem("custom-tokens") || "{}",
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const chainIdToTokenAddressToData: Record<
|
|
21
|
-
string,
|
|
22
|
-
Record<string, Token>
|
|
23
|
-
> = {};
|
|
24
|
-
|
|
25
|
-
supportedChains.forEach((chain) => {
|
|
26
|
-
chainIdToTokenAddressToData[chain.chainId] = {};
|
|
27
|
-
chain.tokens.forEach((token) => {
|
|
28
|
-
chainIdToTokenAddressToData[chain.chainId]![token.address] = token;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
return deepMergeObjects(chainIdToTokenAddressToData, customTokens);
|
|
32
|
-
}, [supportedChains]);
|
|
33
|
-
|
|
34
|
-
const findTokenDataByAddressAndChain = useCallback(
|
|
35
|
-
(tokenAddress: string, chainId: string): Token | undefined => {
|
|
36
|
-
return supportedTokens[chainId]?.[tokenAddress];
|
|
37
|
-
},
|
|
38
|
-
[supportedTokens],
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const tokenData = findTokenDataByAddressAndChain(
|
|
42
|
-
transaction.tokenAddress.toLowerCase(),
|
|
43
|
-
transaction.sourceChainId,
|
|
44
|
-
);
|
|
45
|
-
const tokenOutData = transaction.tokenOutAddress
|
|
46
|
-
? findTokenDataByAddressAndChain(
|
|
47
|
-
transaction.tokenOutAddress?.toLowerCase(),
|
|
48
|
-
transaction.targetChainId,
|
|
49
|
-
)
|
|
50
|
-
: undefined;
|
|
51
|
-
const transferredAmount = weiToHumanReadable({
|
|
52
|
-
amount: transaction.amountWei,
|
|
53
|
-
decimals: tokenData?.decimals || 18,
|
|
54
|
-
precisionFractionalPlaces: 4,
|
|
55
|
-
});
|
|
56
|
-
const receivedAmount = weiToHumanReadable({
|
|
57
|
-
amount: transaction?.tokenOutAmount || "0",
|
|
58
|
-
decimals: tokenOutData?.decimals || 18,
|
|
59
|
-
precisionFractionalPlaces: 4,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const sourceChainData = supportedChains.find(
|
|
63
|
-
(chain) => chain.chainId === transaction.sourceChainId,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const targetChainData = supportedChains.find(
|
|
67
|
-
(chain) => chain.chainId === transaction.targetChainId,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<div className="xpay-flex xpay-flex-col xpay-global-border xpay-rounded-xl xpay-bg-[rgb(15,15,15)] xpay-text-white xpay-text-xs sm:xpay-text-sm xpay-p-4 xpay-gap-3 xpay-mb-2">
|
|
72
|
-
<div className="xpay-flex xpay-w-full xpay-items-center xpay-justify-between">
|
|
73
|
-
<div className="xpay-text-sm sm:xpay-text-base">{date}</div>
|
|
74
|
-
<div className="xpay-flex xpay-items-center">
|
|
75
|
-
{transaction.status === "IN_PROGRESS" && (
|
|
76
|
-
<div className="xpay-flex xpay-items-center">
|
|
77
|
-
<div className="xpay-text-[rgb(250,200,100)]">In progress</div>
|
|
78
|
-
</div>
|
|
79
|
-
)}
|
|
80
|
-
|
|
81
|
-
{transaction.status === "DONE" && (
|
|
82
|
-
<div className="xpay-flex xpay-items-center">
|
|
83
|
-
<div className="xpay-text-[rgb(100,200,100)]">Done</div>
|
|
84
|
-
</div>
|
|
85
|
-
)}
|
|
86
|
-
|
|
87
|
-
{transaction.status === "REVERTED" && (
|
|
88
|
-
<div className="xpay-flex xpay-items-center">
|
|
89
|
-
<div className="xpay-text-[rgb(255,100,100)]">Reverted</div>
|
|
90
|
-
</div>
|
|
91
|
-
)}
|
|
92
|
-
|
|
93
|
-
<a
|
|
94
|
-
href={`${
|
|
95
|
-
supportedChains.find(
|
|
96
|
-
(chain) => chain.chainId === transaction.sourceChainId,
|
|
97
|
-
)?.transactionExplorer
|
|
98
|
-
}/${transaction.hash}`}
|
|
99
|
-
target="_blank"
|
|
100
|
-
rel="noreferrer"
|
|
101
|
-
className="xpay-ml-2 xpay-no-underline visited:xpay-text-white hover:xpay-text-white"
|
|
102
|
-
aria-label="Show the transaction in the chain explorer"
|
|
103
|
-
>
|
|
104
|
-
<div className="xpay-w-3.5 xpay-h-3.5">
|
|
105
|
-
<ArrowUpRightIcon />
|
|
106
|
-
</div>
|
|
107
|
-
</a>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
<div className="xpay-flex xpay-justify-between xpay-flex-wrap xpay-gap-2">
|
|
111
|
-
<div className="xpay-flex xpay-items-center">
|
|
112
|
-
<div className="xpay-flex xpay-items-center">
|
|
113
|
-
<img
|
|
114
|
-
src={sourceChainData?.image}
|
|
115
|
-
alt={`${sourceChainData?.name} logo`}
|
|
116
|
-
className="xpay-w-5 xpay-h-5 xpay-mr-1"
|
|
117
|
-
/>
|
|
118
|
-
<div>{sourceChainData?.displayName}</div>
|
|
119
|
-
</div>
|
|
120
|
-
|
|
121
|
-
<div className="xpay-w-3.5 xpay-h-3.5 xpay-my-0 xpay-mx-1.5">
|
|
122
|
-
<ArrowRightIcon />
|
|
123
|
-
</div>
|
|
124
|
-
|
|
125
|
-
<div className="xpay-flex xpay-items-center">
|
|
126
|
-
<img
|
|
127
|
-
src={targetChainData?.image}
|
|
128
|
-
alt={`${targetChainData?.name} logo`}
|
|
129
|
-
className="xpay-w-5 xpay-h-5 xpay-mr-1"
|
|
130
|
-
/>
|
|
131
|
-
<div>{targetChainData?.displayName}</div>
|
|
132
|
-
</div>
|
|
133
|
-
</div>
|
|
134
|
-
|
|
135
|
-
<div className="xpay-flex xpay-items-center xpay-mb-2 last:xpay-mb-0">
|
|
136
|
-
<div className="xpay-flex xpay-items-center xpay-flex-wrap">
|
|
137
|
-
<div className="xpay-flex xpay-items-center">
|
|
138
|
-
{Number(transferredAmount) < MINIMUM_DISPLAYED_TOKEN_AMOUNT
|
|
139
|
-
? `<${MINIMUM_DISPLAYED_TOKEN_AMOUNT}`
|
|
140
|
-
: transferredAmount}
|
|
141
|
-
<div className="xpay-ml-1">{tokenData?.symbol}</div>
|
|
142
|
-
{tokenData?.image ? (
|
|
143
|
-
<img
|
|
144
|
-
src={tokenData?.image}
|
|
145
|
-
alt={tokenData?.name || ""}
|
|
146
|
-
className="xpay-w-5 xpay-h-5 xpay-ml-1"
|
|
147
|
-
/>
|
|
148
|
-
) : (
|
|
149
|
-
<div className="xpay-flex xpay-items-center xpay-justify-center xpay-w-5 xpay-h-5 xpay-text-[10px] xpay-ml-1 xpay-rounded-full xpay-bg-[#272e40] xpay-text-[#e0e7fa]">
|
|
150
|
-
{tokenData?.symbol.substring(0, 1)}
|
|
151
|
-
</div>
|
|
152
|
-
)}
|
|
153
|
-
</div>
|
|
154
|
-
{transaction.tokenOutAddress && (
|
|
155
|
-
<>
|
|
156
|
-
<div className="xpay-w-3.5 xpay-h-3.5 xpay-my-0 xpay-mx-1.5">
|
|
157
|
-
<ArrowRightIcon />
|
|
158
|
-
</div>
|
|
159
|
-
<div className="xpay-flex xpay-items-center">
|
|
160
|
-
{Number(receivedAmount) < 0.0001 ? "<0.0001" : receivedAmount}
|
|
161
|
-
<div className="xpay-ml-1">{tokenOutData?.symbol}</div>
|
|
162
|
-
|
|
163
|
-
{tokenOutData?.image ? (
|
|
164
|
-
<img
|
|
165
|
-
src={tokenOutData?.image}
|
|
166
|
-
alt={tokenOutData?.name || ""}
|
|
167
|
-
className="xpay-w-5 xpay-h-5 xpay-ml-1"
|
|
168
|
-
/>
|
|
169
|
-
) : (
|
|
170
|
-
<div className="xpay-flex xpay-items-center xpay-justify-center xpay-w-5 xpay-h-5 xpay-text-[10px] xpay-ml-1 xpay-rounded-full xpay-bg-[#272e40] xpay-text-[#e0e7fa]">
|
|
171
|
-
{tokenData?.symbol.substring(0, 1)}
|
|
172
|
-
</div>
|
|
173
|
-
)}
|
|
174
|
-
</div>
|
|
175
|
-
</>
|
|
176
|
-
)}
|
|
177
|
-
</div>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
);
|
|
182
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ChainlinkCCIPIcon, XSwapBadgeIcon } from "@src/components/icons";
|
|
2
|
-
|
|
3
|
-
export const PoweredBy = () => {
|
|
4
|
-
return (
|
|
5
|
-
<div className="xpay-flex xpay-justify-center xpay-items-center xpay-gap-2 xpay-my-3">
|
|
6
|
-
<span className="xpay-text-x_grey">Powered by</span>
|
|
7
|
-
<XSwapBadgeIcon />
|
|
8
|
-
<span>✕</span>
|
|
9
|
-
<ChainlinkCCIPIcon />
|
|
10
|
-
</div>
|
|
11
|
-
);
|
|
12
|
-
};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { CloseIcon, InfoIcon, PercentageIcon } from "../icons";
|
|
2
|
-
import { SLIPPAGE_PRESETS } from "@src/constants";
|
|
3
|
-
import { FC, useState, useEffect } from "react";
|
|
4
|
-
import { NUMBER_INPUT_REGEX } from "@src/constants";
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
slippage: string;
|
|
8
|
-
setSlippage: React.Dispatch<React.SetStateAction<string>>;
|
|
9
|
-
setSettingsShown: React.Dispatch<React.SetStateAction<boolean>>;
|
|
10
|
-
expressChecked: boolean;
|
|
11
|
-
setExpressChecked: React.Dispatch<React.SetStateAction<boolean>>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const Settings: FC<Props> = ({
|
|
15
|
-
setSlippage,
|
|
16
|
-
setSettingsShown,
|
|
17
|
-
slippage,
|
|
18
|
-
expressChecked,
|
|
19
|
-
setExpressChecked,
|
|
20
|
-
}) => {
|
|
21
|
-
const [slippageActivePresetIndex, setSlippageActivePresetIndex] = useState(1);
|
|
22
|
-
const [usingSlippageInput, setUsingSlippageInput] = useState(false);
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!usingSlippageInput) {
|
|
26
|
-
setSlippage(
|
|
27
|
-
SLIPPAGE_PRESETS[slippageActivePresetIndex]?.toString() || "1.5",
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}, [slippageActivePresetIndex, usingSlippageInput]);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div className="xpay-absolute xpay-w-[310px] xpay-right-0 xpay-top-[46px] xpay-z-10 xpay-bg-black xpay-border xpay-border-solid xpay-border-[rgba(54,129,198,1)] xpay-p-4 xpay-rounded-xl">
|
|
34
|
-
<div className="xpay-flex xpay-flex-col xpay-gap-4 xpay-justify-between">
|
|
35
|
-
<div className="xpay-flex xpay-justify-between">
|
|
36
|
-
<div className="xpay-text-base">Settings</div>
|
|
37
|
-
<div
|
|
38
|
-
className="xpay-cursor-pointer"
|
|
39
|
-
onClick={() => setSettingsShown(false)}
|
|
40
|
-
>
|
|
41
|
-
<CloseIcon />
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
<div>
|
|
45
|
-
<div className="xpay-flex xpay-gap-2 xpay-items-center">
|
|
46
|
-
<div className="xpay-text-sm xpay-text-[rgba(255,255,255,0.6)]">
|
|
47
|
-
Express delivery
|
|
48
|
-
</div>
|
|
49
|
-
<div>
|
|
50
|
-
<span
|
|
51
|
-
className="xpay-inline-flex xpay-w-14 xpay-h-9 xpay-p-3 xpay-relative xpay-align-middle xpay-box-border xpay-overflow-hidden xpay-cursor-pointer"
|
|
52
|
-
onClick={() => {
|
|
53
|
-
setExpressChecked((x) => !x);
|
|
54
|
-
}}
|
|
55
|
-
>
|
|
56
|
-
<span className="xpay-h-full, xpay-w-full xpay-rounded-lg xpay-bg-[rgba(255,255,255,0.3)]"></span>
|
|
57
|
-
<span
|
|
58
|
-
className={`xpay-transition-all xpay-w-5 xpay-h-5 xpay-rounded-full xpay-absolute xpay-translate-y-[-4px]
|
|
59
|
-
${
|
|
60
|
-
expressChecked
|
|
61
|
-
? "xpay-translate-x-[12px] xpay-bg-x_blue"
|
|
62
|
-
: "xpay-bg-white"
|
|
63
|
-
} `}
|
|
64
|
-
></span>
|
|
65
|
-
</span>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
<div className="xpay-flex xpay-gap-4">
|
|
69
|
-
<div className="xpay-min-w-[26px] xpay-min-h-[26px] xpay-text-[#ffa726]">
|
|
70
|
-
<InfoIcon />
|
|
71
|
-
</div>
|
|
72
|
-
<div className="xpay-text-xs xpay-text-left">
|
|
73
|
-
Express delivery is a special feature of XSwap that reduces
|
|
74
|
-
transaction time across chains to around 30 seconds. It is
|
|
75
|
-
currently available for swaps below a value of $ 1000 USD.
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
|
-
<div className="xpay-flex xpay-flex-col xpay-gap-2">
|
|
81
|
-
<div className="xpay-text-[rgba(255,255,255,0.6)] xpay-text-sm">
|
|
82
|
-
Slippage
|
|
83
|
-
</div>
|
|
84
|
-
<div className="xpay-flex xpay-gap-2">
|
|
85
|
-
<div className="xpay-flex xpay-items-center xpay-bg-[rgba(15,15,15,1)] p-1 xpay-global-border xpay-rounded-xl">
|
|
86
|
-
{SLIPPAGE_PRESETS.map((preset, index) => (
|
|
87
|
-
<div
|
|
88
|
-
key={index}
|
|
89
|
-
className={`xpay-transition-all xpay-cursor-pointer xpay-block xpay-rounded-lg xpay-p-2 xpay-border-none xpay-text-sm xpay-leading-[10px] ${
|
|
90
|
-
index === slippageActivePresetIndex && !usingSlippageInput
|
|
91
|
-
? "xpay-text-white"
|
|
92
|
-
: "xpay-text-[rgba(255,255,255,0.2)]"
|
|
93
|
-
} ${
|
|
94
|
-
index === slippageActivePresetIndex && !usingSlippageInput
|
|
95
|
-
? "xpay-bg-gradient-to-r xpay-from-[#3681c6] xpay-to-[#2b4a9d]"
|
|
96
|
-
: ""
|
|
97
|
-
}`}
|
|
98
|
-
onClick={() => {
|
|
99
|
-
setUsingSlippageInput(false);
|
|
100
|
-
setSlippageActivePresetIndex(index);
|
|
101
|
-
}}
|
|
102
|
-
>
|
|
103
|
-
{`${preset.toFixed(1)}%`}
|
|
104
|
-
</div>
|
|
105
|
-
))}
|
|
106
|
-
</div>
|
|
107
|
-
<div className="xpay-bg-[rgba(39,39,39,1)] xpay-p-2 xpay-border xpay-border-solid xpay-border-[rgba(82,82,82,1)] xpay-rounded-xl xpay-text-white xpay-flex xpay-items-center">
|
|
108
|
-
<input
|
|
109
|
-
className="xpay-text-white xpay-border-none xpay-bg-[rgba(39,39,39,1)] xpay-w-10 placeholder:xpay-text-[rgba(255,255,255,0.2)] focus:xpay-outline-none xpay-text-sm xpay-leading-none"
|
|
110
|
-
placeholder="1.5"
|
|
111
|
-
value={usingSlippageInput ? slippage : ""}
|
|
112
|
-
onChange={(e) => {
|
|
113
|
-
if (e.target.value.length > 0) {
|
|
114
|
-
if (NUMBER_INPUT_REGEX.test(e.target.value)) {
|
|
115
|
-
setUsingSlippageInput(true);
|
|
116
|
-
setSlippage(e.target.value.replace(/,/g, "."));
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
setUsingSlippageInput(false);
|
|
120
|
-
setSlippageActivePresetIndex(1);
|
|
121
|
-
}
|
|
122
|
-
}}
|
|
123
|
-
/>
|
|
124
|
-
<PercentageIcon />
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
<div className="xpay-flex xpay-gap-4">
|
|
128
|
-
<div className="xpay-min-w-[26px] xpay-min-h-[26px] xpay-text-[#ffa726]">
|
|
129
|
-
<InfoIcon />
|
|
130
|
-
</div>
|
|
131
|
-
<div className="xpay-text-xs xpay-text-left">
|
|
132
|
-
Slippage is the price variation you are willing to accept in the
|
|
133
|
-
event that the price of the trade changes while it is processing.
|
|
134
|
-
<br /> <br />
|
|
135
|
-
If the trade fails due to too-low slippage, you will receive USDC
|
|
136
|
-
on the destination chain.
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
);
|
|
143
|
-
};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { FC, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { weiToHumanReadable } from "@src/utils";
|
|
3
|
-
import { Chain, Route, Token, TokenPrices } from "@src/models";
|
|
4
|
-
import { ArrowDownIcon } from "../icons";
|
|
5
|
-
import { UsdPrice } from "@src/components/TxConfigForm/UsdPrice";
|
|
6
|
-
import { getPrices } from "@src/services";
|
|
7
|
-
import { Skeleton } from "@src/components";
|
|
8
|
-
import { UnknownTokenLogo } from "../UnknownTokenLogo/UnknownTokenLogo";
|
|
9
|
-
|
|
10
|
-
interface Props {
|
|
11
|
-
isGettingRoute: boolean;
|
|
12
|
-
route: Route | undefined;
|
|
13
|
-
dstToken: Token | undefined;
|
|
14
|
-
dstChain: Chain | undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const Summary: FC<Props> = ({
|
|
18
|
-
isGettingRoute,
|
|
19
|
-
route,
|
|
20
|
-
dstToken,
|
|
21
|
-
dstChain,
|
|
22
|
-
}) => {
|
|
23
|
-
const [prices, setPrices] = useState<TokenPrices>();
|
|
24
|
-
|
|
25
|
-
const amountReadable = useMemo(
|
|
26
|
-
() =>
|
|
27
|
-
weiToHumanReadable({
|
|
28
|
-
amount: route?.estAmountOut || "0",
|
|
29
|
-
decimals: dstToken?.decimals || 18,
|
|
30
|
-
precisionFractionalPlaces: 8,
|
|
31
|
-
}),
|
|
32
|
-
[route, dstToken],
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (dstChain) {
|
|
37
|
-
getPrices({ chainId: dstChain.chainId, currency: "USD" }).then((prices) =>
|
|
38
|
-
setPrices(prices),
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}, [dstChain]);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<div className="xpay-flex xpay-flex-col xpay-global-border xpay-rounded-lg xpay-bg-[rgba(15,15,15,1)] xpay-p-4 xpay-relative">
|
|
45
|
-
<div className="xpay-flex xpay-justify-between">
|
|
46
|
-
<div className="xpay-flex xpay-flex-col xpay-gap-1">
|
|
47
|
-
<p className="xpay-text-[rgba(255,255,255,0.6)] xpay-text-sm">
|
|
48
|
-
You receive
|
|
49
|
-
</p>
|
|
50
|
-
{isGettingRoute ? (
|
|
51
|
-
<Skeleton
|
|
52
|
-
width="xpay-w-[100px]"
|
|
53
|
-
height="xpay-h-[36px]"
|
|
54
|
-
other="sm:xpay-w-[190px]"
|
|
55
|
-
/>
|
|
56
|
-
) : (
|
|
57
|
-
<div className="xpay-flex xpay-gap-2 xpay-items-center xpay-text-white xpay-text-xl sm:xpay-text-3xl">
|
|
58
|
-
{amountReadable}
|
|
59
|
-
</div>
|
|
60
|
-
)}
|
|
61
|
-
</div>
|
|
62
|
-
<div className="xpay-flex xpay-flex-col xpay-items-end xpay-gap-1 xpay-text-sm">
|
|
63
|
-
<div className="xpay-flex xpay-justify-center xpay-items-center xpay-gap-1">
|
|
64
|
-
<div className="xpay-w-5 xpay-h-5">
|
|
65
|
-
{dstToken?.image ? (
|
|
66
|
-
<img
|
|
67
|
-
className="xpay-w-5 xpay-h-5"
|
|
68
|
-
src={dstToken?.image}
|
|
69
|
-
alt={dstToken?.name}
|
|
70
|
-
/>
|
|
71
|
-
) : (
|
|
72
|
-
<UnknownTokenLogo tokenName={"?"} />
|
|
73
|
-
)}
|
|
74
|
-
</div>
|
|
75
|
-
<p className="xpay-text-base sm:xpay-text-xl">{dstToken?.name}</p>
|
|
76
|
-
</div>
|
|
77
|
-
<div className="xpay-flex xpay-justify-center xpay-items-center xpay-gap-1">
|
|
78
|
-
<p className="xpay-text-[rgba(255,255,255,0.6)] xpay-text-right">
|
|
79
|
-
on{" "}
|
|
80
|
-
</p>
|
|
81
|
-
<div className="xpay-flex xpay-items-center xpay-gap-1 xpay-text-white">
|
|
82
|
-
<div className="xpay-w-4 xpay-h-4">
|
|
83
|
-
<img src={dstChain?.image} alt={dstChain?.name} />
|
|
84
|
-
</div>
|
|
85
|
-
<div>{dstChain?.displayName}</div>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
<div className="xpay-pt-2">
|
|
91
|
-
<UsdPrice
|
|
92
|
-
prices={prices}
|
|
93
|
-
token={dstToken}
|
|
94
|
-
amount={amountReadable}
|
|
95
|
-
loading={isGettingRoute}
|
|
96
|
-
/>
|
|
97
|
-
</div>
|
|
98
|
-
<div className="xpay-absolute xpay-right-[50%] xpay-top-0 xpay-translate-x-1/2 xpay-translate-y-[-60%] xpay-global-border xpay-rounded-xl p-[5px] xpay-bg-[rgba(15,15,15,1)]">
|
|
99
|
-
<div className="xpay-flex xpay-items-center xpay-justify-center xpay-rounded-lg xpay-w-8 xpay-h-8 xpay-bg-gradient-to-l xpay-from-[rgba(54,129,198,1)] xpay-to-[rgba(43,74,157,1)] ">
|
|
100
|
-
<ArrowDownIcon />
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { FC, useState, useEffect, useRef, useMemo } from "react";
|
|
2
|
-
import { NUMBER_INPUT_REGEX } from "@src/constants";
|
|
3
|
-
import { DownArrowIcon } from "../icons";
|
|
4
|
-
import { Token, Chain, TokenBalances, TokenPrices } from "@src/models";
|
|
5
|
-
import { TokenPicker } from "./TokenPicker";
|
|
6
|
-
import { weiToHumanReadable } from "@src/utils";
|
|
7
|
-
import { ChainListElement } from "./ChainListElement";
|
|
8
|
-
import { BalanceComponent } from "./BalanceComponent";
|
|
9
|
-
import { UsdPrice } from "@src/components/TxConfigForm/UsdPrice";
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
amount: string;
|
|
13
|
-
setAmount: React.Dispatch<React.SetStateAction<string>>;
|
|
14
|
-
srcToken: Token | undefined;
|
|
15
|
-
setSrcToken: React.Dispatch<React.SetStateAction<Token | undefined>>;
|
|
16
|
-
setSrcChain: React.Dispatch<React.SetStateAction<Chain | undefined>>;
|
|
17
|
-
srcChain: Chain | undefined;
|
|
18
|
-
signer: string | undefined;
|
|
19
|
-
balances: TokenBalances | undefined;
|
|
20
|
-
prices: TokenPrices | undefined;
|
|
21
|
-
supportedChains: Chain[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const SwapPanel: FC<Props> = ({
|
|
25
|
-
amount,
|
|
26
|
-
setAmount,
|
|
27
|
-
srcToken,
|
|
28
|
-
setSrcToken,
|
|
29
|
-
srcChain,
|
|
30
|
-
setSrcChain,
|
|
31
|
-
signer,
|
|
32
|
-
balances,
|
|
33
|
-
prices,
|
|
34
|
-
supportedChains,
|
|
35
|
-
}) => {
|
|
36
|
-
const [chainListShown, setChainListShown] = useState(false);
|
|
37
|
-
const [tokenListShown, setTokenListShown] = useState(false);
|
|
38
|
-
const listRef = useRef(null);
|
|
39
|
-
const buttonRef = useRef(null);
|
|
40
|
-
|
|
41
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
42
|
-
if (listRef.current && buttonRef.current) {
|
|
43
|
-
const listElement = listRef.current as HTMLElement;
|
|
44
|
-
const buttonElement = buttonRef.current as HTMLElement;
|
|
45
|
-
if (
|
|
46
|
-
!listElement.contains(event.target as Node) &&
|
|
47
|
-
!buttonElement.contains(event.target as Node)
|
|
48
|
-
)
|
|
49
|
-
setChainListShown(false);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const handleMaxClick = () => {
|
|
54
|
-
if (
|
|
55
|
-
balances &&
|
|
56
|
-
srcToken &&
|
|
57
|
-
balances[srcToken.address] &&
|
|
58
|
-
balances[srcToken.address]?.toString() !== "0"
|
|
59
|
-
)
|
|
60
|
-
setAmount(
|
|
61
|
-
weiToHumanReadable({
|
|
62
|
-
amount: balances[srcToken.address]?.toString() || "0",
|
|
63
|
-
decimals: srcToken.decimals,
|
|
64
|
-
precisionFractionalPlaces: srcToken.decimals,
|
|
65
|
-
}),
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (chainListShown) {
|
|
71
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
72
|
-
return () =>
|
|
73
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
74
|
-
}
|
|
75
|
-
}, [chainListShown]);
|
|
76
|
-
|
|
77
|
-
const chainListOptions = useMemo(
|
|
78
|
-
() =>
|
|
79
|
-
supportedChains.filter((chain) => chain.chainId !== srcChain?.chainId),
|
|
80
|
-
[supportedChains, srcChain],
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<div className="xpay-flex xpay-justify-between xpay-global-border xpay-rounded-lg xpay-bg-[rgba(15,15,15,1)] xpay-p-4">
|
|
85
|
-
<div className="xpay-flex xpay-flex-col xpay-justify-between xpay-gap-2 xpay-overflow-hidden xpay-w-1/2">
|
|
86
|
-
<div className="xpay-flex xpay-flex-col xpay-gap-1">
|
|
87
|
-
<p className="xpay-text-white xpay-opacity-60 xpay-text-xs sm:xpay-text-sm xpay-font-medium">
|
|
88
|
-
You pay
|
|
89
|
-
</p>
|
|
90
|
-
<input
|
|
91
|
-
className="xpay-p-0 xpay-border-none xpay-outline-none xpay-bg-transparent xpay-text-2xl xpay-overflow-ellipsis"
|
|
92
|
-
value={amount}
|
|
93
|
-
onChange={(e) => {
|
|
94
|
-
if (e.target.value === ".") return;
|
|
95
|
-
if (NUMBER_INPUT_REGEX.test(e.target.value)) {
|
|
96
|
-
setAmount(e.target.value.replace(/,/g, "."));
|
|
97
|
-
}
|
|
98
|
-
}}
|
|
99
|
-
inputMode="decimal"
|
|
100
|
-
spellCheck="false"
|
|
101
|
-
autoComplete="off"
|
|
102
|
-
autoCorrect="off"
|
|
103
|
-
placeholder="0"
|
|
104
|
-
/>
|
|
105
|
-
</div>
|
|
106
|
-
<div className="xpay-flex xpay-items-center xpay-text-sm xpay-text-[rgba(255,255,255,0.6)]">
|
|
107
|
-
<UsdPrice
|
|
108
|
-
prices={prices}
|
|
109
|
-
token={srcToken}
|
|
110
|
-
amount={amount}
|
|
111
|
-
loading={false}
|
|
112
|
-
/>
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
<div className="xpay-flex xpay-flex-col xpay-relative xpay-items-end xpay-gap-2.5 xpay-w-1/2 xpay-text-xs">
|
|
116
|
-
<div
|
|
117
|
-
className="xpay-flex xpay-gap-2 xpay-items-center xpay-p-2 xpay-max-w-full xpay-cursor-pointer xpay-bg-black xpay-text-white xpay-global-border xpay-rounded-3xl xpay-whitespace-nowrap"
|
|
118
|
-
onClick={() => {
|
|
119
|
-
setTokenListShown((state) => !state);
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
122
|
-
<img
|
|
123
|
-
height={16}
|
|
124
|
-
width={16}
|
|
125
|
-
src={srcToken?.image}
|
|
126
|
-
alt={srcToken?.name}
|
|
127
|
-
/>
|
|
128
|
-
<div>{srcToken?.symbol}</div>
|
|
129
|
-
<DownArrowIcon />
|
|
130
|
-
</div>
|
|
131
|
-
|
|
132
|
-
{tokenListShown && (
|
|
133
|
-
<TokenPicker
|
|
134
|
-
onCloseClick={() => setTokenListShown(false)}
|
|
135
|
-
tokens={srcChain?.tokens}
|
|
136
|
-
signer={signer}
|
|
137
|
-
selectedToken={srcToken}
|
|
138
|
-
setSelectedToken={(token) => setSrcToken(token)}
|
|
139
|
-
balances={balances}
|
|
140
|
-
/>
|
|
141
|
-
)}
|
|
142
|
-
<div
|
|
143
|
-
onClick={handleMaxClick}
|
|
144
|
-
className="xpay-flex xpay-gap-1 xpay-items-center xpay-font-medium xpay-text-white xpay-opacity-60 xpay-py-0.5 xpay-cursor-pointer"
|
|
145
|
-
>
|
|
146
|
-
{signer && (
|
|
147
|
-
<BalanceComponent balances={balances} srcToken={srcToken} />
|
|
148
|
-
)}
|
|
149
|
-
</div>
|
|
150
|
-
<div
|
|
151
|
-
ref={buttonRef}
|
|
152
|
-
className="xpay-bg-black xpay-global-border xpay-rounded-2xl xpay-whitespace-nowrap xpay-flex xpay-items-center xpay-p-2 xpay-cursor-pointer xpay-gap-2"
|
|
153
|
-
onClick={() => setChainListShown((prev) => !prev)}
|
|
154
|
-
>
|
|
155
|
-
<img
|
|
156
|
-
width="16"
|
|
157
|
-
height="16"
|
|
158
|
-
src={srcChain?.image}
|
|
159
|
-
alt={srcChain?.name}
|
|
160
|
-
/>
|
|
161
|
-
<div>{srcChain?.displayName}</div>
|
|
162
|
-
<DownArrowIcon />
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
{chainListShown && (
|
|
166
|
-
<ul
|
|
167
|
-
ref={listRef}
|
|
168
|
-
className="xpay-bg-black xpay-global-border xpay-rounded-lg xpay-whitespace-nowrap xpay-z-1 xpay-right-0 xpay-top-10 xpay-px-2 xpay-max-w-full xpay-max-h-[40vh] xpay-overflow-auto xpay-absolute xpay-text-sm xpay-z-20"
|
|
169
|
-
>
|
|
170
|
-
{chainListOptions.map((chain, index) => (
|
|
171
|
-
<ChainListElement
|
|
172
|
-
index={index}
|
|
173
|
-
length={supportedChains.length}
|
|
174
|
-
setSrcChain={setSrcChain}
|
|
175
|
-
setChainListShown={setChainListShown}
|
|
176
|
-
chain={chain}
|
|
177
|
-
key={chain.chainId}
|
|
178
|
-
/>
|
|
179
|
-
))}
|
|
180
|
-
</ul>
|
|
181
|
-
)}
|
|
182
|
-
</div>
|
|
183
|
-
</div>
|
|
184
|
-
);
|
|
185
|
-
};
|