@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/dist/index.js CHANGED
@@ -35,8 +35,9 @@ __export(src_exports, {
35
35
  Environment: () => Environment,
36
36
  Web3Environment: () => Web3Environment,
37
37
  XSwapCallType: () => XSwapCallType,
38
- getSwapTx: () => getSwapTx,
39
- monitorTransactionStatus: () => monitorTransactionStatus
38
+ default: () => src_default,
39
+ openTransactionModal: () => openTransactionModal,
40
+ renderTxStatus: () => renderTxStatus
40
41
  });
41
42
  module.exports = __toCommonJS(src_exports);
42
43
 
@@ -58,7 +59,7 @@ var xswap_config_default = {
58
59
  };
59
60
 
60
61
  // package.json
61
- var version = "0.2.4";
62
+ var version = "0.2.5";
62
63
 
63
64
  // src/components/WaitingForInit/index.tsx
64
65
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -96,7 +97,7 @@ var initDocument = () => {
96
97
  createInitIndicatorRoot();
97
98
  Promise.all([
98
99
  createStyleElement(),
99
- createXswapRoot(),
100
+ createXSwapRoot(),
100
101
  createTxStatusRoot()
101
102
  ]).then(() => {
102
103
  initCompleted = true;
@@ -122,7 +123,7 @@ var createStyleElement = async () => {
122
123
  style.textContent = text;
123
124
  document.body.appendChild(style);
124
125
  };
125
- var createXswapRoot = async () => {
126
+ var createXSwapRoot = async () => {
126
127
  const xswapElement = document.createElement("div");
127
128
  xswapElement.setAttribute("id", "xswap-modal");
128
129
  document.body.appendChild(xswapElement);
@@ -145,45 +146,6 @@ var displayInitIndicator = (display) => {
145
146
  display ? initIndicatorRoot.render(/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WaitingForInit, {})) : initIndicatorRoot.render("");
146
147
  };
147
148
 
148
- // src/models/Addresses.ts
149
- var ContractName = /* @__PURE__ */ ((ContractName2) => {
150
- ContractName2["BatchQuery"] = "BatchQuery";
151
- ContractName2["FeeCollector"] = "FeeCollector";
152
- ContractName2["XSwapRouter"] = "XSwapRouter";
153
- return ContractName2;
154
- })(ContractName || {});
155
-
156
- // src/models/Ecosystem.ts
157
- var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
158
- Ecosystem2["EVM"] = "evm";
159
- return Ecosystem2;
160
- })(Ecosystem || {});
161
-
162
- // src/models/Environment.ts
163
- var Environment = /* @__PURE__ */ ((Environment2) => {
164
- Environment2["PROD"] = "production";
165
- Environment2["DEV"] = "develop";
166
- Environment2["LOCAL"] = "local";
167
- return Environment2;
168
- })(Environment || {});
169
-
170
- // src/models/Web3Environment.ts
171
- var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
172
- Web3Environment2["DEVNET"] = "devnet";
173
- Web3Environment2["TESTNET"] = "testnet";
174
- Web3Environment2["MAINNET"] = "mainnet";
175
- return Web3Environment2;
176
- })(Web3Environment || {});
177
-
178
- // src/models/XSwapCallType.ts
179
- var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
180
- XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
181
- XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
182
- XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
183
- XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
184
- return XSwapCallType2;
185
- })(XSwapCallType || {});
186
-
187
149
  // src/services/api.ts
188
150
  async function _sendRequest(urlPath, options) {
189
151
  const response = await fetch(`${xswap_config_default.apiUrl}${urlPath}`, {
@@ -226,10 +188,57 @@ async function getPrices(payload) {
226
188
  })}`
227
189
  );
228
190
  }
191
+ async function getTxStatus(payload) {
192
+ return await _sendRequest(
193
+ `/getTxStatus?${new URLSearchParams({
194
+ data: JSON.stringify(payload)
195
+ // todo remove once gcp starts working
196
+ })}`
197
+ );
198
+ }
229
199
 
230
200
  // src/services/integrations/customCalls/staking.ts
231
201
  var import_ethers3 = require("ethers");
232
202
 
203
+ // src/models/Addresses.ts
204
+ var ContractName = /* @__PURE__ */ ((ContractName2) => {
205
+ ContractName2["BatchQuery"] = "BatchQuery";
206
+ ContractName2["FeeCollector"] = "FeeCollector";
207
+ ContractName2["XSwapRouter"] = "XSwapRouter";
208
+ return ContractName2;
209
+ })(ContractName || {});
210
+
211
+ // src/models/Ecosystem.ts
212
+ var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
213
+ Ecosystem2["EVM"] = "evm";
214
+ return Ecosystem2;
215
+ })(Ecosystem || {});
216
+
217
+ // src/models/Environment.ts
218
+ var Environment = /* @__PURE__ */ ((Environment2) => {
219
+ Environment2["PROD"] = "production";
220
+ Environment2["DEV"] = "develop";
221
+ Environment2["LOCAL"] = "local";
222
+ return Environment2;
223
+ })(Environment || {});
224
+
225
+ // src/models/Web3Environment.ts
226
+ var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
227
+ Web3Environment2["DEVNET"] = "devnet";
228
+ Web3Environment2["TESTNET"] = "testnet";
229
+ Web3Environment2["MAINNET"] = "mainnet";
230
+ return Web3Environment2;
231
+ })(Web3Environment || {});
232
+
233
+ // src/models/XSwapCallType.ts
234
+ var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
235
+ XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
236
+ XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
237
+ XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
238
+ XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
239
+ return XSwapCallType2;
240
+ })(XSwapCallType || {});
241
+
233
242
  // src/utils/contracts.ts
234
243
  var import_ethers = require("ethers");
235
244
 
@@ -661,6 +670,9 @@ var shortAddress = (address) => {
661
670
  address.length
662
671
  )}`;
663
672
  };
673
+ var isETHAddressValid = (address) => {
674
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
675
+ };
664
676
 
665
677
  // src/utils/index.ts
666
678
  var import_date_fns = require("date-fns");
@@ -689,7 +701,7 @@ var getDate = (blockTimestamp) => {
689
701
  };
690
702
 
691
703
  // src/services/integrations/monitoring.ts
692
- var import_ethers5 = require("ethers");
704
+ var import_ethers6 = require("ethers");
693
705
 
694
706
  // src/components/Alert/index.tsx
695
707
  var import_jsx_runtime3 = require("react/jsx-runtime");
@@ -701,7 +713,7 @@ var Alert = ({ desc }) => {
701
713
  };
702
714
 
703
715
  // src/components/TxConfigForm/index.tsx
704
- var import_react11 = require("react");
716
+ var import_react12 = require("react");
705
717
  var import_react_query = require("@tanstack/react-query");
706
718
  var import_wagmi3 = require("wagmi");
707
719
 
@@ -1190,7 +1202,7 @@ var PoweredBy = () => {
1190
1202
  };
1191
1203
 
1192
1204
  // src/components/TxConfigForm/Form.tsx
1193
- var import_react10 = require("react");
1205
+ var import_react11 = require("react");
1194
1206
  var import_ethers4 = require("ethers");
1195
1207
  var import_wagmi2 = require("wagmi");
1196
1208
 
