@xswap-link/sdk 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.css +30 -20
- package/dist/index.d.mts +3 -172
- package/dist/index.d.ts +3 -172
- package/dist/index.js +546 -749
- package/dist/index.mjs +565 -725
- package/package.json +5 -3
- package/src/components/TxConfigForm/PoweredBy.tsx +12 -0
- package/src/components/TxConfigForm/index.tsx +3 -27
- package/src/components/{TxHistoryButton → TxStatusButton}/index.tsx +27 -27
- package/src/components/global.css +4 -0
- package/src/components/index.ts +1 -1
- package/src/config/index.ts +1 -0
- package/src/config/init.ts +31 -0
- package/src/constants/index.ts +14 -0
- package/src/index.ts +6 -6
- package/src/services/integrations/index.ts +1 -0
- package/src/services/integrations/monitoring.ts +148 -0
- package/src/services/integrations/transactions.ts +1 -147
- package/tailwind.config.js +1 -0
package/dist/index.mjs
CHANGED
|
@@ -5,82 +5,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
// src/
|
|
9
|
-
import { jsxs } from "react/jsx-runtime";
|
|
10
|
-
var Alert = ({ desc }) => {
|
|
11
|
-
return /* @__PURE__ */ jsxs("div", { className: "border border-solid border-x_alert rounded-3xl text-x_alert_light text-xs py-0.5 px-2", children: [
|
|
12
|
-
"\u26A0\uFE0F ",
|
|
13
|
-
desc
|
|
14
|
-
] });
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// src/components/TxConfigForm/index.tsx
|
|
18
|
-
import { useMemo as useMemo7 } from "react";
|
|
8
|
+
// src/config/init.ts
|
|
19
9
|
import { createRoot } from "react-dom/client";
|
|
20
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
21
|
-
import { WagmiProvider } from "wagmi";
|
|
22
|
-
|
|
23
|
-
// src/config/wagmiConfig.ts
|
|
24
|
-
import { createConfig, http } from "wagmi";
|
|
25
|
-
import { injected, metaMask, walletConnect, safe } from "wagmi/connectors";
|
|
26
|
-
import * as WagmiChains from "viem/chains";
|
|
27
|
-
import { mainnet } from "viem/chains";
|
|
28
|
-
var getWagmiConfig = (supportedChains) => {
|
|
29
|
-
const chains = mapChains(supportedChains);
|
|
30
|
-
const transports = mapTransports(chains);
|
|
31
|
-
return createConfig({
|
|
32
|
-
chains,
|
|
33
|
-
transports,
|
|
34
|
-
connectors: [
|
|
35
|
-
injected(),
|
|
36
|
-
metaMask(),
|
|
37
|
-
safe(),
|
|
38
|
-
walletConnect({ projectId: "c392898b45ac587a280b5eb33e92aeb0" })
|
|
39
|
-
]
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
var mapChains = (supportedChains) => {
|
|
43
|
-
const result = [mainnet];
|
|
44
|
-
result.push(
|
|
45
|
-
...Object.values(WagmiChains).filter(
|
|
46
|
-
(chain) => chain.id !== mainnet.id && supportedChains.some(({ chainId }) => chainId === chain.id.toString())
|
|
47
|
-
)
|
|
48
|
-
);
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
51
|
-
var mapTransports = (chains) => {
|
|
52
|
-
const transports = {};
|
|
53
|
-
chains.forEach((chain) => {
|
|
54
|
-
transports[chain.id] = http();
|
|
55
|
-
});
|
|
56
|
-
return transports;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// src/components/icons/CloseIcon.tsx
|
|
60
|
-
import { jsx } from "react/jsx-runtime";
|
|
61
|
-
var CloseIcon = () => {
|
|
62
|
-
return /* @__PURE__ */ jsx(
|
|
63
|
-
"svg",
|
|
64
|
-
{
|
|
65
|
-
height: "18",
|
|
66
|
-
width: "18",
|
|
67
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
68
|
-
viewBox: "0 0 10.312 8.319",
|
|
69
|
-
children: /* @__PURE__ */ jsx(
|
|
70
|
-
"path",
|
|
71
|
-
{
|
|
72
|
-
fill: "white",
|
|
73
|
-
d: "M6.073 4.078 10.151 0H9.093A1.87 1.87 0 0 0 7.77.548L5.157 3.162 2.543.548A1.87 1.87 0 0 0 1.22 0H.161L4.24 4.078 0 8.318h1.058a1.87 1.87 0 0 0 1.322-.547l2.777-2.777 2.776 2.777a1.869 1.869 0 0 0 1.322.548h1.058Z"
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// src/components/TxConfigForm/Form.tsx
|
|
81
|
-
import { useEffect as useEffect7, useState as useState8 } from "react";
|
|
82
|
-
import { ethers as ethers4 } from "ethers";
|
|
83
|
-
import { useAccount, useSwitchChain } from "wagmi";
|
|
84
10
|
|
|
85
11
|
// xswap.config.ts
|
|
86
12
|
var xSwapConfig = {
|
|
@@ -96,6 +22,73 @@ var xswap_config_default = {
|
|
|
96
22
|
...xSwapConfigLocal
|
|
97
23
|
};
|
|
98
24
|
|
|
25
|
+
// package.json
|
|
26
|
+
var version = "0.2.2";
|
|
27
|
+
|
|
28
|
+
// src/config/init.ts
|
|
29
|
+
var xswapRoot;
|
|
30
|
+
var txStatusRoot;
|
|
31
|
+
var initDocument = () => {
|
|
32
|
+
if (typeof document === "undefined") {
|
|
33
|
+
throw new Error("Can't render XPay components from server side.");
|
|
34
|
+
}
|
|
35
|
+
fetch(`${xswap_config_default.apiUrl}/sdk/css?data={"version": "${version}"}`).then(
|
|
36
|
+
async (css) => {
|
|
37
|
+
const style = document.createElement("style");
|
|
38
|
+
style.textContent = await css.text();
|
|
39
|
+
document.body.appendChild(style);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
const xswapElement = document.createElement("div");
|
|
43
|
+
xswapElement.setAttribute("id", "xswap-modal");
|
|
44
|
+
document.body.appendChild(xswapElement);
|
|
45
|
+
xswapRoot = createRoot(xswapElement);
|
|
46
|
+
const txStatusElement = document.createElement("div");
|
|
47
|
+
txStatusElement.setAttribute("id", "xswap-tx-status");
|
|
48
|
+
txStatusElement.setAttribute("class", "xswap-tx-status");
|
|
49
|
+
document.body.appendChild(txStatusElement);
|
|
50
|
+
txStatusRoot = createRoot(txStatusElement);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/models/Addresses.ts
|
|
54
|
+
var ContractName = /* @__PURE__ */ ((ContractName2) => {
|
|
55
|
+
ContractName2["BatchQuery"] = "BatchQuery";
|
|
56
|
+
ContractName2["FeeCollector"] = "FeeCollector";
|
|
57
|
+
ContractName2["XSwapRouter"] = "XSwapRouter";
|
|
58
|
+
return ContractName2;
|
|
59
|
+
})(ContractName || {});
|
|
60
|
+
|
|
61
|
+
// src/models/Ecosystem.ts
|
|
62
|
+
var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
|
|
63
|
+
Ecosystem2["EVM"] = "evm";
|
|
64
|
+
return Ecosystem2;
|
|
65
|
+
})(Ecosystem || {});
|
|
66
|
+
|
|
67
|
+
// src/models/Environment.ts
|
|
68
|
+
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
69
|
+
Environment2["PROD"] = "production";
|
|
70
|
+
Environment2["DEV"] = "develop";
|
|
71
|
+
Environment2["LOCAL"] = "local";
|
|
72
|
+
return Environment2;
|
|
73
|
+
})(Environment || {});
|
|
74
|
+
|
|
75
|
+
// src/models/Web3Environment.ts
|
|
76
|
+
var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
|
|
77
|
+
Web3Environment2["DEVNET"] = "devnet";
|
|
78
|
+
Web3Environment2["TESTNET"] = "testnet";
|
|
79
|
+
Web3Environment2["MAINNET"] = "mainnet";
|
|
80
|
+
return Web3Environment2;
|
|
81
|
+
})(Web3Environment || {});
|
|
82
|
+
|
|
83
|
+
// src/models/XSwapCallType.ts
|
|
84
|
+
var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
|
|
85
|
+
XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
|
|
86
|
+
XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
|
|
87
|
+
XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
|
|
88
|
+
XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
|
|
89
|
+
return XSwapCallType2;
|
|
90
|
+
})(XSwapCallType || {});
|
|
91
|
+
|
|
99
92
|
// src/services/api.ts
|
|
100
93
|
async function _sendRequest(urlPath, options) {
|
|
101
94
|
const response = await fetch(`${xswap_config_default.apiUrl}${urlPath}`, {
|
|
@@ -124,26 +117,6 @@ async function getChains(ecosystem) {
|
|
|
124
117
|
return _sendRequest(`/chains?data=${JSON.stringify({ ecosystem })}
|
|
125
118
|
`);
|
|
126
119
|
}
|
|
127
|
-
async function getChainData(chainId, ecosystem) {
|
|
128
|
-
return _sendRequest(
|
|
129
|
-
`/chains?data=${JSON.stringify({
|
|
130
|
-
chainId,
|
|
131
|
-
ecosystem
|
|
132
|
-
})}`
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
async function getTokens(chainId, address, ecosystem) {
|
|
136
|
-
return _sendRequest(
|
|
137
|
-
`/tokens?data=${JSON.stringify({
|
|
138
|
-
chainId,
|
|
139
|
-
address,
|
|
140
|
-
ecosystem
|
|
141
|
-
})}`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
async function getBridgeTokens() {
|
|
145
|
-
return _sendRequest(`/bridgeTokens`);
|
|
146
|
-
}
|
|
147
120
|
async function getHistory(payload) {
|
|
148
121
|
return await _sendRequest(
|
|
149
122
|
`/history?${new URLSearchParams({
|
|
@@ -162,45 +135,6 @@ async function getPrices(payload) {
|
|
|
162
135
|
// src/services/integrations/customCalls/staking.ts
|
|
163
136
|
import { ethers as ethers2 } from "ethers";
|
|
164
137
|
|
|
165
|
-
// src/models/Addresses.ts
|
|
166
|
-
var ContractName = /* @__PURE__ */ ((ContractName2) => {
|
|
167
|
-
ContractName2["BatchQuery"] = "BatchQuery";
|
|
168
|
-
ContractName2["FeeCollector"] = "FeeCollector";
|
|
169
|
-
ContractName2["XSwapRouter"] = "XSwapRouter";
|
|
170
|
-
return ContractName2;
|
|
171
|
-
})(ContractName || {});
|
|
172
|
-
|
|
173
|
-
// src/models/Ecosystem.ts
|
|
174
|
-
var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
|
|
175
|
-
Ecosystem2["EVM"] = "evm";
|
|
176
|
-
return Ecosystem2;
|
|
177
|
-
})(Ecosystem || {});
|
|
178
|
-
|
|
179
|
-
// src/models/Environment.ts
|
|
180
|
-
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
181
|
-
Environment2["PROD"] = "production";
|
|
182
|
-
Environment2["DEV"] = "develop";
|
|
183
|
-
Environment2["LOCAL"] = "local";
|
|
184
|
-
return Environment2;
|
|
185
|
-
})(Environment || {});
|
|
186
|
-
|
|
187
|
-
// src/models/Web3Environment.ts
|
|
188
|
-
var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
|
|
189
|
-
Web3Environment2["DEVNET"] = "devnet";
|
|
190
|
-
Web3Environment2["TESTNET"] = "testnet";
|
|
191
|
-
Web3Environment2["MAINNET"] = "mainnet";
|
|
192
|
-
return Web3Environment2;
|
|
193
|
-
})(Web3Environment || {});
|
|
194
|
-
|
|
195
|
-
// src/models/XSwapCallType.ts
|
|
196
|
-
var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
|
|
197
|
-
XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
|
|
198
|
-
XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
|
|
199
|
-
XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
|
|
200
|
-
XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
|
|
201
|
-
return XSwapCallType2;
|
|
202
|
-
})(XSwapCallType || {});
|
|
203
|
-
|
|
204
138
|
// src/utils/contracts.ts
|
|
205
139
|
import { ethers } from "ethers";
|
|
206
140
|
|
|
@@ -227,16 +161,6 @@ var weiToHumanReadable = ({
|
|
|
227
161
|
}
|
|
228
162
|
return res;
|
|
229
163
|
};
|
|
230
|
-
var generateRandomBigNumber = (length) => {
|
|
231
|
-
return BigNumber.from(utils.randomBytes(length));
|
|
232
|
-
};
|
|
233
|
-
var generateUniqueRandomBigNumber = (length, existingValues) => {
|
|
234
|
-
let result;
|
|
235
|
-
while (result === void 0 || existingValues.includes(result)) {
|
|
236
|
-
result = generateRandomBigNumber(length);
|
|
237
|
-
}
|
|
238
|
-
return result;
|
|
239
|
-
};
|
|
240
164
|
|
|
241
165
|
// src/contracts/abi/BatchQuery.json
|
|
242
166
|
var BatchQuery_default = [
|
|
@@ -571,20 +495,18 @@ var ROUTE_TIMEOUT_MS = 5e3;
|
|
|
571
495
|
var MINIMUM_DISPLAYED_TOKEN_AMOUNT = 1e-4;
|
|
572
496
|
var DEFAULT_SOURCE_CHAIN_ID = "1";
|
|
573
497
|
var CCIP_EXPLORER = "https://ccip.chain.link/";
|
|
498
|
+
var TX_RECEIPT_STATUS_LIFETIME = 1e4;
|
|
499
|
+
var MSG_SENT_EVENT_SIG = "MessageSent(bytes32,uint64,address,bytes,address,uint256,uint256,address,uint256)";
|
|
500
|
+
var MSG_SENT_EVENT_ABI = [
|
|
501
|
+
"event MessageSent(bytes32 indexed messageId, uint64 indexed destinationChainSelector, address indexed sender, bytes data, address token, uint256 tokenAmount, uint256 valueForInstantCcipRecieve, address transferedToken, uint256 transferedTokenAmount)"
|
|
502
|
+
];
|
|
503
|
+
var MSG_RECEIVED_EVENT_SIG = "MessageReceived(bytes32,uint64,address,bytes,address,uint256)";
|
|
504
|
+
var MSG_RECEIVED_EVENT_ABI = [
|
|
505
|
+
"event MessageReceived(bytes32 indexed messageId, uint64 indexed sourceChainSelector, address indexed sender, bytes data, address token, uint256 tokenAmount)"
|
|
506
|
+
];
|
|
574
507
|
|
|
575
508
|
// src/utils/contracts.ts
|
|
576
509
|
var IERC20 = new ethers.utils.Interface(ERC20Abi);
|
|
577
|
-
var getBalanceOf = async (wallet, token, rpcUrl) => {
|
|
578
|
-
const provider = ethers.getDefaultProvider(rpcUrl);
|
|
579
|
-
if (token === ethers.constants.AddressZero) {
|
|
580
|
-
return ethers.utils.formatEther(await provider.getBalance(wallet));
|
|
581
|
-
}
|
|
582
|
-
const contract = new ethers.Contract(token, ERC20Abi, provider);
|
|
583
|
-
return ethers.utils.formatUnits(
|
|
584
|
-
await contract.balanceOf(wallet),
|
|
585
|
-
await contract.decimals()
|
|
586
|
-
);
|
|
587
|
-
};
|
|
588
510
|
var getBalances = async (chain, wallet) => {
|
|
589
511
|
return {
|
|
590
512
|
...await getNativeBalance(chain, wallet),
|
|
@@ -635,35 +557,6 @@ var getErc20Balances = async (chain, wallet) => {
|
|
|
635
557
|
});
|
|
636
558
|
return balances;
|
|
637
559
|
};
|
|
638
|
-
var generateApproveTxData = (tokenAddress, spender, amount) => {
|
|
639
|
-
return tokenAddress !== ethers.constants.AddressZero ? {
|
|
640
|
-
to: tokenAddress,
|
|
641
|
-
value: safeBigNumberFrom("0"),
|
|
642
|
-
data: IERC20.encodeFunctionData("approve", [spender, amount])
|
|
643
|
-
} : void 0;
|
|
644
|
-
};
|
|
645
|
-
var findPlaceholderIndex = (abi, funName, funParams, placeholderValue) => {
|
|
646
|
-
if (funParams.flat(Infinity).filter((param) => param === placeholderValue).length !== 1) {
|
|
647
|
-
throw new Error("Random placeholder value must be provided and unique.");
|
|
648
|
-
}
|
|
649
|
-
const iface = new ethers.utils.Interface(abi);
|
|
650
|
-
const functionFragment = iface.getFunction(funName);
|
|
651
|
-
if (!functionFragment) {
|
|
652
|
-
throw new Error(`Can't find function "${funName}" in provided ABI.`);
|
|
653
|
-
}
|
|
654
|
-
const encodedFunData = iface.encodeFunctionData(functionFragment, funParams);
|
|
655
|
-
const paramData = encodedFunData.slice(10);
|
|
656
|
-
const chunks = [];
|
|
657
|
-
for (let i = 0; i < paramData.length; i += 64) {
|
|
658
|
-
chunks.push(paramData.slice(i, i + 64));
|
|
659
|
-
}
|
|
660
|
-
const searchValue = placeholderValue.toHexString().slice(2).padStart(64, "0");
|
|
661
|
-
const result = chunks.findIndex((chunk) => chunk === searchValue);
|
|
662
|
-
if (result === -1) {
|
|
663
|
-
throw new Error("Randomized parameter not found in the encoded data.");
|
|
664
|
-
}
|
|
665
|
-
return result;
|
|
666
|
-
};
|
|
667
560
|
|
|
668
561
|
// src/utils/strings.ts
|
|
669
562
|
var shortAddress = (address) => {
|
|
@@ -675,266 +568,103 @@ var shortAddress = (address) => {
|
|
|
675
568
|
|
|
676
569
|
// src/utils/index.ts
|
|
677
570
|
import { format } from "date-fns";
|
|
678
|
-
var replaceNull = (values, newValue) => {
|
|
679
|
-
const modifiedValues = [...values];
|
|
680
|
-
for (let i = 0; i < modifiedValues.length; i++) {
|
|
681
|
-
if (Array.isArray(modifiedValues[i])) {
|
|
682
|
-
modifiedValues[i] = replaceNull(modifiedValues[i], newValue);
|
|
683
|
-
} else {
|
|
684
|
-
if (modifiedValues[i] === null) {
|
|
685
|
-
modifiedValues[i] = newValue;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
return modifiedValues;
|
|
690
|
-
};
|
|
691
571
|
var deepMergeObjects = (obj1, obj2) => {
|
|
692
572
|
for (const key in obj2) {
|
|
693
573
|
if (obj2.hasOwnProperty(key)) {
|
|
694
574
|
if (obj1.hasOwnProperty(key) && typeof obj1[key] === "object" && typeof obj2[key] === "object") {
|
|
695
575
|
deepMergeObjects(obj1[key], obj2[key]);
|
|
696
576
|
} else {
|
|
697
|
-
obj1[key] = obj2[key];
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
return { ...obj1 };
|
|
702
|
-
};
|
|
703
|
-
var chunkArray = (array, chunkSize) => {
|
|
704
|
-
const result = [];
|
|
705
|
-
for (let i = 0; i < array.length; i += chunkSize) {
|
|
706
|
-
result.push(array.slice(i, i + chunkSize));
|
|
707
|
-
}
|
|
708
|
-
return result;
|
|
709
|
-
};
|
|
710
|
-
var getDate = (blockTimestamp) => {
|
|
711
|
-
const date = new Date(blockTimestamp * 1e3);
|
|
712
|
-
return format(date, "d MMM yyyy HH:mm:ss");
|
|
713
|
-
};
|
|
714
|
-
|
|
715
|
-
// src/services/integrations/customCalls/staking.ts
|
|
716
|
-
var generateStakingCalls = ({
|
|
717
|
-
token,
|
|
718
|
-
staking,
|
|
719
|
-
stakingAbi,
|
|
720
|
-
stakingFunName,
|
|
721
|
-
stakingFunParams
|
|
722
|
-
}) => {
|
|
723
|
-
const flatStakingFunParams = stakingFunParams.flat(Infinity);
|
|
724
|
-
if (flatStakingFunParams.filter((param) => param === null).length !== 1) {
|
|
725
|
-
throw new Error(
|
|
726
|
-
"Exactly 1 'null' value should be provided in 'funParams' in order to override token balance"
|
|
727
|
-
);
|
|
728
|
-
}
|
|
729
|
-
const randomBigNumber = generateUniqueRandomBigNumber(
|
|
730
|
-
32,
|
|
731
|
-
flatStakingFunParams
|
|
732
|
-
);
|
|
733
|
-
const modifiedStakingFunParams = replaceNull(
|
|
734
|
-
stakingFunParams,
|
|
735
|
-
randomBigNumber
|
|
736
|
-
);
|
|
737
|
-
const approveFunParams = [staking, randomBigNumber];
|
|
738
|
-
const stakingApproveCall = {
|
|
739
|
-
callType: 1 /* FULL_TOKEN_BALANCE */,
|
|
740
|
-
target: token,
|
|
741
|
-
callData: IERC20.encodeFunctionData("approve", approveFunParams),
|
|
742
|
-
payload: ethers2.utils.defaultAbiCoder.encode(
|
|
743
|
-
["address", "uint256"],
|
|
744
|
-
[
|
|
745
|
-
token,
|
|
746
|
-
findPlaceholderIndex(
|
|
747
|
-
JSON.stringify(ERC20Abi),
|
|
748
|
-
"approve",
|
|
749
|
-
approveFunParams,
|
|
750
|
-
randomBigNumber
|
|
751
|
-
)
|
|
752
|
-
]
|
|
753
|
-
),
|
|
754
|
-
value: "0"
|
|
755
|
-
};
|
|
756
|
-
const stakingCall = {
|
|
757
|
-
callType: 1 /* FULL_TOKEN_BALANCE */,
|
|
758
|
-
target: staking,
|
|
759
|
-
callData: new ethers2.utils.Interface(stakingAbi).encodeFunctionData(
|
|
760
|
-
stakingFunName,
|
|
761
|
-
modifiedStakingFunParams
|
|
762
|
-
),
|
|
763
|
-
payload: ethers2.utils.defaultAbiCoder.encode(
|
|
764
|
-
["address", "uint256"],
|
|
765
|
-
[
|
|
766
|
-
token,
|
|
767
|
-
findPlaceholderIndex(
|
|
768
|
-
stakingAbi,
|
|
769
|
-
stakingFunName,
|
|
770
|
-
modifiedStakingFunParams,
|
|
771
|
-
randomBigNumber
|
|
772
|
-
)
|
|
773
|
-
]
|
|
774
|
-
),
|
|
775
|
-
value: "0"
|
|
776
|
-
};
|
|
777
|
-
return [stakingApproveCall, stakingCall];
|
|
778
|
-
};
|
|
779
|
-
|
|
780
|
-
// src/services/integrations/transactions.ts
|
|
781
|
-
import { ethers as ethers3 } from "ethers";
|
|
782
|
-
var getSwapTx = async ({
|
|
783
|
-
dstChain,
|
|
784
|
-
dstToken,
|
|
785
|
-
customContractCalls = [],
|
|
786
|
-
desc
|
|
787
|
-
}) => {
|
|
788
|
-
const supportedChains = (await getChains()).filter(
|
|
789
|
-
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
790
|
-
);
|
|
791
|
-
validateSwapTxData(supportedChains, dstChain, dstToken);
|
|
792
|
-
const route = await openTxConfigForm({
|
|
793
|
-
dstChainId: dstChain,
|
|
794
|
-
dstTokenAddr: dstToken,
|
|
795
|
-
customContractCalls,
|
|
796
|
-
desc,
|
|
797
|
-
supportedChains
|
|
798
|
-
});
|
|
799
|
-
return route.transactions;
|
|
800
|
-
};
|
|
801
|
-
var validateSwapTxData = (supportedChains, dstChain, dstToken) => {
|
|
802
|
-
const supportedDstChain = supportedChains.find(
|
|
803
|
-
({ chainId }) => chainId === dstChain
|
|
804
|
-
);
|
|
805
|
-
if (!supportedDstChain) {
|
|
806
|
-
throw new Error(`Provided chain '${dstChain}' is not supported`);
|
|
807
|
-
}
|
|
808
|
-
if (!supportedDstChain.tokens.some(({ address }) => address === dstToken)) {
|
|
809
|
-
throw new Error(`Provided token '${dstToken}' is not supported`);
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
|
-
var monitorTransactionStatus = async (srcChainId, txHash) => {
|
|
813
|
-
const txReceipt = await getTxReceipt(srcChainId, txHash);
|
|
814
|
-
if (!txReceipt) {
|
|
815
|
-
throw new Error(
|
|
816
|
-
`No transaction found for chain ${srcChainId} tx ${txHash}`
|
|
817
|
-
);
|
|
818
|
-
}
|
|
819
|
-
const supportedChains = (await getChains()).filter(
|
|
820
|
-
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
821
|
-
);
|
|
822
|
-
const messageSentEventSignature = "MessageSent(bytes32,uint64,address,bytes,address,uint256,uint256,address,uint256)";
|
|
823
|
-
const messageSentEventAbi = [
|
|
824
|
-
"event MessageSent(bytes32 indexed messageId, uint64 indexed destinationChainSelector, address indexed sender, bytes data, address token, uint256 tokenAmount, uint256 valueForInstantCcipRecieve, address transferedToken, uint256 transferedTokenAmount)"
|
|
825
|
-
];
|
|
826
|
-
const messageReceivedEventSignature = "MessageReceived(bytes32,uint64,address,bytes,address,uint256)";
|
|
827
|
-
const messageReceivedEventAbi = [
|
|
828
|
-
"event MessageReceived(bytes32 indexed messageId, uint64 indexed sourceChainSelector, address indexed sender, bytes data, address token, uint256 tokenAmount)"
|
|
829
|
-
];
|
|
830
|
-
const messageSentEvent = txReceipt.logs?.find((log) => {
|
|
831
|
-
return log.topics[0] === ethers3.utils.id(messageSentEventSignature);
|
|
832
|
-
});
|
|
833
|
-
if (!messageSentEvent) {
|
|
834
|
-
throw new Error(
|
|
835
|
-
`No transaction event found for chain ${srcChainId} tx ${txHash}`
|
|
836
|
-
);
|
|
837
|
-
}
|
|
838
|
-
const messageId = messageSentEvent?.topics[1];
|
|
839
|
-
const iface = new ethers3.utils.Interface(messageSentEventAbi);
|
|
840
|
-
const decodedMessageSentEvent = iface.parseLog(messageSentEvent);
|
|
841
|
-
if (!decodedMessageSentEvent) {
|
|
842
|
-
throw new Error(
|
|
843
|
-
`No transaction event arguments found for chain ${srcChainId} tx ${txHash}`
|
|
844
|
-
);
|
|
845
|
-
}
|
|
846
|
-
const srcChain = supportedChains.find(
|
|
847
|
-
(chain) => chain.chainId === srcChainId.toString()
|
|
848
|
-
);
|
|
849
|
-
const srcToken = srcChain?.tokens.find(
|
|
850
|
-
(token) => token.address === decodedMessageSentEvent.args?.token.toString()
|
|
851
|
-
);
|
|
852
|
-
const targetChain = supportedChains.find(
|
|
853
|
-
(chain) => chain.ccipChainId === decodedMessageSentEvent.args?.destinationChainSelector?.toString()
|
|
854
|
-
);
|
|
855
|
-
const toChainId = targetChain?.chainId;
|
|
856
|
-
if (!toChainId) {
|
|
857
|
-
throw new Error(`Unknown destination chain!`);
|
|
858
|
-
}
|
|
859
|
-
const transaction = {
|
|
860
|
-
txHash,
|
|
861
|
-
fromChain: srcChain?.displayName,
|
|
862
|
-
fromChainImage: srcChain?.image,
|
|
863
|
-
toChain: targetChain.displayName,
|
|
864
|
-
toChainImage: targetChain.image,
|
|
865
|
-
fromToken: srcToken?.symbol,
|
|
866
|
-
fromTokenImage: srcToken?.image,
|
|
867
|
-
fromAmount: weiToHumanReadable({
|
|
868
|
-
amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
|
|
869
|
-
decimals: srcToken?.decimals || 18,
|
|
870
|
-
precisionFractionalPlaces: 4
|
|
871
|
-
}),
|
|
872
|
-
isDone: false,
|
|
873
|
-
explorer: `${CCIP_EXPLORER}/tx/${txHash}`
|
|
874
|
-
};
|
|
875
|
-
addTransactionToRenderedTransactions(transaction);
|
|
876
|
-
renderTxHistoryButtons();
|
|
877
|
-
const xSwapRouterOnDestinationAddress = ADDRESSES[toChainId]?.XSwapRouter;
|
|
878
|
-
if (!xSwapRouterOnDestinationAddress) {
|
|
879
|
-
throw new Error(`Unknown destination XSwapRouter!`);
|
|
880
|
-
}
|
|
881
|
-
const xSwapRouterOnDestination = new ethers3.Contract(
|
|
882
|
-
xSwapRouterOnDestinationAddress,
|
|
883
|
-
messageReceivedEventAbi,
|
|
884
|
-
ethers3.getDefaultProvider(
|
|
885
|
-
supportedChains.find((chain) => chain.chainId === toChainId)?.publicRpcUrls[0]
|
|
886
|
-
)
|
|
887
|
-
);
|
|
888
|
-
const eventFilter = {
|
|
889
|
-
address: xSwapRouterOnDestinationAddress,
|
|
890
|
-
topics: [ethers3.utils.id(messageReceivedEventSignature), messageId]
|
|
891
|
-
};
|
|
892
|
-
const onSuccess = async () => {
|
|
893
|
-
updateTransactionDoneInRenderedTransactions(txHash);
|
|
894
|
-
renderTxHistoryButtons();
|
|
895
|
-
await new Promise((resolve) => setTimeout(() => resolve(true), 5e3));
|
|
896
|
-
removeTransactionFromRenderedTransactions(txHash);
|
|
897
|
-
renderTxHistoryButtons();
|
|
898
|
-
};
|
|
899
|
-
xSwapRouterOnDestination.once(eventFilter, () => onSuccess());
|
|
577
|
+
obj1[key] = obj2[key];
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return { ...obj1 };
|
|
900
582
|
};
|
|
901
|
-
var
|
|
902
|
-
const
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
chain?.publicRpcUrls[0]
|
|
906
|
-
);
|
|
907
|
-
try {
|
|
908
|
-
return await provider.getTransactionReceipt(txHash);
|
|
909
|
-
} catch (error) {
|
|
910
|
-
console.error("Error fetching transaction receipt:", error);
|
|
911
|
-
return null;
|
|
583
|
+
var chunkArray = (array, chunkSize) => {
|
|
584
|
+
const result = [];
|
|
585
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
586
|
+
result.push(array.slice(i, i + chunkSize));
|
|
912
587
|
}
|
|
588
|
+
return result;
|
|
589
|
+
};
|
|
590
|
+
var getDate = (blockTimestamp) => {
|
|
591
|
+
const date = new Date(blockTimestamp * 1e3);
|
|
592
|
+
return format(date, "d MMM yyyy HH:mm:ss");
|
|
913
593
|
};
|
|
914
594
|
|
|
915
|
-
// src/
|
|
916
|
-
import {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
926
|
-
};
|
|
927
|
-
}, [value, delay]);
|
|
928
|
-
const [debouncedValue, setValue] = useState(value);
|
|
929
|
-
return debouncedValue;
|
|
595
|
+
// src/services/integrations/monitoring.ts
|
|
596
|
+
import { ethers as ethers4 } from "ethers";
|
|
597
|
+
|
|
598
|
+
// src/components/Alert/index.tsx
|
|
599
|
+
import { jsxs } from "react/jsx-runtime";
|
|
600
|
+
var Alert = ({ desc }) => {
|
|
601
|
+
return /* @__PURE__ */ jsxs("div", { className: "border border-solid border-x_alert rounded-3xl text-x_alert_light text-xs py-0.5 px-2", children: [
|
|
602
|
+
"\u26A0\uFE0F ",
|
|
603
|
+
desc
|
|
604
|
+
] });
|
|
930
605
|
};
|
|
931
606
|
|
|
932
|
-
// src/components/TxConfigForm/
|
|
933
|
-
import {
|
|
934
|
-
import
|
|
607
|
+
// src/components/TxConfigForm/index.tsx
|
|
608
|
+
import { useMemo as useMemo7 } from "react";
|
|
609
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
610
|
+
import { WagmiProvider } from "wagmi";
|
|
935
611
|
|
|
936
|
-
// src/
|
|
937
|
-
import {
|
|
612
|
+
// src/config/wagmiConfig.ts
|
|
613
|
+
import { createConfig, http } from "wagmi";
|
|
614
|
+
import { injected, metaMask, walletConnect, safe } from "wagmi/connectors";
|
|
615
|
+
import * as WagmiChains from "viem/chains";
|
|
616
|
+
import { mainnet } from "viem/chains";
|
|
617
|
+
var getWagmiConfig = (supportedChains) => {
|
|
618
|
+
const chains = mapChains(supportedChains);
|
|
619
|
+
const transports = mapTransports(chains);
|
|
620
|
+
return createConfig({
|
|
621
|
+
chains,
|
|
622
|
+
transports,
|
|
623
|
+
connectors: [
|
|
624
|
+
injected(),
|
|
625
|
+
metaMask(),
|
|
626
|
+
safe(),
|
|
627
|
+
walletConnect({ projectId: "c392898b45ac587a280b5eb33e92aeb0" })
|
|
628
|
+
]
|
|
629
|
+
});
|
|
630
|
+
};
|
|
631
|
+
var mapChains = (supportedChains) => {
|
|
632
|
+
const result = [mainnet];
|
|
633
|
+
result.push(
|
|
634
|
+
...Object.values(WagmiChains).filter(
|
|
635
|
+
(chain) => chain.id !== mainnet.id && supportedChains.some(({ chainId }) => chainId === chain.id.toString())
|
|
636
|
+
)
|
|
637
|
+
);
|
|
638
|
+
return result;
|
|
639
|
+
};
|
|
640
|
+
var mapTransports = (chains) => {
|
|
641
|
+
const transports = {};
|
|
642
|
+
chains.forEach((chain) => {
|
|
643
|
+
transports[chain.id] = http();
|
|
644
|
+
});
|
|
645
|
+
return transports;
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
// src/components/icons/CloseIcon.tsx
|
|
649
|
+
import { jsx } from "react/jsx-runtime";
|
|
650
|
+
var CloseIcon = () => {
|
|
651
|
+
return /* @__PURE__ */ jsx(
|
|
652
|
+
"svg",
|
|
653
|
+
{
|
|
654
|
+
height: "18",
|
|
655
|
+
width: "18",
|
|
656
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
657
|
+
viewBox: "0 0 10.312 8.319",
|
|
658
|
+
children: /* @__PURE__ */ jsx(
|
|
659
|
+
"path",
|
|
660
|
+
{
|
|
661
|
+
fill: "white",
|
|
662
|
+
d: "M6.073 4.078 10.151 0H9.093A1.87 1.87 0 0 0 7.77.548L5.157 3.162 2.543.548A1.87 1.87 0 0 0 1.22 0H.161L4.24 4.078 0 8.318h1.058a1.87 1.87 0 0 0 1.322-.547l2.777-2.777 2.776 2.777a1.869 1.869 0 0 0 1.322.548h1.058Z"
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
};
|
|
938
668
|
|
|
939
669
|
// src/components/icons/ArrowRightIcon.tsx
|
|
940
670
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -1352,8 +1082,46 @@ var XSwapLogo = () => {
|
|
|
1352
1082
|
);
|
|
1353
1083
|
};
|
|
1354
1084
|
|
|
1085
|
+
// src/components/TxConfigForm/PoweredBy.tsx
|
|
1086
|
+
import { jsx as jsx23, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1087
|
+
var PoweredBy = () => {
|
|
1088
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex justify-center items-center gap-2 my-3", children: [
|
|
1089
|
+
/* @__PURE__ */ jsx23("span", { className: "text-x_grey", children: "Powered by" }),
|
|
1090
|
+
/* @__PURE__ */ jsx23(XSwapBadgeIcon, {}),
|
|
1091
|
+
/* @__PURE__ */ jsx23("span", { children: "\u2715" }),
|
|
1092
|
+
/* @__PURE__ */ jsx23(ChainlinkCCIPIcon, {})
|
|
1093
|
+
] });
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
// src/components/TxConfigForm/Form.tsx
|
|
1097
|
+
import { useEffect as useEffect7, useState as useState8 } from "react";
|
|
1098
|
+
import { ethers as ethers3 } from "ethers";
|
|
1099
|
+
import { useAccount, useSwitchChain } from "wagmi";
|
|
1100
|
+
|
|
1101
|
+
// src/hooks/useDebounce.tsx
|
|
1102
|
+
import { useEffect, useRef, useState } from "react";
|
|
1103
|
+
var useDebounce = (value, delay) => {
|
|
1104
|
+
const timeoutRef = useRef(null);
|
|
1105
|
+
useEffect(() => {
|
|
1106
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1107
|
+
timeoutRef.current = setTimeout(() => {
|
|
1108
|
+
setValue(value);
|
|
1109
|
+
}, delay);
|
|
1110
|
+
return () => {
|
|
1111
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1112
|
+
};
|
|
1113
|
+
}, [value, delay]);
|
|
1114
|
+
const [debouncedValue, setValue] = useState(value);
|
|
1115
|
+
return debouncedValue;
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
// src/components/TxConfigForm/History.tsx
|
|
1119
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState2 } from "react";
|
|
1120
|
+
import BigNumberJS2 from "bignumber.js";
|
|
1121
|
+
|
|
1355
1122
|
// src/components/TxConfigForm/HistoryCard.tsx
|
|
1356
|
-
import {
|
|
1123
|
+
import { useCallback, useMemo } from "react";
|
|
1124
|
+
import { Fragment, jsx as jsx24, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1357
1125
|
var HistoryCard = ({ transaction, supportedChains }) => {
|
|
1358
1126
|
const date = getDate(transaction.timestamp);
|
|
1359
1127
|
const supportedTokens = useMemo(() => {
|
|
@@ -1399,14 +1167,14 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1399
1167
|
const targetChainData = supportedChains.find(
|
|
1400
1168
|
(chain) => chain.chainId === transaction.targetChainId
|
|
1401
1169
|
);
|
|
1402
|
-
return /* @__PURE__ */
|
|
1403
|
-
/* @__PURE__ */
|
|
1404
|
-
/* @__PURE__ */
|
|
1405
|
-
/* @__PURE__ */
|
|
1406
|
-
transaction.status === "IN_PROGRESS" && /* @__PURE__ */
|
|
1407
|
-
transaction.status === "DONE" && /* @__PURE__ */
|
|
1408
|
-
transaction.status === "REVERTED" && /* @__PURE__ */
|
|
1409
|
-
/* @__PURE__ */
|
|
1170
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col globalBorder rounded-xl bg-[rgb(15,15,15)] text-white text-xs sm:text-sm p-4 gap-3 mb-2", children: [
|
|
1171
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex w-full items-center justify-between", children: [
|
|
1172
|
+
/* @__PURE__ */ jsx24("div", { className: "text-sm sm:text-base", children: date }),
|
|
1173
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center", children: [
|
|
1174
|
+
transaction.status === "IN_PROGRESS" && /* @__PURE__ */ jsx24("div", { className: "flex items-center", children: /* @__PURE__ */ jsx24("div", { className: "text-[rgb(250,200,100)]", children: "In progress" }) }),
|
|
1175
|
+
transaction.status === "DONE" && /* @__PURE__ */ jsx24("div", { className: "flex items-center", children: /* @__PURE__ */ jsx24("div", { className: "text-[rgb(100,200,100)]", children: "Done" }) }),
|
|
1176
|
+
transaction.status === "REVERTED" && /* @__PURE__ */ jsx24("div", { className: "flex items-center", children: /* @__PURE__ */ jsx24("div", { className: "text-[rgb(255,100,100)]", children: "Reverted" }) }),
|
|
1177
|
+
/* @__PURE__ */ jsx24(
|
|
1410
1178
|
"a",
|
|
1411
1179
|
{
|
|
1412
1180
|
href: `${supportedChains.find(
|
|
@@ -1416,15 +1184,15 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1416
1184
|
rel: "noreferrer",
|
|
1417
1185
|
className: "ml-2 no-underline",
|
|
1418
1186
|
"aria-label": "Show the transaction in the chain explorer",
|
|
1419
|
-
children: /* @__PURE__ */
|
|
1187
|
+
children: /* @__PURE__ */ jsx24("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx24(ArrowUpRightIcon, {}) })
|
|
1420
1188
|
}
|
|
1421
1189
|
)
|
|
1422
1190
|
] })
|
|
1423
1191
|
] }),
|
|
1424
|
-
/* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
/* @__PURE__ */
|
|
1427
|
-
/* @__PURE__ */
|
|
1192
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex justify-between flex-wrap gap-2", children: [
|
|
1193
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center", children: [
|
|
1194
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center", children: [
|
|
1195
|
+
/* @__PURE__ */ jsx24(
|
|
1428
1196
|
"img",
|
|
1429
1197
|
{
|
|
1430
1198
|
src: sourceChainData?.image,
|
|
@@ -1432,11 +1200,11 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1432
1200
|
className: "w-5 h-5 mr-1"
|
|
1433
1201
|
}
|
|
1434
1202
|
),
|
|
1435
|
-
/* @__PURE__ */
|
|
1203
|
+
/* @__PURE__ */ jsx24("div", { children: sourceChainData?.displayName })
|
|
1436
1204
|
] }),
|
|
1437
|
-
/* @__PURE__ */
|
|
1438
|
-
/* @__PURE__ */
|
|
1439
|
-
/* @__PURE__ */
|
|
1205
|
+
/* @__PURE__ */ jsx24("div", { className: "w-3.5 h-3.5 my-0 mx-1.5", children: /* @__PURE__ */ jsx24(ArrowRightIcon, {}) }),
|
|
1206
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center", children: [
|
|
1207
|
+
/* @__PURE__ */ jsx24(
|
|
1440
1208
|
"img",
|
|
1441
1209
|
{
|
|
1442
1210
|
src: targetChainData?.image,
|
|
@@ -1444,35 +1212,35 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1444
1212
|
className: "w-5 h-5 mr-1"
|
|
1445
1213
|
}
|
|
1446
1214
|
),
|
|
1447
|
-
/* @__PURE__ */
|
|
1215
|
+
/* @__PURE__ */ jsx24("div", { children: targetChainData?.displayName })
|
|
1448
1216
|
] })
|
|
1449
1217
|
] }),
|
|
1450
|
-
/* @__PURE__ */
|
|
1451
|
-
/* @__PURE__ */
|
|
1218
|
+
/* @__PURE__ */ jsx24("div", { className: "flex items-center mb-2 last:mb-0", children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center flex-wrap", children: [
|
|
1219
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center", children: [
|
|
1452
1220
|
Number(transferredAmount) < MINIMUM_DISPLAYED_TOKEN_AMOUNT ? `<${MINIMUM_DISPLAYED_TOKEN_AMOUNT}` : transferredAmount,
|
|
1453
|
-
/* @__PURE__ */
|
|
1454
|
-
tokenData?.image ? /* @__PURE__ */
|
|
1221
|
+
/* @__PURE__ */ jsx24("div", { className: "ml-1", children: tokenData?.symbol }),
|
|
1222
|
+
tokenData?.image ? /* @__PURE__ */ jsx24(
|
|
1455
1223
|
"img",
|
|
1456
1224
|
{
|
|
1457
1225
|
src: tokenData?.image,
|
|
1458
1226
|
alt: tokenData?.name || "",
|
|
1459
1227
|
className: "w-5 h-5 ml-1"
|
|
1460
1228
|
}
|
|
1461
|
-
) : /* @__PURE__ */
|
|
1229
|
+
) : /* @__PURE__ */ jsx24("div", { className: "flex items-center justify-center w-5 h-5 text-[10px] ml-1 rounded-full bg-[#272e40] text-[#e0e7fa]", children: tokenData?.symbol.substring(0, 1) })
|
|
1462
1230
|
] }),
|
|
1463
|
-
transaction.tokenOutAddress && /* @__PURE__ */
|
|
1464
|
-
/* @__PURE__ */
|
|
1465
|
-
/* @__PURE__ */
|
|
1231
|
+
transaction.tokenOutAddress && /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1232
|
+
/* @__PURE__ */ jsx24("div", { className: "w-3.5 h-3.5 my-0 mx-1.5", children: /* @__PURE__ */ jsx24(ArrowRightIcon, {}) }),
|
|
1233
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center", children: [
|
|
1466
1234
|
Number(receivedAmount) < 1e-4 ? "<0.0001" : receivedAmount,
|
|
1467
|
-
/* @__PURE__ */
|
|
1468
|
-
tokenOutData?.image ? /* @__PURE__ */
|
|
1235
|
+
/* @__PURE__ */ jsx24("div", { className: "ml-1", children: tokenOutData?.symbol }),
|
|
1236
|
+
tokenOutData?.image ? /* @__PURE__ */ jsx24(
|
|
1469
1237
|
"img",
|
|
1470
1238
|
{
|
|
1471
1239
|
src: tokenOutData?.image,
|
|
1472
1240
|
alt: tokenOutData?.name || "",
|
|
1473
1241
|
className: "w-5 h-5 ml-1"
|
|
1474
1242
|
}
|
|
1475
|
-
) : /* @__PURE__ */
|
|
1243
|
+
) : /* @__PURE__ */ jsx24("div", { className: "flex items-center justify-center w-5 h-5 text-[10px] ml-1 rounded-full bg-[#272e40] text-[#e0e7fa]", children: tokenData?.symbol.substring(0, 1) })
|
|
1476
1244
|
] })
|
|
1477
1245
|
] })
|
|
1478
1246
|
] }) })
|
|
@@ -1481,7 +1249,7 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1481
1249
|
};
|
|
1482
1250
|
|
|
1483
1251
|
// src/components/TxConfigForm/History.tsx
|
|
1484
|
-
import { jsx as
|
|
1252
|
+
import { jsx as jsx25, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1485
1253
|
var History = ({ signer, supportedChains }) => {
|
|
1486
1254
|
const [fetchedHistory, setFetchedHistory] = useState2();
|
|
1487
1255
|
const [historyLoadedOnce, setHistoryLoadedOnce] = useState2(false);
|
|
@@ -1533,11 +1301,11 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1533
1301
|
return () => clearInterval(timer);
|
|
1534
1302
|
}, [signer, fetchHistory, getHistory, historyLoadedOnce]);
|
|
1535
1303
|
if (!signer)
|
|
1536
|
-
return /* @__PURE__ */
|
|
1537
|
-
return /* @__PURE__ */
|
|
1538
|
-
fetchedHistory?.length === 0 && historyLoadedOnce && /* @__PURE__ */
|
|
1539
|
-
!fetchedHistory && !historyLoadedOnce && /* @__PURE__ */
|
|
1540
|
-
fetchedHistory?.map((transaction, index) => /* @__PURE__ */
|
|
1304
|
+
return /* @__PURE__ */ jsx25("div", { className: "flex items-center justify-center w-full h-[30vh]", children: "Connect a wallet to browse history" });
|
|
1305
|
+
return /* @__PURE__ */ jsx25("div", { className: "flex items-center justify-center w-full", children: /* @__PURE__ */ jsxs8("div", { className: "w-full h-96 overflow-scroll overflow-x-hidden", children: [
|
|
1306
|
+
fetchedHistory?.length === 0 && historyLoadedOnce && /* @__PURE__ */ jsx25("div", { className: "w-full text-center py-4 px-0 text-[rgb(158,158,158)]", children: "Your history is empty..." }),
|
|
1307
|
+
!fetchedHistory && !historyLoadedOnce && /* @__PURE__ */ jsx25("div", { className: "flex w-full h-full items-center justify-center", children: /* @__PURE__ */ jsx25(CircularProgressIcon, {}) }),
|
|
1308
|
+
fetchedHistory?.map((transaction, index) => /* @__PURE__ */ jsx25(
|
|
1541
1309
|
HistoryCard,
|
|
1542
1310
|
{
|
|
1543
1311
|
transaction,
|
|
@@ -1549,30 +1317,30 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1549
1317
|
};
|
|
1550
1318
|
|
|
1551
1319
|
// src/components/TxConfigForm/TopBar.tsx
|
|
1552
|
-
import { Fragment as Fragment2, jsx as
|
|
1320
|
+
import { Fragment as Fragment2, jsx as jsx26, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1553
1321
|
var TopBar = ({
|
|
1554
1322
|
signer,
|
|
1555
1323
|
setSettingsShown,
|
|
1556
1324
|
setHistoryTabShown,
|
|
1557
1325
|
historyTabShown
|
|
1558
1326
|
}) => {
|
|
1559
|
-
return /* @__PURE__ */
|
|
1560
|
-
/* @__PURE__ */
|
|
1561
|
-
/* @__PURE__ */
|
|
1562
|
-
!historyTabShown && /* @__PURE__ */
|
|
1327
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex w-full justify-between items-center mx-auto sm:pl-4 pr-8 pt-2", children: [
|
|
1328
|
+
/* @__PURE__ */ jsx26("div", { className: "rounded-lg text-[rgba(255,255,255,0.6)] text-xs sm:text-base whitespace-nowrap", children: signer ? `Connected wallet: ${shortAddress(signer)}` : `Wallet disconnected` }),
|
|
1329
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex gap-2", children: [
|
|
1330
|
+
!historyTabShown && /* @__PURE__ */ jsx26(
|
|
1563
1331
|
"div",
|
|
1564
1332
|
{
|
|
1565
1333
|
onClick: () => setSettingsShown(true),
|
|
1566
1334
|
className: "flex items-center text-xs gap-1 cursor-pointer",
|
|
1567
|
-
children: /* @__PURE__ */
|
|
1335
|
+
children: /* @__PURE__ */ jsx26("div", { className: "w-7 h-7 rounded-full bg-gradient-to-r from-x_blue_light to-x_blue_dark flex items-center justify-center", children: /* @__PURE__ */ jsx26(SettingsIcon, {}) })
|
|
1568
1336
|
}
|
|
1569
1337
|
),
|
|
1570
|
-
/* @__PURE__ */
|
|
1338
|
+
/* @__PURE__ */ jsx26(
|
|
1571
1339
|
"div",
|
|
1572
1340
|
{
|
|
1573
1341
|
onClick: () => setHistoryTabShown((x) => !x),
|
|
1574
1342
|
className: "flex items-center text-sm gap-1 cursor-pointer",
|
|
1575
|
-
children: !historyTabShown ? /* @__PURE__ */
|
|
1343
|
+
children: !historyTabShown ? /* @__PURE__ */ jsx26(Fragment2, { children: /* @__PURE__ */ jsx26("div", { className: "w-7 h-7 rounded-full bg-gradient-to-r from-x_blue_light to-x_blue_dark flex items-center justify-center", children: /* @__PURE__ */ jsx26(HistoryIcon, {}) }) }) : /* @__PURE__ */ jsx26("div", { children: "Back" })
|
|
1576
1344
|
}
|
|
1577
1345
|
)
|
|
1578
1346
|
] })
|
|
@@ -1581,7 +1349,7 @@ var TopBar = ({
|
|
|
1581
1349
|
|
|
1582
1350
|
// src/components/TxConfigForm/Settings.tsx
|
|
1583
1351
|
import { useState as useState3, useEffect as useEffect3 } from "react";
|
|
1584
|
-
import { jsx as
|
|
1352
|
+
import { jsx as jsx27, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1585
1353
|
var Settings = ({
|
|
1586
1354
|
setSlippage,
|
|
1587
1355
|
setSettingsShown,
|
|
@@ -1598,22 +1366,22 @@ var Settings = ({
|
|
|
1598
1366
|
);
|
|
1599
1367
|
}
|
|
1600
1368
|
}, [slippageActivePresetIndex, usingSlippageInput]);
|
|
1601
|
-
return /* @__PURE__ */
|
|
1602
|
-
/* @__PURE__ */
|
|
1603
|
-
/* @__PURE__ */
|
|
1604
|
-
/* @__PURE__ */
|
|
1369
|
+
return /* @__PURE__ */ jsx27("div", { className: "absolute w-[310px] right-0 top-[46px] z-10 bg-black border border-solid border-[rgba(54,129,198,1)] p-4 rounded-xl", children: /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-4 justify-between", children: [
|
|
1370
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex justify-between", children: [
|
|
1371
|
+
/* @__PURE__ */ jsx27("div", { className: "text-base", children: "Settings" }),
|
|
1372
|
+
/* @__PURE__ */ jsx27(
|
|
1605
1373
|
"div",
|
|
1606
1374
|
{
|
|
1607
1375
|
className: "cursor-pointer",
|
|
1608
1376
|
onClick: () => setSettingsShown(false),
|
|
1609
|
-
children: /* @__PURE__ */
|
|
1377
|
+
children: /* @__PURE__ */ jsx27(CloseIcon, {})
|
|
1610
1378
|
}
|
|
1611
1379
|
)
|
|
1612
1380
|
] }),
|
|
1613
|
-
/* @__PURE__ */
|
|
1614
|
-
/* @__PURE__ */
|
|
1615
|
-
/* @__PURE__ */
|
|
1616
|
-
/* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ jsxs10("div", { children: [
|
|
1382
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-2 items-center", children: [
|
|
1383
|
+
/* @__PURE__ */ jsx27("div", { className: "text-sm text-[rgba(255,255,255,0.6)]", children: "Express delivery" }),
|
|
1384
|
+
/* @__PURE__ */ jsx27("div", { children: /* @__PURE__ */ jsxs10(
|
|
1617
1385
|
"span",
|
|
1618
1386
|
{
|
|
1619
1387
|
className: "inline-flex w-14 h-9 p-3 relative align-middle box-border overflow-hidden cursor-pointer",
|
|
@@ -1621,8 +1389,8 @@ var Settings = ({
|
|
|
1621
1389
|
setExpressChecked((x) => !x);
|
|
1622
1390
|
},
|
|
1623
1391
|
children: [
|
|
1624
|
-
/* @__PURE__ */
|
|
1625
|
-
/* @__PURE__ */
|
|
1392
|
+
/* @__PURE__ */ jsx27("span", { className: "h-full, w-full rounded-lg bg-[rgba(255,255,255,0.3)]" }),
|
|
1393
|
+
/* @__PURE__ */ jsx27(
|
|
1626
1394
|
"span",
|
|
1627
1395
|
{
|
|
1628
1396
|
className: `transition-all w-5 h-5 rounded-full absolute translate-y-[-4px]
|
|
@@ -1633,15 +1401,15 @@ var Settings = ({
|
|
|
1633
1401
|
}
|
|
1634
1402
|
) })
|
|
1635
1403
|
] }),
|
|
1636
|
-
/* @__PURE__ */
|
|
1637
|
-
/* @__PURE__ */
|
|
1638
|
-
/* @__PURE__ */
|
|
1404
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-4", children: [
|
|
1405
|
+
/* @__PURE__ */ jsx27("div", { className: "min-w-[26px] min-h-[26px] text-[#ffa726]", children: /* @__PURE__ */ jsx27(InfoIcon, {}) }),
|
|
1406
|
+
/* @__PURE__ */ jsx27("div", { className: "text-xs text-left", children: "Express delivery is a special feature of XSwap that reduces transaction time across chains to around 30 seconds. It is currently available for swaps below a value of $ 1000 USD." })
|
|
1639
1407
|
] })
|
|
1640
1408
|
] }),
|
|
1641
|
-
/* @__PURE__ */
|
|
1642
|
-
/* @__PURE__ */
|
|
1643
|
-
/* @__PURE__ */
|
|
1644
|
-
/* @__PURE__ */
|
|
1409
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-2 ", children: [
|
|
1410
|
+
/* @__PURE__ */ jsx27("div", { className: " text-[rgba(255,255,255,0.6)] text-sm", children: "Slippage" }),
|
|
1411
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-2", children: [
|
|
1412
|
+
/* @__PURE__ */ jsx27("div", { className: "flex items-center bg-[rgba(15,15,15,1)] p-1 globalBorder rounded-xl", children: SLIPPAGE_PRESETS.map((preset, index) => /* @__PURE__ */ jsx27(
|
|
1645
1413
|
"div",
|
|
1646
1414
|
{
|
|
1647
1415
|
className: `transition-all cursor-pointer block rounded-lg p-2 border-none text-sm leading-[10px] ${index === slippageActivePresetIndex && !usingSlippageInput ? "text-white" : "text-[rgba(255,255,255,0.2)]"} ${index === slippageActivePresetIndex && !usingSlippageInput ? "bg-gradient-to-r from-[#3681c6] to-[#2b4a9d]" : ""}`,
|
|
@@ -1653,8 +1421,8 @@ var Settings = ({
|
|
|
1653
1421
|
},
|
|
1654
1422
|
index
|
|
1655
1423
|
)) }),
|
|
1656
|
-
/* @__PURE__ */
|
|
1657
|
-
/* @__PURE__ */
|
|
1424
|
+
/* @__PURE__ */ jsxs10("div", { className: "bg-[rgba(39,39,39,1)] p-2 border border-solid border-[rgba(82,82,82,1)] rounded-xl text-white flex items-center", children: [
|
|
1425
|
+
/* @__PURE__ */ jsx27(
|
|
1658
1426
|
"input",
|
|
1659
1427
|
{
|
|
1660
1428
|
className: "text-white border-none bg-[rgba(39,39,39,1)] w-10 placeholder:text-[rgba(255,255,255,0.2)] focus:outline-none text-sm leading-none",
|
|
@@ -1673,16 +1441,16 @@ var Settings = ({
|
|
|
1673
1441
|
}
|
|
1674
1442
|
}
|
|
1675
1443
|
),
|
|
1676
|
-
/* @__PURE__ */
|
|
1444
|
+
/* @__PURE__ */ jsx27(PercentageIcon, {})
|
|
1677
1445
|
] })
|
|
1678
1446
|
] }),
|
|
1679
|
-
/* @__PURE__ */
|
|
1680
|
-
/* @__PURE__ */
|
|
1681
|
-
/* @__PURE__ */
|
|
1447
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-4", children: [
|
|
1448
|
+
/* @__PURE__ */ jsx27("div", { className: "min-w-[26px] min-h-[26px] text-[#ffa726]", children: /* @__PURE__ */ jsx27(InfoIcon, {}) }),
|
|
1449
|
+
/* @__PURE__ */ jsxs10("div", { className: "text-xs text-left", children: [
|
|
1682
1450
|
"Slippage is the price variation you are willing to accept in the event that the price of the trade changes while it is processing.",
|
|
1683
|
-
/* @__PURE__ */
|
|
1451
|
+
/* @__PURE__ */ jsx27("br", {}),
|
|
1684
1452
|
" ",
|
|
1685
|
-
/* @__PURE__ */
|
|
1453
|
+
/* @__PURE__ */ jsx27("br", {}),
|
|
1686
1454
|
"If the trade fails due to too-low slippage, you will receive USDC on the destination chain."
|
|
1687
1455
|
] })
|
|
1688
1456
|
] })
|
|
@@ -1691,7 +1459,7 @@ var Settings = ({
|
|
|
1691
1459
|
};
|
|
1692
1460
|
|
|
1693
1461
|
// src/components/TxConfigForm/FeesDetails.tsx
|
|
1694
|
-
import { jsx as
|
|
1462
|
+
import { jsx as jsx28, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1695
1463
|
var FeesDetails = ({
|
|
1696
1464
|
isGettingRoute,
|
|
1697
1465
|
route,
|
|
@@ -1702,12 +1470,12 @@ var FeesDetails = ({
|
|
|
1702
1470
|
feesDetailsShown,
|
|
1703
1471
|
setFeesDetailsShown
|
|
1704
1472
|
}) => {
|
|
1705
|
-
return /* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
1707
|
-
/* @__PURE__ */
|
|
1708
|
-
/* @__PURE__ */
|
|
1709
|
-
/* @__PURE__ */
|
|
1710
|
-
isGettingRoute ? /* @__PURE__ */
|
|
1473
|
+
return /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-3 globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4 mb-1", children: [
|
|
1474
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex w-full items-center justify-between text-xs sm:text-sm ", children: [
|
|
1475
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1 font-medium text-white opacity-60", children: [
|
|
1476
|
+
/* @__PURE__ */ jsx28(CoinsIcon, {}),
|
|
1477
|
+
/* @__PURE__ */ jsx28("div", { className: "mr-1", children: "Fees:" }),
|
|
1478
|
+
isGettingRoute ? /* @__PURE__ */ jsx28("div", { className: "bg-current rounded animate-pulse w-20 h-4" }) : ` ${weiToHumanReadable({
|
|
1711
1479
|
amount: safeBigNumberFrom(
|
|
1712
1480
|
route?.xSwapFees.xSwapFee.nativeFee || "0"
|
|
1713
1481
|
).add(safeBigNumberFrom(route?.xSwapFees.ccipFee || "0")).add(
|
|
@@ -1717,30 +1485,30 @@ var FeesDetails = ({
|
|
|
1717
1485
|
precisionFractionalPlaces: 5
|
|
1718
1486
|
})} ${paymentToken?.symbol}`
|
|
1719
1487
|
] }),
|
|
1720
|
-
/* @__PURE__ */
|
|
1721
|
-
/* @__PURE__ */
|
|
1488
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex gap-1 items-center", children: [
|
|
1489
|
+
/* @__PURE__ */ jsxs11(
|
|
1722
1490
|
"div",
|
|
1723
1491
|
{
|
|
1724
1492
|
className: `flex gap-1 items-center font-medium ${expressChecked ? "text-x_green" : "text-white opacity-60"}`,
|
|
1725
1493
|
children: [
|
|
1726
|
-
/* @__PURE__ */
|
|
1494
|
+
/* @__PURE__ */ jsx28(TimerIcon, {}),
|
|
1727
1495
|
expressChecked ? "Fast ~ 30sec " : "Normal ~ 30min"
|
|
1728
1496
|
]
|
|
1729
1497
|
}
|
|
1730
1498
|
),
|
|
1731
|
-
/* @__PURE__ */
|
|
1499
|
+
/* @__PURE__ */ jsx28(
|
|
1732
1500
|
"div",
|
|
1733
1501
|
{
|
|
1734
1502
|
onClick: () => setFeesDetailsShown((x) => !x),
|
|
1735
1503
|
className: "font-medium text-white opacity-60 cursor-pointer flex items-center w-[15px] h-[9px]",
|
|
1736
|
-
children: feesDetailsShown ? /* @__PURE__ */
|
|
1504
|
+
children: feesDetailsShown ? /* @__PURE__ */ jsx28(ChevronUpIcon, {}) : /* @__PURE__ */ jsx28(ChevronDownIcon, {})
|
|
1737
1505
|
}
|
|
1738
1506
|
)
|
|
1739
1507
|
] })
|
|
1740
1508
|
] }),
|
|
1741
|
-
feesDetailsShown && /* @__PURE__ */
|
|
1742
|
-
/* @__PURE__ */
|
|
1743
|
-
/* @__PURE__ */
|
|
1509
|
+
feesDetailsShown && /* @__PURE__ */ jsxs11("div", { className: "flex w-full items-center justify-between ", children: [
|
|
1510
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-col text-[10px] gap-1", children: [
|
|
1511
|
+
/* @__PURE__ */ jsxs11("div", { className: "font-medium text-white opacity-60", children: [
|
|
1744
1512
|
"CCIP Fee:",
|
|
1745
1513
|
` ${weiToHumanReadable({
|
|
1746
1514
|
amount: route?.xSwapFees.ccipFee || "0",
|
|
@@ -1748,7 +1516,7 @@ var FeesDetails = ({
|
|
|
1748
1516
|
precisionFractionalPlaces: 5
|
|
1749
1517
|
})} ${paymentToken?.symbol}`
|
|
1750
1518
|
] }),
|
|
1751
|
-
/* @__PURE__ */
|
|
1519
|
+
/* @__PURE__ */ jsxs11("div", { className: "font-medium text-white opacity-60", children: [
|
|
1752
1520
|
"Native Fee:",
|
|
1753
1521
|
` ${weiToHumanReadable({
|
|
1754
1522
|
amount: route?.xSwapFees.xSwapFee.nativeFee || "0",
|
|
@@ -1757,12 +1525,12 @@ var FeesDetails = ({
|
|
|
1757
1525
|
})} ${paymentToken?.symbol}`
|
|
1758
1526
|
] })
|
|
1759
1527
|
] }),
|
|
1760
|
-
/* @__PURE__ */
|
|
1761
|
-
/* @__PURE__ */
|
|
1528
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-col text-[10px] gap-1", children: [
|
|
1529
|
+
/* @__PURE__ */ jsxs11("div", { className: "font-medium text-white opacity-60", children: [
|
|
1762
1530
|
"Slippage: ",
|
|
1763
1531
|
`${slippage}%`
|
|
1764
1532
|
] }),
|
|
1765
|
-
/* @__PURE__ */
|
|
1533
|
+
/* @__PURE__ */ jsxs11("div", { className: "font-medium text-white opacity-60", children: [
|
|
1766
1534
|
"Min amount out:",
|
|
1767
1535
|
" ",
|
|
1768
1536
|
weiToHumanReadable({
|
|
@@ -1783,7 +1551,7 @@ import { useEffect as useEffect5, useMemo as useMemo3, useState as useState5 } f
|
|
|
1783
1551
|
|
|
1784
1552
|
// src/components/TxConfigForm/UsdPrice.tsx
|
|
1785
1553
|
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
1786
|
-
import { Fragment as Fragment3, jsx as
|
|
1554
|
+
import { Fragment as Fragment3, jsx as jsx29 } from "react/jsx-runtime";
|
|
1787
1555
|
var UsdPrice = ({
|
|
1788
1556
|
prices,
|
|
1789
1557
|
token,
|
|
@@ -1796,11 +1564,11 @@ var UsdPrice = ({
|
|
|
1796
1564
|
setUsdPrice((Number(amount) * Number(prices[token.address])).toFixed(2));
|
|
1797
1565
|
}
|
|
1798
1566
|
}, [token, prices, amount]);
|
|
1799
|
-
return /* @__PURE__ */
|
|
1567
|
+
return /* @__PURE__ */ jsx29("div", { className: "opacity-60 py-4", children: loading ? /* @__PURE__ */ jsx29(Skeleton, { width: "w-12", height: "h-4" }) : token ? prices && prices[token.address] ? /* @__PURE__ */ jsx29("div", { children: `$${usdPrice}` }) : /* @__PURE__ */ jsx29(Alert, { desc: "Unknown price" }) : /* @__PURE__ */ jsx29(Fragment3, { children: "$0.00" }) });
|
|
1800
1568
|
};
|
|
1801
1569
|
|
|
1802
1570
|
// src/components/TxConfigForm/Summary.tsx
|
|
1803
|
-
import { jsx as
|
|
1571
|
+
import { jsx as jsx30, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1804
1572
|
var Summary = ({
|
|
1805
1573
|
isGettingRoute,
|
|
1806
1574
|
route,
|
|
@@ -1823,32 +1591,32 @@ var Summary = ({
|
|
|
1823
1591
|
);
|
|
1824
1592
|
}
|
|
1825
1593
|
}, [dstChain]);
|
|
1826
|
-
return /* @__PURE__ */
|
|
1827
|
-
/* @__PURE__ */
|
|
1828
|
-
/* @__PURE__ */
|
|
1829
|
-
/* @__PURE__ */
|
|
1830
|
-
isGettingRoute ? /* @__PURE__ */
|
|
1594
|
+
return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4 relative", children: [
|
|
1595
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex justify-between", children: [
|
|
1596
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1", children: [
|
|
1597
|
+
/* @__PURE__ */ jsx30("p", { className: "text-[rgba(255,255,255,0.6)] text-sm", children: "You receive" }),
|
|
1598
|
+
isGettingRoute ? /* @__PURE__ */ jsx30(
|
|
1831
1599
|
Skeleton,
|
|
1832
1600
|
{
|
|
1833
1601
|
width: "w-[100px]",
|
|
1834
1602
|
height: "h-[36px]",
|
|
1835
1603
|
other: "sm:w-[190px]"
|
|
1836
1604
|
}
|
|
1837
|
-
) : /* @__PURE__ */
|
|
1605
|
+
) : /* @__PURE__ */ jsxs12("div", { className: "flex gap-2 items-center text-white text-xl sm:text-3xl", children: [
|
|
1838
1606
|
amountReadable,
|
|
1839
|
-
/* @__PURE__ */
|
|
1840
|
-
/* @__PURE__ */
|
|
1607
|
+
/* @__PURE__ */ jsx30("div", { className: "w-4 sm:w-6 h-4 sm:h-6", children: /* @__PURE__ */ jsx30("img", { src: dstToken?.image, alt: dstToken?.name }) }),
|
|
1608
|
+
/* @__PURE__ */ jsx30("p", { className: "text-base sm:text-xl", children: dstToken?.symbol })
|
|
1841
1609
|
] })
|
|
1842
1610
|
] }),
|
|
1843
|
-
/* @__PURE__ */
|
|
1844
|
-
/* @__PURE__ */
|
|
1845
|
-
/* @__PURE__ */
|
|
1846
|
-
/* @__PURE__ */
|
|
1847
|
-
/* @__PURE__ */
|
|
1611
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 text-sm", children: [
|
|
1612
|
+
/* @__PURE__ */ jsx30("p", { className: "text-[rgba(255,255,255,0.6)] text-right", children: "on chain:" }),
|
|
1613
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1 text-white", children: [
|
|
1614
|
+
/* @__PURE__ */ jsx30("div", { className: "w-4 h-4", children: /* @__PURE__ */ jsx30("img", { src: dstChain?.image, alt: dstChain?.name }) }),
|
|
1615
|
+
/* @__PURE__ */ jsx30("div", { children: dstChain?.displayName })
|
|
1848
1616
|
] })
|
|
1849
1617
|
] })
|
|
1850
1618
|
] }),
|
|
1851
|
-
/* @__PURE__ */
|
|
1619
|
+
/* @__PURE__ */ jsx30(
|
|
1852
1620
|
UsdPrice,
|
|
1853
1621
|
{
|
|
1854
1622
|
prices,
|
|
@@ -1857,7 +1625,7 @@ var Summary = ({
|
|
|
1857
1625
|
loading: isGettingRoute
|
|
1858
1626
|
}
|
|
1859
1627
|
),
|
|
1860
|
-
/* @__PURE__ */
|
|
1628
|
+
/* @__PURE__ */ jsx30("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__ */ jsx30("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__ */ jsx30(ArrowDownIcon, {}) }) })
|
|
1861
1629
|
] });
|
|
1862
1630
|
};
|
|
1863
1631
|
|
|
@@ -1867,7 +1635,7 @@ import { useState as useState7, useEffect as useEffect6, useRef as useRef2, useM
|
|
|
1867
1635
|
// src/components/TxConfigForm/TokenPicker.tsx
|
|
1868
1636
|
import { useState as useState6, useMemo as useMemo4 } from "react";
|
|
1869
1637
|
import { createPortal } from "react-dom";
|
|
1870
|
-
import { Fragment as Fragment4, jsx as
|
|
1638
|
+
import { Fragment as Fragment4, jsx as jsx31, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1871
1639
|
var TokenPicker = ({
|
|
1872
1640
|
onCloseClick,
|
|
1873
1641
|
tokens,
|
|
@@ -1894,24 +1662,24 @@ var TokenPicker = ({
|
|
|
1894
1662
|
);
|
|
1895
1663
|
}, [searchValue, tokens]);
|
|
1896
1664
|
return modalRoot ? createPortal(
|
|
1897
|
-
/* @__PURE__ */
|
|
1665
|
+
/* @__PURE__ */ jsx31(
|
|
1898
1666
|
"div",
|
|
1899
1667
|
{
|
|
1900
1668
|
onClick: onBackdropClick,
|
|
1901
1669
|
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",
|
|
1902
|
-
children: /* @__PURE__ */
|
|
1903
|
-
/* @__PURE__ */
|
|
1670
|
+
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: [
|
|
1671
|
+
/* @__PURE__ */ jsx31(
|
|
1904
1672
|
"div",
|
|
1905
1673
|
{
|
|
1906
1674
|
onClick: onCloseClick,
|
|
1907
1675
|
className: "absolute top-4 right-4 cursor-pointer",
|
|
1908
|
-
children: /* @__PURE__ */
|
|
1676
|
+
children: /* @__PURE__ */ jsx31(CloseIcon, {})
|
|
1909
1677
|
}
|
|
1910
1678
|
),
|
|
1911
|
-
/* @__PURE__ */
|
|
1912
|
-
/* @__PURE__ */
|
|
1913
|
-
/* @__PURE__ */
|
|
1914
|
-
/* @__PURE__ */
|
|
1679
|
+
/* @__PURE__ */ jsx31("p", { className: "text-base mb-4", children: "Pick a token" }),
|
|
1680
|
+
/* @__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: [
|
|
1681
|
+
/* @__PURE__ */ jsx31("div", { className: "w-6 h-6", children: /* @__PURE__ */ jsx31(SearchIcon, {}) }),
|
|
1682
|
+
/* @__PURE__ */ jsx31(
|
|
1915
1683
|
"input",
|
|
1916
1684
|
{
|
|
1917
1685
|
placeholder: "Search name or paste address",
|
|
@@ -1921,7 +1689,7 @@ var TokenPicker = ({
|
|
|
1921
1689
|
}
|
|
1922
1690
|
)
|
|
1923
1691
|
] }),
|
|
1924
|
-
/* @__PURE__ */
|
|
1692
|
+
/* @__PURE__ */ jsx31("div", { className: "my-4 mx-0 flex flex-wrap gap-3", children: tokens?.filter((token) => token?.quickPick).map((token) => /* @__PURE__ */ jsxs13(
|
|
1925
1693
|
"div",
|
|
1926
1694
|
{
|
|
1927
1695
|
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)]" : ""}`,
|
|
@@ -1930,14 +1698,14 @@ var TokenPicker = ({
|
|
|
1930
1698
|
onCloseClick();
|
|
1931
1699
|
},
|
|
1932
1700
|
children: [
|
|
1933
|
-
/* @__PURE__ */
|
|
1934
|
-
/* @__PURE__ */
|
|
1701
|
+
/* @__PURE__ */ jsx31("img", { src: token.image, alt: token.name, className: "w-5" }),
|
|
1702
|
+
/* @__PURE__ */ jsx31("div", { className: "text-sm", children: token.symbol })
|
|
1935
1703
|
]
|
|
1936
1704
|
},
|
|
1937
1705
|
token.address
|
|
1938
1706
|
)) }),
|
|
1939
|
-
/* @__PURE__ */
|
|
1940
|
-
/* @__PURE__ */
|
|
1707
|
+
/* @__PURE__ */ jsx31("div", { className: "h-[2px] my-0 mx-[-24px] w-[100%+48px] px-12 bg-[rgba(255,255,255,0.1)]" }),
|
|
1708
|
+
/* @__PURE__ */ jsx31("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(
|
|
1941
1709
|
"div",
|
|
1942
1710
|
{
|
|
1943
1711
|
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)]" : ""}`,
|
|
@@ -1946,29 +1714,29 @@ var TokenPicker = ({
|
|
|
1946
1714
|
onCloseClick();
|
|
1947
1715
|
},
|
|
1948
1716
|
children: [
|
|
1949
|
-
token.image ? /* @__PURE__ */
|
|
1717
|
+
token.image ? /* @__PURE__ */ jsx31(
|
|
1950
1718
|
"img",
|
|
1951
1719
|
{
|
|
1952
1720
|
src: token.image,
|
|
1953
1721
|
alt: token.name,
|
|
1954
1722
|
className: "token-picker__all__logo"
|
|
1955
1723
|
}
|
|
1956
|
-
) : /* @__PURE__ */
|
|
1957
|
-
/* @__PURE__ */
|
|
1958
|
-
/* @__PURE__ */
|
|
1959
|
-
/* @__PURE__ */
|
|
1960
|
-
/* @__PURE__ */
|
|
1724
|
+
) : /* @__PURE__ */ jsx31("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) }),
|
|
1725
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex justify-between items-center gap-1 overflow-hidden grow", children: [
|
|
1726
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col leading-[16px]", children: [
|
|
1727
|
+
/* @__PURE__ */ jsx31("div", { className: "overflow-hidden whitespace-nowrap text-ellipsis text-[15px]", children: token.name }),
|
|
1728
|
+
/* @__PURE__ */ jsx31("div", { className: "text-[#888] text-[11px]", children: token.symbol })
|
|
1961
1729
|
] }),
|
|
1962
|
-
signer && /* @__PURE__ */
|
|
1730
|
+
signer && /* @__PURE__ */ jsx31(Fragment4, { children: balances && balances[token.address] && token.decimals ? /* @__PURE__ */ jsx31("div", { className: "text-xs", children: weiToHumanReadable({
|
|
1963
1731
|
amount: balances[token.address]?.toString() || "0",
|
|
1964
1732
|
decimals: token.decimals,
|
|
1965
1733
|
precisionFractionalPlaces: 4
|
|
1966
|
-
}) }) : /* @__PURE__ */
|
|
1734
|
+
}) }) : /* @__PURE__ */ jsx31(Skeleton, { width: "w-12", height: "h-3" }) })
|
|
1967
1735
|
] })
|
|
1968
1736
|
]
|
|
1969
1737
|
},
|
|
1970
1738
|
`${index}_${token.address}`
|
|
1971
|
-
)) : /* @__PURE__ */
|
|
1739
|
+
)) : /* @__PURE__ */ jsx31("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx31("p", { className: "text-sm text-white", children: "No tokens found." }) }) })
|
|
1972
1740
|
] })
|
|
1973
1741
|
}
|
|
1974
1742
|
),
|
|
@@ -1977,7 +1745,7 @@ var TokenPicker = ({
|
|
|
1977
1745
|
};
|
|
1978
1746
|
|
|
1979
1747
|
// src/components/TxConfigForm/ChainListElement.tsx
|
|
1980
|
-
import { jsx as
|
|
1748
|
+
import { jsx as jsx32, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1981
1749
|
var ChainListElement = ({
|
|
1982
1750
|
chain,
|
|
1983
1751
|
setSrcChain,
|
|
@@ -1985,8 +1753,8 @@ var ChainListElement = ({
|
|
|
1985
1753
|
index,
|
|
1986
1754
|
length
|
|
1987
1755
|
}) => {
|
|
1988
|
-
return /* @__PURE__ */
|
|
1989
|
-
/* @__PURE__ */
|
|
1756
|
+
return /* @__PURE__ */ jsxs14("div", { children: [
|
|
1757
|
+
/* @__PURE__ */ jsxs14(
|
|
1990
1758
|
"li",
|
|
1991
1759
|
{
|
|
1992
1760
|
className: "bg-transparent border-none flex gap-1 items-center cursor-pointer py-2 w-full",
|
|
@@ -1995,19 +1763,19 @@ var ChainListElement = ({
|
|
|
1995
1763
|
setChainListShown(false);
|
|
1996
1764
|
},
|
|
1997
1765
|
children: [
|
|
1998
|
-
/* @__PURE__ */
|
|
1766
|
+
/* @__PURE__ */ jsx32("img", { width: 12, height: 12, src: chain.image, alt: chain.displayName }),
|
|
1999
1767
|
chain.displayName
|
|
2000
1768
|
]
|
|
2001
1769
|
}
|
|
2002
1770
|
),
|
|
2003
|
-
index !== length - 1 && /* @__PURE__ */
|
|
1771
|
+
index !== length - 1 && /* @__PURE__ */ jsx32("div", { className: "h-px mx-2 bg-[rgba(255,255,255,0.15)]" })
|
|
2004
1772
|
] }, `${chain.ecosystem}-${chain.chainId}`);
|
|
2005
1773
|
};
|
|
2006
1774
|
|
|
2007
1775
|
// src/components/TxConfigForm/BalanceComponent.tsx
|
|
2008
1776
|
import { useMemo as useMemo5 } from "react";
|
|
2009
1777
|
import BigNumber3 from "bignumber.js";
|
|
2010
|
-
import { Fragment as Fragment5, jsx as
|
|
1778
|
+
import { Fragment as Fragment5, jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2011
1779
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
2012
1780
|
const balanceText = useMemo5(() => {
|
|
2013
1781
|
if (!balances || !srcToken) return "0";
|
|
@@ -2027,7 +1795,7 @@ var BalanceComponent = ({ srcToken, balances }) => {
|
|
|
2027
1795
|
precisionFractionalPlaces: 5
|
|
2028
1796
|
});
|
|
2029
1797
|
}, [srcToken, balances]);
|
|
2030
|
-
return /* @__PURE__ */
|
|
1798
|
+
return /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
2031
1799
|
"Balance:",
|
|
2032
1800
|
" ",
|
|
2033
1801
|
srcToken && balances ? weiToHumanReadable({
|
|
@@ -2035,12 +1803,12 @@ var BalanceComponent = ({ srcToken, balances }) => {
|
|
|
2035
1803
|
decimals: srcToken.decimals,
|
|
2036
1804
|
precisionFractionalPlaces: 4
|
|
2037
1805
|
}) : 0,
|
|
2038
|
-
/* @__PURE__ */
|
|
1806
|
+
/* @__PURE__ */ jsx33("span", { className: "bg-gradient-to-r from-x_blue_light to-x_blue_dark bg-clip-text text-transparent", children: "Max" })
|
|
2039
1807
|
] });
|
|
2040
1808
|
};
|
|
2041
1809
|
|
|
2042
1810
|
// src/components/TxConfigForm/SwapPanel.tsx
|
|
2043
|
-
import { jsx as
|
|
1811
|
+
import { jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2044
1812
|
var SwapPanel = ({
|
|
2045
1813
|
amount,
|
|
2046
1814
|
setAmount,
|
|
@@ -2085,11 +1853,11 @@ var SwapPanel = ({
|
|
|
2085
1853
|
() => supportedChains.filter((chain) => chain.chainId !== srcChain?.chainId),
|
|
2086
1854
|
[supportedChains, srcChain]
|
|
2087
1855
|
);
|
|
2088
|
-
return /* @__PURE__ */
|
|
2089
|
-
/* @__PURE__ */
|
|
2090
|
-
/* @__PURE__ */
|
|
2091
|
-
/* @__PURE__ */
|
|
2092
|
-
/* @__PURE__ */
|
|
1856
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex justify-between globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4", children: [
|
|
1857
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex flex-col justify-between gap-2 overflow-hidden w-1/2", children: [
|
|
1858
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-1", children: [
|
|
1859
|
+
/* @__PURE__ */ jsx34("p", { className: "text-white opacity-60 text-xs sm:text-sm font-medium", children: "You pay" }),
|
|
1860
|
+
/* @__PURE__ */ jsx34(
|
|
2093
1861
|
"input",
|
|
2094
1862
|
{
|
|
2095
1863
|
className: "p-0 border-none outline-none bg-transparent text-2xl overflow-ellipsis",
|
|
@@ -2108,7 +1876,7 @@ var SwapPanel = ({
|
|
|
2108
1876
|
}
|
|
2109
1877
|
)
|
|
2110
1878
|
] }),
|
|
2111
|
-
/* @__PURE__ */
|
|
1879
|
+
/* @__PURE__ */ jsx34("div", { className: "flex items-center text-sm text-[rgba(255,255,255,0.6)]", children: /* @__PURE__ */ jsx34(
|
|
2112
1880
|
UsdPrice,
|
|
2113
1881
|
{
|
|
2114
1882
|
prices,
|
|
@@ -2118,8 +1886,8 @@ var SwapPanel = ({
|
|
|
2118
1886
|
}
|
|
2119
1887
|
) })
|
|
2120
1888
|
] }),
|
|
2121
|
-
/* @__PURE__ */
|
|
2122
|
-
/* @__PURE__ */
|
|
1889
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex flex-col relative items-end gap-2.5 w-1/2 text-xs", children: [
|
|
1890
|
+
/* @__PURE__ */ jsxs16(
|
|
2123
1891
|
"div",
|
|
2124
1892
|
{
|
|
2125
1893
|
className: "flex gap-2 items-center p-2 max-w-full cursor-pointer bg-black text-white globalBorder rounded-3xl whitespace-nowrap",
|
|
@@ -2127,7 +1895,7 @@ var SwapPanel = ({
|
|
|
2127
1895
|
setTokenListShown((state) => !state);
|
|
2128
1896
|
},
|
|
2129
1897
|
children: [
|
|
2130
|
-
/* @__PURE__ */
|
|
1898
|
+
/* @__PURE__ */ jsx34(
|
|
2131
1899
|
"img",
|
|
2132
1900
|
{
|
|
2133
1901
|
height: 16,
|
|
@@ -2136,12 +1904,12 @@ var SwapPanel = ({
|
|
|
2136
1904
|
alt: srcToken?.name
|
|
2137
1905
|
}
|
|
2138
1906
|
),
|
|
2139
|
-
/* @__PURE__ */
|
|
2140
|
-
/* @__PURE__ */
|
|
1907
|
+
/* @__PURE__ */ jsx34("div", { children: srcToken?.symbol }),
|
|
1908
|
+
/* @__PURE__ */ jsx34(DownArrowIcon, {})
|
|
2141
1909
|
]
|
|
2142
1910
|
}
|
|
2143
1911
|
),
|
|
2144
|
-
tokenListShown && /* @__PURE__ */
|
|
1912
|
+
tokenListShown && /* @__PURE__ */ jsx34(
|
|
2145
1913
|
TokenPicker,
|
|
2146
1914
|
{
|
|
2147
1915
|
onCloseClick: () => setTokenListShown(false),
|
|
@@ -2152,22 +1920,22 @@ var SwapPanel = ({
|
|
|
2152
1920
|
balances
|
|
2153
1921
|
}
|
|
2154
1922
|
),
|
|
2155
|
-
/* @__PURE__ */
|
|
1923
|
+
/* @__PURE__ */ jsx34(
|
|
2156
1924
|
"div",
|
|
2157
1925
|
{
|
|
2158
1926
|
onClick: handleMaxClick,
|
|
2159
1927
|
className: "flex gap-1 items-center font-medium text-white opacity-60 py-0.5 cursor-pointer",
|
|
2160
|
-
children: signer && /* @__PURE__ */
|
|
1928
|
+
children: signer && /* @__PURE__ */ jsx34(BalanceComponent, { balances, srcToken })
|
|
2161
1929
|
}
|
|
2162
1930
|
),
|
|
2163
|
-
/* @__PURE__ */
|
|
1931
|
+
/* @__PURE__ */ jsxs16(
|
|
2164
1932
|
"div",
|
|
2165
1933
|
{
|
|
2166
1934
|
ref: buttonRef,
|
|
2167
1935
|
className: "bg-black globalBorder rounded-2xl whitespace-nowrap flex items-center p-2 cursor-pointer gap-2",
|
|
2168
1936
|
onClick: () => setChainListShown((prev) => !prev),
|
|
2169
1937
|
children: [
|
|
2170
|
-
/* @__PURE__ */
|
|
1938
|
+
/* @__PURE__ */ jsx34(
|
|
2171
1939
|
"img",
|
|
2172
1940
|
{
|
|
2173
1941
|
width: "16",
|
|
@@ -2176,17 +1944,17 @@ var SwapPanel = ({
|
|
|
2176
1944
|
alt: srcChain?.name
|
|
2177
1945
|
}
|
|
2178
1946
|
),
|
|
2179
|
-
/* @__PURE__ */
|
|
2180
|
-
/* @__PURE__ */
|
|
1947
|
+
/* @__PURE__ */ jsx34("div", { children: srcChain?.displayName }),
|
|
1948
|
+
/* @__PURE__ */ jsx34(DownArrowIcon, {})
|
|
2181
1949
|
]
|
|
2182
1950
|
}
|
|
2183
1951
|
),
|
|
2184
|
-
chainListShown && /* @__PURE__ */
|
|
1952
|
+
chainListShown && /* @__PURE__ */ jsx34(
|
|
2185
1953
|
"ul",
|
|
2186
1954
|
{
|
|
2187
1955
|
ref: listRef,
|
|
2188
1956
|
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",
|
|
2189
|
-
children: chainListOptions.map((chain, index) => /* @__PURE__ */
|
|
1957
|
+
children: chainListOptions.map((chain, index) => /* @__PURE__ */ jsx34(
|
|
2190
1958
|
ChainListElement,
|
|
2191
1959
|
{
|
|
2192
1960
|
index,
|
|
@@ -2203,9 +1971,9 @@ var SwapPanel = ({
|
|
|
2203
1971
|
};
|
|
2204
1972
|
|
|
2205
1973
|
// src/components/TxConfigForm/ErrorField.tsx
|
|
2206
|
-
import { jsx as
|
|
1974
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
2207
1975
|
var ErrorField = ({ error }) => {
|
|
2208
|
-
return /* @__PURE__ */
|
|
1976
|
+
return /* @__PURE__ */ jsx35(
|
|
2209
1977
|
"div",
|
|
2210
1978
|
{
|
|
2211
1979
|
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"}`,
|
|
@@ -2215,15 +1983,15 @@ var ErrorField = ({ error }) => {
|
|
|
2215
1983
|
};
|
|
2216
1984
|
|
|
2217
1985
|
// src/components/TxConfigForm/Description.tsx
|
|
2218
|
-
import { jsx as
|
|
1986
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
2219
1987
|
var Description = ({ description }) => {
|
|
2220
|
-
return /* @__PURE__ */
|
|
1988
|
+
return /* @__PURE__ */ jsx36("div", { className: "flex flex-col items-start rounded-lg px-4 py-2", children: /* @__PURE__ */ jsx36("div", { className: "w-full flex gap-4 items-start justify-between text-xl", children: description }) });
|
|
2221
1989
|
};
|
|
2222
1990
|
|
|
2223
1991
|
// src/components/TxConfigForm/Button.tsx
|
|
2224
|
-
import { jsx as
|
|
1992
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
2225
1993
|
var Button = ({ children, onClick, type, disabled }) => {
|
|
2226
|
-
return /* @__PURE__ */
|
|
1994
|
+
return /* @__PURE__ */ jsx37(
|
|
2227
1995
|
"button",
|
|
2228
1996
|
{
|
|
2229
1997
|
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",
|
|
@@ -2236,7 +2004,7 @@ var Button = ({ children, onClick, type, disabled }) => {
|
|
|
2236
2004
|
};
|
|
2237
2005
|
|
|
2238
2006
|
// src/components/TxConfigForm/Form.tsx
|
|
2239
|
-
import { jsx as
|
|
2007
|
+
import { jsx as jsx38, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2240
2008
|
var Form = ({
|
|
2241
2009
|
dstChainId,
|
|
2242
2010
|
dstTokenAddr,
|
|
@@ -2301,7 +2069,7 @@ var Form = ({
|
|
|
2301
2069
|
`Configuration error: selected token ($${srcToken.symbol} ${srcToken.name}) has unknown decimals param.`
|
|
2302
2070
|
);
|
|
2303
2071
|
getRoute({
|
|
2304
|
-
fromAmount:
|
|
2072
|
+
fromAmount: ethers3.utils.parseUnits(debouncedAmount, srcToken.decimals).toString(),
|
|
2305
2073
|
fromAddress: signer || ADDRESSES[srcChain.chainId].FeeCollector,
|
|
2306
2074
|
fromChain: srcChain.chainId,
|
|
2307
2075
|
fromToken: srcToken.address,
|
|
@@ -2335,7 +2103,7 @@ var Form = ({
|
|
|
2335
2103
|
if (srcChain) {
|
|
2336
2104
|
setPaymentToken(
|
|
2337
2105
|
srcChain.tokens.find(
|
|
2338
|
-
(token) => token.address.toLowerCase() ===
|
|
2106
|
+
(token) => token.address.toLowerCase() === ethers3.constants.AddressZero.toLowerCase()
|
|
2339
2107
|
)
|
|
2340
2108
|
);
|
|
2341
2109
|
}
|
|
@@ -2366,13 +2134,13 @@ var Form = ({
|
|
|
2366
2134
|
const handleSwitchChain = async () => {
|
|
2367
2135
|
await switchChainAsync({ chainId: Number(srcChain?.chainId) });
|
|
2368
2136
|
};
|
|
2369
|
-
return /* @__PURE__ */
|
|
2137
|
+
return /* @__PURE__ */ jsxs17(
|
|
2370
2138
|
"form",
|
|
2371
2139
|
{
|
|
2372
2140
|
className: "flex flex-col gap-2 z-10 my-0 mx-auto p-4 rounded-3xl overflow-hidden font-light w-x_mobile sm:w-x_desktop",
|
|
2373
2141
|
onSubmit: handleSubmit,
|
|
2374
2142
|
children: [
|
|
2375
|
-
/* @__PURE__ */
|
|
2143
|
+
/* @__PURE__ */ jsx38(
|
|
2376
2144
|
TopBar,
|
|
2377
2145
|
{
|
|
2378
2146
|
signer,
|
|
@@ -2381,7 +2149,7 @@ var Form = ({
|
|
|
2381
2149
|
setSettingsShown
|
|
2382
2150
|
}
|
|
2383
2151
|
),
|
|
2384
|
-
settingsShown && /* @__PURE__ */
|
|
2152
|
+
settingsShown && /* @__PURE__ */ jsx38(
|
|
2385
2153
|
Settings,
|
|
2386
2154
|
{
|
|
2387
2155
|
expressChecked,
|
|
@@ -2391,9 +2159,9 @@ var Form = ({
|
|
|
2391
2159
|
setSlippage
|
|
2392
2160
|
}
|
|
2393
2161
|
),
|
|
2394
|
-
historyTabShown ? /* @__PURE__ */
|
|
2395
|
-
desc && /* @__PURE__ */
|
|
2396
|
-
/* @__PURE__ */
|
|
2162
|
+
historyTabShown ? /* @__PURE__ */ jsx38(History, { signer, supportedChains }) : /* @__PURE__ */ jsxs17("div", { className: "flex flex-col gap-2", children: [
|
|
2163
|
+
desc && /* @__PURE__ */ jsx38(Description, { description: desc }),
|
|
2164
|
+
/* @__PURE__ */ jsx38(
|
|
2397
2165
|
SwapPanel,
|
|
2398
2166
|
{
|
|
2399
2167
|
amount,
|
|
@@ -2408,7 +2176,7 @@ var Form = ({
|
|
|
2408
2176
|
setSrcChain
|
|
2409
2177
|
}
|
|
2410
2178
|
),
|
|
2411
|
-
/* @__PURE__ */
|
|
2179
|
+
/* @__PURE__ */ jsx38(
|
|
2412
2180
|
Summary,
|
|
2413
2181
|
{
|
|
2414
2182
|
isGettingRoute,
|
|
@@ -2417,7 +2185,7 @@ var Form = ({
|
|
|
2417
2185
|
dstChain
|
|
2418
2186
|
}
|
|
2419
2187
|
),
|
|
2420
|
-
/* @__PURE__ */
|
|
2188
|
+
/* @__PURE__ */ jsx38(
|
|
2421
2189
|
FeesDetails,
|
|
2422
2190
|
{
|
|
2423
2191
|
route,
|
|
@@ -2430,8 +2198,8 @@ var Form = ({
|
|
|
2430
2198
|
setFeesDetailsShown
|
|
2431
2199
|
}
|
|
2432
2200
|
),
|
|
2433
|
-
formError.length > 0 && /* @__PURE__ */
|
|
2434
|
-
signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */
|
|
2201
|
+
formError.length > 0 && /* @__PURE__ */ jsx38(ErrorField, { error: formError }),
|
|
2202
|
+
signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ jsx38(Button, { type: "button", onClick: handleSwitchChain, children: "Switch chain" }) : /* @__PURE__ */ jsx38(
|
|
2435
2203
|
Button,
|
|
2436
2204
|
{
|
|
2437
2205
|
type: "submit",
|
|
@@ -2445,11 +2213,8 @@ var Form = ({
|
|
|
2445
2213
|
);
|
|
2446
2214
|
};
|
|
2447
2215
|
|
|
2448
|
-
// package.json
|
|
2449
|
-
var version = "0.2.0";
|
|
2450
|
-
|
|
2451
2216
|
// src/components/TxConfigForm/index.tsx
|
|
2452
|
-
import { jsx as
|
|
2217
|
+
import { jsx as jsx39, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2453
2218
|
var TxConfigForm = ({
|
|
2454
2219
|
dstChainId,
|
|
2455
2220
|
dstTokenAddr,
|
|
@@ -2471,13 +2236,13 @@ var TxConfigForm = ({
|
|
|
2471
2236
|
() => getWagmiConfig(supportedChains),
|
|
2472
2237
|
supportedChains
|
|
2473
2238
|
);
|
|
2474
|
-
return /* @__PURE__ */
|
|
2239
|
+
return /* @__PURE__ */ jsx39(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx39(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx39(
|
|
2475
2240
|
"div",
|
|
2476
2241
|
{
|
|
2477
2242
|
className: "top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10",
|
|
2478
2243
|
onClick: onBackdropClick,
|
|
2479
|
-
children: /* @__PURE__ */
|
|
2480
|
-
/* @__PURE__ */
|
|
2244
|
+
children: /* @__PURE__ */ jsxs18("div", { className: "relative bg-black rounded-3xl w-lg overflow-auto text-white border-2 border-solid border-[rgba(255,255,255,0.1)]", children: [
|
|
2245
|
+
/* @__PURE__ */ jsx39(
|
|
2481
2246
|
Form,
|
|
2482
2247
|
{
|
|
2483
2248
|
dstChainId,
|
|
@@ -2488,20 +2253,15 @@ var TxConfigForm = ({
|
|
|
2488
2253
|
onSubmit
|
|
2489
2254
|
}
|
|
2490
2255
|
),
|
|
2491
|
-
/* @__PURE__ */
|
|
2256
|
+
/* @__PURE__ */ jsx39(
|
|
2492
2257
|
"div",
|
|
2493
2258
|
{
|
|
2494
2259
|
className: "absolute top-7 right-4 cursor-pointer text-white",
|
|
2495
2260
|
onClick: onClose,
|
|
2496
|
-
children: /* @__PURE__ */
|
|
2261
|
+
children: /* @__PURE__ */ jsx39(CloseIcon, {})
|
|
2497
2262
|
}
|
|
2498
2263
|
),
|
|
2499
|
-
/* @__PURE__ */
|
|
2500
|
-
/* @__PURE__ */ jsx38("span", { children: "Powered by" }),
|
|
2501
|
-
/* @__PURE__ */ jsx38(XSwapBadgeIcon, {}),
|
|
2502
|
-
/* @__PURE__ */ jsx38("span", { children: "\u2715" }),
|
|
2503
|
-
/* @__PURE__ */ jsx38(ChainlinkCCIPIcon, {})
|
|
2504
|
-
] })
|
|
2264
|
+
/* @__PURE__ */ jsx39(PoweredBy, {})
|
|
2505
2265
|
] })
|
|
2506
2266
|
}
|
|
2507
2267
|
) }) });
|
|
@@ -2516,7 +2276,7 @@ var openTxConfigForm = async ({
|
|
|
2516
2276
|
try {
|
|
2517
2277
|
return await new Promise((resolve) => {
|
|
2518
2278
|
xswapRoot.render(
|
|
2519
|
-
/* @__PURE__ */
|
|
2279
|
+
/* @__PURE__ */ jsx39(
|
|
2520
2280
|
TxConfigForm,
|
|
2521
2281
|
{
|
|
2522
2282
|
dstChainId,
|
|
@@ -2539,24 +2299,11 @@ var openTxConfigForm = async ({
|
|
|
2539
2299
|
throw new Error(`XSwap component error, ${err}`);
|
|
2540
2300
|
}
|
|
2541
2301
|
};
|
|
2542
|
-
var xswapRoot;
|
|
2543
|
-
if (typeof document !== "undefined") {
|
|
2544
|
-
const xswapStyleElement = document.createElement("link");
|
|
2545
|
-
xswapStyleElement.rel = "stylesheet";
|
|
2546
|
-
xswapStyleElement.type = "text/css";
|
|
2547
|
-
xswapStyleElement.href = `${xswap_config_default.apiUrl}/sdk/css/${version}`;
|
|
2548
|
-
document.head.appendChild(xswapStyleElement);
|
|
2549
|
-
const xswapModalElement = document.createElement("div");
|
|
2550
|
-
xswapModalElement.setAttribute("id", "xswap-modal");
|
|
2551
|
-
document.body.appendChild(xswapModalElement);
|
|
2552
|
-
xswapRoot = createRoot(xswapModalElement);
|
|
2553
|
-
}
|
|
2554
2302
|
|
|
2555
|
-
// src/components/
|
|
2556
|
-
import { useState as useState9 } from "react";
|
|
2557
|
-
import {
|
|
2558
|
-
|
|
2559
|
-
var TxHistoryButton = ({ transaction }) => {
|
|
2303
|
+
// src/components/TxStatusButton/index.tsx
|
|
2304
|
+
import { useMemo as useMemo8, useState as useState9 } from "react";
|
|
2305
|
+
import { Fragment as Fragment6, jsx as jsx40, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2306
|
+
var TxStatusButton = ({ transaction }) => {
|
|
2560
2307
|
const {
|
|
2561
2308
|
fromChain,
|
|
2562
2309
|
fromChainImage,
|
|
@@ -2570,15 +2317,23 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2570
2317
|
explorer
|
|
2571
2318
|
} = transaction;
|
|
2572
2319
|
const [isWide, setIsWide] = useState9(false);
|
|
2573
|
-
|
|
2574
|
-
|
|
2320
|
+
const background = useMemo8(
|
|
2321
|
+
() => 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)]",
|
|
2322
|
+
[isDone]
|
|
2323
|
+
);
|
|
2324
|
+
const border = useMemo8(
|
|
2325
|
+
() => isDone ? "border border-solid border-x_green_dark" : "border border-solid border-x_blue_dark",
|
|
2326
|
+
[isDone]
|
|
2327
|
+
);
|
|
2328
|
+
return /* @__PURE__ */ jsxs19("div", { className: "flex gap-2", onClick: () => setIsWide((x) => !x), children: [
|
|
2329
|
+
isWide && /* @__PURE__ */ jsxs19(
|
|
2575
2330
|
"div",
|
|
2576
2331
|
{
|
|
2577
|
-
className: `flex items-center min-w-60 sm:w-[520px] text-white h-14 px-4 text-sm gap-3 rounded-xl
|
|
2332
|
+
className: `flex items-center min-w-60 sm:w-[520px] text-white h-14 px-4 text-sm gap-3 rounded-xl ${background} ${border}`,
|
|
2578
2333
|
children: [
|
|
2579
|
-
/* @__PURE__ */
|
|
2580
|
-
/* @__PURE__ */
|
|
2581
|
-
/* @__PURE__ */
|
|
2334
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex justify-between flex-col gap-2 sm:gap-5 sm:flex-row w-full", children: [
|
|
2335
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
|
|
2336
|
+
/* @__PURE__ */ jsx40(
|
|
2582
2337
|
"img",
|
|
2583
2338
|
{
|
|
2584
2339
|
className: "w-5 h-5",
|
|
@@ -2586,16 +2341,16 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2586
2341
|
alt: "source chain"
|
|
2587
2342
|
}
|
|
2588
2343
|
),
|
|
2589
|
-
/* @__PURE__ */
|
|
2590
|
-
/* @__PURE__ */
|
|
2591
|
-
/* @__PURE__ */
|
|
2592
|
-
/* @__PURE__ */
|
|
2344
|
+
/* @__PURE__ */ jsx40("div", { children: fromChain }),
|
|
2345
|
+
/* @__PURE__ */ jsx40("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx40(ArrowRightIcon, {}) }),
|
|
2346
|
+
/* @__PURE__ */ jsx40("img", { className: "w-5 h-5", src: toChainImage, alt: "to chain" }),
|
|
2347
|
+
/* @__PURE__ */ jsx40("div", { children: toChain })
|
|
2593
2348
|
] }),
|
|
2594
|
-
/* @__PURE__ */
|
|
2595
|
-
/* @__PURE__ */
|
|
2596
|
-
/* @__PURE__ */
|
|
2597
|
-
/* @__PURE__ */
|
|
2598
|
-
/* @__PURE__ */
|
|
2349
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
|
|
2350
|
+
/* @__PURE__ */ jsx40("div", { children: "Sent" }),
|
|
2351
|
+
/* @__PURE__ */ jsx40("div", { children: fromAmount }),
|
|
2352
|
+
/* @__PURE__ */ jsx40("div", { children: fromToken }),
|
|
2353
|
+
/* @__PURE__ */ jsx40(
|
|
2599
2354
|
"img",
|
|
2600
2355
|
{
|
|
2601
2356
|
className: "w-5 h-5",
|
|
@@ -2605,7 +2360,7 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2605
2360
|
)
|
|
2606
2361
|
] })
|
|
2607
2362
|
] }),
|
|
2608
|
-
/* @__PURE__ */
|
|
2363
|
+
/* @__PURE__ */ jsx40(
|
|
2609
2364
|
"a",
|
|
2610
2365
|
{
|
|
2611
2366
|
href: explorer,
|
|
@@ -2613,22 +2368,21 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2613
2368
|
rel: "noreferrer",
|
|
2614
2369
|
className: "no-underline cursor-pointer",
|
|
2615
2370
|
"aria-label": "Show the transaction in the chain explorer",
|
|
2616
|
-
children: /* @__PURE__ */
|
|
2371
|
+
children: /* @__PURE__ */ jsx40("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx40(ArrowUpRightIcon, {}) })
|
|
2617
2372
|
}
|
|
2618
2373
|
)
|
|
2619
2374
|
]
|
|
2620
2375
|
}
|
|
2621
2376
|
),
|
|
2622
|
-
/* @__PURE__ */
|
|
2377
|
+
/* @__PURE__ */ jsx40(
|
|
2623
2378
|
"div",
|
|
2624
2379
|
{
|
|
2625
|
-
className: `text-white rounded-xl cursor-pointer
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
/* @__PURE__ */
|
|
2629
|
-
|
|
2630
|
-
/* @__PURE__ */
|
|
2631
|
-
/* @__PURE__ */ jsx39("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ jsx39(CircularProgressIcon, {}) })
|
|
2380
|
+
className: `text-white rounded-xl cursor-pointer ${background} ${border}`,
|
|
2381
|
+
children: /* @__PURE__ */ jsxs19("div", { className: "flex gap-2 items-center h-14 w-20 justify-center", children: [
|
|
2382
|
+
/* @__PURE__ */ jsx40(ArrowLeftIcon, {}),
|
|
2383
|
+
/* @__PURE__ */ jsx40("div", { className: "relative flex items-center justify-center w-9 h-9", children: isDone ? /* @__PURE__ */ jsx40("div", { className: "text-x_green w-5 h-5", children: /* @__PURE__ */ jsx40(CheckIcon, {}) }) : /* @__PURE__ */ jsxs19(Fragment6, { children: [
|
|
2384
|
+
/* @__PURE__ */ jsx40("div", { className: "w-5 h-5", children: /* @__PURE__ */ jsx40(XSwapLogo, {}) }),
|
|
2385
|
+
/* @__PURE__ */ jsx40("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ jsx40(CircularProgressIcon, {}) })
|
|
2632
2386
|
] }) })
|
|
2633
2387
|
] })
|
|
2634
2388
|
}
|
|
@@ -2654,73 +2408,159 @@ var updateTransactionDoneInRenderedTransactions = (txHash) => {
|
|
|
2654
2408
|
transaction.isDone = true;
|
|
2655
2409
|
}
|
|
2656
2410
|
};
|
|
2657
|
-
var
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
"class",
|
|
2661
|
-
"absolute bottom-5 right-2 flex flex-col gap-3 pl-9 items-end w-full z-50"
|
|
2662
|
-
);
|
|
2663
|
-
document.body.appendChild(historyElement);
|
|
2664
|
-
var txHistoryButtonRoot = createRoot2(historyElement);
|
|
2665
|
-
var renderTxHistoryButtons = () => {
|
|
2666
|
-
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ jsx39(TxHistoryButton, { transaction: item }, item.txHash));
|
|
2667
|
-
txHistoryButtonRoot.render(buttons);
|
|
2411
|
+
var renderTxStatusButtons = () => {
|
|
2412
|
+
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ jsx40(TxStatusButton, { transaction: item }, item.txHash));
|
|
2413
|
+
txStatusRoot.render(buttons);
|
|
2668
2414
|
};
|
|
2669
2415
|
|
|
2670
2416
|
// src/components/Skeleton/index.tsx
|
|
2671
|
-
import { jsx as
|
|
2417
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
2672
2418
|
var Skeleton = ({ width, height }) => {
|
|
2673
|
-
return /* @__PURE__ */
|
|
2419
|
+
return /* @__PURE__ */ jsx41("div", { className: `bg-current rounded animate-pulse ${width} ${height}` });
|
|
2420
|
+
};
|
|
2421
|
+
|
|
2422
|
+
// src/services/integrations/monitoring.ts
|
|
2423
|
+
import retry from "async-retry";
|
|
2424
|
+
var monitorTransactionStatus = async (txChainId, txHash) => {
|
|
2425
|
+
const txReceipt = await getTxReceipt(txChainId, txHash);
|
|
2426
|
+
const supportedChains = (await getChains()).filter(
|
|
2427
|
+
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
2428
|
+
);
|
|
2429
|
+
const messageSentEvent = txReceipt.logs?.find((log) => {
|
|
2430
|
+
return log.topics[0] === ethers4.utils.id(MSG_SENT_EVENT_SIG);
|
|
2431
|
+
});
|
|
2432
|
+
if (!messageSentEvent) {
|
|
2433
|
+
throw new Error(
|
|
2434
|
+
`No transaction event found for chain ${txChainId} tx ${txHash}`
|
|
2435
|
+
);
|
|
2436
|
+
}
|
|
2437
|
+
const messageId = messageSentEvent?.topics[1];
|
|
2438
|
+
const iface = new ethers4.utils.Interface(MSG_SENT_EVENT_ABI);
|
|
2439
|
+
const decodedMessageSentEvent = iface.parseLog(messageSentEvent);
|
|
2440
|
+
if (!decodedMessageSentEvent) {
|
|
2441
|
+
throw new Error(
|
|
2442
|
+
`No transaction event arguments found for chain ${txChainId} tx ${txHash}`
|
|
2443
|
+
);
|
|
2444
|
+
}
|
|
2445
|
+
const srcChain = supportedChains.find(
|
|
2446
|
+
(chain) => chain.chainId === txChainId.toString()
|
|
2447
|
+
);
|
|
2448
|
+
const srcToken = srcChain?.tokens.find(
|
|
2449
|
+
(token) => token.address === decodedMessageSentEvent.args?.token.toString()
|
|
2450
|
+
);
|
|
2451
|
+
const dstChain = supportedChains.find(
|
|
2452
|
+
(chain) => chain.ccipChainId === decodedMessageSentEvent.args?.destinationChainSelector?.toString()
|
|
2453
|
+
);
|
|
2454
|
+
const dstChainId = dstChain?.chainId;
|
|
2455
|
+
if (!dstChainId) {
|
|
2456
|
+
throw new Error(`Unknown destination chain!`);
|
|
2457
|
+
}
|
|
2458
|
+
const transaction = {
|
|
2459
|
+
txHash,
|
|
2460
|
+
fromChain: srcChain?.displayName,
|
|
2461
|
+
fromChainImage: srcChain?.image,
|
|
2462
|
+
toChain: dstChain.displayName,
|
|
2463
|
+
toChainImage: dstChain.image,
|
|
2464
|
+
fromToken: srcToken?.symbol,
|
|
2465
|
+
fromTokenImage: srcToken?.image,
|
|
2466
|
+
fromAmount: weiToHumanReadable({
|
|
2467
|
+
amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
|
|
2468
|
+
decimals: srcToken?.decimals || 18,
|
|
2469
|
+
precisionFractionalPlaces: 4
|
|
2470
|
+
}),
|
|
2471
|
+
isDone: false,
|
|
2472
|
+
explorer: `${CCIP_EXPLORER}/tx/${txHash}`
|
|
2473
|
+
};
|
|
2474
|
+
addTransactionToRenderedTransactions(transaction);
|
|
2475
|
+
renderTxStatusButtons();
|
|
2476
|
+
const xSwapRouterOnDestinationAddress = ADDRESSES[dstChainId]?.XSwapRouter;
|
|
2477
|
+
if (!xSwapRouterOnDestinationAddress) {
|
|
2478
|
+
throw new Error(`Unknown destination XSwapRouter!`);
|
|
2479
|
+
}
|
|
2480
|
+
const xSwapRouterOnDestination = new ethers4.Contract(
|
|
2481
|
+
xSwapRouterOnDestinationAddress,
|
|
2482
|
+
MSG_RECEIVED_EVENT_ABI,
|
|
2483
|
+
ethers4.getDefaultProvider(
|
|
2484
|
+
supportedChains.find((chain) => chain.chainId === dstChainId)?.publicRpcUrls[0]
|
|
2485
|
+
)
|
|
2486
|
+
);
|
|
2487
|
+
const msgReceivedEventFilter = {
|
|
2488
|
+
address: xSwapRouterOnDestinationAddress,
|
|
2489
|
+
topics: [ethers4.utils.id(MSG_RECEIVED_EVENT_SIG), messageId]
|
|
2490
|
+
};
|
|
2491
|
+
const onSuccess = async () => {
|
|
2492
|
+
updateTransactionDoneInRenderedTransactions(txHash);
|
|
2493
|
+
renderTxStatusButtons();
|
|
2494
|
+
await new Promise(
|
|
2495
|
+
(resolve) => setTimeout(() => resolve(true), TX_RECEIPT_STATUS_LIFETIME)
|
|
2496
|
+
);
|
|
2497
|
+
removeTransactionFromRenderedTransactions(txHash);
|
|
2498
|
+
renderTxStatusButtons();
|
|
2499
|
+
};
|
|
2500
|
+
xSwapRouterOnDestination.once(msgReceivedEventFilter, () => onSuccess());
|
|
2501
|
+
};
|
|
2502
|
+
var getTxReceipt = async (txChainId, txHash) => {
|
|
2503
|
+
try {
|
|
2504
|
+
const chain = (await getChains()).find(
|
|
2505
|
+
(chain2) => chain2.chainId === txChainId
|
|
2506
|
+
);
|
|
2507
|
+
const provider = new ethers4.providers.JsonRpcProvider(
|
|
2508
|
+
chain?.publicRpcUrls[0]
|
|
2509
|
+
);
|
|
2510
|
+
return await retry(async () => {
|
|
2511
|
+
const txReceipt = await provider.getTransactionReceipt(txHash);
|
|
2512
|
+
if (!txReceipt) {
|
|
2513
|
+
throw new Error(`Couldn't fetch tx receipt`);
|
|
2514
|
+
}
|
|
2515
|
+
return txReceipt;
|
|
2516
|
+
});
|
|
2517
|
+
} catch (e) {
|
|
2518
|
+
throw new Error(
|
|
2519
|
+
`Couldn't fetch tx ${txHash} receipt on chain ${txChainId}`
|
|
2520
|
+
);
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
|
|
2524
|
+
// src/services/integrations/transactions.ts
|
|
2525
|
+
var getSwapTx = async ({
|
|
2526
|
+
dstChain,
|
|
2527
|
+
dstToken,
|
|
2528
|
+
customContractCalls = [],
|
|
2529
|
+
desc
|
|
2530
|
+
}) => {
|
|
2531
|
+
const supportedChains = (await getChains()).filter(
|
|
2532
|
+
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
2533
|
+
);
|
|
2534
|
+
validateSwapTxData(supportedChains, dstChain, dstToken);
|
|
2535
|
+
const route = await openTxConfigForm({
|
|
2536
|
+
dstChainId: dstChain,
|
|
2537
|
+
dstTokenAddr: dstToken,
|
|
2538
|
+
customContractCalls,
|
|
2539
|
+
desc,
|
|
2540
|
+
supportedChains
|
|
2541
|
+
});
|
|
2542
|
+
return route.transactions;
|
|
2543
|
+
};
|
|
2544
|
+
var validateSwapTxData = (supportedChains, dstChain, dstToken) => {
|
|
2545
|
+
const supportedDstChain = supportedChains.find(
|
|
2546
|
+
({ chainId }) => chainId === dstChain
|
|
2547
|
+
);
|
|
2548
|
+
if (!supportedDstChain) {
|
|
2549
|
+
throw new Error(`Provided chain '${dstChain}' is not supported`);
|
|
2550
|
+
}
|
|
2551
|
+
if (!supportedDstChain.tokens.some(({ address }) => address === dstToken)) {
|
|
2552
|
+
throw new Error(`Provided token '${dstToken}' is not supported`);
|
|
2553
|
+
}
|
|
2674
2554
|
};
|
|
2555
|
+
|
|
2556
|
+
// src/index.ts
|
|
2557
|
+
initDocument();
|
|
2675
2558
|
export {
|
|
2676
|
-
ADDRESSES,
|
|
2677
|
-
Alert,
|
|
2678
|
-
BALANCES_CHUNK_SIZE,
|
|
2679
|
-
BatchQueryAbi,
|
|
2680
|
-
CCIP_EXPLORER,
|
|
2681
2559
|
ContractName,
|
|
2682
|
-
DEFAULT_ECOSYSTEM,
|
|
2683
|
-
DEFAULT_SOURCE_CHAIN_ID,
|
|
2684
|
-
DELIVERY_TIME,
|
|
2685
|
-
ERC20Abi,
|
|
2686
|
-
EXPRESS_DELIVERY_TIME,
|
|
2687
2560
|
Ecosystem,
|
|
2688
2561
|
Environment,
|
|
2689
|
-
IERC20,
|
|
2690
|
-
MINIMUM_DISPLAYED_TOKEN_AMOUNT,
|
|
2691
|
-
NUMBER_INPUT_REGEX,
|
|
2692
|
-
ROUTE_TIMEOUT_MS,
|
|
2693
|
-
SLIPPAGE_PRESETS,
|
|
2694
|
-
Skeleton,
|
|
2695
|
-
TxHistoryButton,
|
|
2696
2562
|
Web3Environment,
|
|
2697
2563
|
XSwapCallType,
|
|
2698
|
-
addTransactionToRenderedTransactions,
|
|
2699
|
-
chunkArray,
|
|
2700
|
-
deepMergeObjects,
|
|
2701
|
-
findPlaceholderIndex,
|
|
2702
|
-
generateApproveTxData,
|
|
2703
|
-
generateRandomBigNumber,
|
|
2704
|
-
generateStakingCalls,
|
|
2705
|
-
generateUniqueRandomBigNumber,
|
|
2706
|
-
getBalanceOf,
|
|
2707
|
-
getBalances,
|
|
2708
|
-
getBridgeTokens,
|
|
2709
|
-
getChainData,
|
|
2710
|
-
getChains,
|
|
2711
|
-
getDate,
|
|
2712
|
-
getHistory,
|
|
2713
|
-
getPrices,
|
|
2714
|
-
getRoute,
|
|
2715
2564
|
getSwapTx,
|
|
2716
|
-
|
|
2717
|
-
monitorTransactionStatus,
|
|
2718
|
-
openTxConfigForm,
|
|
2719
|
-
removeTransactionFromRenderedTransactions,
|
|
2720
|
-
renderTxHistoryButtons,
|
|
2721
|
-
replaceNull,
|
|
2722
|
-
safeBigNumberFrom,
|
|
2723
|
-
shortAddress,
|
|
2724
|
-
updateTransactionDoneInRenderedTransactions,
|
|
2725
|
-
weiToHumanReadable
|
|
2565
|
+
monitorTransactionStatus
|
|
2726
2566
|
};
|