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