@@ -1355,15 +1367,35 @@ var History = ({ signer, supportedChains }) => {
1355
1367
  const fetchedTransactions = [];
1356
1368
  if (downloadedHistory) {
1357
1369
  for (const entry of downloadedHistory.history) {
1370
+ let status = "IN_PROGRESS";
1358
1371
  if (!entry.source) {
1359
1372
  continue;
1360
1373
  }
1361
- let status;
1362
- if (entry.failed) status = "REVERTED";
1374
+ if (entry.failed) {
1375
+ status = "REVERTED";
1376
+ }
1363
1377
  if (!!entry.target) {
1364
1378
  status = "DONE";
1365
- } else {
1366
- status = "IN_PROGRESS";
1379
+ }
1380
+ if (entry.transferType === "SINGLE_CHAIN") {
1381
+ if (!entry.target) {
1382
+ continue;
1383
+ }
1384
+ const blockTimestampMs2 = new Date(entry.target.blockTime).getTime();
1385
+ const estimatedDeliveryTimestamp2 = blockTimestampMs2 / 1e3;
1386
+ fetchedTransactions.push({
1387
+ hash: entry.target.transactionHash,
1388
+ timestamp: blockTimestampMs2 / 1e3,
1389
+ sourceChainId: entry.target.blockchainId,
1390
+ targetChainId: entry.target.blockchainId,
1391
+ amountWei: entry.source.tokenAmount,
1392
+ tokenAddress: entry.source.tokenAddress,
1393
+ tokenOutAddress: entry.target?.tokenAmount,
1394
+ tokenOutAmount: entry.target?.tokenAmount,
1395
+ estimatedDeliveryTimestamp: estimatedDeliveryTimestamp2,
1396
+ status
1397
+ });
1398
+ continue;
1367
1399
  }
1368
1400
  const blockTimestampMs = new Date(entry.source.blockTime).getTime();
1369
1401
  const estimatedDeliveryTimestamp = new import_bignumber2.default(
@@ -1557,6 +1589,7 @@ var Settings = ({
1557
1589
  };
1558
1590
 
1559
1591
  // src/components/TxConfigForm/FeesDetails.tsx
1592
+ var import_react5 = require("react");
1560
1593
  var import_jsx_runtime31 = require("react/jsx-runtime");
1561
1594
  var FeesDetails = ({
1562
1595
  isGettingRoute,
@@ -1569,6 +1602,9 @@ var FeesDetails = ({
1569
1602
  feesDetailsShown,
1570
1603
  setFeesDetailsShown
1571
1604
  }) => {
1605
+ const isExpressDeliveryPossible = (0, import_react5.useMemo)(() => {
1606
+ return expressChecked && !exceedsExpressDeliveryLimit;
1607
+ }, [expressChecked, exceedsExpressDeliveryLimit]);
1572
1608
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col gap-3 globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-2 sm:p-4 mb-1", children: [
1573
1609
  /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex w-full items-center justify-between text-xs sm:text-sm", children: [
1574
1610
  /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1 font-medium text-white opacity-60", children: [
@@ -1585,13 +1621,13 @@ var FeesDetails = ({
1585
1621
  })} ${paymentToken?.symbol}`
1586
1622
  ] }),
1587
1623
  /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex gap-1 items-center", children: [
1588
- /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
1624
+ route?.xSwapFees.expressDeliveryFee && !isGettingRoute && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
1589
1625
  "div",
1590
1626
  {
1591
- className: `flex gap-1 items-center font-medium ${expressChecked && !exceedsExpressDeliveryLimit ? "text-x_green" : "text-white opacity-60"}`,
1627
+ className: `flex gap-1 items-center font-medium ${isExpressDeliveryPossible ? "text-x_green" : "text-white opacity-60"}`,
1592
1628
  children: [
1593
1629
  /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(TimerIcon, {}),
1594
- expressChecked && !exceedsExpressDeliveryLimit ? "Fast ~ 30sec " : "Normal ~ 30min"
1630
+ isExpressDeliveryPossible ? "Fast ~ 30sec " : "Normal ~ 30min"
1595
1631
  ]
1596
1632
  }
1597
1633
  ),
@@ -1647,10 +1683,10 @@ var FeesDetails = ({
1647
1683
  };
1648
1684
 
1649
1685
  // src/components/TxConfigForm/Summary.tsx
1650
- var import_react6 = require("react");
1686
+ var import_react7 = require("react");
1651
1687
 
1652
1688
  // src/components/TxConfigForm/UsdPrice.tsx
1653
- var import_react5 = require("react");
1689
+ var import_react6 = require("react");
1654
1690
  var import_jsx_runtime32 = require("react/jsx-runtime");
1655
1691
  var UsdPrice = ({
1656
1692
  prices,
@@ -1660,8 +1696,8 @@ var UsdPrice = ({
1660
1696
  type,
1661
1697
  setExceedsExpressDeliveryLimit
1662
1698
  }) => {
1663
- const [usdPrice, setUsdPrice] = (0, import_react5.useState)("0.00");
1664
- (0, import_react5.useEffect)(() => {
1699
+ const [usdPrice, setUsdPrice] = (0, import_react6.useState)("0.00");
1700
+ (0, import_react6.useEffect)(() => {
1665
1701
  if (token && prices && prices[token.address]) {
1666
1702
  const newUsdPrice = (Number(amount) * Number(prices[token.address])).toFixed(2);
1667
1703
  if (type === "src" && setExceedsExpressDeliveryLimit) {
@@ -1675,16 +1711,28 @@ var UsdPrice = ({
1675
1711
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "opacity-60 py-4", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Skeleton, { width: "w-12", height: "h-4" }) : token ? prices && prices[token.address] ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: `$${usdPrice}` }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Alert, { desc: "Unknown price" }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: "$0.00" }) });
1676
1712
  };
1677
1713
 
1678
- // src/components/TxConfigForm/Summary.tsx
1714
+ // src/components/UnknownTokenLogo/UnknownTokenLogo.tsx
1679
1715
  var import_jsx_runtime33 = require("react/jsx-runtime");
1716
+ var UnknownTokenLogo = ({ tokenName, className }) => {
1717
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1718
+ "div",
1719
+ {
1720
+ className: `w-5 h-5 rounded-full bg-white shadow-sm flex items-center justify-center text-black ${className}`,
1721
+ children: tokenName.substring(0, 1)
1722
+ }
1723
+ );
1724
+ };
1725
+
1726
+ // src/components/TxConfigForm/Summary.tsx
1727
+ var import_jsx_runtime34 = require("react/jsx-runtime");
1680
1728
  var Summary = ({
1681
1729
  isGettingRoute,
1682
1730
  route,
1683
1731
  dstToken,
1684
1732
  dstChain
1685
1733
  }) => {
1686
- const [prices, setPrices] = (0, import_react6.useState)();
1687
- const amountReadable = (0, import_react6.useMemo)(
1734
+ const [prices, setPrices] = (0, import_react7.useState)();
1735
+ const amountReadable = (0, import_react7.useMemo)(
1688
1736
  () => weiToHumanReadable({
1689
1737
  amount: route?.estAmountOut || "0",
1690
1738
  decimals: dstToken?.decimals || 18,
@@ -1692,41 +1740,54 @@ var Summary = ({
1692
1740
  }),
1693
1741
  [route, dstToken]
1694
1742
  );
1695
- (0, import_react6.useEffect)(() => {
1743
+ (0, import_react7.useEffect)(() => {
1696
1744
  if (dstChain) {
1697
1745
  getPrices({ chainId: dstChain.chainId, currency: "USD" }).then(
1698
1746
  (prices2) => setPrices(prices2)
1699
1747
  );
1700
1748
  }
1701
1749
  }, [dstChain]);
1702
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4 relative", children: [
1703
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex justify-between", children: [
1704
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col gap-1", children: [
1705
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[rgba(255,255,255,0.6)] text-sm", children: "You receive" }),
1706
- isGettingRoute ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1750
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex flex-col globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4 relative", children: [
1751
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex justify-between", children: [
1752
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex flex-col gap-1", children: [
1753
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-[rgba(255,255,255,0.6)] text-sm", children: "You receive" }),
1754
+ isGettingRoute ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1707
1755
  Skeleton,
1708
1756
  {
1709
1757
  width: "w-[100px]",
1710
1758
  height: "h-[36px]",
1711
1759
  other: "sm:w-[190px]"
1712
1760
  }
1713
- ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "flex gap-2 items-center text-white text-xl sm:text-3xl", children: amountReadable })
1761
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "flex gap-2 items-center text-white text-xl sm:text-3xl", children: amountReadable })
1714
1762
  ] }),
1715
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-col items-end gap-1 text-sm", children: [
1716
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex justify-center items-center gap-1", children: [
1717
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "w-4 sm:w-6 h-4 sm:h-6", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("img", { src: dstToken?.image, alt: dstToken?.name }) }),
1718
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-base sm:text-xl", children: dstToken?.symbol })
1763
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex flex-col items-end gap-1 text-sm", children: [
1764
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex justify-center items-center gap-1", children: [
1765
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "w-5 h-5", children: dstToken?.image ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1766
+ "img",
1767
+ {
1768
+ className: "w-5 h-5",
1769
+ src: dstToken?.image,
1770
+ alt: dstToken?.name
1771
+ }
1772
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1773
+ UnknownTokenLogo,
1774
+ {
1775
+ tokenName: "?",
1776
+ className: "token-select__generated-logo"
1777
+ }
1778
+ ) }),
1779
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-base sm:text-xl", children: dstToken?.name })
1719
1780
  ] }),
1720
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex justify-center items-center gap-1", children: [
1721
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-[rgba(255,255,255,0.6)] text-right", children: "on " }),
1722
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center gap-1 text-white", children: [
1723
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "w-4 h-4", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("img", { src: dstChain?.image, alt: dstChain?.name }) }),
1724
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { children: dstChain?.displayName })
1781
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex justify-center items-center gap-1", children: [
1782
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-[rgba(255,255,255,0.6)] text-right", children: "on " }),
1783
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex items-center gap-1 text-white", children: [
1784
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "w-4 h-4", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("img", { src: dstChain?.image, alt: dstChain?.name }) }),
1785
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { children: dstChain?.displayName })
1725
1786
  ] })
1726
1787
  ] })
1727
1788
  ] })
1728
1789
  ] }),
1729
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1790
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1730
1791
  UsdPrice,
1731
1792
  {
1732
1793
  prices,
@@ -1736,17 +1797,17 @@ var Summary = ({
1736
1797
  type: "dst"
1737
1798
  }
1738
1799
  ),
1739
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("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__ */ (0, import_jsx_runtime33.jsx)("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__ */ (0, import_jsx_runtime33.jsx)(ArrowDownIcon, {}) }) })
1800
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("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__ */ (0, import_jsx_runtime34.jsx)("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__ */ (0, import_jsx_runtime34.jsx)(ArrowDownIcon, {}) }) })
1740
1801
  ] });
1741
1802
  };
1742
1803
 
1743
1804
  // src/components/TxConfigForm/SwapPanel.tsx
1744
- var import_react9 = require("react");
1805
+ var import_react10 = require("react");
1745
1806
 
1746
1807
  // src/components/TxConfigForm/TokenPicker.tsx
1747
- var import_react7 = require("react");
1808
+ var import_react8 = require("react");
1748
1809
  var import_react_dom = require("react-dom");
1749
- var import_jsx_runtime34 = require("react/jsx-runtime");
1810
+ var import_jsx_runtime35 = require("react/jsx-runtime");
1750
1811
  var TokenPicker = ({
1751
1812
  onCloseClick,
1752
1813
  tokens,
@@ -1755,7 +1816,7 @@ var TokenPicker = ({
1755
1816
  signer,
1756
1817
  balances
1757
1818
  }) => {
1758
- const [searchValue, setSearchValue] = (0, import_react7.useState)("");
1819
+ const [searchValue, setSearchValue] = (0, import_react8.useState)("");
1759
1820
  const modalRoot = document.querySelector("#xswap-modal");
1760
1821
  const onBackdropClick = (e) => {
1761
1822
  e.stopPropagation();
@@ -1764,7 +1825,7 @@ var TokenPicker = ({
1764
1825
  onCloseClick();
1765
1826
  }
1766
1827
  };
1767
- const filteredTokens = (0, import_react7.useMemo)(() => {
1828
+ const filteredTokens = (0, import_react8.useMemo)(() => {
1768
1829
  const isMatch = (value, searchValue2) => value.toLowerCase().indexOf(searchValue2.toLowerCase()) > -1;
1769
1830
  return tokens?.filter(
1770
1831
  (token) => isMatch(token.symbol, searchValue) || isMatch(token.name, searchValue) || token.address === searchValue.toLowerCase()
@@ -1773,24 +1834,24 @@ var TokenPicker = ({
1773
1834
  );
1774
1835
  }, [searchValue, tokens]);
1775
1836
  return modalRoot ? (0, import_react_dom.createPortal)(
1776
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1837
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
1777
1838
  "div",
1778
1839
  {
1779
1840
  onClick: onBackdropClick,
1780
1841
  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",
1781
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("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: [
1782
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1842
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("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: [
1843
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
1783
1844
  "div",
1784
1845
  {
1785
1846
  onClick: onCloseClick,
1786
1847
  className: "absolute top-4 right-4 cursor-pointer",
1787
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CloseIcon, {})
1848
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CloseIcon, {})
1788
1849
  }
1789
1850
  ),
1790
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-base mb-4", children: "Pick a token" }),
1791
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("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: [
1792
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "w-6 h-6", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(SearchIcon, {}) }),
1793
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1851
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-base mb-4", children: "Pick a token" }),
1852
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("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: [
1853
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "w-6 h-6", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SearchIcon, {}) }),
1854
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
1794
1855
  "input",
1795
1856
  {
1796
1857
  placeholder: "Search name or paste address",
@@ -1800,7 +1861,7 @@ var TokenPicker = ({
1800
1861
  }
1801
1862
  )
1802
1863
  ] }),
1803
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "my-4 mx-0 flex flex-wrap gap-3", children: tokens?.filter((token) => token?.quickPick).map((token) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
1864
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "my-4 mx-0 flex flex-wrap gap-3", children: tokens?.filter((token) => token?.quickPick).map((token) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
1804
1865
  "div",
1805
1866
  {
1806
1867
  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)]" : ""}`,
@@ -1809,14 +1870,14 @@ var TokenPicker = ({
1809
1870
  onCloseClick();
1810
1871
  },
1811
1872
  children: [
1812
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("img", { src: token.image, alt: token.name, className: "w-5" }),
1813
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "text-sm", children: token.symbol })
1873
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("img", { src: token.image, alt: token.name, className: "w-5" }),
1874
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "text-sm", children: token.symbol })
1814
1875
  ]
1815
1876
  },
1816
1877
  token.address
1817
1878
  )) }),
