@xswap-link/sdk 0.2.4 → 0.2.5
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 +8 -0
- package/dist/index.css +13 -7
- package/dist/index.d.mts +19 -12
- package/dist/index.d.ts +19 -12
- package/dist/index.js +408 -263
- package/dist/index.mjs +337 -192
- package/package.json +1 -1
- package/src/components/TxConfigForm/FeesDetails.tsx +17 -13
- package/src/components/TxConfigForm/Form.tsx +21 -5
- package/src/components/TxConfigForm/History.tsx +31 -4
- package/src/components/TxConfigForm/Summary.tsx +16 -4
- package/src/components/TxConfigForm/SwapPanel.tsx +1 -1
- package/src/components/TxConfigForm/index.tsx +5 -0
- package/src/components/TxStatusButton/index.tsx +21 -13
- package/src/components/UnknownTokenLogo/UnknownTokenLogo.tsx +14 -0
- package/src/components/global.css +1 -1
- package/src/config/init.tsx +2 -2
- package/src/index.ts +9 -1
- package/src/models/TokenData.ts +1 -1
- package/src/models/TransactionHistory.ts +12 -8
- package/src/models/payloads/GetRoutePayload.ts +1 -0
- package/src/models/payloads/GetSwapTxPayload.ts +1 -0
- package/src/services/api.ts +9 -0
- package/src/services/blockchain.ts +49 -0
- package/src/services/index.ts +1 -0
- package/src/services/integrations/monitoring.ts +34 -14
- package/src/services/integrations/transactions.ts +8 -3
- package/src/utils/strings.ts +4 -0
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.2.
|
|
26
|
+
var version = "0.2.5";
|
|
27
27
|
|
|
28
28
|
// src/components/WaitingForInit/index.tsx
|
|
29
29
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -61,7 +61,7 @@ var initDocument = () => {
|
|
|
61
61
|
createInitIndicatorRoot();
|
|
62
62
|
Promise.all([
|
|
63
63
|
createStyleElement(),
|
|
64
|
-
|
|
64
|
+
createXSwapRoot(),
|
|
65
65
|
createTxStatusRoot()
|
|
66
66
|
]).then(() => {
|
|
67
67
|
initCompleted = true;
|
|
@@ -87,7 +87,7 @@ var createStyleElement = async () => {
|
|
|
87
87
|
style.textContent = text;
|
|
88
88
|
document.body.appendChild(style);
|
|
89
89
|
};
|
|
90
|
-
var
|
|
90
|
+
var createXSwapRoot = async () => {
|
|
91
91
|
const xswapElement = document.createElement("div");
|
|
92
92
|
xswapElement.setAttribute("id", "xswap-modal");
|
|
93
93
|
document.body.appendChild(xswapElement);
|
|
@@ -110,45 +110,6 @@ var displayInitIndicator = (display) => {
|
|
|
110
110
|
display ? initIndicatorRoot.render(/* @__PURE__ */ jsx2(WaitingForInit, {})) : initIndicatorRoot.render("");
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
// src/models/Addresses.ts
|
|
114
|
-
var ContractName = /* @__PURE__ */ ((ContractName2) => {
|
|
115
|
-
ContractName2["BatchQuery"] = "BatchQuery";
|
|
116
|
-
ContractName2["FeeCollector"] = "FeeCollector";
|
|
117
|
-
ContractName2["XSwapRouter"] = "XSwapRouter";
|
|
118
|
-
return ContractName2;
|
|
119
|
-
})(ContractName || {});
|
|
120
|
-
|
|
121
|
-
// src/models/Ecosystem.ts
|
|
122
|
-
var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
|
|
123
|
-
Ecosystem2["EVM"] = "evm";
|
|
124
|
-
return Ecosystem2;
|
|
125
|
-
})(Ecosystem || {});
|
|
126
|
-
|
|
127
|
-
// src/models/Environment.ts
|
|
128
|
-
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
129
|
-
Environment2["PROD"] = "production";
|
|
130
|
-
Environment2["DEV"] = "develop";
|
|
131
|
-
Environment2["LOCAL"] = "local";
|
|
132
|
-
return Environment2;
|
|
133
|
-
})(Environment || {});
|
|
134
|
-
|
|
135
|
-
// src/models/Web3Environment.ts
|
|
136
|
-
var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
|
|
137
|
-
Web3Environment2["DEVNET"] = "devnet";
|
|
138
|
-
Web3Environment2["TESTNET"] = "testnet";
|
|
139
|
-
Web3Environment2["MAINNET"] = "mainnet";
|
|
140
|
-
return Web3Environment2;
|
|
141
|
-
})(Web3Environment || {});
|
|
142
|
-
|
|
143
|
-
// src/models/XSwapCallType.ts
|
|
144
|
-
var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
|
|
145
|
-
XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
|
|
146
|
-
XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
|
|
147
|
-
XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
|
|
148
|
-
XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
|
|
149
|
-
return XSwapCallType2;
|
|
150
|
-
})(XSwapCallType || {});
|
|
151
|
-
|
|
152
113
|
// src/services/api.ts
|
|
153
114
|
async function _sendRequest(urlPath, options) {
|
|
154
115
|
const response = await fetch(`${xswap_config_default.apiUrl}${urlPath}`, {
|
|
@@ -191,10 +152,57 @@ async function getPrices(payload) {
|
|
|
191
152
|
})}`
|
|
192
153
|
);
|
|
193
154
|
}
|
|
155
|
+
async function getTxStatus(payload) {
|
|
156
|
+
return await _sendRequest(
|
|
157
|
+
`/getTxStatus?${new URLSearchParams({
|
|
158
|
+
data: JSON.stringify(payload)
|
|
159
|
+
// todo remove once gcp starts working
|
|
160
|
+
})}`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
194
163
|
|
|
195
164
|
// src/services/integrations/customCalls/staking.ts
|
|
196
165
|
import { ethers as ethers2 } from "ethers";
|
|
197
166
|
|
|
167
|
+
// src/models/Addresses.ts
|
|
168
|
+
var ContractName = /* @__PURE__ */ ((ContractName2) => {
|
|
169
|
+
ContractName2["BatchQuery"] = "BatchQuery";
|
|
170
|
+
ContractName2["FeeCollector"] = "FeeCollector";
|
|
171
|
+
ContractName2["XSwapRouter"] = "XSwapRouter";
|
|
172
|
+
return ContractName2;
|
|
173
|
+
})(ContractName || {});
|
|
174
|
+
|
|
175
|
+
// src/models/Ecosystem.ts
|
|
176
|
+
var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
|
|
177
|
+
Ecosystem2["EVM"] = "evm";
|
|
178
|
+
return Ecosystem2;
|
|
179
|
+
})(Ecosystem || {});
|
|
180
|
+
|
|
181
|
+
// src/models/Environment.ts
|
|
182
|
+
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
183
|
+
Environment2["PROD"] = "production";
|
|
184
|
+
Environment2["DEV"] = "develop";
|
|
185
|
+
Environment2["LOCAL"] = "local";
|
|
186
|
+
return Environment2;
|
|
187
|
+
})(Environment || {});
|
|
188
|
+
|
|
189
|
+
// src/models/Web3Environment.ts
|
|
190
|
+
var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
|
|
191
|
+
Web3Environment2["DEVNET"] = "devnet";
|
|
192
|
+
Web3Environment2["TESTNET"] = "testnet";
|
|
193
|
+
Web3Environment2["MAINNET"] = "mainnet";
|
|
194
|
+
return Web3Environment2;
|
|
195
|
+
})(Web3Environment || {});
|
|
196
|
+
|
|
197
|
+
// src/models/XSwapCallType.ts
|
|
198
|
+
var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
|
|
199
|
+
XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
|
|
200
|
+
XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
|
|
201
|
+
XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
|
|
202
|
+
XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
|
|
203
|
+
return XSwapCallType2;
|
|
204
|
+
})(XSwapCallType || {});
|
|
205
|
+
|
|
198
206
|
// src/utils/contracts.ts
|
|
199
207
|
import { ethers } from "ethers";
|
|
200
208
|
|
|
@@ -626,6 +634,9 @@ var shortAddress = (address) => {
|
|
|
626
634
|
address.length
|
|
627
635
|
)}`;
|
|
628
636
|
};
|
|
637
|
+
var isETHAddressValid = (address) => {
|
|
638
|
+
return /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
639
|
+
};
|
|
629
640
|
|
|
630
641
|
// src/utils/index.ts
|
|
631
642
|
import { format } from "date-fns";
|
|
@@ -654,7 +665,7 @@ var getDate = (blockTimestamp) => {
|
|
|
654
665
|
};
|
|
655
666
|
|
|
656
667
|
// src/services/integrations/monitoring.ts
|
|
657
|
-
import { ethers as
|
|
668
|
+
import { ethers as ethers5 } from "ethers";
|
|
658
669
|
|
|
659
670
|
// src/components/Alert/index.tsx
|
|
660
671
|
import { jsxs } from "react/jsx-runtime";
|
|
@@ -666,7 +677,7 @@ var Alert = ({ desc }) => {
|
|
|
666
677
|
};
|
|
667
678
|
|
|
668
679
|
// src/components/TxConfigForm/index.tsx
|
|
669
|
-
import { useMemo as
|
|
680
|
+
import { useMemo as useMemo8 } from "react";
|
|
670
681
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
671
682
|
import { WagmiProvider } from "wagmi";
|
|
672
683
|
|
|
@@ -1320,15 +1331,35 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1320
1331
|
const fetchedTransactions = [];
|
|
1321
1332
|
if (downloadedHistory) {
|
|
1322
1333
|
for (const entry of downloadedHistory.history) {
|
|
1334
|
+
let status = "IN_PROGRESS";
|
|
1323
1335
|
if (!entry.source) {
|
|
1324
1336
|
continue;
|
|
1325
1337
|
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1338
|
+
if (entry.failed) {
|
|
1339
|
+
status = "REVERTED";
|
|
1340
|
+
}
|
|
1328
1341
|
if (!!entry.target) {
|
|
1329
1342
|
status = "DONE";
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1343
|
+
}
|
|
1344
|
+
if (entry.transferType === "SINGLE_CHAIN") {
|
|
1345
|
+
if (!entry.target) {
|
|
1346
|
+
continue;
|
|
1347
|
+
}
|
|
1348
|
+
const blockTimestampMs2 = new Date(entry.target.blockTime).getTime();
|
|
1349
|
+
const estimatedDeliveryTimestamp2 = blockTimestampMs2 / 1e3;
|
|
1350
|
+
fetchedTransactions.push({
|
|
1351
|
+
hash: entry.target.transactionHash,
|
|
1352
|
+
timestamp: blockTimestampMs2 / 1e3,
|
|
1353
|
+
sourceChainId: entry.target.blockchainId,
|
|
1354
|
+
targetChainId: entry.target.blockchainId,
|
|
1355
|
+
amountWei: entry.source.tokenAmount,
|
|
1356
|
+
tokenAddress: entry.source.tokenAddress,
|
|
1357
|
+
tokenOutAddress: entry.target?.tokenAmount,
|
|
1358
|
+
tokenOutAmount: entry.target?.tokenAmount,
|
|
1359
|
+
estimatedDeliveryTimestamp: estimatedDeliveryTimestamp2,
|
|
1360
|
+
status
|
|
1361
|
+
});
|
|
1362
|
+
continue;
|
|
1332
1363
|
}
|
|
1333
1364
|
const blockTimestampMs = new Date(entry.source.blockTime).getTime();
|
|
1334
1365
|
const estimatedDeliveryTimestamp = new BigNumberJS2(
|
|
@@ -1522,6 +1553,7 @@ var Settings = ({
|
|
|
1522
1553
|
};
|
|
1523
1554
|
|
|
1524
1555
|
// src/components/TxConfigForm/FeesDetails.tsx
|
|
1556
|
+
import { useMemo as useMemo2 } from "react";
|
|
1525
1557
|
import { jsx as jsx30, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1526
1558
|
var FeesDetails = ({
|
|
1527
1559
|
isGettingRoute,
|
|
@@ -1534,6 +1566,9 @@ var FeesDetails = ({
|
|
|
1534
1566
|
feesDetailsShown,
|
|
1535
1567
|
setFeesDetailsShown
|
|
1536
1568
|
}) => {
|
|
1569
|
+
const isExpressDeliveryPossible = useMemo2(() => {
|
|
1570
|
+
return expressChecked && !exceedsExpressDeliveryLimit;
|
|
1571
|
+
}, [expressChecked, exceedsExpressDeliveryLimit]);
|
|
1537
1572
|
return /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-3 globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-2 sm:p-4 mb-1", children: [
|
|
1538
1573
|
/* @__PURE__ */ jsxs11("div", { className: "flex w-full items-center justify-between text-xs sm:text-sm", children: [
|
|
1539
1574
|
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1 font-medium text-white opacity-60", children: [
|
|
@@ -1550,13 +1585,13 @@ var FeesDetails = ({
|
|
|
1550
1585
|
})} ${paymentToken?.symbol}`
|
|
1551
1586
|
] }),
|
|
1552
1587
|
/* @__PURE__ */ jsxs11("div", { className: "flex gap-1 items-center", children: [
|
|
1553
|
-
/* @__PURE__ */ jsxs11(
|
|
1588
|
+
route?.xSwapFees.expressDeliveryFee && !isGettingRoute && /* @__PURE__ */ jsxs11(
|
|
1554
1589
|
"div",
|
|
1555
1590
|
{
|
|
1556
|
-
className: `flex gap-1 items-center font-medium ${
|
|
1591
|
+
className: `flex gap-1 items-center font-medium ${isExpressDeliveryPossible ? "text-x_green" : "text-white opacity-60"}`,
|
|
1557
1592
|
children: [
|
|
1558
1593
|
/* @__PURE__ */ jsx30(TimerIcon, {}),
|
|
1559
|
-
|
|
1594
|
+
isExpressDeliveryPossible ? "Fast ~ 30sec " : "Normal ~ 30min"
|
|
1560
1595
|
]
|
|
1561
1596
|
}
|
|
1562
1597
|
),
|
|
@@ -1612,7 +1647,7 @@ var FeesDetails = ({
|
|
|
1612
1647
|
};
|
|
1613
1648
|
|
|
1614
1649
|
// src/components/TxConfigForm/Summary.tsx
|
|
1615
|
-
import { useEffect as useEffect5, useMemo as
|
|
1650
|
+
import { useEffect as useEffect5, useMemo as useMemo4, useState as useState5 } from "react";
|
|
1616
1651
|
|
|
1617
1652
|
// src/components/TxConfigForm/UsdPrice.tsx
|
|
1618
1653
|
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
@@ -1640,8 +1675,20 @@ var UsdPrice = ({
|
|
|
1640
1675
|
return /* @__PURE__ */ jsx31("div", { className: "opacity-60 py-4", children: loading ? /* @__PURE__ */ jsx31(Skeleton, { width: "w-12", height: "h-4" }) : token ? prices && prices[token.address] ? /* @__PURE__ */ jsx31("div", { children: `$${usdPrice}` }) : /* @__PURE__ */ jsx31(Alert, { desc: "Unknown price" }) : /* @__PURE__ */ jsx31(Fragment3, { children: "$0.00" }) });
|
|
1641
1676
|
};
|
|
1642
1677
|
|
|
1678
|
+
// src/components/UnknownTokenLogo/UnknownTokenLogo.tsx
|
|
1679
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
1680
|
+
var UnknownTokenLogo = ({ tokenName, className }) => {
|
|
1681
|
+
return /* @__PURE__ */ jsx32(
|
|
1682
|
+
"div",
|
|
1683
|
+
{
|
|
1684
|
+
className: `w-5 h-5 rounded-full bg-white shadow-sm flex items-center justify-center text-black ${className}`,
|
|
1685
|
+
children: tokenName.substring(0, 1)
|
|
1686
|
+
}
|
|
1687
|
+
);
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1643
1690
|
// src/components/TxConfigForm/Summary.tsx
|
|
1644
|
-
import { jsx as
|
|
1691
|
+
import { jsx as jsx33, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1645
1692
|
var Summary = ({
|
|
1646
1693
|
isGettingRoute,
|
|
1647
1694
|
route,
|
|
@@ -1649,7 +1696,7 @@ var Summary = ({
|
|
|
1649
1696
|
dstChain
|
|
1650
1697
|
}) => {
|
|
1651
1698
|
const [prices, setPrices] = useState5();
|
|
1652
|
-
const amountReadable =
|
|
1699
|
+
const amountReadable = useMemo4(
|
|
1653
1700
|
() => weiToHumanReadable({
|
|
1654
1701
|
amount: route?.estAmountOut || "0",
|
|
1655
1702
|
decimals: dstToken?.decimals || 18,
|
|
@@ -1667,31 +1714,44 @@ var Summary = ({
|
|
|
1667
1714
|
return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4 relative", children: [
|
|
1668
1715
|
/* @__PURE__ */ jsxs12("div", { className: "flex justify-between", children: [
|
|
1669
1716
|
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1", children: [
|
|
1670
|
-
/* @__PURE__ */
|
|
1671
|
-
isGettingRoute ? /* @__PURE__ */
|
|
1717
|
+
/* @__PURE__ */ jsx33("p", { className: "text-[rgba(255,255,255,0.6)] text-sm", children: "You receive" }),
|
|
1718
|
+
isGettingRoute ? /* @__PURE__ */ jsx33(
|
|
1672
1719
|
Skeleton,
|
|
1673
1720
|
{
|
|
1674
1721
|
width: "w-[100px]",
|
|
1675
1722
|
height: "h-[36px]",
|
|
1676
1723
|
other: "sm:w-[190px]"
|
|
1677
1724
|
}
|
|
1678
|
-
) : /* @__PURE__ */
|
|
1725
|
+
) : /* @__PURE__ */ jsx33("div", { className: "flex gap-2 items-center text-white text-xl sm:text-3xl", children: amountReadable })
|
|
1679
1726
|
] }),
|
|
1680
1727
|
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-end gap-1 text-sm", children: [
|
|
1681
1728
|
/* @__PURE__ */ jsxs12("div", { className: "flex justify-center items-center gap-1", children: [
|
|
1682
|
-
/* @__PURE__ */
|
|
1683
|
-
|
|
1729
|
+
/* @__PURE__ */ jsx33("div", { className: "w-5 h-5", children: dstToken?.image ? /* @__PURE__ */ jsx33(
|
|
1730
|
+
"img",
|
|
1731
|
+
{
|
|
1732
|
+
className: "w-5 h-5",
|
|
1733
|
+
src: dstToken?.image,
|
|
1734
|
+
alt: dstToken?.name
|
|
1735
|
+
}
|
|
1736
|
+
) : /* @__PURE__ */ jsx33(
|
|
1737
|
+
UnknownTokenLogo,
|
|
1738
|
+
{
|
|
1739
|
+
tokenName: "?",
|
|
1740
|
+
className: "token-select__generated-logo"
|
|
1741
|
+
}
|
|
1742
|
+
) }),
|
|
1743
|
+
/* @__PURE__ */ jsx33("p", { className: "text-base sm:text-xl", children: dstToken?.name })
|
|
1684
1744
|
] }),
|
|
1685
1745
|
/* @__PURE__ */ jsxs12("div", { className: "flex justify-center items-center gap-1", children: [
|
|
1686
|
-
/* @__PURE__ */
|
|
1746
|
+
/* @__PURE__ */ jsx33("p", { className: "text-[rgba(255,255,255,0.6)] text-right", children: "on " }),
|
|
1687
1747
|
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1 text-white", children: [
|
|
1688
|
-
/* @__PURE__ */
|
|
1689
|
-
/* @__PURE__ */
|
|
1748
|
+
/* @__PURE__ */ jsx33("div", { className: "w-4 h-4", children: /* @__PURE__ */ jsx33("img", { src: dstChain?.image, alt: dstChain?.name }) }),
|
|
1749
|
+
/* @__PURE__ */ jsx33("div", { children: dstChain?.displayName })
|
|
1690
1750
|
] })
|
|
1691
1751
|
] })
|
|
1692
1752
|
] })
|
|
1693
1753
|
] }),
|
|
1694
|
-
/* @__PURE__ */
|
|
1754
|
+
/* @__PURE__ */ jsx33(
|
|
1695
1755
|
UsdPrice,
|
|
1696
1756
|
{
|
|
1697
1757
|
prices,
|
|
@@ -1701,17 +1761,17 @@ var Summary = ({
|
|
|
1701
1761
|
type: "dst"
|
|
1702
1762
|
}
|
|
1703
1763
|
),
|
|
1704
|
-
/* @__PURE__ */
|
|
1764
|
+
/* @__PURE__ */ jsx33("div", { className: "absolute right-[50%] top-0 translate-x-1/2 translate-y-[-60%] globalBorder rounded-xl p-[5px] bg-[rgba(15,15,15,1)]", children: /* @__PURE__ */ jsx33("div", { className: " flex items-center justify-center rounded-lg w-8 h-8 bg-gradient-to-l from-[rgba(54,129,198,1)] to-[rgba(43,74,157,1)] ", children: /* @__PURE__ */ jsx33(ArrowDownIcon, {}) }) })
|
|
1705
1765
|
] });
|
|
1706
1766
|
};
|
|
1707
1767
|
|
|
1708
1768
|
// src/components/TxConfigForm/SwapPanel.tsx
|
|
1709
|
-
import { useState as useState7, useEffect as useEffect6, useRef as useRef2, useMemo as
|
|
1769
|
+
import { useState as useState7, useEffect as useEffect6, useRef as useRef2, useMemo as useMemo7 } from "react";
|
|
1710
1770
|
|
|
1711
1771
|
// src/components/TxConfigForm/TokenPicker.tsx
|
|
1712
|
-
import { useState as useState6, useMemo as
|
|
1772
|
+
import { useState as useState6, useMemo as useMemo5 } from "react";
|
|
1713
1773
|
import { createPortal } from "react-dom";
|
|
1714
|
-
import { Fragment as Fragment4, jsx as
|
|
1774
|
+
import { Fragment as Fragment4, jsx as jsx34, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1715
1775
|
var TokenPicker = ({
|
|
1716
1776
|
onCloseClick,
|
|
1717
1777
|
tokens,
|
|
@@ -1729,7 +1789,7 @@ var TokenPicker = ({
|
|
|
1729
1789
|
onCloseClick();
|
|
1730
1790
|
}
|
|
1731
1791
|
};
|
|
1732
|
-
const filteredTokens =
|
|
1792
|
+
const filteredTokens = useMemo5(() => {
|
|
1733
1793
|
const isMatch = (value, searchValue2) => value.toLowerCase().indexOf(searchValue2.toLowerCase()) > -1;
|
|
1734
1794
|
return tokens?.filter(
|
|
1735
1795
|
(token) => isMatch(token.symbol, searchValue) || isMatch(token.name, searchValue) || token.address === searchValue.toLowerCase()
|
|
@@ -1738,24 +1798,24 @@ var TokenPicker = ({
|
|
|
1738
1798
|
);
|
|
1739
1799
|
}, [searchValue, tokens]);
|
|
1740
1800
|
return modalRoot ? createPortal(
|
|
1741
|
-
/* @__PURE__ */
|
|
1801
|
+
/* @__PURE__ */ jsx34(
|
|
1742
1802
|
"div",
|
|
1743
1803
|
{
|
|
1744
1804
|
onClick: onBackdropClick,
|
|
1745
1805
|
className: "box-border fixed h-full w-full z-[999] top-0 left-0 bg-[rgba(0,0,0,0.8)] flex items-center justify-center p-5",
|
|
1746
1806
|
children: /* @__PURE__ */ jsxs13("div", { className: "relative bg-black rounded-3xl p-6 max-h-[70%] flex flex-col text-base text-white w-[452px] h-[70%] border border-solid border-[rgba(255,255,255,0.2)]", children: [
|
|
1747
|
-
/* @__PURE__ */
|
|
1807
|
+
/* @__PURE__ */ jsx34(
|
|
1748
1808
|
"div",
|
|
1749
1809
|
{
|
|
1750
1810
|
onClick: onCloseClick,
|
|
1751
1811
|
className: "absolute top-4 right-4 cursor-pointer",
|
|
1752
|
-
children: /* @__PURE__ */
|
|
1812
|
+
children: /* @__PURE__ */ jsx34(CloseIcon, {})
|
|
1753
1813
|
}
|
|
1754
1814
|
),
|
|
1755
|
-
/* @__PURE__ */
|
|
1815
|
+
/* @__PURE__ */ jsx34("p", { className: "text-base mb-4", children: "Pick a token" }),
|
|
1756
1816
|
/* @__PURE__ */ jsxs13("div", { className: "flex items-center border border-solid border-[rgba(255,255,255,0.1)] rounded-lg py-0 px-3 gap-2 bg-[rgba(15,15,15,1)]", children: [
|
|
1757
|
-
/* @__PURE__ */
|
|
1758
|
-
/* @__PURE__ */
|
|
1817
|
+
/* @__PURE__ */ jsx34("div", { className: "w-6 h-6", children: /* @__PURE__ */ jsx34(SearchIcon, {}) }),
|
|
1818
|
+
/* @__PURE__ */ jsx34(
|
|
1759
1819
|
"input",
|
|
1760
1820
|
{
|
|
1761
1821
|
placeholder: "Search name or paste address",
|
|
@@ -1765,7 +1825,7 @@ var TokenPicker = ({
|
|
|
1765
1825
|
}
|
|
1766
1826
|
)
|
|
1767
1827
|
] }),
|
|
1768
|
-
/* @__PURE__ */
|
|
1828
|
+
/* @__PURE__ */ jsx34("div", { className: "my-4 mx-0 flex flex-wrap gap-3", children: tokens?.filter((token) => token?.quickPick).map((token) => /* @__PURE__ */ jsxs13(
|
|
1769
1829
|
"div",
|
|
1770
1830
|
{
|
|
1771
1831
|
className: `flex gap-2 py-1 px-2 items-center bg-[rgb(15,15,15)] rounded-2xl border border-solid border-[rgba(255,255,255,0.1)] hover:bg-[rgb(25,25,25)] hover:cursor-pointer ${token.address === selectedToken?.address ? "bg-[rgb(35, 35, 35)]" : ""}`,
|
|
@@ -1774,14 +1834,14 @@ var TokenPicker = ({
|
|
|
1774
1834
|
onCloseClick();
|
|
1775
1835
|
},
|
|
1776
1836
|
children: [
|
|
1777
|
-
/* @__PURE__ */
|
|
1778
|
-
/* @__PURE__ */
|
|
1837
|
+
/* @__PURE__ */ jsx34("img", { src: token.image, alt: token.name, className: "w-5" }),
|
|
1838
|
+
/* @__PURE__ */ jsx34("div", { className: "text-sm", children: token.symbol })
|
|
1779
1839
|
]
|
|
1780
1840
|
},
|
|
1781
1841
|
token.address
|
|
1782
1842
|
)) }),
|
|
1783
|
-
/* @__PURE__ */
|
|
1784
|
-
/* @__PURE__ */
|
|
1843
|
+
/* @__PURE__ */ jsx34("div", { className: "h-[2px] my-0 mx-[-24px] w-[100%+48px] px-12 bg-[rgba(255,255,255,0.1)]" }),
|
|
1844
|
+
/* @__PURE__ */ jsx34("div", { className: "overflow-y-scroll h-full mx-[-24px] w-[100%+48px] flex flex-col", children: filteredTokens && filteredTokens.length > 0 ? filteredTokens.map((token, index) => /* @__PURE__ */ jsxs13(
|
|
1785
1845
|
"div",
|
|
1786
1846
|
{
|
|
1787
1847
|
className: `flex gap-3 py-2 px-[24px] w-full items-center hover:bg-[rgb(25,25,25)] hover:cursor-pointer ${token.address === selectedToken?.address ? "bg-[rgb(35,35,35)]" : ""}`,
|
|
@@ -1790,29 +1850,29 @@ var TokenPicker = ({
|
|
|
1790
1850
|
onCloseClick();
|
|
1791
1851
|
},
|
|
1792
1852
|
children: [
|
|
1793
|
-
token.image ? /* @__PURE__ */
|
|
1853
|
+
token.image ? /* @__PURE__ */ jsx34(
|
|
1794
1854
|
"img",
|
|
1795
1855
|
{
|
|
1796
1856
|
src: token.image,
|
|
1797
1857
|
alt: token.name,
|
|
1798
1858
|
className: "token-picker__all__logo"
|
|
1799
1859
|
}
|
|
1800
|
-
) : /* @__PURE__ */
|
|
1860
|
+
) : /* @__PURE__ */ jsx34("div", { className: "flex items-center justify-center w-9 h-9 text-[15px] ml-1 rounded-full bg-[#272e40] text-[#e0e7fa]", children: token?.symbol.substring(0, 1) }),
|
|
1801
1861
|
/* @__PURE__ */ jsxs13("div", { className: "flex justify-between items-center gap-1 overflow-hidden grow", children: [
|
|
1802
1862
|
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col leading-[16px]", children: [
|
|
1803
|
-
/* @__PURE__ */
|
|
1804
|
-
/* @__PURE__ */
|
|
1863
|
+
/* @__PURE__ */ jsx34("div", { className: "overflow-hidden whitespace-nowrap text-ellipsis text-[15px]", children: token.name }),
|
|
1864
|
+
/* @__PURE__ */ jsx34("div", { className: "text-[#888] text-[11px]", children: token.symbol })
|
|
1805
1865
|
] }),
|
|
1806
|
-
signer && /* @__PURE__ */
|
|
1866
|
+
signer && /* @__PURE__ */ jsx34(Fragment4, { children: balances && balances[token.address] && token.decimals ? /* @__PURE__ */ jsx34("div", { className: "text-xs", children: weiToHumanReadable({
|
|
1807
1867
|
amount: balances[token.address]?.toString() || "0",
|
|
1808
1868
|
decimals: token.decimals,
|
|
1809
1869
|
precisionFractionalPlaces: 4
|
|
1810
|
-
}) }) : /* @__PURE__ */
|
|
1870
|
+
}) }) : /* @__PURE__ */ jsx34(Skeleton, { width: "w-12", height: "h-3" }) })
|
|
1811
1871
|
] })
|
|
1812
1872
|
]
|
|
1813
1873
|
},
|
|
1814
1874
|
`${index}_${token.address}`
|
|
1815
|
-
)) : /* @__PURE__ */
|
|
1875
|
+
)) : /* @__PURE__ */ jsx34("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx34("p", { className: "text-sm text-white", children: "No tokens found." }) }) })
|
|
1816
1876
|
] })
|
|
1817
1877
|
}
|
|
1818
1878
|
),
|
|
@@ -1821,7 +1881,7 @@ var TokenPicker = ({
|
|
|
1821
1881
|
};
|
|
1822
1882
|
|
|
1823
1883
|
// src/components/TxConfigForm/ChainListElement.tsx
|
|
1824
|
-
import { jsx as
|
|
1884
|
+
import { jsx as jsx35, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1825
1885
|
var ChainListElement = ({
|
|
1826
1886
|
chain,
|
|
1827
1887
|
setSrcChain,
|
|
@@ -1839,21 +1899,21 @@ var ChainListElement = ({
|
|
|
1839
1899
|
setChainListShown(false);
|
|
1840
1900
|
},
|
|
1841
1901
|
children: [
|
|
1842
|
-
/* @__PURE__ */
|
|
1902
|
+
/* @__PURE__ */ jsx35("img", { width: 12, height: 12, src: chain.image, alt: chain.displayName }),
|
|
1843
1903
|
chain.displayName
|
|
1844
1904
|
]
|
|
1845
1905
|
}
|
|
1846
1906
|
),
|
|
1847
|
-
index !== length - 1 && /* @__PURE__ */
|
|
1907
|
+
index !== length - 1 && /* @__PURE__ */ jsx35("div", { className: "h-px mx-2 bg-[rgba(255,255,255,0.15)]" })
|
|
1848
1908
|
] }, `${chain.ecosystem}-${chain.chainId}`);
|
|
1849
1909
|
};
|
|
1850
1910
|
|
|
1851
1911
|
// src/components/TxConfigForm/BalanceComponent.tsx
|
|
1852
|
-
import { useMemo as
|
|
1912
|
+
import { useMemo as useMemo6 } from "react";
|
|
1853
1913
|
import BigNumber3 from "bignumber.js";
|
|
1854
|
-
import { Fragment as Fragment5, jsx as
|
|
1914
|
+
import { Fragment as Fragment5, jsx as jsx36, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1855
1915
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
1856
|
-
const balanceText =
|
|
1916
|
+
const balanceText = useMemo6(() => {
|
|
1857
1917
|
if (!balances || !srcToken) return "0";
|
|
1858
1918
|
if (balances[srcToken.address]?.toString() === "0") return "0";
|
|
1859
1919
|
const fullHumanReadable = weiToHumanReadable({
|
|
@@ -1879,12 +1939,12 @@ var BalanceComponent = ({ srcToken, balances }) => {
|
|
|
1879
1939
|
decimals: srcToken.decimals,
|
|
1880
1940
|
precisionFractionalPlaces: 4
|
|
1881
1941
|
}) : 0,
|
|
1882
|
-
/* @__PURE__ */
|
|
1942
|
+
/* @__PURE__ */ jsx36("span", { className: "bg-gradient-to-r from-x_blue_light to-x_blue_dark bg-clip-text text-transparent", children: "Max" })
|
|
1883
1943
|
] });
|
|
1884
1944
|
};
|
|
1885
1945
|
|
|
1886
1946
|
// src/components/TxConfigForm/SwapPanel.tsx
|
|
1887
|
-
import { jsx as
|
|
1947
|
+
import { jsx as jsx37, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1888
1948
|
var SwapPanel = ({
|
|
1889
1949
|
amount,
|
|
1890
1950
|
setAmount,
|
|
@@ -1916,7 +1976,7 @@ var SwapPanel = ({
|
|
|
1916
1976
|
weiToHumanReadable({
|
|
1917
1977
|
amount: balances[srcToken.address]?.toString() || "0",
|
|
1918
1978
|
decimals: srcToken.decimals,
|
|
1919
|
-
precisionFractionalPlaces:
|
|
1979
|
+
precisionFractionalPlaces: srcToken.decimals
|
|
1920
1980
|
})
|
|
1921
1981
|
);
|
|
1922
1982
|
};
|
|
@@ -1926,15 +1986,15 @@ var SwapPanel = ({
|
|
|
1926
1986
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1927
1987
|
}
|
|
1928
1988
|
}, [chainListShown]);
|
|
1929
|
-
const chainListOptions =
|
|
1989
|
+
const chainListOptions = useMemo7(
|
|
1930
1990
|
() => supportedChains.filter((chain) => chain.chainId !== srcChain?.chainId),
|
|
1931
1991
|
[supportedChains, srcChain]
|
|
1932
1992
|
);
|
|
1933
1993
|
return /* @__PURE__ */ jsxs16("div", { className: "flex justify-between globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4", children: [
|
|
1934
1994
|
/* @__PURE__ */ jsxs16("div", { className: "flex flex-col justify-between gap-2 overflow-hidden w-1/2", children: [
|
|
1935
1995
|
/* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-1", children: [
|
|
1936
|
-
/* @__PURE__ */
|
|
1937
|
-
/* @__PURE__ */
|
|
1996
|
+
/* @__PURE__ */ jsx37("p", { className: "text-white opacity-60 text-xs sm:text-sm font-medium", children: "You pay" }),
|
|
1997
|
+
/* @__PURE__ */ jsx37(
|
|
1938
1998
|
"input",
|
|
1939
1999
|
{
|
|
1940
2000
|
className: "p-0 border-none outline-none bg-transparent text-2xl overflow-ellipsis",
|
|
@@ -1953,7 +2013,7 @@ var SwapPanel = ({
|
|
|
1953
2013
|
}
|
|
1954
2014
|
)
|
|
1955
2015
|
] }),
|
|
1956
|
-
/* @__PURE__ */
|
|
2016
|
+
/* @__PURE__ */ jsx37("div", { className: "flex items-center text-sm text-[rgba(255,255,255,0.6)]", children: /* @__PURE__ */ jsx37(
|
|
1957
2017
|
UsdPrice,
|
|
1958
2018
|
{
|
|
1959
2019
|
prices,
|
|
@@ -1974,7 +2034,7 @@ var SwapPanel = ({
|
|
|
1974
2034
|
setTokenListShown((state) => !state);
|
|
1975
2035
|
},
|
|
1976
2036
|
children: [
|
|
1977
|
-
/* @__PURE__ */
|
|
2037
|
+
/* @__PURE__ */ jsx37(
|
|
1978
2038
|
"img",
|
|
1979
2039
|
{
|
|
1980
2040
|
height: 16,
|
|
@@ -1983,12 +2043,12 @@ var SwapPanel = ({
|
|
|
1983
2043
|
alt: srcToken?.name
|
|
1984
2044
|
}
|
|
1985
2045
|
),
|
|
1986
|
-
/* @__PURE__ */
|
|
1987
|
-
/* @__PURE__ */
|
|
2046
|
+
/* @__PURE__ */ jsx37("div", { children: srcToken?.symbol }),
|
|
2047
|
+
/* @__PURE__ */ jsx37(DownArrowIcon, {})
|
|
1988
2048
|
]
|
|
1989
2049
|
}
|
|
1990
2050
|
),
|
|
1991
|
-
tokenListShown && /* @__PURE__ */
|
|
2051
|
+
tokenListShown && /* @__PURE__ */ jsx37(
|
|
1992
2052
|
TokenPicker,
|
|
1993
2053
|
{
|
|
1994
2054
|
onCloseClick: () => setTokenListShown(false),
|
|
@@ -1999,12 +2059,12 @@ var SwapPanel = ({
|
|
|
1999
2059
|
balances
|
|
2000
2060
|
}
|
|
2001
2061
|
),
|
|
2002
|
-
/* @__PURE__ */
|
|
2062
|
+
/* @__PURE__ */ jsx37(
|
|
2003
2063
|
"div",
|
|
2004
2064
|
{
|
|
2005
2065
|
onClick: handleMaxClick,
|
|
2006
2066
|
className: "flex gap-1 items-center font-medium text-white opacity-60 py-0.5 cursor-pointer",
|
|
2007
|
-
children: signer && /* @__PURE__ */
|
|
2067
|
+
children: signer && /* @__PURE__ */ jsx37(BalanceComponent, { balances, srcToken })
|
|
2008
2068
|
}
|
|
2009
2069
|
),
|
|
2010
2070
|
/* @__PURE__ */ jsxs16(
|
|
@@ -2014,7 +2074,7 @@ var SwapPanel = ({
|
|
|
2014
2074
|
className: "bg-black globalBorder rounded-2xl whitespace-nowrap flex items-center p-2 cursor-pointer gap-2",
|
|
2015
2075
|
onClick: () => setChainListShown((prev) => !prev),
|
|
2016
2076
|
children: [
|
|
2017
|
-
/* @__PURE__ */
|
|
2077
|
+
/* @__PURE__ */ jsx37(
|
|
2018
2078
|
"img",
|
|
2019
2079
|
{
|
|
2020
2080
|
width: "16",
|
|
@@ -2023,17 +2083,17 @@ var SwapPanel = ({
|
|
|
2023
2083
|
alt: srcChain?.name
|
|
2024
2084
|
}
|
|
2025
2085
|
),
|
|
2026
|
-
/* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
2086
|
+
/* @__PURE__ */ jsx37("div", { children: srcChain?.displayName }),
|
|
2087
|
+
/* @__PURE__ */ jsx37(DownArrowIcon, {})
|
|
2028
2088
|
]
|
|
2029
2089
|
}
|
|
2030
2090
|
),
|
|
2031
|
-
chainListShown && /* @__PURE__ */
|
|
2091
|
+
chainListShown && /* @__PURE__ */ jsx37(
|
|
2032
2092
|
"ul",
|
|
2033
2093
|
{
|
|
2034
2094
|
ref: listRef,
|
|
2035
2095
|
className: "bg-black globalBorder rounded-lg whitespace-nowrap z-1 right-0 top-10 px-2 max-w-full max-h-[40vh] overflow-auto absolute text-sm z-20",
|
|
2036
|
-
children: chainListOptions.map((chain, index) => /* @__PURE__ */
|
|
2096
|
+
children: chainListOptions.map((chain, index) => /* @__PURE__ */ jsx37(
|
|
2037
2097
|
ChainListElement,
|
|
2038
2098
|
{
|
|
2039
2099
|
index,
|
|
@@ -2050,9 +2110,9 @@ var SwapPanel = ({
|
|
|
2050
2110
|
};
|
|
2051
2111
|
|
|
2052
2112
|
// src/components/TxConfigForm/ErrorField.tsx
|
|
2053
|
-
import { jsx as
|
|
2113
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
2054
2114
|
var ErrorField = ({ error }) => {
|
|
2055
|
-
return /* @__PURE__ */
|
|
2115
|
+
return /* @__PURE__ */ jsx38(
|
|
2056
2116
|
"div",
|
|
2057
2117
|
{
|
|
2058
2118
|
className: `flex justify-center mb-1 items-center w-full rounded-2xl bg-x_error_background border border-solid ${error.length > 0 ? "border-x_error_border" : "border-transparent"}`,
|
|
@@ -2062,15 +2122,15 @@ var ErrorField = ({ error }) => {
|
|
|
2062
2122
|
};
|
|
2063
2123
|
|
|
2064
2124
|
// src/components/TxConfigForm/Description.tsx
|
|
2065
|
-
import { jsx as
|
|
2125
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
2066
2126
|
var Description = ({ description }) => {
|
|
2067
|
-
return /* @__PURE__ */
|
|
2127
|
+
return /* @__PURE__ */ jsx39("div", { className: "flex flex-col items-start rounded-lg px-4 py-2", children: /* @__PURE__ */ jsx39("div", { className: "w-full flex gap-4 items-start justify-between text-xl", children: description }) });
|
|
2068
2128
|
};
|
|
2069
2129
|
|
|
2070
2130
|
// src/components/TxConfigForm/Button.tsx
|
|
2071
|
-
import { jsx as
|
|
2131
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
2072
2132
|
var Button = ({ children, onClick, type, disabled }) => {
|
|
2073
|
-
return /* @__PURE__ */
|
|
2133
|
+
return /* @__PURE__ */ jsx40(
|
|
2074
2134
|
"button",
|
|
2075
2135
|
{
|
|
2076
2136
|
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",
|
|
@@ -2083,8 +2143,9 @@ var Button = ({ children, onClick, type, disabled }) => {
|
|
|
2083
2143
|
};
|
|
2084
2144
|
|
|
2085
2145
|
// src/components/TxConfigForm/Form.tsx
|
|
2086
|
-
import { jsx as
|
|
2146
|
+
import { jsx as jsx41, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2087
2147
|
var Form = ({
|
|
2148
|
+
integratorId,
|
|
2088
2149
|
dstChainId,
|
|
2089
2150
|
dstTokenAddr,
|
|
2090
2151
|
customContractCalls,
|
|
@@ -2131,14 +2192,24 @@ var Form = ({
|
|
|
2131
2192
|
setDstChain(supportedChains.find((chain) => chain.chainId === dstChainId));
|
|
2132
2193
|
}, [supportedChains, dstChainId]);
|
|
2133
2194
|
useEffect7(() => {
|
|
2134
|
-
|
|
2135
|
-
dstChain
|
|
2195
|
+
(async () => {
|
|
2196
|
+
if (!dstChain) {
|
|
2197
|
+
return;
|
|
2198
|
+
}
|
|
2199
|
+
let dstTokenResult = dstChain?.tokens.find(
|
|
2136
2200
|
(token) => token.address.toLowerCase() === dstTokenAddr.toLowerCase()
|
|
2137
|
-
)
|
|
2138
|
-
|
|
2201
|
+
);
|
|
2202
|
+
if (!dstTokenResult) {
|
|
2203
|
+
dstTokenResult = await getCustomTokenData(
|
|
2204
|
+
dstChain,
|
|
2205
|
+
dstTokenAddr.toLowerCase()
|
|
2206
|
+
);
|
|
2207
|
+
}
|
|
2208
|
+
setDstToken(dstTokenResult);
|
|
2209
|
+
})();
|
|
2139
2210
|
}, [dstChain]);
|
|
2140
2211
|
useEffect7(() => {
|
|
2141
|
-
if (srcChain && srcToken && dstChain && debouncedAmount && paymentToken && slippage) {
|
|
2212
|
+
if (integratorId && srcChain && srcToken && dstChain && debouncedAmount && paymentToken && slippage) {
|
|
2142
2213
|
setFormError("");
|
|
2143
2214
|
const timeout = setTimeout(() => {
|
|
2144
2215
|
setFormError("Getting Route is taking longer than usually");
|
|
@@ -2150,6 +2221,7 @@ var Form = ({
|
|
|
2150
2221
|
`Configuration error: selected token ($${srcToken.symbol} ${srcToken.name}) has unknown decimals param.`
|
|
2151
2222
|
);
|
|
2152
2223
|
getRoute({
|
|
2224
|
+
integratorId,
|
|
2153
2225
|
fromAmount: ethers3.utils.parseUnits(debouncedAmount, srcToken.decimals).toString(),
|
|
2154
2226
|
fromAddress: signer || ADDRESSES[srcChain.chainId].FeeCollector,
|
|
2155
2227
|
fromChain: srcChain.chainId,
|
|
@@ -2221,7 +2293,7 @@ var Form = ({
|
|
|
2221
2293
|
className: "flex flex-col gap-2 z-10 my-0 p-2 md:p-4 rounded-3xl overflow-hidden font-light sm:w-x_desktop",
|
|
2222
2294
|
onSubmit: handleSubmit,
|
|
2223
2295
|
children: [
|
|
2224
|
-
/* @__PURE__ */
|
|
2296
|
+
/* @__PURE__ */ jsx41(
|
|
2225
2297
|
TopBar,
|
|
2226
2298
|
{
|
|
2227
2299
|
signer,
|
|
@@ -2231,7 +2303,7 @@ var Form = ({
|
|
|
2231
2303
|
onClose
|
|
2232
2304
|
}
|
|
2233
2305
|
),
|
|
2234
|
-
settingsShown && /* @__PURE__ */
|
|
2306
|
+
settingsShown && /* @__PURE__ */ jsx41(
|
|
2235
2307
|
Settings,
|
|
2236
2308
|
{
|
|
2237
2309
|
expressChecked,
|
|
@@ -2241,9 +2313,9 @@ var Form = ({
|
|
|
2241
2313
|
setSlippage
|
|
2242
2314
|
}
|
|
2243
2315
|
),
|
|
2244
|
-
historyTabShown ? /* @__PURE__ */
|
|
2245
|
-
desc && /* @__PURE__ */
|
|
2246
|
-
/* @__PURE__ */
|
|
2316
|
+
historyTabShown ? /* @__PURE__ */ jsx41(History, { signer, supportedChains }) : /* @__PURE__ */ jsxs17("div", { className: "flex flex-col gap-2", children: [
|
|
2317
|
+
desc && /* @__PURE__ */ jsx41(Description, { description: desc }),
|
|
2318
|
+
/* @__PURE__ */ jsx41(
|
|
2247
2319
|
SwapPanel,
|
|
2248
2320
|
{
|
|
2249
2321
|
amount,
|
|
@@ -2259,7 +2331,7 @@ var Form = ({
|
|
|
2259
2331
|
setExceedsExpressDeliveryLimit
|
|
2260
2332
|
}
|
|
2261
2333
|
),
|
|
2262
|
-
/* @__PURE__ */
|
|
2334
|
+
/* @__PURE__ */ jsx41(
|
|
2263
2335
|
Summary,
|
|
2264
2336
|
{
|
|
2265
2337
|
isGettingRoute,
|
|
@@ -2268,7 +2340,7 @@ var Form = ({
|
|
|
2268
2340
|
dstChain
|
|
2269
2341
|
}
|
|
2270
2342
|
),
|
|
2271
|
-
/* @__PURE__ */
|
|
2343
|
+
/* @__PURE__ */ jsx41(
|
|
2272
2344
|
FeesDetails,
|
|
2273
2345
|
{
|
|
2274
2346
|
route,
|
|
@@ -2282,8 +2354,8 @@ var Form = ({
|
|
|
2282
2354
|
setFeesDetailsShown
|
|
2283
2355
|
}
|
|
2284
2356
|
),
|
|
2285
|
-
formError.length > 0 && /* @__PURE__ */
|
|
2286
|
-
signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */
|
|
2357
|
+
formError.length > 0 && /* @__PURE__ */ jsx41(ErrorField, { error: formError }),
|
|
2358
|
+
signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ jsx41(Button, { type: "button", onClick: handleSwitchChain, children: "Switch chain" }) : /* @__PURE__ */ jsx41(
|
|
2287
2359
|
Button,
|
|
2288
2360
|
{
|
|
2289
2361
|
type: "submit",
|
|
@@ -2298,8 +2370,9 @@ var Form = ({
|
|
|
2298
2370
|
};
|
|
2299
2371
|
|
|
2300
2372
|
// src/components/TxConfigForm/index.tsx
|
|
2301
|
-
import { jsx as
|
|
2373
|
+
import { jsx as jsx42, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2302
2374
|
var TxConfigForm = ({
|
|
2375
|
+
integratorId,
|
|
2303
2376
|
dstChainId,
|
|
2304
2377
|
dstTokenAddr,
|
|
2305
2378
|
customContractCalls,
|
|
@@ -2316,19 +2389,20 @@ var TxConfigForm = ({
|
|
|
2316
2389
|
}
|
|
2317
2390
|
};
|
|
2318
2391
|
const queryClient = new QueryClient();
|
|
2319
|
-
const wagmiConfig =
|
|
2392
|
+
const wagmiConfig = useMemo8(
|
|
2320
2393
|
() => getWagmiConfig(supportedChains),
|
|
2321
2394
|
supportedChains
|
|
2322
2395
|
);
|
|
2323
|
-
return /* @__PURE__ */
|
|
2396
|
+
return /* @__PURE__ */ jsx42(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx42(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx42(
|
|
2324
2397
|
"div",
|
|
2325
2398
|
{
|
|
2326
2399
|
className: "top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10",
|
|
2327
2400
|
onClick: onBackdropClick,
|
|
2328
2401
|
children: /* @__PURE__ */ jsxs18("div", { className: "relative bg-black rounded-3xl overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]", children: [
|
|
2329
|
-
/* @__PURE__ */
|
|
2402
|
+
/* @__PURE__ */ jsx42(
|
|
2330
2403
|
Form,
|
|
2331
2404
|
{
|
|
2405
|
+
integratorId,
|
|
2332
2406
|
dstChainId,
|
|
2333
2407
|
dstTokenAddr,
|
|
2334
2408
|
customContractCalls,
|
|
@@ -2338,12 +2412,13 @@ var TxConfigForm = ({
|
|
|
2338
2412
|
onClose
|
|
2339
2413
|
}
|
|
2340
2414
|
),
|
|
2341
|
-
/* @__PURE__ */
|
|
2415
|
+
/* @__PURE__ */ jsx42(PoweredBy, {})
|
|
2342
2416
|
] })
|
|
2343
2417
|
}
|
|
2344
2418
|
) }) });
|
|
2345
2419
|
};
|
|
2346
2420
|
var openTxConfigForm = async ({
|
|
2421
|
+
integratorId,
|
|
2347
2422
|
dstChainId,
|
|
2348
2423
|
dstTokenAddr,
|
|
2349
2424
|
customContractCalls,
|
|
@@ -2354,9 +2429,10 @@ var openTxConfigForm = async ({
|
|
|
2354
2429
|
return await new Promise(async (resolve) => {
|
|
2355
2430
|
await waitForInitialization();
|
|
2356
2431
|
xswapRoot.render(
|
|
2357
|
-
/* @__PURE__ */
|
|
2432
|
+
/* @__PURE__ */ jsx42(
|
|
2358
2433
|
TxConfigForm,
|
|
2359
2434
|
{
|
|
2435
|
+
integratorId,
|
|
2360
2436
|
dstChainId,
|
|
2361
2437
|
dstTokenAddr,
|
|
2362
2438
|
customContractCalls,
|
|
@@ -2379,27 +2455,26 @@ var openTxConfigForm = async ({
|
|
|
2379
2455
|
};
|
|
2380
2456
|
|
|
2381
2457
|
// src/components/TxStatusButton/index.tsx
|
|
2382
|
-
import { useMemo as
|
|
2383
|
-
import { Fragment as Fragment6, jsx as
|
|
2458
|
+
import { useMemo as useMemo9, useState as useState9 } from "react";
|
|
2459
|
+
import { Fragment as Fragment6, jsx as jsx43, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2384
2460
|
var TxStatusButton = ({ transaction }) => {
|
|
2385
2461
|
const {
|
|
2386
|
-
fromChain,
|
|
2387
|
-
fromChainImage,
|
|
2388
|
-
fromToken,
|
|
2389
|
-
fromTokenImage,
|
|
2390
|
-
fromAmount,
|
|
2391
|
-
toChain,
|
|
2392
|
-
toChainImage,
|
|
2462
|
+
srcChain: fromChain,
|
|
2463
|
+
srcChainImage: fromChainImage,
|
|
2464
|
+
srcToken: fromToken,
|
|
2465
|
+
srcTokenImage: fromTokenImage,
|
|
2466
|
+
srcAmount: fromAmount,
|
|
2467
|
+
dstChain: toChain,
|
|
2468
|
+
dstChainImage: toChainImage,
|
|
2393
2469
|
isDone,
|
|
2394
|
-
txHash,
|
|
2395
2470
|
explorer
|
|
2396
2471
|
} = transaction;
|
|
2397
2472
|
const [isWide, setIsWide] = useState9(false);
|
|
2398
|
-
const background =
|
|
2473
|
+
const background = useMemo9(
|
|
2399
2474
|
() => isDone ? "bg-[rgba(2,2,2,1)] bg-gradient-to-r from-[rgba(76,175,80,0.2)] to-[rgba(46,125,50,0.2)]" : "bg-[rgba(2,2,2,1)] bg-gradient-to-r from-[rgba(54,129,198,0.2)] to-[rgba(43,74,157,0.2)]",
|
|
2400
2475
|
[isDone]
|
|
2401
2476
|
);
|
|
2402
|
-
const border =
|
|
2477
|
+
const border = useMemo9(
|
|
2403
2478
|
() => isDone ? "border border-solid border-x_green_dark" : "border border-solid border-x_blue_dark",
|
|
2404
2479
|
[isDone]
|
|
2405
2480
|
);
|
|
@@ -2411,7 +2486,7 @@ var TxStatusButton = ({ transaction }) => {
|
|
|
2411
2486
|
children: [
|
|
2412
2487
|
/* @__PURE__ */ jsxs19("div", { className: "flex justify-between flex-col gap-2 sm:gap-5 sm:flex-row w-full", children: [
|
|
2413
2488
|
/* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
|
|
2414
|
-
/* @__PURE__ */
|
|
2489
|
+
/* @__PURE__ */ jsx43(
|
|
2415
2490
|
"img",
|
|
2416
2491
|
{
|
|
2417
2492
|
className: "w-5 h-5",
|
|
@@ -2419,26 +2494,32 @@ var TxStatusButton = ({ transaction }) => {
|
|
|
2419
2494
|
alt: "source chain"
|
|
2420
2495
|
}
|
|
2421
2496
|
),
|
|
2422
|
-
/* @__PURE__ */
|
|
2423
|
-
/* @__PURE__ */
|
|
2424
|
-
/* @__PURE__ */
|
|
2425
|
-
/* @__PURE__ */
|
|
2497
|
+
/* @__PURE__ */ jsx43("div", { children: fromChain }),
|
|
2498
|
+
/* @__PURE__ */ jsx43("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx43(ArrowRightIcon, {}) }),
|
|
2499
|
+
/* @__PURE__ */ jsx43("img", { className: "w-5 h-5", src: toChainImage, alt: "to chain" }),
|
|
2500
|
+
/* @__PURE__ */ jsx43("div", { children: toChain })
|
|
2426
2501
|
] }),
|
|
2427
2502
|
/* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
|
|
2428
|
-
/* @__PURE__ */
|
|
2429
|
-
/* @__PURE__ */
|
|
2430
|
-
/* @__PURE__ */
|
|
2431
|
-
/* @__PURE__ */
|
|
2503
|
+
/* @__PURE__ */ jsx43("div", { children: "Sent" }),
|
|
2504
|
+
/* @__PURE__ */ jsx43("div", { children: fromAmount }),
|
|
2505
|
+
/* @__PURE__ */ jsx43("div", { children: fromToken }),
|
|
2506
|
+
fromTokenImage ? /* @__PURE__ */ jsx43(
|
|
2432
2507
|
"img",
|
|
2433
2508
|
{
|
|
2434
2509
|
className: "w-5 h-5",
|
|
2435
2510
|
src: fromTokenImage,
|
|
2436
2511
|
alt: "source token"
|
|
2437
2512
|
}
|
|
2513
|
+
) : /* @__PURE__ */ jsx43(
|
|
2514
|
+
UnknownTokenLogo,
|
|
2515
|
+
{
|
|
2516
|
+
tokenName: "?",
|
|
2517
|
+
className: "token-select__generated-logo"
|
|
2518
|
+
}
|
|
2438
2519
|
)
|
|
2439
2520
|
] })
|
|
2440
2521
|
] }),
|
|
2441
|
-
/* @__PURE__ */
|
|
2522
|
+
/* @__PURE__ */ jsx43(
|
|
2442
2523
|
"a",
|
|
2443
2524
|
{
|
|
2444
2525
|
href: explorer,
|
|
@@ -2446,21 +2527,21 @@ var TxStatusButton = ({ transaction }) => {
|
|
|
2446
2527
|
rel: "noreferrer",
|
|
2447
2528
|
className: "no-underline cursor-pointer",
|
|
2448
2529
|
"aria-label": "Show the transaction in the chain explorer",
|
|
2449
|
-
children: /* @__PURE__ */
|
|
2530
|
+
children: /* @__PURE__ */ jsx43("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx43(ArrowUpRightIcon, {}) })
|
|
2450
2531
|
}
|
|
2451
2532
|
)
|
|
2452
2533
|
]
|
|
2453
2534
|
}
|
|
2454
2535
|
),
|
|
2455
|
-
/* @__PURE__ */
|
|
2536
|
+
/* @__PURE__ */ jsx43(
|
|
2456
2537
|
"div",
|
|
2457
2538
|
{
|
|
2458
2539
|
className: `text-white rounded-xl cursor-pointer ${background} ${border}`,
|
|
2459
2540
|
children: /* @__PURE__ */ jsxs19("div", { className: "flex gap-2 items-center h-14 w-20 justify-center", children: [
|
|
2460
|
-
/* @__PURE__ */
|
|
2461
|
-
/* @__PURE__ */
|
|
2462
|
-
/* @__PURE__ */
|
|
2463
|
-
/* @__PURE__ */
|
|
2541
|
+
/* @__PURE__ */ jsx43(ArrowLeftIcon, {}),
|
|
2542
|
+
/* @__PURE__ */ jsx43("div", { className: "relative flex items-center justify-center w-9 h-9", children: isDone ? /* @__PURE__ */ jsx43("div", { className: "text-x_green w-5 h-5", children: /* @__PURE__ */ jsx43(CheckIcon, {}) }) : /* @__PURE__ */ jsxs19(Fragment6, { children: [
|
|
2543
|
+
/* @__PURE__ */ jsx43("div", { className: "w-5 h-5", children: /* @__PURE__ */ jsx43(XSwapLogo, {}) }),
|
|
2544
|
+
/* @__PURE__ */ jsx43("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ jsx43(CircularProgressIcon, {}) })
|
|
2464
2545
|
] }) })
|
|
2465
2546
|
] })
|
|
2466
2547
|
}
|
|
@@ -2487,25 +2568,66 @@ var updateTransactionDoneInRenderedTransactions = (txHash) => {
|
|
|
2487
2568
|
}
|
|
2488
2569
|
};
|
|
2489
2570
|
var renderTxStatusButtons = () => {
|
|
2490
|
-
const buttons = renderedTransactions.map((item) => /* @__PURE__ */
|
|
2571
|
+
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ jsx43(TxStatusButton, { transaction: item }, item.txHash));
|
|
2491
2572
|
txStatusRoot.render(buttons);
|
|
2492
2573
|
};
|
|
2493
2574
|
|
|
2494
2575
|
// src/components/Skeleton/index.tsx
|
|
2495
|
-
import { jsx as
|
|
2576
|
+
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
2496
2577
|
var Skeleton = ({ width, height }) => {
|
|
2497
|
-
return /* @__PURE__ */
|
|
2578
|
+
return /* @__PURE__ */ jsx44("div", { className: `bg-current rounded animate-pulse ${width} ${height}` });
|
|
2498
2579
|
};
|
|
2499
2580
|
|
|
2500
2581
|
// src/services/integrations/monitoring.ts
|
|
2501
2582
|
import retry from "async-retry";
|
|
2502
|
-
|
|
2583
|
+
|
|
2584
|
+
// src/services/blockchain.ts
|
|
2585
|
+
import { ethers as ethers4 } from "ethers";
|
|
2586
|
+
var getCustomTokenData = async (chain, tokenAddress) => {
|
|
2587
|
+
const rpcUrl = chain.publicRpcUrls[0];
|
|
2588
|
+
const customTokenContract = new ethers4.Contract(
|
|
2589
|
+
tokenAddress.toLowerCase(),
|
|
2590
|
+
ERC20Abi,
|
|
2591
|
+
ethers4.getDefaultProvider(rpcUrl)
|
|
2592
|
+
);
|
|
2593
|
+
try {
|
|
2594
|
+
const query = async (contract, method, args = []) => {
|
|
2595
|
+
if (contract?.provider) {
|
|
2596
|
+
const response = await contract[method](...args);
|
|
2597
|
+
return response;
|
|
2598
|
+
}
|
|
2599
|
+
return null;
|
|
2600
|
+
};
|
|
2601
|
+
const responses = await Promise.all([
|
|
2602
|
+
query(customTokenContract, "decimals"),
|
|
2603
|
+
query(customTokenContract, "name"),
|
|
2604
|
+
query(customTokenContract, "symbol")
|
|
2605
|
+
]);
|
|
2606
|
+
const [decimals, name, symbol] = responses;
|
|
2607
|
+
return {
|
|
2608
|
+
address: tokenAddress,
|
|
2609
|
+
symbol,
|
|
2610
|
+
name,
|
|
2611
|
+
decimals,
|
|
2612
|
+
quickPick: false,
|
|
2613
|
+
supported: true,
|
|
2614
|
+
priority: 0
|
|
2615
|
+
};
|
|
2616
|
+
} catch (_) {
|
|
2617
|
+
throw new Error(
|
|
2618
|
+
`Provided token ${tokenAddress} does not exists on chain ${chain.displayName}`
|
|
2619
|
+
);
|
|
2620
|
+
}
|
|
2621
|
+
};
|
|
2622
|
+
|
|
2623
|
+
// src/services/integrations/monitoring.ts
|
|
2624
|
+
var renderTxStatus = async (txChainId, txHash) => {
|
|
2503
2625
|
const txReceipt = await getTxReceipt(txChainId, txHash);
|
|
2504
2626
|
const supportedChains = (await getChains()).filter(
|
|
2505
2627
|
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
2506
2628
|
);
|
|
2507
2629
|
const messageSentEvent = txReceipt.logs?.find((log) => {
|
|
2508
|
-
return log.topics[0] ===
|
|
2630
|
+
return log.topics[0] === ethers5.utils.id(MSG_SENT_EVENT_SIG);
|
|
2509
2631
|
});
|
|
2510
2632
|
if (!messageSentEvent) {
|
|
2511
2633
|
throw new Error(
|
|
@@ -2513,7 +2635,7 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
|
|
|
2513
2635
|
);
|
|
2514
2636
|
}
|
|
2515
2637
|
const messageId = messageSentEvent?.topics[1];
|
|
2516
|
-
const iface = new
|
|
2638
|
+
const iface = new ethers5.utils.Interface(MSG_SENT_EVENT_ABI);
|
|
2517
2639
|
const decodedMessageSentEvent = iface.parseLog(messageSentEvent);
|
|
2518
2640
|
if (!decodedMessageSentEvent) {
|
|
2519
2641
|
throw new Error(
|
|
@@ -2523,9 +2645,16 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
|
|
|
2523
2645
|
const srcChain = supportedChains.find(
|
|
2524
2646
|
(chain) => chain.chainId === txChainId.toString()
|
|
2525
2647
|
);
|
|
2526
|
-
|
|
2648
|
+
if (!srcChain) {
|
|
2649
|
+
throw new Error(`Unknown src chain ${txChainId}`);
|
|
2650
|
+
}
|
|
2651
|
+
const tokenAddress = decodedMessageSentEvent.args?.token.toString();
|
|
2652
|
+
let srcToken = srcChain.tokens.find(
|
|
2527
2653
|
(token) => token.address === decodedMessageSentEvent.args?.token.toString()
|
|
2528
2654
|
);
|
|
2655
|
+
if (!srcToken) {
|
|
2656
|
+
srcToken = await getCustomTokenData(srcChain, tokenAddress);
|
|
2657
|
+
}
|
|
2529
2658
|
const dstChain = supportedChains.find(
|
|
2530
2659
|
(chain) => chain.ccipChainId === decodedMessageSentEvent.args?.destinationChainSelector?.toString()
|
|
2531
2660
|
);
|
|
@@ -2533,19 +2662,20 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
|
|
|
2533
2662
|
if (!dstChainId) {
|
|
2534
2663
|
throw new Error(`Unknown destination chain!`);
|
|
2535
2664
|
}
|
|
2665
|
+
const tokenAmount = weiToHumanReadable({
|
|
2666
|
+
amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
|
|
2667
|
+
decimals: srcToken?.decimals || 18,
|
|
2668
|
+
precisionFractionalPlaces: 4
|
|
2669
|
+
});
|
|
2536
2670
|
const transaction = {
|
|
2537
2671
|
txHash,
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
|
|
2546
|
-
decimals: srcToken?.decimals || 18,
|
|
2547
|
-
precisionFractionalPlaces: 4
|
|
2548
|
-
}),
|
|
2672
|
+
srcChain: srcChain.displayName,
|
|
2673
|
+
srcChainImage: srcChain.image,
|
|
2674
|
+
dstChain: dstChain.displayName,
|
|
2675
|
+
dstChainImage: dstChain.image,
|
|
2676
|
+
srcToken: srcToken?.symbol,
|
|
2677
|
+
srcTokenImage: srcToken?.image,
|
|
2678
|
+
srcAmount: tokenAmount === "0" ? "<0.0001" : tokenAmount,
|
|
2549
2679
|
isDone: false,
|
|
2550
2680
|
explorer: `${CCIP_EXPLORER}/tx/${txHash}`
|
|
2551
2681
|
};
|
|
@@ -2555,16 +2685,16 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
|
|
|
2555
2685
|
if (!xSwapRouterOnDestinationAddress) {
|
|
2556
2686
|
throw new Error(`Unknown destination XSwapRouter!`);
|
|
2557
2687
|
}
|
|
2558
|
-
const xSwapRouterOnDestination = new
|
|
2688
|
+
const xSwapRouterOnDestination = new ethers5.Contract(
|
|
2559
2689
|
xSwapRouterOnDestinationAddress,
|
|
2560
2690
|
MSG_RECEIVED_EVENT_ABI,
|
|
2561
|
-
|
|
2691
|
+
ethers5.getDefaultProvider(
|
|
2562
2692
|
supportedChains.find((chain) => chain.chainId === dstChainId)?.publicRpcUrls[0]
|
|
2563
2693
|
)
|
|
2564
2694
|
);
|
|
2565
2695
|
const msgReceivedEventFilter = {
|
|
2566
2696
|
address: xSwapRouterOnDestinationAddress,
|
|
2567
|
-
topics: [
|
|
2697
|
+
topics: [ethers5.utils.id(MSG_RECEIVED_EVENT_SIG), messageId]
|
|
2568
2698
|
};
|
|
2569
2699
|
const onSuccess = async () => {
|
|
2570
2700
|
updateTransactionDoneInRenderedTransactions(txHash);
|
|
@@ -2575,6 +2705,11 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
|
|
|
2575
2705
|
removeTransactionFromRenderedTransactions(txHash);
|
|
2576
2706
|
renderTxStatusButtons();
|
|
2577
2707
|
};
|
|
2708
|
+
getTxStatus({ transferId: messageId }).then((response) => {
|
|
2709
|
+
if (response.status === "DONE") {
|
|
2710
|
+
onSuccess();
|
|
2711
|
+
}
|
|
2712
|
+
});
|
|
2578
2713
|
xSwapRouterOnDestination.once(msgReceivedEventFilter, () => onSuccess());
|
|
2579
2714
|
};
|
|
2580
2715
|
var getTxReceipt = async (txChainId, txHash) => {
|
|
@@ -2582,7 +2717,7 @@ var getTxReceipt = async (txChainId, txHash) => {
|
|
|
2582
2717
|
const chain = (await getChains()).find(
|
|
2583
2718
|
(chain2) => chain2.chainId === txChainId
|
|
2584
2719
|
);
|
|
2585
|
-
const provider = new
|
|
2720
|
+
const provider = new ethers5.providers.JsonRpcProvider(
|
|
2586
2721
|
chain?.publicRpcUrls[0]
|
|
2587
2722
|
);
|
|
2588
2723
|
return await retry(async () => {
|
|
@@ -2600,7 +2735,8 @@ var getTxReceipt = async (txChainId, txHash) => {
|
|
|
2600
2735
|
};
|
|
2601
2736
|
|
|
2602
2737
|
// src/services/integrations/transactions.ts
|
|
2603
|
-
var
|
|
2738
|
+
var openTransactionModal = async ({
|
|
2739
|
+
integratorId,
|
|
2604
2740
|
dstChain,
|
|
2605
2741
|
dstToken,
|
|
2606
2742
|
customContractCalls = [],
|
|
@@ -2611,6 +2747,7 @@ var getSwapTx = async ({
|
|
|
2611
2747
|
);
|
|
2612
2748
|
validateSwapTxData(supportedChains, dstChain, dstToken);
|
|
2613
2749
|
const route = await openTxConfigForm({
|
|
2750
|
+
integratorId,
|
|
2614
2751
|
dstChainId: dstChain,
|
|
2615
2752
|
dstTokenAddr: dstToken,
|
|
2616
2753
|
customContractCalls,
|
|
@@ -2626,19 +2763,27 @@ var validateSwapTxData = (supportedChains, dstChain, dstToken) => {
|
|
|
2626
2763
|
if (!supportedDstChain) {
|
|
2627
2764
|
throw new Error(`Provided chain '${dstChain}' is not supported`);
|
|
2628
2765
|
}
|
|
2629
|
-
if (!
|
|
2630
|
-
throw new Error(
|
|
2766
|
+
if (!isETHAddressValid(dstToken)) {
|
|
2767
|
+
throw new Error(
|
|
2768
|
+
`Provided token address ${dstToken} on chain ${dstChain} is not correct`
|
|
2769
|
+
);
|
|
2631
2770
|
}
|
|
2632
2771
|
};
|
|
2633
2772
|
|
|
2634
2773
|
// src/index.ts
|
|
2635
2774
|
initDocument();
|
|
2775
|
+
var XPay = {
|
|
2776
|
+
openTransactionModal,
|
|
2777
|
+
renderTxStatus
|
|
2778
|
+
};
|
|
2779
|
+
var src_default = XPay;
|
|
2636
2780
|
export {
|
|
2637
2781
|
ContractName,
|
|
2638
2782
|
Ecosystem,
|
|
2639
2783
|
Environment,
|
|
2640
2784
|
Web3Environment,
|
|
2641
2785
|
XSwapCallType,
|
|
2642
|
-
|
|
2643
|
-
|
|
2786
|
+
src_default as default,
|
|
2787
|
+
openTransactionModal,
|
|
2788
|
+
renderTxStatus
|
|
2644
2789
|
};
|