@xswap-link/sdk 0.3.2 → 0.3.4
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 +14 -0
- package/dist/index.css +1 -1209
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.global.js +642 -0
- package/dist/index.js +432 -476
- package/dist/index.mjs +467 -511
- package/package.json +11 -4
- package/src/components/TxConfigForm/BalanceComponent.tsx +3 -2
- package/src/components/TxConfigForm/ConfirmationView/ErrorView.tsx +38 -0
- package/src/components/TxConfigForm/ConfirmationView/SuccessView.tsx +159 -0
- package/src/components/TxConfigForm/ConfirmationView/index.tsx +149 -0
- package/src/components/TxConfigForm/ConnectWalletPrompt.tsx +21 -0
- package/src/components/TxConfigForm/Form.tsx +83 -432
- package/src/components/TxConfigForm/index.tsx +6 -7
- package/src/components/global.css +0 -1
- package/src/constants/index.ts +1 -0
- package/src/models/payloads/GetSwapTxPayload.ts +1 -1
- package/src/services/api.ts +6 -1
- package/src/services/integrations/transactions.ts +4 -4
- package/src/utils/numbers.ts +1 -1
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useDebounce.tsx +0 -21
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ var xswap_config_default = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
// package.json
|
|
26
|
-
var version = "0.3.
|
|
26
|
+
var version = "0.3.4";
|
|
27
27
|
|
|
28
28
|
// src/components/WaitingForInit/index.tsx
|
|
29
29
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -145,10 +145,11 @@ async function _sendRequest(urlPath, options) {
|
|
|
145
145
|
}
|
|
146
146
|
return response.json();
|
|
147
147
|
}
|
|
148
|
-
async function getRoute(payload) {
|
|
148
|
+
async function getRoute(payload, abortSignal) {
|
|
149
149
|
return _sendRequest("/route", {
|
|
150
150
|
method: "POST",
|
|
151
|
-
body: JSON.stringify(payload)
|
|
151
|
+
body: JSON.stringify(payload),
|
|
152
|
+
signal: abortSignal
|
|
152
153
|
});
|
|
153
154
|
}
|
|
154
155
|
async function getChains(ecosystem) {
|
|
@@ -557,6 +558,7 @@ var MINIMUM_DISPLAYED_TOKEN_AMOUNT = 1e-4;
|
|
|
557
558
|
var DEFAULT_SOURCE_CHAIN_ID = "1";
|
|
558
559
|
var CCIP_EXPLORER = "https://ccip.chain.link/";
|
|
559
560
|
var TX_RECEIPT_STATUS_LIFETIME = 6e4;
|
|
561
|
+
var DEFAULT_REQUEST_ABORT_MSG = "Request deprecated";
|
|
560
562
|
var MSG_SENT_EVENT_SIG = "MessageSent(bytes32,uint64,address,bytes,address,uint256,uint256,address,uint256)";
|
|
561
563
|
var MSG_SENT_EVENT_ABI = [
|
|
562
564
|
"event MessageSent(bytes32 indexed messageId, uint64 indexed destinationChainSelector, address indexed sender, bytes data, address token, uint256 tokenAmount, uint256 valueForInstantCcipRecieve, address transferedToken, uint256 transferedTokenAmount)"
|
|
@@ -568,17 +570,6 @@ var MSG_RECEIVED_EVENT_ABI = [
|
|
|
568
570
|
|
|
569
571
|
// src/utils/contracts.ts
|
|
570
572
|
var IERC20 = new ethers.utils.Interface(ERC20Abi);
|
|
571
|
-
var getAllowanceOf = async (token, wallet, spender, rpcUrl) => {
|
|
572
|
-
const provider = ethers.getDefaultProvider(rpcUrl);
|
|
573
|
-
if (token === ethers.constants.AddressZero) {
|
|
574
|
-
return ethers.constants.MaxUint256.toString();
|
|
575
|
-
}
|
|
576
|
-
const contract = new ethers.Contract(token, ERC20Abi, provider);
|
|
577
|
-
return ethers.utils.formatUnits(
|
|
578
|
-
await contract.allowance(wallet, spender),
|
|
579
|
-
await contract.decimals()
|
|
580
|
-
);
|
|
581
|
-
};
|
|
582
573
|
var getBalances = async (chain, wallet) => {
|
|
583
574
|
return {
|
|
584
575
|
...await getNativeBalance(chain, wallet),
|
|
@@ -631,7 +622,7 @@ var getErc20Balances = async (chain, wallet) => {
|
|
|
631
622
|
};
|
|
632
623
|
|
|
633
624
|
// src/utils/numbers.ts
|
|
634
|
-
import
|
|
625
|
+
import BigNumberJS from "bignumber.js";
|
|
635
626
|
import { BigNumber as BigNumber2, utils } from "ethers";
|
|
636
627
|
var safeBigNumberFrom = (value) => {
|
|
637
628
|
BigNumberJS.config({ DECIMAL_PLACES: 0 });
|
|
@@ -746,7 +737,7 @@ var getDate = (blockTimestamp) => {
|
|
|
746
737
|
};
|
|
747
738
|
|
|
748
739
|
// src/services/integrations/monitoring.ts
|
|
749
|
-
import { ethers as
|
|
740
|
+
import { ethers as ethers7 } from "ethers";
|
|
750
741
|
|
|
751
742
|
// src/components/Alert/index.tsx
|
|
752
743
|
import { jsxs } from "react/jsx-runtime";
|
|
@@ -758,7 +749,7 @@ var Alert = ({ desc }) => {
|
|
|
758
749
|
};
|
|
759
750
|
|
|
760
751
|
// src/components/TxConfigForm/index.tsx
|
|
761
|
-
import { useMemo as
|
|
752
|
+
import { useMemo as useMemo9, useState as useState9 } from "react";
|
|
762
753
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
763
754
|
import { WagmiProvider } from "wagmi";
|
|
764
755
|
|
|
@@ -1354,33 +1345,16 @@ var PoweredBy = () => {
|
|
|
1354
1345
|
// src/components/TxConfigForm/Form.tsx
|
|
1355
1346
|
import {
|
|
1356
1347
|
useCallback as useCallback3,
|
|
1357
|
-
useEffect as
|
|
1358
|
-
useMemo as
|
|
1359
|
-
useRef as
|
|
1360
|
-
useState as
|
|
1348
|
+
useEffect as useEffect7,
|
|
1349
|
+
useMemo as useMemo8,
|
|
1350
|
+
useRef as useRef2,
|
|
1351
|
+
useState as useState8
|
|
1361
1352
|
} from "react";
|
|
1362
|
-
import { ethers as
|
|
1353
|
+
import { ethers as ethers5 } from "ethers";
|
|
1363
1354
|
import { useAccount, useSendTransaction, useSwitchChain } from "wagmi";
|
|
1364
1355
|
|
|
1365
|
-
// src/hooks/useDebounce.tsx
|
|
1366
|
-
import { useEffect, useRef, useState } from "react";
|
|
1367
|
-
var useDebounce = (value, delay) => {
|
|
1368
|
-
const timeoutRef = useRef(null);
|
|
1369
|
-
useEffect(() => {
|
|
1370
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1371
|
-
timeoutRef.current = setTimeout(() => {
|
|
1372
|
-
setValue(value);
|
|
1373
|
-
}, delay);
|
|
1374
|
-
return () => {
|
|
1375
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1376
|
-
};
|
|
1377
|
-
}, [value, delay]);
|
|
1378
|
-
const [debouncedValue, setValue] = useState(value);
|
|
1379
|
-
return debouncedValue;
|
|
1380
|
-
};
|
|
1381
|
-
|
|
1382
1356
|
// src/components/TxConfigForm/History.tsx
|
|
1383
|
-
import { useCallback as useCallback2, useEffect
|
|
1357
|
+
import { useCallback as useCallback2, useEffect, useState } from "react";
|
|
1384
1358
|
import BigNumberJS2 from "bignumber.js";
|
|
1385
1359
|
|
|
1386
1360
|
// src/components/TxConfigForm/HistoryCard.tsx
|
|
@@ -1515,8 +1489,8 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1515
1489
|
// src/components/TxConfigForm/History.tsx
|
|
1516
1490
|
import { jsx as jsx30, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1517
1491
|
var History = ({ signer, supportedChains }) => {
|
|
1518
|
-
const [fetchedHistory, setFetchedHistory] =
|
|
1519
|
-
const [historyLoadedOnce, setHistoryLoadedOnce] =
|
|
1492
|
+
const [fetchedHistory, setFetchedHistory] = useState();
|
|
1493
|
+
const [historyLoadedOnce, setHistoryLoadedOnce] = useState(false);
|
|
1520
1494
|
const fetchHistory = useCallback2(async () => {
|
|
1521
1495
|
if (signer) {
|
|
1522
1496
|
const downloadedHistory = await getHistory({ walletAddress: signer });
|
|
@@ -1577,7 +1551,7 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1577
1551
|
}
|
|
1578
1552
|
}
|
|
1579
1553
|
}, [signer, getHistory]);
|
|
1580
|
-
|
|
1554
|
+
useEffect(() => {
|
|
1581
1555
|
if (!historyLoadedOnce) fetchHistory();
|
|
1582
1556
|
const timer = setInterval(() => {
|
|
1583
1557
|
fetchHistory();
|
|
@@ -1634,7 +1608,7 @@ var TopBar = ({
|
|
|
1634
1608
|
};
|
|
1635
1609
|
|
|
1636
1610
|
// src/components/TxConfigForm/Settings.tsx
|
|
1637
|
-
import { useState as
|
|
1611
|
+
import { useState as useState2, useEffect as useEffect2 } from "react";
|
|
1638
1612
|
import { jsx as jsx32, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1639
1613
|
var Settings = ({
|
|
1640
1614
|
setSlippage,
|
|
@@ -1643,9 +1617,9 @@ var Settings = ({
|
|
|
1643
1617
|
expressChecked,
|
|
1644
1618
|
setExpressChecked
|
|
1645
1619
|
}) => {
|
|
1646
|
-
const [slippageActivePresetIndex, setSlippageActivePresetIndex] =
|
|
1647
|
-
const [usingSlippageInput, setUsingSlippageInput] =
|
|
1648
|
-
|
|
1620
|
+
const [slippageActivePresetIndex, setSlippageActivePresetIndex] = useState2(1);
|
|
1621
|
+
const [usingSlippageInput, setUsingSlippageInput] = useState2(false);
|
|
1622
|
+
useEffect2(() => {
|
|
1649
1623
|
if (!usingSlippageInput) {
|
|
1650
1624
|
setSlippage(
|
|
1651
1625
|
SLIPPAGE_PRESETS[slippageActivePresetIndex]?.toString() || "1.5"
|
|
@@ -1834,10 +1808,10 @@ var FeesDetails = ({
|
|
|
1834
1808
|
};
|
|
1835
1809
|
|
|
1836
1810
|
// src/components/TxConfigForm/Summary.tsx
|
|
1837
|
-
import { useEffect as
|
|
1811
|
+
import { useEffect as useEffect4, useMemo as useMemo2, useState as useState4 } from "react";
|
|
1838
1812
|
|
|
1839
1813
|
// src/components/TxConfigForm/UsdPrice.tsx
|
|
1840
|
-
import { useEffect as
|
|
1814
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
1841
1815
|
import { Fragment as Fragment3, jsx as jsx34 } from "react/jsx-runtime";
|
|
1842
1816
|
var UsdPrice = ({
|
|
1843
1817
|
prices,
|
|
@@ -1845,8 +1819,8 @@ var UsdPrice = ({
|
|
|
1845
1819
|
amount = "0",
|
|
1846
1820
|
loading = false
|
|
1847
1821
|
}) => {
|
|
1848
|
-
const [usdPrice, setUsdPrice] =
|
|
1849
|
-
|
|
1822
|
+
const [usdPrice, setUsdPrice] = useState3("0.00");
|
|
1823
|
+
useEffect3(() => {
|
|
1850
1824
|
if (token && prices && prices[token.address]) {
|
|
1851
1825
|
const newUsdPrice = (Number(amount) * Number(prices[token.address.toLowerCase()])).toFixed(2);
|
|
1852
1826
|
setUsdPrice(newUsdPrice);
|
|
@@ -1875,7 +1849,7 @@ var Summary = ({
|
|
|
1875
1849
|
dstToken,
|
|
1876
1850
|
dstChain
|
|
1877
1851
|
}) => {
|
|
1878
|
-
const [prices, setPrices] =
|
|
1852
|
+
const [prices, setPrices] = useState4();
|
|
1879
1853
|
const amountReadable = useMemo2(
|
|
1880
1854
|
() => weiToHumanReadable({
|
|
1881
1855
|
amount: route?.estAmountOut || "0",
|
|
@@ -1884,7 +1858,7 @@ var Summary = ({
|
|
|
1884
1858
|
}),
|
|
1885
1859
|
[route, dstToken]
|
|
1886
1860
|
);
|
|
1887
|
-
|
|
1861
|
+
useEffect4(() => {
|
|
1888
1862
|
if (dstChain) {
|
|
1889
1863
|
getPrices({ chainId: dstChain.chainId, currency: "USD" }).then(
|
|
1890
1864
|
(prices2) => setPrices(prices2)
|
|
@@ -1942,10 +1916,10 @@ var Summary = ({
|
|
|
1942
1916
|
};
|
|
1943
1917
|
|
|
1944
1918
|
// src/components/TxConfigForm/SwapPanel.tsx
|
|
1945
|
-
import { useState as
|
|
1919
|
+
import { useState as useState6, useEffect as useEffect5, useRef, useMemo as useMemo5 } from "react";
|
|
1946
1920
|
|
|
1947
1921
|
// src/components/TxConfigForm/TokenPicker.tsx
|
|
1948
|
-
import { useState as
|
|
1922
|
+
import { useState as useState5, useMemo as useMemo3 } from "react";
|
|
1949
1923
|
import { createPortal } from "react-dom";
|
|
1950
1924
|
import { Fragment as Fragment4, jsx as jsx37, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1951
1925
|
var TokenPicker = ({
|
|
@@ -1956,7 +1930,7 @@ var TokenPicker = ({
|
|
|
1956
1930
|
signer,
|
|
1957
1931
|
balances
|
|
1958
1932
|
}) => {
|
|
1959
|
-
const [searchValue, setSearchValue] =
|
|
1933
|
+
const [searchValue, setSearchValue] = useState5("");
|
|
1960
1934
|
const onBackdropClick = (e) => {
|
|
1961
1935
|
e.stopPropagation();
|
|
1962
1936
|
e.nativeEvent.stopImmediatePropagation();
|
|
@@ -2085,8 +2059,8 @@ var ChainListElement = ({
|
|
|
2085
2059
|
};
|
|
2086
2060
|
|
|
2087
2061
|
// src/components/TxConfigForm/BalanceComponent.tsx
|
|
2088
|
-
import { useMemo as useMemo4 } from "react";
|
|
2089
2062
|
import BigNumber3 from "bignumber.js";
|
|
2063
|
+
import { useMemo as useMemo4 } from "react";
|
|
2090
2064
|
import { Fragment as Fragment5, jsx as jsx39, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2091
2065
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
2092
2066
|
const balanceText = useMemo4(() => {
|
|
@@ -2133,10 +2107,10 @@ var SwapPanel = ({
|
|
|
2133
2107
|
prices,
|
|
2134
2108
|
supportedChains
|
|
2135
2109
|
}) => {
|
|
2136
|
-
const [chainListShown, setChainListShown] =
|
|
2137
|
-
const [tokenListShown, setTokenListShown] =
|
|
2138
|
-
const listRef =
|
|
2139
|
-
const buttonRef =
|
|
2110
|
+
const [chainListShown, setChainListShown] = useState6(false);
|
|
2111
|
+
const [tokenListShown, setTokenListShown] = useState6(false);
|
|
2112
|
+
const listRef = useRef(null);
|
|
2113
|
+
const buttonRef = useRef(null);
|
|
2140
2114
|
const handleClickOutside = (event) => {
|
|
2141
2115
|
if (listRef.current && buttonRef.current) {
|
|
2142
2116
|
const listElement = listRef.current;
|
|
@@ -2155,7 +2129,7 @@ var SwapPanel = ({
|
|
|
2155
2129
|
})
|
|
2156
2130
|
);
|
|
2157
2131
|
};
|
|
2158
|
-
|
|
2132
|
+
useEffect5(() => {
|
|
2159
2133
|
if (chainListShown) {
|
|
2160
2134
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2161
2135
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
@@ -2319,16 +2293,50 @@ var Button = ({ children, onClick, type, disabled }) => {
|
|
|
2319
2293
|
// src/components/TxConfigForm/Form.tsx
|
|
2320
2294
|
import { getChainId, waitForTransactionReceipt } from "wagmi/actions";
|
|
2321
2295
|
|
|
2322
|
-
// src/components/TxConfigForm/
|
|
2323
|
-
import {
|
|
2296
|
+
// src/components/TxConfigForm/ConfirmationView/index.tsx
|
|
2297
|
+
import { ethers as ethers4 } from "ethers";
|
|
2298
|
+
|
|
2299
|
+
// src/components/Spinner/index.tsx
|
|
2324
2300
|
import { jsx as jsx44, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2301
|
+
var Spinner = ({ width, height }) => {
|
|
2302
|
+
return /* @__PURE__ */ jsx44("div", { role: "status", children: /* @__PURE__ */ jsxs19(
|
|
2303
|
+
"svg",
|
|
2304
|
+
{
|
|
2305
|
+
"aria-hidden": "true",
|
|
2306
|
+
className: `xpay-w-${width} xpay-h-${height} xpay-text-gray-200 xpay-animate-spin dark:xpay-text-gray-600 xpay-fill-[rgba(54,129,198,1)]`,
|
|
2307
|
+
viewBox: "0 0 100 101",
|
|
2308
|
+
fill: "none",
|
|
2309
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2310
|
+
children: [
|
|
2311
|
+
/* @__PURE__ */ jsx44(
|
|
2312
|
+
"path",
|
|
2313
|
+
{
|
|
2314
|
+
d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",
|
|
2315
|
+
fill: "currentColor"
|
|
2316
|
+
}
|
|
2317
|
+
),
|
|
2318
|
+
/* @__PURE__ */ jsx44(
|
|
2319
|
+
"path",
|
|
2320
|
+
{
|
|
2321
|
+
d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",
|
|
2322
|
+
fill: "currentFill"
|
|
2323
|
+
}
|
|
2324
|
+
)
|
|
2325
|
+
]
|
|
2326
|
+
}
|
|
2327
|
+
) });
|
|
2328
|
+
};
|
|
2329
|
+
|
|
2330
|
+
// src/components/TxConfigForm/ConfirmationAmount.tsx
|
|
2331
|
+
import { useEffect as useEffect6, useMemo as useMemo6, useState as useState7 } from "react";
|
|
2332
|
+
import { jsx as jsx45, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2325
2333
|
var ConfirmationAmount = ({
|
|
2326
2334
|
amount,
|
|
2327
2335
|
token,
|
|
2328
2336
|
chain,
|
|
2329
2337
|
type
|
|
2330
2338
|
}) => {
|
|
2331
|
-
const [prices, setPrices] =
|
|
2339
|
+
const [prices, setPrices] = useState7();
|
|
2332
2340
|
const amountReadable = useMemo6(() => {
|
|
2333
2341
|
return weiToHumanReadable({
|
|
2334
2342
|
amount: amount || "0",
|
|
@@ -2336,24 +2344,24 @@ var ConfirmationAmount = ({
|
|
|
2336
2344
|
precisionFractionalPlaces: 8
|
|
2337
2345
|
});
|
|
2338
2346
|
}, [amount, token]);
|
|
2339
|
-
|
|
2347
|
+
useEffect6(() => {
|
|
2340
2348
|
if (chain) {
|
|
2341
2349
|
getPrices({ chainId: chain.chainId, currency: "USD" }).then(
|
|
2342
2350
|
(prices2) => setPrices(prices2)
|
|
2343
2351
|
);
|
|
2344
2352
|
}
|
|
2345
2353
|
}, [chain]);
|
|
2346
|
-
return /* @__PURE__ */
|
|
2347
|
-
/* @__PURE__ */
|
|
2348
|
-
/* @__PURE__ */
|
|
2349
|
-
/* @__PURE__ */
|
|
2354
|
+
return /* @__PURE__ */ jsx45("div", { className: "xpay-flex xpay-flex-col xpay-globalBorder xpay-rounded-xl xpay-bg-gradient-to-r xpay-from-x_blue_300_20 xpay-to-x_blue_400_20 xpay-p-4 xpay-relative", children: /* @__PURE__ */ jsxs20("div", { className: "xpay-flex xpay-justify-between", children: [
|
|
2355
|
+
/* @__PURE__ */ jsxs20("div", { className: "xpay-flex xpay-flex-col xpay-gap-1", children: [
|
|
2356
|
+
/* @__PURE__ */ jsx45("p", { className: "xpay-text-white xpay-opacity-60 xpay-text-xs sm:xpay-text-sm xpay-font-medium", children: type === "src" ? "You pay" : "You receive" }),
|
|
2357
|
+
/* @__PURE__ */ jsx45(
|
|
2350
2358
|
"div",
|
|
2351
2359
|
{
|
|
2352
2360
|
className: `xpay-flex xpay-gap-2 xpay-items-center xpay-text-xl sm:xpay-text-3xl ${type === "dst" ? "xpay-text-[rgba(54,129,198,1)]" : "xpay-text-white"}`,
|
|
2353
2361
|
children: amountReadable
|
|
2354
2362
|
}
|
|
2355
2363
|
),
|
|
2356
|
-
/* @__PURE__ */
|
|
2364
|
+
/* @__PURE__ */ jsx45(
|
|
2357
2365
|
UsdPrice,
|
|
2358
2366
|
{
|
|
2359
2367
|
prices,
|
|
@@ -2363,19 +2371,19 @@ var ConfirmationAmount = ({
|
|
|
2363
2371
|
}
|
|
2364
2372
|
)
|
|
2365
2373
|
] }),
|
|
2366
|
-
/* @__PURE__ */
|
|
2367
|
-
/* @__PURE__ */
|
|
2368
|
-
/* @__PURE__ */
|
|
2369
|
-
/* @__PURE__ */
|
|
2374
|
+
/* @__PURE__ */ jsxs20("div", { className: "xpay-flex xpay-gap-2 xpay-text-sm xpay-justify-center xpay-items-center", children: [
|
|
2375
|
+
/* @__PURE__ */ jsxs20("div", { className: "xpay-flex xpay-flex-col xpay-justify-center xpay-items-end xpay-gap-1", children: [
|
|
2376
|
+
/* @__PURE__ */ jsx45("p", { className: "xpay-text-base sm:xpay-text-xl", children: token?.name }),
|
|
2377
|
+
/* @__PURE__ */ jsx45("div", { className: "xpay-flex xpay-justify-center xpay-items-center xpay-gap-1", children: /* @__PURE__ */ jsx45("p", { className: "xpay-text-[rgba(255,255,255,0.6)] xpay-text-xs xpay-text-right", children: chain?.displayName }) })
|
|
2370
2378
|
] }),
|
|
2371
|
-
/* @__PURE__ */
|
|
2379
|
+
/* @__PURE__ */ jsx45("div", { className: "xpay-w-10 xpay-h-10", children: token?.image ? /* @__PURE__ */ jsx45(
|
|
2372
2380
|
"img",
|
|
2373
2381
|
{
|
|
2374
2382
|
className: "xpay-w-10 xpay-h-10",
|
|
2375
2383
|
src: token?.image,
|
|
2376
2384
|
alt: token?.name
|
|
2377
2385
|
}
|
|
2378
|
-
) : /* @__PURE__ */
|
|
2386
|
+
) : /* @__PURE__ */ jsx45(
|
|
2379
2387
|
UnknownTokenLogo,
|
|
2380
2388
|
{
|
|
2381
2389
|
tokenName: "?",
|
|
@@ -2386,39 +2394,227 @@ var ConfirmationAmount = ({
|
|
|
2386
2394
|
] }) });
|
|
2387
2395
|
};
|
|
2388
2396
|
|
|
2389
|
-
// src/components/
|
|
2390
|
-
import { jsx as
|
|
2391
|
-
var
|
|
2392
|
-
return /* @__PURE__ */
|
|
2393
|
-
"
|
|
2397
|
+
// src/components/TxConfigForm/ConfirmationView/ErrorView.tsx
|
|
2398
|
+
import { jsx as jsx46, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2399
|
+
var ErrorView = ({ txError, onClose }) => {
|
|
2400
|
+
return /* @__PURE__ */ jsxs21("div", { children: [
|
|
2401
|
+
/* @__PURE__ */ jsx46("div", { className: "xpay-flex xpay-w-full xpay-justify-end xpay-items-center xpay-mx-auto xpay-p-2", children: /* @__PURE__ */ jsx46("div", { className: "xpay-cursor-pointer xpay-text-white", onClick: onClose, children: /* @__PURE__ */ jsx46(CloseIcon, {}) }) }),
|
|
2402
|
+
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col xpay-w-full xpay-justify-center xpay-items-center xpay-mx-auto xpay-p-2 xpay-gap-4", children: [
|
|
2403
|
+
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46(ErrorIcon, {}) }),
|
|
2404
|
+
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col", children: [
|
|
2405
|
+
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46("p", { className: "xpay-text-2xl xpay-font-bold xpay-leading-8 xpay-text-center xpay-text-white", children: "Transaction error!" }) }),
|
|
2406
|
+
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46("p", { className: "xpay-text-sm xpay-text-center xpay-text-white xpay-opacity-50", children: parseWeb3Error(txError) }) })
|
|
2407
|
+
] })
|
|
2408
|
+
] })
|
|
2409
|
+
] });
|
|
2410
|
+
};
|
|
2411
|
+
|
|
2412
|
+
// src/components/TxConfigForm/ConfirmationView/SuccessView.tsx
|
|
2413
|
+
import { useMemo as useMemo7 } from "react";
|
|
2414
|
+
import { Fragment as Fragment6, jsx as jsx47, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2415
|
+
var SuccessView = ({
|
|
2416
|
+
onClose,
|
|
2417
|
+
srcChain,
|
|
2418
|
+
dstChain,
|
|
2419
|
+
isExpressDelivery,
|
|
2420
|
+
srcToken,
|
|
2421
|
+
amount,
|
|
2422
|
+
dstDisplayToken,
|
|
2423
|
+
dstToken,
|
|
2424
|
+
route,
|
|
2425
|
+
txSuccessHash,
|
|
2426
|
+
supportedChains
|
|
2427
|
+
}) => {
|
|
2428
|
+
const dstTokenToDisplay = useMemo7(() => {
|
|
2429
|
+
return dstDisplayToken ? dstDisplayToken : dstToken;
|
|
2430
|
+
}, [dstDisplayToken, dstToken]);
|
|
2431
|
+
return /* @__PURE__ */ jsxs22("div", { children: [
|
|
2432
|
+
/* @__PURE__ */ jsx47("div", { className: "xpay-flex xpay-w-full xpay-justify-end xpay-items-center xpay-mx-auto xpay-p-2", children: /* @__PURE__ */ jsx47("div", { className: "xpay-cursor-pointer xpay-text-white", onClick: onClose, children: /* @__PURE__ */ jsx47(CloseIcon, {}) }) }),
|
|
2433
|
+
/* @__PURE__ */ jsxs22("div", { className: "xpay-flex xpay-flex-col xpay-w-full xpay-justify-center xpay-items-center xpay-mx-auto xpay-p-2 xpay-gap-4", children: [
|
|
2434
|
+
/* @__PURE__ */ jsx47("div", { children: /* @__PURE__ */ jsx47(SuccessIcon, {}) }),
|
|
2435
|
+
/* @__PURE__ */ jsxs22("div", { className: "xpay-flex xpay-flex-col", children: [
|
|
2436
|
+
/* @__PURE__ */ jsx47("div", { children: /* @__PURE__ */ jsx47("p", { className: "xpay-text-2xl xpay-font-bold xpay-leading-8 xpay-text-center xpay-text-white", children: "Transaction success!" }) }),
|
|
2437
|
+
srcChain?.chainId !== dstChain?.chainId ? /* @__PURE__ */ jsx47("div", { children: /* @__PURE__ */ jsxs22("p", { className: "xpay-text-sm xpay-text-center xpay-text-white xpay-opacity-50", children: [
|
|
2438
|
+
"Approximated time of delivery:",
|
|
2439
|
+
" ",
|
|
2440
|
+
isExpressDelivery ? "30 seconds" : "30 minutes"
|
|
2441
|
+
] }) }) : /* @__PURE__ */ jsx47(Fragment6, {})
|
|
2442
|
+
] }),
|
|
2443
|
+
/* @__PURE__ */ jsxs22("div", { className: "xpay-flex xpay-gap-4 xpay-items-center", children: [
|
|
2444
|
+
/* @__PURE__ */ jsxs22("div", { className: "xpay-flex xpay-gap-2", children: [
|
|
2445
|
+
/* @__PURE__ */ jsx47("div", { className: "xpay-w-10 xpay-h-10", children: srcToken?.image ? /* @__PURE__ */ jsx47(
|
|
2446
|
+
"img",
|
|
2447
|
+
{
|
|
2448
|
+
className: "xpay-w-10 xpay-h-10",
|
|
2449
|
+
src: srcToken?.image,
|
|
2450
|
+
alt: srcToken?.name
|
|
2451
|
+
}
|
|
2452
|
+
) : /* @__PURE__ */ jsx47(
|
|
2453
|
+
UnknownTokenLogo,
|
|
2454
|
+
{
|
|
2455
|
+
tokenName: "?",
|
|
2456
|
+
className: "xpay-w-10 xpay-h-10"
|
|
2457
|
+
}
|
|
2458
|
+
) }),
|
|
2459
|
+
/* @__PURE__ */ jsxs22("div", { className: "xpay-flex xpay-flex-col xpay-items-start", children: [
|
|
2460
|
+
/* @__PURE__ */ jsx47("div", { className: "xpay-flex", children: `${amount} ${srcToken?.symbol}` }),
|
|
2461
|
+
/* @__PURE__ */ jsx47("div", { className: "xpay-text-sm xpay-text-center xpay-text-white xpay-opacity-50", children: srcChain?.displayName })
|
|
2462
|
+
] })
|
|
2463
|
+
] }),
|
|
2464
|
+
/* @__PURE__ */ jsx47("div", { className: "xpay-w-3.5 xpay-h-3.5", children: /* @__PURE__ */ jsx47(ArrowRightIcon, {}) }),
|
|
2465
|
+
/* @__PURE__ */ jsxs22("div", { className: "xpay-flex xpay-gap-2", children: [
|
|
2466
|
+
/* @__PURE__ */ jsx47("div", { className: "xpay-w-10 xpay-h-10", children: dstTokenToDisplay?.image ? /* @__PURE__ */ jsx47(
|
|
2467
|
+
"img",
|
|
2468
|
+
{
|
|
2469
|
+
className: "xpay-w-10 xpay-h-10",
|
|
2470
|
+
src: dstTokenToDisplay?.image,
|
|
2471
|
+
alt: dstTokenToDisplay?.name
|
|
2472
|
+
}
|
|
2473
|
+
) : /* @__PURE__ */ jsx47(
|
|
2474
|
+
UnknownTokenLogo,
|
|
2475
|
+
{
|
|
2476
|
+
tokenName: "?",
|
|
2477
|
+
className: "xpay-w-10 xpay-h-10"
|
|
2478
|
+
}
|
|
2479
|
+
) }),
|
|
2480
|
+
/* @__PURE__ */ jsxs22("div", { className: "xpay-flex xpay-flex-col xpay-items-start", children: [
|
|
2481
|
+
/* @__PURE__ */ jsxs22("div", { className: "xpay-flex", children: [
|
|
2482
|
+
weiToHumanReadable({
|
|
2483
|
+
amount: route?.estAmountOut || "0",
|
|
2484
|
+
decimals: dstTokenToDisplay?.decimals || 18,
|
|
2485
|
+
precisionFractionalPlaces: 4
|
|
2486
|
+
}),
|
|
2487
|
+
" ",
|
|
2488
|
+
dstTokenToDisplay?.symbol
|
|
2489
|
+
] }),
|
|
2490
|
+
/* @__PURE__ */ jsx47("div", { className: "xpay-text-sm xpay-text-center xpay-text-white xpay-opacity-50", children: dstChain?.displayName })
|
|
2491
|
+
] })
|
|
2492
|
+
] })
|
|
2493
|
+
] }),
|
|
2494
|
+
/* @__PURE__ */ jsx47("div", { children: /* @__PURE__ */ jsxs22(
|
|
2495
|
+
"a",
|
|
2496
|
+
{
|
|
2497
|
+
href: srcChain?.chainId !== dstChain?.chainId ? `${CCIP_EXPLORER}/tx/${txSuccessHash}` : `${supportedChains.find(
|
|
2498
|
+
(chain) => chain.chainId === srcChain?.chainId
|
|
2499
|
+
)?.transactionExplorer}/${txSuccessHash}`,
|
|
2500
|
+
target: "_blank",
|
|
2501
|
+
rel: "noreferrer",
|
|
2502
|
+
className: "xpay-flex xpay-items-center xpay-gap-2 xpay-font-bold xpay-no-underline xpay-cursor-pointer xpay-text-center",
|
|
2503
|
+
"aria-label": "Show the transaction in the chain explorer",
|
|
2504
|
+
children: [
|
|
2505
|
+
/* @__PURE__ */ jsx47("p", { className: "xpay-bg-gradient-to-r xpay-from-x_blue_light xpay-to-x_blue_dark xpay-bg-clip-text xpay-text-transparent xpay-underline", children: "View details on Explorer" }),
|
|
2506
|
+
/* @__PURE__ */ jsx47("div", { className: "xpay-w-3.5 xpay-h-3.5 xpay-bg-gradient-to-r xpay-text-x_blue_dark", children: /* @__PURE__ */ jsx47(ArrowUpRightIcon, {}) })
|
|
2507
|
+
]
|
|
2508
|
+
}
|
|
2509
|
+
) })
|
|
2510
|
+
] })
|
|
2511
|
+
] });
|
|
2512
|
+
};
|
|
2513
|
+
|
|
2514
|
+
// src/components/TxConfigForm/ConfirmationView/index.tsx
|
|
2515
|
+
import { Fragment as Fragment7, jsx as jsx48, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2516
|
+
var ConfirmationView = ({
|
|
2517
|
+
txError,
|
|
2518
|
+
onClose,
|
|
2519
|
+
txSuccessHash,
|
|
2520
|
+
srcChain,
|
|
2521
|
+
dstChain,
|
|
2522
|
+
isExpressDelivery,
|
|
2523
|
+
srcToken,
|
|
2524
|
+
amount,
|
|
2525
|
+
dstDisplayToken,
|
|
2526
|
+
dstToken,
|
|
2527
|
+
route,
|
|
2528
|
+
supportedChains,
|
|
2529
|
+
approveTxLoading,
|
|
2530
|
+
approveTxDone,
|
|
2531
|
+
txLoading
|
|
2532
|
+
}) => {
|
|
2533
|
+
return /* @__PURE__ */ jsx48("div", { className: "xpay-flex xpay-flex-col xpay-gap-2 xpay-z-10 xpay-my-0 xpay-p-2 md:xpay-p-4 xpay-rounded-3xl xpay-overflow-hidden xpay-font-light sm:xpay-w-x_desktop xpay-w-screen", children: txError ? /* @__PURE__ */ jsx48(ErrorView, { txError, onClose }) : txSuccessHash ? /* @__PURE__ */ jsx48(
|
|
2534
|
+
SuccessView,
|
|
2394
2535
|
{
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2536
|
+
onClose,
|
|
2537
|
+
isExpressDelivery,
|
|
2538
|
+
amount,
|
|
2539
|
+
supportedChains,
|
|
2540
|
+
txSuccessHash,
|
|
2541
|
+
srcChain,
|
|
2542
|
+
dstChain,
|
|
2543
|
+
srcToken,
|
|
2544
|
+
dstDisplayToken,
|
|
2545
|
+
dstToken,
|
|
2546
|
+
route
|
|
2547
|
+
}
|
|
2548
|
+
) : (
|
|
2549
|
+
// Tx Confirmation modal
|
|
2550
|
+
/* @__PURE__ */ jsxs23(Fragment7, { children: [
|
|
2551
|
+
/* @__PURE__ */ jsxs23("div", { className: "xpay-flex xpay-w-full xpay-justify-between xpay-items-center xpay-mx-auto xpay-p-2 xpay-font-light ", children: [
|
|
2552
|
+
/* @__PURE__ */ jsx48("p", { className: "xpay-text-white xpay-text-xl", children: "Confirmation" }),
|
|
2553
|
+
/* @__PURE__ */ jsx48("div", { className: "xpay-flex xpay-w-full xpay-justify-end xpay-items-center xpay-mx-auto xpay-p-2", children: /* @__PURE__ */ jsx48(
|
|
2554
|
+
"div",
|
|
2410
2555
|
{
|
|
2411
|
-
|
|
2412
|
-
|
|
2556
|
+
className: "xpay-cursor-pointer xpay-text-white",
|
|
2557
|
+
onClick: onClose,
|
|
2558
|
+
children: /* @__PURE__ */ jsx48(CloseIcon, {})
|
|
2413
2559
|
}
|
|
2414
|
-
)
|
|
2415
|
-
]
|
|
2416
|
-
|
|
2560
|
+
) })
|
|
2561
|
+
] }),
|
|
2562
|
+
/* @__PURE__ */ jsx48("div", { className: "xpay-flex xpay-flex-col xpay-gap-2", children: /* @__PURE__ */ jsx48(
|
|
2563
|
+
ConfirmationAmount,
|
|
2564
|
+
{
|
|
2565
|
+
amount: ethers4.utils.parseUnits(amount, srcToken?.decimals).toString(),
|
|
2566
|
+
chain: srcChain,
|
|
2567
|
+
token: srcToken,
|
|
2568
|
+
type: "src"
|
|
2569
|
+
}
|
|
2570
|
+
) }),
|
|
2571
|
+
/* @__PURE__ */ jsx48("div", { className: "xpay-flex xpay-justify-center xpay-globalBorder xpay-rounded-xl xpay-p-[5px] xpay--mt-7 xpay--mb-6 ", children: /* @__PURE__ */ jsx48("div", { className: "xpay-flex xpay-items-center xpay-justify-center xpay-rounded-lg xpay-w-8 xpay-h-8 xpay-bg-gradient-to-l xpay-from-[rgba(54,129,198,1)] xpay-to-[rgba(43,74,157,1)] ", children: /* @__PURE__ */ jsx48(ArrowDownIcon, {}) }) }),
|
|
2572
|
+
/* @__PURE__ */ jsx48("div", { className: "xpay-flex xpay-flex-col xpay-gap-2", children: /* @__PURE__ */ jsx48(
|
|
2573
|
+
ConfirmationAmount,
|
|
2574
|
+
{
|
|
2575
|
+
amount: route?.estAmountOut || "0",
|
|
2576
|
+
chain: dstChain,
|
|
2577
|
+
token: dstDisplayToken ? dstDisplayToken : dstToken,
|
|
2578
|
+
type: "dst"
|
|
2579
|
+
}
|
|
2580
|
+
) }),
|
|
2581
|
+
/* @__PURE__ */ jsxs23("div", { className: "xpay-flex xpay-flex-col xpay-globalBorder xpay-p-4 xpay-justify-center xpay-rounded-xl xpay-bg-[rgba(15,15,15,1)] xpay-relative", children: [
|
|
2582
|
+
route?.transactions.approve && /* @__PURE__ */ jsxs23(Fragment7, { children: [
|
|
2583
|
+
/* @__PURE__ */ jsxs23("div", { className: "xpay-flex xpay-justify-between xpay-items-center", children: [
|
|
2584
|
+
/* @__PURE__ */ jsxs23("div", { className: "xpay-flex xpay-items-center xpay-gap-2", children: [
|
|
2585
|
+
/* @__PURE__ */ jsx48(SignIcon, {}),
|
|
2586
|
+
/* @__PURE__ */ jsx48("p", { className: "xpay-opacity-50", children: approveTxLoading ? "Wait for approval confirmation" : "Approve token spending" })
|
|
2587
|
+
] }),
|
|
2588
|
+
/* @__PURE__ */ jsxs23("div", { className: "xpay-flex xpay-items-center", children: [
|
|
2589
|
+
approveTxLoading && /* @__PURE__ */ jsx48(Spinner, { width: "5", height: "5" }),
|
|
2590
|
+
approveTxDone && /* @__PURE__ */ jsx48("div", { className: "xpay-text-x_green xpay-w-5 xpay-h-5", children: /* @__PURE__ */ jsx48(CheckIcon, {}) })
|
|
2591
|
+
] })
|
|
2592
|
+
] }),
|
|
2593
|
+
/* @__PURE__ */ jsx48("div", { className: "xpay-w-px xpay-h-6 xpay-mt-1 xpay-mb-1 xpay-ml-2.5 xpay-bg-white xpay-opacity-50" })
|
|
2594
|
+
] }),
|
|
2595
|
+
/* @__PURE__ */ jsxs23("div", { className: "xpay-flex xpay-justify-between xpay-items-center", children: [
|
|
2596
|
+
/* @__PURE__ */ jsxs23("div", { className: "xpay-flex xpay-items-center xpay-gap-2", children: [
|
|
2597
|
+
/* @__PURE__ */ jsx48(SignIcon, {}),
|
|
2598
|
+
/* @__PURE__ */ jsx48("p", { className: "xpay-opacity-50", children: txLoading ? "Wait for transaction confirmation" : "Confirm transaction" })
|
|
2599
|
+
] }),
|
|
2600
|
+
/* @__PURE__ */ jsx48("div", { className: "xpay-flex xpay-items-center", children: txLoading && /* @__PURE__ */ jsx48(Spinner, { width: "5", height: "5" }) })
|
|
2601
|
+
] })
|
|
2602
|
+
] })
|
|
2603
|
+
] })
|
|
2417
2604
|
) });
|
|
2418
2605
|
};
|
|
2419
2606
|
|
|
2607
|
+
// src/components/TxConfigForm/ConnectWalletPrompt.tsx
|
|
2608
|
+
import { jsx as jsx49, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2609
|
+
var ConnectWalletPrompt = ({ onClose }) => {
|
|
2610
|
+
return /* @__PURE__ */ jsxs24("div", { className: "xpay-flex xpay-flex-col xpay-gap-2 xpay-z-10 xpay-my-0 xpay-p-2 md:xpay-p-4 xpay-rounded-3xl xpay-overflow-hidden xpay-font-light sm:xpay-w-x_desktop xpay-w-screen", children: [
|
|
2611
|
+
/* @__PURE__ */ jsx49("div", { className: "xpay-flex xpay-w-full xpay-justify-end xpay-items-center xpay-mx-auto xpay-p-2", children: /* @__PURE__ */ jsx49("div", { className: "xpay-cursor-pointer xpay-text-white", onClick: onClose, children: /* @__PURE__ */ jsx49(CloseIcon, {}) }) }),
|
|
2612
|
+
/* @__PURE__ */ jsx49("p", { className: "xpay-text-xl xpay-font-bold xpay-leading-8 xpay-text-center xpay-text-white", children: "Please connect the wallet first." })
|
|
2613
|
+
] });
|
|
2614
|
+
};
|
|
2615
|
+
|
|
2420
2616
|
// src/components/TxConfigForm/Form.tsx
|
|
2421
|
-
import { Fragment as
|
|
2617
|
+
import { Fragment as Fragment8, jsx as jsx50, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
2422
2618
|
var Form = ({
|
|
2423
2619
|
integratorId,
|
|
2424
2620
|
dstChainId,
|
|
@@ -2426,54 +2622,45 @@ var Form = ({
|
|
|
2426
2622
|
customContractCalls,
|
|
2427
2623
|
desc,
|
|
2428
2624
|
supportedChains,
|
|
2429
|
-
|
|
2625
|
+
returnTransactions,
|
|
2430
2626
|
dstDisplayTokenAddr,
|
|
2431
2627
|
wagmiConfig,
|
|
2432
2628
|
onSubmit,
|
|
2433
2629
|
onClose,
|
|
2434
2630
|
setBackdropClickDisabled
|
|
2435
2631
|
}) => {
|
|
2436
|
-
const [signer, setSigner] =
|
|
2437
|
-
const [dstChain, setDstChain] =
|
|
2438
|
-
const [dstToken, setDstToken] =
|
|
2439
|
-
const [dstDisplayToken, setDstDisplayToken] =
|
|
2440
|
-
const [srcChain, setSrcChain] =
|
|
2441
|
-
const [srcToken, setSrcToken] =
|
|
2442
|
-
const [amount, setAmount] =
|
|
2443
|
-
const [paymentToken, setPaymentToken] =
|
|
2444
|
-
const [route, setRoute] =
|
|
2445
|
-
const [expressChecked, setExpressChecked] =
|
|
2446
|
-
const [historyTabShown, setHistoryTabShown] =
|
|
2447
|
-
const [isGettingRoute, setIsGettingRoute] =
|
|
2448
|
-
const [prices, setPrices] =
|
|
2449
|
-
const [balances, setBalances] =
|
|
2450
|
-
const [settingsShown, setSettingsShown] =
|
|
2451
|
-
const [formError, setFormError] =
|
|
2452
|
-
const [slippage, setSlippage] =
|
|
2453
|
-
const [feesDetailsShown, setFeesDetailsShown] =
|
|
2454
|
-
const [executingTransactions, setExecutingTransactions] =
|
|
2455
|
-
const [transactionSuccessHash, setTransactionSuccessHash] =
|
|
2456
|
-
const [txLoading, setTxLoading] =
|
|
2457
|
-
const [approveTxLoading, setApproveTxLoading] =
|
|
2458
|
-
const [approveTxDone, setApproveTxDone] =
|
|
2459
|
-
const [transactionError, setTransactionError] =
|
|
2460
|
-
const
|
|
2461
|
-
const prevAllowanceValuesRef = useRef3({
|
|
2462
|
-
srcChainId: srcChain?.chainId,
|
|
2463
|
-
srcTokenAddress: srcToken?.address,
|
|
2464
|
-
routeTo: ethers4.constants.AddressZero
|
|
2465
|
-
});
|
|
2466
|
-
const currentAllowanceRequestNonce = useRef3(0);
|
|
2467
|
-
const [isAllowanceLoading, setIsAllowanceLoading] = useState9(false);
|
|
2468
|
-
const [srcTokenAllowance, setSrcTokenAllowance] = useState9("0");
|
|
2632
|
+
const [signer, setSigner] = useState8();
|
|
2633
|
+
const [dstChain, setDstChain] = useState8();
|
|
2634
|
+
const [dstToken, setDstToken] = useState8();
|
|
2635
|
+
const [dstDisplayToken, setDstDisplayToken] = useState8();
|
|
2636
|
+
const [srcChain, setSrcChain] = useState8();
|
|
2637
|
+
const [srcToken, setSrcToken] = useState8();
|
|
2638
|
+
const [amount, setAmount] = useState8("");
|
|
2639
|
+
const [paymentToken, setPaymentToken] = useState8();
|
|
2640
|
+
const [route, setRoute] = useState8();
|
|
2641
|
+
const [expressChecked, setExpressChecked] = useState8(true);
|
|
2642
|
+
const [historyTabShown, setHistoryTabShown] = useState8(false);
|
|
2643
|
+
const [isGettingRoute, setIsGettingRoute] = useState8(false);
|
|
2644
|
+
const [prices, setPrices] = useState8();
|
|
2645
|
+
const [balances, setBalances] = useState8();
|
|
2646
|
+
const [settingsShown, setSettingsShown] = useState8(false);
|
|
2647
|
+
const [formError, setFormError] = useState8("");
|
|
2648
|
+
const [slippage, setSlippage] = useState8("1.5");
|
|
2649
|
+
const [feesDetailsShown, setFeesDetailsShown] = useState8(false);
|
|
2650
|
+
const [executingTransactions, setExecutingTransactions] = useState8(false);
|
|
2651
|
+
const [transactionSuccessHash, setTransactionSuccessHash] = useState8();
|
|
2652
|
+
const [txLoading, setTxLoading] = useState8(false);
|
|
2653
|
+
const [approveTxLoading, setApproveTxLoading] = useState8(false);
|
|
2654
|
+
const [approveTxDone, setApproveTxDone] = useState8(false);
|
|
2655
|
+
const [transactionError, setTransactionError] = useState8(null);
|
|
2656
|
+
const routeAbortController = useRef2(null);
|
|
2469
2657
|
const { sendTransaction } = useSendTransaction({ config: wagmiConfig });
|
|
2470
|
-
const debouncedAmount = useDebounce(amount, 1e3);
|
|
2471
2658
|
const account = useAccount();
|
|
2472
2659
|
const { switchChainAsync } = useSwitchChain();
|
|
2473
|
-
|
|
2660
|
+
useEffect7(() => {
|
|
2474
2661
|
setSigner(account.address);
|
|
2475
2662
|
}, [account.address]);
|
|
2476
|
-
|
|
2663
|
+
useEffect7(() => {
|
|
2477
2664
|
const defaultChain = supportedChains.find(
|
|
2478
2665
|
({ chainId }) => chainId === account.chainId?.toString()
|
|
2479
2666
|
);
|
|
@@ -2483,10 +2670,10 @@ var Form = ({
|
|
|
2483
2670
|
)
|
|
2484
2671
|
);
|
|
2485
2672
|
}, [account.chainId]);
|
|
2486
|
-
|
|
2673
|
+
useEffect7(() => {
|
|
2487
2674
|
setDstChain(supportedChains.find((chain) => chain.chainId === dstChainId));
|
|
2488
2675
|
}, [supportedChains, dstChainId]);
|
|
2489
|
-
|
|
2676
|
+
useEffect7(() => {
|
|
2490
2677
|
(async () => {
|
|
2491
2678
|
if (!dstChain) {
|
|
2492
2679
|
return;
|
|
@@ -2515,8 +2702,8 @@ var Form = ({
|
|
|
2515
2702
|
}
|
|
2516
2703
|
})();
|
|
2517
2704
|
}, [dstChain]);
|
|
2518
|
-
|
|
2519
|
-
if (!(integratorId && srcChain && srcToken && dstChain &&
|
|
2705
|
+
useEffect7(() => {
|
|
2706
|
+
if (!(integratorId && srcChain && srcToken && dstChain && amount && paymentToken && signer && slippage)) {
|
|
2520
2707
|
return;
|
|
2521
2708
|
}
|
|
2522
2709
|
setFormError("");
|
|
@@ -2529,122 +2716,83 @@ var Form = ({
|
|
|
2529
2716
|
throw new Error(
|
|
2530
2717
|
`Configuration error: selected token ($${srcToken.symbol} ${srcToken.name}) has unknown decimals param.`
|
|
2531
2718
|
);
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
}
|
|
2719
|
+
if (routeAbortController.current) {
|
|
2720
|
+
routeAbortController.current.abort(DEFAULT_REQUEST_ABORT_MSG);
|
|
2721
|
+
}
|
|
2722
|
+
routeAbortController.current = new AbortController();
|
|
2723
|
+
getRoute(
|
|
2724
|
+
{
|
|
2725
|
+
integratorId,
|
|
2726
|
+
fromAmount: ethers5.utils.parseUnits(amount, srcToken.decimals).toString(),
|
|
2727
|
+
fromAddress: signer || ADDRESSES[srcChain.chainId].FeeCollector,
|
|
2728
|
+
fromChain: srcChain.chainId,
|
|
2729
|
+
fromToken: srcToken.address,
|
|
2730
|
+
toAddress: signer || ADDRESSES[dstChain.chainId].FeeCollector,
|
|
2731
|
+
toChain: dstChainId,
|
|
2732
|
+
toToken: dstTokenAddr,
|
|
2733
|
+
paymentToken: paymentToken.address,
|
|
2734
|
+
slippage: Number(slippage),
|
|
2735
|
+
expressDelivery: expressChecked,
|
|
2736
|
+
customContractCalls
|
|
2737
|
+
},
|
|
2738
|
+
routeAbortController.current.signal
|
|
2739
|
+
).then((response) => {
|
|
2551
2740
|
setRoute(response);
|
|
2552
2741
|
setFormError("");
|
|
2742
|
+
setIsGettingRoute(false);
|
|
2743
|
+
routeAbortController.current = null;
|
|
2553
2744
|
}).catch((err) => {
|
|
2554
|
-
|
|
2745
|
+
if (err !== DEFAULT_REQUEST_ABORT_MSG) {
|
|
2746
|
+
setFormError(err.message);
|
|
2747
|
+
}
|
|
2555
2748
|
}).finally(() => {
|
|
2556
|
-
setIsGettingRoute(false);
|
|
2557
2749
|
clearTimeout(timeout);
|
|
2558
2750
|
});
|
|
2559
2751
|
}, [
|
|
2752
|
+
amount,
|
|
2560
2753
|
signer,
|
|
2561
2754
|
srcChain,
|
|
2562
2755
|
srcToken,
|
|
2563
|
-
debouncedAmount,
|
|
2564
2756
|
paymentToken,
|
|
2565
2757
|
slippage,
|
|
2566
2758
|
expressChecked
|
|
2567
2759
|
]);
|
|
2568
|
-
|
|
2569
|
-
(async () => {
|
|
2570
|
-
if (!signer || !srcToken?.address || !srcChain?.publicRpcUrls[0] || srcToken?.address === ethers4.constants.AddressZero) {
|
|
2571
|
-
return;
|
|
2572
|
-
}
|
|
2573
|
-
if (route && route.transactions.swap?.to) {
|
|
2574
|
-
const {
|
|
2575
|
-
srcChainId: prevFromChainId,
|
|
2576
|
-
srcTokenAddress: prevFromTokenAddress,
|
|
2577
|
-
routeTo: prevRouteTo
|
|
2578
|
-
} = prevAllowanceValuesRef.current;
|
|
2579
|
-
const hasChanges = srcChain?.chainId !== prevFromChainId || srcToken?.address !== prevFromTokenAddress || route.transactions.swap?.to !== prevRouteTo;
|
|
2580
|
-
if (!hasChanges) {
|
|
2581
|
-
return;
|
|
2582
|
-
}
|
|
2583
|
-
prevAllowanceValuesRef.current = {
|
|
2584
|
-
srcChainId: srcChain?.chainId,
|
|
2585
|
-
srcTokenAddress: srcToken?.address,
|
|
2586
|
-
routeTo: route.transactions.swap?.to
|
|
2587
|
-
};
|
|
2588
|
-
const nonce = Date.now();
|
|
2589
|
-
currentAllowanceRequestNonce.current = nonce;
|
|
2590
|
-
setIsAllowanceLoading(true);
|
|
2591
|
-
const allowanceResponse = await getAllowanceOf(
|
|
2592
|
-
srcToken?.address,
|
|
2593
|
-
signer,
|
|
2594
|
-
route.transactions.swap.to,
|
|
2595
|
-
srcChain?.publicRpcUrls[0]
|
|
2596
|
-
);
|
|
2597
|
-
if (nonce !== currentAllowanceRequestNonce.current) {
|
|
2598
|
-
return;
|
|
2599
|
-
}
|
|
2600
|
-
setSrcTokenAllowance(allowanceResponse);
|
|
2601
|
-
setIsAllowanceLoading(false);
|
|
2602
|
-
}
|
|
2603
|
-
})();
|
|
2604
|
-
}, [srcChain, srcToken?.address, signer, setSrcTokenAllowance, route]);
|
|
2605
|
-
useEffect8(() => {
|
|
2760
|
+
useEffect7(() => {
|
|
2606
2761
|
if (srcChain) {
|
|
2607
2762
|
setPaymentToken(
|
|
2608
2763
|
srcChain.tokens.find(
|
|
2609
|
-
(token) => token.address.toLowerCase() ===
|
|
2764
|
+
(token) => token.address.toLowerCase() === ethers5.constants.AddressZero.toLowerCase()
|
|
2610
2765
|
)
|
|
2611
2766
|
);
|
|
2612
2767
|
}
|
|
2613
2768
|
}, [srcChain]);
|
|
2614
|
-
|
|
2769
|
+
useEffect7(() => {
|
|
2615
2770
|
setAmount("");
|
|
2616
2771
|
setFormError("");
|
|
2617
2772
|
setIsGettingRoute(false);
|
|
2618
2773
|
setRoute(void 0);
|
|
2619
|
-
const nonce = Date.now();
|
|
2620
|
-
currentRouteRequestNonce.current = nonce;
|
|
2621
2774
|
}, [srcToken]);
|
|
2622
|
-
|
|
2775
|
+
useEffect7(() => {
|
|
2623
2776
|
setSrcToken(srcChain?.tokens[0]);
|
|
2624
2777
|
setAmount("");
|
|
2625
2778
|
setIsGettingRoute(false);
|
|
2626
2779
|
setRoute(void 0);
|
|
2627
|
-
const nonce = Date.now();
|
|
2628
|
-
currentRouteRequestNonce.current = nonce;
|
|
2629
2780
|
}, [srcChain]);
|
|
2630
|
-
|
|
2781
|
+
useEffect7(() => {
|
|
2631
2782
|
if (srcChain) {
|
|
2632
2783
|
getPrices({ chainId: srcChain.chainId, currency: "USD" }).then(
|
|
2633
2784
|
(prices2) => setPrices(prices2)
|
|
2634
2785
|
);
|
|
2635
2786
|
}
|
|
2636
2787
|
}, [srcChain]);
|
|
2637
|
-
|
|
2788
|
+
useEffect7(() => {
|
|
2638
2789
|
if (srcChain && signer) {
|
|
2639
2790
|
getBalances(srcChain, signer).then((balances2) => setBalances(balances2));
|
|
2640
2791
|
}
|
|
2641
2792
|
}, [srcChain, signer]);
|
|
2642
|
-
|
|
2793
|
+
useEffect7(() => {
|
|
2643
2794
|
setBackdropClickDisabled(executingTransactions);
|
|
2644
2795
|
}, [executingTransactions]);
|
|
2645
|
-
const isAllowanceOk = useMemo7(() => {
|
|
2646
|
-
return srcToken?.address === ethers4.constants.AddressZero || Number(srcTokenAllowance) >= Number(amount);
|
|
2647
|
-
}, [srcToken, amount, srcTokenAllowance]);
|
|
2648
2796
|
const triggerTx = useCallback3(async () => {
|
|
2649
2797
|
if (!route) {
|
|
2650
2798
|
return;
|
|
@@ -2652,10 +2800,10 @@ var Form = ({
|
|
|
2652
2800
|
setExecutingTransactions(true);
|
|
2653
2801
|
setBackdropClickDisabled(true);
|
|
2654
2802
|
setTransactionError(null);
|
|
2655
|
-
if (route.transactions.approve
|
|
2803
|
+
if (route.transactions.approve) {
|
|
2656
2804
|
setApproveTxDone(false);
|
|
2657
2805
|
const { to, data } = route.transactions.approve;
|
|
2658
|
-
|
|
2806
|
+
sendTransaction(
|
|
2659
2807
|
{
|
|
2660
2808
|
to,
|
|
2661
2809
|
data
|
|
@@ -2671,7 +2819,7 @@ var Form = ({
|
|
|
2671
2819
|
});
|
|
2672
2820
|
setApproveTxLoading(false);
|
|
2673
2821
|
setApproveTxDone(true);
|
|
2674
|
-
swap(route);
|
|
2822
|
+
await swap(route);
|
|
2675
2823
|
},
|
|
2676
2824
|
onError: (error) => {
|
|
2677
2825
|
setTransactionError(`Approval failed: ${error.message}`);
|
|
@@ -2688,17 +2836,15 @@ var Form = ({
|
|
|
2688
2836
|
signer,
|
|
2689
2837
|
srcChain,
|
|
2690
2838
|
srcToken,
|
|
2691
|
-
debouncedAmount,
|
|
2692
2839
|
paymentToken,
|
|
2693
2840
|
slippage,
|
|
2694
2841
|
expressChecked,
|
|
2695
|
-
amount
|
|
2696
|
-
srcTokenAllowance
|
|
2842
|
+
amount
|
|
2697
2843
|
]);
|
|
2698
2844
|
const swap = useCallback3(
|
|
2699
2845
|
async (route2) => {
|
|
2700
2846
|
const { to, value, data } = route2.transactions.swap;
|
|
2701
|
-
|
|
2847
|
+
sendTransaction(
|
|
2702
2848
|
{
|
|
2703
2849
|
to,
|
|
2704
2850
|
value: BigInt(value),
|
|
@@ -2726,23 +2872,14 @@ var Form = ({
|
|
|
2726
2872
|
}
|
|
2727
2873
|
);
|
|
2728
2874
|
},
|
|
2729
|
-
[
|
|
2730
|
-
route,
|
|
2731
|
-
signer,
|
|
2732
|
-
srcChain,
|
|
2733
|
-
srcToken,
|
|
2734
|
-
debouncedAmount,
|
|
2735
|
-
paymentToken,
|
|
2736
|
-
slippage,
|
|
2737
|
-
expressChecked
|
|
2738
|
-
]
|
|
2875
|
+
[route, signer, srcChain, srcToken, paymentToken, slippage, expressChecked]
|
|
2739
2876
|
);
|
|
2740
2877
|
const handleSubmit = (event) => {
|
|
2741
2878
|
event.preventDefault();
|
|
2742
2879
|
if (!route) {
|
|
2743
2880
|
return;
|
|
2744
2881
|
}
|
|
2745
|
-
if (
|
|
2882
|
+
if (returnTransactions) {
|
|
2746
2883
|
onSubmit(route);
|
|
2747
2884
|
return;
|
|
2748
2885
|
}
|
|
@@ -2751,8 +2888,7 @@ var Form = ({
|
|
|
2751
2888
|
const handleSwitchChain = async () => {
|
|
2752
2889
|
await switchChainAsync({ chainId: Number(srcChain?.chainId) });
|
|
2753
2890
|
};
|
|
2754
|
-
const swapButton =
|
|
2755
|
-
let disabled = false;
|
|
2891
|
+
const swapButton = useMemo8(() => {
|
|
2756
2892
|
if (transactionError) {
|
|
2757
2893
|
return {
|
|
2758
2894
|
text: transactionError,
|
|
@@ -2766,14 +2902,14 @@ var Form = ({
|
|
|
2766
2902
|
text: "Connect wallet",
|
|
2767
2903
|
fn: () => {
|
|
2768
2904
|
},
|
|
2769
|
-
disabled
|
|
2905
|
+
disabled: false
|
|
2770
2906
|
};
|
|
2771
2907
|
}
|
|
2772
2908
|
if (signer && srcChain && srcChain.chainId !== account.chainId?.toString()) {
|
|
2773
2909
|
return {
|
|
2774
2910
|
text: "Switch chain",
|
|
2775
2911
|
fn: handleSwitchChain,
|
|
2776
|
-
disabled
|
|
2912
|
+
disabled: false
|
|
2777
2913
|
};
|
|
2778
2914
|
}
|
|
2779
2915
|
if (!amount) {
|
|
@@ -2784,7 +2920,7 @@ var Form = ({
|
|
|
2784
2920
|
disabled: true
|
|
2785
2921
|
};
|
|
2786
2922
|
}
|
|
2787
|
-
if (amount && balances && srcToken && srcToken.decimals && balances[srcToken?.address] !== void 0 && !
|
|
2923
|
+
if (amount && balances && srcToken && srcToken.decimals && balances[srcToken?.address] !== void 0 && !ethers5.utils.parseUnits(amount, srcToken.decimals).lt(balances[srcToken?.address] || "0")) {
|
|
2788
2924
|
return {
|
|
2789
2925
|
text: "Insufficient balance",
|
|
2790
2926
|
fn: () => {
|
|
@@ -2800,234 +2936,54 @@ var Form = ({
|
|
|
2800
2936
|
disabled: true
|
|
2801
2937
|
};
|
|
2802
2938
|
}
|
|
2803
|
-
if (isAllowanceLoading) {
|
|
2804
|
-
return {
|
|
2805
|
-
text: `Checking allowance`,
|
|
2806
|
-
fn: () => {
|
|
2807
|
-
},
|
|
2808
|
-
disabled: true
|
|
2809
|
-
};
|
|
2810
|
-
}
|
|
2811
2939
|
return {
|
|
2812
2940
|
text: "Submit",
|
|
2813
2941
|
fn: () => {
|
|
2814
2942
|
},
|
|
2815
|
-
disabled
|
|
2943
|
+
disabled: false
|
|
2816
2944
|
};
|
|
2817
2945
|
}, [
|
|
2818
2946
|
account,
|
|
2819
2947
|
srcToken,
|
|
2820
2948
|
srcChain,
|
|
2821
|
-
isAllowanceOk,
|
|
2822
2949
|
amount,
|
|
2823
2950
|
balances,
|
|
2824
2951
|
signer,
|
|
2825
2952
|
transactionError,
|
|
2826
|
-
route
|
|
2827
|
-
isAllowanceLoading
|
|
2953
|
+
route
|
|
2828
2954
|
]);
|
|
2829
|
-
const isExpressDelivery =
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
expressDeliveryFee = safeBigNumberFrom("0");
|
|
2833
|
-
} else {
|
|
2834
|
-
expressDeliveryFee = safeBigNumberFrom(
|
|
2835
|
-
route?.xSwapFees.expressDeliveryFee
|
|
2836
|
-
);
|
|
2837
|
-
}
|
|
2838
|
-
if (expressDeliveryFee.gt("0")) {
|
|
2839
|
-
return true;
|
|
2840
|
-
}
|
|
2841
|
-
return false;
|
|
2955
|
+
const isExpressDelivery = useMemo8(() => {
|
|
2956
|
+
const expressDeliveryFee = !route?.xSwapFees || !route?.xSwapFees.expressDeliveryFee ? safeBigNumberFrom("0") : safeBigNumberFrom(route?.xSwapFees.expressDeliveryFee);
|
|
2957
|
+
return expressDeliveryFee.gt("0");
|
|
2842
2958
|
}, [route]);
|
|
2843
|
-
return /* @__PURE__ */
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
{
|
|
2863
|
-
className: "xpay-cursor-pointer xpay-text-white",
|
|
2864
|
-
onClick: onClose,
|
|
2865
|
-
children: /* @__PURE__ */ jsx46(CloseIcon, {})
|
|
2866
|
-
}
|
|
2867
|
-
) }),
|
|
2868
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col xpay-w-full xpay-justify-center xpay-items-center xpay-mx-auto xpay-p-2 xpay-gap-4", children: [
|
|
2869
|
-
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46(ErrorIcon, {}) }),
|
|
2870
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col", children: [
|
|
2871
|
-
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46("p", { className: "xpay-text-2xl xpay-font-bold xpay-leading-8 xpay-text-center xpay-text-white", children: "Transaction error!" }) }),
|
|
2872
|
-
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46("p", { className: "xpay-text-sm xpay-text-center xpay-text-white xpay-opacity-50", children: parseWeb3Error(transactionError) }) })
|
|
2873
|
-
] })
|
|
2874
|
-
] })
|
|
2875
|
-
] })
|
|
2876
|
-
) : transactionSuccessHash ? (
|
|
2877
|
-
// Tx Success modal
|
|
2878
|
-
/* @__PURE__ */ jsxs21("div", { children: [
|
|
2879
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-flex xpay-w-full xpay-justify-end xpay-items-center xpay-mx-auto xpay-p-2", children: /* @__PURE__ */ jsx46(
|
|
2880
|
-
"div",
|
|
2881
|
-
{
|
|
2882
|
-
className: "xpay-cursor-pointer xpay-text-white",
|
|
2883
|
-
onClick: onClose,
|
|
2884
|
-
children: /* @__PURE__ */ jsx46(CloseIcon, {})
|
|
2885
|
-
}
|
|
2886
|
-
) }),
|
|
2887
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col xpay-w-full xpay-justify-center xpay-items-center xpay-mx-auto xpay-p-2 xpay-gap-4", children: [
|
|
2888
|
-
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46(SuccessIcon, {}) }),
|
|
2889
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col", children: [
|
|
2890
|
-
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46("p", { className: "xpay-text-2xl xpay-font-bold xpay-leading-8 xpay-text-center xpay-text-white", children: "Transaction success!" }) }),
|
|
2891
|
-
srcChain?.chainId !== dstChain?.chainId ? /* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsxs21("p", { className: "xpay-text-sm xpay-text-center xpay-text-white xpay-opacity-50", children: [
|
|
2892
|
-
"Approximated time of delivery:",
|
|
2893
|
-
" ",
|
|
2894
|
-
isExpressDelivery ? "30 seconds" : "30 minutes"
|
|
2895
|
-
] }) }) : /* @__PURE__ */ jsx46(Fragment6, {})
|
|
2896
|
-
] }),
|
|
2897
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-gap-4 xpay-items-center", children: [
|
|
2898
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-gap-2", children: [
|
|
2899
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-w-10 xpay-h-10", children: srcToken?.image ? /* @__PURE__ */ jsx46(
|
|
2900
|
-
"img",
|
|
2901
|
-
{
|
|
2902
|
-
className: "xpay-w-10 xpay-h-10",
|
|
2903
|
-
src: srcToken?.image,
|
|
2904
|
-
alt: srcToken?.name
|
|
2905
|
-
}
|
|
2906
|
-
) : /* @__PURE__ */ jsx46(
|
|
2907
|
-
UnknownTokenLogo,
|
|
2908
|
-
{
|
|
2909
|
-
tokenName: "?",
|
|
2910
|
-
className: "xpay-w-10 xpay-h-10"
|
|
2911
|
-
}
|
|
2912
|
-
) }),
|
|
2913
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col xpay-items-start", children: [
|
|
2914
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-flex", children: `${debouncedAmount} ${srcToken?.symbol}` }),
|
|
2915
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-text-sm xpay-text-center xpay-text-white xpay-opacity-50", children: srcChain?.displayName })
|
|
2916
|
-
] })
|
|
2917
|
-
] }),
|
|
2918
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-w-3.5 xpay-h-3.5", children: /* @__PURE__ */ jsx46(ArrowRightIcon, {}) }),
|
|
2919
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-gap-2", children: [
|
|
2920
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-w-10 xpay-h-10", children: (dstDisplayToken ? dstDisplayToken : dstToken)?.image ? /* @__PURE__ */ jsx46(
|
|
2921
|
-
"img",
|
|
2922
|
-
{
|
|
2923
|
-
className: "xpay-w-10 xpay-h-10",
|
|
2924
|
-
src: (dstDisplayToken ? dstDisplayToken : dstToken)?.image,
|
|
2925
|
-
alt: (dstDisplayToken ? dstDisplayToken : dstToken)?.name
|
|
2926
|
-
}
|
|
2927
|
-
) : /* @__PURE__ */ jsx46(
|
|
2928
|
-
UnknownTokenLogo,
|
|
2929
|
-
{
|
|
2930
|
-
tokenName: "?",
|
|
2931
|
-
className: "xpay-w-10 xpay-h-10"
|
|
2932
|
-
}
|
|
2933
|
-
) }),
|
|
2934
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col xpay-items-start", children: [
|
|
2935
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex", children: [
|
|
2936
|
-
weiToHumanReadable({
|
|
2937
|
-
amount: route?.estAmountOut || "0",
|
|
2938
|
-
decimals: (dstDisplayToken ? dstDisplayToken : dstToken)?.decimals || 18,
|
|
2939
|
-
precisionFractionalPlaces: 4
|
|
2940
|
-
}),
|
|
2941
|
-
" ",
|
|
2942
|
-
(dstDisplayToken ? dstDisplayToken : dstToken)?.symbol
|
|
2943
|
-
] }),
|
|
2944
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-text-sm xpay-text-center xpay-text-white xpay-opacity-50", children: dstChain?.displayName })
|
|
2945
|
-
] })
|
|
2946
|
-
] })
|
|
2947
|
-
] }),
|
|
2948
|
-
/* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsxs21(
|
|
2949
|
-
"a",
|
|
2950
|
-
{
|
|
2951
|
-
href: srcChain?.chainId !== dstChain?.chainId ? `${CCIP_EXPLORER}/tx/${transactionSuccessHash}` : `${supportedChains.find(
|
|
2952
|
-
(chain) => chain.chainId === srcChain?.chainId
|
|
2953
|
-
)?.transactionExplorer}/${transactionSuccessHash}`,
|
|
2954
|
-
target: "_blank",
|
|
2955
|
-
rel: "noreferrer",
|
|
2956
|
-
className: "xpay-flex xpay-items-center xpay-gap-2 xpay-font-bold xpay-no-underline xpay-cursor-pointer xpay-text-center",
|
|
2957
|
-
"aria-label": "Show the transaction in the chain explorer",
|
|
2958
|
-
children: [
|
|
2959
|
-
/* @__PURE__ */ jsx46("p", { className: "xpay-bg-gradient-to-r xpay-from-x_blue_light xpay-to-x_blue_dark xpay-bg-clip-text xpay-text-transparent xpay-underline", children: "View details on Explorer" }),
|
|
2960
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-w-3.5 xpay-h-3.5 xpay-bg-gradient-to-r xpay-text-x_blue_dark", children: /* @__PURE__ */ jsx46(ArrowUpRightIcon, {}) })
|
|
2961
|
-
]
|
|
2962
|
-
}
|
|
2963
|
-
) })
|
|
2964
|
-
] })
|
|
2965
|
-
] })
|
|
2959
|
+
return /* @__PURE__ */ jsx50(Fragment8, { children: !signer ? /* @__PURE__ */ jsx50(ConnectWalletPrompt, { onClose }) : executingTransactions ? /* @__PURE__ */ jsx50(
|
|
2960
|
+
ConfirmationView,
|
|
2961
|
+
{
|
|
2962
|
+
txError: transactionError,
|
|
2963
|
+
onClose,
|
|
2964
|
+
txSuccessHash: transactionSuccessHash,
|
|
2965
|
+
srcChain,
|
|
2966
|
+
dstChain,
|
|
2967
|
+
isExpressDelivery,
|
|
2968
|
+
srcToken,
|
|
2969
|
+
amount,
|
|
2970
|
+
dstDisplayToken,
|
|
2971
|
+
dstToken,
|
|
2972
|
+
route,
|
|
2973
|
+
supportedChains,
|
|
2974
|
+
approveTxLoading,
|
|
2975
|
+
approveTxDone,
|
|
2976
|
+
txLoading
|
|
2977
|
+
}
|
|
2966
2978
|
) : (
|
|
2967
|
-
// Tx Confirmation modal
|
|
2968
|
-
/* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
2969
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-w-full xpay-justify-between xpay-items-center xpay-mx-auto xpay-p-2 xpay-font-light ", children: [
|
|
2970
|
-
/* @__PURE__ */ jsx46("p", { className: "xpay-text-white xpay-text-xl", children: "Confirmation" }),
|
|
2971
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-flex xpay-w-full xpay-justify-end xpay-items-center xpay-mx-auto xpay-p-2", children: /* @__PURE__ */ jsx46(
|
|
2972
|
-
"div",
|
|
2973
|
-
{
|
|
2974
|
-
className: "xpay-cursor-pointer xpay-text-white",
|
|
2975
|
-
onClick: onClose,
|
|
2976
|
-
children: /* @__PURE__ */ jsx46(CloseIcon, {})
|
|
2977
|
-
}
|
|
2978
|
-
) })
|
|
2979
|
-
] }),
|
|
2980
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-flex xpay-flex-col xpay-gap-2", children: /* @__PURE__ */ jsx46(
|
|
2981
|
-
ConfirmationAmount,
|
|
2982
|
-
{
|
|
2983
|
-
amount: ethers4.utils.parseUnits(debouncedAmount, srcToken?.decimals).toString(),
|
|
2984
|
-
chain: srcChain,
|
|
2985
|
-
token: srcToken,
|
|
2986
|
-
type: "src"
|
|
2987
|
-
}
|
|
2988
|
-
) }),
|
|
2989
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-flex xpay-justify-center xpay-globalBorder xpay-rounded-xl xpay-p-[5px] xpay--mt-7 xpay--mb-6 ", children: /* @__PURE__ */ jsx46("div", { className: "xpay-flex xpay-items-center xpay-justify-center xpay-rounded-lg xpay-w-8 xpay-h-8 xpay-bg-gradient-to-l xpay-from-[rgba(54,129,198,1)] xpay-to-[rgba(43,74,157,1)] ", children: /* @__PURE__ */ jsx46(ArrowDownIcon, {}) }) }),
|
|
2990
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-flex xpay-flex-col xpay-gap-2", children: /* @__PURE__ */ jsx46(
|
|
2991
|
-
ConfirmationAmount,
|
|
2992
|
-
{
|
|
2993
|
-
amount: route?.estAmountOut || "0",
|
|
2994
|
-
chain: dstChain,
|
|
2995
|
-
token: dstDisplayToken ? dstDisplayToken : dstToken,
|
|
2996
|
-
type: "dst"
|
|
2997
|
-
}
|
|
2998
|
-
) }),
|
|
2999
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-flex-col xpay-globalBorder xpay-p-4 xpay-justify-center xpay-rounded-xl xpay-bg-[rgba(15,15,15,1)] xpay-relative", children: [
|
|
3000
|
-
route?.transactions.approve && !isAllowanceOk && /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
3001
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-justify-between xpay-items-center", children: [
|
|
3002
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-items-center xpay-gap-2", children: [
|
|
3003
|
-
/* @__PURE__ */ jsx46(SignIcon, {}),
|
|
3004
|
-
/* @__PURE__ */ jsx46("p", { className: "xpay-opacity-50", children: approveTxLoading ? "Wait for approval confirmation" : "Approve token spending" })
|
|
3005
|
-
] }),
|
|
3006
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-items-center", children: [
|
|
3007
|
-
approveTxLoading && /* @__PURE__ */ jsx46(Spinner, { width: "5", height: "5" }),
|
|
3008
|
-
approveTxDone && /* @__PURE__ */ jsx46("div", { className: "xpay-text-x_green xpay-w-5 xpay-h-5", children: /* @__PURE__ */ jsx46(CheckIcon, {}) })
|
|
3009
|
-
] })
|
|
3010
|
-
] }),
|
|
3011
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-w-px xpay-h-6 xpay-mt-1 xpay-mb-1 xpay-ml-2.5 xpay-bg-white xpay-opacity-50" })
|
|
3012
|
-
] }),
|
|
3013
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-justify-between xpay-items-center", children: [
|
|
3014
|
-
/* @__PURE__ */ jsxs21("div", { className: "xpay-flex xpay-items-center xpay-gap-2", children: [
|
|
3015
|
-
/* @__PURE__ */ jsx46(SignIcon, {}),
|
|
3016
|
-
/* @__PURE__ */ jsx46("p", { className: "xpay-opacity-50", children: txLoading ? "Wait for transaction confirmation" : "Confirm transaction" })
|
|
3017
|
-
] }),
|
|
3018
|
-
/* @__PURE__ */ jsx46("div", { className: "xpay-flex xpay-items-center", children: txLoading && /* @__PURE__ */ jsx46(Spinner, { width: "5", height: "5" }) })
|
|
3019
|
-
] })
|
|
3020
|
-
] })
|
|
3021
|
-
] })
|
|
3022
|
-
) }) : (
|
|
3023
2979
|
// XPay form
|
|
3024
|
-
/* @__PURE__ */
|
|
2980
|
+
/* @__PURE__ */ jsxs25(
|
|
3025
2981
|
"form",
|
|
3026
2982
|
{
|
|
3027
2983
|
className: "xpay-flex xpay-flex-col xpay-gap-2 xpay-z-10 xpay-my-0 p-2 md:xpay-p-4 xpay-rounded-3xl xpay-overflow-hidden xpay-font-light sm:xpay-w-x_desktop",
|
|
3028
2984
|
onSubmit: handleSubmit,
|
|
3029
2985
|
children: [
|
|
3030
|
-
/* @__PURE__ */
|
|
2986
|
+
/* @__PURE__ */ jsx50(
|
|
3031
2987
|
TopBar,
|
|
3032
2988
|
{
|
|
3033
2989
|
signer,
|
|
@@ -3037,7 +2993,7 @@ var Form = ({
|
|
|
3037
2993
|
onClose
|
|
3038
2994
|
}
|
|
3039
2995
|
),
|
|
3040
|
-
settingsShown && /* @__PURE__ */
|
|
2996
|
+
settingsShown && /* @__PURE__ */ jsx50(
|
|
3041
2997
|
Settings,
|
|
3042
2998
|
{
|
|
3043
2999
|
expressChecked,
|
|
@@ -3047,8 +3003,8 @@ var Form = ({
|
|
|
3047
3003
|
setSlippage
|
|
3048
3004
|
}
|
|
3049
3005
|
),
|
|
3050
|
-
historyTabShown ? /* @__PURE__ */
|
|
3051
|
-
/* @__PURE__ */
|
|
3006
|
+
historyTabShown ? /* @__PURE__ */ jsx50(History, { signer, supportedChains }) : /* @__PURE__ */ jsxs25("div", { className: "xpay-flex xpay-flex-col xpay-gap-2", children: [
|
|
3007
|
+
/* @__PURE__ */ jsx50(
|
|
3052
3008
|
SwapPanel,
|
|
3053
3009
|
{
|
|
3054
3010
|
amount,
|
|
@@ -3063,7 +3019,7 @@ var Form = ({
|
|
|
3063
3019
|
setSrcChain
|
|
3064
3020
|
}
|
|
3065
3021
|
),
|
|
3066
|
-
/* @__PURE__ */
|
|
3022
|
+
/* @__PURE__ */ jsx50(
|
|
3067
3023
|
Summary,
|
|
3068
3024
|
{
|
|
3069
3025
|
isGettingRoute,
|
|
@@ -3072,8 +3028,8 @@ var Form = ({
|
|
|
3072
3028
|
dstChain
|
|
3073
3029
|
}
|
|
3074
3030
|
),
|
|
3075
|
-
desc && /* @__PURE__ */
|
|
3076
|
-
/* @__PURE__ */
|
|
3031
|
+
desc && /* @__PURE__ */ jsx50(Description, { description: desc }),
|
|
3032
|
+
/* @__PURE__ */ jsx50(
|
|
3077
3033
|
FeesDetails,
|
|
3078
3034
|
{
|
|
3079
3035
|
route,
|
|
@@ -3086,8 +3042,8 @@ var Form = ({
|
|
|
3086
3042
|
isExpressDelivery
|
|
3087
3043
|
}
|
|
3088
3044
|
),
|
|
3089
|
-
formError.length > 0 && /* @__PURE__ */
|
|
3090
|
-
/* @__PURE__ */
|
|
3045
|
+
formError.length > 0 && /* @__PURE__ */ jsx50(ErrorField, { error: formError }),
|
|
3046
|
+
/* @__PURE__ */ jsx50(
|
|
3091
3047
|
Button,
|
|
3092
3048
|
{
|
|
3093
3049
|
type: "submit",
|
|
@@ -3104,7 +3060,7 @@ var Form = ({
|
|
|
3104
3060
|
};
|
|
3105
3061
|
|
|
3106
3062
|
// src/components/TxConfigForm/index.tsx
|
|
3107
|
-
import { jsx as
|
|
3063
|
+
import { jsx as jsx51, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
3108
3064
|
var TxConfigForm = ({
|
|
3109
3065
|
integratorId,
|
|
3110
3066
|
dstChainId,
|
|
@@ -3112,12 +3068,12 @@ var TxConfigForm = ({
|
|
|
3112
3068
|
customContractCalls,
|
|
3113
3069
|
desc,
|
|
3114
3070
|
supportedChains,
|
|
3115
|
-
|
|
3071
|
+
returnTransactions,
|
|
3116
3072
|
dstDisplayTokenAddr,
|
|
3117
3073
|
onSubmit,
|
|
3118
3074
|
onClose
|
|
3119
3075
|
}) => {
|
|
3120
|
-
const [backdropClickDisabled, setBackdropClickDisabled] =
|
|
3076
|
+
const [backdropClickDisabled, setBackdropClickDisabled] = useState9(false);
|
|
3121
3077
|
const onBackdropClick = (e) => {
|
|
3122
3078
|
e.stopPropagation();
|
|
3123
3079
|
e.nativeEvent.stopImmediatePropagation();
|
|
@@ -3126,17 +3082,17 @@ var TxConfigForm = ({
|
|
|
3126
3082
|
}
|
|
3127
3083
|
};
|
|
3128
3084
|
const queryClient = new QueryClient();
|
|
3129
|
-
const wagmiConfig =
|
|
3085
|
+
const wagmiConfig = useMemo9(
|
|
3130
3086
|
() => getWagmiConfig(supportedChains),
|
|
3131
3087
|
supportedChains
|
|
3132
3088
|
);
|
|
3133
|
-
return /* @__PURE__ */
|
|
3089
|
+
return /* @__PURE__ */ jsx51(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx51(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx51(
|
|
3134
3090
|
"div",
|
|
3135
3091
|
{
|
|
3136
3092
|
className: "xpay-top-0 xpay-left-0 xpay-right-0 xpay-bottom-0 xpay-bg-[rgba(0,0,0,0.8)] xpay-fixed xpay-flex xpay-items-center xpay-justify-center xpay-z-10",
|
|
3137
3093
|
onMouseDown: onBackdropClick,
|
|
3138
|
-
children: /* @__PURE__ */
|
|
3139
|
-
/* @__PURE__ */
|
|
3094
|
+
children: /* @__PURE__ */ jsxs26("div", { className: "xpay-relative xpay-bg-black xpay-rounded-3xl xpay-overflow-auto xpay-text-white xpay-border-2 xpay-border-solid xpay-border-[rgba(255,255,255,0.1)]", children: [
|
|
3095
|
+
/* @__PURE__ */ jsx51(
|
|
3140
3096
|
Form,
|
|
3141
3097
|
{
|
|
3142
3098
|
integratorId,
|
|
@@ -3146,14 +3102,14 @@ var TxConfigForm = ({
|
|
|
3146
3102
|
desc,
|
|
3147
3103
|
supportedChains,
|
|
3148
3104
|
wagmiConfig,
|
|
3149
|
-
|
|
3105
|
+
returnTransactions: !!returnTransactions,
|
|
3150
3106
|
dstDisplayTokenAddr,
|
|
3151
3107
|
onSubmit,
|
|
3152
3108
|
onClose,
|
|
3153
3109
|
setBackdropClickDisabled: (disabled) => setBackdropClickDisabled(disabled)
|
|
3154
3110
|
}
|
|
3155
3111
|
),
|
|
3156
|
-
/* @__PURE__ */
|
|
3112
|
+
/* @__PURE__ */ jsx51(PoweredBy, {})
|
|
3157
3113
|
] })
|
|
3158
3114
|
}
|
|
3159
3115
|
) }) });
|
|
@@ -3165,7 +3121,7 @@ var openTxConfigForm = async ({
|
|
|
3165
3121
|
customContractCalls,
|
|
3166
3122
|
desc,
|
|
3167
3123
|
supportedChains,
|
|
3168
|
-
|
|
3124
|
+
returnTransactions,
|
|
3169
3125
|
dstDisplayTokenAddr
|
|
3170
3126
|
}) => {
|
|
3171
3127
|
try {
|
|
@@ -3178,7 +3134,7 @@ var openTxConfigForm = async ({
|
|
|
3178
3134
|
throw new Error("XPay was incorrectly initialised");
|
|
3179
3135
|
}
|
|
3180
3136
|
xpayRoot.render(
|
|
3181
|
-
/* @__PURE__ */
|
|
3137
|
+
/* @__PURE__ */ jsx51(
|
|
3182
3138
|
TxConfigForm,
|
|
3183
3139
|
{
|
|
3184
3140
|
integratorId,
|
|
@@ -3187,10 +3143,10 @@ var openTxConfigForm = async ({
|
|
|
3187
3143
|
customContractCalls,
|
|
3188
3144
|
desc,
|
|
3189
3145
|
supportedChains,
|
|
3190
|
-
|
|
3146
|
+
returnTransactions,
|
|
3191
3147
|
dstDisplayTokenAddr,
|
|
3192
3148
|
onSubmit: (route) => {
|
|
3193
|
-
if (
|
|
3149
|
+
if (returnTransactions) {
|
|
3194
3150
|
resolve(route);
|
|
3195
3151
|
}
|
|
3196
3152
|
if (xpayRoot) {
|
|
@@ -3212,8 +3168,8 @@ var openTxConfigForm = async ({
|
|
|
3212
3168
|
};
|
|
3213
3169
|
|
|
3214
3170
|
// src/components/TxStatusButton/index.tsx
|
|
3215
|
-
import { useMemo as
|
|
3216
|
-
import { Fragment as
|
|
3171
|
+
import { useMemo as useMemo10, useState as useState10 } from "react";
|
|
3172
|
+
import { Fragment as Fragment9, jsx as jsx52, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3217
3173
|
var TxStatusButton = ({ transaction }) => {
|
|
3218
3174
|
const {
|
|
3219
3175
|
srcChain: fromChain,
|
|
@@ -3226,29 +3182,29 @@ var TxStatusButton = ({ transaction }) => {
|
|
|
3226
3182
|
isDone,
|
|
3227
3183
|
explorer
|
|
3228
3184
|
} = transaction;
|
|
3229
|
-
const [isWide, setIsWide] =
|
|
3230
|
-
const background =
|
|
3185
|
+
const [isWide, setIsWide] = useState10(false);
|
|
3186
|
+
const background = useMemo10(
|
|
3231
3187
|
() => isDone ? "xpay-bg-[rgba(2,2,2,1)] xpay-bg-gradient-to-r xpay-from-[rgba(76,175,80,0.2)] xpay-to-[rgba(46,125,50,0.2)]" : "xpay-bg-[rgba(2,2,2,1)] xpay-bg-gradient-to-r xpay-from-[rgba(54,129,198,0.2)] xpay-to-[rgba(43,74,157,0.2)]",
|
|
3232
3188
|
[isDone]
|
|
3233
3189
|
);
|
|
3234
|
-
const border =
|
|
3190
|
+
const border = useMemo10(
|
|
3235
3191
|
() => isDone ? "xpay-border xpay-border-solid xpay-border-x_green_dark" : "xpay-border xpay-border-solid xpay-border-x_blue_dark",
|
|
3236
3192
|
[isDone]
|
|
3237
3193
|
);
|
|
3238
|
-
return /* @__PURE__ */
|
|
3194
|
+
return /* @__PURE__ */ jsxs27(
|
|
3239
3195
|
"div",
|
|
3240
3196
|
{
|
|
3241
3197
|
className: "xpay-flex xpay-gap-2",
|
|
3242
3198
|
onClick: () => setIsWide((x) => !x),
|
|
3243
3199
|
children: [
|
|
3244
|
-
isWide && /* @__PURE__ */
|
|
3200
|
+
isWide && /* @__PURE__ */ jsxs27(
|
|
3245
3201
|
"div",
|
|
3246
3202
|
{
|
|
3247
3203
|
className: `xpay-flex xpay-items-center xpay-min-w-60 sm:xpay-w-[520px] xpay-text-white xpay-h-14 xpay-px-4 xpay-text-sm xpay-gap-3 xpay-rounded-xl ${background} ${border}`,
|
|
3248
3204
|
children: [
|
|
3249
|
-
/* @__PURE__ */
|
|
3250
|
-
/* @__PURE__ */
|
|
3251
|
-
/* @__PURE__ */
|
|
3205
|
+
/* @__PURE__ */ jsxs27("div", { className: "xpay-flex xpay-justify-between xpay-flex-col xpay-gap-2 sm:xpay-gap-5 sm:xpay-flex-row xpay-w-full", children: [
|
|
3206
|
+
/* @__PURE__ */ jsxs27("div", { className: "xpay-flex xpay-items-center xpay-gap-2", children: [
|
|
3207
|
+
/* @__PURE__ */ jsx52(
|
|
3252
3208
|
"img",
|
|
3253
3209
|
{
|
|
3254
3210
|
className: "xpay-w-5 xpay-h-5",
|
|
@@ -3256,9 +3212,9 @@ var TxStatusButton = ({ transaction }) => {
|
|
|
3256
3212
|
alt: "source chain"
|
|
3257
3213
|
}
|
|
3258
3214
|
),
|
|
3259
|
-
/* @__PURE__ */
|
|
3260
|
-
/* @__PURE__ */
|
|
3261
|
-
/* @__PURE__ */
|
|
3215
|
+
/* @__PURE__ */ jsx52("div", { children: fromChain }),
|
|
3216
|
+
/* @__PURE__ */ jsx52("div", { className: "xpay-w-3.5 xpay-h-3.5", children: /* @__PURE__ */ jsx52(ArrowRightIcon, {}) }),
|
|
3217
|
+
/* @__PURE__ */ jsx52(
|
|
3262
3218
|
"img",
|
|
3263
3219
|
{
|
|
3264
3220
|
className: "xpay-w-5 xpay-h-5",
|
|
@@ -3266,23 +3222,23 @@ var TxStatusButton = ({ transaction }) => {
|
|
|
3266
3222
|
alt: "to chain"
|
|
3267
3223
|
}
|
|
3268
3224
|
),
|
|
3269
|
-
/* @__PURE__ */
|
|
3225
|
+
/* @__PURE__ */ jsx52("div", { children: toChain })
|
|
3270
3226
|
] }),
|
|
3271
|
-
/* @__PURE__ */
|
|
3272
|
-
/* @__PURE__ */
|
|
3273
|
-
/* @__PURE__ */
|
|
3274
|
-
/* @__PURE__ */
|
|
3275
|
-
fromTokenImage ? /* @__PURE__ */
|
|
3227
|
+
/* @__PURE__ */ jsxs27("div", { className: "xpay-flex xpay-items-center xpay-gap-2", children: [
|
|
3228
|
+
/* @__PURE__ */ jsx52("div", { children: "Sent" }),
|
|
3229
|
+
/* @__PURE__ */ jsx52("div", { children: fromAmount }),
|
|
3230
|
+
/* @__PURE__ */ jsx52("div", { children: fromToken }),
|
|
3231
|
+
fromTokenImage ? /* @__PURE__ */ jsx52(
|
|
3276
3232
|
"img",
|
|
3277
3233
|
{
|
|
3278
3234
|
className: "xpay-w-5 xpay-h-5",
|
|
3279
3235
|
src: fromTokenImage,
|
|
3280
3236
|
alt: "source token"
|
|
3281
3237
|
}
|
|
3282
|
-
) : /* @__PURE__ */
|
|
3238
|
+
) : /* @__PURE__ */ jsx52(UnknownTokenLogo, { tokenName: "?" })
|
|
3283
3239
|
] })
|
|
3284
3240
|
] }),
|
|
3285
|
-
/* @__PURE__ */
|
|
3241
|
+
/* @__PURE__ */ jsx52(
|
|
3286
3242
|
"a",
|
|
3287
3243
|
{
|
|
3288
3244
|
href: explorer,
|
|
@@ -3290,21 +3246,21 @@ var TxStatusButton = ({ transaction }) => {
|
|
|
3290
3246
|
rel: "noreferrer",
|
|
3291
3247
|
className: "xpay-no-underline xpay-cursor-pointer",
|
|
3292
3248
|
"aria-label": "Show the transaction in the chain explorer",
|
|
3293
|
-
children: /* @__PURE__ */
|
|
3249
|
+
children: /* @__PURE__ */ jsx52("div", { className: "xpay-w-3.5 xpay-h-3.5", children: /* @__PURE__ */ jsx52(ArrowUpRightIcon, {}) })
|
|
3294
3250
|
}
|
|
3295
3251
|
)
|
|
3296
3252
|
]
|
|
3297
3253
|
}
|
|
3298
3254
|
),
|
|
3299
|
-
/* @__PURE__ */
|
|
3255
|
+
/* @__PURE__ */ jsx52(
|
|
3300
3256
|
"div",
|
|
3301
3257
|
{
|
|
3302
3258
|
className: `xpay-text-white xpay-rounded-xl xpay-cursor-pointer ${background} ${border}`,
|
|
3303
|
-
children: /* @__PURE__ */
|
|
3304
|
-
/* @__PURE__ */
|
|
3305
|
-
/* @__PURE__ */
|
|
3306
|
-
/* @__PURE__ */
|
|
3307
|
-
/* @__PURE__ */
|
|
3259
|
+
children: /* @__PURE__ */ jsxs27("div", { className: "xpay-flex xpay-gap-2 xpay-items-center xpay-h-14 xpay-w-20 xpay-justify-center", children: [
|
|
3260
|
+
/* @__PURE__ */ jsx52(ArrowLeftIcon, {}),
|
|
3261
|
+
/* @__PURE__ */ jsx52("div", { className: "xpay-relative xpay-flex xpay-items-center xpay-justify-center xpay-w-9 xpay-h-9", children: isDone ? /* @__PURE__ */ jsx52("div", { className: "xpay-text-x_green xpay-w-5 xpay-h-5", children: /* @__PURE__ */ jsx52(CheckIcon, {}) }) : /* @__PURE__ */ jsxs27(Fragment9, { children: [
|
|
3262
|
+
/* @__PURE__ */ jsx52("div", { className: "xpay-w-5 xpay-h-5", children: /* @__PURE__ */ jsx52(XSwapLogo, {}) }),
|
|
3263
|
+
/* @__PURE__ */ jsx52("div", { className: "xpay-absolute xpay-flex xpay-items-center xpay-justify-center xpay-top-0 xpay-left-0 xpay-right-0 xpay-bottom-0 xpay-text-white", children: /* @__PURE__ */ jsx52(Spinner, { width: "10", height: "10" }) })
|
|
3308
3264
|
] }) })
|
|
3309
3265
|
] })
|
|
3310
3266
|
}
|
|
@@ -3333,19 +3289,19 @@ var updateTransactionDoneInRenderedTransactions = (txHash) => {
|
|
|
3333
3289
|
}
|
|
3334
3290
|
};
|
|
3335
3291
|
var renderTxStatusButtons = () => {
|
|
3336
|
-
const buttons = renderedTransactions.map((item) => /* @__PURE__ */
|
|
3292
|
+
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ jsx52(TxStatusButton, { transaction: item }, item.txHash));
|
|
3337
3293
|
if (xpayTxStatusRoot === null) {
|
|
3338
3294
|
throw new Error("XPay was incorrectly initialised");
|
|
3339
3295
|
}
|
|
3340
3296
|
xpayTxStatusRoot.render(
|
|
3341
|
-
/* @__PURE__ */
|
|
3297
|
+
/* @__PURE__ */ jsx52("div", { className: "xpay-fixed xpay-bottom-5 xpay-right-2 xpay-flex xpay-flex-col xpay-gap-3 xpay-pl-9 xpay-items-end xpay-w-full xpay-z-50", children: buttons })
|
|
3342
3298
|
);
|
|
3343
3299
|
};
|
|
3344
3300
|
|
|
3345
3301
|
// src/components/Skeleton/index.tsx
|
|
3346
|
-
import { jsx as
|
|
3302
|
+
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
3347
3303
|
var Skeleton = ({ width, height }) => {
|
|
3348
|
-
return /* @__PURE__ */
|
|
3304
|
+
return /* @__PURE__ */ jsx53(
|
|
3349
3305
|
"div",
|
|
3350
3306
|
{
|
|
3351
3307
|
className: `xpay-bg-gray-700 xpay-rounded xpay-animate-pulse ${width} ${height}`
|
|
@@ -3357,13 +3313,13 @@ var Skeleton = ({ width, height }) => {
|
|
|
3357
3313
|
import retry from "async-retry";
|
|
3358
3314
|
|
|
3359
3315
|
// src/services/blockchain.ts
|
|
3360
|
-
import { ethers as
|
|
3316
|
+
import { ethers as ethers6 } from "ethers";
|
|
3361
3317
|
var getCustomTokenData = async (chain, tokenAddress) => {
|
|
3362
3318
|
const rpcUrl = chain.publicRpcUrls[0];
|
|
3363
|
-
const customTokenContract = new
|
|
3319
|
+
const customTokenContract = new ethers6.Contract(
|
|
3364
3320
|
tokenAddress.toLowerCase(),
|
|
3365
3321
|
ERC20Abi,
|
|
3366
|
-
|
|
3322
|
+
ethers6.getDefaultProvider(rpcUrl)
|
|
3367
3323
|
);
|
|
3368
3324
|
try {
|
|
3369
3325
|
const query = async (contract, method, args = []) => {
|
|
@@ -3402,7 +3358,7 @@ var renderTxStatus = async (txChainId, txHash) => {
|
|
|
3402
3358
|
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
3403
3359
|
);
|
|
3404
3360
|
const messageSentEvent = txReceipt.logs?.find((log) => {
|
|
3405
|
-
return log.topics[0] ===
|
|
3361
|
+
return log.topics[0] === ethers7.utils.id(MSG_SENT_EVENT_SIG);
|
|
3406
3362
|
});
|
|
3407
3363
|
if (!messageSentEvent) {
|
|
3408
3364
|
throw new Error(
|
|
@@ -3410,7 +3366,7 @@ var renderTxStatus = async (txChainId, txHash) => {
|
|
|
3410
3366
|
);
|
|
3411
3367
|
}
|
|
3412
3368
|
const messageId = messageSentEvent?.topics[1];
|
|
3413
|
-
const iface = new
|
|
3369
|
+
const iface = new ethers7.utils.Interface(MSG_SENT_EVENT_ABI);
|
|
3414
3370
|
const decodedMessageSentEvent = iface.parseLog(messageSentEvent);
|
|
3415
3371
|
if (!decodedMessageSentEvent) {
|
|
3416
3372
|
throw new Error(
|
|
@@ -3460,16 +3416,16 @@ var renderTxStatus = async (txChainId, txHash) => {
|
|
|
3460
3416
|
if (!xSwapRouterOnDestinationAddress) {
|
|
3461
3417
|
throw new Error(`Unknown destination XSwapRouter!`);
|
|
3462
3418
|
}
|
|
3463
|
-
const xSwapRouterOnDestination = new
|
|
3419
|
+
const xSwapRouterOnDestination = new ethers7.Contract(
|
|
3464
3420
|
xSwapRouterOnDestinationAddress,
|
|
3465
3421
|
MSG_RECEIVED_EVENT_ABI,
|
|
3466
|
-
|
|
3422
|
+
ethers7.getDefaultProvider(
|
|
3467
3423
|
supportedChains.find((chain) => chain.chainId === dstChainId)?.publicRpcUrls[0]
|
|
3468
3424
|
)
|
|
3469
3425
|
);
|
|
3470
3426
|
const msgReceivedEventFilter = {
|
|
3471
3427
|
address: xSwapRouterOnDestinationAddress,
|
|
3472
|
-
topics: [
|
|
3428
|
+
topics: [ethers7.utils.id(MSG_RECEIVED_EVENT_SIG), messageId]
|
|
3473
3429
|
};
|
|
3474
3430
|
const onSuccess = async () => {
|
|
3475
3431
|
updateTransactionDoneInRenderedTransactions(txHash);
|
|
@@ -3500,7 +3456,7 @@ var getTxReceipt = async (txChainId, txHash) => {
|
|
|
3500
3456
|
const chain = (await getChains()).find(
|
|
3501
3457
|
(chain2) => chain2.chainId === txChainId
|
|
3502
3458
|
);
|
|
3503
|
-
const provider = new
|
|
3459
|
+
const provider = new ethers7.providers.JsonRpcProvider(
|
|
3504
3460
|
chain?.publicRpcUrls[0]
|
|
3505
3461
|
);
|
|
3506
3462
|
return await retry(async () => {
|
|
@@ -3524,7 +3480,7 @@ var openTransactionModal = async ({
|
|
|
3524
3480
|
dstToken,
|
|
3525
3481
|
customContractCalls = [],
|
|
3526
3482
|
desc,
|
|
3527
|
-
|
|
3483
|
+
returnTransactions,
|
|
3528
3484
|
dstDisplayToken
|
|
3529
3485
|
}) => {
|
|
3530
3486
|
const supportedChains = (await getChains()).filter(
|
|
@@ -3538,10 +3494,10 @@ var openTransactionModal = async ({
|
|
|
3538
3494
|
customContractCalls,
|
|
3539
3495
|
desc,
|
|
3540
3496
|
supportedChains,
|
|
3541
|
-
|
|
3497
|
+
returnTransactions,
|
|
3542
3498
|
dstDisplayTokenAddr: dstDisplayToken
|
|
3543
3499
|
});
|
|
3544
|
-
if (
|
|
3500
|
+
if (returnTransactions) {
|
|
3545
3501
|
return route.transactions;
|
|
3546
3502
|
}
|
|
3547
3503
|
};
|