uniport-sdk 0.0.1 → 0.0.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/LICENSE +21 -0
- package/README.md +128 -73
- package/dist/components/index.cjs +1140 -975
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +1118 -953
- package/dist/components/index.js.map +1 -1
- package/dist/core/index.cjs +216 -130
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +55 -45
- package/dist/core/index.d.ts +55 -45
- package/dist/core/index.js +212 -116
- package/dist/core/index.js.map +1 -1
- package/dist/{index-uzI1Zngp.d.cts → index-Dg_m2bK3.d.cts} +19 -10
- package/dist/{index-uzI1Zngp.d.ts → index-Dg_m2bK3.d.ts} +19 -10
- package/dist/index.cjs +1178 -1018
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +1145 -975
- package/dist/index.js.map +1 -1
- package/package.json +18 -12
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import React, { useState, useRef, useCallback, useEffect } from 'react';
|
|
1
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
4
3
|
import { QRCodeSVG } from 'qrcode.react';
|
|
5
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
5
|
|
|
@@ -9,7 +8,7 @@ var TOKEN_ICONS = {
|
|
|
9
8
|
// Stablecoins
|
|
10
9
|
USDC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
|
|
11
10
|
USDT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",
|
|
12
|
-
DAI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/
|
|
11
|
+
DAI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeEC495271d0F/logo.png",
|
|
13
12
|
// Major tokens
|
|
14
13
|
ETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
15
14
|
WETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png",
|
|
@@ -42,16 +41,16 @@ var TOKEN_ICONS = {
|
|
|
42
41
|
SHIB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE/logo.png",
|
|
43
42
|
PEPE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6982508145454Ce325dDbE47a25d4ec3d2311933/logo.png",
|
|
44
43
|
// Ecosystem tokens
|
|
45
|
-
STRK: "https://
|
|
46
|
-
BERA: "https://
|
|
44
|
+
STRK: "https://coin-images.coingecko.com/coins/images/26433/large/starknet.png",
|
|
45
|
+
BERA: "https://s2.coinmarketcap.com/static/img/coins/64x64/31645.png",
|
|
47
46
|
GNO: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6810e776880C02933D47DB1b9fc05908e5386b96/logo.png",
|
|
48
|
-
MON: "https://
|
|
47
|
+
MON: "https://s2.coinmarketcap.com/static/img/coins/64x64/33868.png",
|
|
49
48
|
ZEC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png",
|
|
50
49
|
// Meme coins
|
|
51
|
-
TRUMP: "https://
|
|
52
|
-
WIF: "https://
|
|
53
|
-
BRETT: "https://
|
|
54
|
-
TURBO: "https://
|
|
50
|
+
TRUMP: "https://s2.coinmarketcap.com/static/img/coins/64x64/35336.png",
|
|
51
|
+
WIF: "https://s2.coinmarketcap.com/static/img/coins/64x64/28752.png",
|
|
52
|
+
BRETT: "https://s2.coinmarketcap.com/static/img/coins/64x64/29743.png",
|
|
53
|
+
TURBO: "https://s2.coinmarketcap.com/static/img/coins/64x64/24911.png",
|
|
55
54
|
// Default fallback
|
|
56
55
|
DEFAULT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png"
|
|
57
56
|
};
|
|
@@ -73,21 +72,29 @@ var CHAIN_ICONS = {
|
|
|
73
72
|
cardano: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cardano/info/logo.png",
|
|
74
73
|
aptos: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/aptos/info/logo.png",
|
|
75
74
|
gnosis: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/xdai/info/logo.png",
|
|
76
|
-
starknet: "https://
|
|
77
|
-
bera: "https://
|
|
78
|
-
monad: "https://
|
|
75
|
+
starknet: "https://coin-images.coingecko.com/coins/images/26433/large/starknet.png",
|
|
76
|
+
bera: "https://s2.coinmarketcap.com/static/img/coins/64x64/31645.png",
|
|
77
|
+
monad: "https://s2.coinmarketcap.com/static/img/coins/64x64/33868.png",
|
|
79
78
|
doge: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/doge/info/logo.png",
|
|
80
79
|
ltc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png",
|
|
81
80
|
bch: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png",
|
|
82
81
|
xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png",
|
|
83
82
|
zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png"
|
|
84
83
|
};
|
|
85
|
-
function createToken(chain, symbol, assetId, decimals, contractAddress) {
|
|
86
|
-
const
|
|
84
|
+
function createToken(chain, symbol, assetId, decimals, contractAddress, options) {
|
|
85
|
+
const normalizedSymbol = symbol.replace("$", "").replace(" ", "");
|
|
86
|
+
const canonicalPrefix = TOKEN_NAME_PREFIXES[chain] || chain;
|
|
87
|
+
const legacyName = `${chain}${normalizedSymbol}`;
|
|
88
|
+
const name = options?.name || `${canonicalPrefix}${normalizedSymbol}`;
|
|
87
89
|
const icon = TOKEN_ICONS[symbol] || TOKEN_ICONS.DEFAULT;
|
|
88
90
|
const chainIcon = CHAIN_ICONS[chain];
|
|
91
|
+
const aliases = new Set(options?.aliases || []);
|
|
92
|
+
if (legacyName !== name) {
|
|
93
|
+
aliases.add(legacyName);
|
|
94
|
+
}
|
|
89
95
|
return {
|
|
90
96
|
name,
|
|
97
|
+
aliases: aliases.size > 0 ? Array.from(aliases) : void 0,
|
|
91
98
|
symbol,
|
|
92
99
|
assetId,
|
|
93
100
|
chain,
|
|
@@ -97,6 +104,19 @@ function createToken(chain, symbol, assetId, decimals, contractAddress) {
|
|
|
97
104
|
contractAddress
|
|
98
105
|
};
|
|
99
106
|
}
|
|
107
|
+
var TOKEN_NAME_PREFIXES = {
|
|
108
|
+
eth: "ethereum",
|
|
109
|
+
arb: "arbitrum",
|
|
110
|
+
op: "optimism",
|
|
111
|
+
sol: "solana",
|
|
112
|
+
btc: "bitcoin",
|
|
113
|
+
avax: "avalanche",
|
|
114
|
+
doge: "dogecoin",
|
|
115
|
+
ltc: "litecoin",
|
|
116
|
+
bch: "bitcoinCash",
|
|
117
|
+
bera: "berachain",
|
|
118
|
+
zec: "zcash"
|
|
119
|
+
};
|
|
100
120
|
var suiSUI = createToken("sui", "SUI", "nep141:sui.omft.near", 9);
|
|
101
121
|
var suiUSDC = createToken("sui", "USDC", "nep141:sui-c1b81ecaf27933252d31a963bc5e9458f13c18ce.omft.near", 6, "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC");
|
|
102
122
|
var ethereumETH = createToken("eth", "ETH", "nep141:eth.omft.near", 18);
|
|
@@ -118,7 +138,7 @@ var arbitrumARB = createToken("arb", "ARB", "nep141:arb-0x912ce59144191c1204e645
|
|
|
118
138
|
var arbitrumGMX = createToken("arb", "GMX", "nep141:arb-0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a.omft.near", 18, "0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a");
|
|
119
139
|
var baseETH = createToken("base", "ETH", "nep141:base.omft.near", 18);
|
|
120
140
|
var baseUSDC = createToken("base", "USDC", "nep141:base-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913.omft.near", 6, "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913");
|
|
121
|
-
var baseCbBTC = createToken("base", "cbBTC", "nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near", 8, "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf");
|
|
141
|
+
var baseCbBTC = createToken("base", "cbBTC", "nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near", 8, "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf", { name: "baseCbBTC" });
|
|
122
142
|
var baseBRETT = createToken("base", "BRETT", "nep141:base-0x532f27101965dd16442e59d40670faf5ebb142e4.omft.near", 18, "0x532f27101965dd16442e59d40670faf5ebb142e4");
|
|
123
143
|
var optimismETH = createToken("op", "ETH", "nep245:v2_1.omni.hot.tg:10_11111111111111111111", 18);
|
|
124
144
|
var optimismUSDC = createToken("op", "USDC", "nep245:v2_1.omni.hot.tg:10_A2ewyUyDp6qsue1jqZsGypkCxRJ", 6, "0x0b2c639c533813f4aa9d7837caf62653d097ff85");
|
|
@@ -153,7 +173,10 @@ var aptosAPT = createToken("aptos", "APT", "nep141:aptos.omft.near", 8);
|
|
|
153
173
|
var starknetSTRK = createToken("starknet", "STRK", "nep141:starknet.omft.near", 18);
|
|
154
174
|
var berachainBERA = createToken("bera", "BERA", "nep141:bera.omft.near", 18);
|
|
155
175
|
var zcashZEC = createToken("zec", "ZEC", "nep141:zec.omft.near", 8);
|
|
156
|
-
var nearNEAR = createToken("near", "wNEAR", "nep141:wrap.near", 24, "wrap.near"
|
|
176
|
+
var nearNEAR = createToken("near", "wNEAR", "nep141:wrap.near", 24, "wrap.near", {
|
|
177
|
+
name: "nearNEAR",
|
|
178
|
+
aliases: ["nearwNEAR"]
|
|
179
|
+
});
|
|
157
180
|
var nearUSDC = createToken("near", "USDC", "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1", 6, "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1");
|
|
158
181
|
var nearUSDT = createToken("near", "USDT", "nep141:usdt.tether-token.near", 6, "usdt.tether-token.near");
|
|
159
182
|
var CHAINS = {
|
|
@@ -310,7 +333,9 @@ var CHAINS = {
|
|
|
310
333
|
};
|
|
311
334
|
var ALL_TOKENS = Object.values(CHAINS).flatMap((chain) => chain.tokens);
|
|
312
335
|
function getToken(name) {
|
|
313
|
-
return ALL_TOKENS.find(
|
|
336
|
+
return ALL_TOKENS.find(
|
|
337
|
+
(token) => token.name === name || token.aliases?.includes(name)
|
|
338
|
+
);
|
|
314
339
|
}
|
|
315
340
|
function getTokensByChain(chainId) {
|
|
316
341
|
return CHAINS[chainId]?.tokens || [];
|
|
@@ -321,31 +346,77 @@ function getTokenByAssetId(assetId) {
|
|
|
321
346
|
function getSupportedChains() {
|
|
322
347
|
return Object.values(CHAINS).filter((c) => c.tokens.length > 0);
|
|
323
348
|
}
|
|
324
|
-
|
|
325
|
-
|
|
349
|
+
|
|
350
|
+
// src/core/config.ts
|
|
351
|
+
var DEFAULT_HOSTED_BACKEND_URL = "https://uniport-backend-production.up.railway.app";
|
|
352
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 2e4;
|
|
353
|
+
var configuredBackendUrl;
|
|
354
|
+
var configuredRequestTimeoutMs;
|
|
355
|
+
function normalizeBackendUrl(url) {
|
|
356
|
+
return url.replace(/\/+$/, "");
|
|
357
|
+
}
|
|
358
|
+
function getLegacyBackendOverride() {
|
|
359
|
+
const envBackendUrl = typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_UNIPORT_BACKEND_URL : void 0;
|
|
360
|
+
const windowBackendUrl = typeof window !== "undefined" ? window.__UNIPORT_BACKEND_URL__ : void 0;
|
|
361
|
+
return envBackendUrl || windowBackendUrl;
|
|
326
362
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (!config.apiKey) {
|
|
331
|
-
throw new Error("Uniport SDK Error: apiKey is required. Pass your NEAR API key to initUniport().");
|
|
363
|
+
function configureUniport(config) {
|
|
364
|
+
if (config.backendUrl !== void 0) {
|
|
365
|
+
configuredBackendUrl = config.backendUrl ? normalizeBackendUrl(config.backendUrl) : void 0;
|
|
332
366
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
function getConfig() {
|
|
337
|
-
if (!_config) {
|
|
338
|
-
throw new Error(
|
|
339
|
-
"Uniport SDK not initialized. Call initUniport() first."
|
|
340
|
-
);
|
|
367
|
+
if (config.requestTimeoutMs !== void 0) {
|
|
368
|
+
configuredRequestTimeoutMs = config.requestTimeoutMs > 0 ? config.requestTimeoutMs : DEFAULT_REQUEST_TIMEOUT_MS;
|
|
341
369
|
}
|
|
342
|
-
return _config;
|
|
343
370
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
371
|
+
function getUniportConfig() {
|
|
372
|
+
const backendUrl = configuredBackendUrl || getLegacyBackendOverride() || DEFAULT_HOSTED_BACKEND_URL;
|
|
373
|
+
return {
|
|
374
|
+
backendUrl: normalizeBackendUrl(backendUrl),
|
|
375
|
+
requestTimeoutMs: configuredRequestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS
|
|
376
|
+
};
|
|
346
377
|
}
|
|
347
378
|
|
|
348
379
|
// src/core/intents.ts
|
|
380
|
+
var UniportError = class extends Error {
|
|
381
|
+
constructor(params) {
|
|
382
|
+
super(params.message);
|
|
383
|
+
this.name = "UniportError";
|
|
384
|
+
this.code = params.code;
|
|
385
|
+
this.details = params.details;
|
|
386
|
+
this.status = params.status;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
function isAbortError(error) {
|
|
390
|
+
return error instanceof Error && error.name === "AbortError";
|
|
391
|
+
}
|
|
392
|
+
function toUniportError(body, fallback) {
|
|
393
|
+
return new UniportError({
|
|
394
|
+
code: body.code || fallback.code,
|
|
395
|
+
message: body.message || fallback.message,
|
|
396
|
+
details: body.details,
|
|
397
|
+
status: fallback.status
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
function createTimeoutSignal(timeoutMs, externalSignal) {
|
|
401
|
+
const controller = new AbortController();
|
|
402
|
+
let timedOut = false;
|
|
403
|
+
const timeoutId = setTimeout(() => {
|
|
404
|
+
timedOut = true;
|
|
405
|
+
controller.abort();
|
|
406
|
+
}, timeoutMs);
|
|
407
|
+
const abortFromExternal = () => controller.abort();
|
|
408
|
+
externalSignal?.addEventListener("abort", abortFromExternal, {
|
|
409
|
+
once: true
|
|
410
|
+
});
|
|
411
|
+
return {
|
|
412
|
+
signal: controller.signal,
|
|
413
|
+
didTimeout: () => timedOut,
|
|
414
|
+
cleanup: () => {
|
|
415
|
+
clearTimeout(timeoutId);
|
|
416
|
+
externalSignal?.removeEventListener("abort", abortFromExternal);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
}
|
|
349
420
|
function toSmallestUnits(amount, decimals) {
|
|
350
421
|
const [whole, fraction = ""] = amount.split(".");
|
|
351
422
|
const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
|
|
@@ -361,16 +432,7 @@ function generateDeadline(hoursFromNow = 1) {
|
|
|
361
432
|
const deadline = new Date(Date.now() + hoursFromNow * 60 * 60 * 1e3);
|
|
362
433
|
return deadline.toISOString();
|
|
363
434
|
}
|
|
364
|
-
function ensureInitialized() {
|
|
365
|
-
if (!isInitialized()) {
|
|
366
|
-
throw new Error(
|
|
367
|
-
"Uniport SDK not initialized. Call initUniport() first."
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
435
|
async function getQuote(options) {
|
|
372
|
-
ensureInitialized();
|
|
373
|
-
const config = getConfig();
|
|
374
436
|
const {
|
|
375
437
|
originToken,
|
|
376
438
|
destinationToken,
|
|
@@ -382,97 +444,133 @@ async function getQuote(options) {
|
|
|
382
444
|
swapType = "EXACT_INPUT",
|
|
383
445
|
deadline,
|
|
384
446
|
dry = false,
|
|
385
|
-
referral =
|
|
447
|
+
referral = "uniport",
|
|
448
|
+
signal
|
|
386
449
|
} = options;
|
|
387
450
|
const amountInSmallestUnits = toSmallestUnits(amount, originToken.decimals);
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
destinationAsset: destinationToken.assetId,
|
|
395
|
-
amount: amountInSmallestUnits,
|
|
396
|
-
refundTo,
|
|
397
|
-
refundType: QuoteRequest.refundType.ORIGIN_CHAIN,
|
|
398
|
-
recipient,
|
|
399
|
-
recipientType: QuoteRequest.recipientType.DESTINATION_CHAIN,
|
|
400
|
-
deadline: deadline?.toISOString() || generateDeadline(1),
|
|
401
|
-
referral
|
|
402
|
-
};
|
|
451
|
+
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
452
|
+
const { signal: requestSignal, cleanup, didTimeout } = createTimeoutSignal(
|
|
453
|
+
requestTimeoutMs,
|
|
454
|
+
signal
|
|
455
|
+
);
|
|
456
|
+
let response;
|
|
403
457
|
try {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
458
|
+
response = await fetch(`${backendUrl}/api/quote`, {
|
|
459
|
+
method: "POST",
|
|
460
|
+
headers: { "Content-Type": "application/json" },
|
|
461
|
+
signal: requestSignal,
|
|
462
|
+
body: JSON.stringify({
|
|
463
|
+
dry,
|
|
464
|
+
swapType,
|
|
465
|
+
slippageTolerance,
|
|
466
|
+
originAsset: originToken.assetId,
|
|
467
|
+
destinationAsset: destinationToken.assetId,
|
|
468
|
+
amount: amountInSmallestUnits,
|
|
469
|
+
refundTo,
|
|
470
|
+
recipient,
|
|
471
|
+
deadline: deadline?.toISOString() || generateDeadline(1),
|
|
472
|
+
referral
|
|
473
|
+
})
|
|
474
|
+
});
|
|
417
475
|
} catch (error) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
476
|
+
cleanup();
|
|
477
|
+
if (isAbortError(error)) {
|
|
478
|
+
if (signal?.aborted && !didTimeout()) {
|
|
479
|
+
throw error;
|
|
480
|
+
}
|
|
481
|
+
throw new UniportError({
|
|
482
|
+
code: "REQUEST_TIMEOUT",
|
|
483
|
+
message: "Quote request timed out"
|
|
484
|
+
});
|
|
422
485
|
}
|
|
423
486
|
throw error;
|
|
424
487
|
}
|
|
488
|
+
cleanup();
|
|
489
|
+
if (!response.ok) {
|
|
490
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
491
|
+
throw toUniportError(errorBody, {
|
|
492
|
+
code: "QUOTE_FAILED",
|
|
493
|
+
message: "Quote failed.",
|
|
494
|
+
status: response.status
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
const data = await response.json();
|
|
498
|
+
const quote = data.quote;
|
|
499
|
+
return {
|
|
500
|
+
depositAddress: quote.depositAddress || "",
|
|
501
|
+
memo: quote.depositMemo,
|
|
502
|
+
amountIn: quote.amountIn,
|
|
503
|
+
amountOut: quote.amountOut,
|
|
504
|
+
amountOutFormatted: quote.amountOutFormatted,
|
|
505
|
+
amountOutUsd: quote.amountOutUsd,
|
|
506
|
+
deadline: quote.deadline,
|
|
507
|
+
timeWhenInactive: quote.timeWhenInactive,
|
|
508
|
+
correlationId: data.correlationId
|
|
509
|
+
};
|
|
425
510
|
}
|
|
426
511
|
async function submitDepositTx(params) {
|
|
427
|
-
|
|
428
|
-
const {
|
|
512
|
+
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
513
|
+
const { signal, cleanup } = createTimeoutSignal(requestTimeoutMs);
|
|
514
|
+
let response;
|
|
429
515
|
try {
|
|
430
|
-
await
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
516
|
+
response = await fetch(`${backendUrl}/api/deposit`, {
|
|
517
|
+
method: "POST",
|
|
518
|
+
headers: { "Content-Type": "application/json" },
|
|
519
|
+
signal,
|
|
520
|
+
body: JSON.stringify(params)
|
|
435
521
|
});
|
|
436
522
|
} catch (error) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
523
|
+
cleanup();
|
|
524
|
+
if (isAbortError(error)) {
|
|
525
|
+
throw new UniportError({
|
|
526
|
+
code: "REQUEST_TIMEOUT",
|
|
527
|
+
message: "Deposit submission timed out"
|
|
528
|
+
});
|
|
441
529
|
}
|
|
442
530
|
throw error;
|
|
443
531
|
}
|
|
532
|
+
cleanup();
|
|
533
|
+
if (!response.ok) {
|
|
534
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
535
|
+
throw toUniportError(errorBody, {
|
|
536
|
+
code: "DEPOSIT_SUBMISSION_FAILED",
|
|
537
|
+
message: "Submit deposit failed.",
|
|
538
|
+
status: response.status
|
|
539
|
+
});
|
|
540
|
+
}
|
|
444
541
|
}
|
|
445
542
|
async function getExecutionStatus(depositAddress, memo) {
|
|
446
|
-
|
|
543
|
+
const { backendUrl, requestTimeoutMs } = getUniportConfig();
|
|
544
|
+
const url = new URL(
|
|
545
|
+
`${backendUrl}/api/status/${encodeURIComponent(depositAddress)}`
|
|
546
|
+
);
|
|
547
|
+
if (memo) {
|
|
548
|
+
url.searchParams.set("memo", memo);
|
|
549
|
+
}
|
|
550
|
+
const { signal, cleanup } = createTimeoutSignal(requestTimeoutMs);
|
|
551
|
+
let response;
|
|
447
552
|
try {
|
|
448
|
-
|
|
449
|
-
depositAddress,
|
|
450
|
-
memo
|
|
451
|
-
);
|
|
452
|
-
const status = response.status;
|
|
453
|
-
const isComplete = ["SUCCESS", "REFUNDED", "FAILED"].includes(status);
|
|
454
|
-
const isSuccess = status === "SUCCESS";
|
|
455
|
-
const swapDetails = response.swapDetails;
|
|
456
|
-
const destinationTxHashes = swapDetails?.destinationChainTxHashes?.map((tx) => tx.hash);
|
|
457
|
-
const originTxHashes = swapDetails?.originChainTxHashes?.map(
|
|
458
|
-
(tx) => tx.hash
|
|
459
|
-
);
|
|
460
|
-
return {
|
|
461
|
-
status,
|
|
462
|
-
isComplete,
|
|
463
|
-
isSuccess,
|
|
464
|
-
correlationId: response.correlationId,
|
|
465
|
-
destinationTxHashes,
|
|
466
|
-
originTxHashes
|
|
467
|
-
};
|
|
553
|
+
response = await fetch(url.toString(), { signal });
|
|
468
554
|
} catch (error) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
555
|
+
cleanup();
|
|
556
|
+
if (isAbortError(error)) {
|
|
557
|
+
throw new UniportError({
|
|
558
|
+
code: "REQUEST_TIMEOUT",
|
|
559
|
+
message: "Status check timed out"
|
|
560
|
+
});
|
|
473
561
|
}
|
|
474
562
|
throw error;
|
|
475
563
|
}
|
|
564
|
+
cleanup();
|
|
565
|
+
if (!response.ok) {
|
|
566
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
567
|
+
throw toUniportError(errorBody, {
|
|
568
|
+
code: "STATUS_CHECK_FAILED",
|
|
569
|
+
message: "Status check failed.",
|
|
570
|
+
status: response.status
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
return await response.json();
|
|
476
574
|
}
|
|
477
575
|
async function pollExecutionStatus(depositAddress, options) {
|
|
478
576
|
const {
|
|
@@ -497,8 +595,20 @@ async function pollExecutionStatus(depositAddress, options) {
|
|
|
497
595
|
throw new Error(`Timeout waiting for swap completion after ${timeout}ms`);
|
|
498
596
|
}
|
|
499
597
|
function useUniportPayment(options) {
|
|
500
|
-
const {
|
|
501
|
-
|
|
598
|
+
const {
|
|
599
|
+
recipient,
|
|
600
|
+
refundAddress: initialRefundAddress,
|
|
601
|
+
destinationToken,
|
|
602
|
+
amount: initialAmount,
|
|
603
|
+
onSuccess,
|
|
604
|
+
onError
|
|
605
|
+
} = options;
|
|
606
|
+
const destToken = getToken(destinationToken);
|
|
607
|
+
if (!destToken) {
|
|
608
|
+
throw new Error(
|
|
609
|
+
`Invalid destinationToken: "${destinationToken}". Use a valid token name like "suiUSDC", "arbitrumUSDC", "ethereumUSDC", or "baseETH". See the supported tokens table in the README.`
|
|
610
|
+
);
|
|
611
|
+
}
|
|
502
612
|
const [paymentState, setPaymentState] = useState("idle");
|
|
503
613
|
const [quote, setQuote] = useState(null);
|
|
504
614
|
const [previewQuote, setPreviewQuote] = useState(null);
|
|
@@ -507,57 +617,86 @@ function useUniportPayment(options) {
|
|
|
507
617
|
const [error, setError] = useState(null);
|
|
508
618
|
const [selectedChain, setSelectedChain] = useState(null);
|
|
509
619
|
const [selectedToken, setSelectedToken] = useState(null);
|
|
510
|
-
const [amount, setAmountState] = useState("");
|
|
620
|
+
const [amount, setAmountState] = useState(initialAmount ?? "");
|
|
621
|
+
const [refundAddress, setRefundAddressState] = useState(
|
|
622
|
+
initialRefundAddress ?? ""
|
|
623
|
+
);
|
|
511
624
|
const pollingRef = useRef(null);
|
|
512
625
|
const lastStatusRef = useRef(null);
|
|
513
626
|
const previewDebounceRef = useRef(null);
|
|
514
|
-
const
|
|
627
|
+
const previewAbortRef = useRef(null);
|
|
628
|
+
const chains = getSupportedChains().filter((c) => c.id !== destToken.chain);
|
|
515
629
|
const tokens = selectedChain?.tokens || [];
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
(newAmount) => {
|
|
519
|
-
setAmountState(newAmount);
|
|
630
|
+
const schedulePreviewQuote = useCallback(
|
|
631
|
+
(nextAmount, nextRefundAddress, nextSelectedToken) => {
|
|
520
632
|
setPreviewQuote(null);
|
|
521
633
|
if (previewDebounceRef.current) {
|
|
522
634
|
clearTimeout(previewDebounceRef.current);
|
|
523
635
|
}
|
|
524
|
-
if (
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
originToken: selectedToken,
|
|
530
|
-
destinationToken: destToken,
|
|
531
|
-
amount: newAmount,
|
|
532
|
-
recipient,
|
|
533
|
-
refundTo: refundAddress,
|
|
534
|
-
dry: true
|
|
535
|
-
// Dry run for preview
|
|
536
|
-
});
|
|
537
|
-
setPreviewQuote(result);
|
|
538
|
-
} catch (err) {
|
|
539
|
-
console.warn("Preview quote failed:", err);
|
|
540
|
-
} finally {
|
|
541
|
-
setIsLoadingPreview(false);
|
|
542
|
-
}
|
|
543
|
-
}, 3e3);
|
|
544
|
-
} else {
|
|
636
|
+
if (previewAbortRef.current) {
|
|
637
|
+
previewAbortRef.current.abort();
|
|
638
|
+
previewAbortRef.current = null;
|
|
639
|
+
}
|
|
640
|
+
if (!nextAmount || !nextSelectedToken || !nextRefundAddress) {
|
|
545
641
|
setIsLoadingPreview(false);
|
|
642
|
+
return;
|
|
546
643
|
}
|
|
644
|
+
setIsLoadingPreview(true);
|
|
645
|
+
previewDebounceRef.current = setTimeout(async () => {
|
|
646
|
+
const controller = new AbortController();
|
|
647
|
+
previewAbortRef.current = controller;
|
|
648
|
+
try {
|
|
649
|
+
const result = await getQuote({
|
|
650
|
+
originToken: nextSelectedToken,
|
|
651
|
+
destinationToken: destToken,
|
|
652
|
+
amount: nextAmount,
|
|
653
|
+
recipient,
|
|
654
|
+
refundTo: nextRefundAddress,
|
|
655
|
+
dry: true,
|
|
656
|
+
signal: controller.signal
|
|
657
|
+
});
|
|
658
|
+
setPreviewQuote(result);
|
|
659
|
+
} catch (err) {
|
|
660
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
console.warn("Preview quote failed:", err);
|
|
664
|
+
} finally {
|
|
665
|
+
if (previewAbortRef.current === controller) {
|
|
666
|
+
previewAbortRef.current = null;
|
|
667
|
+
}
|
|
668
|
+
setIsLoadingPreview(false);
|
|
669
|
+
}
|
|
670
|
+
}, 250);
|
|
671
|
+
},
|
|
672
|
+
[destToken, recipient]
|
|
673
|
+
);
|
|
674
|
+
const setAmount = useCallback(
|
|
675
|
+
(newAmount) => {
|
|
676
|
+
setAmountState(newAmount);
|
|
677
|
+
schedulePreviewQuote(newAmount, refundAddress, selectedToken);
|
|
678
|
+
},
|
|
679
|
+
[refundAddress, schedulePreviewQuote, selectedToken]
|
|
680
|
+
);
|
|
681
|
+
const setRefundAddress = useCallback(
|
|
682
|
+
(newRefundAddress) => {
|
|
683
|
+
setRefundAddressState(newRefundAddress);
|
|
684
|
+
schedulePreviewQuote(amount, newRefundAddress, selectedToken);
|
|
547
685
|
},
|
|
548
|
-
[
|
|
686
|
+
[amount, schedulePreviewQuote, selectedToken]
|
|
549
687
|
);
|
|
550
688
|
const handleChainSelect = useCallback((chain) => {
|
|
689
|
+
const nextToken = chain.tokens[0] || null;
|
|
551
690
|
setSelectedChain(chain);
|
|
552
|
-
setSelectedToken(
|
|
691
|
+
setSelectedToken(nextToken);
|
|
553
692
|
setPaymentState("selecting");
|
|
554
|
-
|
|
555
|
-
}, []);
|
|
693
|
+
schedulePreviewQuote(amount, refundAddress, nextToken);
|
|
694
|
+
}, [amount, refundAddress, schedulePreviewQuote]);
|
|
556
695
|
const handleTokenSelect = useCallback((token) => {
|
|
557
696
|
setSelectedToken(token);
|
|
558
697
|
setPaymentState("selecting");
|
|
559
|
-
|
|
560
|
-
}, []);
|
|
698
|
+
schedulePreviewQuote(amount, refundAddress, token);
|
|
699
|
+
}, [amount, refundAddress, schedulePreviewQuote]);
|
|
561
700
|
const fetchQuote = useCallback(async () => {
|
|
562
701
|
if (!selectedToken || !amount || !refundAddress) {
|
|
563
702
|
setError(new Error("Missing required fields"));
|
|
@@ -590,6 +729,12 @@ function useUniportPayment(options) {
|
|
|
590
729
|
destToken,
|
|
591
730
|
onError
|
|
592
731
|
]);
|
|
732
|
+
const stopPolling = useCallback(() => {
|
|
733
|
+
if (pollingRef.current) {
|
|
734
|
+
clearInterval(pollingRef.current);
|
|
735
|
+
pollingRef.current = null;
|
|
736
|
+
}
|
|
737
|
+
}, []);
|
|
593
738
|
const pollStatus = useCallback(async () => {
|
|
594
739
|
if (!quote?.depositAddress) return;
|
|
595
740
|
try {
|
|
@@ -609,10 +754,12 @@ function useUniportPayment(options) {
|
|
|
609
754
|
txHash: result.destinationTxHashes?.[0] || "",
|
|
610
755
|
amount: quote.amountOut
|
|
611
756
|
});
|
|
612
|
-
} else if (result.
|
|
757
|
+
} else if (result.isComplete) {
|
|
613
758
|
setPaymentState("error");
|
|
614
759
|
stopPolling();
|
|
615
|
-
const err = new Error(
|
|
760
|
+
const err = new Error(
|
|
761
|
+
result.status === "REFUNDED" ? "Payment was refunded" : "Payment failed"
|
|
762
|
+
);
|
|
616
763
|
setError(err);
|
|
617
764
|
onError?.(err);
|
|
618
765
|
}
|
|
@@ -620,18 +767,12 @@ function useUniportPayment(options) {
|
|
|
620
767
|
} catch (err) {
|
|
621
768
|
console.error("Status poll error:", err);
|
|
622
769
|
}
|
|
623
|
-
}, [quote, onSuccess, onError]);
|
|
770
|
+
}, [quote, onSuccess, onError, stopPolling]);
|
|
624
771
|
const startPolling = useCallback(() => {
|
|
625
772
|
if (pollingRef.current) return;
|
|
626
773
|
pollStatus();
|
|
627
774
|
pollingRef.current = setInterval(pollStatus, 3e3);
|
|
628
775
|
}, [pollStatus]);
|
|
629
|
-
const stopPolling = useCallback(() => {
|
|
630
|
-
if (pollingRef.current) {
|
|
631
|
-
clearInterval(pollingRef.current);
|
|
632
|
-
pollingRef.current = null;
|
|
633
|
-
}
|
|
634
|
-
}, []);
|
|
635
776
|
const copyToClipboard = useCallback(async (text) => {
|
|
636
777
|
try {
|
|
637
778
|
await navigator.clipboard.writeText(text);
|
|
@@ -645,6 +786,10 @@ function useUniportPayment(options) {
|
|
|
645
786
|
if (previewDebounceRef.current) {
|
|
646
787
|
clearTimeout(previewDebounceRef.current);
|
|
647
788
|
}
|
|
789
|
+
if (previewAbortRef.current) {
|
|
790
|
+
previewAbortRef.current.abort();
|
|
791
|
+
previewAbortRef.current = null;
|
|
792
|
+
}
|
|
648
793
|
setPaymentState("idle");
|
|
649
794
|
setQuote(null);
|
|
650
795
|
setPreviewQuote(null);
|
|
@@ -653,7 +798,16 @@ function useUniportPayment(options) {
|
|
|
653
798
|
setError(null);
|
|
654
799
|
setSelectedChain(null);
|
|
655
800
|
setSelectedToken(null);
|
|
656
|
-
setAmountState("");
|
|
801
|
+
setAmountState(initialAmount ?? "");
|
|
802
|
+
setRefundAddressState(initialRefundAddress ?? "");
|
|
803
|
+
lastStatusRef.current = null;
|
|
804
|
+
}, [initialAmount, initialRefundAddress, stopPolling]);
|
|
805
|
+
const cancelQuote = useCallback(() => {
|
|
806
|
+
stopPolling();
|
|
807
|
+
setPaymentState("selecting");
|
|
808
|
+
setQuote(null);
|
|
809
|
+
setStatus(null);
|
|
810
|
+
setError(null);
|
|
657
811
|
lastStatusRef.current = null;
|
|
658
812
|
}, [stopPolling]);
|
|
659
813
|
useEffect(() => {
|
|
@@ -662,6 +816,10 @@ function useUniportPayment(options) {
|
|
|
662
816
|
if (previewDebounceRef.current) {
|
|
663
817
|
clearTimeout(previewDebounceRef.current);
|
|
664
818
|
}
|
|
819
|
+
if (previewAbortRef.current) {
|
|
820
|
+
previewAbortRef.current.abort();
|
|
821
|
+
previewAbortRef.current = null;
|
|
822
|
+
}
|
|
665
823
|
};
|
|
666
824
|
}, [stopPolling]);
|
|
667
825
|
return {
|
|
@@ -674,281 +832,73 @@ function useUniportPayment(options) {
|
|
|
674
832
|
selectedChain,
|
|
675
833
|
selectedToken,
|
|
676
834
|
amount,
|
|
835
|
+
refundAddress,
|
|
677
836
|
destinationToken: destToken,
|
|
678
837
|
chains,
|
|
679
838
|
tokens,
|
|
680
|
-
destinationTokens,
|
|
681
839
|
setSelectedChain: handleChainSelect,
|
|
682
840
|
setSelectedToken: handleTokenSelect,
|
|
683
841
|
setAmount,
|
|
842
|
+
setRefundAddress,
|
|
684
843
|
fetchQuote,
|
|
685
844
|
startPolling,
|
|
686
845
|
stopPolling,
|
|
846
|
+
cancelQuote,
|
|
687
847
|
reset,
|
|
688
848
|
copyToClipboard
|
|
689
849
|
};
|
|
690
850
|
}
|
|
691
|
-
var
|
|
692
|
-
overlay:
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
margin: 0,
|
|
739
|
-
textShadow: "0 0 15px rgba(255,255,255,0.3)"
|
|
740
|
-
},
|
|
741
|
-
subtitle: {
|
|
742
|
-
fontSize: "12px",
|
|
743
|
-
color: "rgba(255,255,255,0.4)",
|
|
744
|
-
marginTop: "4px",
|
|
745
|
-
fontWeight: 300,
|
|
746
|
-
letterSpacing: "0.5px"
|
|
747
|
-
},
|
|
748
|
-
closeButton: {
|
|
749
|
-
position: "absolute",
|
|
750
|
-
top: "16px",
|
|
751
|
-
right: "16px",
|
|
752
|
-
width: "32px",
|
|
753
|
-
height: "32px",
|
|
754
|
-
borderRadius: "8px",
|
|
755
|
-
background: "rgba(255,255,255,0.05)",
|
|
756
|
-
border: "1px solid rgba(255,255,255,0.1)",
|
|
757
|
-
color: "rgba(255,255,255,0.6)",
|
|
758
|
-
cursor: "pointer",
|
|
759
|
-
display: "flex",
|
|
760
|
-
alignItems: "center",
|
|
761
|
-
justifyContent: "center",
|
|
762
|
-
transition: "all 0.2s"
|
|
763
|
-
},
|
|
764
|
-
selectorsRow: {
|
|
765
|
-
display: "grid",
|
|
766
|
-
gridTemplateColumns: "1fr 1fr",
|
|
767
|
-
gap: "12px",
|
|
768
|
-
marginBottom: "24px"
|
|
769
|
-
},
|
|
770
|
-
selector: {
|
|
771
|
-
display: "flex",
|
|
772
|
-
alignItems: "center",
|
|
773
|
-
justifyContent: "space-between",
|
|
774
|
-
padding: "12px",
|
|
775
|
-
background: "rgba(255,255,255,0.05)",
|
|
776
|
-
border: "1px solid rgba(255,255,255,0.05)",
|
|
777
|
-
borderRadius: "16px",
|
|
778
|
-
cursor: "pointer",
|
|
779
|
-
transition: "all 0.2s"
|
|
780
|
-
},
|
|
781
|
-
selectorIcon: {
|
|
782
|
-
width: "32px",
|
|
783
|
-
height: "32px",
|
|
784
|
-
borderRadius: "50%",
|
|
785
|
-
background: "#1c1c26",
|
|
786
|
-
border: "1px solid rgba(255,255,255,0.1)",
|
|
787
|
-
display: "flex",
|
|
788
|
-
alignItems: "center",
|
|
789
|
-
justifyContent: "center",
|
|
790
|
-
overflow: "hidden"
|
|
791
|
-
},
|
|
792
|
-
selectorLabel: {
|
|
793
|
-
fontSize: "10px",
|
|
794
|
-
textTransform: "uppercase",
|
|
795
|
-
letterSpacing: "1.5px",
|
|
796
|
-
color: "rgba(255,255,255,0.3)",
|
|
797
|
-
fontWeight: 500
|
|
798
|
-
},
|
|
799
|
-
selectorValue: {
|
|
800
|
-
fontSize: "14px",
|
|
801
|
-
color: "rgba(255,255,255,0.9)",
|
|
802
|
-
fontWeight: 500
|
|
803
|
-
},
|
|
804
|
-
amountInput: {
|
|
805
|
-
width: "100%",
|
|
806
|
-
textAlign: "center",
|
|
807
|
-
fontSize: "48px",
|
|
808
|
-
fontWeight: 500,
|
|
809
|
-
color: "white",
|
|
810
|
-
background: "transparent",
|
|
811
|
-
border: "none",
|
|
812
|
-
outline: "none",
|
|
813
|
-
marginBottom: "24px",
|
|
814
|
-
caretColor: "#4F46E5"
|
|
815
|
-
},
|
|
816
|
-
details: {
|
|
817
|
-
marginBottom: "20px",
|
|
818
|
-
padding: "0 4px"
|
|
819
|
-
},
|
|
820
|
-
detailRow: {
|
|
821
|
-
display: "flex",
|
|
822
|
-
justifyContent: "space-between",
|
|
823
|
-
alignItems: "center",
|
|
824
|
-
fontSize: "12px",
|
|
825
|
-
color: "rgba(255,255,255,0.4)",
|
|
826
|
-
marginBottom: "8px"
|
|
827
|
-
},
|
|
828
|
-
detailValue: {
|
|
829
|
-
fontWeight: 500,
|
|
830
|
-
color: "rgba(255,255,255,0.7)",
|
|
831
|
-
display: "flex",
|
|
832
|
-
alignItems: "center",
|
|
833
|
-
gap: "6px"
|
|
834
|
-
},
|
|
835
|
-
button: {
|
|
836
|
-
width: "100%",
|
|
837
|
-
position: "relative",
|
|
838
|
-
overflow: "hidden",
|
|
839
|
-
borderRadius: "16px",
|
|
840
|
-
padding: "2px",
|
|
841
|
-
background: "linear-gradient(90deg, #4F46E5, #7C3AED, #4F46E5)",
|
|
842
|
-
backgroundSize: "200% 200%",
|
|
843
|
-
animation: "uniport-gradient 3s ease infinite",
|
|
844
|
-
border: "none",
|
|
845
|
-
cursor: "pointer"
|
|
846
|
-
},
|
|
847
|
-
buttonInner: {
|
|
848
|
-
display: "flex",
|
|
849
|
-
alignItems: "center",
|
|
850
|
-
justifyContent: "center",
|
|
851
|
-
gap: "8px",
|
|
852
|
-
height: "48px",
|
|
853
|
-
borderRadius: "14px",
|
|
854
|
-
background: "#0A0A0F",
|
|
855
|
-
color: "white",
|
|
856
|
-
fontSize: "14px",
|
|
857
|
-
fontWeight: 500,
|
|
858
|
-
transition: "background 0.3s"
|
|
859
|
-
},
|
|
860
|
-
buttonDisabled: {
|
|
861
|
-
opacity: 0.5,
|
|
862
|
-
cursor: "not-allowed"
|
|
863
|
-
},
|
|
864
|
-
// QR container - dark background, no white box
|
|
865
|
-
qrContainer: {
|
|
866
|
-
display: "flex",
|
|
867
|
-
flexDirection: "column",
|
|
868
|
-
alignItems: "center",
|
|
869
|
-
padding: "24px",
|
|
870
|
-
background: "transparent",
|
|
871
|
-
marginBottom: "16px"
|
|
872
|
-
},
|
|
873
|
-
// Address with copy button
|
|
874
|
-
addressContainer: {
|
|
875
|
-
display: "flex",
|
|
876
|
-
alignItems: "center",
|
|
877
|
-
justifyContent: "center",
|
|
878
|
-
gap: "8px",
|
|
879
|
-
marginTop: "16px"
|
|
880
|
-
},
|
|
881
|
-
addressText: {
|
|
882
|
-
fontSize: "12px",
|
|
883
|
-
color: "rgba(255,255,255,0.6)",
|
|
884
|
-
wordBreak: "break-all",
|
|
885
|
-
textAlign: "center",
|
|
886
|
-
fontFamily: "monospace"
|
|
887
|
-
},
|
|
888
|
-
copyButton: {
|
|
889
|
-
display: "flex",
|
|
890
|
-
alignItems: "center",
|
|
891
|
-
justifyContent: "center",
|
|
892
|
-
width: "32px",
|
|
893
|
-
height: "32px",
|
|
894
|
-
borderRadius: "8px",
|
|
895
|
-
background: "rgba(255,255,255,0.1)",
|
|
896
|
-
border: "1px solid rgba(255,255,255,0.15)",
|
|
897
|
-
cursor: "pointer",
|
|
898
|
-
transition: "all 0.2s",
|
|
899
|
-
flexShrink: 0
|
|
900
|
-
},
|
|
901
|
-
statusBadge: {
|
|
902
|
-
display: "inline-flex",
|
|
903
|
-
alignItems: "center",
|
|
904
|
-
gap: "6px",
|
|
905
|
-
padding: "6px 12px",
|
|
906
|
-
borderRadius: "20px",
|
|
907
|
-
fontSize: "12px",
|
|
908
|
-
fontWeight: 500
|
|
909
|
-
},
|
|
910
|
-
processingBadge: {
|
|
911
|
-
background: "rgba(79, 70, 229, 0.2)",
|
|
912
|
-
color: "#818CF8"
|
|
913
|
-
},
|
|
914
|
-
dropdown: {
|
|
915
|
-
position: "absolute",
|
|
916
|
-
top: "calc(100% + 8px)",
|
|
917
|
-
left: 0,
|
|
918
|
-
right: 0,
|
|
919
|
-
background: "rgba(22, 22, 30, 0.98)",
|
|
920
|
-
border: "1px solid rgba(255,255,255,0.1)",
|
|
921
|
-
borderRadius: "16px",
|
|
922
|
-
maxHeight: "200px",
|
|
923
|
-
overflowY: "auto",
|
|
924
|
-
zIndex: 10,
|
|
925
|
-
boxShadow: "0 20px 40px rgba(0,0,0,0.5)"
|
|
926
|
-
},
|
|
927
|
-
dropdownItem: {
|
|
928
|
-
display: "flex",
|
|
929
|
-
alignItems: "center",
|
|
930
|
-
gap: "12px",
|
|
931
|
-
padding: "12px 16px",
|
|
932
|
-
cursor: "pointer",
|
|
933
|
-
transition: "background 0.2s"
|
|
934
|
-
},
|
|
935
|
-
loadingDot: {
|
|
936
|
-
width: "8px",
|
|
937
|
-
height: "8px",
|
|
938
|
-
borderRadius: "50%",
|
|
939
|
-
background: "#818CF8",
|
|
940
|
-
animation: "uniport-pulse 1s ease infinite"
|
|
941
|
-
},
|
|
942
|
-
tokenBadge: {
|
|
943
|
-
display: "inline-flex",
|
|
944
|
-
alignItems: "center",
|
|
945
|
-
gap: "4px",
|
|
946
|
-
padding: "2px 8px",
|
|
947
|
-
borderRadius: "12px",
|
|
948
|
-
background: "rgba(255,255,255,0.08)",
|
|
949
|
-
fontSize: "11px"
|
|
950
|
-
}
|
|
851
|
+
var LIGHT = {
|
|
852
|
+
overlay: "rgba(0, 0, 0, 0.42)",
|
|
853
|
+
modalBg: "#ffffff",
|
|
854
|
+
rowHover: "#f5f5f7",
|
|
855
|
+
inputBg: "#f5f5f7",
|
|
856
|
+
warningBg: "#fffbeb",
|
|
857
|
+
warningBorder: "rgba(245, 158, 11, 0.25)",
|
|
858
|
+
text: "#1c1c1e",
|
|
859
|
+
textSecondary: "#3a3a3c",
|
|
860
|
+
textMuted: "#8e8e93",
|
|
861
|
+
border: "#e5e5ea",
|
|
862
|
+
accent: "#6366f1",
|
|
863
|
+
success: "#30d158",
|
|
864
|
+
error: "#ff3b30",
|
|
865
|
+
warning: "#d97706",
|
|
866
|
+
warningText: "#92400e",
|
|
867
|
+
btnBg: "#1c1c1e",
|
|
868
|
+
btnText: "#ffffff",
|
|
869
|
+
btnDisabledBg: "#e5e5ea",
|
|
870
|
+
btnDisabledText: "#8e8e93",
|
|
871
|
+
iconBtnBg: "#f5f5f7",
|
|
872
|
+
iconBtnHover: "#e5e5ea",
|
|
873
|
+
iconBtnColor: "#3a3a3c"
|
|
874
|
+
};
|
|
875
|
+
var DARK = {
|
|
876
|
+
overlay: "rgba(0, 0, 0, 0.65)",
|
|
877
|
+
modalBg: "#1c1c1e",
|
|
878
|
+
rowHover: "#2c2c2e",
|
|
879
|
+
inputBg: "#2c2c2e",
|
|
880
|
+
warningBg: "rgba(245, 158, 11, 0.1)",
|
|
881
|
+
warningBorder: "rgba(245, 158, 11, 0.2)",
|
|
882
|
+
text: "#ffffff",
|
|
883
|
+
textSecondary: "rgba(235, 235, 245, 0.85)",
|
|
884
|
+
textMuted: "#8e8e93",
|
|
885
|
+
border: "#38383a",
|
|
886
|
+
accent: "#818cf8",
|
|
887
|
+
success: "#30d158",
|
|
888
|
+
error: "#ff453a",
|
|
889
|
+
warning: "#ffd60a",
|
|
890
|
+
warningText: "#ffd60a",
|
|
891
|
+
btnBg: "#6366f1",
|
|
892
|
+
btnText: "#ffffff",
|
|
893
|
+
btnDisabledBg: "#3a3a3c",
|
|
894
|
+
btnDisabledText: "#636366",
|
|
895
|
+
iconBtnBg: "#2c2c2e",
|
|
896
|
+
iconBtnHover: "#3a3a3c",
|
|
897
|
+
iconBtnColor: "rgba(235, 235, 245, 0.8)"
|
|
951
898
|
};
|
|
899
|
+
function getTheme(mode) {
|
|
900
|
+
return mode === "dark" ? DARK : LIGHT;
|
|
901
|
+
}
|
|
952
902
|
var injectStyles = () => {
|
|
953
903
|
if (typeof document === "undefined") return;
|
|
954
904
|
if (document.getElementById("uniport-styles")) return;
|
|
@@ -957,643 +907,861 @@ var injectStyles = () => {
|
|
|
957
907
|
style.textContent = `
|
|
958
908
|
@keyframes uniport-fade-in {
|
|
959
909
|
from { opacity: 0; }
|
|
960
|
-
to
|
|
910
|
+
to { opacity: 1; }
|
|
961
911
|
}
|
|
962
912
|
@keyframes uniport-slide-up {
|
|
963
|
-
from { opacity: 0; transform: translateY(
|
|
964
|
-
to
|
|
913
|
+
from { opacity: 0; transform: translateY(14px) scale(0.98); }
|
|
914
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
965
915
|
}
|
|
966
|
-
@keyframes uniport-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
100% { background-position: 0% 50%; }
|
|
916
|
+
@keyframes uniport-spin {
|
|
917
|
+
from { transform: rotate(0deg); }
|
|
918
|
+
to { transform: rotate(360deg); }
|
|
970
919
|
}
|
|
971
920
|
@keyframes uniport-pulse {
|
|
972
921
|
0%, 100% { opacity: 1; }
|
|
973
|
-
50%
|
|
922
|
+
50% { opacity: 0.35; }
|
|
974
923
|
}
|
|
975
924
|
`;
|
|
976
925
|
document.head.appendChild(style);
|
|
977
926
|
};
|
|
927
|
+
var AVATAR_COLORS = [
|
|
928
|
+
"#6366f1",
|
|
929
|
+
"#8b5cf6",
|
|
930
|
+
"#06b6d4",
|
|
931
|
+
"#10b981",
|
|
932
|
+
"#f59e0b",
|
|
933
|
+
"#ef4444",
|
|
934
|
+
"#ec4899",
|
|
935
|
+
"#3b82f6",
|
|
936
|
+
"#14b8a6",
|
|
937
|
+
"#f97316"
|
|
938
|
+
];
|
|
939
|
+
function charColor(name) {
|
|
940
|
+
let h = 0;
|
|
941
|
+
for (let i = 0; i < name.length; i++) {
|
|
942
|
+
h = name.charCodeAt(i) + ((h << 5) - h);
|
|
943
|
+
}
|
|
944
|
+
return AVATAR_COLORS[Math.abs(h) % AVATAR_COLORS.length];
|
|
945
|
+
}
|
|
946
|
+
function TokenAvatar({ src, name, size = 40 }) {
|
|
947
|
+
const [failed, setFailed] = useState(false);
|
|
948
|
+
if (failed || !src) {
|
|
949
|
+
return /* @__PURE__ */ jsx(
|
|
950
|
+
"div",
|
|
951
|
+
{
|
|
952
|
+
"aria-label": name,
|
|
953
|
+
style: {
|
|
954
|
+
width: size,
|
|
955
|
+
height: size,
|
|
956
|
+
borderRadius: "50%",
|
|
957
|
+
background: charColor(name),
|
|
958
|
+
display: "flex",
|
|
959
|
+
alignItems: "center",
|
|
960
|
+
justifyContent: "center",
|
|
961
|
+
fontSize: Math.round(size * 0.4),
|
|
962
|
+
fontWeight: 700,
|
|
963
|
+
color: "#fff",
|
|
964
|
+
flexShrink: 0,
|
|
965
|
+
userSelect: "none",
|
|
966
|
+
letterSpacing: "-0.01em"
|
|
967
|
+
},
|
|
968
|
+
children: name.charAt(0).toUpperCase()
|
|
969
|
+
}
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
return /* @__PURE__ */ jsx(
|
|
973
|
+
"img",
|
|
974
|
+
{
|
|
975
|
+
src,
|
|
976
|
+
alt: name,
|
|
977
|
+
width: size,
|
|
978
|
+
height: size,
|
|
979
|
+
style: { borderRadius: "50%", objectFit: "cover", flexShrink: 0, display: "block" },
|
|
980
|
+
onError: () => setFailed(true)
|
|
981
|
+
}
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
function BackArrow({ color }) {
|
|
985
|
+
return /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M19 12H5M5 12l7 7M5 12l7-7", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
986
|
+
}
|
|
987
|
+
function XMark({ color }) {
|
|
988
|
+
return /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12", stroke: color, strokeWidth: "2.5", strokeLinecap: "round" }) });
|
|
989
|
+
}
|
|
990
|
+
function ChevronRight({ color }) {
|
|
991
|
+
return /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M9 18l6-6-6-6", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
992
|
+
}
|
|
993
|
+
function Spinner({ color }) {
|
|
994
|
+
return /* @__PURE__ */ jsxs(
|
|
995
|
+
"svg",
|
|
996
|
+
{
|
|
997
|
+
width: "18",
|
|
998
|
+
height: "18",
|
|
999
|
+
viewBox: "0 0 24 24",
|
|
1000
|
+
fill: "none",
|
|
1001
|
+
style: { animation: "uniport-spin 0.75s linear infinite", display: "block", flexShrink: 0 },
|
|
1002
|
+
children: [
|
|
1003
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10", stroke: color, strokeWidth: "3", strokeOpacity: "0.2" }),
|
|
1004
|
+
/* @__PURE__ */ jsx("path", { d: "M12 2a10 10 0 019.95 9", stroke: color, strokeWidth: "3", strokeLinecap: "round" })
|
|
1005
|
+
]
|
|
1006
|
+
}
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
function CopyIcon({ color }) {
|
|
1010
|
+
return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [
|
|
1011
|
+
/* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", stroke: color, strokeWidth: "2" }),
|
|
1012
|
+
/* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1", stroke: color, strokeWidth: "2" })
|
|
1013
|
+
] });
|
|
1014
|
+
}
|
|
1015
|
+
function CheckMark({ color }) {
|
|
1016
|
+
return /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M20 6L9 17l-5-5", stroke: color, strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1017
|
+
}
|
|
1018
|
+
function WarningTriangle({ color }) {
|
|
1019
|
+
return /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0, marginTop: 1 }, children: [
|
|
1020
|
+
/* @__PURE__ */ jsx(
|
|
1021
|
+
"path",
|
|
1022
|
+
{
|
|
1023
|
+
d: "M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",
|
|
1024
|
+
stroke: color,
|
|
1025
|
+
strokeWidth: "2",
|
|
1026
|
+
strokeLinecap: "round",
|
|
1027
|
+
strokeLinejoin: "round"
|
|
1028
|
+
}
|
|
1029
|
+
),
|
|
1030
|
+
/* @__PURE__ */ jsx("line", { x1: "12", y1: "9", x2: "12", y2: "13", stroke: color, strokeWidth: "2", strokeLinecap: "round" }),
|
|
1031
|
+
/* @__PURE__ */ jsx("line", { x1: "12", y1: "17", x2: "12.01", y2: "17", stroke: color, strokeWidth: "2", strokeLinecap: "round" })
|
|
1032
|
+
] });
|
|
1033
|
+
}
|
|
978
1034
|
function UniportModal({
|
|
979
1035
|
open,
|
|
980
1036
|
onClose,
|
|
981
1037
|
recipient,
|
|
982
1038
|
refundAddress,
|
|
983
|
-
destinationToken
|
|
1039
|
+
destinationToken,
|
|
984
1040
|
amount: initialAmount,
|
|
1041
|
+
theme: themeMode = "light",
|
|
985
1042
|
onSuccess,
|
|
986
1043
|
onError
|
|
987
1044
|
}) {
|
|
1045
|
+
const t = getTheme(themeMode);
|
|
988
1046
|
const payment = useUniportPayment({
|
|
989
1047
|
recipient,
|
|
990
1048
|
refundAddress,
|
|
991
1049
|
destinationToken,
|
|
1050
|
+
amount: initialAmount,
|
|
992
1051
|
onSuccess,
|
|
993
1052
|
onError
|
|
994
1053
|
});
|
|
995
|
-
const [
|
|
996
|
-
const [tokenDropdownOpen, setTokenDropdownOpen] = React.useState(false);
|
|
1054
|
+
const [modalStep, setModalStep] = useState("chain");
|
|
997
1055
|
const [copied, setCopied] = useState(false);
|
|
998
1056
|
const [showReceipt, setShowReceipt] = useState(false);
|
|
1057
|
+
const [portalRoot, setPortalRoot] = useState(null);
|
|
999
1058
|
useEffect(() => {
|
|
1059
|
+
setPortalRoot(document.body);
|
|
1000
1060
|
injectStyles();
|
|
1001
1061
|
}, []);
|
|
1002
1062
|
useEffect(() => {
|
|
1003
|
-
if (payment.paymentState === "awaiting_deposit")
|
|
1004
|
-
payment.startPolling();
|
|
1005
|
-
}
|
|
1063
|
+
if (payment.paymentState === "awaiting_deposit") payment.startPolling();
|
|
1006
1064
|
}, [payment.paymentState]);
|
|
1007
1065
|
useEffect(() => {
|
|
1008
1066
|
return () => payment.stopPolling();
|
|
1009
1067
|
}, []);
|
|
1010
1068
|
const handleClose = useCallback(() => {
|
|
1011
1069
|
payment.reset();
|
|
1070
|
+
setModalStep("chain");
|
|
1071
|
+
setShowReceipt(false);
|
|
1012
1072
|
onClose();
|
|
1013
1073
|
}, [payment, onClose]);
|
|
1014
1074
|
useEffect(() => {
|
|
1015
|
-
const
|
|
1075
|
+
const onKey = (e) => {
|
|
1016
1076
|
if (e.key === "Escape") handleClose();
|
|
1017
1077
|
};
|
|
1018
1078
|
if (open) {
|
|
1019
|
-
document.addEventListener("keydown",
|
|
1020
|
-
|
|
1079
|
+
document.addEventListener("keydown", onKey);
|
|
1080
|
+
document.body.style.overflow = "hidden";
|
|
1081
|
+
return () => {
|
|
1082
|
+
document.removeEventListener("keydown", onKey);
|
|
1083
|
+
document.body.style.overflow = "";
|
|
1084
|
+
};
|
|
1021
1085
|
}
|
|
1022
1086
|
}, [open, handleClose]);
|
|
1023
1087
|
const handleCopy = useCallback(async () => {
|
|
1024
1088
|
if (payment.quote?.depositAddress) {
|
|
1025
|
-
const
|
|
1026
|
-
if (
|
|
1089
|
+
const ok = await payment.copyToClipboard(payment.quote.depositAddress);
|
|
1090
|
+
if (ok) {
|
|
1027
1091
|
setCopied(true);
|
|
1028
1092
|
setTimeout(() => setCopied(false), 2e3);
|
|
1029
1093
|
}
|
|
1030
1094
|
}
|
|
1031
1095
|
}, [payment]);
|
|
1032
|
-
if (!open) return null;
|
|
1033
|
-
const
|
|
1034
|
-
const
|
|
1035
|
-
const
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1096
|
+
if (!open || !portalRoot) return null;
|
|
1097
|
+
const { paymentState } = payment;
|
|
1098
|
+
const showQR = paymentState === "awaiting_deposit" || paymentState === "processing";
|
|
1099
|
+
const isSuccess = paymentState === "success";
|
|
1100
|
+
const isError = paymentState === "error";
|
|
1101
|
+
const isQuoting = paymentState === "quoting";
|
|
1102
|
+
const canSubmit = !!(payment.selectedToken && payment.amount && payment.refundAddress.trim());
|
|
1103
|
+
const showBack = !isSuccess && !isError && (showQR || modalStep !== "chain");
|
|
1104
|
+
const iconBtn = {
|
|
1105
|
+
width: 36,
|
|
1106
|
+
height: 36,
|
|
1107
|
+
borderRadius: "50%",
|
|
1108
|
+
background: t.iconBtnBg,
|
|
1109
|
+
border: "none",
|
|
1110
|
+
cursor: "pointer",
|
|
1111
|
+
display: "flex",
|
|
1112
|
+
alignItems: "center",
|
|
1113
|
+
justifyContent: "center",
|
|
1114
|
+
transition: "background 0.15s",
|
|
1115
|
+
flexShrink: 0,
|
|
1116
|
+
padding: 0
|
|
1117
|
+
};
|
|
1118
|
+
const primaryBtn = (disabled) => ({
|
|
1119
|
+
width: "100%",
|
|
1120
|
+
height: 52,
|
|
1121
|
+
borderRadius: "14px",
|
|
1122
|
+
border: "none",
|
|
1123
|
+
background: disabled ? t.btnDisabledBg : t.btnBg,
|
|
1124
|
+
color: disabled ? t.btnDisabledText : t.btnText,
|
|
1125
|
+
fontSize: "15px",
|
|
1126
|
+
fontWeight: 600,
|
|
1127
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
1128
|
+
display: "flex",
|
|
1129
|
+
alignItems: "center",
|
|
1130
|
+
justifyContent: "center",
|
|
1131
|
+
gap: "8px",
|
|
1132
|
+
fontFamily: "inherit",
|
|
1133
|
+
letterSpacing: "-0.01em"
|
|
1134
|
+
});
|
|
1135
|
+
const warningBox = {
|
|
1136
|
+
display: "flex",
|
|
1137
|
+
gap: "9px",
|
|
1138
|
+
alignItems: "flex-start",
|
|
1139
|
+
padding: "11px 13px",
|
|
1140
|
+
background: t.warningBg,
|
|
1141
|
+
border: `1px solid ${t.warningBorder}`,
|
|
1142
|
+
borderRadius: "10px"
|
|
1143
|
+
};
|
|
1144
|
+
const renderHeader = (title) => /* @__PURE__ */ jsxs("div", { style: {
|
|
1145
|
+
display: "flex",
|
|
1146
|
+
alignItems: "center",
|
|
1147
|
+
justifyContent: "space-between",
|
|
1148
|
+
padding: "18px 18px 0",
|
|
1149
|
+
marginBottom: "12px"
|
|
1150
|
+
}, children: [
|
|
1151
|
+
/* @__PURE__ */ jsx("div", { style: { width: 36, display: "flex" }, children: showBack && /* @__PURE__ */ jsx(
|
|
1152
|
+
"button",
|
|
1153
|
+
{
|
|
1154
|
+
style: iconBtn,
|
|
1155
|
+
onClick: () => {
|
|
1156
|
+
if (showQR) {
|
|
1157
|
+
payment.cancelQuote();
|
|
1158
|
+
setModalStep("amount");
|
|
1159
|
+
} else if (modalStep === "token") setModalStep("chain");
|
|
1160
|
+
else if (modalStep === "amount") setModalStep("token");
|
|
1161
|
+
},
|
|
1162
|
+
onMouseEnter: (e) => {
|
|
1163
|
+
e.currentTarget.style.background = t.iconBtnHover;
|
|
1164
|
+
},
|
|
1165
|
+
onMouseLeave: (e) => {
|
|
1166
|
+
e.currentTarget.style.background = t.iconBtnBg;
|
|
1167
|
+
},
|
|
1168
|
+
children: /* @__PURE__ */ jsx(BackArrow, { color: t.iconBtnColor })
|
|
1169
|
+
}
|
|
1170
|
+
) }),
|
|
1171
|
+
/* @__PURE__ */ jsx("h2", { style: { margin: 0, fontSize: "16px", fontWeight: 600, color: t.text, letterSpacing: "-0.015em" }, children: title }),
|
|
1172
|
+
/* @__PURE__ */ jsx(
|
|
1173
|
+
"button",
|
|
1174
|
+
{
|
|
1175
|
+
style: iconBtn,
|
|
1176
|
+
onClick: handleClose,
|
|
1177
|
+
onMouseEnter: (e) => {
|
|
1178
|
+
e.currentTarget.style.background = t.iconBtnHover;
|
|
1179
|
+
},
|
|
1180
|
+
onMouseLeave: (e) => {
|
|
1181
|
+
e.currentTarget.style.background = t.iconBtnBg;
|
|
1182
|
+
},
|
|
1183
|
+
children: /* @__PURE__ */ jsx(XMark, { color: t.iconBtnColor })
|
|
1184
|
+
}
|
|
1185
|
+
)
|
|
1186
|
+
] });
|
|
1187
|
+
const renderChainStep = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1188
|
+
renderHeader("Select network"),
|
|
1189
|
+
/* @__PURE__ */ jsx("div", { style: { overflowY: "auto", maxHeight: 420 }, children: payment.chains.map((chain, i) => /* @__PURE__ */ jsxs(
|
|
1190
|
+
"button",
|
|
1191
|
+
{
|
|
1192
|
+
onClick: () => {
|
|
1193
|
+
payment.setSelectedChain(chain);
|
|
1194
|
+
setModalStep("token");
|
|
1195
|
+
},
|
|
1196
|
+
style: {
|
|
1197
|
+
display: "flex",
|
|
1198
|
+
alignItems: "center",
|
|
1199
|
+
gap: "14px",
|
|
1200
|
+
width: "100%",
|
|
1201
|
+
padding: "13px 20px",
|
|
1202
|
+
background: "transparent",
|
|
1203
|
+
border: "none",
|
|
1204
|
+
borderBottom: i < payment.chains.length - 1 ? `1px solid ${t.border}` : "none",
|
|
1205
|
+
cursor: "pointer",
|
|
1206
|
+
textAlign: "left",
|
|
1207
|
+
transition: "background 0.1s",
|
|
1208
|
+
fontFamily: "inherit"
|
|
1209
|
+
},
|
|
1210
|
+
onMouseEnter: (e) => {
|
|
1211
|
+
e.currentTarget.style.background = t.rowHover;
|
|
1212
|
+
},
|
|
1213
|
+
onMouseLeave: (e) => {
|
|
1214
|
+
e.currentTarget.style.background = "transparent";
|
|
1215
|
+
},
|
|
1216
|
+
children: [
|
|
1217
|
+
/* @__PURE__ */ jsx(TokenAvatar, { src: chain.icon, name: chain.name, size: 40 }),
|
|
1218
|
+
/* @__PURE__ */ jsx("span", { style: { flex: 1, fontSize: "15px", fontWeight: 500, color: t.text }, children: chain.name }),
|
|
1219
|
+
/* @__PURE__ */ jsx(ChevronRight, { color: t.textMuted })
|
|
1220
|
+
]
|
|
1221
|
+
},
|
|
1222
|
+
chain.id
|
|
1223
|
+
)) })
|
|
1224
|
+
] });
|
|
1225
|
+
const renderTokenStep = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1226
|
+
renderHeader("Select token"),
|
|
1227
|
+
/* @__PURE__ */ jsx("div", { style: { overflowY: "auto", maxHeight: 420 }, children: payment.tokens.map((token, i) => /* @__PURE__ */ jsxs(
|
|
1228
|
+
"button",
|
|
1229
|
+
{
|
|
1230
|
+
onClick: () => {
|
|
1231
|
+
payment.setSelectedToken(token);
|
|
1232
|
+
setModalStep("amount");
|
|
1233
|
+
},
|
|
1234
|
+
style: {
|
|
1235
|
+
display: "flex",
|
|
1236
|
+
alignItems: "center",
|
|
1237
|
+
gap: "14px",
|
|
1238
|
+
width: "100%",
|
|
1239
|
+
padding: "13px 20px",
|
|
1240
|
+
background: "transparent",
|
|
1241
|
+
border: "none",
|
|
1242
|
+
borderBottom: i < payment.tokens.length - 1 ? `1px solid ${t.border}` : "none",
|
|
1243
|
+
cursor: "pointer",
|
|
1244
|
+
textAlign: "left",
|
|
1245
|
+
transition: "background 0.1s",
|
|
1246
|
+
fontFamily: "inherit"
|
|
1247
|
+
},
|
|
1248
|
+
onMouseEnter: (e) => {
|
|
1249
|
+
e.currentTarget.style.background = t.rowHover;
|
|
1250
|
+
},
|
|
1251
|
+
onMouseLeave: (e) => {
|
|
1252
|
+
e.currentTarget.style.background = "transparent";
|
|
1253
|
+
},
|
|
1254
|
+
children: [
|
|
1255
|
+
/* @__PURE__ */ jsx(TokenAvatar, { src: token.icon, name: token.symbol, size: 40 }),
|
|
1256
|
+
/* @__PURE__ */ jsx("span", { style: { flex: 1, fontSize: "15px", fontWeight: 500, color: t.text }, children: token.symbol }),
|
|
1257
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "13px", color: t.textMuted, fontWeight: 500 }, children: payment.selectedChain?.name })
|
|
1258
|
+
]
|
|
1259
|
+
},
|
|
1260
|
+
token.assetId
|
|
1261
|
+
)) })
|
|
1262
|
+
] });
|
|
1263
|
+
const renderAmountStep = () => {
|
|
1264
|
+
const tok = payment.selectedToken;
|
|
1265
|
+
const ch = payment.selectedChain;
|
|
1266
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1267
|
+
renderHeader("Enter amount"),
|
|
1268
|
+
/* @__PURE__ */ jsxs("div", { style: { padding: "4px 20px 24px" }, children: [
|
|
1269
|
+
/* @__PURE__ */ jsxs("div", { style: {
|
|
1270
|
+
display: "flex",
|
|
1271
|
+
alignItems: "center",
|
|
1272
|
+
gap: "10px",
|
|
1273
|
+
padding: "10px 13px",
|
|
1274
|
+
background: t.inputBg,
|
|
1275
|
+
borderRadius: "12px",
|
|
1276
|
+
marginBottom: "24px"
|
|
1277
|
+
}, children: [
|
|
1278
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [
|
|
1279
|
+
tok && /* @__PURE__ */ jsx(TokenAvatar, { src: tok.icon, name: tok.symbol, size: 30 }),
|
|
1280
|
+
/* @__PURE__ */ jsx("div", { style: { marginLeft: -8, marginTop: 12 }, children: /* @__PURE__ */ jsx(TokenAvatar, { src: payment.destinationToken.icon, name: payment.destinationToken.symbol, size: 20 }) })
|
|
1097
1281
|
] }),
|
|
1098
|
-
/* @__PURE__ */ jsxs("
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1282
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1283
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: "13px", fontWeight: 600, color: t.text }, children: [
|
|
1284
|
+
tok?.symbol,
|
|
1285
|
+
" on ",
|
|
1286
|
+
ch?.name
|
|
1287
|
+
] }),
|
|
1288
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: "12px", color: t.textMuted, marginTop: 1 }, children: [
|
|
1289
|
+
"\u2192 ",
|
|
1290
|
+
payment.destinationToken.symbol,
|
|
1291
|
+
" on ",
|
|
1292
|
+
payment.destinationToken.chain.toUpperCase()
|
|
1293
|
+
] })
|
|
1103
1294
|
] })
|
|
1104
|
-
] }
|
|
1105
|
-
|
|
1106
|
-
/* @__PURE__ */ jsx(
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1295
|
+
] }),
|
|
1296
|
+
/* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginBottom: "6px" }, children: [
|
|
1297
|
+
/* @__PURE__ */ jsx(
|
|
1298
|
+
"input",
|
|
1299
|
+
{
|
|
1300
|
+
type: "text",
|
|
1301
|
+
inputMode: "decimal",
|
|
1302
|
+
placeholder: "0.00",
|
|
1303
|
+
value: payment.amount,
|
|
1304
|
+
onChange: (e) => payment.setAmount(e.target.value),
|
|
1305
|
+
style: {
|
|
1306
|
+
width: "100%",
|
|
1307
|
+
textAlign: "center",
|
|
1308
|
+
fontSize: "54px",
|
|
1309
|
+
fontWeight: 600,
|
|
1310
|
+
color: payment.amount ? t.text : t.textMuted,
|
|
1311
|
+
background: "transparent",
|
|
1312
|
+
border: "none",
|
|
1313
|
+
outline: "none",
|
|
1314
|
+
caretColor: t.accent,
|
|
1315
|
+
fontFamily: "inherit",
|
|
1316
|
+
letterSpacing: "-0.04em",
|
|
1317
|
+
lineHeight: 1,
|
|
1318
|
+
padding: 0
|
|
1319
|
+
},
|
|
1320
|
+
autoFocus: true
|
|
1321
|
+
}
|
|
1322
|
+
),
|
|
1323
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "14px", color: t.textMuted, marginTop: 8 }, children: tok?.symbol })
|
|
1324
|
+
] }),
|
|
1325
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "18px" }, children: [
|
|
1326
|
+
/* @__PURE__ */ jsxs(
|
|
1327
|
+
"label",
|
|
1328
|
+
{
|
|
1329
|
+
style: {
|
|
1330
|
+
display: "block",
|
|
1331
|
+
fontSize: "13px",
|
|
1332
|
+
fontWeight: 600,
|
|
1333
|
+
color: t.text,
|
|
1334
|
+
marginBottom: "8px"
|
|
1335
|
+
},
|
|
1336
|
+
children: [
|
|
1337
|
+
"Refund address on ",
|
|
1338
|
+
ch?.name || "the source chain"
|
|
1339
|
+
]
|
|
1340
|
+
}
|
|
1341
|
+
),
|
|
1342
|
+
/* @__PURE__ */ jsx(
|
|
1343
|
+
"input",
|
|
1344
|
+
{
|
|
1345
|
+
type: "text",
|
|
1346
|
+
value: payment.refundAddress,
|
|
1347
|
+
onChange: (e) => payment.setRefundAddress(e.target.value),
|
|
1348
|
+
placeholder: `Enter a ${ch?.name || "source chain"} refund address`,
|
|
1349
|
+
spellCheck: false,
|
|
1350
|
+
autoCapitalize: "off",
|
|
1351
|
+
autoCorrect: "off",
|
|
1352
|
+
style: {
|
|
1353
|
+
width: "100%",
|
|
1354
|
+
padding: "13px 14px",
|
|
1355
|
+
fontSize: "14px",
|
|
1356
|
+
color: payment.refundAddress ? t.text : t.textMuted,
|
|
1357
|
+
background: t.inputBg,
|
|
1358
|
+
border: `1px solid ${t.border}`,
|
|
1359
|
+
borderRadius: "12px",
|
|
1360
|
+
outline: "none",
|
|
1361
|
+
fontFamily: "inherit"
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
),
|
|
1365
|
+
/* @__PURE__ */ jsx(
|
|
1366
|
+
"p",
|
|
1367
|
+
{
|
|
1368
|
+
style: {
|
|
1369
|
+
margin: "8px 0 0",
|
|
1370
|
+
fontSize: "12px",
|
|
1371
|
+
color: t.textMuted,
|
|
1372
|
+
lineHeight: 1.5
|
|
1373
|
+
},
|
|
1374
|
+
children: "Used only if the swap fails. This address must live on the chain the payer is sending from."
|
|
1375
|
+
}
|
|
1376
|
+
)
|
|
1377
|
+
] }),
|
|
1378
|
+
/* @__PURE__ */ jsxs("div", { style: {
|
|
1379
|
+
textAlign: "center",
|
|
1380
|
+
height: 32,
|
|
1381
|
+
display: "flex",
|
|
1382
|
+
alignItems: "center",
|
|
1383
|
+
justifyContent: "center",
|
|
1384
|
+
gap: 5,
|
|
1385
|
+
marginBottom: "20px"
|
|
1386
|
+
}, children: [
|
|
1387
|
+
payment.amount && payment.isLoadingPreview && [0, 0.2, 0.4].map((delay, i) => /* @__PURE__ */ jsx("div", { style: {
|
|
1388
|
+
width: 6,
|
|
1389
|
+
height: 6,
|
|
1390
|
+
borderRadius: "50%",
|
|
1391
|
+
background: t.accent,
|
|
1392
|
+
animation: `uniport-pulse 1s ease infinite ${delay}s`
|
|
1393
|
+
} }, i)),
|
|
1394
|
+
payment.amount && !payment.isLoadingPreview && payment.previewQuote && /* @__PURE__ */ jsxs("span", { style: { fontSize: "15px", color: t.textSecondary }, children: [
|
|
1395
|
+
"\u2248 ",
|
|
1396
|
+
/* @__PURE__ */ jsxs("strong", { style: { color: t.text }, children: [
|
|
1397
|
+
payment.previewQuote.amountOutFormatted,
|
|
1398
|
+
" ",
|
|
1399
|
+
payment.destinationToken.symbol
|
|
1400
|
+
] })
|
|
1401
|
+
] }),
|
|
1402
|
+
payment.amount && !payment.isLoadingPreview && !payment.previewQuote && /* @__PURE__ */ jsx("span", { style: { fontSize: "13px", color: t.textMuted }, children: "Fetching estimate\u2026" })
|
|
1403
|
+
] }),
|
|
1404
|
+
!!payment.amount && /* @__PURE__ */ jsxs("div", { style: { ...warningBox, marginBottom: "20px" }, children: [
|
|
1405
|
+
/* @__PURE__ */ jsx(WarningTriangle, { color: t.warning }),
|
|
1406
|
+
/* @__PURE__ */ jsxs("p", { style: { margin: 0, fontSize: "13px", color: t.warningText, lineHeight: 1.55 }, children: [
|
|
1407
|
+
"You must send",
|
|
1408
|
+
" ",
|
|
1409
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
1410
|
+
"exactly ",
|
|
1411
|
+
payment.amount,
|
|
1412
|
+
" ",
|
|
1413
|
+
tok?.symbol
|
|
1414
|
+
] }),
|
|
1415
|
+
" ",
|
|
1416
|
+
"on ",
|
|
1417
|
+
/* @__PURE__ */ jsx("strong", { children: ch?.name }),
|
|
1418
|
+
". Sending a different amount or asset may result in loss of funds."
|
|
1112
1419
|
] })
|
|
1113
|
-
] }
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1420
|
+
] }),
|
|
1421
|
+
/* @__PURE__ */ jsx(
|
|
1422
|
+
"button",
|
|
1423
|
+
{
|
|
1424
|
+
disabled: !canSubmit || isQuoting,
|
|
1425
|
+
onClick: () => payment.fetchQuote(),
|
|
1426
|
+
style: primaryBtn(!canSubmit || isQuoting),
|
|
1427
|
+
children: isQuoting ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1428
|
+
/* @__PURE__ */ jsx(Spinner, { color: t.btnText }),
|
|
1429
|
+
" Getting quote\u2026"
|
|
1430
|
+
] }) : "Confirm Payment"
|
|
1431
|
+
}
|
|
1432
|
+
),
|
|
1433
|
+
!payment.refundAddress.trim() && /* @__PURE__ */ jsxs("p", { style: { textAlign: "center", fontSize: "12px", color: t.error, margin: "10px 0 0" }, children: [
|
|
1434
|
+
"Enter a refund address on ",
|
|
1435
|
+
ch?.name || "the source chain",
|
|
1436
|
+
" to continue."
|
|
1437
|
+
] })
|
|
1438
|
+
] })
|
|
1439
|
+
] });
|
|
1440
|
+
};
|
|
1441
|
+
const renderPaymentStep = () => {
|
|
1442
|
+
const { quote } = payment;
|
|
1443
|
+
const isProcessing = paymentState === "processing";
|
|
1444
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1445
|
+
renderHeader(`Send ${payment.amount} ${payment.selectedToken?.symbol ?? ""} on ${payment.selectedChain?.name ?? ""}`),
|
|
1446
|
+
/* @__PURE__ */ jsx("div", { style: { padding: "4px 20px 24px" }, children: quote && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1447
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
1448
|
+
background: "#ffffff",
|
|
1449
|
+
borderRadius: "16px",
|
|
1450
|
+
padding: "20px",
|
|
1451
|
+
display: "flex",
|
|
1452
|
+
alignItems: "center",
|
|
1453
|
+
justifyContent: "center",
|
|
1454
|
+
border: `1px solid ${t.border}`,
|
|
1455
|
+
marginBottom: "14px"
|
|
1456
|
+
}, children: /* @__PURE__ */ jsx(
|
|
1125
1457
|
QRCodeSVG,
|
|
1126
1458
|
{
|
|
1127
|
-
value:
|
|
1128
|
-
size:
|
|
1459
|
+
value: quote.depositAddress,
|
|
1460
|
+
size: 200,
|
|
1129
1461
|
level: "M",
|
|
1130
|
-
bgColor: "
|
|
1131
|
-
fgColor: "
|
|
1462
|
+
bgColor: "#ffffff",
|
|
1463
|
+
fgColor: "#000000"
|
|
1132
1464
|
}
|
|
1133
1465
|
) }),
|
|
1134
|
-
/* @__PURE__ */ jsxs("div", { style:
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1466
|
+
/* @__PURE__ */ jsxs("div", { style: {
|
|
1467
|
+
display: "flex",
|
|
1468
|
+
alignItems: "center",
|
|
1469
|
+
gap: "10px",
|
|
1470
|
+
padding: "11px 13px",
|
|
1471
|
+
background: t.inputBg,
|
|
1472
|
+
borderRadius: "10px",
|
|
1473
|
+
marginBottom: "14px",
|
|
1474
|
+
border: `1px solid ${t.border}`
|
|
1475
|
+
}, children: [
|
|
1476
|
+
/* @__PURE__ */ jsx("span", { style: {
|
|
1477
|
+
flex: 1,
|
|
1478
|
+
fontSize: "11px",
|
|
1479
|
+
color: t.textSecondary,
|
|
1480
|
+
fontFamily: "monospace",
|
|
1481
|
+
wordBreak: "break-all",
|
|
1482
|
+
lineHeight: 1.5
|
|
1483
|
+
}, children: quote.depositAddress }),
|
|
1140
1484
|
/* @__PURE__ */ jsx(
|
|
1141
1485
|
"button",
|
|
1142
1486
|
{
|
|
1143
|
-
style: styles.copyButton,
|
|
1144
1487
|
onClick: handleCopy,
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1488
|
+
title: "Copy address",
|
|
1489
|
+
style: {
|
|
1490
|
+
flexShrink: 0,
|
|
1491
|
+
width: 34,
|
|
1492
|
+
height: 34,
|
|
1493
|
+
borderRadius: "8px",
|
|
1494
|
+
background: copied ? `${t.success}18` : t.iconBtnBg,
|
|
1495
|
+
border: `1px solid ${copied ? t.success + "44" : t.border}`,
|
|
1496
|
+
cursor: "pointer",
|
|
1497
|
+
display: "flex",
|
|
1498
|
+
alignItems: "center",
|
|
1499
|
+
justifyContent: "center",
|
|
1500
|
+
transition: "all 0.2s"
|
|
1150
1501
|
},
|
|
1151
|
-
children: copied ? /* @__PURE__ */ jsx(
|
|
1502
|
+
children: copied ? /* @__PURE__ */ jsx(CheckMark, { color: t.success }) : /* @__PURE__ */ jsx(CopyIcon, { color: t.textMuted })
|
|
1152
1503
|
}
|
|
1153
1504
|
)
|
|
1154
1505
|
] }),
|
|
1155
|
-
/* @__PURE__ */ jsxs("div", { style: { ...
|
|
1156
|
-
/* @__PURE__ */
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
style: {
|
|
1162
|
-
...styles.statusBadge,
|
|
1163
|
-
...styles.processingBadge
|
|
1164
|
-
},
|
|
1165
|
-
children: [
|
|
1166
|
-
/* @__PURE__ */ jsx(PulseIcon, {}),
|
|
1167
|
-
" ",
|
|
1168
|
-
payment.paymentState === "processing" ? "Processing deposit..." : "Waiting for deposit"
|
|
1169
|
-
]
|
|
1170
|
-
}
|
|
1171
|
-
)
|
|
1172
|
-
] }),
|
|
1173
|
-
/* @__PURE__ */ jsxs("div", { style: styles.detailRow, children: [
|
|
1174
|
-
/* @__PURE__ */ jsx("span", { children: "Amount to send" }),
|
|
1175
|
-
/* @__PURE__ */ jsxs("span", { style: styles.detailValue, children: [
|
|
1506
|
+
/* @__PURE__ */ jsxs("div", { style: { ...warningBox, marginBottom: "14px" }, children: [
|
|
1507
|
+
/* @__PURE__ */ jsx(WarningTriangle, { color: t.warning }),
|
|
1508
|
+
/* @__PURE__ */ jsxs("p", { style: { margin: 0, fontSize: "13px", color: t.warningText, lineHeight: 1.55 }, children: [
|
|
1509
|
+
"Only send",
|
|
1510
|
+
" ",
|
|
1511
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
1176
1512
|
payment.amount,
|
|
1177
1513
|
" ",
|
|
1178
|
-
payment.selectedToken?.symbol
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
/* @__PURE__ */ jsxs("span", { style: styles.detailValue, children: [
|
|
1185
|
-
"~",
|
|
1186
|
-
payment.quote.amountOutFormatted,
|
|
1187
|
-
" ",
|
|
1188
|
-
payment.destinationToken.symbol,
|
|
1189
|
-
/* @__PURE__ */ jsx("span", { style: styles.tokenBadge, children: "Sui" })
|
|
1190
|
-
] })
|
|
1191
|
-
] })
|
|
1192
|
-
] })
|
|
1193
|
-
] }),
|
|
1194
|
-
!showQR && !isSuccess && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1195
|
-
/* @__PURE__ */ jsxs("div", { style: styles.selectorsRow, children: [
|
|
1196
|
-
/* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
1197
|
-
/* @__PURE__ */ jsxs(
|
|
1198
|
-
"div",
|
|
1199
|
-
{
|
|
1200
|
-
style: styles.selector,
|
|
1201
|
-
onClick: () => {
|
|
1202
|
-
setChainDropdownOpen(!chainDropdownOpen);
|
|
1203
|
-
setTokenDropdownOpen(false);
|
|
1204
|
-
},
|
|
1205
|
-
children: [
|
|
1206
|
-
/* @__PURE__ */ jsxs(
|
|
1207
|
-
"div",
|
|
1208
|
-
{
|
|
1209
|
-
style: {
|
|
1210
|
-
display: "flex",
|
|
1211
|
-
alignItems: "center",
|
|
1212
|
-
gap: "12px"
|
|
1213
|
-
},
|
|
1214
|
-
children: [
|
|
1215
|
-
/* @__PURE__ */ jsx("div", { style: styles.selectorIcon, children: payment.selectedChain ? /* @__PURE__ */ jsx(
|
|
1216
|
-
"img",
|
|
1217
|
-
{
|
|
1218
|
-
src: payment.selectedChain.icon,
|
|
1219
|
-
alt: "",
|
|
1220
|
-
style: {
|
|
1221
|
-
width: "100%",
|
|
1222
|
-
height: "100%"
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
) : /* @__PURE__ */ jsx(GlobeIcon, {}) }),
|
|
1226
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1227
|
-
/* @__PURE__ */ jsx("div", { style: styles.selectorLabel, children: "Chain" }),
|
|
1228
|
-
/* @__PURE__ */ jsx("div", { style: styles.selectorValue, children: payment.selectedChain?.name || "Select" })
|
|
1229
|
-
] })
|
|
1230
|
-
]
|
|
1231
|
-
}
|
|
1232
|
-
),
|
|
1233
|
-
/* @__PURE__ */ jsx(ChevronIcon, {})
|
|
1234
|
-
]
|
|
1235
|
-
}
|
|
1236
|
-
),
|
|
1237
|
-
chainDropdownOpen && /* @__PURE__ */ jsx("div", { style: styles.dropdown, children: payment.chains.map((chain) => /* @__PURE__ */ jsxs(
|
|
1238
|
-
"div",
|
|
1239
|
-
{
|
|
1240
|
-
style: styles.dropdownItem,
|
|
1241
|
-
onClick: () => {
|
|
1242
|
-
payment.setSelectedChain(chain);
|
|
1243
|
-
setChainDropdownOpen(false);
|
|
1244
|
-
},
|
|
1245
|
-
onMouseEnter: (e) => {
|
|
1246
|
-
e.currentTarget.style.background = "rgba(255,255,255,0.1)";
|
|
1247
|
-
},
|
|
1248
|
-
onMouseLeave: (e) => {
|
|
1249
|
-
e.currentTarget.style.background = "transparent";
|
|
1250
|
-
},
|
|
1251
|
-
children: [
|
|
1252
|
-
/* @__PURE__ */ jsx(
|
|
1253
|
-
"img",
|
|
1254
|
-
{
|
|
1255
|
-
src: chain.icon,
|
|
1256
|
-
alt: "",
|
|
1257
|
-
style: {
|
|
1258
|
-
width: "24px",
|
|
1259
|
-
height: "24px",
|
|
1260
|
-
borderRadius: "50%"
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
),
|
|
1264
|
-
/* @__PURE__ */ jsx(
|
|
1265
|
-
"span",
|
|
1266
|
-
{
|
|
1267
|
-
style: {
|
|
1268
|
-
color: "white",
|
|
1269
|
-
fontSize: "14px"
|
|
1270
|
-
},
|
|
1271
|
-
children: chain.name
|
|
1272
|
-
}
|
|
1273
|
-
)
|
|
1274
|
-
]
|
|
1275
|
-
},
|
|
1276
|
-
chain.id
|
|
1277
|
-
)) })
|
|
1278
|
-
] }),
|
|
1279
|
-
/* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
1280
|
-
/* @__PURE__ */ jsxs(
|
|
1281
|
-
"div",
|
|
1282
|
-
{
|
|
1283
|
-
style: {
|
|
1284
|
-
...styles.selector,
|
|
1285
|
-
opacity: payment.selectedChain ? 1 : 0.5,
|
|
1286
|
-
pointerEvents: payment.selectedChain ? "auto" : "none"
|
|
1287
|
-
},
|
|
1288
|
-
onClick: () => {
|
|
1289
|
-
if (payment.selectedChain) {
|
|
1290
|
-
setTokenDropdownOpen(!tokenDropdownOpen);
|
|
1291
|
-
setChainDropdownOpen(false);
|
|
1292
|
-
}
|
|
1293
|
-
},
|
|
1294
|
-
children: [
|
|
1295
|
-
/* @__PURE__ */ jsxs(
|
|
1296
|
-
"div",
|
|
1297
|
-
{
|
|
1298
|
-
style: {
|
|
1299
|
-
display: "flex",
|
|
1300
|
-
alignItems: "center",
|
|
1301
|
-
gap: "12px"
|
|
1302
|
-
},
|
|
1303
|
-
children: [
|
|
1304
|
-
/* @__PURE__ */ jsx("div", { style: styles.selectorIcon, children: payment.selectedToken ? /* @__PURE__ */ jsx(
|
|
1305
|
-
"img",
|
|
1306
|
-
{
|
|
1307
|
-
src: payment.selectedToken.icon,
|
|
1308
|
-
alt: "",
|
|
1309
|
-
style: {
|
|
1310
|
-
width: "100%",
|
|
1311
|
-
height: "100%"
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
) : /* @__PURE__ */ jsx(DollarIcon, {}) }),
|
|
1315
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1316
|
-
/* @__PURE__ */ jsx("div", { style: styles.selectorLabel, children: "Token" }),
|
|
1317
|
-
/* @__PURE__ */ jsx("div", { style: styles.selectorValue, children: payment.selectedToken?.symbol || "Select" })
|
|
1318
|
-
] })
|
|
1319
|
-
]
|
|
1320
|
-
}
|
|
1321
|
-
),
|
|
1322
|
-
/* @__PURE__ */ jsx(ChevronIcon, {})
|
|
1323
|
-
]
|
|
1324
|
-
}
|
|
1325
|
-
),
|
|
1326
|
-
tokenDropdownOpen && /* @__PURE__ */ jsx("div", { style: styles.dropdown, children: payment.tokens.map((token) => /* @__PURE__ */ jsxs(
|
|
1327
|
-
"div",
|
|
1328
|
-
{
|
|
1329
|
-
style: styles.dropdownItem,
|
|
1330
|
-
onClick: () => {
|
|
1331
|
-
payment.setSelectedToken(token);
|
|
1332
|
-
setTokenDropdownOpen(false);
|
|
1333
|
-
},
|
|
1334
|
-
onMouseEnter: (e) => {
|
|
1335
|
-
e.currentTarget.style.background = "rgba(255,255,255,0.1)";
|
|
1336
|
-
},
|
|
1337
|
-
onMouseLeave: (e) => {
|
|
1338
|
-
e.currentTarget.style.background = "transparent";
|
|
1339
|
-
},
|
|
1340
|
-
children: [
|
|
1341
|
-
/* @__PURE__ */ jsx(
|
|
1342
|
-
"img",
|
|
1343
|
-
{
|
|
1344
|
-
src: token.icon,
|
|
1345
|
-
alt: "",
|
|
1346
|
-
style: {
|
|
1347
|
-
width: "24px",
|
|
1348
|
-
height: "24px",
|
|
1349
|
-
borderRadius: "50%"
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
),
|
|
1353
|
-
/* @__PURE__ */ jsx(
|
|
1354
|
-
"span",
|
|
1355
|
-
{
|
|
1356
|
-
style: {
|
|
1357
|
-
color: "white",
|
|
1358
|
-
fontSize: "14px"
|
|
1359
|
-
},
|
|
1360
|
-
children: token.symbol
|
|
1361
|
-
}
|
|
1362
|
-
)
|
|
1363
|
-
]
|
|
1364
|
-
},
|
|
1365
|
-
token.assetId
|
|
1366
|
-
)) })
|
|
1514
|
+
payment.selectedToken?.symbol
|
|
1515
|
+
] }),
|
|
1516
|
+
" ",
|
|
1517
|
+
"on ",
|
|
1518
|
+
/* @__PURE__ */ jsx("strong", { children: payment.selectedChain?.name }),
|
|
1519
|
+
" to this address. Other assets may be permanently lost."
|
|
1367
1520
|
] })
|
|
1368
1521
|
] }),
|
|
1369
|
-
/* @__PURE__ */
|
|
1370
|
-
"
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
value: payment.amount,
|
|
1376
|
-
onChange: (e) => payment.setAmount(e.target.value),
|
|
1377
|
-
style: styles.amountInput
|
|
1378
|
-
}
|
|
1379
|
-
),
|
|
1380
|
-
/* @__PURE__ */ jsxs("div", { style: styles.details, children: [
|
|
1381
|
-
payment.amount && /* @__PURE__ */ jsxs("div", { style: styles.detailRow, children: [
|
|
1382
|
-
/* @__PURE__ */ jsx("span", { children: "You receive" }),
|
|
1383
|
-
payment.isLoadingPreview ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "4px" }, children: [
|
|
1384
|
-
/* @__PURE__ */ jsx("div", { style: styles.loadingDot }),
|
|
1385
|
-
/* @__PURE__ */ jsx("div", { style: { ...styles.loadingDot, animationDelay: "0.2s" } }),
|
|
1386
|
-
/* @__PURE__ */ jsx("div", { style: { ...styles.loadingDot, animationDelay: "0.4s" } })
|
|
1387
|
-
] }) : payment.previewQuote ? /* @__PURE__ */ jsxs("span", { style: styles.detailValue, children: [
|
|
1388
|
-
"~",
|
|
1389
|
-
payment.previewQuote.amountOutFormatted,
|
|
1522
|
+
/* @__PURE__ */ jsxs("div", { style: { borderTop: `1px solid ${t.border}`, paddingTop: "12px" }, children: [
|
|
1523
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "10px" }, children: [
|
|
1524
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "13px", color: t.textMuted }, children: "You'll receive" }),
|
|
1525
|
+
/* @__PURE__ */ jsxs("span", { style: { fontSize: "13px", fontWeight: 600, color: t.text }, children: [
|
|
1526
|
+
"\u2248",
|
|
1527
|
+
quote.amountOutFormatted,
|
|
1390
1528
|
" ",
|
|
1391
1529
|
payment.destinationToken.symbol
|
|
1392
|
-
] }) : /* @__PURE__ */ jsx("span", { style: { color: "rgba(255,255,255,0.3)" }, children: "Enter amount..." })
|
|
1393
|
-
] }),
|
|
1394
|
-
/* @__PURE__ */ jsxs("div", { style: styles.detailRow, children: [
|
|
1395
|
-
/* @__PURE__ */ jsx("span", { children: "Destination" }),
|
|
1396
|
-
/* @__PURE__ */ jsxs("span", { style: styles.detailValue, children: [
|
|
1397
|
-
payment.destinationToken.symbol,
|
|
1398
|
-
" on Sui"
|
|
1399
1530
|
] })
|
|
1400
|
-
] })
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
" Processing..."
|
|
1531
|
+
] }),
|
|
1532
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
1533
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "13px", color: t.textMuted }, children: "Status" }),
|
|
1534
|
+
/* @__PURE__ */ jsx("span", { style: {
|
|
1535
|
+
fontSize: "13px",
|
|
1536
|
+
fontWeight: 600,
|
|
1537
|
+
color: isProcessing ? t.accent : t.warning,
|
|
1538
|
+
display: "flex",
|
|
1539
|
+
alignItems: "center",
|
|
1540
|
+
gap: "6px"
|
|
1541
|
+
}, children: isProcessing ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1542
|
+
/* @__PURE__ */ jsx(Spinner, { color: t.accent }),
|
|
1543
|
+
" Processing\u2026"
|
|
1414
1544
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1415
|
-
|
|
1416
|
-
|
|
1545
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
1546
|
+
width: 8,
|
|
1547
|
+
height: 8,
|
|
1548
|
+
borderRadius: "50%",
|
|
1549
|
+
background: t.warning,
|
|
1550
|
+
animation: "uniport-pulse 1.5s ease infinite"
|
|
1551
|
+
} }),
|
|
1552
|
+
"Waiting for deposit"
|
|
1417
1553
|
] }) })
|
|
1418
|
-
}
|
|
1419
|
-
)
|
|
1420
|
-
] })
|
|
1421
|
-
] })
|
|
1554
|
+
] })
|
|
1555
|
+
] })
|
|
1556
|
+
] }) })
|
|
1557
|
+
] });
|
|
1558
|
+
};
|
|
1559
|
+
const renderSuccessStep = () => /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
1422
1560
|
/* @__PURE__ */ jsx(
|
|
1423
|
-
"
|
|
1561
|
+
"button",
|
|
1424
1562
|
{
|
|
1425
|
-
style: {
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
marginTop: "16px"
|
|
1563
|
+
style: { ...iconBtn, position: "absolute", top: 18, right: 18 },
|
|
1564
|
+
onClick: handleClose,
|
|
1565
|
+
onMouseEnter: (e) => {
|
|
1566
|
+
e.currentTarget.style.background = t.iconBtnHover;
|
|
1430
1567
|
},
|
|
1431
|
-
|
|
1568
|
+
onMouseLeave: (e) => {
|
|
1569
|
+
e.currentTarget.style.background = t.iconBtnBg;
|
|
1570
|
+
},
|
|
1571
|
+
children: /* @__PURE__ */ jsx(XMark, { color: t.iconBtnColor })
|
|
1432
1572
|
}
|
|
1433
|
-
)
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1573
|
+
),
|
|
1574
|
+
/* @__PURE__ */ jsxs("div", { style: { padding: "44px 24px 28px", textAlign: "center" }, children: [
|
|
1575
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
1576
|
+
width: 72,
|
|
1577
|
+
height: 72,
|
|
1578
|
+
borderRadius: "50%",
|
|
1579
|
+
background: `${t.success}18`,
|
|
1580
|
+
border: `2px solid ${t.success}55`,
|
|
1581
|
+
display: "flex",
|
|
1582
|
+
alignItems: "center",
|
|
1583
|
+
justifyContent: "center",
|
|
1584
|
+
margin: "0 auto 20px"
|
|
1585
|
+
}, children: /* @__PURE__ */ jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
|
|
1586
|
+
"path",
|
|
1587
|
+
{
|
|
1588
|
+
d: "M20 6L9 17l-5-5",
|
|
1589
|
+
stroke: t.success,
|
|
1590
|
+
strokeWidth: "2.5",
|
|
1591
|
+
strokeLinecap: "round",
|
|
1592
|
+
strokeLinejoin: "round"
|
|
1593
|
+
}
|
|
1594
|
+
) }) }),
|
|
1595
|
+
/* @__PURE__ */ jsx("h2", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 700, color: t.text, letterSpacing: "-0.02em" }, children: "Payment sent!" }),
|
|
1596
|
+
/* @__PURE__ */ jsxs("p", { style: { margin: "0 0 24px", fontSize: "14px", color: t.textMuted, lineHeight: 1.6 }, children: [
|
|
1597
|
+
payment.amount,
|
|
1598
|
+
" ",
|
|
1599
|
+
payment.selectedToken?.symbol,
|
|
1600
|
+
" \u2192 ",
|
|
1601
|
+
"\u2248",
|
|
1602
|
+
payment.quote?.amountOutFormatted,
|
|
1603
|
+
" ",
|
|
1604
|
+
payment.destinationToken.symbol
|
|
1605
|
+
] }),
|
|
1606
|
+
/* @__PURE__ */ jsx(
|
|
1607
|
+
"button",
|
|
1608
|
+
{
|
|
1609
|
+
onClick: () => setShowReceipt((p) => !p),
|
|
1610
|
+
style: {
|
|
1611
|
+
background: "transparent",
|
|
1612
|
+
border: "none",
|
|
1613
|
+
color: t.accent,
|
|
1614
|
+
fontSize: "14px",
|
|
1615
|
+
cursor: "pointer",
|
|
1616
|
+
textDecoration: "underline",
|
|
1617
|
+
marginBottom: showReceipt ? 14 : 0,
|
|
1618
|
+
fontFamily: "inherit"
|
|
1619
|
+
},
|
|
1620
|
+
children: showReceipt ? "Hide receipt" : "View receipt"
|
|
1621
|
+
}
|
|
1622
|
+
),
|
|
1623
|
+
showReceipt && /* @__PURE__ */ jsxs("div", { style: { background: t.inputBg, borderRadius: "12px", padding: "14px", textAlign: "left", marginBottom: "20px" }, children: [
|
|
1624
|
+
payment.status?.originTxHashes?.map((hash, i) => /* @__PURE__ */ jsxs("div", { style: { marginBottom: 10 }, children: [
|
|
1625
|
+
/* @__PURE__ */ jsxs("p", { style: { color: t.textMuted, fontSize: "11px", margin: "0 0 3px", textTransform: "uppercase", letterSpacing: "0.05em" }, children: [
|
|
1626
|
+
"Source TX \xB7 ",
|
|
1627
|
+
payment.selectedChain?.name
|
|
1628
|
+
] }),
|
|
1629
|
+
/* @__PURE__ */ jsxs(
|
|
1630
|
+
"a",
|
|
1631
|
+
{
|
|
1632
|
+
href: `https://etherscan.io/tx/${hash}`,
|
|
1633
|
+
target: "_blank",
|
|
1634
|
+
rel: "noopener noreferrer",
|
|
1635
|
+
style: { color: t.accent, fontSize: "12px", fontFamily: "monospace", textDecoration: "none" },
|
|
1636
|
+
children: [
|
|
1637
|
+
hash.slice(0, 12),
|
|
1638
|
+
"\u2026",
|
|
1639
|
+
hash.slice(-8),
|
|
1640
|
+
" \u2197"
|
|
1641
|
+
]
|
|
1642
|
+
}
|
|
1643
|
+
)
|
|
1644
|
+
] }, `o${i}`)),
|
|
1645
|
+
payment.status?.destinationTxHashes?.map((hash, i) => /* @__PURE__ */ jsxs("div", { children: [
|
|
1646
|
+
/* @__PURE__ */ jsx("p", { style: { color: t.textMuted, fontSize: "11px", margin: "0 0 3px", textTransform: "uppercase", letterSpacing: "0.05em" }, children: "Destination TX" }),
|
|
1647
|
+
/* @__PURE__ */ jsxs("span", { style: { color: t.textSecondary, fontSize: "12px", fontFamily: "monospace" }, children: [
|
|
1648
|
+
hash.slice(0, 12),
|
|
1649
|
+
"\u2026",
|
|
1650
|
+
hash.slice(-8)
|
|
1651
|
+
] })
|
|
1652
|
+
] }, `d${i}`)),
|
|
1653
|
+
!payment.status?.originTxHashes?.length && !payment.status?.destinationTxHashes?.length && /* @__PURE__ */ jsx("p", { style: { color: t.textMuted, fontSize: "13px", margin: 0 }, children: "Loading transaction details\u2026" })
|
|
1654
|
+
] }),
|
|
1655
|
+
/* @__PURE__ */ jsx("button", { onClick: handleClose, style: primaryBtn(false), children: "Done" })
|
|
1656
|
+
] })
|
|
1657
|
+
] });
|
|
1658
|
+
const renderErrorStep = () => /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
1659
|
+
/* @__PURE__ */ jsx(
|
|
1660
|
+
"button",
|
|
1661
|
+
{
|
|
1662
|
+
style: { ...iconBtn, position: "absolute", top: 18, right: 18 },
|
|
1663
|
+
onClick: handleClose,
|
|
1664
|
+
onMouseEnter: (e) => {
|
|
1665
|
+
e.currentTarget.style.background = t.iconBtnHover;
|
|
1666
|
+
},
|
|
1667
|
+
onMouseLeave: (e) => {
|
|
1668
|
+
e.currentTarget.style.background = t.iconBtnBg;
|
|
1669
|
+
},
|
|
1670
|
+
children: /* @__PURE__ */ jsx(XMark, { color: t.iconBtnColor })
|
|
1671
|
+
}
|
|
1672
|
+
),
|
|
1673
|
+
/* @__PURE__ */ jsxs("div", { style: { padding: "44px 24px 28px", textAlign: "center" }, children: [
|
|
1674
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
1675
|
+
width: 72,
|
|
1676
|
+
height: 72,
|
|
1677
|
+
borderRadius: "50%",
|
|
1678
|
+
background: `${t.error}18`,
|
|
1679
|
+
border: `2px solid ${t.error}44`,
|
|
1680
|
+
display: "flex",
|
|
1681
|
+
alignItems: "center",
|
|
1682
|
+
justifyContent: "center",
|
|
1683
|
+
margin: "0 auto 20px"
|
|
1684
|
+
}, children: /* @__PURE__ */ jsx(XMark, { color: t.error }) }),
|
|
1685
|
+
/* @__PURE__ */ jsx("h2", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 700, color: t.text, letterSpacing: "-0.02em" }, children: "Payment failed" }),
|
|
1686
|
+
/* @__PURE__ */ jsx("p", { style: { margin: "0 0 28px", fontSize: "14px", color: t.textMuted, lineHeight: 1.6 }, children: payment.error?.message || "Something went wrong. Please try again." }),
|
|
1687
|
+
/* @__PURE__ */ jsx(
|
|
1688
|
+
"button",
|
|
1689
|
+
{
|
|
1690
|
+
onClick: () => {
|
|
1691
|
+
payment.reset();
|
|
1692
|
+
setModalStep("chain");
|
|
1693
|
+
},
|
|
1694
|
+
style: { ...primaryBtn(false), background: "transparent", border: `1.5px solid ${t.border}`, color: t.text },
|
|
1695
|
+
children: "Try again"
|
|
1696
|
+
}
|
|
1697
|
+
)
|
|
1698
|
+
] })
|
|
1699
|
+
] });
|
|
1700
|
+
const renderContent = () => {
|
|
1701
|
+
if (isSuccess) return renderSuccessStep();
|
|
1702
|
+
if (isError) return renderErrorStep();
|
|
1703
|
+
if (showQR) return renderPaymentStep();
|
|
1704
|
+
if (modalStep === "chain") return renderChainStep();
|
|
1705
|
+
if (modalStep === "token") return renderTokenStep();
|
|
1706
|
+
return renderAmountStep();
|
|
1707
|
+
};
|
|
1708
|
+
return ReactDOM.createPortal(
|
|
1709
|
+
/* @__PURE__ */ jsx(
|
|
1710
|
+
"div",
|
|
1711
|
+
{
|
|
1712
|
+
style: {
|
|
1713
|
+
// This overlay must live at the top of the DOM stacking order.
|
|
1714
|
+
// By portaling into document.body we escape any parent element that
|
|
1715
|
+
// has transform, filter, or backdrop-filter (all of which would
|
|
1716
|
+
// otherwise break position:fixed, making it relative to that element
|
|
1717
|
+
// rather than the viewport).
|
|
1718
|
+
position: "fixed",
|
|
1719
|
+
top: 0,
|
|
1720
|
+
left: 0,
|
|
1721
|
+
right: 0,
|
|
1722
|
+
bottom: 0,
|
|
1723
|
+
zIndex: 2147483647,
|
|
1724
|
+
// max z-index
|
|
1725
|
+
display: "flex",
|
|
1726
|
+
alignItems: "center",
|
|
1727
|
+
justifyContent: "center",
|
|
1728
|
+
padding: "16px",
|
|
1729
|
+
// Overlay colour + frosted effect applied here (on the backdrop),
|
|
1730
|
+
// NOT on the modal card itself.
|
|
1731
|
+
backgroundColor: t.overlay,
|
|
1732
|
+
backdropFilter: "blur(18px) saturate(180%)",
|
|
1733
|
+
WebkitBackdropFilter: "blur(18px) saturate(180%)",
|
|
1734
|
+
animation: "uniport-fade-in 0.18s ease"
|
|
1735
|
+
},
|
|
1736
|
+
onClick: handleClose,
|
|
1737
|
+
children: /* @__PURE__ */ jsx(
|
|
1738
|
+
"div",
|
|
1574
1739
|
{
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1740
|
+
onClick: (e) => e.stopPropagation(),
|
|
1741
|
+
style: {
|
|
1742
|
+
position: "relative",
|
|
1743
|
+
width: "100%",
|
|
1744
|
+
maxWidth: "440px",
|
|
1745
|
+
// Solid card — no glassmorphism on the card itself
|
|
1746
|
+
background: t.modalBg,
|
|
1747
|
+
borderRadius: "20px",
|
|
1748
|
+
boxShadow: themeMode === "light" ? "0 24px 64px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.06)" : "0 24px 64px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.06)",
|
|
1749
|
+
fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
1750
|
+
// Only the initial modal mount gets the slide-up animation.
|
|
1751
|
+
// Content transitions (chain→token→amount) use plain renders,
|
|
1752
|
+
// not component remounts, so polling re-renders don't re-trigger it.
|
|
1753
|
+
animation: "uniport-slide-up 0.22s ease",
|
|
1754
|
+
overflow: "hidden",
|
|
1755
|
+
maxHeight: "90vh",
|
|
1756
|
+
display: "flex",
|
|
1757
|
+
flexDirection: "column"
|
|
1758
|
+
},
|
|
1759
|
+
children: renderContent()
|
|
1579
1760
|
}
|
|
1580
1761
|
)
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
}
|
|
1585
|
-
function ArrowIcon() {
|
|
1586
|
-
return /* @__PURE__ */ jsx(
|
|
1587
|
-
"svg",
|
|
1588
|
-
{
|
|
1589
|
-
width: "16",
|
|
1590
|
-
height: "16",
|
|
1591
|
-
viewBox: "0 0 24 24",
|
|
1592
|
-
fill: "none",
|
|
1593
|
-
stroke: "currentColor",
|
|
1594
|
-
strokeWidth: "2",
|
|
1595
|
-
children: /* @__PURE__ */ jsx("path", { d: "M5 12h14M12 5l7 7-7 7" })
|
|
1596
|
-
}
|
|
1762
|
+
}
|
|
1763
|
+
),
|
|
1764
|
+
portalRoot
|
|
1597
1765
|
);
|
|
1598
1766
|
}
|
|
1599
1767
|
var buttonStyles = {
|
|
@@ -1655,12 +1823,13 @@ var buttonStyles = {
|
|
|
1655
1823
|
function UniportButton({
|
|
1656
1824
|
recipient,
|
|
1657
1825
|
refundAddress,
|
|
1658
|
-
destinationToken
|
|
1826
|
+
destinationToken,
|
|
1659
1827
|
amount,
|
|
1660
1828
|
label = "Pay with Crypto",
|
|
1661
1829
|
variant = "default",
|
|
1662
1830
|
disabled = false,
|
|
1663
1831
|
className,
|
|
1832
|
+
theme = "light",
|
|
1664
1833
|
onSuccess,
|
|
1665
1834
|
onError,
|
|
1666
1835
|
onOpenChange
|
|
@@ -1704,6 +1873,7 @@ function UniportButton({
|
|
|
1704
1873
|
refundAddress,
|
|
1705
1874
|
destinationToken,
|
|
1706
1875
|
amount,
|
|
1876
|
+
theme,
|
|
1707
1877
|
onSuccess,
|
|
1708
1878
|
onError
|
|
1709
1879
|
}
|
|
@@ -1755,6 +1925,6 @@ function UniportIcon() {
|
|
|
1755
1925
|
);
|
|
1756
1926
|
}
|
|
1757
1927
|
|
|
1758
|
-
export { ALL_TOKENS, CHAINS, CHAIN_ICONS, TOKEN_ICONS, UniportButton, UniportModal, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, fromSmallestUnits, generateDeadline,
|
|
1928
|
+
export { ALL_TOKENS, CHAINS, CHAIN_ICONS, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, TOKEN_ICONS, UniportButton, UniportError, UniportModal, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, fromSmallestUnits, generateDeadline, getExecutionStatus, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, rippleXRP, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, useUniportPayment, zcashZEC };
|
|
1759
1929
|
//# sourceMappingURL=index.js.map
|
|
1760
1930
|
//# sourceMappingURL=index.js.map
|