@xswap-link/sdk 0.13.1 → 0.14.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/CHANGELOG.md +22 -0
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.global.js +87 -86
- package/dist/index.js +2888 -2521
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2828 -2458
- package/dist/index.mjs.map +1 -1
- package/localTheme.ts +5 -3
- package/package.json +1 -1
- package/src/assets/icons/AdjustmentsIcon.tsx +16 -0
- package/src/assets/icons/CaretDownIcon.tsx +12 -0
- package/src/assets/icons/CaretsUpDownIcon.tsx +13 -0
- package/src/assets/icons/ChainlinkMarkIcon.tsx +17 -0
- package/src/assets/icons/ClockIcon.tsx +14 -0
- package/src/assets/icons/CloseIcon.tsx +6 -2
- package/src/assets/icons/WarningIcon.tsx +19 -0
- package/src/assets/icons/index.ts +6 -0
- package/src/components/Modal/index.tsx +14 -9
- package/src/components/PoweredBy/index.tsx +12 -5
- package/src/components/Swap/Header/Controls/index.tsx +50 -36
- package/src/components/Swap/Header/index.tsx +12 -5
- package/src/components/Swap/HistoryView/ActivityCard/index.tsx +212 -0
- package/src/components/Swap/HistoryView/index.tsx +24 -6
- package/src/components/Swap/PickerView/index.tsx +151 -0
- package/src/components/Swap/ReorderButton/ReorderButton.tsx +5 -7
- package/src/components/Swap/SettingsView/Delivery/index.tsx +27 -28
- package/src/components/Swap/SettingsView/InfiniteApproval/index.tsx +27 -24
- package/src/components/Swap/SettingsView/Slippage/index.tsx +44 -43
- package/src/components/Swap/SettingsView/index.tsx +1 -1
- package/src/components/Swap/SwapView/ConfirmationView/TxOverview/index.tsx +50 -4
- package/src/components/Swap/SwapView/FeesPanel/DeliveryInfo/index.tsx +9 -19
- package/src/components/Swap/SwapView/FeesPanel/Fee/index.tsx +4 -4
- package/src/components/Swap/SwapView/FeesPanel/Fees/index.tsx +5 -9
- package/src/components/Swap/SwapView/FeesPanel/index.tsx +21 -22
- package/src/components/Swap/SwapView/SwapButton/index.tsx +25 -6
- package/src/components/Swap/SwapView/SwapPanel/AmountPanel/Balance/index.tsx +56 -12
- package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +42 -41
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/ChainPicker/index.tsx +143 -0
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/NetworkFilter/index.tsx +159 -0
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +105 -55
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +226 -276
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +57 -97
- package/src/components/Swap/SwapView/SwapPanel/UsdValue/index.tsx +27 -0
- package/src/components/Swap/SwapView/SwapPanel/WalletPanel/index.tsx +60 -49
- package/src/components/Swap/SwapView/SwapPanel/index.tsx +20 -25
- package/src/components/Swap/SwapView/WalletPicker/index.tsx +6 -1
- package/src/components/Swap/SwapView/index.tsx +2 -1
- package/src/components/Swap/index.tsx +20 -4
- package/src/components/ToggleButton/index.tsx +18 -15
- package/src/components/TxConfigForm/index.tsx +5 -5
- package/src/components/TxWidgetWC/index.tsx +4 -0
- package/src/components/TxWidgetWCWrapped/index.tsx +2 -0
- package/src/context/HistoryProvider.tsx +2 -1
- package/src/context/SwapProvider.tsx +87 -62
- package/src/context/TxUIWrapper.tsx +3 -3
- package/src/hooks/useEvmContractApi.ts +28 -4
- package/src/models/TransactionHistory.ts +1 -0
- package/src/models/payloads/GetBalancesPayload.ts +1 -0
- package/src/models/payloads/ModalIntegrationPayload.ts +1 -0
- package/src/models/payloads/WidgetIntegrationPayload.ts +1 -0
- package/src/services/api.ts +37 -0
- package/src/utils/index.ts +48 -1
- package/src/utils/tokens.ts +20 -1
- package/tailwind.config.js +4 -1
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/ChainItem/index.tsx +0 -97
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/index.tsx +0 -103
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/index.tsx +0 -65
- package/src/components/Swap/SwapView/SwapPanel/MaxPanel/index.tsx +0 -43
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/QuickPickTokenItem/index.tsx +0 -37
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { StarsIcon } from "@src/assets/icons";
|
|
1
|
+
import { StarsIcon, WarningIcon } from "@src/assets/icons";
|
|
2
2
|
import { Skeleton, TokenLogoWithChain } from "@src/components";
|
|
3
3
|
import { SwapPanelType } from "@src/components/Swap/SwapView";
|
|
4
4
|
import { useSwapContext } from "@src/context";
|
|
5
5
|
import { TokenOption } from "@src/models";
|
|
6
|
-
import { weiToHumanReadable } from "@src/utils";
|
|
6
|
+
import { shortAddress, weiToHumanReadable } from "@src/utils";
|
|
7
7
|
import { ethers } from "ethers";
|
|
8
8
|
import { useMemo } from "react";
|
|
9
9
|
import { useAccount } from "wagmi";
|
|
@@ -14,6 +14,11 @@ type Props = {
|
|
|
14
14
|
selectedChainId: string | undefined;
|
|
15
15
|
onClick: () => void;
|
|
16
16
|
panelType: SwapPanelType;
|
|
17
|
+
/**
|
|
18
|
+
* When picking this token would disconnect the other side of the swap,
|
|
19
|
+
* names the side that will be reset ("source" | "destination").
|
|
20
|
+
*/
|
|
21
|
+
resetWarning?: SwapPanelType | null;
|
|
17
22
|
};
|
|
18
23
|
export const TokenItem = ({
|
|
19
24
|
token,
|
|
@@ -21,6 +26,7 @@ export const TokenItem = ({
|
|
|
21
26
|
onClick,
|
|
22
27
|
selectedChainId,
|
|
23
28
|
panelType,
|
|
29
|
+
resetWarning,
|
|
24
30
|
}: Props) => {
|
|
25
31
|
const {
|
|
26
32
|
supportedChains,
|
|
@@ -55,66 +61,110 @@ export const TokenItem = ({
|
|
|
55
61
|
return tokenBalance * +tokenPrice;
|
|
56
62
|
}, [tokenBalance, tokenPrice, hasBalance]);
|
|
57
63
|
|
|
64
|
+
const isSelected =
|
|
65
|
+
token.address.toLowerCase() === selectedTokenAddress?.toLowerCase() &&
|
|
66
|
+
selectedChainId &&
|
|
67
|
+
token.chainId === selectedChainId;
|
|
68
|
+
|
|
58
69
|
return (
|
|
59
|
-
<div
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
<div className="pb-2">
|
|
71
|
+
<div
|
|
72
|
+
className={`flex gap-3 items-center p-3 sm:p-4 rounded-xl cursor-pointer bg-gradient-to-r from-t_bg_tertiary/[0.02] to-t_bg_tertiary/[0.02] bg-[rgba(40,40,40,0.15)] hover:bg-t_bg_tertiary hover:bg-opacity-10 transition-colors ${
|
|
73
|
+
isSelected ? "!bg-t_bg_tertiary !bg-opacity-10" : ""
|
|
74
|
+
}`}
|
|
75
|
+
onClick={onClick}
|
|
76
|
+
>
|
|
77
|
+
<div className={`shrink-0 ${resetWarning ? "opacity-40" : ""}`}>
|
|
78
|
+
<TokenLogoWithChain
|
|
79
|
+
token={token}
|
|
80
|
+
chain={chain}
|
|
81
|
+
tokenLogoClassName="min-w-10 w-10 h-10"
|
|
82
|
+
generatedLogoClassName="min-w-10 w-10 h-10 text-[16px]"
|
|
83
|
+
chainLogoClassName="w-[18px]"
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
<div className="flex justify-between items-center gap-2 w-full min-w-0">
|
|
87
|
+
<div
|
|
88
|
+
className={`text-left min-w-0 ${resetWarning ? "opacity-40" : ""}`}
|
|
89
|
+
>
|
|
90
|
+
<div className="text-sm font-medium leading-5 tracking-[0.01em] text-t_text_primary flex items-center gap-1">
|
|
91
|
+
{token.symbol}
|
|
92
|
+
{integrationConfig?.highlightedDstTokens?.includes(
|
|
93
|
+
token.symbol,
|
|
94
|
+
) &&
|
|
95
|
+
panelType === "destination" && (
|
|
96
|
+
<div
|
|
97
|
+
className="flex items-center justify-center text-t_text_primary rounded-full w-3.5 h-3.5 text-xs"
|
|
98
|
+
title="AI-powered token"
|
|
99
|
+
>
|
|
100
|
+
<StarsIcon />
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
<div className="flex gap-2 items-center text-xs leading-[18px] tracking-[0.01em] text-t_text_primary text-opacity-50">
|
|
105
|
+
<span className="whitespace-nowrap">
|
|
106
|
+
{chain?.displayName || token.name}
|
|
107
|
+
</span>
|
|
108
|
+
{!resetWarning && (
|
|
109
|
+
<>
|
|
110
|
+
<span className="w-0.5 h-0.5 bg-t_text_primary opacity-25 shrink-0" />
|
|
111
|
+
<span className="whitespace-nowrap hidden sm:block">
|
|
112
|
+
{shortAddress(token.address)}
|
|
113
|
+
</span>
|
|
114
|
+
</>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div className="text-right shrink-0">
|
|
120
|
+
{address && isFetchingBalances ? (
|
|
121
|
+
<Skeleton className="w-[48px] h-[12px]" />
|
|
122
|
+
) : (
|
|
123
|
+
token.balance &&
|
|
124
|
+
token.decimals &&
|
|
125
|
+
address && (
|
|
82
126
|
<div
|
|
83
|
-
className={`
|
|
84
|
-
|
|
127
|
+
className={`text-sm font-medium leading-5 tracking-[0.01em] text-t_text_primary ${
|
|
128
|
+
resetWarning ? "opacity-40" : ""
|
|
129
|
+
}`}
|
|
85
130
|
>
|
|
86
|
-
|
|
131
|
+
{token.balance.eq(0) || tokenBalance! > 0.0001
|
|
132
|
+
? weiToHumanReadable({
|
|
133
|
+
amount: token.balance.toString(),
|
|
134
|
+
decimals: token.decimals,
|
|
135
|
+
precisionFractionalPlaces: 4,
|
|
136
|
+
})
|
|
137
|
+
: "<0.0001"}
|
|
87
138
|
</div>
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{hasBalance && (
|
|
106
|
-
<div className="text-xs text-t_text_primary text-opacity-50">
|
|
107
|
-
{tokenValueUsd ? `$${tokenValueUsd.toFixed(2)}` : "$ -"}
|
|
139
|
+
)
|
|
140
|
+
)}
|
|
141
|
+
{resetWarning ? (
|
|
142
|
+
<div className="flex items-center justify-end gap-1.5 text-[#D77F02]">
|
|
143
|
+
<WarningIcon className="w-3.5 h-3.5 shrink-0" />
|
|
144
|
+
<span className="text-xs leading-[18px] tracking-[0.01em] whitespace-nowrap">
|
|
145
|
+
<span className="sm:hidden">
|
|
146
|
+
{resetWarning === "source"
|
|
147
|
+
? "Source will reset."
|
|
148
|
+
: "Destination will reset."}
|
|
149
|
+
</span>
|
|
150
|
+
<span className="hidden sm:inline">
|
|
151
|
+
{resetWarning === "source"
|
|
152
|
+
? "Source will reset after selection."
|
|
153
|
+
: "Destination will reset after selection."}
|
|
154
|
+
</span>
|
|
155
|
+
</span>
|
|
108
156
|
</div>
|
|
157
|
+
) : (
|
|
158
|
+
!isFetchingBalances &&
|
|
159
|
+
hasBalance &&
|
|
160
|
+
address && (
|
|
161
|
+
<div className="text-xs leading-[18px] tracking-[0.01em] text-t_text_primary text-opacity-50">
|
|
162
|
+
{tokenValueUsd ? `${tokenValueUsd.toFixed(2)} USD` : "-"}
|
|
163
|
+
</div>
|
|
164
|
+
)
|
|
109
165
|
)}
|
|
110
166
|
</div>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
{address && isFetchingBalances && (
|
|
114
|
-
<div>
|
|
115
|
-
<Skeleton className="w-[48px] h-[12px]" />
|
|
116
|
-
</div>
|
|
117
|
-
)}
|
|
167
|
+
</div>
|
|
118
168
|
</div>
|
|
119
169
|
</div>
|
|
120
170
|
);
|