@xswap-link/sdk 0.8.0 → 0.8.2
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 +110 -110
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/src/components/TxConfigForm/index.tsx +2 -2
- package/src/utils/validation.ts +20 -4
- package/tailwind.config.js +51 -28
package/package.json
CHANGED
|
@@ -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>
|
package/src/utils/validation.ts
CHANGED
|
@@ -42,14 +42,22 @@ const getDefaultDestinationChain = ({
|
|
|
42
42
|
return defaultTargetChain;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const getDefaultSwapTokenForChain = (
|
|
45
|
+
const getDefaultSwapTokenForChain = (
|
|
46
|
+
chain: Chain,
|
|
47
|
+
sameChain?: boolean,
|
|
48
|
+
sourceTokenId?: string,
|
|
49
|
+
) => {
|
|
46
50
|
const xswapToken = chain.tokens.find((token) => token.tokenId === "XSWAP");
|
|
47
51
|
|
|
48
52
|
if (xswapToken) {
|
|
49
53
|
return xswapToken;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
const fallbackToken = chain.tokens.find((token) =>
|
|
56
|
+
const fallbackToken = chain.tokens.find((token) =>
|
|
57
|
+
sameChain
|
|
58
|
+
? token.supported && token.tokenId !== sourceTokenId
|
|
59
|
+
: token.supported,
|
|
60
|
+
);
|
|
53
61
|
|
|
54
62
|
if (fallbackToken) {
|
|
55
63
|
return fallbackToken;
|
|
@@ -164,7 +172,11 @@ export const mapToValidPath = ({
|
|
|
164
172
|
let newTargetToken: Token | undefined =
|
|
165
173
|
target.token ||
|
|
166
174
|
(type === "SWAP"
|
|
167
|
-
? getDefaultSwapTokenForChain(
|
|
175
|
+
? getDefaultSwapTokenForChain(
|
|
176
|
+
newTargetChain,
|
|
177
|
+
newSourceChain.chainId === newTargetChain.chainId,
|
|
178
|
+
newSourceToken?.tokenId,
|
|
179
|
+
)
|
|
168
180
|
: getDefaultBridgeTokenForChain({
|
|
169
181
|
chain: newTargetChain,
|
|
170
182
|
bridgeTokensDictionary,
|
|
@@ -305,7 +317,11 @@ export const mapToValidPath = ({
|
|
|
305
317
|
newSourceToken = getDefaultSwapTokenForChain(newSourceChain);
|
|
306
318
|
}
|
|
307
319
|
if (!newTargetToken) {
|
|
308
|
-
newTargetToken = getDefaultSwapTokenForChain(
|
|
320
|
+
newTargetToken = getDefaultSwapTokenForChain(
|
|
321
|
+
newTargetChain,
|
|
322
|
+
newSourceChain.chainId === newTargetChain.chainId,
|
|
323
|
+
newSourceToken?.tokenId,
|
|
324
|
+
);
|
|
309
325
|
}
|
|
310
326
|
} else {
|
|
311
327
|
if (!newSourceToken) {
|
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",
|