1818
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "h-[2px] my-0 mx-[-24px] w-[100%+48px] px-12 bg-[rgba(255,255,255,0.1)]" }),
1819
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("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__ */ (0, import_jsx_runtime34.jsxs)(
1879
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-[2px] my-0 mx-[-24px] w-[100%+48px] px-12 bg-[rgba(255,255,255,0.1)]" }),
1880
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("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__ */ (0, import_jsx_runtime35.jsxs)(
1820
1881
  "div",
1821
1882
  {
1822
1883
  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)]" : ""}`,
@@ -1825,29 +1886,29 @@ var TokenPicker = ({
1825
1886
  onCloseClick();
1826
1887
  },
1827
1888
  children: [
1828
- token.image ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1889
+ token.image ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
1829
1890
  "img",
1830
1891
  {
1831
1892
  src: token.image,
1832
1893
  alt: token.name,
1833
1894
  className: "token-picker__all__logo"
1834
1895
  }
1835
- ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("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) }),
1836
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex justify-between items-center gap-1 overflow-hidden grow", children: [
1837
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex flex-col leading-[16px]", children: [
1838
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "overflow-hidden whitespace-nowrap text-ellipsis text-[15px]", children: token.name }),
1839
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "text-[#888] text-[11px]", children: token.symbol })
1896
+ ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("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) }),
1897
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex justify-between items-center gap-1 overflow-hidden grow", children: [
1898
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col leading-[16px]", children: [
1899
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "overflow-hidden whitespace-nowrap text-ellipsis text-[15px]", children: token.name }),
1900
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "text-[#888] text-[11px]", children: token.symbol })
1840
1901
  ] }),
1841
- signer && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: balances && balances[token.address] && token.decimals ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "text-xs", children: weiToHumanReadable({
1902
+ signer && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: balances && balances[token.address] && token.decimals ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "text-xs", children: weiToHumanReadable({
1842
1903
  amount: balances[token.address]?.toString() || "0",
1843
1904
  decimals: token.decimals,
1844
1905
  precisionFractionalPlaces: 4
1845
- }) }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Skeleton, { width: "w-12", height: "h-3" }) })
1906
+ }) }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Skeleton, { width: "w-12", height: "h-3" }) })
1846
1907
  ] })
1847
1908
  ]
1848
1909
  },
1849
1910
  `${index}_${token.address}`
1850
- )) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-sm text-white", children: "No tokens found." }) }) })
1911
+ )) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm text-white", children: "No tokens found." }) }) })
1851
1912
  ] })
1852
1913
  }
1853
1914
  ),
