@xswap-link/sdk 0.2.1 → 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 +6 -0
- package/dist/index.css +19 -12
- package/dist/index.d.mts +2 -177
- package/dist/index.d.ts +2 -177
- package/dist/index.js +527 -756
- package/dist/index.mjs +525 -706
- package/package.json +1 -1
- package/src/components/TxConfigForm/PoweredBy.tsx +12 -0
- package/src/components/TxConfigForm/index.tsx +3 -27
- package/src/components/{TxHistoryButton → TxStatusButton}/index.tsx +7 -15
- 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/index.ts +6 -6
- package/src/services/integrations/monitoring.ts +4 -4
- 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 = [
|
|
@@ -583,17 +507,6 @@ var MSG_RECEIVED_EVENT_ABI = [
|
|
|
583
507
|
|
|
584
508
|
// src/utils/contracts.ts
|
|
585
509
|
var IERC20 = new ethers.utils.Interface(ERC20Abi);
|
|
586
|
-
var getBalanceOf = async (wallet, token, rpcUrl) => {
|
|
587
|
-
const provider = ethers.getDefaultProvider(rpcUrl);
|
|
588
|
-
if (token === ethers.constants.AddressZero) {
|
|
589
|
-
return ethers.utils.formatEther(await provider.getBalance(wallet));
|
|
590
|
-
}
|
|
591
|
-
const contract = new ethers.Contract(token, ERC20Abi, provider);
|
|
592
|
-
return ethers.utils.formatUnits(
|
|
593
|
-
await contract.balanceOf(wallet),
|
|
594
|
-
await contract.decimals()
|
|
595
|
-
);
|
|
596
|
-
};
|
|
597
510
|
var getBalances = async (chain, wallet) => {
|
|
598
511
|
return {
|
|
599
512
|
...await getNativeBalance(chain, wallet),
|
|
@@ -644,35 +557,6 @@ var getErc20Balances = async (chain, wallet) => {
|
|
|
644
557
|
});
|
|
645
558
|
return balances;
|
|
646
559
|
};
|
|
647
|
-
var generateApproveTxData = (tokenAddress, spender, amount) => {
|
|
648
|
-
return tokenAddress !== ethers.constants.AddressZero ? {
|
|
649
|
-
to: tokenAddress,
|
|
650
|
-
value: safeBigNumberFrom("0"),
|
|
651
|
-
data: IERC20.encodeFunctionData("approve", [spender, amount])
|
|
652
|
-
} : void 0;
|
|
653
|
-
};
|
|
654
|
-
var findPlaceholderIndex = (abi, funName, funParams, placeholderValue) => {
|
|
655
|
-
if (funParams.flat(Infinity).filter((param) => param === placeholderValue).length !== 1) {
|
|
656
|
-
throw new Error("Random placeholder value must be provided and unique.");
|
|
657
|
-
}
|
|
658
|
-
const iface = new ethers.utils.Interface(abi);
|
|
659
|
-
const functionFragment = iface.getFunction(funName);
|
|
660
|
-
if (!functionFragment) {
|
|
661
|
-
throw new Error(`Can't find function "${funName}" in provided ABI.`);
|
|
662
|
-
}
|
|
663
|
-
const encodedFunData = iface.encodeFunctionData(functionFragment, funParams);
|
|
664
|
-
const paramData = encodedFunData.slice(10);
|
|
665
|
-
const chunks = [];
|
|
666
|
-
for (let i = 0; i < paramData.length; i += 64) {
|
|
667
|
-
chunks.push(paramData.slice(i, i + 64));
|
|
668
|
-
}
|
|
669
|
-
const searchValue = placeholderValue.toHexString().slice(2).padStart(64, "0");
|
|
670
|
-
const result = chunks.findIndex((chunk) => chunk === searchValue);
|
|
671
|
-
if (result === -1) {
|
|
672
|
-
throw new Error("Randomized parameter not found in the encoded data.");
|
|
673
|
-
}
|
|
674
|
-
return result;
|
|
675
|
-
};
|
|
676
560
|
|
|
677
561
|
// src/utils/strings.ts
|
|
678
562
|
var shortAddress = (address) => {
|
|
@@ -684,19 +568,6 @@ var shortAddress = (address) => {
|
|
|
684
568
|
|
|
685
569
|
// src/utils/index.ts
|
|
686
570
|
import { format } from "date-fns";
|
|
687
|
-
var replaceNull = (values, newValue) => {
|
|
688
|
-
const modifiedValues = [...values];
|
|
689
|
-
for (let i = 0; i < modifiedValues.length; i++) {
|
|
690
|
-
if (Array.isArray(modifiedValues[i])) {
|
|
691
|
-
modifiedValues[i] = replaceNull(modifiedValues[i], newValue);
|
|
692
|
-
} else {
|
|
693
|
-
if (modifiedValues[i] === null) {
|
|
694
|
-
modifiedValues[i] = newValue;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
return modifiedValues;
|
|
699
|
-
};
|
|
700
571
|
var deepMergeObjects = (obj1, obj2) => {
|
|
701
572
|
for (const key in obj2) {
|
|
702
573
|
if (obj2.hasOwnProperty(key)) {
|
|
@@ -721,229 +592,79 @@ var getDate = (blockTimestamp) => {
|
|
|
721
592
|
return format(date, "d MMM yyyy HH:mm:ss");
|
|
722
593
|
};
|
|
723
594
|
|
|
724
|
-
// src/services/integrations/customCalls/staking.ts
|
|
725
|
-
var generateStakingCalls = ({
|
|
726
|
-
token,
|
|
727
|
-
staking,
|
|
728
|
-
stakingAbi,
|
|
729
|
-
stakingFunName,
|
|
730
|
-
stakingFunParams
|
|
731
|
-
}) => {
|
|
732
|
-
const flatStakingFunParams = stakingFunParams.flat(Infinity);
|
|
733
|
-
if (flatStakingFunParams.filter((param) => param === null).length !== 1) {
|
|
734
|
-
throw new Error(
|
|
735
|
-
"Exactly 1 'null' value should be provided in 'funParams' in order to override token balance"
|
|
736
|
-
);
|
|
737
|
-
}
|
|
738
|
-
const randomBigNumber = generateUniqueRandomBigNumber(
|
|
739
|
-
32,
|
|
740
|
-
flatStakingFunParams
|
|
741
|
-
);
|
|
742
|
-
const modifiedStakingFunParams = replaceNull(
|
|
743
|
-
stakingFunParams,
|
|
744
|
-
randomBigNumber
|
|
745
|
-
);
|
|
746
|
-
const approveFunParams = [staking, randomBigNumber];
|
|
747
|
-
const stakingApproveCall = {
|
|
748
|
-
callType: 1 /* FULL_TOKEN_BALANCE */,
|
|
749
|
-
target: token,
|
|
750
|
-
callData: IERC20.encodeFunctionData("approve", approveFunParams),
|
|
751
|
-
payload: ethers2.utils.defaultAbiCoder.encode(
|
|
752
|
-
["address", "uint256"],
|
|
753
|
-
[
|
|
754
|
-
token,
|
|
755
|
-
findPlaceholderIndex(
|
|
756
|
-
JSON.stringify(ERC20Abi),
|
|
757
|
-
"approve",
|
|
758
|
-
approveFunParams,
|
|
759
|
-
randomBigNumber
|
|
760
|
-
)
|
|
761
|
-
]
|
|
762
|
-
),
|
|
763
|
-
value: "0"
|
|
764
|
-
};
|
|
765
|
-
const stakingCall = {
|
|
766
|
-
callType: 1 /* FULL_TOKEN_BALANCE */,
|
|
767
|
-
target: staking,
|
|
768
|
-
callData: new ethers2.utils.Interface(stakingAbi).encodeFunctionData(
|
|
769
|
-
stakingFunName,
|
|
770
|
-
modifiedStakingFunParams
|
|
771
|
-
),
|
|
772
|
-
payload: ethers2.utils.defaultAbiCoder.encode(
|
|
773
|
-
["address", "uint256"],
|
|
774
|
-
[
|
|
775
|
-
token,
|
|
776
|
-
findPlaceholderIndex(
|
|
777
|
-
stakingAbi,
|
|
778
|
-
stakingFunName,
|
|
779
|
-
modifiedStakingFunParams,
|
|
780
|
-
randomBigNumber
|
|
781
|
-
)
|
|
782
|
-
]
|
|
783
|
-
),
|
|
784
|
-
value: "0"
|
|
785
|
-
};
|
|
786
|
-
return [stakingApproveCall, stakingCall];
|
|
787
|
-
};
|
|
788
|
-
|
|
789
595
|
// src/services/integrations/monitoring.ts
|
|
790
|
-
import { ethers as
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
});
|
|
800
|
-
if (!messageSentEvent) {
|
|
801
|
-
throw new Error(
|
|
802
|
-
`No transaction event found for chain ${txChainId} tx ${txHash}`
|
|
803
|
-
);
|
|
804
|
-
}
|
|
805
|
-
const messageId = messageSentEvent?.topics[1];
|
|
806
|
-
const iface = new ethers3.utils.Interface(MSG_SENT_EVENT_ABI);
|
|
807
|
-
const decodedMessageSentEvent = iface.parseLog(messageSentEvent);
|
|
808
|
-
if (!decodedMessageSentEvent) {
|
|
809
|
-
throw new Error(
|
|
810
|
-
`No transaction event arguments found for chain ${txChainId} tx ${txHash}`
|
|
811
|
-
);
|
|
812
|
-
}
|
|
813
|
-
const srcChain = supportedChains.find(
|
|
814
|
-
(chain) => chain.chainId === txChainId.toString()
|
|
815
|
-
);
|
|
816
|
-
const srcToken = srcChain?.tokens.find(
|
|
817
|
-
(token) => token.address === decodedMessageSentEvent.args?.token.toString()
|
|
818
|
-
);
|
|
819
|
-
const dstChain = supportedChains.find(
|
|
820
|
-
(chain) => chain.ccipChainId === decodedMessageSentEvent.args?.destinationChainSelector?.toString()
|
|
821
|
-
);
|
|
822
|
-
const dstChainId = dstChain?.chainId;
|
|
823
|
-
if (!dstChainId) {
|
|
824
|
-
throw new Error(`Unknown destination chain!`);
|
|
825
|
-
}
|
|
826
|
-
const transaction = {
|
|
827
|
-
txHash,
|
|
828
|
-
fromChain: srcChain?.displayName,
|
|
829
|
-
fromChainImage: srcChain?.image,
|
|
830
|
-
toChain: dstChain.displayName,
|
|
831
|
-
toChainImage: dstChain.image,
|
|
832
|
-
fromToken: srcToken?.symbol,
|
|
833
|
-
fromTokenImage: srcToken?.image,
|
|
834
|
-
fromAmount: weiToHumanReadable({
|
|
835
|
-
amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
|
|
836
|
-
decimals: srcToken?.decimals || 18,
|
|
837
|
-
precisionFractionalPlaces: 4
|
|
838
|
-
}),
|
|
839
|
-
isDone: false,
|
|
840
|
-
explorer: `${CCIP_EXPLORER}/tx/${txHash}`
|
|
841
|
-
};
|
|
842
|
-
addTransactionToRenderedTransactions(transaction);
|
|
843
|
-
renderTxHistoryButtons();
|
|
844
|
-
const xSwapRouterOnDestinationAddress = ADDRESSES[dstChainId]?.XSwapRouter;
|
|
845
|
-
if (!xSwapRouterOnDestinationAddress) {
|
|
846
|
-
throw new Error(`Unknown destination XSwapRouter!`);
|
|
847
|
-
}
|
|
848
|
-
const xSwapRouterOnDestination = new ethers3.Contract(
|
|
849
|
-
xSwapRouterOnDestinationAddress,
|
|
850
|
-
MSG_RECEIVED_EVENT_ABI,
|
|
851
|
-
ethers3.getDefaultProvider(
|
|
852
|
-
supportedChains.find((chain) => chain.chainId === dstChainId)?.publicRpcUrls[0]
|
|
853
|
-
)
|
|
854
|
-
);
|
|
855
|
-
const msgReceivedEventFilter = {
|
|
856
|
-
address: xSwapRouterOnDestinationAddress,
|
|
857
|
-
topics: [ethers3.utils.id(MSG_RECEIVED_EVENT_SIG), messageId]
|
|
858
|
-
};
|
|
859
|
-
const onSuccess = async () => {
|
|
860
|
-
updateTransactionDoneInRenderedTransactions(txHash);
|
|
861
|
-
renderTxHistoryButtons();
|
|
862
|
-
await new Promise(
|
|
863
|
-
(resolve) => setTimeout(() => resolve(true), TX_RECEIPT_STATUS_LIFETIME)
|
|
864
|
-
);
|
|
865
|
-
removeTransactionFromRenderedTransactions(txHash);
|
|
866
|
-
renderTxHistoryButtons();
|
|
867
|
-
};
|
|
868
|
-
xSwapRouterOnDestination.once(msgReceivedEventFilter, () => onSuccess());
|
|
869
|
-
};
|
|
870
|
-
var getTxReceipt = async (txChainId, txHash) => {
|
|
871
|
-
try {
|
|
872
|
-
const chain = (await getChains()).find(
|
|
873
|
-
(chain2) => chain2.chainId === txChainId
|
|
874
|
-
);
|
|
875
|
-
const provider = new ethers3.providers.JsonRpcProvider(
|
|
876
|
-
chain?.publicRpcUrls[0]
|
|
877
|
-
);
|
|
878
|
-
return await retry(async () => {
|
|
879
|
-
const txReceipt = await provider.getTransactionReceipt(txHash);
|
|
880
|
-
if (!txReceipt) {
|
|
881
|
-
throw new Error(`Couldn't fetch tx receipt`);
|
|
882
|
-
}
|
|
883
|
-
return txReceipt;
|
|
884
|
-
});
|
|
885
|
-
} catch (e) {
|
|
886
|
-
throw new Error(
|
|
887
|
-
`Couldn't fetch tx ${txHash} receipt on chain ${txChainId}`
|
|
888
|
-
);
|
|
889
|
-
}
|
|
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
|
+
] });
|
|
890
605
|
};
|
|
891
606
|
|
|
892
|
-
// src/
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
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";
|
|
611
|
+
|
|
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
|
+
]
|
|
909
629
|
});
|
|
910
|
-
return route.transactions;
|
|
911
630
|
};
|
|
912
|
-
var
|
|
913
|
-
const
|
|
914
|
-
|
|
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
|
+
)
|
|
915
637
|
);
|
|
916
|
-
|
|
917
|
-
throw new Error(`Provided chain '${dstChain}' is not supported`);
|
|
918
|
-
}
|
|
919
|
-
if (!supportedDstChain.tokens.some(({ address }) => address === dstToken)) {
|
|
920
|
-
throw new Error(`Provided token '${dstToken}' is not supported`);
|
|
921
|
-
}
|
|
638
|
+
return result;
|
|
922
639
|
};
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
930
|
-
timeoutRef.current = setTimeout(() => {
|
|
931
|
-
setValue(value);
|
|
932
|
-
}, delay);
|
|
933
|
-
return () => {
|
|
934
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
935
|
-
};
|
|
936
|
-
}, [value, delay]);
|
|
937
|
-
const [debouncedValue, setValue] = useState(value);
|
|
938
|
-
return debouncedValue;
|
|
640
|
+
var mapTransports = (chains) => {
|
|
641
|
+
const transports = {};
|
|
642
|
+
chains.forEach((chain) => {
|
|
643
|
+
transports[chain.id] = http();
|
|
644
|
+
});
|
|
645
|
+
return transports;
|
|
939
646
|
};
|
|
940
647
|
|
|
941
|
-
// src/components/
|
|
942
|
-
import {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
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
|
+
};
|
|
947
668
|
|
|
948
669
|
// src/components/icons/ArrowRightIcon.tsx
|
|
949
670
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -1361,8 +1082,46 @@ var XSwapLogo = () => {
|
|
|
1361
1082
|
);
|
|
1362
1083
|
};
|
|
1363
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
|
+
|
|
1364
1122
|
// src/components/TxConfigForm/HistoryCard.tsx
|
|
1365
|
-
import {
|
|
1123
|
+
import { useCallback, useMemo } from "react";
|
|
1124
|
+
import { Fragment, jsx as jsx24, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1366
1125
|
var HistoryCard = ({ transaction, supportedChains }) => {
|
|
1367
1126
|
const date = getDate(transaction.timestamp);
|
|
1368
1127
|
const supportedTokens = useMemo(() => {
|
|
@@ -1408,14 +1167,14 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1408
1167
|
const targetChainData = supportedChains.find(
|
|
1409
1168
|
(chain) => chain.chainId === transaction.targetChainId
|
|
1410
1169
|
);
|
|
1411
|
-
return /* @__PURE__ */
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */
|
|
1414
|
-
/* @__PURE__ */
|
|
1415
|
-
transaction.status === "IN_PROGRESS" && /* @__PURE__ */
|
|
1416
|
-
transaction.status === "DONE" && /* @__PURE__ */
|
|
1417
|
-
transaction.status === "REVERTED" && /* @__PURE__ */
|
|
1418
|
-
/* @__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(
|
|
1419
1178
|
"a",
|
|
1420
1179
|
{
|
|
1421
1180
|
href: `${supportedChains.find(
|
|
@@ -1425,15 +1184,15 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1425
1184
|
rel: "noreferrer",
|
|
1426
1185
|
className: "ml-2 no-underline",
|
|
1427
1186
|
"aria-label": "Show the transaction in the chain explorer",
|
|
1428
|
-
children: /* @__PURE__ */
|
|
1187
|
+
children: /* @__PURE__ */ jsx24("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx24(ArrowUpRightIcon, {}) })
|
|
1429
1188
|
}
|
|
1430
1189
|
)
|
|
1431
1190
|
] })
|
|
1432
1191
|
] }),
|
|
1433
|
-
/* @__PURE__ */
|
|
1434
|
-
/* @__PURE__ */
|
|
1435
|
-
/* @__PURE__ */
|
|
1436
|
-
/* @__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(
|
|
1437
1196
|
"img",
|
|
1438
1197
|
{
|
|
1439
1198
|
src: sourceChainData?.image,
|
|
@@ -1441,11 +1200,11 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1441
1200
|
className: "w-5 h-5 mr-1"
|
|
1442
1201
|
}
|
|
1443
1202
|
),
|
|
1444
|
-
/* @__PURE__ */
|
|
1203
|
+
/* @__PURE__ */ jsx24("div", { children: sourceChainData?.displayName })
|
|
1445
1204
|
] }),
|
|
1446
|
-
/* @__PURE__ */
|
|
1447
|
-
/* @__PURE__ */
|
|
1448
|
-
/* @__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(
|
|
1449
1208
|
"img",
|
|
1450
1209
|
{
|
|
1451
1210
|
src: targetChainData?.image,
|
|
@@ -1453,35 +1212,35 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1453
1212
|
className: "w-5 h-5 mr-1"
|
|
1454
1213
|
}
|
|
1455
1214
|
),
|
|
1456
|
-
/* @__PURE__ */
|
|
1215
|
+
/* @__PURE__ */ jsx24("div", { children: targetChainData?.displayName })
|
|
1457
1216
|
] })
|
|
1458
1217
|
] }),
|
|
1459
|
-
/* @__PURE__ */
|
|
1460
|
-
/* @__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: [
|
|
1461
1220
|
Number(transferredAmount) < MINIMUM_DISPLAYED_TOKEN_AMOUNT ? `<${MINIMUM_DISPLAYED_TOKEN_AMOUNT}` : transferredAmount,
|
|
1462
|
-
/* @__PURE__ */
|
|
1463
|
-
tokenData?.image ? /* @__PURE__ */
|
|
1221
|
+
/* @__PURE__ */ jsx24("div", { className: "ml-1", children: tokenData?.symbol }),
|
|
1222
|
+
tokenData?.image ? /* @__PURE__ */ jsx24(
|
|
1464
1223
|
"img",
|
|
1465
1224
|
{
|
|
1466
1225
|
src: tokenData?.image,
|
|
1467
1226
|
alt: tokenData?.name || "",
|
|
1468
1227
|
className: "w-5 h-5 ml-1"
|
|
1469
1228
|
}
|
|
1470
|
-
) : /* @__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) })
|
|
1471
1230
|
] }),
|
|
1472
|
-
transaction.tokenOutAddress && /* @__PURE__ */
|
|
1473
|
-
/* @__PURE__ */
|
|
1474
|
-
/* @__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: [
|
|
1475
1234
|
Number(receivedAmount) < 1e-4 ? "<0.0001" : receivedAmount,
|
|
1476
|
-
/* @__PURE__ */
|
|
1477
|
-
tokenOutData?.image ? /* @__PURE__ */
|
|
1235
|
+
/* @__PURE__ */ jsx24("div", { className: "ml-1", children: tokenOutData?.symbol }),
|
|
1236
|
+
tokenOutData?.image ? /* @__PURE__ */ jsx24(
|
|
1478
1237
|
"img",
|
|
1479
1238
|
{
|
|
1480
1239
|
src: tokenOutData?.image,
|
|
1481
1240
|
alt: tokenOutData?.name || "",
|
|
1482
1241
|
className: "w-5 h-5 ml-1"
|
|
1483
1242
|
}
|
|
1484
|
-
) : /* @__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) })
|
|
1485
1244
|
] })
|
|
1486
1245
|
] })
|
|
1487
1246
|
] }) })
|
|
@@ -1490,7 +1249,7 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1490
1249
|
};
|
|
1491
1250
|
|
|
1492
1251
|
// src/components/TxConfigForm/History.tsx
|
|
1493
|
-
import { jsx as
|
|
1252
|
+
import { jsx as jsx25, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1494
1253
|
var History = ({ signer, supportedChains }) => {
|
|
1495
1254
|
const [fetchedHistory, setFetchedHistory] = useState2();
|
|
1496
1255
|
const [historyLoadedOnce, setHistoryLoadedOnce] = useState2(false);
|
|
@@ -1542,11 +1301,11 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1542
1301
|
return () => clearInterval(timer);
|
|
1543
1302
|
}, [signer, fetchHistory, getHistory, historyLoadedOnce]);
|
|
1544
1303
|
if (!signer)
|
|
1545
|
-
return /* @__PURE__ */
|
|
1546
|
-
return /* @__PURE__ */
|
|
1547
|
-
fetchedHistory?.length === 0 && historyLoadedOnce && /* @__PURE__ */
|
|
1548
|
-
!fetchedHistory && !historyLoadedOnce && /* @__PURE__ */
|
|
1549
|
-
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(
|
|
1550
1309
|
HistoryCard,
|
|
1551
1310
|
{
|
|
1552
1311
|
transaction,
|
|
@@ -1558,30 +1317,30 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1558
1317
|
};
|
|
1559
1318
|
|
|
1560
1319
|
// src/components/TxConfigForm/TopBar.tsx
|
|
1561
|
-
import { Fragment as Fragment2, jsx as
|
|
1320
|
+
import { Fragment as Fragment2, jsx as jsx26, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1562
1321
|
var TopBar = ({
|
|
1563
1322
|
signer,
|
|
1564
1323
|
setSettingsShown,
|
|
1565
1324
|
setHistoryTabShown,
|
|
1566
1325
|
historyTabShown
|
|
1567
1326
|
}) => {
|
|
1568
|
-
return /* @__PURE__ */
|
|
1569
|
-
/* @__PURE__ */
|
|
1570
|
-
/* @__PURE__ */
|
|
1571
|
-
!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(
|
|
1572
1331
|
"div",
|
|
1573
1332
|
{
|
|
1574
1333
|
onClick: () => setSettingsShown(true),
|
|
1575
1334
|
className: "flex items-center text-xs gap-1 cursor-pointer",
|
|
1576
|
-
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, {}) })
|
|
1577
1336
|
}
|
|
1578
1337
|
),
|
|
1579
|
-
/* @__PURE__ */
|
|
1338
|
+
/* @__PURE__ */ jsx26(
|
|
1580
1339
|
"div",
|
|
1581
1340
|
{
|
|
1582
1341
|
onClick: () => setHistoryTabShown((x) => !x),
|
|
1583
1342
|
className: "flex items-center text-sm gap-1 cursor-pointer",
|
|
1584
|
-
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" })
|
|
1585
1344
|
}
|
|
1586
1345
|
)
|
|
1587
1346
|
] })
|
|
@@ -1590,7 +1349,7 @@ var TopBar = ({
|
|
|
1590
1349
|
|
|
1591
1350
|
// src/components/TxConfigForm/Settings.tsx
|
|
1592
1351
|
import { useState as useState3, useEffect as useEffect3 } from "react";
|
|
1593
|
-
import { jsx as
|
|
1352
|
+
import { jsx as jsx27, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1594
1353
|
var Settings = ({
|
|
1595
1354
|
setSlippage,
|
|
1596
1355
|
setSettingsShown,
|
|
@@ -1607,22 +1366,22 @@ var Settings = ({
|
|
|
1607
1366
|
);
|
|
1608
1367
|
}
|
|
1609
1368
|
}, [slippageActivePresetIndex, usingSlippageInput]);
|
|
1610
|
-
return /* @__PURE__ */
|
|
1611
|
-
/* @__PURE__ */
|
|
1612
|
-
/* @__PURE__ */
|
|
1613
|
-
/* @__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(
|
|
1614
1373
|
"div",
|
|
1615
1374
|
{
|
|
1616
1375
|
className: "cursor-pointer",
|
|
1617
1376
|
onClick: () => setSettingsShown(false),
|
|
1618
|
-
children: /* @__PURE__ */
|
|
1377
|
+
children: /* @__PURE__ */ jsx27(CloseIcon, {})
|
|
1619
1378
|
}
|
|
1620
1379
|
)
|
|
1621
1380
|
] }),
|
|
1622
|
-
/* @__PURE__ */
|
|
1623
|
-
/* @__PURE__ */
|
|
1624
|
-
/* @__PURE__ */
|
|
1625
|
-
/* @__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(
|
|
1626
1385
|
"span",
|
|
1627
1386
|
{
|
|
1628
1387
|
className: "inline-flex w-14 h-9 p-3 relative align-middle box-border overflow-hidden cursor-pointer",
|
|
@@ -1630,8 +1389,8 @@ var Settings = ({
|
|
|
1630
1389
|
setExpressChecked((x) => !x);
|
|
1631
1390
|
},
|
|
1632
1391
|
children: [
|
|
1633
|
-
/* @__PURE__ */
|
|
1634
|
-
/* @__PURE__ */
|
|
1392
|
+
/* @__PURE__ */ jsx27("span", { className: "h-full, w-full rounded-lg bg-[rgba(255,255,255,0.3)]" }),
|
|
1393
|
+
/* @__PURE__ */ jsx27(
|
|
1635
1394
|
"span",
|
|
1636
1395
|
{
|
|
1637
1396
|
className: `transition-all w-5 h-5 rounded-full absolute translate-y-[-4px]
|
|
@@ -1642,15 +1401,15 @@ var Settings = ({
|
|
|
1642
1401
|
}
|
|
1643
1402
|
) })
|
|
1644
1403
|
] }),
|
|
1645
|
-
/* @__PURE__ */
|
|
1646
|
-
/* @__PURE__ */
|
|
1647
|
-
/* @__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." })
|
|
1648
1407
|
] })
|
|
1649
1408
|
] }),
|
|
1650
|
-
/* @__PURE__ */
|
|
1651
|
-
/* @__PURE__ */
|
|
1652
|
-
/* @__PURE__ */
|
|
1653
|
-
/* @__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(
|
|
1654
1413
|
"div",
|
|
1655
1414
|
{
|
|
1656
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]" : ""}`,
|
|
@@ -1662,8 +1421,8 @@ var Settings = ({
|
|
|
1662
1421
|
},
|
|
1663
1422
|
index
|
|
1664
1423
|
)) }),
|
|
1665
|
-
/* @__PURE__ */
|
|
1666
|
-
/* @__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(
|
|
1667
1426
|
"input",
|
|
1668
1427
|
{
|
|
1669
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",
|
|
@@ -1682,16 +1441,16 @@ var Settings = ({
|
|
|
1682
1441
|
}
|
|
1683
1442
|
}
|
|
1684
1443
|
),
|
|
1685
|
-
/* @__PURE__ */
|
|
1444
|
+
/* @__PURE__ */ jsx27(PercentageIcon, {})
|
|
1686
1445
|
] })
|
|
1687
1446
|
] }),
|
|
1688
|
-
/* @__PURE__ */
|
|
1689
|
-
/* @__PURE__ */
|
|
1690
|
-
/* @__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: [
|
|
1691
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.",
|
|
1692
|
-
/* @__PURE__ */
|
|
1451
|
+
/* @__PURE__ */ jsx27("br", {}),
|
|
1693
1452
|
" ",
|
|
1694
|
-
/* @__PURE__ */
|
|
1453
|
+
/* @__PURE__ */ jsx27("br", {}),
|
|
1695
1454
|
"If the trade fails due to too-low slippage, you will receive USDC on the destination chain."
|
|
1696
1455
|
] })
|
|
1697
1456
|
] })
|
|
@@ -1700,7 +1459,7 @@ var Settings = ({
|
|
|
1700
1459
|
};
|
|
1701
1460
|
|
|
1702
1461
|
// src/components/TxConfigForm/FeesDetails.tsx
|
|
1703
|
-
import { jsx as
|
|
1462
|
+
import { jsx as jsx28, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1704
1463
|
var FeesDetails = ({
|
|
1705
1464
|
isGettingRoute,
|
|
1706
1465
|
route,
|
|
@@ -1711,12 +1470,12 @@ var FeesDetails = ({
|
|
|
1711
1470
|
feesDetailsShown,
|
|
1712
1471
|
setFeesDetailsShown
|
|
1713
1472
|
}) => {
|
|
1714
|
-
return /* @__PURE__ */
|
|
1715
|
-
/* @__PURE__ */
|
|
1716
|
-
/* @__PURE__ */
|
|
1717
|
-
/* @__PURE__ */
|
|
1718
|
-
/* @__PURE__ */
|
|
1719
|
-
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({
|
|
1720
1479
|
amount: safeBigNumberFrom(
|
|
1721
1480
|
route?.xSwapFees.xSwapFee.nativeFee || "0"
|
|
1722
1481
|
).add(safeBigNumberFrom(route?.xSwapFees.ccipFee || "0")).add(
|
|
@@ -1726,30 +1485,30 @@ var FeesDetails = ({
|
|
|
1726
1485
|
precisionFractionalPlaces: 5
|
|
1727
1486
|
})} ${paymentToken?.symbol}`
|
|
1728
1487
|
] }),
|
|
1729
|
-
/* @__PURE__ */
|
|
1730
|
-
/* @__PURE__ */
|
|
1488
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex gap-1 items-center", children: [
|
|
1489
|
+
/* @__PURE__ */ jsxs11(
|
|
1731
1490
|
"div",
|
|
1732
1491
|
{
|
|
1733
1492
|
className: `flex gap-1 items-center font-medium ${expressChecked ? "text-x_green" : "text-white opacity-60"}`,
|
|
1734
1493
|
children: [
|
|
1735
|
-
/* @__PURE__ */
|
|
1494
|
+
/* @__PURE__ */ jsx28(TimerIcon, {}),
|
|
1736
1495
|
expressChecked ? "Fast ~ 30sec " : "Normal ~ 30min"
|
|
1737
1496
|
]
|
|
1738
1497
|
}
|
|
1739
1498
|
),
|
|
1740
|
-
/* @__PURE__ */
|
|
1499
|
+
/* @__PURE__ */ jsx28(
|
|
1741
1500
|
"div",
|
|
1742
1501
|
{
|
|
1743
1502
|
onClick: () => setFeesDetailsShown((x) => !x),
|
|
1744
1503
|
className: "font-medium text-white opacity-60 cursor-pointer flex items-center w-[15px] h-[9px]",
|
|
1745
|
-
children: feesDetailsShown ? /* @__PURE__ */
|
|
1504
|
+
children: feesDetailsShown ? /* @__PURE__ */ jsx28(ChevronUpIcon, {}) : /* @__PURE__ */ jsx28(ChevronDownIcon, {})
|
|
1746
1505
|
}
|
|
1747
1506
|
)
|
|
1748
1507
|
] })
|
|
1749
1508
|
] }),
|
|
1750
|
-
feesDetailsShown && /* @__PURE__ */
|
|
1751
|
-
/* @__PURE__ */
|
|
1752
|
-
/* @__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: [
|
|
1753
1512
|
"CCIP Fee:",
|
|
1754
1513
|
` ${weiToHumanReadable({
|
|
1755
1514
|
amount: route?.xSwapFees.ccipFee || "0",
|
|
@@ -1757,7 +1516,7 @@ var FeesDetails = ({
|
|
|
1757
1516
|
precisionFractionalPlaces: 5
|
|
1758
1517
|
})} ${paymentToken?.symbol}`
|
|
1759
1518
|
] }),
|
|
1760
|
-
/* @__PURE__ */
|
|
1519
|
+
/* @__PURE__ */ jsxs11("div", { className: "font-medium text-white opacity-60", children: [
|
|
1761
1520
|
"Native Fee:",
|
|
1762
1521
|
` ${weiToHumanReadable({
|
|
1763
1522
|
amount: route?.xSwapFees.xSwapFee.nativeFee || "0",
|
|
@@ -1766,12 +1525,12 @@ var FeesDetails = ({
|
|
|
1766
1525
|
})} ${paymentToken?.symbol}`
|
|
1767
1526
|
] })
|
|
1768
1527
|
] }),
|
|
1769
|
-
/* @__PURE__ */
|
|
1770
|
-
/* @__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: [
|
|
1771
1530
|
"Slippage: ",
|
|
1772
1531
|
`${slippage}%`
|
|
1773
1532
|
] }),
|
|
1774
|
-
/* @__PURE__ */
|
|
1533
|
+
/* @__PURE__ */ jsxs11("div", { className: "font-medium text-white opacity-60", children: [
|
|
1775
1534
|
"Min amount out:",
|
|
1776
1535
|
" ",
|
|
1777
1536
|
weiToHumanReadable({
|
|
@@ -1792,7 +1551,7 @@ import { useEffect as useEffect5, useMemo as useMemo3, useState as useState5 } f
|
|
|
1792
1551
|
|
|
1793
1552
|
// src/components/TxConfigForm/UsdPrice.tsx
|
|
1794
1553
|
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
1795
|
-
import { Fragment as Fragment3, jsx as
|
|
1554
|
+
import { Fragment as Fragment3, jsx as jsx29 } from "react/jsx-runtime";
|
|
1796
1555
|
var UsdPrice = ({
|
|
1797
1556
|
prices,
|
|
1798
1557
|
token,
|
|
@@ -1805,11 +1564,11 @@ var UsdPrice = ({
|
|
|
1805
1564
|
setUsdPrice((Number(amount) * Number(prices[token.address])).toFixed(2));
|
|
1806
1565
|
}
|
|
1807
1566
|
}, [token, prices, amount]);
|
|
1808
|
-
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" }) });
|
|
1809
1568
|
};
|
|
1810
1569
|
|
|
1811
1570
|
// src/components/TxConfigForm/Summary.tsx
|
|
1812
|
-
import { jsx as
|
|
1571
|
+
import { jsx as jsx30, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1813
1572
|
var Summary = ({
|
|
1814
1573
|
isGettingRoute,
|
|
1815
1574
|
route,
|
|
@@ -1832,32 +1591,32 @@ var Summary = ({
|
|
|
1832
1591
|
);
|
|
1833
1592
|
}
|
|
1834
1593
|
}, [dstChain]);
|
|
1835
|
-
return /* @__PURE__ */
|
|
1836
|
-
/* @__PURE__ */
|
|
1837
|
-
/* @__PURE__ */
|
|
1838
|
-
/* @__PURE__ */
|
|
1839
|
-
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(
|
|
1840
1599
|
Skeleton,
|
|
1841
1600
|
{
|
|
1842
1601
|
width: "w-[100px]",
|
|
1843
1602
|
height: "h-[36px]",
|
|
1844
1603
|
other: "sm:w-[190px]"
|
|
1845
1604
|
}
|
|
1846
|
-
) : /* @__PURE__ */
|
|
1605
|
+
) : /* @__PURE__ */ jsxs12("div", { className: "flex gap-2 items-center text-white text-xl sm:text-3xl", children: [
|
|
1847
1606
|
amountReadable,
|
|
1848
|
-
/* @__PURE__ */
|
|
1849
|
-
/* @__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 })
|
|
1850
1609
|
] })
|
|
1851
1610
|
] }),
|
|
1852
|
-
/* @__PURE__ */
|
|
1853
|
-
/* @__PURE__ */
|
|
1854
|
-
/* @__PURE__ */
|
|
1855
|
-
/* @__PURE__ */
|
|
1856
|
-
/* @__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 })
|
|
1857
1616
|
] })
|
|
1858
1617
|
] })
|
|
1859
1618
|
] }),
|
|
1860
|
-
/* @__PURE__ */
|
|
1619
|
+
/* @__PURE__ */ jsx30(
|
|
1861
1620
|
UsdPrice,
|
|
1862
1621
|
{
|
|
1863
1622
|
prices,
|
|
@@ -1866,7 +1625,7 @@ var Summary = ({
|
|
|
1866
1625
|
loading: isGettingRoute
|
|
1867
1626
|
}
|
|
1868
1627
|
),
|
|
1869
|
-
/* @__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, {}) }) })
|
|
1870
1629
|
] });
|
|
1871
1630
|
};
|
|
1872
1631
|
|
|
@@ -1876,7 +1635,7 @@ import { useState as useState7, useEffect as useEffect6, useRef as useRef2, useM
|
|
|
1876
1635
|
// src/components/TxConfigForm/TokenPicker.tsx
|
|
1877
1636
|
import { useState as useState6, useMemo as useMemo4 } from "react";
|
|
1878
1637
|
import { createPortal } from "react-dom";
|
|
1879
|
-
import { Fragment as Fragment4, jsx as
|
|
1638
|
+
import { Fragment as Fragment4, jsx as jsx31, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1880
1639
|
var TokenPicker = ({
|
|
1881
1640
|
onCloseClick,
|
|
1882
1641
|
tokens,
|
|
@@ -1903,24 +1662,24 @@ var TokenPicker = ({
|
|
|
1903
1662
|
);
|
|
1904
1663
|
}, [searchValue, tokens]);
|
|
1905
1664
|
return modalRoot ? createPortal(
|
|
1906
|
-
/* @__PURE__ */
|
|
1665
|
+
/* @__PURE__ */ jsx31(
|
|
1907
1666
|
"div",
|
|
1908
1667
|
{
|
|
1909
1668
|
onClick: onBackdropClick,
|
|
1910
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",
|
|
1911
|
-
children: /* @__PURE__ */
|
|
1912
|
-
/* @__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(
|
|
1913
1672
|
"div",
|
|
1914
1673
|
{
|
|
1915
1674
|
onClick: onCloseClick,
|
|
1916
1675
|
className: "absolute top-4 right-4 cursor-pointer",
|
|
1917
|
-
children: /* @__PURE__ */
|
|
1676
|
+
children: /* @__PURE__ */ jsx31(CloseIcon, {})
|
|
1918
1677
|
}
|
|
1919
1678
|
),
|
|
1920
|
-
/* @__PURE__ */
|
|
1921
|
-
/* @__PURE__ */
|
|
1922
|
-
/* @__PURE__ */
|
|
1923
|
-
/* @__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(
|
|
1924
1683
|
"input",
|
|
1925
1684
|
{
|
|
1926
1685
|
placeholder: "Search name or paste address",
|
|
@@ -1930,7 +1689,7 @@ var TokenPicker = ({
|
|
|
1930
1689
|
}
|
|
1931
1690
|
)
|
|
1932
1691
|
] }),
|
|
1933
|
-
/* @__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(
|
|
1934
1693
|
"div",
|
|
1935
1694
|
{
|
|
1936
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)]" : ""}`,
|
|
@@ -1939,14 +1698,14 @@ var TokenPicker = ({
|
|
|
1939
1698
|
onCloseClick();
|
|
1940
1699
|
},
|
|
1941
1700
|
children: [
|
|
1942
|
-
/* @__PURE__ */
|
|
1943
|
-
/* @__PURE__ */
|
|
1701
|
+
/* @__PURE__ */ jsx31("img", { src: token.image, alt: token.name, className: "w-5" }),
|
|
1702
|
+
/* @__PURE__ */ jsx31("div", { className: "text-sm", children: token.symbol })
|
|
1944
1703
|
]
|
|
1945
1704
|
},
|
|
1946
1705
|
token.address
|
|
1947
1706
|
)) }),
|
|
1948
|
-
/* @__PURE__ */
|
|
1949
|
-
/* @__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(
|
|
1950
1709
|
"div",
|
|
1951
1710
|
{
|
|
1952
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)]" : ""}`,
|
|
@@ -1955,29 +1714,29 @@ var TokenPicker = ({
|
|
|
1955
1714
|
onCloseClick();
|
|
1956
1715
|
},
|
|
1957
1716
|
children: [
|
|
1958
|
-
token.image ? /* @__PURE__ */
|
|
1717
|
+
token.image ? /* @__PURE__ */ jsx31(
|
|
1959
1718
|
"img",
|
|
1960
1719
|
{
|
|
1961
1720
|
src: token.image,
|
|
1962
1721
|
alt: token.name,
|
|
1963
1722
|
className: "token-picker__all__logo"
|
|
1964
1723
|
}
|
|
1965
|
-
) : /* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
1967
|
-
/* @__PURE__ */
|
|
1968
|
-
/* @__PURE__ */
|
|
1969
|
-
/* @__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 })
|
|
1970
1729
|
] }),
|
|
1971
|
-
signer && /* @__PURE__ */
|
|
1730
|
+
signer && /* @__PURE__ */ jsx31(Fragment4, { children: balances && balances[token.address] && token.decimals ? /* @__PURE__ */ jsx31("div", { className: "text-xs", children: weiToHumanReadable({
|
|
1972
1731
|
amount: balances[token.address]?.toString() || "0",
|
|
1973
1732
|
decimals: token.decimals,
|
|
1974
1733
|
precisionFractionalPlaces: 4
|
|
1975
|
-
}) }) : /* @__PURE__ */
|
|
1734
|
+
}) }) : /* @__PURE__ */ jsx31(Skeleton, { width: "w-12", height: "h-3" }) })
|
|
1976
1735
|
] })
|
|
1977
1736
|
]
|
|
1978
1737
|
},
|
|
1979
1738
|
`${index}_${token.address}`
|
|
1980
|
-
)) : /* @__PURE__ */
|
|
1739
|
+
)) : /* @__PURE__ */ jsx31("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx31("p", { className: "text-sm text-white", children: "No tokens found." }) }) })
|
|
1981
1740
|
] })
|
|
1982
1741
|
}
|
|
1983
1742
|
),
|
|
@@ -1986,7 +1745,7 @@ var TokenPicker = ({
|
|
|
1986
1745
|
};
|
|
1987
1746
|
|
|
1988
1747
|
// src/components/TxConfigForm/ChainListElement.tsx
|
|
1989
|
-
import { jsx as
|
|
1748
|
+
import { jsx as jsx32, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1990
1749
|
var ChainListElement = ({
|
|
1991
1750
|
chain,
|
|
1992
1751
|
setSrcChain,
|
|
@@ -1994,8 +1753,8 @@ var ChainListElement = ({
|
|
|
1994
1753
|
index,
|
|
1995
1754
|
length
|
|
1996
1755
|
}) => {
|
|
1997
|
-
return /* @__PURE__ */
|
|
1998
|
-
/* @__PURE__ */
|
|
1756
|
+
return /* @__PURE__ */ jsxs14("div", { children: [
|
|
1757
|
+
/* @__PURE__ */ jsxs14(
|
|
1999
1758
|
"li",
|
|
2000
1759
|
{
|
|
2001
1760
|
className: "bg-transparent border-none flex gap-1 items-center cursor-pointer py-2 w-full",
|
|
@@ -2004,19 +1763,19 @@ var ChainListElement = ({
|
|
|
2004
1763
|
setChainListShown(false);
|
|
2005
1764
|
},
|
|
2006
1765
|
children: [
|
|
2007
|
-
/* @__PURE__ */
|
|
1766
|
+
/* @__PURE__ */ jsx32("img", { width: 12, height: 12, src: chain.image, alt: chain.displayName }),
|
|
2008
1767
|
chain.displayName
|
|
2009
1768
|
]
|
|
2010
1769
|
}
|
|
2011
1770
|
),
|
|
2012
|
-
index !== length - 1 && /* @__PURE__ */
|
|
1771
|
+
index !== length - 1 && /* @__PURE__ */ jsx32("div", { className: "h-px mx-2 bg-[rgba(255,255,255,0.15)]" })
|
|
2013
1772
|
] }, `${chain.ecosystem}-${chain.chainId}`);
|
|
2014
1773
|
};
|
|
2015
1774
|
|
|
2016
1775
|
// src/components/TxConfigForm/BalanceComponent.tsx
|
|
2017
1776
|
import { useMemo as useMemo5 } from "react";
|
|
2018
1777
|
import BigNumber3 from "bignumber.js";
|
|
2019
|
-
import { Fragment as Fragment5, jsx as
|
|
1778
|
+
import { Fragment as Fragment5, jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2020
1779
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
2021
1780
|
const balanceText = useMemo5(() => {
|
|
2022
1781
|
if (!balances || !srcToken) return "0";
|
|
@@ -2036,7 +1795,7 @@ var BalanceComponent = ({ srcToken, balances }) => {
|
|
|
2036
1795
|
precisionFractionalPlaces: 5
|
|
2037
1796
|
});
|
|
2038
1797
|
}, [srcToken, balances]);
|
|
2039
|
-
return /* @__PURE__ */
|
|
1798
|
+
return /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
2040
1799
|
"Balance:",
|
|
2041
1800
|
" ",
|
|
2042
1801
|
srcToken && balances ? weiToHumanReadable({
|
|
@@ -2044,12 +1803,12 @@ var BalanceComponent = ({ srcToken, balances }) => {
|
|
|
2044
1803
|
decimals: srcToken.decimals,
|
|
2045
1804
|
precisionFractionalPlaces: 4
|
|
2046
1805
|
}) : 0,
|
|
2047
|
-
/* @__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" })
|
|
2048
1807
|
] });
|
|
2049
1808
|
};
|
|
2050
1809
|
|
|
2051
1810
|
// src/components/TxConfigForm/SwapPanel.tsx
|
|
2052
|
-
import { jsx as
|
|
1811
|
+
import { jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2053
1812
|
var SwapPanel = ({
|
|
2054
1813
|
amount,
|
|
2055
1814
|
setAmount,
|
|
@@ -2094,11 +1853,11 @@ var SwapPanel = ({
|
|
|
2094
1853
|
() => supportedChains.filter((chain) => chain.chainId !== srcChain?.chainId),
|
|
2095
1854
|
[supportedChains, srcChain]
|
|
2096
1855
|
);
|
|
2097
|
-
return /* @__PURE__ */
|
|
2098
|
-
/* @__PURE__ */
|
|
2099
|
-
/* @__PURE__ */
|
|
2100
|
-
/* @__PURE__ */
|
|
2101
|
-
/* @__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(
|
|
2102
1861
|
"input",
|
|
2103
1862
|
{
|
|
2104
1863
|
className: "p-0 border-none outline-none bg-transparent text-2xl overflow-ellipsis",
|
|
@@ -2117,7 +1876,7 @@ var SwapPanel = ({
|
|
|
2117
1876
|
}
|
|
2118
1877
|
)
|
|
2119
1878
|
] }),
|
|
2120
|
-
/* @__PURE__ */
|
|
1879
|
+
/* @__PURE__ */ jsx34("div", { className: "flex items-center text-sm text-[rgba(255,255,255,0.6)]", children: /* @__PURE__ */ jsx34(
|
|
2121
1880
|
UsdPrice,
|
|
2122
1881
|
{
|
|
2123
1882
|
prices,
|
|
@@ -2127,8 +1886,8 @@ var SwapPanel = ({
|
|
|
2127
1886
|
}
|
|
2128
1887
|
) })
|
|
2129
1888
|
] }),
|
|
2130
|
-
/* @__PURE__ */
|
|
2131
|
-
/* @__PURE__ */
|
|
1889
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex flex-col relative items-end gap-2.5 w-1/2 text-xs", children: [
|
|
1890
|
+
/* @__PURE__ */ jsxs16(
|
|
2132
1891
|
"div",
|
|
2133
1892
|
{
|
|
2134
1893
|
className: "flex gap-2 items-center p-2 max-w-full cursor-pointer bg-black text-white globalBorder rounded-3xl whitespace-nowrap",
|
|
@@ -2136,7 +1895,7 @@ var SwapPanel = ({
|
|
|
2136
1895
|
setTokenListShown((state) => !state);
|
|
2137
1896
|
},
|
|
2138
1897
|
children: [
|
|
2139
|
-
/* @__PURE__ */
|
|
1898
|
+
/* @__PURE__ */ jsx34(
|
|
2140
1899
|
"img",
|
|
2141
1900
|
{
|
|
2142
1901
|
height: 16,
|
|
@@ -2145,12 +1904,12 @@ var SwapPanel = ({
|
|
|
2145
1904
|
alt: srcToken?.name
|
|
2146
1905
|
}
|
|
2147
1906
|
),
|
|
2148
|
-
/* @__PURE__ */
|
|
2149
|
-
/* @__PURE__ */
|
|
1907
|
+
/* @__PURE__ */ jsx34("div", { children: srcToken?.symbol }),
|
|
1908
|
+
/* @__PURE__ */ jsx34(DownArrowIcon, {})
|
|
2150
1909
|
]
|
|
2151
1910
|
}
|
|
2152
1911
|
),
|
|
2153
|
-
tokenListShown && /* @__PURE__ */
|
|
1912
|
+
tokenListShown && /* @__PURE__ */ jsx34(
|
|
2154
1913
|
TokenPicker,
|
|
2155
1914
|
{
|
|
2156
1915
|
onCloseClick: () => setTokenListShown(false),
|
|
@@ -2161,22 +1920,22 @@ var SwapPanel = ({
|
|
|
2161
1920
|
balances
|
|
2162
1921
|
}
|
|
2163
1922
|
),
|
|
2164
|
-
/* @__PURE__ */
|
|
1923
|
+
/* @__PURE__ */ jsx34(
|
|
2165
1924
|
"div",
|
|
2166
1925
|
{
|
|
2167
1926
|
onClick: handleMaxClick,
|
|
2168
1927
|
className: "flex gap-1 items-center font-medium text-white opacity-60 py-0.5 cursor-pointer",
|
|
2169
|
-
children: signer && /* @__PURE__ */
|
|
1928
|
+
children: signer && /* @__PURE__ */ jsx34(BalanceComponent, { balances, srcToken })
|
|
2170
1929
|
}
|
|
2171
1930
|
),
|
|
2172
|
-
/* @__PURE__ */
|
|
1931
|
+
/* @__PURE__ */ jsxs16(
|
|
2173
1932
|
"div",
|
|
2174
1933
|
{
|
|
2175
1934
|
ref: buttonRef,
|
|
2176
1935
|
className: "bg-black globalBorder rounded-2xl whitespace-nowrap flex items-center p-2 cursor-pointer gap-2",
|
|
2177
1936
|
onClick: () => setChainListShown((prev) => !prev),
|
|
2178
1937
|
children: [
|
|
2179
|
-
/* @__PURE__ */
|
|
1938
|
+
/* @__PURE__ */ jsx34(
|
|
2180
1939
|
"img",
|
|
2181
1940
|
{
|
|
2182
1941
|
width: "16",
|
|
@@ -2185,17 +1944,17 @@ var SwapPanel = ({
|
|
|
2185
1944
|
alt: srcChain?.name
|
|
2186
1945
|
}
|
|
2187
1946
|
),
|
|
2188
|
-
/* @__PURE__ */
|
|
2189
|
-
/* @__PURE__ */
|
|
1947
|
+
/* @__PURE__ */ jsx34("div", { children: srcChain?.displayName }),
|
|
1948
|
+
/* @__PURE__ */ jsx34(DownArrowIcon, {})
|
|
2190
1949
|
]
|
|
2191
1950
|
}
|
|
2192
1951
|
),
|
|
2193
|
-
chainListShown && /* @__PURE__ */
|
|
1952
|
+
chainListShown && /* @__PURE__ */ jsx34(
|
|
2194
1953
|
"ul",
|
|
2195
1954
|
{
|
|
2196
1955
|
ref: listRef,
|
|
2197
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",
|
|
2198
|
-
children: chainListOptions.map((chain, index) => /* @__PURE__ */
|
|
1957
|
+
children: chainListOptions.map((chain, index) => /* @__PURE__ */ jsx34(
|
|
2199
1958
|
ChainListElement,
|
|
2200
1959
|
{
|
|
2201
1960
|
index,
|
|
@@ -2212,9 +1971,9 @@ var SwapPanel = ({
|
|
|
2212
1971
|
};
|
|
2213
1972
|
|
|
2214
1973
|
// src/components/TxConfigForm/ErrorField.tsx
|
|
2215
|
-
import { jsx as
|
|
1974
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
2216
1975
|
var ErrorField = ({ error }) => {
|
|
2217
|
-
return /* @__PURE__ */
|
|
1976
|
+
return /* @__PURE__ */ jsx35(
|
|
2218
1977
|
"div",
|
|
2219
1978
|
{
|
|
2220
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"}`,
|
|
@@ -2224,15 +1983,15 @@ var ErrorField = ({ error }) => {
|
|
|
2224
1983
|
};
|
|
2225
1984
|
|
|
2226
1985
|
// src/components/TxConfigForm/Description.tsx
|
|
2227
|
-
import { jsx as
|
|
1986
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
2228
1987
|
var Description = ({ description }) => {
|
|
2229
|
-
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 }) });
|
|
2230
1989
|
};
|
|
2231
1990
|
|
|
2232
1991
|
// src/components/TxConfigForm/Button.tsx
|
|
2233
|
-
import { jsx as
|
|
1992
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
2234
1993
|
var Button = ({ children, onClick, type, disabled }) => {
|
|
2235
|
-
return /* @__PURE__ */
|
|
1994
|
+
return /* @__PURE__ */ jsx37(
|
|
2236
1995
|
"button",
|
|
2237
1996
|
{
|
|
2238
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",
|
|
@@ -2245,7 +2004,7 @@ var Button = ({ children, onClick, type, disabled }) => {
|
|
|
2245
2004
|
};
|
|
2246
2005
|
|
|
2247
2006
|
// src/components/TxConfigForm/Form.tsx
|
|
2248
|
-
import { jsx as
|
|
2007
|
+
import { jsx as jsx38, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2249
2008
|
var Form = ({
|
|
2250
2009
|
dstChainId,
|
|
2251
2010
|
dstTokenAddr,
|
|
@@ -2310,7 +2069,7 @@ var Form = ({
|
|
|
2310
2069
|
`Configuration error: selected token ($${srcToken.symbol} ${srcToken.name}) has unknown decimals param.`
|
|
2311
2070
|
);
|
|
2312
2071
|
getRoute({
|
|
2313
|
-
fromAmount:
|
|
2072
|
+
fromAmount: ethers3.utils.parseUnits(debouncedAmount, srcToken.decimals).toString(),
|
|
2314
2073
|
fromAddress: signer || ADDRESSES[srcChain.chainId].FeeCollector,
|
|
2315
2074
|
fromChain: srcChain.chainId,
|
|
2316
2075
|
fromToken: srcToken.address,
|
|
@@ -2344,7 +2103,7 @@ var Form = ({
|
|
|
2344
2103
|
if (srcChain) {
|
|
2345
2104
|
setPaymentToken(
|
|
2346
2105
|
srcChain.tokens.find(
|
|
2347
|
-
(token) => token.address.toLowerCase() ===
|
|
2106
|
+
(token) => token.address.toLowerCase() === ethers3.constants.AddressZero.toLowerCase()
|
|
2348
2107
|
)
|
|
2349
2108
|
);
|
|
2350
2109
|
}
|
|
@@ -2375,13 +2134,13 @@ var Form = ({
|
|
|
2375
2134
|
const handleSwitchChain = async () => {
|
|
2376
2135
|
await switchChainAsync({ chainId: Number(srcChain?.chainId) });
|
|
2377
2136
|
};
|
|
2378
|
-
return /* @__PURE__ */
|
|
2137
|
+
return /* @__PURE__ */ jsxs17(
|
|
2379
2138
|
"form",
|
|
2380
2139
|
{
|
|
2381
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",
|
|
2382
2141
|
onSubmit: handleSubmit,
|
|
2383
2142
|
children: [
|
|
2384
|
-
/* @__PURE__ */
|
|
2143
|
+
/* @__PURE__ */ jsx38(
|
|
2385
2144
|
TopBar,
|
|
2386
2145
|
{
|
|
2387
2146
|
signer,
|
|
@@ -2390,7 +2149,7 @@ var Form = ({
|
|
|
2390
2149
|
setSettingsShown
|
|
2391
2150
|
}
|
|
2392
2151
|
),
|
|
2393
|
-
settingsShown && /* @__PURE__ */
|
|
2152
|
+
settingsShown && /* @__PURE__ */ jsx38(
|
|
2394
2153
|
Settings,
|
|
2395
2154
|
{
|
|
2396
2155
|
expressChecked,
|
|
@@ -2400,9 +2159,9 @@ var Form = ({
|
|
|
2400
2159
|
setSlippage
|
|
2401
2160
|
}
|
|
2402
2161
|
),
|
|
2403
|
-
historyTabShown ? /* @__PURE__ */
|
|
2404
|
-
desc && /* @__PURE__ */
|
|
2405
|
-
/* @__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(
|
|
2406
2165
|
SwapPanel,
|
|
2407
2166
|
{
|
|
2408
2167
|
amount,
|
|
@@ -2417,7 +2176,7 @@ var Form = ({
|
|
|
2417
2176
|
setSrcChain
|
|
2418
2177
|
}
|
|
2419
2178
|
),
|
|
2420
|
-
/* @__PURE__ */
|
|
2179
|
+
/* @__PURE__ */ jsx38(
|
|
2421
2180
|
Summary,
|
|
2422
2181
|
{
|
|
2423
2182
|
isGettingRoute,
|
|
@@ -2426,7 +2185,7 @@ var Form = ({
|
|
|
2426
2185
|
dstChain
|
|
2427
2186
|
}
|
|
2428
2187
|
),
|
|
2429
|
-
/* @__PURE__ */
|
|
2188
|
+
/* @__PURE__ */ jsx38(
|
|
2430
2189
|
FeesDetails,
|
|
2431
2190
|
{
|
|
2432
2191
|
route,
|
|
@@ -2439,8 +2198,8 @@ var Form = ({
|
|
|
2439
2198
|
setFeesDetailsShown
|
|
2440
2199
|
}
|
|
2441
2200
|
),
|
|
2442
|
-
formError.length > 0 && /* @__PURE__ */
|
|
2443
|
-
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(
|
|
2444
2203
|
Button,
|
|
2445
2204
|
{
|
|
2446
2205
|
type: "submit",
|
|
@@ -2454,11 +2213,8 @@ var Form = ({
|
|
|
2454
2213
|
);
|
|
2455
2214
|
};
|
|
2456
2215
|
|
|
2457
|
-
// package.json
|
|
2458
|
-
var version = "0.2.1";
|
|
2459
|
-
|
|
2460
2216
|
// src/components/TxConfigForm/index.tsx
|
|
2461
|
-
import { jsx as
|
|
2217
|
+
import { jsx as jsx39, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2462
2218
|
var TxConfigForm = ({
|
|
2463
2219
|
dstChainId,
|
|
2464
2220
|
dstTokenAddr,
|
|
@@ -2480,13 +2236,13 @@ var TxConfigForm = ({
|
|
|
2480
2236
|
() => getWagmiConfig(supportedChains),
|
|
2481
2237
|
supportedChains
|
|
2482
2238
|
);
|
|
2483
|
-
return /* @__PURE__ */
|
|
2239
|
+
return /* @__PURE__ */ jsx39(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx39(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx39(
|
|
2484
2240
|
"div",
|
|
2485
2241
|
{
|
|
2486
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",
|
|
2487
2243
|
onClick: onBackdropClick,
|
|
2488
|
-
children: /* @__PURE__ */
|
|
2489
|
-
/* @__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(
|
|
2490
2246
|
Form,
|
|
2491
2247
|
{
|
|
2492
2248
|
dstChainId,
|
|
@@ -2497,20 +2253,15 @@ var TxConfigForm = ({
|
|
|
2497
2253
|
onSubmit
|
|
2498
2254
|
}
|
|
2499
2255
|
),
|
|
2500
|
-
/* @__PURE__ */
|
|
2256
|
+
/* @__PURE__ */ jsx39(
|
|
2501
2257
|
"div",
|
|
2502
2258
|
{
|
|
2503
2259
|
className: "absolute top-7 right-4 cursor-pointer text-white",
|
|
2504
2260
|
onClick: onClose,
|
|
2505
|
-
children: /* @__PURE__ */
|
|
2261
|
+
children: /* @__PURE__ */ jsx39(CloseIcon, {})
|
|
2506
2262
|
}
|
|
2507
2263
|
),
|
|
2508
|
-
/* @__PURE__ */
|
|
2509
|
-
/* @__PURE__ */ jsx38("span", { children: "Powered by" }),
|
|
2510
|
-
/* @__PURE__ */ jsx38(XSwapBadgeIcon, {}),
|
|
2511
|
-
/* @__PURE__ */ jsx38("span", { children: "\u2715" }),
|
|
2512
|
-
/* @__PURE__ */ jsx38(ChainlinkCCIPIcon, {})
|
|
2513
|
-
] })
|
|
2264
|
+
/* @__PURE__ */ jsx39(PoweredBy, {})
|
|
2514
2265
|
] })
|
|
2515
2266
|
}
|
|
2516
2267
|
) }) });
|
|
@@ -2525,7 +2276,7 @@ var openTxConfigForm = async ({
|
|
|
2525
2276
|
try {
|
|
2526
2277
|
return await new Promise((resolve) => {
|
|
2527
2278
|
xswapRoot.render(
|
|
2528
|
-
/* @__PURE__ */
|
|
2279
|
+
/* @__PURE__ */ jsx39(
|
|
2529
2280
|
TxConfigForm,
|
|
2530
2281
|
{
|
|
2531
2282
|
dstChainId,
|
|
@@ -2548,24 +2299,11 @@ var openTxConfigForm = async ({
|
|
|
2548
2299
|
throw new Error(`XSwap component error, ${err}`);
|
|
2549
2300
|
}
|
|
2550
2301
|
};
|
|
2551
|
-
var xswapRoot;
|
|
2552
|
-
if (typeof document !== "undefined") {
|
|
2553
|
-
const xswapStyleElement = document.createElement("link");
|
|
2554
|
-
xswapStyleElement.rel = "stylesheet";
|
|
2555
|
-
xswapStyleElement.type = "text/css";
|
|
2556
|
-
xswapStyleElement.href = `${xswap_config_default.apiUrl}/sdk/css?data={"version": "${version}"}`;
|
|
2557
|
-
document.head.appendChild(xswapStyleElement);
|
|
2558
|
-
const xswapModalElement = document.createElement("div");
|
|
2559
|
-
xswapModalElement.setAttribute("id", "xswap-modal");
|
|
2560
|
-
document.body.appendChild(xswapModalElement);
|
|
2561
|
-
xswapRoot = createRoot(xswapModalElement);
|
|
2562
|
-
}
|
|
2563
2302
|
|
|
2564
|
-
// src/components/
|
|
2303
|
+
// src/components/TxStatusButton/index.tsx
|
|
2565
2304
|
import { useMemo as useMemo8, useState as useState9 } from "react";
|
|
2566
|
-
import {
|
|
2567
|
-
|
|
2568
|
-
var TxHistoryButton = ({ transaction }) => {
|
|
2305
|
+
import { Fragment as Fragment6, jsx as jsx40, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2306
|
+
var TxStatusButton = ({ transaction }) => {
|
|
2569
2307
|
const {
|
|
2570
2308
|
fromChain,
|
|
2571
2309
|
fromChainImage,
|
|
@@ -2587,15 +2325,15 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2587
2325
|
() => isDone ? "border border-solid border-x_green_dark" : "border border-solid border-x_blue_dark",
|
|
2588
2326
|
[isDone]
|
|
2589
2327
|
);
|
|
2590
|
-
return /* @__PURE__ */
|
|
2591
|
-
isWide && /* @__PURE__ */
|
|
2328
|
+
return /* @__PURE__ */ jsxs19("div", { className: "flex gap-2", onClick: () => setIsWide((x) => !x), children: [
|
|
2329
|
+
isWide && /* @__PURE__ */ jsxs19(
|
|
2592
2330
|
"div",
|
|
2593
2331
|
{
|
|
2594
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}`,
|
|
2595
2333
|
children: [
|
|
2596
|
-
/* @__PURE__ */
|
|
2597
|
-
/* @__PURE__ */
|
|
2598
|
-
/* @__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(
|
|
2599
2337
|
"img",
|
|
2600
2338
|
{
|
|
2601
2339
|
className: "w-5 h-5",
|
|
@@ -2603,16 +2341,16 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2603
2341
|
alt: "source chain"
|
|
2604
2342
|
}
|
|
2605
2343
|
),
|
|
2606
|
-
/* @__PURE__ */
|
|
2607
|
-
/* @__PURE__ */
|
|
2608
|
-
/* @__PURE__ */
|
|
2609
|
-
/* @__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 })
|
|
2610
2348
|
] }),
|
|
2611
|
-
/* @__PURE__ */
|
|
2612
|
-
/* @__PURE__ */
|
|
2613
|
-
/* @__PURE__ */
|
|
2614
|
-
/* @__PURE__ */
|
|
2615
|
-
/* @__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(
|
|
2616
2354
|
"img",
|
|
2617
2355
|
{
|
|
2618
2356
|
className: "w-5 h-5",
|
|
@@ -2622,7 +2360,7 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2622
2360
|
)
|
|
2623
2361
|
] })
|
|
2624
2362
|
] }),
|
|
2625
|
-
/* @__PURE__ */
|
|
2363
|
+
/* @__PURE__ */ jsx40(
|
|
2626
2364
|
"a",
|
|
2627
2365
|
{
|
|
2628
2366
|
href: explorer,
|
|
@@ -2630,21 +2368,21 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2630
2368
|
rel: "noreferrer",
|
|
2631
2369
|
className: "no-underline cursor-pointer",
|
|
2632
2370
|
"aria-label": "Show the transaction in the chain explorer",
|
|
2633
|
-
children: /* @__PURE__ */
|
|
2371
|
+
children: /* @__PURE__ */ jsx40("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ jsx40(ArrowUpRightIcon, {}) })
|
|
2634
2372
|
}
|
|
2635
2373
|
)
|
|
2636
2374
|
]
|
|
2637
2375
|
}
|
|
2638
2376
|
),
|
|
2639
|
-
/* @__PURE__ */
|
|
2377
|
+
/* @__PURE__ */ jsx40(
|
|
2640
2378
|
"div",
|
|
2641
2379
|
{
|
|
2642
2380
|
className: `text-white rounded-xl cursor-pointer ${background} ${border}`,
|
|
2643
|
-
children: /* @__PURE__ */
|
|
2644
|
-
/* @__PURE__ */
|
|
2645
|
-
/* @__PURE__ */
|
|
2646
|
-
/* @__PURE__ */
|
|
2647
|
-
/* @__PURE__ */
|
|
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, {}) })
|
|
2648
2386
|
] }) })
|
|
2649
2387
|
] })
|
|
2650
2388
|
}
|
|
@@ -2670,78 +2408,159 @@ var updateTransactionDoneInRenderedTransactions = (txHash) => {
|
|
|
2670
2408
|
transaction.isDone = true;
|
|
2671
2409
|
}
|
|
2672
2410
|
};
|
|
2673
|
-
var
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
"class",
|
|
2677
|
-
"absolute bottom-5 right-2 flex flex-col gap-3 pl-9 items-end w-full z-50"
|
|
2678
|
-
);
|
|
2679
|
-
document.body.appendChild(historyElement);
|
|
2680
|
-
var txHistoryButtonRoot = createRoot2(historyElement);
|
|
2681
|
-
var renderTxHistoryButtons = () => {
|
|
2682
|
-
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ jsx39(TxHistoryButton, { transaction: item }, item.txHash));
|
|
2683
|
-
txHistoryButtonRoot.render(buttons);
|
|
2411
|
+
var renderTxStatusButtons = () => {
|
|
2412
|
+
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ jsx40(TxStatusButton, { transaction: item }, item.txHash));
|
|
2413
|
+
txStatusRoot.render(buttons);
|
|
2684
2414
|
};
|
|
2685
2415
|
|
|
2686
2416
|
// src/components/Skeleton/index.tsx
|
|
2687
|
-
import { jsx as
|
|
2417
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
2688
2418
|
var Skeleton = ({ width, height }) => {
|
|
2689
|
-
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
|
+
}
|
|
2690
2554
|
};
|
|
2555
|
+
|
|
2556
|
+
// src/index.ts
|
|
2557
|
+
initDocument();
|
|
2691
2558
|
export {
|
|
2692
|
-
ADDRESSES,
|
|
2693
|
-
Alert,
|
|
2694
|
-
BALANCES_CHUNK_SIZE,
|
|
2695
|
-
BatchQueryAbi,
|
|
2696
|
-
CCIP_EXPLORER,
|
|
2697
2559
|
ContractName,
|
|
2698
|
-
DEFAULT_ECOSYSTEM,
|
|
2699
|
-
DEFAULT_SOURCE_CHAIN_ID,
|
|
2700
|
-
DELIVERY_TIME,
|
|
2701
|
-
ERC20Abi,
|
|
2702
|
-
EXPRESS_DELIVERY_TIME,
|
|
2703
2560
|
Ecosystem,
|
|
2704
2561
|
Environment,
|
|
2705
|
-
IERC20,
|
|
2706
|
-
MINIMUM_DISPLAYED_TOKEN_AMOUNT,
|
|
2707
|
-
MSG_RECEIVED_EVENT_ABI,
|
|
2708
|
-
MSG_RECEIVED_EVENT_SIG,
|
|
2709
|
-
MSG_SENT_EVENT_ABI,
|
|
2710
|
-
MSG_SENT_EVENT_SIG,
|
|
2711
|
-
NUMBER_INPUT_REGEX,
|
|
2712
|
-
ROUTE_TIMEOUT_MS,
|
|
2713
|
-
SLIPPAGE_PRESETS,
|
|
2714
|
-
Skeleton,
|
|
2715
|
-
TX_RECEIPT_STATUS_LIFETIME,
|
|
2716
|
-
TxHistoryButton,
|
|
2717
2562
|
Web3Environment,
|
|
2718
2563
|
XSwapCallType,
|
|
2719
|
-
addTransactionToRenderedTransactions,
|
|
2720
|
-
chunkArray,
|
|
2721
|
-
deepMergeObjects,
|
|
2722
|
-
findPlaceholderIndex,
|
|
2723
|
-
generateApproveTxData,
|
|
2724
|
-
generateRandomBigNumber,
|
|
2725
|
-
generateStakingCalls,
|
|
2726
|
-
generateUniqueRandomBigNumber,
|
|
2727
|
-
getBalanceOf,
|
|
2728
|
-
getBalances,
|
|
2729
|
-
getBridgeTokens,
|
|
2730
|
-
getChainData,
|
|
2731
|
-
getChains,
|
|
2732
|
-
getDate,
|
|
2733
|
-
getHistory,
|
|
2734
|
-
getPrices,
|
|
2735
|
-
getRoute,
|
|
2736
2564
|
getSwapTx,
|
|
2737
|
-
|
|
2738
|
-
monitorTransactionStatus,
|
|
2739
|
-
openTxConfigForm,
|
|
2740
|
-
removeTransactionFromRenderedTransactions,
|
|
2741
|
-
renderTxHistoryButtons,
|
|
2742
|
-
replaceNull,
|
|
2743
|
-
safeBigNumberFrom,
|
|
2744
|
-
shortAddress,
|
|
2745
|
-
updateTransactionDoneInRenderedTransactions,
|
|
2746
|
-
weiToHumanReadable
|
|
2565
|
+
monitorTransactionStatus
|
|
2747
2566
|
};
|