@xswap-link/sdk 0.1.3 → 0.2.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/.github/workflows/publish.yml +21 -2
- package/CHANGELOG.md +12 -0
- package/dist/index.css +3 -38
- package/dist/index.js +89 -82
- package/dist/index.mjs +81 -75
- package/package.json +1 -1
- package/src/components/TxConfigForm/Button.tsx +20 -0
- package/src/components/TxConfigForm/Form.tsx +8 -9
- package/src/components/TxConfigForm/index.tsx +40 -32
- package/src/components/global.css +0 -4
|
@@ -27,11 +27,30 @@ jobs:
|
|
|
27
27
|
|
|
28
28
|
- run: pnpm install
|
|
29
29
|
- run: pnpm install react@18.2.0 react-dom@18.2.0 @types/react@18.2.0 @types/react-dom@18.2.0
|
|
30
|
+
|
|
30
31
|
- name: Create Release Pull Request or Publish
|
|
31
32
|
id: changesets
|
|
32
|
-
uses: changesets
|
|
33
|
+
uses: xswap-link/changesets-action@v1
|
|
33
34
|
with:
|
|
34
35
|
publish: pnpm run release
|
|
35
36
|
env:
|
|
36
37
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
37
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
38
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
39
|
+
|
|
40
|
+
- name: Get latest created release info
|
|
41
|
+
if: steps.changesets.outputs.published == 'true'
|
|
42
|
+
id: latest_release_info
|
|
43
|
+
uses: jossef/action-latest-release-info@v1.2.1
|
|
44
|
+
env:
|
|
45
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
46
|
+
|
|
47
|
+
- name: Publish index.css
|
|
48
|
+
if: steps.changesets.outputs.published == 'true'
|
|
49
|
+
uses: actions/upload-release-asset@v1
|
|
50
|
+
env:
|
|
51
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
52
|
+
with:
|
|
53
|
+
upload_url: ${{ steps.latest_release_info.outputs.upload_url }}
|
|
54
|
+
asset_path: ./dist/index.css
|
|
55
|
+
asset_name: index.css
|
|
56
|
+
asset_content_type: text/plain
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @xswap-link/xswap-sdk
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3fe79fb: publish index.css while releasing new version and append css element automatically so an integrator doesn't have to
|
|
8
|
+
|
|
9
|
+
## 0.1.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 1c0c46a: fix button display styling and logic
|
|
14
|
+
|
|
3
15
|
## 0.1.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.css
CHANGED
|
@@ -1060,44 +1060,6 @@ video {
|
|
|
1060
1060
|
background-color: #252525;
|
|
1061
1061
|
border-radius: 4px;
|
|
1062
1062
|
}
|
|
1063
|
-
button {
|
|
1064
|
-
width: 100%;
|
|
1065
|
-
}
|
|
1066
|
-
button {
|
|
1067
|
-
cursor: pointer;
|
|
1068
|
-
}
|
|
1069
|
-
button {
|
|
1070
|
-
border-radius: 1rem;
|
|
1071
|
-
}
|
|
1072
|
-
button {
|
|
1073
|
-
border-style: none;
|
|
1074
|
-
}
|
|
1075
|
-
button {
|
|
1076
|
-
background-image: linear-gradient(to right, var(--tw-gradient-stops));
|
|
1077
|
-
}
|
|
1078
|
-
button {
|
|
1079
|
-
--tw-gradient-from: #3681c6 var(--tw-gradient-from-position);
|
|
1080
|
-
--tw-gradient-to: rgb(54 129 198 / 0) var(--tw-gradient-to-position);
|
|
1081
|
-
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
|
|
1082
|
-
}
|
|
1083
|
-
button {
|
|
1084
|
-
--tw-gradient-to: #2b4a9d var(--tw-gradient-to-position);
|
|
1085
|
-
}
|
|
1086
|
-
button {
|
|
1087
|
-
padding-top: 1rem;
|
|
1088
|
-
padding-bottom: 1rem;
|
|
1089
|
-
}
|
|
1090
|
-
button {
|
|
1091
|
-
font-size: 1.25rem;
|
|
1092
|
-
line-height: 1.75rem;
|
|
1093
|
-
}
|
|
1094
|
-
button {
|
|
1095
|
-
--tw-text-opacity: 1;
|
|
1096
|
-
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1097
|
-
}
|
|
1098
|
-
button:disabled {
|
|
1099
|
-
opacity: 0.25;
|
|
1100
|
-
}
|
|
1101
1063
|
.globalBorder {
|
|
1102
1064
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
1103
1065
|
}
|
|
@@ -1123,6 +1085,9 @@ video {
|
|
|
1123
1085
|
outline: 2px solid transparent;
|
|
1124
1086
|
outline-offset: 2px;
|
|
1125
1087
|
}
|
|
1088
|
+
.disabled\:opacity-25:disabled {
|
|
1089
|
+
opacity: 0.25;
|
|
1090
|
+
}
|
|
1126
1091
|
@media (min-width: 640px) {
|
|
1127
1092
|
.sm\:h-6 {
|
|
1128
1093
|
height: 1.5rem;
|
package/dist/index.js
CHANGED
|
@@ -995,14 +995,12 @@ var import_react = require("react");
|
|
|
995
995
|
var useDebounce = (value, delay) => {
|
|
996
996
|
const timeoutRef = (0, import_react.useRef)(null);
|
|
997
997
|
(0, import_react.useEffect)(() => {
|
|
998
|
-
if (timeoutRef.current)
|
|
999
|
-
clearTimeout(timeoutRef.current);
|
|
998
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1000
999
|
timeoutRef.current = setTimeout(() => {
|
|
1001
1000
|
setValue(value);
|
|
1002
1001
|
}, delay);
|
|
1003
1002
|
return () => {
|
|
1004
|
-
if (timeoutRef.current)
|
|
1005
|
-
clearTimeout(timeoutRef.current);
|
|
1003
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1006
1004
|
};
|
|
1007
1005
|
}, [value, delay]);
|
|
1008
1006
|
const [debouncedValue, setValue] = (0, import_react.useState)(value);
|
|
@@ -1575,8 +1573,7 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1575
1573
|
continue;
|
|
1576
1574
|
}
|
|
1577
1575
|
let status;
|
|
1578
|
-
if (entry.failed)
|
|
1579
|
-
status = "REVERTED";
|
|
1576
|
+
if (entry.failed) status = "REVERTED";
|
|
1580
1577
|
if (!!entry.target) {
|
|
1581
1578
|
status = "DONE";
|
|
1582
1579
|
} else {
|
|
@@ -1607,8 +1604,7 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1607
1604
|
}
|
|
1608
1605
|
}, [signer, getHistory]);
|
|
1609
1606
|
(0, import_react3.useEffect)(() => {
|
|
1610
|
-
if (!historyLoadedOnce)
|
|
1611
|
-
fetchHistory();
|
|
1607
|
+
if (!historyLoadedOnce) fetchHistory();
|
|
1612
1608
|
const timer = setInterval(() => {
|
|
1613
1609
|
fetchHistory();
|
|
1614
1610
|
}, 6e4);
|
|
@@ -2092,10 +2088,8 @@ var import_bignumber3 = __toESM(require("bignumber.js"));
|
|
|
2092
2088
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2093
2089
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
2094
2090
|
const balanceText = (0, import_react8.useMemo)(() => {
|
|
2095
|
-
if (!balances || !srcToken)
|
|
2096
|
-
|
|
2097
|
-
if (balances[srcToken.address]?.toString() === "0")
|
|
2098
|
-
return "0";
|
|
2091
|
+
if (!balances || !srcToken) return "0";
|
|
2092
|
+
if (balances[srcToken.address]?.toString() === "0") return "0";
|
|
2099
2093
|
const fullHumanReadable = weiToHumanReadable({
|
|
2100
2094
|
amount: balances[srcToken.address]?.toString() || "0",
|
|
2101
2095
|
decimals: srcToken.decimals,
|
|
@@ -2179,8 +2173,7 @@ var SwapPanel = ({
|
|
|
2179
2173
|
className: "p-0 border-none outline-none bg-transparent text-2xl overflow-ellipsis",
|
|
2180
2174
|
value: amount,
|
|
2181
2175
|
onChange: (e) => {
|
|
2182
|
-
if (e.target.value === ".")
|
|
2183
|
-
return;
|
|
2176
|
+
if (e.target.value === ".") return;
|
|
2184
2177
|
if (NUMBER_INPUT_REGEX.test(e.target.value)) {
|
|
2185
2178
|
setAmount(e.target.value.replace(/,/g, "."));
|
|
2186
2179
|
}
|
|
@@ -2305,8 +2298,23 @@ var Description = ({ description }) => {
|
|
|
2305
2298
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "flex flex-col items-start rounded-lg px-4 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "w-full flex gap-4 items-start justify-between text-xl", children: description }) });
|
|
2306
2299
|
};
|
|
2307
2300
|
|
|
2308
|
-
// src/components/TxConfigForm/
|
|
2301
|
+
// src/components/TxConfigForm/Button.tsx
|
|
2309
2302
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
2303
|
+
var Button = ({ children, onClick, type, disabled }) => {
|
|
2304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
2305
|
+
"button",
|
|
2306
|
+
{
|
|
2307
|
+
className: "text-white border-none rounded-2xl text-xl py-4 cursor-pointer w-full bg-gradient-to-r from-[#3681c6] to-[#2b4a9d] disabled:opacity-25",
|
|
2308
|
+
onClick,
|
|
2309
|
+
type,
|
|
2310
|
+
disabled,
|
|
2311
|
+
children
|
|
2312
|
+
}
|
|
2313
|
+
);
|
|
2314
|
+
};
|
|
2315
|
+
|
|
2316
|
+
// src/components/TxConfigForm/Form.tsx
|
|
2317
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
2310
2318
|
var Form = ({
|
|
2311
2319
|
dstChainId,
|
|
2312
2320
|
dstTokenAddr,
|
|
@@ -2431,19 +2439,18 @@ var Form = ({
|
|
|
2431
2439
|
}, [srcChain, signer]);
|
|
2432
2440
|
const handleSubmit = (event) => {
|
|
2433
2441
|
event.preventDefault();
|
|
2434
|
-
if (route)
|
|
2435
|
-
onSubmit(route);
|
|
2442
|
+
if (route) onSubmit(route);
|
|
2436
2443
|
};
|
|
2437
2444
|
const handleSwitchChain = async () => {
|
|
2438
2445
|
await switchChainAsync({ chainId: Number(srcChain?.chainId) });
|
|
2439
2446
|
};
|
|
2440
|
-
return /* @__PURE__ */ (0,
|
|
2447
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
2441
2448
|
"form",
|
|
2442
2449
|
{
|
|
2443
2450
|
className: "flex flex-col gap-2 z-10 my-0 mx-auto p-4 rounded-3xl overflow-hidden font-light w-x_mobile sm:w-x_desktop",
|
|
2444
2451
|
onSubmit: handleSubmit,
|
|
2445
2452
|
children: [
|
|
2446
|
-
/* @__PURE__ */ (0,
|
|
2453
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2447
2454
|
TopBar,
|
|
2448
2455
|
{
|
|
2449
2456
|
signer,
|
|
@@ -2452,7 +2459,7 @@ var Form = ({
|
|
|
2452
2459
|
setSettingsShown
|
|
2453
2460
|
}
|
|
2454
2461
|
),
|
|
2455
|
-
settingsShown && /* @__PURE__ */ (0,
|
|
2462
|
+
settingsShown && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2456
2463
|
Settings,
|
|
2457
2464
|
{
|
|
2458
2465
|
expressChecked,
|
|
@@ -2462,9 +2469,9 @@ var Form = ({
|
|
|
2462
2469
|
setSlippage
|
|
2463
2470
|
}
|
|
2464
2471
|
),
|
|
2465
|
-
historyTabShown ? /* @__PURE__ */ (0,
|
|
2466
|
-
desc && /* @__PURE__ */ (0,
|
|
2467
|
-
/* @__PURE__ */ (0,
|
|
2472
|
+
historyTabShown ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(History, { signer, supportedChains }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
2473
|
+
desc && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Description, { description: desc }),
|
|
2474
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2468
2475
|
SwapPanel,
|
|
2469
2476
|
{
|
|
2470
2477
|
amount,
|
|
@@ -2479,7 +2486,7 @@ var Form = ({
|
|
|
2479
2486
|
setSrcChain
|
|
2480
2487
|
}
|
|
2481
2488
|
),
|
|
2482
|
-
/* @__PURE__ */ (0,
|
|
2489
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2483
2490
|
Summary,
|
|
2484
2491
|
{
|
|
2485
2492
|
isGettingRoute,
|
|
@@ -2488,7 +2495,7 @@ var Form = ({
|
|
|
2488
2495
|
dstChain
|
|
2489
2496
|
}
|
|
2490
2497
|
),
|
|
2491
|
-
/* @__PURE__ */ (0,
|
|
2498
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2492
2499
|
FeesDetails,
|
|
2493
2500
|
{
|
|
2494
2501
|
route,
|
|
@@ -2501,17 +2508,9 @@ var Form = ({
|
|
|
2501
2508
|
setFeesDetailsShown
|
|
2502
2509
|
}
|
|
2503
2510
|
),
|
|
2504
|
-
formError.length > 0 && /* @__PURE__ */ (0,
|
|
2505
|
-
srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ (0,
|
|
2506
|
-
|
|
2507
|
-
{
|
|
2508
|
-
disabled: !signer,
|
|
2509
|
-
type: "button",
|
|
2510
|
-
onClick: handleSwitchChain,
|
|
2511
|
-
children: "Switch chain"
|
|
2512
|
-
}
|
|
2513
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
2514
|
-
"button",
|
|
2511
|
+
formError.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ErrorField, { error: formError }),
|
|
2512
|
+
signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Button, { type: "button", onClick: handleSwitchChain, children: "Switch chain" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2513
|
+
Button,
|
|
2515
2514
|
{
|
|
2516
2515
|
type: "submit",
|
|
2517
2516
|
disabled: !signer || !route || isGettingRoute,
|
|
@@ -2524,8 +2523,11 @@ var Form = ({
|
|
|
2524
2523
|
);
|
|
2525
2524
|
};
|
|
2526
2525
|
|
|
2526
|
+
// package.json
|
|
2527
|
+
var version = "0.2.0";
|
|
2528
|
+
|
|
2527
2529
|
// src/components/TxConfigForm/index.tsx
|
|
2528
|
-
var
|
|
2530
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
2529
2531
|
var TxConfigForm = ({
|
|
2530
2532
|
dstChainId,
|
|
2531
2533
|
dstTokenAddr,
|
|
@@ -2547,13 +2549,13 @@ var TxConfigForm = ({
|
|
|
2547
2549
|
() => getWagmiConfig(supportedChains),
|
|
2548
2550
|
supportedChains
|
|
2549
2551
|
);
|
|
2550
|
-
return /* @__PURE__ */ (0,
|
|
2552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_wagmi3.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2551
2553
|
"div",
|
|
2552
2554
|
{
|
|
2553
2555
|
className: "top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10",
|
|
2554
2556
|
onClick: onBackdropClick,
|
|
2555
|
-
children: /* @__PURE__ */ (0,
|
|
2556
|
-
/* @__PURE__ */ (0,
|
|
2557
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "relative bg-black rounded-3xl w-lg overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]", children: [
|
|
2558
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2557
2559
|
Form,
|
|
2558
2560
|
{
|
|
2559
2561
|
dstChainId,
|
|
@@ -2564,19 +2566,19 @@ var TxConfigForm = ({
|
|
|
2564
2566
|
onSubmit
|
|
2565
2567
|
}
|
|
2566
2568
|
),
|
|
2567
|
-
/* @__PURE__ */ (0,
|
|
2569
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2568
2570
|
"div",
|
|
2569
2571
|
{
|
|
2570
2572
|
className: "absolute top-7 right-4 cursor-pointer text-white",
|
|
2571
2573
|
onClick: onClose,
|
|
2572
|
-
children: /* @__PURE__ */ (0,
|
|
2574
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CloseIcon, {})
|
|
2573
2575
|
}
|
|
2574
2576
|
),
|
|
2575
|
-
/* @__PURE__ */ (0,
|
|
2576
|
-
/* @__PURE__ */ (0,
|
|
2577
|
-
/* @__PURE__ */ (0,
|
|
2578
|
-
/* @__PURE__ */ (0,
|
|
2579
|
-
/* @__PURE__ */ (0,
|
|
2577
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "swappage__poweredby", children: [
|
|
2578
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: "Powered by" }),
|
|
2579
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(XSwapBadgeIcon, {}),
|
|
2580
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: "\u2715" }),
|
|
2581
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChainlinkCCIPIcon, {})
|
|
2580
2582
|
] })
|
|
2581
2583
|
] })
|
|
2582
2584
|
}
|
|
@@ -2591,8 +2593,8 @@ var openTxConfigForm = async ({
|
|
|
2591
2593
|
}) => {
|
|
2592
2594
|
try {
|
|
2593
2595
|
return await new Promise((resolve) => {
|
|
2594
|
-
|
|
2595
|
-
/* @__PURE__ */ (0,
|
|
2596
|
+
xswapRoot.render(
|
|
2597
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2596
2598
|
TxConfigForm,
|
|
2597
2599
|
{
|
|
2598
2600
|
dstChainId,
|
|
@@ -2602,10 +2604,10 @@ var openTxConfigForm = async ({
|
|
|
2602
2604
|
supportedChains,
|
|
2603
2605
|
onSubmit: (route) => {
|
|
2604
2606
|
resolve(route);
|
|
2605
|
-
|
|
2607
|
+
xswapRoot.render("");
|
|
2606
2608
|
},
|
|
2607
2609
|
onClose: () => {
|
|
2608
|
-
|
|
2610
|
+
xswapRoot.render("");
|
|
2609
2611
|
}
|
|
2610
2612
|
}
|
|
2611
2613
|
)
|
|
@@ -2615,18 +2617,23 @@ var openTxConfigForm = async ({
|
|
|
2615
2617
|
throw new Error(`XSwap component error, ${err}`);
|
|
2616
2618
|
}
|
|
2617
2619
|
};
|
|
2618
|
-
var
|
|
2620
|
+
var xswapRoot;
|
|
2619
2621
|
if (typeof document !== "undefined") {
|
|
2620
|
-
const
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2622
|
+
const xswapStyleElement = document.createElement("link");
|
|
2623
|
+
xswapStyleElement.rel = "stylesheet";
|
|
2624
|
+
xswapStyleElement.type = "text/css";
|
|
2625
|
+
xswapStyleElement.href = `${xswap_config_default.apiUrl}/sdk/css/${version}`;
|
|
2626
|
+
document.head.appendChild(xswapStyleElement);
|
|
2627
|
+
const xswapModalElement = document.createElement("div");
|
|
2628
|
+
xswapModalElement.setAttribute("id", "xswap-modal");
|
|
2629
|
+
document.body.appendChild(xswapModalElement);
|
|
2630
|
+
xswapRoot = (0, import_client.createRoot)(xswapModalElement);
|
|
2624
2631
|
}
|
|
2625
2632
|
|
|
2626
2633
|
// src/components/TxHistoryButton/index.tsx
|
|
2627
2634
|
var import_react12 = require("react");
|
|
2628
2635
|
var import_client2 = require("react-dom/client");
|
|
2629
|
-
var
|
|
2636
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
2630
2637
|
var TxHistoryButton = ({ transaction }) => {
|
|
2631
2638
|
const {
|
|
2632
2639
|
fromChain,
|
|
@@ -2641,15 +2648,15 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2641
2648
|
explorer
|
|
2642
2649
|
} = transaction;
|
|
2643
2650
|
const [isWide, setIsWide] = (0, import_react12.useState)(false);
|
|
2644
|
-
return /* @__PURE__ */ (0,
|
|
2645
|
-
isWide && /* @__PURE__ */ (0,
|
|
2651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex gap-2", onClick: () => setIsWide((x) => !x), children: [
|
|
2652
|
+
isWide && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
2646
2653
|
"div",
|
|
2647
2654
|
{
|
|
2648
2655
|
className: `flex items-center min-w-60 sm:w-[520px] text-white h-14 px-4 text-sm gap-3 rounded-xl bg-gradient-to-r ${isDone ? "from-[rgba(76,175,80,0.1)] to-[rgba(46,125,50,0.1)] border border-solid border-x_green_dark" : "from-[rgba(54,129,198,0.1)] to-[rgba(43,74,157,0.1)] border border-solid border-x_blue_dark"}`,
|
|
2649
2656
|
children: [
|
|
2650
|
-
/* @__PURE__ */ (0,
|
|
2651
|
-
/* @__PURE__ */ (0,
|
|
2652
|
-
/* @__PURE__ */ (0,
|
|
2657
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex justify-between flex-col gap-2 sm:gap-5 sm:flex-row w-full", children: [
|
|
2658
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2659
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2653
2660
|
"img",
|
|
2654
2661
|
{
|
|
2655
2662
|
className: "w-5 h-5",
|
|
@@ -2657,16 +2664,16 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2657
2664
|
alt: "source chain"
|
|
2658
2665
|
}
|
|
2659
2666
|
),
|
|
2660
|
-
/* @__PURE__ */ (0,
|
|
2661
|
-
/* @__PURE__ */ (0,
|
|
2662
|
-
/* @__PURE__ */ (0,
|
|
2663
|
-
/* @__PURE__ */ (0,
|
|
2667
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { children: fromChain }),
|
|
2668
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ArrowRightIcon, {}) }),
|
|
2669
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("img", { className: "w-5 h-5", src: toChainImage, alt: "to chain" }),
|
|
2670
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { children: toChain })
|
|
2664
2671
|
] }),
|
|
2665
|
-
/* @__PURE__ */ (0,
|
|
2666
|
-
/* @__PURE__ */ (0,
|
|
2667
|
-
/* @__PURE__ */ (0,
|
|
2668
|
-
/* @__PURE__ */ (0,
|
|
2669
|
-
/* @__PURE__ */ (0,
|
|
2672
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2673
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { children: "Sent" }),
|
|
2674
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { children: fromAmount }),
|
|
2675
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { children: fromToken }),
|
|
2676
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2670
2677
|
"img",
|
|
2671
2678
|
{
|
|
2672
2679
|
className: "w-5 h-5",
|
|
@@ -2676,7 +2683,7 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2676
2683
|
)
|
|
2677
2684
|
] })
|
|
2678
2685
|
] }),
|
|
2679
|
-
/* @__PURE__ */ (0,
|
|
2686
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2680
2687
|
"a",
|
|
2681
2688
|
{
|
|
2682
2689
|
href: explorer,
|
|
@@ -2684,22 +2691,22 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2684
2691
|
rel: "noreferrer",
|
|
2685
2692
|
className: "no-underline cursor-pointer",
|
|
2686
2693
|
"aria-label": "Show the transaction in the chain explorer",
|
|
2687
|
-
children: /* @__PURE__ */ (0,
|
|
2694
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ArrowUpRightIcon, {}) })
|
|
2688
2695
|
}
|
|
2689
2696
|
)
|
|
2690
2697
|
]
|
|
2691
2698
|
}
|
|
2692
2699
|
),
|
|
2693
|
-
/* @__PURE__ */ (0,
|
|
2700
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2694
2701
|
"div",
|
|
2695
2702
|
{
|
|
2696
2703
|
className: `text-white rounded-xl cursor-pointer bg-gradient-to-r
|
|
2697
2704
|
${isDone ? "from-[rgba(76,175,80,0.1)] to-[rgba(46,125,50,0.1)] border border-solid border-x_green_dark" : "from-[rgba(54,129,198,0.1)] to-[rgba(43,74,157,0.1)] border border-solid border-x_blue_dark"}`,
|
|
2698
|
-
children: /* @__PURE__ */ (0,
|
|
2699
|
-
/* @__PURE__ */ (0,
|
|
2700
|
-
/* @__PURE__ */ (0,
|
|
2701
|
-
/* @__PURE__ */ (0,
|
|
2702
|
-
/* @__PURE__ */ (0,
|
|
2705
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex gap-2 items-center h-14 w-20 justify-center", children: [
|
|
2706
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ArrowLeftIcon, {}),
|
|
2707
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "relative flex items-center justify-center w-9 h-9", children: isDone ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "text-x_green w-5 h-5", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
2708
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "w-5 h-5", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(XSwapLogo, {}) }),
|
|
2709
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CircularProgressIcon, {}) })
|
|
2703
2710
|
] }) })
|
|
2704
2711
|
] })
|
|
2705
2712
|
}
|
|
@@ -2734,14 +2741,14 @@ historyElement.setAttribute(
|
|
|
2734
2741
|
document.body.appendChild(historyElement);
|
|
2735
2742
|
var txHistoryButtonRoot = (0, import_client2.createRoot)(historyElement);
|
|
2736
2743
|
var renderTxHistoryButtons = () => {
|
|
2737
|
-
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ (0,
|
|
2744
|
+
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(TxHistoryButton, { transaction: item }, item.txHash));
|
|
2738
2745
|
txHistoryButtonRoot.render(buttons);
|
|
2739
2746
|
};
|
|
2740
2747
|
|
|
2741
2748
|
// src/components/Skeleton/index.tsx
|
|
2742
|
-
var
|
|
2749
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
2743
2750
|
var Skeleton = ({ width, height }) => {
|
|
2744
|
-
return /* @__PURE__ */ (0,
|
|
2751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: `bg-current rounded animate-pulse ${width} ${height}` });
|
|
2745
2752
|
};
|
|
2746
2753
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2747
2754
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
2
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
3
|
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
6
|
});
|
|
8
7
|
|
|
@@ -918,14 +917,12 @@ import { useEffect, useRef, useState } from "react";
|
|
|
918
917
|
var useDebounce = (value, delay) => {
|
|
919
918
|
const timeoutRef = useRef(null);
|
|
920
919
|
useEffect(() => {
|
|
921
|
-
if (timeoutRef.current)
|
|
922
|
-
clearTimeout(timeoutRef.current);
|
|
920
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
923
921
|
timeoutRef.current = setTimeout(() => {
|
|
924
922
|
setValue(value);
|
|
925
923
|
}, delay);
|
|
926
924
|
return () => {
|
|
927
|
-
if (timeoutRef.current)
|
|
928
|
-
clearTimeout(timeoutRef.current);
|
|
925
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
929
926
|
};
|
|
930
927
|
}, [value, delay]);
|
|
931
928
|
const [debouncedValue, setValue] = useState(value);
|
|
@@ -1498,8 +1495,7 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1498
1495
|
continue;
|
|
1499
1496
|
}
|
|
1500
1497
|
let status;
|
|
1501
|
-
if (entry.failed)
|
|
1502
|
-
status = "REVERTED";
|
|
1498
|
+
if (entry.failed) status = "REVERTED";
|
|
1503
1499
|
if (!!entry.target) {
|
|
1504
1500
|
status = "DONE";
|
|
1505
1501
|
} else {
|
|
@@ -1530,8 +1526,7 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1530
1526
|
}
|
|
1531
1527
|
}, [signer, getHistory]);
|
|
1532
1528
|
useEffect2(() => {
|
|
1533
|
-
if (!historyLoadedOnce)
|
|
1534
|
-
fetchHistory();
|
|
1529
|
+
if (!historyLoadedOnce) fetchHistory();
|
|
1535
1530
|
const timer = setInterval(() => {
|
|
1536
1531
|
fetchHistory();
|
|
1537
1532
|
}, 6e4);
|
|
@@ -2015,10 +2010,8 @@ import BigNumber3 from "bignumber.js";
|
|
|
2015
2010
|
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2016
2011
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
2017
2012
|
const balanceText = useMemo5(() => {
|
|
2018
|
-
if (!balances || !srcToken)
|
|
2019
|
-
|
|
2020
|
-
if (balances[srcToken.address]?.toString() === "0")
|
|
2021
|
-
return "0";
|
|
2013
|
+
if (!balances || !srcToken) return "0";
|
|
2014
|
+
if (balances[srcToken.address]?.toString() === "0") return "0";
|
|
2022
2015
|
const fullHumanReadable = weiToHumanReadable({
|
|
2023
2016
|
amount: balances[srcToken.address]?.toString() || "0",
|
|
2024
2017
|
decimals: srcToken.decimals,
|
|
@@ -2102,8 +2095,7 @@ var SwapPanel = ({
|
|
|
2102
2095
|
className: "p-0 border-none outline-none bg-transparent text-2xl overflow-ellipsis",
|
|
2103
2096
|
value: amount,
|
|
2104
2097
|
onChange: (e) => {
|
|
2105
|
-
if (e.target.value === ".")
|
|
2106
|
-
return;
|
|
2098
|
+
if (e.target.value === ".") return;
|
|
2107
2099
|
if (NUMBER_INPUT_REGEX.test(e.target.value)) {
|
|
2108
2100
|
setAmount(e.target.value.replace(/,/g, "."));
|
|
2109
2101
|
}
|
|
@@ -2228,8 +2220,23 @@ var Description = ({ description }) => {
|
|
|
2228
2220
|
return /* @__PURE__ */ jsx35("div", { className: "flex flex-col items-start rounded-lg px-4 py-2", children: /* @__PURE__ */ jsx35("div", { className: "w-full flex gap-4 items-start justify-between text-xl", children: description }) });
|
|
2229
2221
|
};
|
|
2230
2222
|
|
|
2223
|
+
// src/components/TxConfigForm/Button.tsx
|
|
2224
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
2225
|
+
var Button = ({ children, onClick, type, disabled }) => {
|
|
2226
|
+
return /* @__PURE__ */ jsx36(
|
|
2227
|
+
"button",
|
|
2228
|
+
{
|
|
2229
|
+
className: "text-white border-none rounded-2xl text-xl py-4 cursor-pointer w-full bg-gradient-to-r from-[#3681c6] to-[#2b4a9d] disabled:opacity-25",
|
|
2230
|
+
onClick,
|
|
2231
|
+
type,
|
|
2232
|
+
disabled,
|
|
2233
|
+
children
|
|
2234
|
+
}
|
|
2235
|
+
);
|
|
2236
|
+
};
|
|
2237
|
+
|
|
2231
2238
|
// src/components/TxConfigForm/Form.tsx
|
|
2232
|
-
import { jsx as
|
|
2239
|
+
import { jsx as jsx37, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2233
2240
|
var Form = ({
|
|
2234
2241
|
dstChainId,
|
|
2235
2242
|
dstTokenAddr,
|
|
@@ -2354,8 +2361,7 @@ var Form = ({
|
|
|
2354
2361
|
}, [srcChain, signer]);
|
|
2355
2362
|
const handleSubmit = (event) => {
|
|
2356
2363
|
event.preventDefault();
|
|
2357
|
-
if (route)
|
|
2358
|
-
onSubmit(route);
|
|
2364
|
+
if (route) onSubmit(route);
|
|
2359
2365
|
};
|
|
2360
2366
|
const handleSwitchChain = async () => {
|
|
2361
2367
|
await switchChainAsync({ chainId: Number(srcChain?.chainId) });
|
|
@@ -2366,7 +2372,7 @@ var Form = ({
|
|
|
2366
2372
|
className: "flex flex-col gap-2 z-10 my-0 mx-auto p-4 rounded-3xl overflow-hidden font-light w-x_mobile sm:w-x_desktop",
|
|
2367
2373
|
onSubmit: handleSubmit,
|
|
2368
2374
|
children: [
|
|
2369
|
-
/* @__PURE__ */
|
|
2375
|
+
/* @__PURE__ */ jsx37(
|
|
2370
2376
|
TopBar,
|
|
2371
2377
|
{
|
|
2372
2378
|
signer,
|
|
@@ -2375,7 +2381,7 @@ var Form = ({
|
|
|
2375
2381
|
setSettingsShown
|
|
2376
2382
|
}
|
|
2377
2383
|
),
|
|
2378
|
-
settingsShown && /* @__PURE__ */
|
|
2384
|
+
settingsShown && /* @__PURE__ */ jsx37(
|
|
2379
2385
|
Settings,
|
|
2380
2386
|
{
|
|
2381
2387
|
expressChecked,
|
|
@@ -2385,9 +2391,9 @@ var Form = ({
|
|
|
2385
2391
|
setSlippage
|
|
2386
2392
|
}
|
|
2387
2393
|
),
|
|
2388
|
-
historyTabShown ? /* @__PURE__ */
|
|
2389
|
-
desc && /* @__PURE__ */
|
|
2390
|
-
/* @__PURE__ */
|
|
2394
|
+
historyTabShown ? /* @__PURE__ */ jsx37(History, { signer, supportedChains }) : /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-2", children: [
|
|
2395
|
+
desc && /* @__PURE__ */ jsx37(Description, { description: desc }),
|
|
2396
|
+
/* @__PURE__ */ jsx37(
|
|
2391
2397
|
SwapPanel,
|
|
2392
2398
|
{
|
|
2393
2399
|
amount,
|
|
@@ -2402,7 +2408,7 @@ var Form = ({
|
|
|
2402
2408
|
setSrcChain
|
|
2403
2409
|
}
|
|
2404
2410
|
),
|
|
2405
|
-
/* @__PURE__ */
|
|
2411
|
+
/* @__PURE__ */ jsx37(
|
|
2406
2412
|
Summary,
|
|
2407
2413
|
{
|
|
2408
2414
|
isGettingRoute,
|
|
@@ -2411,7 +2417,7 @@ var Form = ({
|
|
|
2411
2417
|
dstChain
|
|
2412
2418
|
}
|
|
2413
2419
|
),
|
|
2414
|
-
/* @__PURE__ */
|
|
2420
|
+
/* @__PURE__ */ jsx37(
|
|
2415
2421
|
FeesDetails,
|
|
2416
2422
|
{
|
|
2417
2423
|
route,
|
|
@@ -2424,17 +2430,9 @@ var Form = ({
|
|
|
2424
2430
|
setFeesDetailsShown
|
|
2425
2431
|
}
|
|
2426
2432
|
),
|
|
2427
|
-
formError.length > 0 && /* @__PURE__ */
|
|
2428
|
-
srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */
|
|
2429
|
-
|
|
2430
|
-
{
|
|
2431
|
-
disabled: !signer,
|
|
2432
|
-
type: "button",
|
|
2433
|
-
onClick: handleSwitchChain,
|
|
2434
|
-
children: "Switch chain"
|
|
2435
|
-
}
|
|
2436
|
-
) : /* @__PURE__ */ jsx36(
|
|
2437
|
-
"button",
|
|
2433
|
+
formError.length > 0 && /* @__PURE__ */ jsx37(ErrorField, { error: formError }),
|
|
2434
|
+
signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ jsx37(Button, { type: "button", onClick: handleSwitchChain, children: "Switch chain" }) : /* @__PURE__ */ jsx37(
|
|
2435
|
+
Button,
|
|
2438
2436
|
{
|
|
2439
2437
|
type: "submit",
|
|
2440
2438
|
disabled: !signer || !route || isGettingRoute,
|
|
@@ -2447,8 +2445,11 @@ var Form = ({
|
|
|
2447
2445
|
);
|
|
2448
2446
|
};
|
|
2449
2447
|
|
|
2448
|
+
// package.json
|
|
2449
|
+
var version = "0.2.0";
|
|
2450
|
+
|
|
2450
2451
|
// src/components/TxConfigForm/index.tsx
|
|
2451
|
-
import { jsx as
|
|
2452
|
+
import { jsx as jsx38, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2452
2453
|
var TxConfigForm = ({
|
|
2453
2454
|
dstChainId,
|
|
2454
2455
|
dstTokenAddr,
|
|
@@ -2470,13 +2471,13 @@ var TxConfigForm = ({
|
|
|
2470
2471
|
() => getWagmiConfig(supportedChains),
|
|
2471
2472
|
supportedChains
|
|
2472
2473
|
);
|
|
2473
|
-
return /* @__PURE__ */
|
|
2474
|
+
return /* @__PURE__ */ jsx38(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx38(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx38(
|
|
2474
2475
|
"div",
|
|
2475
2476
|
{
|
|
2476
2477
|
className: "top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10",
|
|
2477
2478
|
onClick: onBackdropClick,
|
|
2478
2479
|
children: /* @__PURE__ */ jsxs17("div", { className: "relative bg-black rounded-3xl w-lg overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]", children: [
|
|
2479
|
-
/* @__PURE__ */
|
|
2480
|
+
/* @__PURE__ */ jsx38(
|
|
2480
2481
|
Form,
|
|
2481
2482
|
{
|
|
2482
2483
|
dstChainId,
|
|
@@ -2487,19 +2488,19 @@ var TxConfigForm = ({
|
|
|
2487
2488
|
onSubmit
|
|
2488
2489
|
}
|
|
2489
2490
|
),
|
|
2490
|
-
/* @__PURE__ */
|
|
2491
|
+
/* @__PURE__ */ jsx38(
|
|
2491
2492
|
"div",
|
|
2492
2493
|
{
|
|
2493
2494
|
className: "absolute top-7 right-4 cursor-pointer text-white",
|
|
2494
2495
|
onClick: onClose,
|
|
2495
|
-
children: /* @__PURE__ */
|
|
2496
|
+
children: /* @__PURE__ */ jsx38(CloseIcon, {})
|
|
2496
2497
|
}
|
|
2497
2498
|
),
|
|
2498
2499
|
/* @__PURE__ */ jsxs17("div", { className: "swappage__poweredby", children: [
|
|
2499
|
-
/* @__PURE__ */
|
|
2500
|
-
/* @__PURE__ */
|
|
2501
|
-
/* @__PURE__ */
|
|
2502
|
-
/* @__PURE__ */
|
|
2500
|
+
/* @__PURE__ */ jsx38("span", { children: "Powered by" }),
|
|
2501
|
+
/* @__PURE__ */ jsx38(XSwapBadgeIcon, {}),
|
|
2502
|
+
/* @__PURE__ */ jsx38("span", { children: "\u2715" }),
|
|
2503
|
+
/* @__PURE__ */ jsx38(ChainlinkCCIPIcon, {})
|
|
2503
2504
|
] })
|
|
2504
2505
|
] })
|
|
2505
2506
|
}
|
|
@@ -2514,8 +2515,8 @@ var openTxConfigForm = async ({
|
|
|
2514
2515
|
}) => {
|
|
2515
2516
|
try {
|
|
2516
2517
|
return await new Promise((resolve) => {
|
|
2517
|
-
|
|
2518
|
-
/* @__PURE__ */
|
|
2518
|
+
xswapRoot.render(
|
|
2519
|
+
/* @__PURE__ */ jsx38(
|
|
2519
2520
|
TxConfigForm,
|
|
2520
2521
|
{
|
|
2521
2522
|
dstChainId,
|
|
@@ -2525,10 +2526,10 @@ var openTxConfigForm = async ({
|
|
|
2525
2526
|
supportedChains,
|
|
2526
2527
|
onSubmit: (route) => {
|
|
2527
2528
|
resolve(route);
|
|
2528
|
-
|
|
2529
|
+
xswapRoot.render("");
|
|
2529
2530
|
},
|
|
2530
2531
|
onClose: () => {
|
|
2531
|
-
|
|
2532
|
+
xswapRoot.render("");
|
|
2532
2533
|
}
|
|
2533
2534
|
}
|
|
2534
2535
|
)
|
|
@@ -2538,18 +2539,23 @@ var openTxConfigForm = async ({
|
|
|
2538
2539
|
throw new Error(`XSwap component error, ${err}`);
|
|
2539
2540
|
}
|
|
2540
2541
|
};
|
|
2541
|
-
var
|
|
2542
|
+
var xswapRoot;
|
|
2542
2543
|
if (typeof document !== "undefined") {
|
|
2543
|
-
const
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2544
|
+
const xswapStyleElement = document.createElement("link");
|
|
2545
|
+
xswapStyleElement.rel = "stylesheet";
|
|
2546
|
+
xswapStyleElement.type = "text/css";
|
|
2547
|
+
xswapStyleElement.href = `${xswap_config_default.apiUrl}/sdk/css/${version}`;
|
|
2548
|
+
document.head.appendChild(xswapStyleElement);
|
|
2549
|
+
const xswapModalElement = document.createElement("div");
|
|
2550
|
+
xswapModalElement.setAttribute("id", "xswap-modal");
|
|
2551
|
+
document.body.appendChild(xswapModalElement);
|
|
2552
|
+
xswapRoot = createRoot(xswapModalElement);
|
|
2547
2553
|
}
|
|
2548
2554
|
|
|
2549
2555
|
// src/components/TxHistoryButton/index.tsx
|
|
2550
2556
|
import { useState as useState9 } from "react";
|
|
2551
2557
|
import { createRoot as createRoot2 } from "react-dom/client";
|
|
2552
|
-
import { Fragment as Fragment6, jsx as
|
|
2558
|
+
import { Fragment as Fragment6, jsx as jsx39, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2553
2559
|
var TxHistoryButton = ({ transaction }) => {
|
|
2554
2560
|
const {
|
|
2555
2561
|
fromChain,
|
|
@@ -2572,7 +2578,7 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2572
2578
|
children: [
|
|
2573
2579
|
/* @__PURE__ */ jsxs18("div", { className: "flex justify-between flex-col gap-2 sm:gap-5 sm:flex-row w-full", children: [
|
|
2574
2580
|
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
2575
|
-
/* @__PURE__ */
|
|
2581
|
+
/* @__PURE__ */ jsx39(
|
|
2576
2582
|
"img",
|
|
2577
2583
|
{
|
|
2578
2584
|
className: "w-5 h-5",
|
|
@@ -2580,16 +2586,16 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2580
2586
|
alt: "source chain"
|
|
2581
2587
|
}
|
|
2582
2588
|
),
|
|
2583
|
-
/* @__PURE__ */
|
|
2584
|
-
/* @__PURE__ */
|
|
2585
|
-
/* @__PURE__ */
|
|
2586
|
-
/* @__PURE__ */
|
|
2589
|
+
/* @__PURE__ */ jsx39("div", { children: fromChain }),
|
|
2590
|
+
/* @__PURE__ */ jsx39("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx39(ArrowRightIcon, {}) }),
|
|
2591
|
+
/* @__PURE__ */ jsx39("img", { className: "w-5 h-5", src: toChainImage, alt: "to chain" }),
|
|
2592
|
+
/* @__PURE__ */ jsx39("div", { children: toChain })
|
|
2587
2593
|
] }),
|
|
2588
2594
|
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
2589
|
-
/* @__PURE__ */
|
|
2590
|
-
/* @__PURE__ */
|
|
2591
|
-
/* @__PURE__ */
|
|
2592
|
-
/* @__PURE__ */
|
|
2595
|
+
/* @__PURE__ */ jsx39("div", { children: "Sent" }),
|
|
2596
|
+
/* @__PURE__ */ jsx39("div", { children: fromAmount }),
|
|
2597
|
+
/* @__PURE__ */ jsx39("div", { children: fromToken }),
|
|
2598
|
+
/* @__PURE__ */ jsx39(
|
|
2593
2599
|
"img",
|
|
2594
2600
|
{
|
|
2595
2601
|
className: "w-5 h-5",
|
|
@@ -2599,7 +2605,7 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2599
2605
|
)
|
|
2600
2606
|
] })
|
|
2601
2607
|
] }),
|
|
2602
|
-
/* @__PURE__ */
|
|
2608
|
+
/* @__PURE__ */ jsx39(
|
|
2603
2609
|
"a",
|
|
2604
2610
|
{
|
|
2605
2611
|
href: explorer,
|
|
@@ -2607,22 +2613,22 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2607
2613
|
rel: "noreferrer",
|
|
2608
2614
|
className: "no-underline cursor-pointer",
|
|
2609
2615
|
"aria-label": "Show the transaction in the chain explorer",
|
|
2610
|
-
children: /* @__PURE__ */
|
|
2616
|
+
children: /* @__PURE__ */ jsx39("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx39(ArrowUpRightIcon, {}) })
|
|
2611
2617
|
}
|
|
2612
2618
|
)
|
|
2613
2619
|
]
|
|
2614
2620
|
}
|
|
2615
2621
|
),
|
|
2616
|
-
/* @__PURE__ */
|
|
2622
|
+
/* @__PURE__ */ jsx39(
|
|
2617
2623
|
"div",
|
|
2618
2624
|
{
|
|
2619
2625
|
className: `text-white rounded-xl cursor-pointer bg-gradient-to-r
|
|
2620
2626
|
${isDone ? "from-[rgba(76,175,80,0.1)] to-[rgba(46,125,50,0.1)] border border-solid border-x_green_dark" : "from-[rgba(54,129,198,0.1)] to-[rgba(43,74,157,0.1)] border border-solid border-x_blue_dark"}`,
|
|
2621
2627
|
children: /* @__PURE__ */ jsxs18("div", { className: "flex gap-2 items-center h-14 w-20 justify-center", children: [
|
|
2622
|
-
/* @__PURE__ */
|
|
2623
|
-
/* @__PURE__ */
|
|
2624
|
-
/* @__PURE__ */
|
|
2625
|
-
/* @__PURE__ */
|
|
2628
|
+
/* @__PURE__ */ jsx39(ArrowLeftIcon, {}),
|
|
2629
|
+
/* @__PURE__ */ jsx39("div", { className: "relative flex items-center justify-center w-9 h-9", children: isDone ? /* @__PURE__ */ jsx39("div", { className: "text-x_green w-5 h-5", children: /* @__PURE__ */ jsx39(CheckIcon, {}) }) : /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
2630
|
+
/* @__PURE__ */ jsx39("div", { className: "w-5 h-5", children: /* @__PURE__ */ jsx39(XSwapLogo, {}) }),
|
|
2631
|
+
/* @__PURE__ */ jsx39("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ jsx39(CircularProgressIcon, {}) })
|
|
2626
2632
|
] }) })
|
|
2627
2633
|
] })
|
|
2628
2634
|
}
|
|
@@ -2657,14 +2663,14 @@ historyElement.setAttribute(
|
|
|
2657
2663
|
document.body.appendChild(historyElement);
|
|
2658
2664
|
var txHistoryButtonRoot = createRoot2(historyElement);
|
|
2659
2665
|
var renderTxHistoryButtons = () => {
|
|
2660
|
-
const buttons = renderedTransactions.map((item) => /* @__PURE__ */
|
|
2666
|
+
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ jsx39(TxHistoryButton, { transaction: item }, item.txHash));
|
|
2661
2667
|
txHistoryButtonRoot.render(buttons);
|
|
2662
2668
|
};
|
|
2663
2669
|
|
|
2664
2670
|
// src/components/Skeleton/index.tsx
|
|
2665
|
-
import { jsx as
|
|
2671
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
2666
2672
|
var Skeleton = ({ width, height }) => {
|
|
2667
|
-
return /* @__PURE__ */
|
|
2673
|
+
return /* @__PURE__ */ jsx40("div", { className: `bg-current rounded animate-pulse ${width} ${height}` });
|
|
2668
2674
|
};
|
|
2669
2675
|
export {
|
|
2670
2676
|
ADDRESSES,
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
type?: "submit" | "reset" | "button";
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export const Button: FC<Props> = ({ children, onClick, type, disabled }) => {
|
|
10
|
+
return (
|
|
11
|
+
<button
|
|
12
|
+
className="text-white border-none rounded-2xl text-xl py-4 cursor-pointer w-full bg-gradient-to-r from-[#3681c6] to-[#2b4a9d] disabled:opacity-25"
|
|
13
|
+
onClick={onClick}
|
|
14
|
+
type={type}
|
|
15
|
+
disabled={disabled}
|
|
16
|
+
>
|
|
17
|
+
{children}
|
|
18
|
+
</button>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -18,6 +18,7 @@ import { SwapPanel } from "./SwapPanel";
|
|
|
18
18
|
import { ErrorField } from "./ErrorField";
|
|
19
19
|
import { Description } from "./Description";
|
|
20
20
|
import { DEFAULT_SOURCE_CHAIN_ID } from "@src/constants";
|
|
21
|
+
import { Button } from "./Button";
|
|
21
22
|
|
|
22
23
|
export const Form = ({
|
|
23
24
|
dstChainId,
|
|
@@ -233,21 +234,19 @@ export const Form = ({
|
|
|
233
234
|
setFeesDetailsShown={setFeesDetailsShown}
|
|
234
235
|
/>
|
|
235
236
|
{formError.length > 0 && <ErrorField error={formError} />}
|
|
236
|
-
{
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
onClick={handleSwitchChain}
|
|
241
|
-
>
|
|
237
|
+
{signer &&
|
|
238
|
+
srcChain &&
|
|
239
|
+
srcChain.chainId !== account.chainId?.toString() ? (
|
|
240
|
+
<Button type="button" onClick={handleSwitchChain}>
|
|
242
241
|
Switch chain
|
|
243
|
-
</
|
|
242
|
+
</Button>
|
|
244
243
|
) : (
|
|
245
|
-
<
|
|
244
|
+
<Button
|
|
246
245
|
type="submit"
|
|
247
246
|
disabled={!signer || !route || isGettingRoute}
|
|
248
247
|
>
|
|
249
248
|
Submit
|
|
250
|
-
</
|
|
249
|
+
</Button>
|
|
251
250
|
)}
|
|
252
251
|
</div>
|
|
253
252
|
)}
|
|
@@ -8,6 +8,8 @@ import { Chain, ContractCall, Route } from "@src/models";
|
|
|
8
8
|
import { CloseIcon } from "@src/components/icons/CloseIcon";
|
|
9
9
|
import { Form } from "./Form";
|
|
10
10
|
import { ChainlinkCCIPIcon, XSwapBadgeIcon } from "../icons";
|
|
11
|
+
import { version } from "../../../package.json";
|
|
12
|
+
import xswapConfig from "../../../xswap.config";
|
|
11
13
|
|
|
12
14
|
export type TxConfigFormProps = {
|
|
13
15
|
dstChainId: string;
|
|
@@ -46,34 +48,34 @@ const TxConfigForm = ({
|
|
|
46
48
|
return (
|
|
47
49
|
<WagmiProvider config={wagmiConfig}>
|
|
48
50
|
<QueryClientProvider client={queryClient}>
|
|
49
|
-
<div
|
|
50
|
-
className="top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10"
|
|
51
|
-
onClick={onBackdropClick}
|
|
52
|
-
>
|
|
53
|
-
<div className="relative bg-black rounded-3xl w-lg overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]">
|
|
54
|
-
<Form
|
|
55
|
-
dstChainId={dstChainId}
|
|
56
|
-
dstTokenAddr={dstTokenAddr}
|
|
57
|
-
customContractCalls={customContractCalls}
|
|
58
|
-
desc={desc}
|
|
59
|
-
supportedChains={supportedChains}
|
|
60
|
-
onSubmit={onSubmit}
|
|
61
|
-
/>
|
|
62
51
|
<div
|
|
63
|
-
className="
|
|
64
|
-
onClick={
|
|
52
|
+
className="top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10"
|
|
53
|
+
onClick={onBackdropClick}
|
|
65
54
|
>
|
|
66
|
-
<
|
|
67
|
-
|
|
55
|
+
<div className="relative bg-black rounded-3xl w-lg overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]">
|
|
56
|
+
<Form
|
|
57
|
+
dstChainId={dstChainId}
|
|
58
|
+
dstTokenAddr={dstTokenAddr}
|
|
59
|
+
customContractCalls={customContractCalls}
|
|
60
|
+
desc={desc}
|
|
61
|
+
supportedChains={supportedChains}
|
|
62
|
+
onSubmit={onSubmit}
|
|
63
|
+
/>
|
|
64
|
+
<div
|
|
65
|
+
className="absolute top-7 right-4 cursor-pointer text-white"
|
|
66
|
+
onClick={onClose}
|
|
67
|
+
>
|
|
68
|
+
<CloseIcon />
|
|
69
|
+
</div>
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
<div className="swappage__poweredby">
|
|
72
|
+
<span>Powered by</span>
|
|
73
|
+
<XSwapBadgeIcon />
|
|
74
|
+
<span>✕</span>
|
|
75
|
+
<ChainlinkCCIPIcon />
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
74
78
|
</div>
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
79
|
</QueryClientProvider>
|
|
78
80
|
</WagmiProvider>
|
|
79
81
|
);
|
|
@@ -88,7 +90,7 @@ export const openTxConfigForm = async ({
|
|
|
88
90
|
}: TxConfigFormProps): Promise<Route> => {
|
|
89
91
|
try {
|
|
90
92
|
return await new Promise((resolve) => {
|
|
91
|
-
|
|
93
|
+
xswapRoot.render(
|
|
92
94
|
<TxConfigForm
|
|
93
95
|
dstChainId={dstChainId}
|
|
94
96
|
dstTokenAddr={dstTokenAddr}
|
|
@@ -97,10 +99,10 @@ export const openTxConfigForm = async ({
|
|
|
97
99
|
supportedChains={supportedChains}
|
|
98
100
|
onSubmit={(route) => {
|
|
99
101
|
resolve(route);
|
|
100
|
-
|
|
102
|
+
xswapRoot.render("");
|
|
101
103
|
}}
|
|
102
104
|
onClose={() => {
|
|
103
|
-
|
|
105
|
+
xswapRoot.render("");
|
|
104
106
|
}}
|
|
105
107
|
/>,
|
|
106
108
|
);
|
|
@@ -111,10 +113,16 @@ export const openTxConfigForm = async ({
|
|
|
111
113
|
};
|
|
112
114
|
|
|
113
115
|
// skip on server-side integrations
|
|
114
|
-
let
|
|
116
|
+
let xswapRoot: Root;
|
|
115
117
|
if (typeof document !== "undefined") {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
const xswapStyleElement = document.createElement("link");
|
|
119
|
+
xswapStyleElement.rel = "stylesheet";
|
|
120
|
+
xswapStyleElement.type = "text/css";
|
|
121
|
+
xswapStyleElement.href = `${xswapConfig.apiUrl}/sdk/css/${version}`;
|
|
122
|
+
document.head.appendChild(xswapStyleElement);
|
|
123
|
+
|
|
124
|
+
const xswapModalElement = document.createElement("div");
|
|
125
|
+
xswapModalElement.setAttribute("id", "xswap-modal");
|
|
126
|
+
document.body.appendChild(xswapModalElement);
|
|
127
|
+
xswapRoot = createRoot(xswapModalElement);
|
|
120
128
|
}
|
|
@@ -24,10 +24,6 @@
|
|
|
24
24
|
border-radius: 4px;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
button {
|
|
28
|
-
@apply text-white border-none rounded-2xl text-xl py-4 cursor-pointer w-full bg-gradient-to-r from-[#3681c6] to-[#2b4a9d] disabled:opacity-25;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
27
|
.globalBorder {
|
|
32
28
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
33
29
|
}
|