@@ -1856,7 +1917,7 @@ var TokenPicker = ({
1856
1917
  };
1857
1918
 
1858
1919
  // src/components/TxConfigForm/ChainListElement.tsx
1859
- var import_jsx_runtime35 = require("react/jsx-runtime");
1920
+ var import_jsx_runtime36 = require("react/jsx-runtime");
1860
1921
  var ChainListElement = ({
1861
1922
  chain,
1862
1923
  setSrcChain,
@@ -1864,8 +1925,8 @@ var ChainListElement = ({
1864
1925
  index,
1865
1926
  length
1866
1927
  }) => {
1867
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { children: [
1868
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
1928
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
1929
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
1869
1930
  "li",
1870
1931
  {
1871
1932
  className: "bg-transparent border-none flex gap-1 items-center cursor-pointer py-2 w-full",
@@ -1874,21 +1935,21 @@ var ChainListElement = ({
1874
1935
  setChainListShown(false);
1875
1936
  },
1876
1937
  children: [
1877
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("img", { width: 12, height: 12, src: chain.image, alt: chain.displayName }),
1938
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("img", { width: 12, height: 12, src: chain.image, alt: chain.displayName }),
1878
1939
  chain.displayName
1879
1940
  ]
1880
1941
  }
1881
1942
  ),
1882
- index !== length - 1 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-px mx-2 bg-[rgba(255,255,255,0.15)]" })
1943
+ index !== length - 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "h-px mx-2 bg-[rgba(255,255,255,0.15)]" })
1883
1944
  ] }, `${chain.ecosystem}-${chain.chainId}`);
1884
1945
  };
1885
1946
 
1886
1947
  // src/components/TxConfigForm/BalanceComponent.tsx
1887
- var import_react8 = require("react");
1948
+ var import_react9 = require("react");
1888
1949
  var import_bignumber3 = __toESM(require("bignumber.js"));
1889
- var import_jsx_runtime36 = require("react/jsx-runtime");
1950
+ var import_jsx_runtime37 = require("react/jsx-runtime");
1890
1951
  var BalanceComponent = ({ srcToken, balances }) => {
1891
- const balanceText = (0, import_react8.useMemo)(() => {
1952
+ const balanceText = (0, import_react9.useMemo)(() => {
1892
1953
  if (!balances || !srcToken) return "0";
1893
1954
  if (balances[srcToken.address]?.toString() === "0") return "0";
1894
1955
  const fullHumanReadable = weiToHumanReadable({
@@ -1906,7 +1967,7 @@ var BalanceComponent = ({ srcToken, balances }) => {
1906
1967
  precisionFractionalPlaces: 5
1907
1968
  });
1908
1969
  }, [srcToken, balances]);
1909
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
1970
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
1910
1971
  "Balance:",
1911
1972
  " ",
1912
1973
  srcToken && balances ? weiToHumanReadable({
@@ -1914,12 +1975,12 @@ var BalanceComponent = ({ srcToken, balances }) => {
1914
1975
  decimals: srcToken.decimals,
1915
1976
  precisionFractionalPlaces: 4
1916
1977
  }) : 0,
1917
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "bg-gradient-to-r from-x_blue_light to-x_blue_dark bg-clip-text text-transparent", children: "Max" })
1978
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "bg-gradient-to-r from-x_blue_light to-x_blue_dark bg-clip-text text-transparent", children: "Max" })
1918
1979
  ] });
1919
1980
  };
1920
1981
 
1921
1982
  // src/components/TxConfigForm/SwapPanel.tsx
1922
- var import_jsx_runtime37 = require("react/jsx-runtime");
1983
+ var import_jsx_runtime38 = require("react/jsx-runtime");
1923
1984
  var SwapPanel = ({
1924
1985
  amount,
1925
1986
  setAmount,
@@ -1933,10 +1994,10 @@ var SwapPanel = ({
1933
1994
  supportedChains,
1934
1995
  setExceedsExpressDeliveryLimit
1935
1996
  }) => {
1936
- const [chainListShown, setChainListShown] = (0, import_react9.useState)(false);
1937
- const [tokenListShown, setTokenListShown] = (0, import_react9.useState)(false);
1938
- const listRef = (0, import_react9.useRef)(null);
1939
- const buttonRef = (0, import_react9.useRef)(null);
1997
+ const [chainListShown, setChainListShown] = (0, import_react10.useState)(false);
1998
+ const [tokenListShown, setTokenListShown] = (0, import_react10.useState)(false);
1999
+ const listRef = (0, import_react10.useRef)(null);
2000
+ const buttonRef = (0, import_react10.useRef)(null);
1940
2001
  const handleClickOutside = (event) => {
1941
2002
  if (listRef.current && buttonRef.current) {
1942
2003
  const listElement = listRef.current;
@@ -1951,25 +2012,25 @@ var SwapPanel = ({
1951
2012
  weiToHumanReadable({
1952
2013
  amount: balances[srcToken.address]?.toString() || "0",
1953
2014
  decimals: srcToken.decimals,
1954
- precisionFractionalPlaces: 4
2015
+ precisionFractionalPlaces: srcToken.decimals
1955
2016
  })
1956
2017
  );
1957
2018
  };
1958
- (0, import_react9.useEffect)(() => {
2019
+ (0, import_react10.useEffect)(() => {
1959
2020
  if (chainListShown) {
1960
2021
  document.addEventListener("mousedown", handleClickOutside);
1961
2022
  return () => document.removeEventListener("mousedown", handleClickOutside);
1962
2023
  }
1963
2024
  }, [chainListShown]);
1964
- const chainListOptions = (0, import_react9.useMemo)(
2025
+ const chainListOptions = (0, import_react10.useMemo)(
1965
2026
  () => supportedChains.filter((chain) => chain.chainId !== srcChain?.chainId),
1966
2027
  [supportedChains, srcChain]
1967
2028
  );
1968
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex justify-between globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4", children: [
1969
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex flex-col justify-between gap-2 overflow-hidden w-1/2", children: [
1970
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex flex-col gap-1", children: [
1971
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "text-white opacity-60 text-xs sm:text-sm font-medium", children: "You pay" }),
1972
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2029
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex justify-between globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4", children: [
2030
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col justify-between gap-2 overflow-hidden w-1/2", children: [
2031
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-1", children: [
2032
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-white opacity-60 text-xs sm:text-sm font-medium", children: "You pay" }),
2033
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1973
2034
  "input",
1974
2035
  {
1975
2036
  className: "p-0 border-none outline-none bg-transparent text-2xl overflow-ellipsis",
@@ -1988,7 +2049,7 @@ var SwapPanel = ({
1988
2049
  }
1989
2050
  )
1990
2051
  ] }),
1991
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "flex items-center text-sm text-[rgba(255,255,255,0.6)]", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2052
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "flex items-center text-sm text-[rgba(255,255,255,0.6)]", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1992
2053
  UsdPrice,
1993
2054
  {
1994
2055
  prices,
@@ -2000,8 +2061,8 @@ var SwapPanel = ({
2000
2061
  }
2001
2062
  ) })
2002
2063
  ] }),
2003
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex flex-col relative items-end gap-2.5 w-1/2 text-xs", children: [
2004
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
2064
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col relative items-end gap-2.5 w-1/2 text-xs", children: [
2065
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
2005
2066
  "div",
2006
2067
  {
2007
2068
  className: "flex gap-2 items-center p-2 max-w-full cursor-pointer bg-black text-white globalBorder rounded-3xl whitespace-nowrap",
@@ -2009,7 +2070,7 @@ var SwapPanel = ({
2009
2070
  setTokenListShown((state) => !state);
2010
2071
  },
2011
2072
  children: [
2012
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2073
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2013
2074
  "img",
2014
2075
  {
2015
2076
  height: 16,
@@ -2018,12 +2079,12 @@ var SwapPanel = ({
2018
2079
  alt: srcToken?.name
2019
2080
  }
2020
2081
  ),
2021
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { children: srcToken?.symbol }),
2022
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(DownArrowIcon, {})
2082
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { children: srcToken?.symbol }),
2083
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DownArrowIcon, {})
2023
2084
  ]
2024
2085
  }
2025
2086
  ),
2026
- tokenListShown && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2087
+ tokenListShown && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2027
2088
  TokenPicker,
