@xswap-link/sdk 0.8.1 → 0.8.3
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 +12 -0
- package/dist/index.global.js +111 -110
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/package.json +1 -1
- package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +6 -2
- package/src/components/TxConfigForm/index.tsx +2 -2
- package/src/components/TxWidgetWC/index.tsx +3 -2
- package/src/context/SwapProvider.tsx +20 -10
- package/src/contracts/addresses.ts +7 -0
- package/tailwind.config.js +51 -28
package/package.json
CHANGED
|
@@ -36,7 +36,9 @@ export const AmountPanel = ({ type }: Props) => {
|
|
|
36
36
|
value={srcValue}
|
|
37
37
|
onChange={(value) => setSrcValue(value)}
|
|
38
38
|
/>
|
|
39
|
-
|
|
39
|
+
{valueUsd && (
|
|
40
|
+
<div className={`text-sx opacity-60`}>{`$${valueUsd}`}</div>
|
|
41
|
+
)}
|
|
40
42
|
</>
|
|
41
43
|
) : isFetchingRoute ? (
|
|
42
44
|
<div className="flex flex-col gap-1">
|
|
@@ -48,7 +50,9 @@ export const AmountPanel = ({ type }: Props) => {
|
|
|
48
50
|
<div className={`text-xl text-t_text_secondary`}>
|
|
49
51
|
{dstValue || 0}
|
|
50
52
|
</div>
|
|
51
|
-
|
|
53
|
+
{valueUsd && (
|
|
54
|
+
<div className={`text-sx opacity-60`}>{`$${valueUsd}`}</div>
|
|
55
|
+
)}
|
|
52
56
|
</>
|
|
53
57
|
)}
|
|
54
58
|
</div>
|
|
@@ -168,13 +168,13 @@ export const TxConfigForm = ({
|
|
|
168
168
|
className="top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex flex-col items-center justify-center z-10"
|
|
169
169
|
onMouseDown={onBackdropClick}
|
|
170
170
|
>
|
|
171
|
-
<div className="relative bg-t_bg_primary rounded-3xl overflow-auto text-t_text_primary border-2 border-solid border-[rgba(255,255,255,0.1)] min-w-x_modal max-w-x_modal min-h-[532px]
|
|
171
|
+
<div className="relative bg-t_bg_primary rounded-3xl overflow-auto text-t_text_primary border-2 border-solid border-[rgba(255,255,255,0.1)] w-x_modal min-w-x_modal max-w-x_modal min-h-[532px]">
|
|
172
172
|
<Swap onSubmit={onSubmit} onClose={onClose} />
|
|
173
173
|
<PoweredBy />
|
|
174
174
|
</div>
|
|
175
175
|
</div>
|
|
176
176
|
) : (
|
|
177
|
-
<div className="bg-t_bg_primary rounded-3xl overflow-auto text-t_text_primary border-2 border-solid border-[rgba(255,255,255,0.1)] min-h-[532px] w-
|
|
177
|
+
<div className="bg-t_bg_primary rounded-3xl overflow-auto text-t_text_primary border-2 border-solid border-[rgba(255,255,255,0.1)] min-h-[532px] w-x_modal min-w-x_modal max-w-x_modal flex flex-col">
|
|
178
178
|
<Swap onSubmit={() => {}} onClose={() => {}} />
|
|
179
179
|
<PoweredBy />
|
|
180
180
|
</div>
|
|
@@ -43,8 +43,9 @@ const TxWidget = ({
|
|
|
43
43
|
setLoading(true);
|
|
44
44
|
|
|
45
45
|
const chains = (await getChains()).filter(
|
|
46
|
-
({ web3Environment, swapSupported }) =>
|
|
47
|
-
web3Environment === Web3Environment.MAINNET &&
|
|
46
|
+
({ web3Environment, bridgeSupported, swapSupported }) =>
|
|
47
|
+
web3Environment === Web3Environment.MAINNET &&
|
|
48
|
+
(bridgeSupported || swapSupported),
|
|
48
49
|
);
|
|
49
50
|
|
|
50
51
|
setSupportedChains(chains);
|
|
@@ -83,10 +83,10 @@ type SwapContext = {
|
|
|
83
83
|
srcValue: string;
|
|
84
84
|
setSrcValue: Dispatch<SetStateAction<string>>;
|
|
85
85
|
srcValueWei: string;
|
|
86
|
-
srcValueUsd: string;
|
|
86
|
+
srcValueUsd: string | null;
|
|
87
87
|
dstValue: string;
|
|
88
88
|
dstValueWei: string;
|
|
89
|
-
dstValueUsd: string;
|
|
89
|
+
dstValueUsd: string | null;
|
|
90
90
|
dstValueMin: string;
|
|
91
91
|
lastTx: Transaction | undefined;
|
|
92
92
|
setLastTxHash: Dispatch<SetStateAction<string>>;
|
|
@@ -143,10 +143,10 @@ const init: SwapContext = {
|
|
|
143
143
|
dstToken: undefined,
|
|
144
144
|
srcValue: "",
|
|
145
145
|
srcValueWei: "",
|
|
146
|
-
srcValueUsd:
|
|
146
|
+
srcValueUsd: null,
|
|
147
147
|
dstValue: "",
|
|
148
148
|
dstValueWei: "",
|
|
149
|
-
dstValueUsd:
|
|
149
|
+
dstValueUsd: null,
|
|
150
150
|
dstValueMin: "",
|
|
151
151
|
lastTx: undefined,
|
|
152
152
|
expressDelivery: true,
|
|
@@ -436,7 +436,7 @@ export const SwapProvider = ({
|
|
|
436
436
|
Number(srcValue) * Number(srcChainTokensPrices[srcToken.address])
|
|
437
437
|
).toFixed(2);
|
|
438
438
|
}
|
|
439
|
-
return
|
|
439
|
+
return null;
|
|
440
440
|
}, [srcChainTokensPrices, srcToken, srcValue]);
|
|
441
441
|
const dstValue = useMemo(
|
|
442
442
|
() =>
|
|
@@ -466,7 +466,7 @@ export const SwapProvider = ({
|
|
|
466
466
|
Number(dstValue) * Number(dstChainTokensPrices[dstToken.address])
|
|
467
467
|
).toFixed(2);
|
|
468
468
|
}
|
|
469
|
-
return
|
|
469
|
+
return null;
|
|
470
470
|
}, [dstChainTokensPrices, dstToken, dstValue]);
|
|
471
471
|
const dstValueMin = useMemo(
|
|
472
472
|
() =>
|
|
@@ -589,10 +589,20 @@ export const SwapProvider = ({
|
|
|
589
589
|
// other source networks
|
|
590
590
|
const srcOtherTokenOptions: TokenOption[] = [];
|
|
591
591
|
const srcOtherChains = supportedChains.filter(
|
|
592
|
-
({ chainId, web3Environment, swapSupported }) =>
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
592
|
+
({ chainId, web3Environment, swapSupported, bridgeSupported }) => {
|
|
593
|
+
if (
|
|
594
|
+
chainId === srcChain.chainId ||
|
|
595
|
+
web3Environment !== Web3Environment.MAINNET
|
|
596
|
+
) {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
if (bridgeUI) {
|
|
601
|
+
return bridgeSupported;
|
|
602
|
+
} else {
|
|
603
|
+
return swapSupported;
|
|
604
|
+
}
|
|
605
|
+
},
|
|
596
606
|
);
|
|
597
607
|
for (const { chainId } of srcOtherChains) {
|
|
598
608
|
srcOtherTokenOptions.push(
|
|
@@ -67,4 +67,11 @@ export const ADDRESSES: Addresses = {
|
|
|
67
67
|
[ContractName.XSwapRouterSingleChain]:
|
|
68
68
|
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
69
69
|
},
|
|
70
|
+
// mode
|
|
71
|
+
"34443": {
|
|
72
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
73
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
74
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
75
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
76
|
+
},
|
|
70
77
|
};
|
package/tailwind.config.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** @type {import("tailwindcss").Config} */
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export default {
|
|
5
4
|
content: ["src/components/**/*.{ts,tsx}", "src/context/**/*.{ts,tsx}"],
|
|
6
5
|
theme: {
|
|
@@ -10,36 +9,60 @@ export default {
|
|
|
10
9
|
},
|
|
11
10
|
extend: {
|
|
12
11
|
colors: {
|
|
13
|
-
t_main_accent_light:
|
|
14
|
-
|
|
12
|
+
t_main_accent_light:
|
|
13
|
+
"color-mix(in srgb, var(--main-accent-light) calc(<alpha-value> * 100%), transparent)",
|
|
14
|
+
t_main_accent_dark:
|
|
15
|
+
"color-mix(in srgb, var(--main-accent-dark) calc(<alpha-value> * 100%), transparent)",
|
|
15
16
|
|
|
16
17
|
t_text_primary: `color-mix(in srgb, var(--text-primary) calc(<alpha-value> * 100%), transparent)`,
|
|
17
18
|
t_text_secondary: `color-mix(in srgb, var(--text-secondary) calc(<alpha-value> * 100%), transparent)`,
|
|
18
|
-
t_text_tertiary:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
t_text_tertiary:
|
|
20
|
+
"color-mix(in srgb, var(--text-tertiary) calc(<alpha-value> * 100%), transparent)",
|
|
21
|
+
t_text_red:
|
|
22
|
+
"color-mix(in srgb, var(--text-red) calc(<alpha-value> * 100%), transparent)",
|
|
23
|
+
t_text_orange:
|
|
24
|
+
"color-mix(in srgb, var(--text-orange) calc(<alpha-value> * 100%), transparent)",
|
|
25
|
+
t_text_green:
|
|
26
|
+
"color-mix(in srgb, var(--text-green) calc(<alpha-value> * 100%), transparent)",
|
|
27
|
+
t_click_primary:
|
|
28
|
+
"color-mix(in srgb, var(--click-primary) calc(<alpha-value> * 100%), transparent)",
|
|
29
|
+
t_click_secondary:
|
|
30
|
+
"color-mix(in srgb, var(--click-secondary) calc(<alpha-value> * 100%), transparent)",
|
|
31
|
+
t_click_tertiary:
|
|
32
|
+
"color-mix(in srgb, var(--click-tertiary) calc(<alpha-value> * 100%), transparent)",
|
|
25
33
|
|
|
26
|
-
t_bg_primary:
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
t_bg_primary:
|
|
35
|
+
"color-mix(in srgb, var(--bg-primary) calc(<alpha-value> * 100%), transparent)",
|
|
36
|
+
t_bg_secondary:
|
|
37
|
+
"color-mix(in srgb, var(--bg-secondary) calc(<alpha-value> * 100%), transparent)",
|
|
38
|
+
t_bg_tertiary:
|
|
39
|
+
"color-mix(in srgb, var(--bg-tertiary) calc(<alpha-value> * 100%), transparent)",
|
|
29
40
|
|
|
30
|
-
t_button_pr_off_text:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
t_button_pr_off_text:
|
|
42
|
+
"color-mix(in srgb, var(--button-pr-off-text) calc(<alpha-value> * 100%), transparent)",
|
|
43
|
+
t_button_pr_off_bg:
|
|
44
|
+
"color-mix(in srgb, var(--button-pr-off-bg) calc(<alpha-value> * 100%), transparent)",
|
|
45
|
+
t_button_pr_text:
|
|
46
|
+
"color-mix(in srgb, var(--button-pr-text) calc(<alpha-value> * 100%), transparent)",
|
|
47
|
+
t_button_pr_bg:
|
|
48
|
+
"color-mix(in srgb, var(--button-pr-bg) calc(<alpha-value> * 100%), transparent)",
|
|
34
49
|
|
|
35
|
-
t_success_dark:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
t_success_dark:
|
|
51
|
+
"color-mix(in srgb, var(--success-dark) calc(<alpha-value> * 100%), transparent)",
|
|
52
|
+
t_success_light:
|
|
53
|
+
"color-mix(in srgb, var(--success-light) calc(<alpha-value> * 100%), transparent)",
|
|
54
|
+
t_info_dark:
|
|
55
|
+
"color-mix(in srgb, var(--info-dark) calc(<alpha-value> * 100%), transparent)",
|
|
56
|
+
t_info_light:
|
|
57
|
+
"color-mix(in srgb, var(--info-light) calc(<alpha-value> * 100%), transparent)",
|
|
58
|
+
t_warning_dark:
|
|
59
|
+
"color-mix(in srgb, var(--warning-dark) calc(<alpha-value> * 100%), transparent)",
|
|
60
|
+
t_warning_light:
|
|
61
|
+
"color-mix(in srgb, var(--warning-light) calc(<alpha-value> * 100%), transparent)",
|
|
62
|
+
t_error_dark:
|
|
63
|
+
"color-mix(in srgb, var(--error-dark) calc(<alpha-value> * 100%), transparent)",
|
|
64
|
+
t_error_light:
|
|
65
|
+
"color-mix(in srgb, var(--error-light) calc(<alpha-value> * 100%), transparent)",
|
|
43
66
|
|
|
44
67
|
x_alert: "rgb(255,183,77)",
|
|
45
68
|
x_alert_light: "rgb(255,226,183)",
|
|
@@ -59,13 +82,13 @@ export default {
|
|
|
59
82
|
x_swap_secondary_active: "#e0e7fa",
|
|
60
83
|
},
|
|
61
84
|
minWidth: {
|
|
62
|
-
x_modal: "360px",
|
|
85
|
+
x_modal: "var(--modal-width, 360px)",
|
|
63
86
|
},
|
|
64
87
|
width: {
|
|
65
|
-
x_modal: "var(--modal-width)",
|
|
88
|
+
x_modal: "var(--modal-width, 480px)",
|
|
66
89
|
},
|
|
67
90
|
maxWidth: {
|
|
68
|
-
x_modal: "480px",
|
|
91
|
+
x_modal: "var(--modal-width, 480px)",
|
|
69
92
|
},
|
|
70
93
|
animation: {
|
|
71
94
|
"spin-slow": "spin 3s linear infinite",
|