@xswap-link/sdk 0.10.5 → 0.10.6
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 +6 -0
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.global.js +4866 -224
- package/dist/index.js +9 -9
- package/dist/index.mjs +8 -8
- package/package.json +2 -2
- package/src/assets/icons/StarsIcon.tsx +18 -0
- package/src/assets/icons/index.ts +1 -0
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +20 -2
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +1 -0
- package/src/components/TxConfigForm/index.tsx +3 -0
- package/src/components/TxWidgetWC/index.tsx +4 -0
- package/src/components/TxWidgetWCWrapped/index.tsx +2 -0
- package/src/models/payloads/ModalIntegrationPayload.ts +1 -0
- package/src/models/payloads/WidgetIntegrationPayload.ts +1 -0
- package/src/services/integrations/transactions.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xswap-link/sdk",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6",
|
|
4
4
|
"description": "JavaScript SDK for XSwap platform",
|
|
5
5
|
"homepage": "https://github.com/xswap-link/xswap-sdk",
|
|
6
6
|
"repository": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"notistack": "^3.0.1",
|
|
46
46
|
"react-error-boundary": "^4.1.0",
|
|
47
47
|
"react-virtuoso": "^4.7.12",
|
|
48
|
-
"viem": "~2.
|
|
48
|
+
"viem": "~2.29.1",
|
|
49
49
|
"wagmi": "^2.14.9"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const StarsIcon = () => {
|
|
2
|
+
return (
|
|
3
|
+
<svg
|
|
4
|
+
width="16"
|
|
5
|
+
height="16"
|
|
6
|
+
viewBox="0 0 16 16"
|
|
7
|
+
fill="none"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
>
|
|
10
|
+
<path
|
|
11
|
+
fill-rule="evenodd"
|
|
12
|
+
clip-rule="evenodd"
|
|
13
|
+
d="M5.89761 2.45159L5.12155 4.38335C4.92404 4.875 4.56316 5.26745 4.11108 5.48225L2.33478 6.32623L4.11108 7.17021C4.56316 7.38501 4.92404 7.77746 5.12155 8.26911L5.89761 10.2009L6.67367 8.26911C6.87118 7.77746 7.23206 7.38501 7.68414 7.17021L9.46044 6.32623L7.68414 5.48225C7.23206 5.26745 6.87118 4.875 6.67367 4.38335L5.89761 2.45159ZM11.6352 7.3349C11.4478 7.35272 11.2681 7.47472 11.1863 7.70089L10.5417 9.48369C10.4927 9.61935 10.3985 9.72999 10.2779 9.79365L8.66756 10.6438C8.26644 10.8556 8.26644 11.477 8.66756 11.6888L10.2779 12.539C10.3985 12.6026 10.4927 12.7133 10.5417 12.8489L11.1863 14.6317C11.3639 15.1228 12.0028 15.1228 12.1804 14.6317L12.825 12.8489C12.874 12.7133 12.9682 12.6026 13.0888 12.539L14.6992 11.6888C15.1003 11.477 15.1003 10.8556 14.6992 10.6438L13.0888 9.79365C12.9682 9.72999 12.874 9.61935 12.825 9.48369L12.1804 7.70089C12.0846 7.43603 11.8546 7.31403 11.6352 7.3349ZM8.11177 8.23467C7.90628 8.33231 7.74225 8.51069 7.65247 8.73417L6.71328 11.072C6.40235 11.8459 5.39287 11.846 5.08194 11.072L4.14275 8.73417C4.05297 8.51069 3.88894 8.33231 3.68344 8.23467L1.53375 7.21328C0.822083 6.87514 0.822082 5.77732 1.53375 5.43918L3.68344 4.41779C3.88894 4.32015 4.05297 4.14177 4.14275 3.91829L5.08194 1.58047C5.39287 0.806512 6.40235 0.806511 6.71328 1.58047L7.65247 3.91829C7.74225 4.14177 7.90628 4.32015 8.11177 4.41779L10.2615 5.43918C10.6624 5.6297 10.8375 6.06138 10.7866 6.46247C10.7472 6.77325 10.5722 7.06566 10.2615 7.21328L8.11177 8.23467ZM11.6834 9.50062L11.5358 9.90876C11.3886 10.3157 11.1062 10.6477 10.7444 10.8386L10.1237 11.1663L10.7444 11.494C11.1062 11.6849 11.3886 12.0169 11.5358 12.4239L11.6834 12.832L11.8309 12.4239C11.9781 12.0169 12.2606 11.6849 12.6223 11.494L13.243 11.1663L12.6223 10.8386C12.2606 10.6477 11.9781 10.3157 11.8309 9.90876L11.6834 9.50062Z"
|
|
14
|
+
fill="white"
|
|
15
|
+
></path>
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { StarsIcon } from "@src/assets/icons";
|
|
1
2
|
import { Skeleton, TokenLogoWithChain } from "@src/components";
|
|
3
|
+
import { SwapPanelType } from "@src/components/Swap/SwapView";
|
|
2
4
|
import { useSwapContext } from "@src/context";
|
|
3
5
|
import { TokenOption } from "@src/models";
|
|
4
6
|
import { weiToHumanReadable } from "@src/utils";
|
|
@@ -11,14 +13,21 @@ type Props = {
|
|
|
11
13
|
selectedTokenAddress: string | undefined;
|
|
12
14
|
selectedChainId: string | undefined;
|
|
13
15
|
onClick: () => void;
|
|
16
|
+
panelType: SwapPanelType;
|
|
14
17
|
};
|
|
15
18
|
export const TokenItem = ({
|
|
16
19
|
token,
|
|
17
20
|
selectedTokenAddress,
|
|
18
21
|
onClick,
|
|
19
22
|
selectedChainId,
|
|
23
|
+
panelType,
|
|
20
24
|
}: Props) => {
|
|
21
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
supportedChains,
|
|
27
|
+
tokenPrices,
|
|
28
|
+
isFetchingBalances,
|
|
29
|
+
integrationConfig,
|
|
30
|
+
} = useSwapContext();
|
|
22
31
|
const { address } = useAccount();
|
|
23
32
|
|
|
24
33
|
const chain = useMemo(
|
|
@@ -66,8 +75,17 @@ export const TokenItem = ({
|
|
|
66
75
|
/>
|
|
67
76
|
<div className="flex justify-between items-center gap-1 w-full">
|
|
68
77
|
<div className="text-left">
|
|
69
|
-
<div className="text-sm font-medium text-ellipsis text-t_text_primary">
|
|
78
|
+
<div className="text-sm font-medium text-ellipsis text-t_text_primary flex items-center gap-1">
|
|
70
79
|
{token.name}
|
|
80
|
+
{integrationConfig?.highlightedDstTokens?.includes(token.symbol) &&
|
|
81
|
+
panelType === "destination" && (
|
|
82
|
+
<div
|
|
83
|
+
className={`flex items-center justify-center text-white rounded-full border-t_bg_secondary ${"w-3.5 h-3.5 text-xs"}`}
|
|
84
|
+
title="AI-powered token"
|
|
85
|
+
>
|
|
86
|
+
<StarsIcon />
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
71
89
|
</div>
|
|
72
90
|
<div className="text-xs text-t_text_primary text-opacity-50 font-medium">
|
|
73
91
|
{token.symbol}
|
|
@@ -27,6 +27,7 @@ export type TxConfigFormPayload = Omit<
|
|
|
27
27
|
supportedChains: Chain[];
|
|
28
28
|
integratorFee?: number;
|
|
29
29
|
integratorFeeReceiverAddress?: string;
|
|
30
|
+
highlightedDstTokens?: string[];
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
type TxConfigFormProps = TxConfigFormPayload &
|
|
@@ -131,6 +132,7 @@ export const TxConfigForm = (props: TxConfigFormProps) => {
|
|
|
131
132
|
override,
|
|
132
133
|
integratorFee,
|
|
133
134
|
integratorFeeReceiverAddress,
|
|
135
|
+
highlightedDstTokens,
|
|
134
136
|
} = normalizedProps;
|
|
135
137
|
|
|
136
138
|
const onBackdropClick = (e: MouseEvent) => {
|
|
@@ -193,6 +195,7 @@ export const TxConfigForm = (props: TxConfigFormProps) => {
|
|
|
193
195
|
onConnectWallet,
|
|
194
196
|
integratorFee,
|
|
195
197
|
integratorFeeReceiverAddress,
|
|
198
|
+
highlightedDstTokens,
|
|
196
199
|
}}
|
|
197
200
|
supportedChains={supportedChains}
|
|
198
201
|
wagmiConfig={wagmiConfig}
|
|
@@ -39,6 +39,7 @@ const TxWidget = ({
|
|
|
39
39
|
override,
|
|
40
40
|
integratorFee,
|
|
41
41
|
integratorFeeReceiverAddress,
|
|
42
|
+
highlightedDstTokens,
|
|
42
43
|
}: WidgetIntegrationPayload) => {
|
|
43
44
|
const [loading, setLoading] = useState(true);
|
|
44
45
|
const [supportedChains, setSupportedChains] = useState<Chain[]>([]);
|
|
@@ -112,6 +113,7 @@ const TxWidget = ({
|
|
|
112
113
|
override={override}
|
|
113
114
|
integratorFee={integratorFee}
|
|
114
115
|
integratorFeeReceiverAddress={integratorFeeReceiverAddress}
|
|
116
|
+
highlightedDstTokens={highlightedDstTokens}
|
|
115
117
|
/>
|
|
116
118
|
)}
|
|
117
119
|
</>
|
|
@@ -158,6 +160,7 @@ export const createTxWidgetWC = () => {
|
|
|
158
160
|
override: "json",
|
|
159
161
|
integratorFee: "number",
|
|
160
162
|
integratorFeeReceiverAddress: "string",
|
|
163
|
+
highlightedDstTokens: "json",
|
|
161
164
|
},
|
|
162
165
|
});
|
|
163
166
|
|
|
@@ -198,4 +201,5 @@ export type TxWidgetWCAttributes = {
|
|
|
198
201
|
"integrator-fee-receiver-address":
|
|
199
202
|
| WidgetIntegrationPayload["integratorFeeReceiverAddress"]
|
|
200
203
|
| undefined;
|
|
204
|
+
"highlighted-dst-tokens": string | undefined;
|
|
201
205
|
};
|
|
@@ -50,6 +50,7 @@ export const TxWidgetWCWrapped = ({
|
|
|
50
50
|
override,
|
|
51
51
|
integratorFee,
|
|
52
52
|
integratorFeeReceiverAddress,
|
|
53
|
+
highlightedDstTokens,
|
|
53
54
|
}: WidgetIntegrationPayload) => {
|
|
54
55
|
useEffect(() => {
|
|
55
56
|
// We couldn't find a way to pass a function to the web component created by @r2wc/core.
|
|
@@ -90,6 +91,7 @@ export const TxWidgetWCWrapped = ({
|
|
|
90
91
|
override={JSON.stringify(override)}
|
|
91
92
|
integrator-fee={integratorFee}
|
|
92
93
|
integrator-fee-receiver-address={integratorFeeReceiverAddress}
|
|
94
|
+
highlighted-dst-tokens={JSON.stringify(highlightedDstTokens)}
|
|
93
95
|
></xpay-widget>
|
|
94
96
|
);
|
|
95
97
|
};
|
|
@@ -25,6 +25,7 @@ export const openTransactionModal = async ({
|
|
|
25
25
|
onSrcTokenChange,
|
|
26
26
|
onSrcChainChange,
|
|
27
27
|
bridge,
|
|
28
|
+
highlightedDstTokens,
|
|
28
29
|
}: ModalIntegrationPayload) => {
|
|
29
30
|
const supportedChains: Chain[] = (await getChains()).filter(
|
|
30
31
|
({ web3Environment, swapSupported }) =>
|
|
@@ -63,6 +64,7 @@ export const openTransactionModal = async ({
|
|
|
63
64
|
onSrcTokenChange,
|
|
64
65
|
onSrcChainChange,
|
|
65
66
|
bridge,
|
|
67
|
+
highlightedDstTokens,
|
|
66
68
|
});
|
|
67
69
|
};
|
|
68
70
|
|