2028
2089
  {
2029
2090
  onCloseClick: () => setTokenListShown(false),
@@ -2034,22 +2095,22 @@ var SwapPanel = ({
2034
2095
  balances
2035
2096
  }
2036
2097
  ),
2037
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2098
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2038
2099
  "div",
2039
2100
  {
2040
2101
  onClick: handleMaxClick,
2041
2102
  className: "flex gap-1 items-center font-medium text-white opacity-60 py-0.5 cursor-pointer",
2042
- children: signer && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(BalanceComponent, { balances, srcToken })
2103
+ children: signer && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BalanceComponent, { balances, srcToken })
2043
2104
  }
2044
2105
  ),
2045
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
2106
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
2046
2107
  "div",
2047
2108
  {
2048
2109
  ref: buttonRef,
2049
2110
  className: "bg-black globalBorder rounded-2xl whitespace-nowrap flex items-center p-2 cursor-pointer gap-2",
2050
2111
  onClick: () => setChainListShown((prev) => !prev),
2051
2112
  children: [
2052
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2113
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2053
2114
  "img",
2054
2115
  {
2055
2116
  width: "16",
@@ -2058,17 +2119,17 @@ var SwapPanel = ({
2058
2119
  alt: srcChain?.name
2059
2120
  }
2060
2121
  ),
2061
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { children: srcChain?.displayName }),
2062
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(DownArrowIcon, {})
2122
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { children: srcChain?.displayName }),
2123
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DownArrowIcon, {})
2063
2124
  ]
2064
2125
  }
2065
2126
  ),
2066
- chainListShown && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2127
+ chainListShown && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2067
2128
  "ul",
