@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.js
CHANGED
|
@@ -30,135 +30,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
ADDRESSES: () => ADDRESSES,
|
|
34
|
-
Alert: () => Alert,
|
|
35
|
-
BALANCES_CHUNK_SIZE: () => BALANCES_CHUNK_SIZE,
|
|
36
|
-
BatchQueryAbi: () => BatchQueryAbi,
|
|
37
|
-
CCIP_EXPLORER: () => CCIP_EXPLORER,
|
|
38
33
|
ContractName: () => ContractName,
|
|
39
|
-
DEFAULT_ECOSYSTEM: () => DEFAULT_ECOSYSTEM,
|
|
40
|
-
DEFAULT_SOURCE_CHAIN_ID: () => DEFAULT_SOURCE_CHAIN_ID,
|
|
41
|
-
DELIVERY_TIME: () => DELIVERY_TIME,
|
|
42
|
-
ERC20Abi: () => ERC20Abi,
|
|
43
|
-
EXPRESS_DELIVERY_TIME: () => EXPRESS_DELIVERY_TIME,
|
|
44
34
|
Ecosystem: () => Ecosystem,
|
|
45
35
|
Environment: () => Environment,
|
|
46
|
-
IERC20: () => IERC20,
|
|
47
|
-
MINIMUM_DISPLAYED_TOKEN_AMOUNT: () => MINIMUM_DISPLAYED_TOKEN_AMOUNT,
|
|
48
|
-
NUMBER_INPUT_REGEX: () => NUMBER_INPUT_REGEX,
|
|
49
|
-
ROUTE_TIMEOUT_MS: () => ROUTE_TIMEOUT_MS,
|
|
50
|
-
SLIPPAGE_PRESETS: () => SLIPPAGE_PRESETS,
|
|
51
|
-
Skeleton: () => Skeleton,
|
|
52
|
-
TxHistoryButton: () => TxHistoryButton,
|
|
53
36
|
Web3Environment: () => Web3Environment,
|
|
54
37
|
XSwapCallType: () => XSwapCallType,
|
|
55
|
-
addTransactionToRenderedTransactions: () => addTransactionToRenderedTransactions,
|
|
56
|
-
chunkArray: () => chunkArray,
|
|
57
|
-
deepMergeObjects: () => deepMergeObjects,
|
|
58
|
-
findPlaceholderIndex: () => findPlaceholderIndex,
|
|
59
|
-
generateApproveTxData: () => generateApproveTxData,
|
|
60
|
-
generateRandomBigNumber: () => generateRandomBigNumber,
|
|
61
|
-
generateStakingCalls: () => generateStakingCalls,
|
|
62
|
-
generateUniqueRandomBigNumber: () => generateUniqueRandomBigNumber,
|
|
63
|
-
getBalanceOf: () => getBalanceOf,
|
|
64
|
-
getBalances: () => getBalances,
|
|
65
|
-
getBridgeTokens: () => getBridgeTokens,
|
|
66
|
-
getChainData: () => getChainData,
|
|
67
|
-
getChains: () => getChains,
|
|
68
|
-
getDate: () => getDate,
|
|
69
|
-
getHistory: () => getHistory,
|
|
70
|
-
getPrices: () => getPrices,
|
|
71
|
-
getRoute: () => getRoute,
|
|
72
38
|
getSwapTx: () => getSwapTx,
|
|
73
|
-
|
|
74
|
-
monitorTransactionStatus: () => monitorTransactionStatus,
|
|
75
|
-
openTxConfigForm: () => openTxConfigForm,
|
|
76
|
-
removeTransactionFromRenderedTransactions: () => removeTransactionFromRenderedTransactions,
|
|
77
|
-
renderTxHistoryButtons: () => renderTxHistoryButtons,
|
|
78
|
-
replaceNull: () => replaceNull,
|
|
79
|
-
safeBigNumberFrom: () => safeBigNumberFrom,
|
|
80
|
-
shortAddress: () => shortAddress,
|
|
81
|
-
updateTransactionDoneInRenderedTransactions: () => updateTransactionDoneInRenderedTransactions,
|
|
82
|
-
weiToHumanReadable: () => weiToHumanReadable
|
|
39
|
+
monitorTransactionStatus: () => monitorTransactionStatus
|
|
83
40
|
});
|
|
84
41
|
module.exports = __toCommonJS(src_exports);
|
|
85
42
|
|
|
86
|
-
// src/
|
|
87
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
88
|
-
var Alert = ({ desc }) => {
|
|
89
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "border border-solid border-x_alert rounded-3xl text-x_alert_light text-xs py-0.5 px-2", children: [
|
|
90
|
-
"\u26A0\uFE0F ",
|
|
91
|
-
desc
|
|
92
|
-
] });
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// src/components/TxConfigForm/index.tsx
|
|
96
|
-
var import_react11 = require("react");
|
|
43
|
+
// src/config/init.ts
|
|
97
44
|
var import_client = require("react-dom/client");
|
|
98
|
-
var import_react_query = require("@tanstack/react-query");
|
|
99
|
-
var import_wagmi3 = require("wagmi");
|
|
100
|
-
|
|
101
|
-
// src/config/wagmiConfig.ts
|
|
102
|
-
var import_wagmi = require("wagmi");
|
|
103
|
-
var import_connectors = require("wagmi/connectors");
|
|
104
|
-
var WagmiChains = __toESM(require("viem/chains"));
|
|
105
|
-
var import_chains = require("viem/chains");
|
|
106
|
-
var getWagmiConfig = (supportedChains) => {
|
|
107
|
-
const chains = mapChains(supportedChains);
|
|
108
|
-
const transports = mapTransports(chains);
|
|
109
|
-
return (0, import_wagmi.createConfig)({
|
|
110
|
-
chains,
|
|
111
|
-
transports,
|
|
112
|
-
connectors: [
|
|
113
|
-
(0, import_connectors.injected)(),
|
|
114
|
-
(0, import_connectors.metaMask)(),
|
|
115
|
-
(0, import_connectors.safe)(),
|
|
116
|
-
(0, import_connectors.walletConnect)({ projectId: "c392898b45ac587a280b5eb33e92aeb0" })
|
|
117
|
-
]
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
var mapChains = (supportedChains) => {
|
|
121
|
-
const result = [import_chains.mainnet];
|
|
122
|
-
result.push(
|
|
123
|
-
...Object.values(WagmiChains).filter(
|
|
124
|
-
(chain) => chain.id !== import_chains.mainnet.id && supportedChains.some(({ chainId }) => chainId === chain.id.toString())
|
|
125
|
-
)
|
|
126
|
-
);
|
|
127
|
-
return result;
|
|
128
|
-
};
|
|
129
|
-
var mapTransports = (chains) => {
|
|
130
|
-
const transports = {};
|
|
131
|
-
chains.forEach((chain) => {
|
|
132
|
-
transports[chain.id] = (0, import_wagmi.http)();
|
|
133
|
-
});
|
|
134
|
-
return transports;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// src/components/icons/CloseIcon.tsx
|
|
138
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
139
|
-
var CloseIcon = () => {
|
|
140
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
141
|
-
"svg",
|
|
142
|
-
{
|
|
143
|
-
height: "18",
|
|
144
|
-
width: "18",
|
|
145
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
146
|
-
viewBox: "0 0 10.312 8.319",
|
|
147
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
148
|
-
"path",
|
|
149
|
-
{
|
|
150
|
-
fill: "white",
|
|
151
|
-
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"
|
|
152
|
-
}
|
|
153
|
-
)
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// src/components/TxConfigForm/Form.tsx
|
|
159
|
-
var import_react10 = require("react");
|
|
160
|
-
var import_ethers5 = require("ethers");
|
|
161
|
-
var import_wagmi2 = require("wagmi");
|
|
162
45
|
|
|
163
46
|
// xswap.config.ts
|
|
164
47
|
var xSwapConfig = {
|
|
@@ -174,6 +57,73 @@ var xswap_config_default = {
|
|
|
174
57
|
...xSwapConfigLocal
|
|
175
58
|
};
|
|
176
59
|
|
|
60
|
+
// package.json
|
|
61
|
+
var version = "0.2.2";
|
|
62
|
+
|
|
63
|
+
// src/config/init.ts
|
|
64
|
+
var xswapRoot;
|
|
65
|
+
var txStatusRoot;
|
|
66
|
+
var initDocument = () => {
|
|
67
|
+
if (typeof document === "undefined") {
|
|
68
|
+
throw new Error("Can't render XPay components from server side.");
|
|
69
|
+
}
|
|
70
|
+
fetch(`${xswap_config_default.apiUrl}/sdk/css?data={"version": "${version}"}`).then(
|
|
71
|
+
async (css) => {
|
|
72
|
+
const style = document.createElement("style");
|
|
73
|
+
style.textContent = await css.text();
|
|
74
|
+
document.body.appendChild(style);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
const xswapElement = document.createElement("div");
|
|
78
|
+
xswapElement.setAttribute("id", "xswap-modal");
|
|
79
|
+
document.body.appendChild(xswapElement);
|
|
80
|
+
xswapRoot = (0, import_client.createRoot)(xswapElement);
|
|
81
|
+
const txStatusElement = document.createElement("div");
|
|
82
|
+
txStatusElement.setAttribute("id", "xswap-tx-status");
|
|
83
|
+
txStatusElement.setAttribute("class", "xswap-tx-status");
|
|
84
|
+
document.body.appendChild(txStatusElement);
|
|
85
|
+
txStatusRoot = (0, import_client.createRoot)(txStatusElement);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/models/Addresses.ts
|
|
89
|
+
var ContractName = /* @__PURE__ */ ((ContractName2) => {
|
|
90
|
+
ContractName2["BatchQuery"] = "BatchQuery";
|
|
91
|
+
ContractName2["FeeCollector"] = "FeeCollector";
|
|
92
|
+
ContractName2["XSwapRouter"] = "XSwapRouter";
|
|
93
|
+
return ContractName2;
|
|
94
|
+
})(ContractName || {});
|
|
95
|
+
|
|
96
|
+
// src/models/Ecosystem.ts
|
|
97
|
+
var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
|
|
98
|
+
Ecosystem2["EVM"] = "evm";
|
|
99
|
+
return Ecosystem2;
|
|
100
|
+
})(Ecosystem || {});
|
|
101
|
+
|
|
102
|
+
// src/models/Environment.ts
|
|
103
|
+
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
104
|
+
Environment2["PROD"] = "production";
|
|
105
|
+
Environment2["DEV"] = "develop";
|
|
106
|
+
Environment2["LOCAL"] = "local";
|
|
107
|
+
return Environment2;
|
|
108
|
+
})(Environment || {});
|
|
109
|
+
|
|
110
|
+
// src/models/Web3Environment.ts
|
|
111
|
+
var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
|
|
112
|
+
Web3Environment2["DEVNET"] = "devnet";
|
|
113
|
+
Web3Environment2["TESTNET"] = "testnet";
|
|
114
|
+
Web3Environment2["MAINNET"] = "mainnet";
|
|
115
|
+
return Web3Environment2;
|
|
116
|
+
})(Web3Environment || {});
|
|
117
|
+
|
|
118
|
+
// src/models/XSwapCallType.ts
|
|
119
|
+
var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
|
|
120
|
+
XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
|
|
121
|
+
XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
|
|
122
|
+
XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
|
|
123
|
+
XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
|
|
124
|
+
return XSwapCallType2;
|
|
125
|
+
})(XSwapCallType || {});
|
|
126
|
+
|
|
177
127
|
// src/services/api.ts
|
|
178
128
|
async function _sendRequest(urlPath, options) {
|
|
179
129
|
const response = await fetch(`${xswap_config_default.apiUrl}${urlPath}`, {
|
|
@@ -202,26 +152,6 @@ async function getChains(ecosystem) {
|
|
|
202
152
|
return _sendRequest(`/chains?data=${JSON.stringify({ ecosystem })}
|
|
203
153
|
`);
|
|
204
154
|
}
|
|
205
|
-
async function getChainData(chainId, ecosystem) {
|
|
206
|
-
return _sendRequest(
|
|
207
|
-
`/chains?data=${JSON.stringify({
|
|
208
|
-
chainId,
|
|
209
|
-
ecosystem
|
|
210
|
-
})}`
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
async function getTokens(chainId, address, ecosystem) {
|
|
214
|
-
return _sendRequest(
|
|
215
|
-
`/tokens?data=${JSON.stringify({
|
|
216
|
-
chainId,
|
|
217
|
-
address,
|
|
218
|
-
ecosystem
|
|
219
|
-
})}`
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
async function getBridgeTokens() {
|
|
223
|
-
return _sendRequest(`/bridgeTokens`);
|
|
224
|
-
}
|
|
225
155
|
async function getHistory(payload) {
|
|
226
156
|
return await _sendRequest(
|
|
227
157
|
`/history?${new URLSearchParams({
|
|
@@ -240,45 +170,6 @@ async function getPrices(payload) {
|
|
|
240
170
|
// src/services/integrations/customCalls/staking.ts
|
|
241
171
|
var import_ethers3 = require("ethers");
|
|
242
172
|
|
|
243
|
-
// src/models/Addresses.ts
|
|
244
|
-
var ContractName = /* @__PURE__ */ ((ContractName2) => {
|
|
245
|
-
ContractName2["BatchQuery"] = "BatchQuery";
|
|
246
|
-
ContractName2["FeeCollector"] = "FeeCollector";
|
|
247
|
-
ContractName2["XSwapRouter"] = "XSwapRouter";
|
|
248
|
-
return ContractName2;
|
|
249
|
-
})(ContractName || {});
|
|
250
|
-
|
|
251
|
-
// src/models/Ecosystem.ts
|
|
252
|
-
var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
|
|
253
|
-
Ecosystem2["EVM"] = "evm";
|
|
254
|
-
return Ecosystem2;
|
|
255
|
-
})(Ecosystem || {});
|
|
256
|
-
|
|
257
|
-
// src/models/Environment.ts
|
|
258
|
-
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
259
|
-
Environment2["PROD"] = "production";
|
|
260
|
-
Environment2["DEV"] = "develop";
|
|
261
|
-
Environment2["LOCAL"] = "local";
|
|
262
|
-
return Environment2;
|
|
263
|
-
})(Environment || {});
|
|
264
|
-
|
|
265
|
-
// src/models/Web3Environment.ts
|
|
266
|
-
var Web3Environment = /* @__PURE__ */ ((Web3Environment2) => {
|
|
267
|
-
Web3Environment2["DEVNET"] = "devnet";
|
|
268
|
-
Web3Environment2["TESTNET"] = "testnet";
|
|
269
|
-
Web3Environment2["MAINNET"] = "mainnet";
|
|
270
|
-
return Web3Environment2;
|
|
271
|
-
})(Web3Environment || {});
|
|
272
|
-
|
|
273
|
-
// src/models/XSwapCallType.ts
|
|
274
|
-
var XSwapCallType = /* @__PURE__ */ ((XSwapCallType2) => {
|
|
275
|
-
XSwapCallType2[XSwapCallType2["DEFAULT"] = 0] = "DEFAULT";
|
|
276
|
-
XSwapCallType2[XSwapCallType2["FULL_TOKEN_BALANCE"] = 1] = "FULL_TOKEN_BALANCE";
|
|
277
|
-
XSwapCallType2[XSwapCallType2["FULL_NATIVE_BALANCE"] = 2] = "FULL_NATIVE_BALANCE";
|
|
278
|
-
XSwapCallType2[XSwapCallType2["COLLECT_TOKEN_BALANCE"] = 3] = "COLLECT_TOKEN_BALANCE";
|
|
279
|
-
return XSwapCallType2;
|
|
280
|
-
})(XSwapCallType || {});
|
|
281
|
-
|
|
282
173
|
// src/utils/contracts.ts
|
|
283
174
|
var import_ethers2 = require("ethers");
|
|
284
175
|
|
|
@@ -305,16 +196,6 @@ var weiToHumanReadable = ({
|
|
|
305
196
|
}
|
|
306
197
|
return res;
|
|
307
198
|
};
|
|
308
|
-
var generateRandomBigNumber = (length) => {
|
|
309
|
-
return import_ethers.BigNumber.from(import_ethers.utils.randomBytes(length));
|
|
310
|
-
};
|
|
311
|
-
var generateUniqueRandomBigNumber = (length, existingValues) => {
|
|
312
|
-
let result;
|
|
313
|
-
while (result === void 0 || existingValues.includes(result)) {
|
|
314
|
-
result = generateRandomBigNumber(length);
|
|
315
|
-
}
|
|
316
|
-
return result;
|
|
317
|
-
};
|
|
318
199
|
|
|
319
200
|
// src/contracts/abi/BatchQuery.json
|
|
320
201
|
var BatchQuery_default = [
|
|
@@ -649,20 +530,18 @@ var ROUTE_TIMEOUT_MS = 5e3;
|
|
|
649
530
|
var MINIMUM_DISPLAYED_TOKEN_AMOUNT = 1e-4;
|
|
650
531
|
var DEFAULT_SOURCE_CHAIN_ID = "1";
|
|
651
532
|
var CCIP_EXPLORER = "https://ccip.chain.link/";
|
|
533
|
+
var TX_RECEIPT_STATUS_LIFETIME = 1e4;
|
|
534
|
+
var MSG_SENT_EVENT_SIG = "MessageSent(bytes32,uint64,address,bytes,address,uint256,uint256,address,uint256)";
|
|
535
|
+
var MSG_SENT_EVENT_ABI = [
|
|
536
|
+
"event MessageSent(bytes32 indexed messageId, uint64 indexed destinationChainSelector, address indexed sender, bytes data, address token, uint256 tokenAmount, uint256 valueForInstantCcipRecieve, address transferedToken, uint256 transferedTokenAmount)"
|
|
537
|
+
];
|
|
538
|
+
var MSG_RECEIVED_EVENT_SIG = "MessageReceived(bytes32,uint64,address,bytes,address,uint256)";
|
|
539
|
+
var MSG_RECEIVED_EVENT_ABI = [
|
|
540
|
+
"event MessageReceived(bytes32 indexed messageId, uint64 indexed sourceChainSelector, address indexed sender, bytes data, address token, uint256 tokenAmount)"
|
|
541
|
+
];
|
|
652
542
|
|
|
653
543
|
// src/utils/contracts.ts
|
|
654
544
|
var IERC20 = new import_ethers2.ethers.utils.Interface(ERC20Abi);
|
|
655
|
-
var getBalanceOf = async (wallet, token, rpcUrl) => {
|
|
656
|
-
const provider = import_ethers2.ethers.getDefaultProvider(rpcUrl);
|
|
657
|
-
if (token === import_ethers2.ethers.constants.AddressZero) {
|
|
658
|
-
return import_ethers2.ethers.utils.formatEther(await provider.getBalance(wallet));
|
|
659
|
-
}
|
|
660
|
-
const contract = new import_ethers2.ethers.Contract(token, ERC20Abi, provider);
|
|
661
|
-
return import_ethers2.ethers.utils.formatUnits(
|
|
662
|
-
await contract.balanceOf(wallet),
|
|
663
|
-
await contract.decimals()
|
|
664
|
-
);
|
|
665
|
-
};
|
|
666
545
|
var getBalances = async (chain, wallet) => {
|
|
667
546
|
return {
|
|
668
547
|
...await getNativeBalance(chain, wallet),
|
|
@@ -713,35 +592,6 @@ var getErc20Balances = async (chain, wallet) => {
|
|
|
713
592
|
});
|
|
714
593
|
return balances;
|
|
715
594
|
};
|
|
716
|
-
var generateApproveTxData = (tokenAddress, spender, amount) => {
|
|
717
|
-
return tokenAddress !== import_ethers2.ethers.constants.AddressZero ? {
|
|
718
|
-
to: tokenAddress,
|
|
719
|
-
value: safeBigNumberFrom("0"),
|
|
720
|
-
data: IERC20.encodeFunctionData("approve", [spender, amount])
|
|
721
|
-
} : void 0;
|
|
722
|
-
};
|
|
723
|
-
var findPlaceholderIndex = (abi, funName, funParams, placeholderValue) => {
|
|
724
|
-
if (funParams.flat(Infinity).filter((param) => param === placeholderValue).length !== 1) {
|
|
725
|
-
throw new Error("Random placeholder value must be provided and unique.");
|
|
726
|
-
}
|
|
727
|
-
const iface = new import_ethers2.ethers.utils.Interface(abi);
|
|
728
|
-
const functionFragment = iface.getFunction(funName);
|
|
729
|
-
if (!functionFragment) {
|
|
730
|
-
throw new Error(`Can't find function "${funName}" in provided ABI.`);
|
|
731
|
-
}
|
|
732
|
-
const encodedFunData = iface.encodeFunctionData(functionFragment, funParams);
|
|
733
|
-
const paramData = encodedFunData.slice(10);
|
|
734
|
-
const chunks = [];
|
|
735
|
-
for (let i = 0; i < paramData.length; i += 64) {
|
|
736
|
-
chunks.push(paramData.slice(i, i + 64));
|
|
737
|
-
}
|
|
738
|
-
const searchValue = placeholderValue.toHexString().slice(2).padStart(64, "0");
|
|
739
|
-
const result = chunks.findIndex((chunk) => chunk === searchValue);
|
|
740
|
-
if (result === -1) {
|
|
741
|
-
throw new Error("Randomized parameter not found in the encoded data.");
|
|
742
|
-
}
|
|
743
|
-
return result;
|
|
744
|
-
};
|
|
745
595
|
|
|
746
596
|
// src/utils/strings.ts
|
|
747
597
|
var shortAddress = (address) => {
|
|
@@ -753,19 +603,6 @@ var shortAddress = (address) => {
|
|
|
753
603
|
|
|
754
604
|
// src/utils/index.ts
|
|
755
605
|
var import_date_fns = require("date-fns");
|
|
756
|
-
var replaceNull = (values, newValue) => {
|
|
757
|
-
const modifiedValues = [...values];
|
|
758
|
-
for (let i = 0; i < modifiedValues.length; i++) {
|
|
759
|
-
if (Array.isArray(modifiedValues[i])) {
|
|
760
|
-
modifiedValues[i] = replaceNull(modifiedValues[i], newValue);
|
|
761
|
-
} else {
|
|
762
|
-
if (modifiedValues[i] === null) {
|
|
763
|
-
modifiedValues[i] = newValue;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
return modifiedValues;
|
|
768
|
-
};
|
|
769
606
|
var deepMergeObjects = (obj1, obj2) => {
|
|
770
607
|
for (const key in obj2) {
|
|
771
608
|
if (obj2.hasOwnProperty(key)) {
|
|
@@ -790,230 +627,80 @@ var getDate = (blockTimestamp) => {
|
|
|
790
627
|
return (0, import_date_fns.format)(date, "d MMM yyyy HH:mm:ss");
|
|
791
628
|
};
|
|
792
629
|
|
|
793
|
-
// src/services/integrations/
|
|
794
|
-
var
|
|
795
|
-
token,
|
|
796
|
-
staking,
|
|
797
|
-
stakingAbi,
|
|
798
|
-
stakingFunName,
|
|
799
|
-
stakingFunParams
|
|
800
|
-
}) => {
|
|
801
|
-
const flatStakingFunParams = stakingFunParams.flat(Infinity);
|
|
802
|
-
if (flatStakingFunParams.filter((param) => param === null).length !== 1) {
|
|
803
|
-
throw new Error(
|
|
804
|
-
"Exactly 1 'null' value should be provided in 'funParams' in order to override token balance"
|
|
805
|
-
);
|
|
806
|
-
}
|
|
807
|
-
const randomBigNumber = generateUniqueRandomBigNumber(
|
|
808
|
-
32,
|
|
809
|
-
flatStakingFunParams
|
|
810
|
-
);
|
|
811
|
-
const modifiedStakingFunParams = replaceNull(
|
|
812
|
-
stakingFunParams,
|
|
813
|
-
randomBigNumber
|
|
814
|
-
);
|
|
815
|
-
const approveFunParams = [staking, randomBigNumber];
|
|
816
|
-
const stakingApproveCall = {
|
|
817
|
-
callType: 1 /* FULL_TOKEN_BALANCE */,
|
|
818
|
-
target: token,
|
|
819
|
-
callData: IERC20.encodeFunctionData("approve", approveFunParams),
|
|
820
|
-
payload: import_ethers3.ethers.utils.defaultAbiCoder.encode(
|
|
821
|
-
["address", "uint256"],
|
|
822
|
-
[
|
|
823
|
-
token,
|
|
824
|
-
findPlaceholderIndex(
|
|
825
|
-
JSON.stringify(ERC20Abi),
|
|
826
|
-
"approve",
|
|
827
|
-
approveFunParams,
|
|
828
|
-
randomBigNumber
|
|
829
|
-
)
|
|
830
|
-
]
|
|
831
|
-
),
|
|
832
|
-
value: "0"
|
|
833
|
-
};
|
|
834
|
-
const stakingCall = {
|
|
835
|
-
callType: 1 /* FULL_TOKEN_BALANCE */,
|
|
836
|
-
target: staking,
|
|
837
|
-
callData: new import_ethers3.ethers.utils.Interface(stakingAbi).encodeFunctionData(
|
|
838
|
-
stakingFunName,
|
|
839
|
-
modifiedStakingFunParams
|
|
840
|
-
),
|
|
841
|
-
payload: import_ethers3.ethers.utils.defaultAbiCoder.encode(
|
|
842
|
-
["address", "uint256"],
|
|
843
|
-
[
|
|
844
|
-
token,
|
|
845
|
-
findPlaceholderIndex(
|
|
846
|
-
stakingAbi,
|
|
847
|
-
stakingFunName,
|
|
848
|
-
modifiedStakingFunParams,
|
|
849
|
-
randomBigNumber
|
|
850
|
-
)
|
|
851
|
-
]
|
|
852
|
-
),
|
|
853
|
-
value: "0"
|
|
854
|
-
};
|
|
855
|
-
return [stakingApproveCall, stakingCall];
|
|
856
|
-
};
|
|
630
|
+
// src/services/integrations/monitoring.ts
|
|
631
|
+
var import_ethers5 = require("ethers");
|
|
857
632
|
|
|
858
|
-
// src/
|
|
859
|
-
var
|
|
860
|
-
var
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
}) => {
|
|
866
|
-
const supportedChains = (await getChains()).filter(
|
|
867
|
-
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
868
|
-
);
|
|
869
|
-
validateSwapTxData(supportedChains, dstChain, dstToken);
|
|
870
|
-
const route = await openTxConfigForm({
|
|
871
|
-
dstChainId: dstChain,
|
|
872
|
-
dstTokenAddr: dstToken,
|
|
873
|
-
customContractCalls,
|
|
874
|
-
desc,
|
|
875
|
-
supportedChains
|
|
876
|
-
});
|
|
877
|
-
return route.transactions;
|
|
878
|
-
};
|
|
879
|
-
var validateSwapTxData = (supportedChains, dstChain, dstToken) => {
|
|
880
|
-
const supportedDstChain = supportedChains.find(
|
|
881
|
-
({ chainId }) => chainId === dstChain
|
|
882
|
-
);
|
|
883
|
-
if (!supportedDstChain) {
|
|
884
|
-
throw new Error(`Provided chain '${dstChain}' is not supported`);
|
|
885
|
-
}
|
|
886
|
-
if (!supportedDstChain.tokens.some(({ address }) => address === dstToken)) {
|
|
887
|
-
throw new Error(`Provided token '${dstToken}' is not supported`);
|
|
888
|
-
}
|
|
633
|
+
// src/components/Alert/index.tsx
|
|
634
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
635
|
+
var Alert = ({ desc }) => {
|
|
636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "border border-solid border-x_alert rounded-3xl text-x_alert_light text-xs py-0.5 px-2", children: [
|
|
637
|
+
"\u26A0\uFE0F ",
|
|
638
|
+
desc
|
|
639
|
+
] });
|
|
889
640
|
};
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
throw new Error(
|
|
921
|
-
`No transaction event arguments found for chain ${srcChainId} tx ${txHash}`
|
|
922
|
-
);
|
|
923
|
-
}
|
|
924
|
-
const srcChain = supportedChains.find(
|
|
925
|
-
(chain) => chain.chainId === srcChainId.toString()
|
|
926
|
-
);
|
|
927
|
-
const srcToken = srcChain?.tokens.find(
|
|
928
|
-
(token) => token.address === decodedMessageSentEvent.args?.token.toString()
|
|
929
|
-
);
|
|
930
|
-
const targetChain = supportedChains.find(
|
|
931
|
-
(chain) => chain.ccipChainId === decodedMessageSentEvent.args?.destinationChainSelector?.toString()
|
|
932
|
-
);
|
|
933
|
-
const toChainId = targetChain?.chainId;
|
|
934
|
-
if (!toChainId) {
|
|
935
|
-
throw new Error(`Unknown destination chain!`);
|
|
936
|
-
}
|
|
937
|
-
const transaction = {
|
|
938
|
-
txHash,
|
|
939
|
-
fromChain: srcChain?.displayName,
|
|
940
|
-
fromChainImage: srcChain?.image,
|
|
941
|
-
toChain: targetChain.displayName,
|
|
942
|
-
toChainImage: targetChain.image,
|
|
943
|
-
fromToken: srcToken?.symbol,
|
|
944
|
-
fromTokenImage: srcToken?.image,
|
|
945
|
-
fromAmount: weiToHumanReadable({
|
|
946
|
-
amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
|
|
947
|
-
decimals: srcToken?.decimals || 18,
|
|
948
|
-
precisionFractionalPlaces: 4
|
|
949
|
-
}),
|
|
950
|
-
isDone: false,
|
|
951
|
-
explorer: `${CCIP_EXPLORER}/tx/${txHash}`
|
|
952
|
-
};
|
|
953
|
-
addTransactionToRenderedTransactions(transaction);
|
|
954
|
-
renderTxHistoryButtons();
|
|
955
|
-
const xSwapRouterOnDestinationAddress = ADDRESSES[toChainId]?.XSwapRouter;
|
|
956
|
-
if (!xSwapRouterOnDestinationAddress) {
|
|
957
|
-
throw new Error(`Unknown destination XSwapRouter!`);
|
|
958
|
-
}
|
|
959
|
-
const xSwapRouterOnDestination = new import_ethers4.ethers.Contract(
|
|
960
|
-
xSwapRouterOnDestinationAddress,
|
|
961
|
-
messageReceivedEventAbi,
|
|
962
|
-
import_ethers4.ethers.getDefaultProvider(
|
|
963
|
-
supportedChains.find((chain) => chain.chainId === toChainId)?.publicRpcUrls[0]
|
|
641
|
+
|
|
642
|
+
// src/components/TxConfigForm/index.tsx
|
|
643
|
+
var import_react11 = require("react");
|
|
644
|
+
var import_react_query = require("@tanstack/react-query");
|
|
645
|
+
var import_wagmi3 = require("wagmi");
|
|
646
|
+
|
|
647
|
+
// src/config/wagmiConfig.ts
|
|
648
|
+
var import_wagmi = require("wagmi");
|
|
649
|
+
var import_connectors = require("wagmi/connectors");
|
|
650
|
+
var WagmiChains = __toESM(require("viem/chains"));
|
|
651
|
+
var import_chains = require("viem/chains");
|
|
652
|
+
var getWagmiConfig = (supportedChains) => {
|
|
653
|
+
const chains = mapChains(supportedChains);
|
|
654
|
+
const transports = mapTransports(chains);
|
|
655
|
+
return (0, import_wagmi.createConfig)({
|
|
656
|
+
chains,
|
|
657
|
+
transports,
|
|
658
|
+
connectors: [
|
|
659
|
+
(0, import_connectors.injected)(),
|
|
660
|
+
(0, import_connectors.metaMask)(),
|
|
661
|
+
(0, import_connectors.safe)(),
|
|
662
|
+
(0, import_connectors.walletConnect)({ projectId: "c392898b45ac587a280b5eb33e92aeb0" })
|
|
663
|
+
]
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
var mapChains = (supportedChains) => {
|
|
667
|
+
const result = [import_chains.mainnet];
|
|
668
|
+
result.push(
|
|
669
|
+
...Object.values(WagmiChains).filter(
|
|
670
|
+
(chain) => chain.id !== import_chains.mainnet.id && supportedChains.some(({ chainId }) => chainId === chain.id.toString())
|
|
964
671
|
)
|
|
965
672
|
);
|
|
966
|
-
|
|
967
|
-
address: xSwapRouterOnDestinationAddress,
|
|
968
|
-
topics: [import_ethers4.ethers.utils.id(messageReceivedEventSignature), messageId]
|
|
969
|
-
};
|
|
970
|
-
const onSuccess = async () => {
|
|
971
|
-
updateTransactionDoneInRenderedTransactions(txHash);
|
|
972
|
-
renderTxHistoryButtons();
|
|
973
|
-
await new Promise((resolve) => setTimeout(() => resolve(true), 5e3));
|
|
974
|
-
removeTransactionFromRenderedTransactions(txHash);
|
|
975
|
-
renderTxHistoryButtons();
|
|
976
|
-
};
|
|
977
|
-
xSwapRouterOnDestination.once(eventFilter, () => onSuccess());
|
|
673
|
+
return result;
|
|
978
674
|
};
|
|
979
|
-
var
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
try {
|
|
986
|
-
return await provider.getTransactionReceipt(txHash);
|
|
987
|
-
} catch (error) {
|
|
988
|
-
console.error("Error fetching transaction receipt:", error);
|
|
989
|
-
return null;
|
|
990
|
-
}
|
|
675
|
+
var mapTransports = (chains) => {
|
|
676
|
+
const transports = {};
|
|
677
|
+
chains.forEach((chain) => {
|
|
678
|
+
transports[chain.id] = (0, import_wagmi.http)();
|
|
679
|
+
});
|
|
680
|
+
return transports;
|
|
991
681
|
};
|
|
992
682
|
|
|
993
|
-
// src/
|
|
994
|
-
var
|
|
995
|
-
var
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
683
|
+
// src/components/icons/CloseIcon.tsx
|
|
684
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
685
|
+
var CloseIcon = () => {
|
|
686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
687
|
+
"svg",
|
|
688
|
+
{
|
|
689
|
+
height: "18",
|
|
690
|
+
width: "18",
|
|
691
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
692
|
+
viewBox: "0 0 10.312 8.319",
|
|
693
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
694
|
+
"path",
|
|
695
|
+
{
|
|
696
|
+
fill: "white",
|
|
697
|
+
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"
|
|
698
|
+
}
|
|
699
|
+
)
|
|
700
|
+
}
|
|
701
|
+
);
|
|
1008
702
|
};
|
|
1009
703
|
|
|
1010
|
-
// src/components/TxConfigForm/History.tsx
|
|
1011
|
-
var import_react3 = require("react");
|
|
1012
|
-
var import_bignumber2 = __toESM(require("bignumber.js"));
|
|
1013
|
-
|
|
1014
|
-
// src/components/TxConfigForm/HistoryCard.tsx
|
|
1015
|
-
var import_react2 = require("react");
|
|
1016
|
-
|
|
1017
704
|
// src/components/icons/ArrowRightIcon.tsx
|
|
1018
705
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1019
706
|
var ArrowRightIcon = () => {
|
|
@@ -1430,8 +1117,46 @@ var XSwapLogo = () => {
|
|
|
1430
1117
|
);
|
|
1431
1118
|
};
|
|
1432
1119
|
|
|
1433
|
-
// src/components/TxConfigForm/
|
|
1120
|
+
// src/components/TxConfigForm/PoweredBy.tsx
|
|
1434
1121
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1122
|
+
var PoweredBy = () => {
|
|
1123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex justify-center items-center gap-2 my-3", children: [
|
|
1124
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-x_grey", children: "Powered by" }),
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(XSwapBadgeIcon, {}),
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: "\u2715" }),
|
|
1127
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChainlinkCCIPIcon, {})
|
|
1128
|
+
] });
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
// src/components/TxConfigForm/Form.tsx
|
|
1132
|
+
var import_react10 = require("react");
|
|
1133
|
+
var import_ethers4 = require("ethers");
|
|
1134
|
+
var import_wagmi2 = require("wagmi");
|
|
1135
|
+
|
|
1136
|
+
// src/hooks/useDebounce.tsx
|
|
1137
|
+
var import_react = require("react");
|
|
1138
|
+
var useDebounce = (value, delay) => {
|
|
1139
|
+
const timeoutRef = (0, import_react.useRef)(null);
|
|
1140
|
+
(0, import_react.useEffect)(() => {
|
|
1141
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1142
|
+
timeoutRef.current = setTimeout(() => {
|
|
1143
|
+
setValue(value);
|
|
1144
|
+
}, delay);
|
|
1145
|
+
return () => {
|
|
1146
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1147
|
+
};
|
|
1148
|
+
}, [value, delay]);
|
|
1149
|
+
const [debouncedValue, setValue] = (0, import_react.useState)(value);
|
|
1150
|
+
return debouncedValue;
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
// src/components/TxConfigForm/History.tsx
|
|
1154
|
+
var import_react3 = require("react");
|
|
1155
|
+
var import_bignumber2 = __toESM(require("bignumber.js"));
|
|
1156
|
+
|
|
1157
|
+
// src/components/TxConfigForm/HistoryCard.tsx
|
|
1158
|
+
var import_react2 = require("react");
|
|
1159
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1435
1160
|
var HistoryCard = ({ transaction, supportedChains }) => {
|
|
1436
1161
|
const date = getDate(transaction.timestamp);
|
|
1437
1162
|
const supportedTokens = (0, import_react2.useMemo)(() => {
|
|
@@ -1477,14 +1202,14 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1477
1202
|
const targetChainData = supportedChains.find(
|
|
1478
1203
|
(chain) => chain.chainId === transaction.targetChainId
|
|
1479
1204
|
);
|
|
1480
|
-
return /* @__PURE__ */ (0,
|
|
1481
|
-
/* @__PURE__ */ (0,
|
|
1482
|
-
/* @__PURE__ */ (0,
|
|
1483
|
-
/* @__PURE__ */ (0,
|
|
1484
|
-
transaction.status === "IN_PROGRESS" && /* @__PURE__ */ (0,
|
|
1485
|
-
transaction.status === "DONE" && /* @__PURE__ */ (0,
|
|
1486
|
-
transaction.status === "REVERTED" && /* @__PURE__ */ (0,
|
|
1487
|
-
/* @__PURE__ */ (0,
|
|
1205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("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: [
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex w-full items-center justify-between", children: [
|
|
1207
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-sm sm:text-base", children: date }),
|
|
1208
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center", children: [
|
|
1209
|
+
transaction.status === "IN_PROGRESS" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-[rgb(250,200,100)]", children: "In progress" }) }),
|
|
1210
|
+
transaction.status === "DONE" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-[rgb(100,200,100)]", children: "Done" }) }),
|
|
1211
|
+
transaction.status === "REVERTED" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-[rgb(255,100,100)]", children: "Reverted" }) }),
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1488
1213
|
"a",
|
|
1489
1214
|
{
|
|
1490
1215
|
href: `${supportedChains.find(
|
|
@@ -1494,15 +1219,15 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1494
1219
|
rel: "noreferrer",
|
|
1495
1220
|
className: "ml-2 no-underline",
|
|
1496
1221
|
"aria-label": "Show the transaction in the chain explorer",
|
|
1497
|
-
children: /* @__PURE__ */ (0,
|
|
1222
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ArrowUpRightIcon, {}) })
|
|
1498
1223
|
}
|
|
1499
1224
|
)
|
|
1500
1225
|
] })
|
|
1501
1226
|
] }),
|
|
1502
|
-
/* @__PURE__ */ (0,
|
|
1503
|
-
/* @__PURE__ */ (0,
|
|
1504
|
-
/* @__PURE__ */ (0,
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1227
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex justify-between flex-wrap gap-2", children: [
|
|
1228
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center", children: [
|
|
1229
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center", children: [
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1506
1231
|
"img",
|
|
1507
1232
|
{
|
|
1508
1233
|
src: sourceChainData?.image,
|
|
@@ -1510,11 +1235,11 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1510
1235
|
className: "w-5 h-5 mr-1"
|
|
1511
1236
|
}
|
|
1512
1237
|
),
|
|
1513
|
-
/* @__PURE__ */ (0,
|
|
1238
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: sourceChainData?.displayName })
|
|
1514
1239
|
] }),
|
|
1515
|
-
/* @__PURE__ */ (0,
|
|
1516
|
-
/* @__PURE__ */ (0,
|
|
1517
|
-
/* @__PURE__ */ (0,
|
|
1240
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-3.5 h-3.5 my-0 mx-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ArrowRightIcon, {}) }),
|
|
1241
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center", children: [
|
|
1242
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1518
1243
|
"img",
|
|
1519
1244
|
{
|
|
1520
1245
|
src: targetChainData?.image,
|
|
@@ -1522,35 +1247,35 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1522
1247
|
className: "w-5 h-5 mr-1"
|
|
1523
1248
|
}
|
|
1524
1249
|
),
|
|
1525
|
-
/* @__PURE__ */ (0,
|
|
1250
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: targetChainData?.displayName })
|
|
1526
1251
|
] })
|
|
1527
1252
|
] }),
|
|
1528
|
-
/* @__PURE__ */ (0,
|
|
1529
|
-
/* @__PURE__ */ (0,
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center mb-2 last:mb-0", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center flex-wrap", children: [
|
|
1254
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center", children: [
|
|
1530
1255
|
Number(transferredAmount) < MINIMUM_DISPLAYED_TOKEN_AMOUNT ? `<${MINIMUM_DISPLAYED_TOKEN_AMOUNT}` : transferredAmount,
|
|
1531
|
-
/* @__PURE__ */ (0,
|
|
1532
|
-
tokenData?.image ? /* @__PURE__ */ (0,
|
|
1256
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "ml-1", children: tokenData?.symbol }),
|
|
1257
|
+
tokenData?.image ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1533
1258
|
"img",
|
|
1534
1259
|
{
|
|
1535
1260
|
src: tokenData?.image,
|
|
1536
1261
|
alt: tokenData?.name || "",
|
|
1537
1262
|
className: "w-5 h-5 ml-1"
|
|
1538
1263
|
}
|
|
1539
|
-
) : /* @__PURE__ */ (0,
|
|
1264
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("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) })
|
|
1540
1265
|
] }),
|
|
1541
|
-
transaction.tokenOutAddress && /* @__PURE__ */ (0,
|
|
1542
|
-
/* @__PURE__ */ (0,
|
|
1543
|
-
/* @__PURE__ */ (0,
|
|
1266
|
+
transaction.tokenOutAddress && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
1267
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-3.5 h-3.5 my-0 mx-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ArrowRightIcon, {}) }),
|
|
1268
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center", children: [
|
|
1544
1269
|
Number(receivedAmount) < 1e-4 ? "<0.0001" : receivedAmount,
|
|
1545
|
-
/* @__PURE__ */ (0,
|
|
1546
|
-
tokenOutData?.image ? /* @__PURE__ */ (0,
|
|
1270
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "ml-1", children: tokenOutData?.symbol }),
|
|
1271
|
+
tokenOutData?.image ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1547
1272
|
"img",
|
|
1548
1273
|
{
|
|
1549
1274
|
src: tokenOutData?.image,
|
|
1550
1275
|
alt: tokenOutData?.name || "",
|
|
1551
1276
|
className: "w-5 h-5 ml-1"
|
|
1552
1277
|
}
|
|
1553
|
-
) : /* @__PURE__ */ (0,
|
|
1278
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("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) })
|
|
1554
1279
|
] })
|
|
1555
1280
|
] })
|
|
1556
1281
|
] }) })
|
|
@@ -1559,7 +1284,7 @@ var HistoryCard = ({ transaction, supportedChains }) => {
|
|
|
1559
1284
|
};
|
|
1560
1285
|
|
|
1561
1286
|
// src/components/TxConfigForm/History.tsx
|
|
1562
|
-
var
|
|
1287
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1563
1288
|
var History = ({ signer, supportedChains }) => {
|
|
1564
1289
|
const [fetchedHistory, setFetchedHistory] = (0, import_react3.useState)();
|
|
1565
1290
|
const [historyLoadedOnce, setHistoryLoadedOnce] = (0, import_react3.useState)(false);
|
|
@@ -1611,11 +1336,11 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1611
1336
|
return () => clearInterval(timer);
|
|
1612
1337
|
}, [signer, fetchHistory, getHistory, historyLoadedOnce]);
|
|
1613
1338
|
if (!signer)
|
|
1614
|
-
return /* @__PURE__ */ (0,
|
|
1615
|
-
return /* @__PURE__ */ (0,
|
|
1616
|
-
fetchedHistory?.length === 0 && historyLoadedOnce && /* @__PURE__ */ (0,
|
|
1617
|
-
!fetchedHistory && !historyLoadedOnce && /* @__PURE__ */ (0,
|
|
1618
|
-
fetchedHistory?.map((transaction, index) => /* @__PURE__ */ (0,
|
|
1339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex items-center justify-center w-full h-[30vh]", children: "Connect a wallet to browse history" });
|
|
1340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex items-center justify-center w-full", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "w-full h-96 overflow-scroll overflow-x-hidden", children: [
|
|
1341
|
+
fetchedHistory?.length === 0 && historyLoadedOnce && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-full text-center py-4 px-0 text-[rgb(158,158,158)]", children: "Your history is empty..." }),
|
|
1342
|
+
!fetchedHistory && !historyLoadedOnce && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex w-full h-full items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CircularProgressIcon, {}) }),
|
|
1343
|
+
fetchedHistory?.map((transaction, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1619
1344
|
HistoryCard,
|
|
1620
1345
|
{
|
|
1621
1346
|
transaction,
|
|
@@ -1627,30 +1352,30 @@ var History = ({ signer, supportedChains }) => {
|
|
|
1627
1352
|
};
|
|
1628
1353
|
|
|
1629
1354
|
// src/components/TxConfigForm/TopBar.tsx
|
|
1630
|
-
var
|
|
1355
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1631
1356
|
var TopBar = ({
|
|
1632
1357
|
signer,
|
|
1633
1358
|
setSettingsShown,
|
|
1634
1359
|
setHistoryTabShown,
|
|
1635
1360
|
historyTabShown
|
|
1636
1361
|
}) => {
|
|
1637
|
-
return /* @__PURE__ */ (0,
|
|
1638
|
-
/* @__PURE__ */ (0,
|
|
1639
|
-
/* @__PURE__ */ (0,
|
|
1640
|
-
!historyTabShown && /* @__PURE__ */ (0,
|
|
1362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex w-full justify-between items-center mx-auto sm:pl-4 pr-8 pt-2", children: [
|
|
1363
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("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` }),
|
|
1364
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex gap-2", children: [
|
|
1365
|
+
!historyTabShown && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1641
1366
|
"div",
|
|
1642
1367
|
{
|
|
1643
1368
|
onClick: () => setSettingsShown(true),
|
|
1644
1369
|
className: "flex items-center text-xs gap-1 cursor-pointer",
|
|
1645
|
-
children: /* @__PURE__ */ (0,
|
|
1370
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("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__ */ (0, import_jsx_runtime27.jsx)(SettingsIcon, {}) })
|
|
1646
1371
|
}
|
|
1647
1372
|
),
|
|
1648
|
-
/* @__PURE__ */ (0,
|
|
1373
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1649
1374
|
"div",
|
|
1650
1375
|
{
|
|
1651
1376
|
onClick: () => setHistoryTabShown((x) => !x),
|
|
1652
1377
|
className: "flex items-center text-sm gap-1 cursor-pointer",
|
|
1653
|
-
children: !historyTabShown ? /* @__PURE__ */ (0,
|
|
1378
|
+
children: !historyTabShown ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("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__ */ (0, import_jsx_runtime27.jsx)(HistoryIcon, {}) }) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: "Back" })
|
|
1654
1379
|
}
|
|
1655
1380
|
)
|
|
1656
1381
|
] })
|
|
@@ -1659,7 +1384,7 @@ var TopBar = ({
|
|
|
1659
1384
|
|
|
1660
1385
|
// src/components/TxConfigForm/Settings.tsx
|
|
1661
1386
|
var import_react4 = require("react");
|
|
1662
|
-
var
|
|
1387
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1663
1388
|
var Settings = ({
|
|
1664
1389
|
setSlippage,
|
|
1665
1390
|
setSettingsShown,
|
|
@@ -1676,22 +1401,22 @@ var Settings = ({
|
|
|
1676
1401
|
);
|
|
1677
1402
|
}
|
|
1678
1403
|
}, [slippageActivePresetIndex, usingSlippageInput]);
|
|
1679
|
-
return /* @__PURE__ */ (0,
|
|
1680
|
-
/* @__PURE__ */ (0,
|
|
1681
|
-
/* @__PURE__ */ (0,
|
|
1682
|
-
/* @__PURE__ */ (0,
|
|
1404
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("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__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col gap-4 justify-between", children: [
|
|
1405
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex justify-between", children: [
|
|
1406
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "text-base", children: "Settings" }),
|
|
1407
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1683
1408
|
"div",
|
|
1684
1409
|
{
|
|
1685
1410
|
className: "cursor-pointer",
|
|
1686
1411
|
onClick: () => setSettingsShown(false),
|
|
1687
|
-
children: /* @__PURE__ */ (0,
|
|
1412
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {})
|
|
1688
1413
|
}
|
|
1689
1414
|
)
|
|
1690
1415
|
] }),
|
|
1691
|
-
/* @__PURE__ */ (0,
|
|
1692
|
-
/* @__PURE__ */ (0,
|
|
1693
|
-
/* @__PURE__ */ (0,
|
|
1694
|
-
/* @__PURE__ */ (0,
|
|
1416
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { children: [
|
|
1417
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex gap-2 items-center", children: [
|
|
1418
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "text-sm text-[rgba(255,255,255,0.6)]", children: "Express delivery" }),
|
|
1419
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
1695
1420
|
"span",
|
|
1696
1421
|
{
|
|
1697
1422
|
className: "inline-flex w-14 h-9 p-3 relative align-middle box-border overflow-hidden cursor-pointer",
|
|
@@ -1699,8 +1424,8 @@ var Settings = ({
|
|
|
1699
1424
|
setExpressChecked((x) => !x);
|
|
1700
1425
|
},
|
|
1701
1426
|
children: [
|
|
1702
|
-
/* @__PURE__ */ (0,
|
|
1703
|
-
/* @__PURE__ */ (0,
|
|
1427
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "h-full, w-full rounded-lg bg-[rgba(255,255,255,0.3)]" }),
|
|
1428
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1704
1429
|
"span",
|
|
1705
1430
|
{
|
|
1706
1431
|
className: `transition-all w-5 h-5 rounded-full absolute translate-y-[-4px]
|
|
@@ -1711,15 +1436,15 @@ var Settings = ({
|
|
|
1711
1436
|
}
|
|
1712
1437
|
) })
|
|
1713
1438
|
] }),
|
|
1714
|
-
/* @__PURE__ */ (0,
|
|
1715
|
-
/* @__PURE__ */ (0,
|
|
1716
|
-
/* @__PURE__ */ (0,
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex gap-4", children: [
|
|
1440
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "min-w-[26px] min-h-[26px] text-[#ffa726]", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(InfoIcon, {}) }),
|
|
1441
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("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." })
|
|
1717
1442
|
] })
|
|
1718
1443
|
] }),
|
|
1719
|
-
/* @__PURE__ */ (0,
|
|
1720
|
-
/* @__PURE__ */ (0,
|
|
1721
|
-
/* @__PURE__ */ (0,
|
|
1722
|
-
/* @__PURE__ */ (0,
|
|
1444
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col gap-2 ", children: [
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: " text-[rgba(255,255,255,0.6)] text-sm", children: "Slippage" }),
|
|
1446
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex gap-2", children: [
|
|
1447
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex items-center bg-[rgba(15,15,15,1)] p-1 globalBorder rounded-xl", children: SLIPPAGE_PRESETS.map((preset, index) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1723
1448
|
"div",
|
|
1724
1449
|
{
|
|
1725
1450
|
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]" : ""}`,
|
|
@@ -1731,8 +1456,8 @@ var Settings = ({
|
|
|
1731
1456
|
},
|
|
1732
1457
|
index
|
|
1733
1458
|
)) }),
|
|
1734
|
-
/* @__PURE__ */ (0,
|
|
1735
|
-
/* @__PURE__ */ (0,
|
|
1459
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("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: [
|
|
1460
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1736
1461
|
"input",
|
|
1737
1462
|
{
|
|
1738
1463
|
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",
|
|
@@ -1751,16 +1476,16 @@ var Settings = ({
|
|
|
1751
1476
|
}
|
|
1752
1477
|
}
|
|
1753
1478
|
),
|
|
1754
|
-
/* @__PURE__ */ (0,
|
|
1479
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PercentageIcon, {})
|
|
1755
1480
|
] })
|
|
1756
1481
|
] }),
|
|
1757
|
-
/* @__PURE__ */ (0,
|
|
1758
|
-
/* @__PURE__ */ (0,
|
|
1759
|
-
/* @__PURE__ */ (0,
|
|
1482
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex gap-4", children: [
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "min-w-[26px] min-h-[26px] text-[#ffa726]", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(InfoIcon, {}) }),
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "text-xs text-left", children: [
|
|
1760
1485
|
"Slippage is the price variation you are willing to accept in the event that the price of the trade changes while it is processing.",
|
|
1761
|
-
/* @__PURE__ */ (0,
|
|
1486
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("br", {}),
|
|
1762
1487
|
" ",
|
|
1763
|
-
/* @__PURE__ */ (0,
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("br", {}),
|
|
1764
1489
|
"If the trade fails due to too-low slippage, you will receive USDC on the destination chain."
|
|
1765
1490
|
] })
|
|
1766
1491
|
] })
|
|
@@ -1769,7 +1494,7 @@ var Settings = ({
|
|
|
1769
1494
|
};
|
|
1770
1495
|
|
|
1771
1496
|
// src/components/TxConfigForm/FeesDetails.tsx
|
|
1772
|
-
var
|
|
1497
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1773
1498
|
var FeesDetails = ({
|
|
1774
1499
|
isGettingRoute,
|
|
1775
1500
|
route,
|
|
@@ -1780,12 +1505,12 @@ var FeesDetails = ({
|
|
|
1780
1505
|
feesDetailsShown,
|
|
1781
1506
|
setFeesDetailsShown
|
|
1782
1507
|
}) => {
|
|
1783
|
-
return /* @__PURE__ */ (0,
|
|
1784
|
-
/* @__PURE__ */ (0,
|
|
1785
|
-
/* @__PURE__ */ (0,
|
|
1786
|
-
/* @__PURE__ */ (0,
|
|
1787
|
-
/* @__PURE__ */ (0,
|
|
1788
|
-
isGettingRoute ? /* @__PURE__ */ (0,
|
|
1508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col gap-3 globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4 mb-1", children: [
|
|
1509
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex w-full items-center justify-between text-xs sm:text-sm ", children: [
|
|
1510
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1 font-medium text-white opacity-60", children: [
|
|
1511
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CoinsIcon, {}),
|
|
1512
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "mr-1", children: "Fees:" }),
|
|
1513
|
+
isGettingRoute ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "bg-current rounded animate-pulse w-20 h-4" }) : ` ${weiToHumanReadable({
|
|
1789
1514
|
amount: safeBigNumberFrom(
|
|
1790
1515
|
route?.xSwapFees.xSwapFee.nativeFee || "0"
|
|
1791
1516
|
).add(safeBigNumberFrom(route?.xSwapFees.ccipFee || "0")).add(
|
|
@@ -1795,30 +1520,30 @@ var FeesDetails = ({
|
|
|
1795
1520
|
precisionFractionalPlaces: 5
|
|
1796
1521
|
})} ${paymentToken?.symbol}`
|
|
1797
1522
|
] }),
|
|
1798
|
-
/* @__PURE__ */ (0,
|
|
1799
|
-
/* @__PURE__ */ (0,
|
|
1523
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex gap-1 items-center", children: [
|
|
1524
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
1800
1525
|
"div",
|
|
1801
1526
|
{
|
|
1802
1527
|
className: `flex gap-1 items-center font-medium ${expressChecked ? "text-x_green" : "text-white opacity-60"}`,
|
|
1803
1528
|
children: [
|
|
1804
|
-
/* @__PURE__ */ (0,
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TimerIcon, {}),
|
|
1805
1530
|
expressChecked ? "Fast ~ 30sec " : "Normal ~ 30min"
|
|
1806
1531
|
]
|
|
1807
1532
|
}
|
|
1808
1533
|
),
|
|
1809
|
-
/* @__PURE__ */ (0,
|
|
1534
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
1810
1535
|
"div",
|
|
1811
1536
|
{
|
|
1812
1537
|
onClick: () => setFeesDetailsShown((x) => !x),
|
|
1813
1538
|
className: "font-medium text-white opacity-60 cursor-pointer flex items-center w-[15px] h-[9px]",
|
|
1814
|
-
children: feesDetailsShown ? /* @__PURE__ */ (0,
|
|
1539
|
+
children: feesDetailsShown ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronUpIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronDownIcon, {})
|
|
1815
1540
|
}
|
|
1816
1541
|
)
|
|
1817
1542
|
] })
|
|
1818
1543
|
] }),
|
|
1819
|
-
feesDetailsShown && /* @__PURE__ */ (0,
|
|
1820
|
-
/* @__PURE__ */ (0,
|
|
1821
|
-
/* @__PURE__ */ (0,
|
|
1544
|
+
feesDetailsShown && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex w-full items-center justify-between ", children: [
|
|
1545
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col text-[10px] gap-1", children: [
|
|
1546
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "font-medium text-white opacity-60", children: [
|
|
1822
1547
|
"CCIP Fee:",
|
|
1823
1548
|
` ${weiToHumanReadable({
|
|
1824
1549
|
amount: route?.xSwapFees.ccipFee || "0",
|
|
@@ -1826,7 +1551,7 @@ var FeesDetails = ({
|
|
|
1826
1551
|
precisionFractionalPlaces: 5
|
|
1827
1552
|
})} ${paymentToken?.symbol}`
|
|
1828
1553
|
] }),
|
|
1829
|
-
/* @__PURE__ */ (0,
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "font-medium text-white opacity-60", children: [
|
|
1830
1555
|
"Native Fee:",
|
|
1831
1556
|
` ${weiToHumanReadable({
|
|
1832
1557
|
amount: route?.xSwapFees.xSwapFee.nativeFee || "0",
|
|
@@ -1835,12 +1560,12 @@ var FeesDetails = ({
|
|
|
1835
1560
|
})} ${paymentToken?.symbol}`
|
|
1836
1561
|
] })
|
|
1837
1562
|
] }),
|
|
1838
|
-
/* @__PURE__ */ (0,
|
|
1839
|
-
/* @__PURE__ */ (0,
|
|
1563
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col text-[10px] gap-1", children: [
|
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "font-medium text-white opacity-60", children: [
|
|
1840
1565
|
"Slippage: ",
|
|
1841
1566
|
`${slippage}%`
|
|
1842
1567
|
] }),
|
|
1843
|
-
/* @__PURE__ */ (0,
|
|
1568
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "font-medium text-white opacity-60", children: [
|
|
1844
1569
|
"Min amount out:",
|
|
1845
1570
|
" ",
|
|
1846
1571
|
weiToHumanReadable({
|
|
@@ -1861,7 +1586,7 @@ var import_react6 = require("react");
|
|
|
1861
1586
|
|
|
1862
1587
|
// src/components/TxConfigForm/UsdPrice.tsx
|
|
1863
1588
|
var import_react5 = require("react");
|
|
1864
|
-
var
|
|
1589
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1865
1590
|
var UsdPrice = ({
|
|
1866
1591
|
prices,
|
|
1867
1592
|
token,
|
|
@@ -1874,11 +1599,11 @@ var UsdPrice = ({
|
|
|
1874
1599
|
setUsdPrice((Number(amount) * Number(prices[token.address])).toFixed(2));
|
|
1875
1600
|
}
|
|
1876
1601
|
}, [token, prices, amount]);
|
|
1877
|
-
return /* @__PURE__ */ (0,
|
|
1602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "opacity-60 py-4", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Skeleton, { width: "w-12", height: "h-4" }) : token ? prices && prices[token.address] ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: `$${usdPrice}` }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Alert, { desc: "Unknown price" }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: "$0.00" }) });
|
|
1878
1603
|
};
|
|
1879
1604
|
|
|
1880
1605
|
// src/components/TxConfigForm/Summary.tsx
|
|
1881
|
-
var
|
|
1606
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1882
1607
|
var Summary = ({
|
|
1883
1608
|
isGettingRoute,
|
|
1884
1609
|
route,
|
|
@@ -1901,32 +1626,32 @@ var Summary = ({
|
|
|
1901
1626
|
);
|
|
1902
1627
|
}
|
|
1903
1628
|
}, [dstChain]);
|
|
1904
|
-
return /* @__PURE__ */ (0,
|
|
1905
|
-
/* @__PURE__ */ (0,
|
|
1906
|
-
/* @__PURE__ */ (0,
|
|
1907
|
-
/* @__PURE__ */ (0,
|
|
1908
|
-
isGettingRoute ? /* @__PURE__ */ (0,
|
|
1629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4 relative", children: [
|
|
1630
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex justify-between", children: [
|
|
1631
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
1632
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-[rgba(255,255,255,0.6)] text-sm", children: "You receive" }),
|
|
1633
|
+
isGettingRoute ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1909
1634
|
Skeleton,
|
|
1910
1635
|
{
|
|
1911
1636
|
width: "w-[100px]",
|
|
1912
1637
|
height: "h-[36px]",
|
|
1913
1638
|
other: "sm:w-[190px]"
|
|
1914
1639
|
}
|
|
1915
|
-
) : /* @__PURE__ */ (0,
|
|
1640
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex gap-2 items-center text-white text-xl sm:text-3xl", children: [
|
|
1916
1641
|
amountReadable,
|
|
1917
|
-
/* @__PURE__ */ (0,
|
|
1918
|
-
/* @__PURE__ */ (0,
|
|
1642
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "w-4 sm:w-6 h-4 sm:h-6", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", { src: dstToken?.image, alt: dstToken?.name }) }),
|
|
1643
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-base sm:text-xl", children: dstToken?.symbol })
|
|
1919
1644
|
] })
|
|
1920
1645
|
] }),
|
|
1921
|
-
/* @__PURE__ */ (0,
|
|
1922
|
-
/* @__PURE__ */ (0,
|
|
1923
|
-
/* @__PURE__ */ (0,
|
|
1924
|
-
/* @__PURE__ */ (0,
|
|
1925
|
-
/* @__PURE__ */ (0,
|
|
1646
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-col gap-1 text-sm", children: [
|
|
1647
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-[rgba(255,255,255,0.6)] text-right", children: "on chain:" }),
|
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1 text-white", children: [
|
|
1649
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "w-4 h-4", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", { src: dstChain?.image, alt: dstChain?.name }) }),
|
|
1650
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: dstChain?.displayName })
|
|
1926
1651
|
] })
|
|
1927
1652
|
] })
|
|
1928
1653
|
] }),
|
|
1929
|
-
/* @__PURE__ */ (0,
|
|
1654
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1930
1655
|
UsdPrice,
|
|
1931
1656
|
{
|
|
1932
1657
|
prices,
|
|
@@ -1935,7 +1660,7 @@ var Summary = ({
|
|
|
1935
1660
|
loading: isGettingRoute
|
|
1936
1661
|
}
|
|
1937
1662
|
),
|
|
1938
|
-
/* @__PURE__ */ (0,
|
|
1663
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "absolute right-[50%] top-0 translate-x-1/2 translate-y-[-60%] globalBorder rounded-xl p-[5px] bg-[rgba(15,15,15,1)]", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: " flex items-center justify-center rounded-lg w-8 h-8 bg-gradient-to-l from-[rgba(54,129,198,1)] to-[rgba(43,74,157,1)] ", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ArrowDownIcon, {}) }) })
|
|
1939
1664
|
] });
|
|
1940
1665
|
};
|
|
1941
1666
|
|
|
@@ -1945,7 +1670,7 @@ var import_react9 = require("react");
|
|
|
1945
1670
|
// src/components/TxConfigForm/TokenPicker.tsx
|
|
1946
1671
|
var import_react7 = require("react");
|
|
1947
1672
|
var import_react_dom = require("react-dom");
|
|
1948
|
-
var
|
|
1673
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1949
1674
|
var TokenPicker = ({
|
|
1950
1675
|
onCloseClick,
|
|
1951
1676
|
tokens,
|
|
@@ -1972,24 +1697,24 @@ var TokenPicker = ({
|
|
|
1972
1697
|
);
|
|
1973
1698
|
}, [searchValue, tokens]);
|
|
1974
1699
|
return modalRoot ? (0, import_react_dom.createPortal)(
|
|
1975
|
-
/* @__PURE__ */ (0,
|
|
1700
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1976
1701
|
"div",
|
|
1977
1702
|
{
|
|
1978
1703
|
onClick: onBackdropClick,
|
|
1979
1704
|
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",
|
|
1980
|
-
children: /* @__PURE__ */ (0,
|
|
1981
|
-
/* @__PURE__ */ (0,
|
|
1705
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "relative bg-black rounded-3xl p-6 max-h-[70%] flex flex-col text-base text-white w-[452px] h-[70%] border border-solid border-[rgba(255,255,255,0.2)]", children: [
|
|
1706
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1982
1707
|
"div",
|
|
1983
1708
|
{
|
|
1984
1709
|
onClick: onCloseClick,
|
|
1985
1710
|
className: "absolute top-4 right-4 cursor-pointer",
|
|
1986
|
-
children: /* @__PURE__ */ (0,
|
|
1711
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(CloseIcon, {})
|
|
1987
1712
|
}
|
|
1988
1713
|
),
|
|
1989
|
-
/* @__PURE__ */ (0,
|
|
1990
|
-
/* @__PURE__ */ (0,
|
|
1991
|
-
/* @__PURE__ */ (0,
|
|
1992
|
-
/* @__PURE__ */ (0,
|
|
1714
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-base mb-4", children: "Pick a token" }),
|
|
1715
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center border border-solid border-[rgba(255,255,255,0.1)] rounded-lg py-0 px-3 gap-2 bg-[rgba(15,15,15,1)]", children: [
|
|
1716
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "w-6 h-6", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(SearchIcon, {}) }),
|
|
1717
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1993
1718
|
"input",
|
|
1994
1719
|
{
|
|
1995
1720
|
placeholder: "Search name or paste address",
|
|
@@ -1999,7 +1724,7 @@ var TokenPicker = ({
|
|
|
1999
1724
|
}
|
|
2000
1725
|
)
|
|
2001
1726
|
] }),
|
|
2002
|
-
/* @__PURE__ */ (0,
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "my-4 mx-0 flex flex-wrap gap-3", children: tokens?.filter((token) => token?.quickPick).map((token) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
2003
1728
|
"div",
|
|
2004
1729
|
{
|
|
2005
1730
|
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)]" : ""}`,
|
|
@@ -2008,14 +1733,14 @@ var TokenPicker = ({
|
|
|
2008
1733
|
onCloseClick();
|
|
2009
1734
|
},
|
|
2010
1735
|
children: [
|
|
2011
|
-
/* @__PURE__ */ (0,
|
|
2012
|
-
/* @__PURE__ */ (0,
|
|
1736
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("img", { src: token.image, alt: token.name, className: "w-5" }),
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "text-sm", children: token.symbol })
|
|
2013
1738
|
]
|
|
2014
1739
|
},
|
|
2015
1740
|
token.address
|
|
2016
1741
|
)) }),
|
|
2017
|
-
/* @__PURE__ */ (0,
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
1742
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "h-[2px] my-0 mx-[-24px] w-[100%+48px] px-12 bg-[rgba(255,255,255,0.1)]" }),
|
|
1743
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "overflow-y-scroll h-full mx-[-24px] w-[100%+48px] flex flex-col", children: filteredTokens && filteredTokens.length > 0 ? filteredTokens.map((token, index) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
2019
1744
|
"div",
|
|
2020
1745
|
{
|
|
2021
1746
|
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)]" : ""}`,
|
|
@@ -2024,29 +1749,29 @@ var TokenPicker = ({
|
|
|
2024
1749
|
onCloseClick();
|
|
2025
1750
|
},
|
|
2026
1751
|
children: [
|
|
2027
|
-
token.image ? /* @__PURE__ */ (0,
|
|
1752
|
+
token.image ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2028
1753
|
"img",
|
|
2029
1754
|
{
|
|
2030
1755
|
src: token.image,
|
|
2031
1756
|
alt: token.name,
|
|
2032
1757
|
className: "token-picker__all__logo"
|
|
2033
1758
|
}
|
|
2034
|
-
) : /* @__PURE__ */ (0,
|
|
2035
|
-
/* @__PURE__ */ (0,
|
|
2036
|
-
/* @__PURE__ */ (0,
|
|
2037
|
-
/* @__PURE__ */ (0,
|
|
2038
|
-
/* @__PURE__ */ (0,
|
|
1759
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex items-center justify-center w-9 h-9 text-[15px] ml-1 rounded-full bg-[#272e40] text-[#e0e7fa]", children: token?.symbol.substring(0, 1) }),
|
|
1760
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex justify-between items-center gap-1 overflow-hidden grow", children: [
|
|
1761
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col leading-[16px]", children: [
|
|
1762
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "overflow-hidden whitespace-nowrap text-ellipsis text-[15px]", children: token.name }),
|
|
1763
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "text-[#888] text-[11px]", children: token.symbol })
|
|
2039
1764
|
] }),
|
|
2040
|
-
signer && /* @__PURE__ */ (0,
|
|
1765
|
+
signer && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: balances && balances[token.address] && token.decimals ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "text-xs", children: weiToHumanReadable({
|
|
2041
1766
|
amount: balances[token.address]?.toString() || "0",
|
|
2042
1767
|
decimals: token.decimals,
|
|
2043
1768
|
precisionFractionalPlaces: 4
|
|
2044
|
-
}) }) : /* @__PURE__ */ (0,
|
|
1769
|
+
}) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Skeleton, { width: "w-12", height: "h-3" }) })
|
|
2045
1770
|
] })
|
|
2046
1771
|
]
|
|
2047
1772
|
},
|
|
2048
1773
|
`${index}_${token.address}`
|
|
2049
|
-
)) : /* @__PURE__ */ (0,
|
|
1774
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-sm text-white", children: "No tokens found." }) }) })
|
|
2050
1775
|
] })
|
|
2051
1776
|
}
|
|
2052
1777
|
),
|
|
@@ -2055,7 +1780,7 @@ var TokenPicker = ({
|
|
|
2055
1780
|
};
|
|
2056
1781
|
|
|
2057
1782
|
// src/components/TxConfigForm/ChainListElement.tsx
|
|
2058
|
-
var
|
|
1783
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2059
1784
|
var ChainListElement = ({
|
|
2060
1785
|
chain,
|
|
2061
1786
|
setSrcChain,
|
|
@@ -2063,8 +1788,8 @@ var ChainListElement = ({
|
|
|
2063
1788
|
index,
|
|
2064
1789
|
length
|
|
2065
1790
|
}) => {
|
|
2066
|
-
return /* @__PURE__ */ (0,
|
|
2067
|
-
/* @__PURE__ */ (0,
|
|
1791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { children: [
|
|
1792
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
2068
1793
|
"li",
|
|
2069
1794
|
{
|
|
2070
1795
|
className: "bg-transparent border-none flex gap-1 items-center cursor-pointer py-2 w-full",
|
|
@@ -2073,19 +1798,19 @@ var ChainListElement = ({
|
|
|
2073
1798
|
setChainListShown(false);
|
|
2074
1799
|
},
|
|
2075
1800
|
children: [
|
|
2076
|
-
/* @__PURE__ */ (0,
|
|
1801
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("img", { width: 12, height: 12, src: chain.image, alt: chain.displayName }),
|
|
2077
1802
|
chain.displayName
|
|
2078
1803
|
]
|
|
2079
1804
|
}
|
|
2080
1805
|
),
|
|
2081
|
-
index !== length - 1 && /* @__PURE__ */ (0,
|
|
1806
|
+
index !== length - 1 && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "h-px mx-2 bg-[rgba(255,255,255,0.15)]" })
|
|
2082
1807
|
] }, `${chain.ecosystem}-${chain.chainId}`);
|
|
2083
1808
|
};
|
|
2084
1809
|
|
|
2085
1810
|
// src/components/TxConfigForm/BalanceComponent.tsx
|
|
2086
1811
|
var import_react8 = require("react");
|
|
2087
1812
|
var import_bignumber3 = __toESM(require("bignumber.js"));
|
|
2088
|
-
var
|
|
1813
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
2089
1814
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
2090
1815
|
const balanceText = (0, import_react8.useMemo)(() => {
|
|
2091
1816
|
if (!balances || !srcToken) return "0";
|
|
@@ -2105,7 +1830,7 @@ var BalanceComponent = ({ srcToken, balances }) => {
|
|
|
2105
1830
|
precisionFractionalPlaces: 5
|
|
2106
1831
|
});
|
|
2107
1832
|
}, [srcToken, balances]);
|
|
2108
|
-
return /* @__PURE__ */ (0,
|
|
1833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
2109
1834
|
"Balance:",
|
|
2110
1835
|
" ",
|
|
2111
1836
|
srcToken && balances ? weiToHumanReadable({
|
|
@@ -2113,12 +1838,12 @@ var BalanceComponent = ({ srcToken, balances }) => {
|
|
|
2113
1838
|
decimals: srcToken.decimals,
|
|
2114
1839
|
precisionFractionalPlaces: 4
|
|
2115
1840
|
}) : 0,
|
|
2116
|
-
/* @__PURE__ */ (0,
|
|
1841
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "bg-gradient-to-r from-x_blue_light to-x_blue_dark bg-clip-text text-transparent", children: "Max" })
|
|
2117
1842
|
] });
|
|
2118
1843
|
};
|
|
2119
1844
|
|
|
2120
1845
|
// src/components/TxConfigForm/SwapPanel.tsx
|
|
2121
|
-
var
|
|
1846
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
2122
1847
|
var SwapPanel = ({
|
|
2123
1848
|
amount,
|
|
2124
1849
|
setAmount,
|
|
@@ -2163,11 +1888,11 @@ var SwapPanel = ({
|
|
|
2163
1888
|
() => supportedChains.filter((chain) => chain.chainId !== srcChain?.chainId),
|
|
2164
1889
|
[supportedChains, srcChain]
|
|
2165
1890
|
);
|
|
2166
|
-
return /* @__PURE__ */ (0,
|
|
2167
|
-
/* @__PURE__ */ (0,
|
|
2168
|
-
/* @__PURE__ */ (0,
|
|
2169
|
-
/* @__PURE__ */ (0,
|
|
2170
|
-
/* @__PURE__ */ (0,
|
|
1891
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex justify-between globalBorder rounded-lg bg-[rgba(15,15,15,1)] p-4", children: [
|
|
1892
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col justify-between gap-2 overflow-hidden w-1/2", children: [
|
|
1893
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
1894
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-white opacity-60 text-xs sm:text-sm font-medium", children: "You pay" }),
|
|
1895
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2171
1896
|
"input",
|
|
2172
1897
|
{
|
|
2173
1898
|
className: "p-0 border-none outline-none bg-transparent text-2xl overflow-ellipsis",
|
|
@@ -2186,7 +1911,7 @@ var SwapPanel = ({
|
|
|
2186
1911
|
}
|
|
2187
1912
|
)
|
|
2188
1913
|
] }),
|
|
2189
|
-
/* @__PURE__ */ (0,
|
|
1914
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "flex items-center text-sm text-[rgba(255,255,255,0.6)]", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2190
1915
|
UsdPrice,
|
|
2191
1916
|
{
|
|
2192
1917
|
prices,
|
|
@@ -2196,8 +1921,8 @@ var SwapPanel = ({
|
|
|
2196
1921
|
}
|
|
2197
1922
|
) })
|
|
2198
1923
|
] }),
|
|
2199
|
-
/* @__PURE__ */ (0,
|
|
2200
|
-
/* @__PURE__ */ (0,
|
|
1924
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col relative items-end gap-2.5 w-1/2 text-xs", children: [
|
|
1925
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
2201
1926
|
"div",
|
|
2202
1927
|
{
|
|
2203
1928
|
className: "flex gap-2 items-center p-2 max-w-full cursor-pointer bg-black text-white globalBorder rounded-3xl whitespace-nowrap",
|
|
@@ -2205,7 +1930,7 @@ var SwapPanel = ({
|
|
|
2205
1930
|
setTokenListShown((state) => !state);
|
|
2206
1931
|
},
|
|
2207
1932
|
children: [
|
|
2208
|
-
/* @__PURE__ */ (0,
|
|
1933
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2209
1934
|
"img",
|
|
2210
1935
|
{
|
|
2211
1936
|
height: 16,
|
|
@@ -2214,12 +1939,12 @@ var SwapPanel = ({
|
|
|
2214
1939
|
alt: srcToken?.name
|
|
2215
1940
|
}
|
|
2216
1941
|
),
|
|
2217
|
-
/* @__PURE__ */ (0,
|
|
2218
|
-
/* @__PURE__ */ (0,
|
|
1942
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { children: srcToken?.symbol }),
|
|
1943
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DownArrowIcon, {})
|
|
2219
1944
|
]
|
|
2220
1945
|
}
|
|
2221
1946
|
),
|
|
2222
|
-
tokenListShown && /* @__PURE__ */ (0,
|
|
1947
|
+
tokenListShown && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2223
1948
|
TokenPicker,
|
|
2224
1949
|
{
|
|
2225
1950
|
onCloseClick: () => setTokenListShown(false),
|
|
@@ -2230,22 +1955,22 @@ var SwapPanel = ({
|
|
|
2230
1955
|
balances
|
|
2231
1956
|
}
|
|
2232
1957
|
),
|
|
2233
|
-
/* @__PURE__ */ (0,
|
|
1958
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2234
1959
|
"div",
|
|
2235
1960
|
{
|
|
2236
1961
|
onClick: handleMaxClick,
|
|
2237
1962
|
className: "flex gap-1 items-center font-medium text-white opacity-60 py-0.5 cursor-pointer",
|
|
2238
|
-
children: signer && /* @__PURE__ */ (0,
|
|
1963
|
+
children: signer && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(BalanceComponent, { balances, srcToken })
|
|
2239
1964
|
}
|
|
2240
1965
|
),
|
|
2241
|
-
/* @__PURE__ */ (0,
|
|
1966
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
2242
1967
|
"div",
|
|
2243
1968
|
{
|
|
2244
1969
|
ref: buttonRef,
|
|
2245
1970
|
className: "bg-black globalBorder rounded-2xl whitespace-nowrap flex items-center p-2 cursor-pointer gap-2",
|
|
2246
1971
|
onClick: () => setChainListShown((prev) => !prev),
|
|
2247
1972
|
children: [
|
|
2248
|
-
/* @__PURE__ */ (0,
|
|
1973
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2249
1974
|
"img",
|
|
2250
1975
|
{
|
|
2251
1976
|
width: "16",
|
|
@@ -2254,17 +1979,17 @@ var SwapPanel = ({
|
|
|
2254
1979
|
alt: srcChain?.name
|
|
2255
1980
|
}
|
|
2256
1981
|
),
|
|
2257
|
-
/* @__PURE__ */ (0,
|
|
2258
|
-
/* @__PURE__ */ (0,
|
|
1982
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { children: srcChain?.displayName }),
|
|
1983
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DownArrowIcon, {})
|
|
2259
1984
|
]
|
|
2260
1985
|
}
|
|
2261
1986
|
),
|
|
2262
|
-
chainListShown && /* @__PURE__ */ (0,
|
|
1987
|
+
chainListShown && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2263
1988
|
"ul",
|
|
2264
1989
|
{
|
|
2265
1990
|
ref: listRef,
|
|
2266
1991
|
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",
|
|
2267
|
-
children: chainListOptions.map((chain, index) => /* @__PURE__ */ (0,
|
|
1992
|
+
children: chainListOptions.map((chain, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2268
1993
|
ChainListElement,
|
|
2269
1994
|
{
|
|
2270
1995
|
index,
|
|
@@ -2281,9 +2006,9 @@ var SwapPanel = ({
|
|
|
2281
2006
|
};
|
|
2282
2007
|
|
|
2283
2008
|
// src/components/TxConfigForm/ErrorField.tsx
|
|
2284
|
-
var
|
|
2009
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
2285
2010
|
var ErrorField = ({ error }) => {
|
|
2286
|
-
return /* @__PURE__ */ (0,
|
|
2011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
2287
2012
|
"div",
|
|
2288
2013
|
{
|
|
2289
2014
|
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"}`,
|
|
@@ -2293,15 +2018,15 @@ var ErrorField = ({ error }) => {
|
|
|
2293
2018
|
};
|
|
2294
2019
|
|
|
2295
2020
|
// src/components/TxConfigForm/Description.tsx
|
|
2296
|
-
var
|
|
2021
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
2297
2022
|
var Description = ({ description }) => {
|
|
2298
|
-
return /* @__PURE__ */ (0,
|
|
2023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "flex flex-col items-start rounded-lg px-4 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "w-full flex gap-4 items-start justify-between text-xl", children: description }) });
|
|
2299
2024
|
};
|
|
2300
2025
|
|
|
2301
2026
|
// src/components/TxConfigForm/Button.tsx
|
|
2302
|
-
var
|
|
2027
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
2303
2028
|
var Button = ({ children, onClick, type, disabled }) => {
|
|
2304
|
-
return /* @__PURE__ */ (0,
|
|
2029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2305
2030
|
"button",
|
|
2306
2031
|
{
|
|
2307
2032
|
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",
|
|
@@ -2314,7 +2039,7 @@ var Button = ({ children, onClick, type, disabled }) => {
|
|
|
2314
2039
|
};
|
|
2315
2040
|
|
|
2316
2041
|
// src/components/TxConfigForm/Form.tsx
|
|
2317
|
-
var
|
|
2042
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
2318
2043
|
var Form = ({
|
|
2319
2044
|
dstChainId,
|
|
2320
2045
|
dstTokenAddr,
|
|
@@ -2379,7 +2104,7 @@ var Form = ({
|
|
|
2379
2104
|
`Configuration error: selected token ($${srcToken.symbol} ${srcToken.name}) has unknown decimals param.`
|
|
2380
2105
|
);
|
|
2381
2106
|
getRoute({
|
|
2382
|
-
fromAmount:
|
|
2107
|
+
fromAmount: import_ethers4.ethers.utils.parseUnits(debouncedAmount, srcToken.decimals).toString(),
|
|
2383
2108
|
fromAddress: signer || ADDRESSES[srcChain.chainId].FeeCollector,
|
|
2384
2109
|
fromChain: srcChain.chainId,
|
|
2385
2110
|
fromToken: srcToken.address,
|
|
@@ -2413,7 +2138,7 @@ var Form = ({
|
|
|
2413
2138
|
if (srcChain) {
|
|
2414
2139
|
setPaymentToken(
|
|
2415
2140
|
srcChain.tokens.find(
|
|
2416
|
-
(token) => token.address.toLowerCase() ===
|
|
2141
|
+
(token) => token.address.toLowerCase() === import_ethers4.ethers.constants.AddressZero.toLowerCase()
|
|
2417
2142
|
)
|
|
2418
2143
|
);
|
|
2419
2144
|
}
|
|
@@ -2444,13 +2169,13 @@ var Form = ({
|
|
|
2444
2169
|
const handleSwitchChain = async () => {
|
|
2445
2170
|
await switchChainAsync({ chainId: Number(srcChain?.chainId) });
|
|
2446
2171
|
};
|
|
2447
|
-
return /* @__PURE__ */ (0,
|
|
2172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
2448
2173
|
"form",
|
|
2449
2174
|
{
|
|
2450
2175
|
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",
|
|
2451
2176
|
onSubmit: handleSubmit,
|
|
2452
2177
|
children: [
|
|
2453
|
-
/* @__PURE__ */ (0,
|
|
2178
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2454
2179
|
TopBar,
|
|
2455
2180
|
{
|
|
2456
2181
|
signer,
|
|
@@ -2459,7 +2184,7 @@ var Form = ({
|
|
|
2459
2184
|
setSettingsShown
|
|
2460
2185
|
}
|
|
2461
2186
|
),
|
|
2462
|
-
settingsShown && /* @__PURE__ */ (0,
|
|
2187
|
+
settingsShown && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2463
2188
|
Settings,
|
|
2464
2189
|
{
|
|
2465
2190
|
expressChecked,
|
|
@@ -2469,9 +2194,9 @@ var Form = ({
|
|
|
2469
2194
|
setSlippage
|
|
2470
2195
|
}
|
|
2471
2196
|
),
|
|
2472
|
-
historyTabShown ? /* @__PURE__ */ (0,
|
|
2473
|
-
desc && /* @__PURE__ */ (0,
|
|
2474
|
-
/* @__PURE__ */ (0,
|
|
2197
|
+
historyTabShown ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(History, { signer, supportedChains }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
2198
|
+
desc && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Description, { description: desc }),
|
|
2199
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2475
2200
|
SwapPanel,
|
|
2476
2201
|
{
|
|
2477
2202
|
amount,
|
|
@@ -2486,7 +2211,7 @@ var Form = ({
|
|
|
2486
2211
|
setSrcChain
|
|
2487
2212
|
}
|
|
2488
2213
|
),
|
|
2489
|
-
/* @__PURE__ */ (0,
|
|
2214
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2490
2215
|
Summary,
|
|
2491
2216
|
{
|
|
2492
2217
|
isGettingRoute,
|
|
@@ -2495,7 +2220,7 @@ var Form = ({
|
|
|
2495
2220
|
dstChain
|
|
2496
2221
|
}
|
|
2497
2222
|
),
|
|
2498
|
-
/* @__PURE__ */ (0,
|
|
2223
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2499
2224
|
FeesDetails,
|
|
2500
2225
|
{
|
|
2501
2226
|
route,
|
|
@@ -2508,8 +2233,8 @@ var Form = ({
|
|
|
2508
2233
|
setFeesDetailsShown
|
|
2509
2234
|
}
|
|
2510
2235
|
),
|
|
2511
|
-
formError.length > 0 && /* @__PURE__ */ (0,
|
|
2512
|
-
signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ (0,
|
|
2236
|
+
formError.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ErrorField, { error: formError }),
|
|
2237
|
+
signer && srcChain && srcChain.chainId !== account.chainId?.toString() ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { type: "button", onClick: handleSwitchChain, children: "Switch chain" }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2513
2238
|
Button,
|
|
2514
2239
|
{
|
|
2515
2240
|
type: "submit",
|
|
@@ -2523,11 +2248,8 @@ var Form = ({
|
|
|
2523
2248
|
);
|
|
2524
2249
|
};
|
|
2525
2250
|
|
|
2526
|
-
// package.json
|
|
2527
|
-
var version = "0.2.0";
|
|
2528
|
-
|
|
2529
2251
|
// src/components/TxConfigForm/index.tsx
|
|
2530
|
-
var
|
|
2252
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
2531
2253
|
var TxConfigForm = ({
|
|
2532
2254
|
dstChainId,
|
|
2533
2255
|
dstTokenAddr,
|
|
@@ -2549,13 +2271,13 @@ var TxConfigForm = ({
|
|
|
2549
2271
|
() => getWagmiConfig(supportedChains),
|
|
2550
2272
|
supportedChains
|
|
2551
2273
|
);
|
|
2552
|
-
return /* @__PURE__ */ (0,
|
|
2274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_wagmi3.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2553
2275
|
"div",
|
|
2554
2276
|
{
|
|
2555
2277
|
className: "top-0 left-0 right-0 bottom-0 bg-[rgba(0,0,0,0.8)] fixed flex items-center justify-center z-10",
|
|
2556
2278
|
onClick: onBackdropClick,
|
|
2557
|
-
children: /* @__PURE__ */ (0,
|
|
2558
|
-
/* @__PURE__ */ (0,
|
|
2279
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("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: [
|
|
2280
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2559
2281
|
Form,
|
|
2560
2282
|
{
|
|
2561
2283
|
dstChainId,
|
|
@@ -2566,20 +2288,15 @@ var TxConfigForm = ({
|
|
|
2566
2288
|
onSubmit
|
|
2567
2289
|
}
|
|
2568
2290
|
),
|
|
2569
|
-
/* @__PURE__ */ (0,
|
|
2291
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2570
2292
|
"div",
|
|
2571
2293
|
{
|
|
2572
2294
|
className: "absolute top-7 right-4 cursor-pointer text-white",
|
|
2573
2295
|
onClick: onClose,
|
|
2574
|
-
children: /* @__PURE__ */ (0,
|
|
2296
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CloseIcon, {})
|
|
2575
2297
|
}
|
|
2576
2298
|
),
|
|
2577
|
-
/* @__PURE__ */ (0,
|
|
2578
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: "Powered by" }),
|
|
2579
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(XSwapBadgeIcon, {}),
|
|
2580
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: "\u2715" }),
|
|
2581
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChainlinkCCIPIcon, {})
|
|
2582
|
-
] })
|
|
2299
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(PoweredBy, {})
|
|
2583
2300
|
] })
|
|
2584
2301
|
}
|
|
2585
2302
|
) }) });
|
|
@@ -2594,7 +2311,7 @@ var openTxConfigForm = async ({
|
|
|
2594
2311
|
try {
|
|
2595
2312
|
return await new Promise((resolve) => {
|
|
2596
2313
|
xswapRoot.render(
|
|
2597
|
-
/* @__PURE__ */ (0,
|
|
2314
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2598
2315
|
TxConfigForm,
|
|
2599
2316
|
{
|
|
2600
2317
|
dstChainId,
|
|
@@ -2617,24 +2334,11 @@ var openTxConfigForm = async ({
|
|
|
2617
2334
|
throw new Error(`XSwap component error, ${err}`);
|
|
2618
2335
|
}
|
|
2619
2336
|
};
|
|
2620
|
-
var xswapRoot;
|
|
2621
|
-
if (typeof document !== "undefined") {
|
|
2622
|
-
const xswapStyleElement = document.createElement("link");
|
|
2623
|
-
xswapStyleElement.rel = "stylesheet";
|
|
2624
|
-
xswapStyleElement.type = "text/css";
|
|
2625
|
-
xswapStyleElement.href = `${xswap_config_default.apiUrl}/sdk/css/${version}`;
|
|
2626
|
-
document.head.appendChild(xswapStyleElement);
|
|
2627
|
-
const xswapModalElement = document.createElement("div");
|
|
2628
|
-
xswapModalElement.setAttribute("id", "xswap-modal");
|
|
2629
|
-
document.body.appendChild(xswapModalElement);
|
|
2630
|
-
xswapRoot = (0, import_client.createRoot)(xswapModalElement);
|
|
2631
|
-
}
|
|
2632
2337
|
|
|
2633
|
-
// src/components/
|
|
2338
|
+
// src/components/TxStatusButton/index.tsx
|
|
2634
2339
|
var import_react12 = require("react");
|
|
2635
|
-
var
|
|
2636
|
-
var
|
|
2637
|
-
var TxHistoryButton = ({ transaction }) => {
|
|
2340
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
2341
|
+
var TxStatusButton = ({ transaction }) => {
|
|
2638
2342
|
const {
|
|
2639
2343
|
fromChain,
|
|
2640
2344
|
fromChainImage,
|
|
@@ -2648,15 +2352,23 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2648
2352
|
explorer
|
|
2649
2353
|
} = transaction;
|
|
2650
2354
|
const [isWide, setIsWide] = (0, import_react12.useState)(false);
|
|
2651
|
-
|
|
2652
|
-
|
|
2355
|
+
const background = (0, import_react12.useMemo)(
|
|
2356
|
+
() => 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)]",
|
|
2357
|
+
[isDone]
|
|
2358
|
+
);
|
|
2359
|
+
const border = (0, import_react12.useMemo)(
|
|
2360
|
+
() => isDone ? "border border-solid border-x_green_dark" : "border border-solid border-x_blue_dark",
|
|
2361
|
+
[isDone]
|
|
2362
|
+
);
|
|
2363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex gap-2", onClick: () => setIsWide((x) => !x), children: [
|
|
2364
|
+
isWide && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
2653
2365
|
"div",
|
|
2654
2366
|
{
|
|
2655
|
-
className: `flex items-center min-w-60 sm:w-[520px] text-white h-14 px-4 text-sm gap-3 rounded-xl
|
|
2367
|
+
className: `flex items-center min-w-60 sm:w-[520px] text-white h-14 px-4 text-sm gap-3 rounded-xl ${background} ${border}`,
|
|
2656
2368
|
children: [
|
|
2657
|
-
/* @__PURE__ */ (0,
|
|
2658
|
-
/* @__PURE__ */ (0,
|
|
2659
|
-
/* @__PURE__ */ (0,
|
|
2369
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex justify-between flex-col gap-2 sm:gap-5 sm:flex-row w-full", children: [
|
|
2370
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2371
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
2660
2372
|
"img",
|
|
2661
2373
|
{
|
|
2662
2374
|
className: "w-5 h-5",
|
|
@@ -2664,16 +2376,16 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2664
2376
|
alt: "source chain"
|
|
2665
2377
|
}
|
|
2666
2378
|
),
|
|
2667
|
-
/* @__PURE__ */ (0,
|
|
2668
|
-
/* @__PURE__ */ (0,
|
|
2669
|
-
/* @__PURE__ */ (0,
|
|
2670
|
-
/* @__PURE__ */ (0,
|
|
2379
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: fromChain }),
|
|
2380
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ArrowRightIcon, {}) }),
|
|
2381
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("img", { className: "w-5 h-5", src: toChainImage, alt: "to chain" }),
|
|
2382
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: toChain })
|
|
2671
2383
|
] }),
|
|
2672
|
-
/* @__PURE__ */ (0,
|
|
2673
|
-
/* @__PURE__ */ (0,
|
|
2674
|
-
/* @__PURE__ */ (0,
|
|
2675
|
-
/* @__PURE__ */ (0,
|
|
2676
|
-
/* @__PURE__ */ (0,
|
|
2384
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2385
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: "Sent" }),
|
|
2386
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: fromAmount }),
|
|
2387
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: fromToken }),
|
|
2388
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
2677
2389
|
"img",
|
|
2678
2390
|
{
|
|
2679
2391
|
className: "w-5 h-5",
|
|
@@ -2683,7 +2395,7 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2683
2395
|
)
|
|
2684
2396
|
] })
|
|
2685
2397
|
] }),
|
|
2686
|
-
/* @__PURE__ */ (0,
|
|
2398
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
2687
2399
|
"a",
|
|
2688
2400
|
{
|
|
2689
2401
|
href: explorer,
|
|
@@ -2691,22 +2403,21 @@ var TxHistoryButton = ({ transaction }) => {
|
|
|
2691
2403
|
rel: "noreferrer",
|
|
2692
2404
|
className: "no-underline cursor-pointer",
|
|
2693
2405
|
"aria-label": "Show the transaction in the chain explorer",
|
|
2694
|
-
children: /* @__PURE__ */ (0,
|
|
2406
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "w-3.5 h-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ArrowUpRightIcon, {}) })
|
|
2695
2407
|
}
|
|
2696
2408
|
)
|
|
2697
2409
|
]
|
|
2698
2410
|
}
|
|
2699
2411
|
),
|
|
2700
|
-
/* @__PURE__ */ (0,
|
|
2412
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
2701
2413
|
"div",
|
|
2702
2414
|
{
|
|
2703
|
-
className: `text-white rounded-xl cursor-pointer
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
/* @__PURE__ */ (0,
|
|
2707
|
-
|
|
2708
|
-
/* @__PURE__ */ (0,
|
|
2709
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CircularProgressIcon, {}) })
|
|
2415
|
+
className: `text-white rounded-xl cursor-pointer ${background} ${border}`,
|
|
2416
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex gap-2 items-center h-14 w-20 justify-center", children: [
|
|
2417
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ArrowLeftIcon, {}),
|
|
2418
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "relative flex items-center justify-center w-9 h-9", children: isDone ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "text-x_green w-5 h-5", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CheckIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
2419
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "w-5 h-5", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(XSwapLogo, {}) }),
|
|
2420
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "absolute flex items-center justify-center top-0 left-0 right-0 bottom-0 text-white", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CircularProgressIcon, {}) })
|
|
2710
2421
|
] }) })
|
|
2711
2422
|
] })
|
|
2712
2423
|
}
|
|
@@ -2732,74 +2443,160 @@ var updateTransactionDoneInRenderedTransactions = (txHash) => {
|
|
|
2732
2443
|
transaction.isDone = true;
|
|
2733
2444
|
}
|
|
2734
2445
|
};
|
|
2735
|
-
var
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
"class",
|
|
2739
|
-
"absolute bottom-5 right-2 flex flex-col gap-3 pl-9 items-end w-full z-50"
|
|
2740
|
-
);
|
|
2741
|
-
document.body.appendChild(historyElement);
|
|
2742
|
-
var txHistoryButtonRoot = (0, import_client2.createRoot)(historyElement);
|
|
2743
|
-
var renderTxHistoryButtons = () => {
|
|
2744
|
-
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(TxHistoryButton, { transaction: item }, item.txHash));
|
|
2745
|
-
txHistoryButtonRoot.render(buttons);
|
|
2446
|
+
var renderTxStatusButtons = () => {
|
|
2447
|
+
const buttons = renderedTransactions.map((item) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(TxStatusButton, { transaction: item }, item.txHash));
|
|
2448
|
+
txStatusRoot.render(buttons);
|
|
2746
2449
|
};
|
|
2747
2450
|
|
|
2748
2451
|
// src/components/Skeleton/index.tsx
|
|
2749
|
-
var
|
|
2452
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
2750
2453
|
var Skeleton = ({ width, height }) => {
|
|
2751
|
-
return /* @__PURE__ */ (0,
|
|
2454
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: `bg-current rounded animate-pulse ${width} ${height}` });
|
|
2455
|
+
};
|
|
2456
|
+
|
|
2457
|
+
// src/services/integrations/monitoring.ts
|
|
2458
|
+
var import_async_retry = __toESM(require("async-retry"));
|
|
2459
|
+
var monitorTransactionStatus = async (txChainId, txHash) => {
|
|
2460
|
+
const txReceipt = await getTxReceipt(txChainId, txHash);
|
|
2461
|
+
const supportedChains = (await getChains()).filter(
|
|
2462
|
+
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
2463
|
+
);
|
|
2464
|
+
const messageSentEvent = txReceipt.logs?.find((log) => {
|
|
2465
|
+
return log.topics[0] === import_ethers5.ethers.utils.id(MSG_SENT_EVENT_SIG);
|
|
2466
|
+
});
|
|
2467
|
+
if (!messageSentEvent) {
|
|
2468
|
+
throw new Error(
|
|
2469
|
+
`No transaction event found for chain ${txChainId} tx ${txHash}`
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
const messageId = messageSentEvent?.topics[1];
|
|
2473
|
+
const iface = new import_ethers5.ethers.utils.Interface(MSG_SENT_EVENT_ABI);
|
|
2474
|
+
const decodedMessageSentEvent = iface.parseLog(messageSentEvent);
|
|
2475
|
+
if (!decodedMessageSentEvent) {
|
|
2476
|
+
throw new Error(
|
|
2477
|
+
`No transaction event arguments found for chain ${txChainId} tx ${txHash}`
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
const srcChain = supportedChains.find(
|
|
2481
|
+
(chain) => chain.chainId === txChainId.toString()
|
|
2482
|
+
);
|
|
2483
|
+
const srcToken = srcChain?.tokens.find(
|
|
2484
|
+
(token) => token.address === decodedMessageSentEvent.args?.token.toString()
|
|
2485
|
+
);
|
|
2486
|
+
const dstChain = supportedChains.find(
|
|
2487
|
+
(chain) => chain.ccipChainId === decodedMessageSentEvent.args?.destinationChainSelector?.toString()
|
|
2488
|
+
);
|
|
2489
|
+
const dstChainId = dstChain?.chainId;
|
|
2490
|
+
if (!dstChainId) {
|
|
2491
|
+
throw new Error(`Unknown destination chain!`);
|
|
2492
|
+
}
|
|
2493
|
+
const transaction = {
|
|
2494
|
+
txHash,
|
|
2495
|
+
fromChain: srcChain?.displayName,
|
|
2496
|
+
fromChainImage: srcChain?.image,
|
|
2497
|
+
toChain: dstChain.displayName,
|
|
2498
|
+
toChainImage: dstChain.image,
|
|
2499
|
+
fromToken: srcToken?.symbol,
|
|
2500
|
+
fromTokenImage: srcToken?.image,
|
|
2501
|
+
fromAmount: weiToHumanReadable({
|
|
2502
|
+
amount: decodedMessageSentEvent.args?.tokenAmount.toString(),
|
|
2503
|
+
decimals: srcToken?.decimals || 18,
|
|
2504
|
+
precisionFractionalPlaces: 4
|
|
2505
|
+
}),
|
|
2506
|
+
isDone: false,
|
|
2507
|
+
explorer: `${CCIP_EXPLORER}/tx/${txHash}`
|
|
2508
|
+
};
|
|
2509
|
+
addTransactionToRenderedTransactions(transaction);
|
|
2510
|
+
renderTxStatusButtons();
|
|
2511
|
+
const xSwapRouterOnDestinationAddress = ADDRESSES[dstChainId]?.XSwapRouter;
|
|
2512
|
+
if (!xSwapRouterOnDestinationAddress) {
|
|
2513
|
+
throw new Error(`Unknown destination XSwapRouter!`);
|
|
2514
|
+
}
|
|
2515
|
+
const xSwapRouterOnDestination = new import_ethers5.ethers.Contract(
|
|
2516
|
+
xSwapRouterOnDestinationAddress,
|
|
2517
|
+
MSG_RECEIVED_EVENT_ABI,
|
|
2518
|
+
import_ethers5.ethers.getDefaultProvider(
|
|
2519
|
+
supportedChains.find((chain) => chain.chainId === dstChainId)?.publicRpcUrls[0]
|
|
2520
|
+
)
|
|
2521
|
+
);
|
|
2522
|
+
const msgReceivedEventFilter = {
|
|
2523
|
+
address: xSwapRouterOnDestinationAddress,
|
|
2524
|
+
topics: [import_ethers5.ethers.utils.id(MSG_RECEIVED_EVENT_SIG), messageId]
|
|
2525
|
+
};
|
|
2526
|
+
const onSuccess = async () => {
|
|
2527
|
+
updateTransactionDoneInRenderedTransactions(txHash);
|
|
2528
|
+
renderTxStatusButtons();
|
|
2529
|
+
await new Promise(
|
|
2530
|
+
(resolve) => setTimeout(() => resolve(true), TX_RECEIPT_STATUS_LIFETIME)
|
|
2531
|
+
);
|
|
2532
|
+
removeTransactionFromRenderedTransactions(txHash);
|
|
2533
|
+
renderTxStatusButtons();
|
|
2534
|
+
};
|
|
2535
|
+
xSwapRouterOnDestination.once(msgReceivedEventFilter, () => onSuccess());
|
|
2536
|
+
};
|
|
2537
|
+
var getTxReceipt = async (txChainId, txHash) => {
|
|
2538
|
+
try {
|
|
2539
|
+
const chain = (await getChains()).find(
|
|
2540
|
+
(chain2) => chain2.chainId === txChainId
|
|
2541
|
+
);
|
|
2542
|
+
const provider = new import_ethers5.ethers.providers.JsonRpcProvider(
|
|
2543
|
+
chain?.publicRpcUrls[0]
|
|
2544
|
+
);
|
|
2545
|
+
return await (0, import_async_retry.default)(async () => {
|
|
2546
|
+
const txReceipt = await provider.getTransactionReceipt(txHash);
|
|
2547
|
+
if (!txReceipt) {
|
|
2548
|
+
throw new Error(`Couldn't fetch tx receipt`);
|
|
2549
|
+
}
|
|
2550
|
+
return txReceipt;
|
|
2551
|
+
});
|
|
2552
|
+
} catch (e) {
|
|
2553
|
+
throw new Error(
|
|
2554
|
+
`Couldn't fetch tx ${txHash} receipt on chain ${txChainId}`
|
|
2555
|
+
);
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2558
|
+
|
|
2559
|
+
// src/services/integrations/transactions.ts
|
|
2560
|
+
var getSwapTx = async ({
|
|
2561
|
+
dstChain,
|
|
2562
|
+
dstToken,
|
|
2563
|
+
customContractCalls = [],
|
|
2564
|
+
desc
|
|
2565
|
+
}) => {
|
|
2566
|
+
const supportedChains = (await getChains()).filter(
|
|
2567
|
+
({ web3Environment, swapSupported }) => web3Environment === "mainnet" /* MAINNET */ && swapSupported
|
|
2568
|
+
);
|
|
2569
|
+
validateSwapTxData(supportedChains, dstChain, dstToken);
|
|
2570
|
+
const route = await openTxConfigForm({
|
|
2571
|
+
dstChainId: dstChain,
|
|
2572
|
+
dstTokenAddr: dstToken,
|
|
2573
|
+
customContractCalls,
|
|
2574
|
+
desc,
|
|
2575
|
+
supportedChains
|
|
2576
|
+
});
|
|
2577
|
+
return route.transactions;
|
|
2578
|
+
};
|
|
2579
|
+
var validateSwapTxData = (supportedChains, dstChain, dstToken) => {
|
|
2580
|
+
const supportedDstChain = supportedChains.find(
|
|
2581
|
+
({ chainId }) => chainId === dstChain
|
|
2582
|
+
);
|
|
2583
|
+
if (!supportedDstChain) {
|
|
2584
|
+
throw new Error(`Provided chain '${dstChain}' is not supported`);
|
|
2585
|
+
}
|
|
2586
|
+
if (!supportedDstChain.tokens.some(({ address }) => address === dstToken)) {
|
|
2587
|
+
throw new Error(`Provided token '${dstToken}' is not supported`);
|
|
2588
|
+
}
|
|
2752
2589
|
};
|
|
2590
|
+
|
|
2591
|
+
// src/index.ts
|
|
2592
|
+
initDocument();
|
|
2753
2593
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2754
2594
|
0 && (module.exports = {
|
|
2755
|
-
ADDRESSES,
|
|
2756
|
-
Alert,
|
|
2757
|
-
BALANCES_CHUNK_SIZE,
|
|
2758
|
-
BatchQueryAbi,
|
|
2759
|
-
CCIP_EXPLORER,
|
|
2760
2595
|
ContractName,
|
|
2761
|
-
DEFAULT_ECOSYSTEM,
|
|
2762
|
-
DEFAULT_SOURCE_CHAIN_ID,
|
|
2763
|
-
DELIVERY_TIME,
|
|
2764
|
-
ERC20Abi,
|
|
2765
|
-
EXPRESS_DELIVERY_TIME,
|
|
2766
2596
|
Ecosystem,
|
|
2767
2597
|
Environment,
|
|
2768
|
-
IERC20,
|
|
2769
|
-
MINIMUM_DISPLAYED_TOKEN_AMOUNT,
|
|
2770
|
-
NUMBER_INPUT_REGEX,
|
|
2771
|
-
ROUTE_TIMEOUT_MS,
|
|
2772
|
-
SLIPPAGE_PRESETS,
|
|
2773
|
-
Skeleton,
|
|
2774
|
-
TxHistoryButton,
|
|
2775
2598
|
Web3Environment,
|
|
2776
2599
|
XSwapCallType,
|
|
2777
|
-
addTransactionToRenderedTransactions,
|
|
2778
|
-
chunkArray,
|
|
2779
|
-
deepMergeObjects,
|
|
2780
|
-
findPlaceholderIndex,
|
|
2781
|
-
generateApproveTxData,
|
|
2782
|
-
generateRandomBigNumber,
|
|
2783
|
-
generateStakingCalls,
|
|
2784
|
-
generateUniqueRandomBigNumber,
|
|
2785
|
-
getBalanceOf,
|
|
2786
|
-
getBalances,
|
|
2787
|
-
getBridgeTokens,
|
|
2788
|
-
getChainData,
|
|
2789
|
-
getChains,
|
|
2790
|
-
getDate,
|
|
2791
|
-
getHistory,
|
|
2792
|
-
getPrices,
|
|
2793
|
-
getRoute,
|
|
2794
2600
|
getSwapTx,
|
|
2795
|
-
|
|
2796
|
-
monitorTransactionStatus,
|
|
2797
|
-
openTxConfigForm,
|
|
2798
|
-
removeTransactionFromRenderedTransactions,
|
|
2799
|
-
renderTxHistoryButtons,
|
|
2800
|
-
replaceNull,
|
|
2801
|
-
safeBigNumberFrom,
|
|
2802
|
-
shortAddress,
|
|
2803
|
-
updateTransactionDoneInRenderedTransactions,
|
|
2804
|
-
weiToHumanReadable
|
|
2601
|
+
monitorTransactionStatus
|
|
2805
2602
|
});
|