2068
2129
  {
2069
2130
  ref: listRef,
2070
2131
  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",
2071
- children: chainListOptions.map((chain, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2132
+ children: chainListOptions.map((chain, index) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2072
2133
  ChainListElement,
2073
2134
  {
2074
2135
  index,
@@ -2085,9 +2146,9 @@ var SwapPanel = ({
2085
2146
  };
2086
2147
 
2087
2148
  // src/components/TxConfigForm/ErrorField.tsx
2088
- var import_jsx_runtime38 = require("react/jsx-runtime");
2149
+ var import_jsx_runtime39 = require("react/jsx-runtime");
2089
2150
  var ErrorField = ({ error }) => {
2090
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2151
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
2091
2152
  "div",
2092
2153
  {
2093
2154
  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"}`,
@@ -2097,15 +2158,15 @@ var ErrorField = ({ error }) => {
2097
2158
  };
2098
2159
 
2099
2160
  // src/components/TxConfigForm/Description.tsx
2100
- var import_jsx_runtime39 = require("react/jsx-runtime");
2161
+ var import_jsx_runtime40 = require("react/jsx-runtime");
2101
2162
  var Description = ({ description }) => {
2102
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "flex flex-col items-start rounded-lg px-4 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "w-full flex gap-4 items-start justify-between text-xl", children: description }) });
2163
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex flex-col items-start rounded-lg px-4 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "w-full flex gap-4 items-start justify-between text-xl", children: description }) });
2103
2164
  };
2104
2165
 
2105
2166
  // src/components/TxConfigForm/Button.tsx
2106
- var import_jsx_runtime40 = require("react/jsx-runtime");
2167
+ var import_jsx_runtime41 = require("react/jsx-runtime");
2107
2168
  var Button = ({ children, onClick, type, disabled }) => {
2108
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
2169
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2109
2170
  "button",
2110
2171
  {
2111
2172
  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",
@@ -2118,8 +2179,9 @@ var Button = ({ children, onClick, type, disabled }) => {
2118
2179
  };
2119
2180
 
2120
2181
  // src/components/TxConfigForm/Form.tsx
2121
- var import_jsx_runtime41 = require("react/jsx-runtime");
2182
+ var import_jsx_runtime42 = require("react/jsx-runtime");
2122
2183
  var Form = ({
2184
+ integratorId,
2123
2185
  dstChainId,
2124
2186
  dstTokenAddr,
2125
2187
  customContractCalls,
@@ -2128,31 +2190,31 @@ var Form = ({
2128
2190
  onSubmit,
2129
2191
  onClose
2130
2192
  }) => {
2131
- const [signer, setSigner] = (0, import_react10.useState)();
2132
- const [dstChain, setDstChain] = (0, import_react10.useState)();
2133
- const [dstToken, setDstToken] = (0, import_react10.useState)();
2134
- const [srcChain, setSrcChain] = (0, import_react10.useState)();
2135
- const [srcToken, setSrcToken] = (0, import_react10.useState)();
2136
- const [amount, setAmount] = (0, import_react10.useState)("");
2137
- const [paymentToken, setPaymentToken] = (0, import_react10.useState)();
2138
- const [route, setRoute] = (0, import_react10.useState)();
2139
- const [expressChecked, setExpressChecked] = (0, import_react10.useState)(true);
2140
- const [historyTabShown, setHistoryTabShown] = (0, import_react10.useState)(false);
2141
- const [isGettingRoute, setIsGettingRoute] = (0, import_react10.useState)(false);
2142
- const [prices, setPrices] = (0, import_react10.useState)();
2143
- const [balances, setBalances] = (0, import_react10.useState)();
2144
- const [settingsShown, setSettingsShown] = (0, import_react10.useState)(false);
2145
- const [formError, setFormError] = (0, import_react10.useState)("");
2146
- const [slippage, setSlippage] = (0, import_react10.useState)("1.5");
2147
- const [feesDetailsShown, setFeesDetailsShown] = (0, import_react10.useState)(false);
2148
- const [exceedsExpressDeliveryLimit, setExceedsExpressDeliveryLimit] = (0, import_react10.useState)(false);
2193
+ const [signer, setSigner] = (0, import_react11.useState)();
2194
+ const [dstChain, setDstChain] = (0, import_react11.useState)();
2195
+ const [dstToken, setDstToken] = (0, import_react11.useState)();
2196
+ const [srcChain, setSrcChain] = (0, import_react11.useState)();
2197
+ const [srcToken, setSrcToken] = (0, import_react11.useState)();
2198
+ const [amount, setAmount] = (0, import_react11.useState)("");
2199
+ const [paymentToken, setPaymentToken] = (0, import_react11.useState)();
2200
+ const [route, setRoute] = (0, import_react11.useState)();
2201
+ const [expressChecked, setExpressChecked] = (0, import_react11.useState)(true);
2202
+ const [historyTabShown, setHistoryTabShown] = (0, import_react11.useState)(false);
2203
+ const [isGettingRoute, setIsGettingRoute] = (0, import_react11.useState)(false);
2204
+ const [prices, setPrices] = (0, import_react11.useState)();
2205
+ const [balances, setBalances] = (0, import_react11.useState)();
2206
+ const [settingsShown, setSettingsShown] = (0, import_react11.useState)(false);
2207
+ const [formError, setFormError] = (0, import_react11.useState)("");
2208
+ const [slippage, setSlippage] = (0, import_react11.useState)("1.5");
2209
+ const [feesDetailsShown, setFeesDetailsShown] = (0, import_react11.useState)(false);
2210
+ const [exceedsExpressDeliveryLimit, setExceedsExpressDeliveryLimit] = (0, import_react11.useState)(false);
2149
2211
  const debouncedAmount = useDebounce(amount, 1e3);
2150
2212
  const account = (0, import_wagmi2.useAccount)();
2151
2213
  const { switchChainAsync } = (0, import_wagmi2.useSwitchChain)();
2152
- (0, import_react10.useEffect)(() => {
2214
+ (0, import_react11.useEffect)(() => {
2153
2215
  setSigner(account.address);
2154
2216
  }, [account.address]);
2155
- (0, import_react10.useEffect)(() => {
2217
+ (0, import_react11.useEffect)(() => {
2156
2218
  const defaultChain = supportedChains.find(
2157
2219
  ({ chainId }) => chainId === account.chainId?.toString()
2158
2220
  );
@@ -2162,18 +2224,28 @@ var Form = ({
2162
2224
  )
2163
2225
  );
2164
2226
  }, [account.chainId]);
2165
- (0, import_react10.useEffect)(() => {
2227
+ (0, import_react11.useEffect)(() => {
2166
2228
  setDstChain(supportedChains.find((chain) => chain.chainId === dstChainId));
2167
2229
  }, [supportedChains, dstChainId]);
2168
- (0, import_react10.useEffect)(() => {
2169
- setDstToken(
2170
- dstChain?.tokens.find(
2230
+ (0, import_react11.useEffect)(() => {
2231
+ (async () => {
2232
+ if (!dstChain) {
2233
+ return;
2234
+ }
2235
+ let dstTokenResult = dstChain?.tokens.find(
2171
2236
  (token) => token.address.toLowerCase() === dstTokenAddr.toLowerCase()
2172
- )
2173
- );
2237
+ );
2238
+ if (!dstTokenResult) {
2239
+ dstTokenResult = await getCustomTokenData(
2240
+ dstChain,
2241
+ dstTokenAddr.toLowerCase()
2242
+ );
2243
+ }
2244
+ setDstToken(dstTokenResult);
2245
+ })();
2174
2246
  }, [dstChain]);
2175
- (0, import_react10.useEffect)(() => {
2176
- if (srcChain && srcToken && dstChain && debouncedAmount && paymentToken && slippage) {
2247
+ (0, import_react11.useEffect)(() => {
2248
+ if (integratorId && srcChain && srcToken && dstChain && debouncedAmount && paymentToken && slippage) {
2177
2249
  setFormError("");
2178
2250
  const timeout = setTimeout(() => {
2179
2251
  setFormError("Getting Route is taking longer than usually");
@@ -2185,6 +2257,7 @@ var Form = ({
2185
2257
  `Configuration error: selected token ($${srcToken.symbol} ${srcToken.name}) has unknown decimals param.`
2186
2258
  );
2187
2259
  getRoute({
2260
+ integratorId,
2188
2261
  fromAmount: import_ethers4.ethers.utils.parseUnits(debouncedAmount, srcToken.decimals).toString(),
2189
2262
  fromAddress: signer || ADDRESSES[srcChain.chainId].FeeCollector,
2190
2263
  fromChain: srcChain.chainId,
@@ -2215,7 +2288,7 @@ var Form = ({
2215
2288
  slippage,
2216
2289
  expressChecked
2217
2290
  ]);
2218
- (0, import_react10.useEffect)(() => {
2291
+ (0, import_react11.useEffect)(() => {
2219
2292
  if (srcChain) {
2220
2293
  setPaymentToken(
2221
2294
  srcChain.tokens.find(
@@ -2224,21 +2297,21 @@ var Form = ({
2224
2297
  );
2225
2298
  }
2226
2299
  }, [srcChain]);
2227
- (0, import_react10.useEffect)(() => {
2300
+ (0, import_react11.useEffect)(() => {
2228
2301
  setAmount("");
2229
2302
  setFormError("");
2230
2303
  }, [srcToken]);
2231
- (0, import_react10.useEffect)(() => {
2304
+ (0, import_react11.useEffect)(() => {
2232
2305
  setSrcToken(srcChain?.tokens[0]);
2233
2306
  }, [srcChain]);
2234
- (0, import_react10.useEffect)(() => {
2307
+ (0, import_react11.useEffect)(() => {
2235
2308
  if (srcChain) {
2236
2309
  getPrices({ chainId: srcChain.chainId, currency: "USD" }).then(
2237
2310
  (prices2) => setPrices(prices2)
2238
2311
  );
2239
2312
  }
2240
2313
  }, [srcChain]);
2241
- (0, import_react10.useEffect)(() => {
2314
+ (0, import_react11.useEffect)(() => {
2242
2315
  if (srcChain && signer) {
2243
2316
  getBalances(srcChain, signer).then((balances2) => setBalances(balances2));
2244
2317
  }
@@ -2250,13 +2323,13 @@ var Form = ({
2250
2323
  const handleSwitchChain = async () => {
2251
2324
  await switchChainAsync({ chainId: Number(srcChain?.chainId) });
2252
2325
  };
2253
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
2326
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
2254
2327
  "form",
2255
2328
  {
2256
2329
  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",
2257
2330
  onSubmit: handleSubmit,
2258
2331
  children: [
2259
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2332
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2260
2333
  TopBar,
2261
2334
  {
2262
2335
  signer,
@@ -2266,7 +2339,7 @@ var Form = ({
2266
2339
  onClose
2267
2340
  }
2268
2341
  ),
2269
- settingsShown && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2342
+ settingsShown && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2270
2343
  Settings,
2271
2344
  {
2272
2345
  expressChecked,
@@ -2276,9 +2349,9 @@ var Form = ({
2276
2349
  setSlippage
2277
2350
  }
2278
2351
  ),
2279
- historyTabShown ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(History, { signer, supportedChains }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col gap-2", children: [
2280
- desc && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Description, { description: desc }),
2281
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2352
+ historyTabShown ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(History, { signer, supportedChains }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex flex-col gap-2", children: [
2353
+ desc && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Description, { description: desc }),
2354
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2282
2355
  SwapPanel,
2283
2356
  {
2284
2357
  amount,
@@ -2294,7 +2367,7 @@ var Form = ({
2294
2367
  setExceedsExpressDeliveryLimit
2295
2368
  }
2296
2369
  ),
2297
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2370
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2298
2371
  Summary,
2299
2372
  {
2300
2373
  isGettingRoute,
@@ -2303,7 +2376,7 @@ var Form = ({
2303
2376
  dstChain
2304
2377
  }
2305
2378
  ),
2306
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2379
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2307
2380
  FeesDetails,
2308
2381
  {
2309
2382
  route,
@@ -2317,8 +2390,8 @@ var Form = ({
2317
2390
  setFeesDetailsShown
2318
2391
  }
2319
2392
  ),
2320
- formError.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ErrorField, { error: formError }),
2321
- signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { type: "button", onClick: handleSwitchChain, children: "Switch chain" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2393
+ formError.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ErrorField, { error: formError }),
2394
+ signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Button, { type: "button", onClick: handleSwitchChain, children: "Switch chain" }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2322
2395
  Button,
2323
2396
  {
2324
2397
  type: "submit",
@@ -2333,8 +2406,9 @@ var Form = ({
2333
2406
  };
2334
2407
 
2335
2408
  // src/components/TxConfigForm/index.tsx
2336
- var import_jsx_runtime42 = require("react/jsx-runtime");
2409
+ var import_jsx_runtime43 = require("react/jsx-runtime");
2337
2410
  var TxConfigForm = ({
2411
+ integratorId,
2338
2412
  dstChainId,
2339
2413
  dstTokenAddr,
2340
2414
  customContractCalls,
@@ -2351,19 +2425,20 @@ var TxConfigForm = ({
2351
2425
  }
2352
2426
  };
2353
2427
  const queryClient = new import_react_query.QueryClient();
2354
- const wagmiConfig = (0, import_react11.useMemo)(
2428
+ const wagmiConfig = (0, import_react12.useMemo)(
2355
2429
  () => getWagmiConfig(supportedChains),
2356
2430
  supportedChains
2357
2431
  );
2358
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_wagmi3.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2432
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_wagmi3.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2359
2433
  "div",
2360
2434
  {
2361
2435
  className: "top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10",
2362
2436
  onClick: onBackdropClick,
2363
- children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "relative bg-black rounded-3xl overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]", children: [
2364
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2437
+ children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "relative bg-black rounded-3xl overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]", children: [
2438
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2365
2439
  Form,
2366
2440
  {
2441
+ integratorId,
2367
2442
  dstChainId,
2368
2443
  dstTokenAddr,
2369
2444
  customContractCalls,
@@ -2373,12 +2448,13 @@ var TxConfigForm = ({
2373
2448
  onClose
2374
2449
  }
2375
2450
  ),
2376
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PoweredBy, {})
2451
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PoweredBy, {})
2377
2452
  ] })
2378
2453
  }
2379
2454
  ) }) });
2380
2455
  };
2381
2456
  var openTxConfigForm = async ({
2457
+ integratorId,
2382
2458
  dstChainId,
2383
2459
  dstTokenAddr,
2384
2460
  customContractCalls,
@@ -2389,9 +2465,10 @@ var openTxConfigForm = async ({
2389
2465
  return await new Promise(async (resolve) => {
2390
2466
  await waitForInitialization();
2391
2467
  xswapRoot.render(
2392
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2468
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2393
2469
  TxConfigForm,
2394
2470
  {
2471
+ integratorId,
2395
2472
  dstChainId,
2396
2473
  dstTokenAddr,
2397
2474
  customContractCalls,
@@ -2414,39 +2491,38 @@ var openTxConfigForm = async ({
2414
2491
  };
2415
2492
 
2416
2493
  // src/components/TxStatusButton/index.tsx
2417
- var import_react12 = require("react");
2418
- var import_jsx_runtime43 = require("react/jsx-runtime");
2494
+ var import_react13 = require("react");
2495
+ var import_jsx_runtime44 = require("react/jsx-runtime");
2419
2496
  var TxStatusButton = ({ transaction }) => {
2420
2497
  const {
2421
- fromChain,
2422
- fromChainImage,
2423
- fromToken,
2424
- fromTokenImage,
2425
- fromAmount,
2426
- toChain,
2427
- toChainImage,
2498
+ srcChain: fromChain,
2499
+ srcChainImage: fromChainImage,
2500
+ srcToken: fromToken,
2501
+ srcTokenImage: fromTokenImage,
2502
+ srcAmount: fromAmount,
2503
+ dstChain: toChain,
2504
+ dstChainImage: toChainImage,
2428
2505
  isDone,
2429
- txHash,
2430
2506
  explorer
2431
2507
  } = transaction;
2432
- const [isWide, setIsWide] = (0, import_react12.useState)(false);
2433
- const background = (0, import_react12.useMemo)(
2508
+ const [isWide, setIsWide] = (0, import_react13.useState)(false);
2509
+ const background = (0, import_react13.useMemo)(
2434
2510
  () => 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)]",
2435
2511
  [isDone]
2436
2512
  );
2437
- const border = (0, import_react12.useMemo)(
2513
+ const border = (0, import_react13.useMemo)(
2438
2514
  () => isDone ? "border border-solid border-x_green_dark" : "border border-solid border-x_blue_dark",
2439
2515
  [isDone]
2440
2516
  );
2441
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex gap-2", onClick: () => setIsWide((x) => !x), children: [
2442
- isWide && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
2517
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex gap-2", onClick: () => setIsWide((x) => !x), children: [
2518
+ isWide && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
2443
2519
  "div",
2444
2520
  {
2445
2521
  className: `flex items-center min-w-60 sm:w-[520px] text-white h-14 px-4 text-sm gap-3 rounded-xl ${background} ${border}`,
2446
2522
  children: [
2447
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex justify-between flex-col gap-2 sm:gap-5 sm:flex-row w-full", children: [
2448
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex items-center gap-2", children: [
2449
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2523
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex justify-between flex-col gap-2 sm:gap-5 sm:flex-row w-full", children: [
2524
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex items-center gap-2", children: [
2525
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2450
2526
  "img",
2451
2527
  {
2452
2528
  className: "w-5 h-5",
@@ -2454,26 +2530,32 @@ var TxStatusButton = ({ transaction }) => {
2454
2530
  alt: "source chain"
2455
2531
  }
2456
2532
  ),
2457
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { children: fromChain }),
2458
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ArrowRightIcon, {}) }),
2459
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("img", { className: "w-5 h-5", src: toChainImage, alt: "to chain" }),
2460
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { children: toChain })
2533
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { children: fromChain }),
2534
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ArrowRightIcon, {}) }),
2535
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("img", { className: "w-5 h-5", src: toChainImage, alt: "to chain" }),
2536
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { children: toChain })
2461
2537
  ] }),
2462
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex items-center gap-2", children: [
2463
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { children: "Sent" }),
2464
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { children: fromAmount }),
2465
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { children: fromToken }),
2466
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2538
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex items-center gap-2", children: [
2539
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { children: "Sent" }),
2540
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { children: fromAmount }),
2541
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { children: fromToken }),
2542
+ fromTokenImage ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2467
2543
  "img",
2468
2544
  {
2469
2545
  className: "w-5 h-5",
2470
2546
  src: fromTokenImage,
2471
2547
  alt: "source token"
2472
2548
  }
2549
+ ) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2550
+ UnknownTokenLogo,
2551
+ {
2552
+ tokenName: "?",
2553
+ className: "token-select__generated-logo"
2554
+ }
2473
2555
  )
2474
2556
  ] })
2475
2557
  ] }),
2476
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2558
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2477
2559
  "a",
2478
2560
  {
2479
2561
  href: explorer,
@@ -2481,21 +2563,21 @@ var TxStatusButton = ({ transaction }) => {
2481
2563
  rel: "noreferrer",
2482
2564
  className: "no-underline cursor-pointer",
2483
2565
  "aria-label": "Show the transaction in the chain explorer",
2484
- children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ArrowUpRightIcon, {}) })
2566
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ArrowUpRightIcon, {}) })
2485
2567
  }
2486
2568
  )
2487
2569
  ]
2488
2570
  }
2489
2571
  ),
2490
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
2572
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2491
2573
  "div",
2492
2574
  {
2493
2575
  className: `text-white rounded-xl cursor-pointer ${background} ${border}`,
2494
- children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex gap-2 items-center h-14 w-20 justify-center", children: [
2495
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ArrowLeftIcon, {}),
2496
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "relative flex items-center justify-center w-9 h-9", children: isDone ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "text-x_green w-5 h-5", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CheckIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
2497
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "w-5 h-5", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(XSwapLogo, {}) }),
2498
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CircularProgressIcon, {}) })
2576
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex gap-2 items-center h-14 w-20 justify-center", children: [
2577
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ArrowLeftIcon, {}),
2578
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "relative flex items-center justify-center w-9 h-9", children: isDone ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "text-x_green w-5 h-5", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CheckIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
2579
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "w-5 h-5", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(XSwapLogo, {}) }),
2580
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CircularProgressIcon, {}) })
2499
2581
  ] }) })
2500
2582
  ] })
2501
2583
  }
@@ -2522,25 +2604,66 @@ var updateTransactionDoneInRenderedTransactions = (txHash) => {
2522
2604
  }
2523
2605
  };
2524
2606
  var renderTxStatusButtons = () => {
2525
- const buttons = renderedTransactions.map((item) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TxStatusButton, { transaction: item }, item.txHash));
2607
+ const buttons = renderedTransactions.map((item) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(TxStatusButton, { transaction: item }, item.txHash));
2526
2608
  txStatusRoot.render(buttons);
2527
2609
  };
2528
2610
 
2529
2611
  // src/components/Skeleton/index.tsx
2530
- var import_jsx_runtime44 = require("react/jsx-runtime");
2612
+ var import_jsx_runtime45 = require("react/jsx-runtime");
2531
2613
  var Skeleton = ({ width, height }) => {
2532
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `bg-current rounded animate-pulse ${width} ${height}` });
2614
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: `bg-current rounded animate-pulse ${width} ${height}` });
2533
2615
  };
2534
2616
 
2535
2617
  // src/services/integrations/monitoring.ts
2536
2618
  var import_async_retry = __toESM(require("async-retry"));
2537
- var monitorTransactionStatus = async (txChainId, txHash) => {
2619
+
2620
+ // src/services/blockchain.ts
2621
+ var import_ethers5 = require("ethers");
2622
+ var getCustomTokenData = async (chain, tokenAddress) => {
2623
+ const rpcUrl = chain.publicRpcUrls[0];
2624
+ const customTokenContract = new import_ethers5.ethers.Contract(
2625
+ tokenAddress.toLowerCase(),
2626
+ ERC20Abi,
2627
+ import_ethers5.ethers.getDefaultProvider(rpcUrl)
2628
+ );
2629
+ try {
2630
+ const query = async (contract, method, args = []) => {
2631
+ if (contract?.provider) {
2632
+ const response = await contract[method](...args);
2633
+ return response;
2634
+ }
2635
+ return null;
2636
+ };
2637
+ const responses = await Promise.all([
2638
+ query(customTokenContract, "decimals"),
2639
+ query(customTokenContract, "name"),
2640
+ query(customTokenContract, "symbol")
2641
+ ]);
2642
+ const [decimals, name, symbol] = responses;
2643
+ return {
2644
+ address: tokenAddress,
2645
+ symbol,
2646
+ name,
2647
+ decimals,
2648
+ quickPick: false,
2649
+ supported: true,
2650
+ priority: 0
2651
+ };
2652
+ } catch (_) {
2653
+ throw new Error(
2654
+ `Provided token ${tokenAddress} does not exists on chain ${chain.displayName}`
2655
+ );
2656
+ }
2657
+ };
2658
+
2659
+ // src/services/integrations/monitoring.ts
2660
+ var renderTxStatus = async (txChainId, txHash) => {
2538
2661
  const txReceipt = await getTxReceipt(txChainId, txHash);
2539
2662
  const supportedChains = (await getChains()).filter(
2540
2663
  ({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
2541
2664
  );
2542
2665
  const messageSentEvent = txReceipt.logs?.find((log) => {
2543
- return log.topics[0] === import_ethers5.ethers.utils.id(MSG_SENT_EVENT_SIG);
2666
+ return log.topics[0] === import_ethers6.ethers.utils.id(MSG_SENT_EVENT_SIG);
2544
2667
  });
2545
2668
  if (!messageSentEvent) {
2546
2669
  throw new Error(
@@ -2548,7 +2671,7 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
2548
2671
  );
2549
2672
  }
2550
2673
  const messageId = messageSentEvent?.topics[1];
2551
- const iface = new import_ethers5.ethers.utils.Interface(MSG_SENT_EVENT_ABI);
2674
+ const iface = new import_ethers6.ethers.utils.Interface(MSG_SENT_EVENT_ABI);
2552
2675
  const decodedMessageSentEvent = iface.parseLog(messageSentEvent);
2553
2676
  if (!decodedMessageSentEvent) {
2554
2677
  throw new Error(
@@ -2558,9 +2681,16 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
2558
2681
  const srcChain = supportedChains.find(
2559
2682
  (chain) => chain.chainId === txChainId.toString()
2560
2683
  );
2561
- const srcToken = srcChain?.tokens.find(
2684
+ if (!srcChain) {
2685
+ throw new Error(`Unknown src chain ${txChainId}`);
2686
+ }
2687
+ const tokenAddress = decodedMessageSentEvent.args?.token.toString();
2688
+ let srcToken = srcChain.tokens.find(
2562
2689
  (token) => token.address === decodedMessageSentEvent.args?.token.toString()
2563
2690
  );
2691
+ if (!srcToken) {
2692
+ srcToken = await getCustomTokenData(srcChain, tokenAddress);
2693
+ }
2564
2694
  const dstChain = supportedChains.find(
2565
2695
  (chain) => chain.ccipChainId === decodedMessageSentEvent.args?.destinationChainSelector?.toString()
2566
2696
  );
@@ -2568,19 +2698,20 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
2568
2698
  if (!dstChainId) {
2569
2699
  throw new Error(`Unknown destination chain!`);
2570
2700
  }
2701
+ const tokenAmount = weiToHumanReadable({
2702
+ amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
2703
+ decimals: srcToken?.decimals || 18,
2704
+ precisionFractionalPlaces: 4
2705
+ });
2571
2706
  const transaction = {
2572
2707
  txHash,
2573
- fromChain: srcChain?.displayName,
2574
- fromChainImage: srcChain?.image,
2575
- toChain: dstChain.displayName,
2576
- toChainImage: dstChain.image,
2577
- fromToken: srcToken?.symbol,
2578
- fromTokenImage: srcToken?.image,
2579
- fromAmount: weiToHumanReadable({
2580
- amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
2581
- decimals: srcToken?.decimals || 18,
2582
- precisionFractionalPlaces: 4
2583
- }),
2708
+ srcChain: srcChain.displayName,
2709
+ srcChainImage: srcChain.image,
2710
+ dstChain: dstChain.displayName,
2711
+ dstChainImage: dstChain.image,
2712
+ srcToken: srcToken?.symbol,
2713
+ srcTokenImage: srcToken?.image,
2714
+ srcAmount: tokenAmount === "0" ? "<0.0001" : tokenAmount,
2584
2715
  isDone: false,
2585
2716
  explorer: `${CCIP_EXPLORER}/tx/${txHash}`
2586
2717
  };
@@ -2590,16 +2721,16 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
2590
2721
  if (!xSwapRouterOnDestinationAddress) {
2591
2722
  throw new Error(`Unknown destination XSwapRouter!`);
2592
2723
  }
2593
- const xSwapRouterOnDestination = new import_ethers5.ethers.Contract(
2724
+ const xSwapRouterOnDestination = new import_ethers6.ethers.Contract(
2594
2725
  xSwapRouterOnDestinationAddress,
2595
2726
  MSG_RECEIVED_EVENT_ABI,
2596
- import_ethers5.ethers.getDefaultProvider(
2727
+ import_ethers6.ethers.getDefaultProvider(
2597
2728
  supportedChains.find((chain) => chain.chainId === dstChainId)?.publicRpcUrls[0]
2598
2729
  )
2599
2730
  );
2600
2731
  const msgReceivedEventFilter = {
2601
2732
  address: xSwapRouterOnDestinationAddress,
2602
- topics: [import_ethers5.ethers.utils.id(MSG_RECEIVED_EVENT_SIG), messageId]
2733
+ topics: [import_ethers6.ethers.utils.id(MSG_RECEIVED_EVENT_SIG), messageId]
2603
2734
  };
2604
2735
  const onSuccess = async () => {
2605
2736
  updateTransactionDoneInRenderedTransactions(txHash);
@@ -2610,6 +2741,11 @@ var monitorTransactionStatus = async (txChainId, txHash) => {
2610
2741
  removeTransactionFromRenderedTransactions(txHash);
2611
2742
  renderTxStatusButtons();
2612
2743
  };
2744
+ getTxStatus({ transferId: messageId }).then((response) => {
2745
+ if (response.status === "DONE") {
2746
+ onSuccess();
2747
+ }
2748
+ });
2613
2749
  xSwapRouterOnDestination.once(msgReceivedEventFilter, () => onSuccess());
2614
2750
  };
2615
2751
  var getTxReceipt = async (txChainId, txHash) => {
@@ -2617,7 +2753,7 @@ var getTxReceipt = async (txChainId, txHash) => {
2617
2753
  const chain = (await getChains()).find(
2618
2754
  (chain2) => chain2.chainId === txChainId
2619
2755
  );
2620
- const provider = new import_ethers5.ethers.providers.JsonRpcProvider(
2756
+ const provider = new import_ethers6.ethers.providers.JsonRpcProvider(
2621
2757
  chain?.publicRpcUrls[0]
2622
2758
  );
2623
2759
  return await (0, import_async_retry.default)(async () => {
@@ -2635,7 +2771,8 @@ var getTxReceipt = async (txChainId, txHash) => {
2635
2771
  };
2636
2772
 
2637
2773
  // src/services/integrations/transactions.ts
2638
- var getSwapTx = async ({
2774
+ var openTransactionModal = async ({
2775
+ integratorId,
2639
2776
  dstChain,
2640
2777
  dstToken,
2641
2778
  customContractCalls = [],
@@ -2646,6 +2783,7 @@ var getSwapTx = async ({
2646
2783
  );
2647
2784
  validateSwapTxData(supportedChains, dstChain, dstToken);
2648
2785
  const route = await openTxConfigForm({
2786
+ integratorId,
2649
2787
  dstChainId: dstChain,
2650
2788
  dstTokenAddr: dstToken,
2651
2789
  customContractCalls,
@@ -2661,13 +2799,20 @@ var validateSwapTxData = (supportedChains, dstChain, dstToken) => {
2661
2799
  if (!supportedDstChain) {
2662
2800
  throw new Error(`Provided chain '${dstChain}' is not supported`);
2663
2801
  }
2664
- if (!supportedDstChain.tokens.some(({ address }) => address === dstToken)) {
2665
- throw new Error(`Provided token '${dstToken}' is not supported`);
2802
+ if (!isETHAddressValid(dstToken)) {
2803
+ throw new Error(
2804
+ `Provided token address ${dstToken} on chain ${dstChain} is not correct`
2805
+ );
2666
2806
  }
2667
2807
  };
2668
2808
 
2669
2809
  // src/index.ts
2670
2810
  initDocument();
2811
+ var XPay = {
2812
+ openTransactionModal,
2813
+ renderTxStatus
2814
+ };
2815
+ var src_default = XPay;
2671
2816
  // Annotate the CommonJS export names for ESM import in node:
2672
2817
  0 && (module.exports = {
2673
2818
  ContractName,
@@ -2675,6 +2820,6 @@ initDocument();
2675
2820
  Environment,
2676
2821
  Web3Environment,
2677
2822
  XSwapCallType,
2678
- getSwapTx,
2679
- monitorTransactionStatus
2823
+ openTransactionModal,
2824
+ renderTxStatus
2680
2825
  });