uniport-sdk 0.0.1

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.
@@ -0,0 +1,1694 @@
1
+ import React, { useState, useEffect, useCallback, useRef } from 'react';
2
+ import { QRCodeSVG } from 'qrcode.react';
3
+ import { QuoteRequest, OneClickService, ApiError } from '@defuse-protocol/one-click-sdk-typescript';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+
6
+ // src/components/UniportButton.tsx
7
+ function getConfig() {
8
+ {
9
+ throw new Error(
10
+ "Uniport SDK not initialized. Call initUniport() first."
11
+ );
12
+ }
13
+ }
14
+
15
+ // src/core/intents.ts
16
+ function toSmallestUnits(amount, decimals) {
17
+ const [whole, fraction = ""] = amount.split(".");
18
+ const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
19
+ return `${whole}${paddedFraction}`.replace(/^0+/, "") || "0";
20
+ }
21
+ function generateDeadline(hoursFromNow = 1) {
22
+ const deadline = new Date(Date.now() + hoursFromNow * 60 * 60 * 1e3);
23
+ return deadline.toISOString();
24
+ }
25
+ function ensureInitialized() {
26
+ {
27
+ throw new Error(
28
+ "Uniport SDK not initialized. Call initUniport() first."
29
+ );
30
+ }
31
+ }
32
+ async function getQuote(options) {
33
+ ensureInitialized();
34
+ const config = getConfig();
35
+ const {
36
+ originToken,
37
+ destinationToken,
38
+ amount,
39
+ recipient,
40
+ refundTo,
41
+ slippageTolerance = 100,
42
+ // 1% default
43
+ swapType = "EXACT_INPUT",
44
+ deadline,
45
+ dry = false,
46
+ referral = config.referral || "uniport"
47
+ } = options;
48
+ const amountInSmallestUnits = toSmallestUnits(amount, originToken.decimals);
49
+ const quoteRequest = {
50
+ dry,
51
+ swapType: QuoteRequest.swapType[swapType],
52
+ slippageTolerance,
53
+ originAsset: originToken.assetId,
54
+ depositType: QuoteRequest.depositType.ORIGIN_CHAIN,
55
+ destinationAsset: destinationToken.assetId,
56
+ amount: amountInSmallestUnits,
57
+ refundTo,
58
+ refundType: QuoteRequest.refundType.ORIGIN_CHAIN,
59
+ recipient,
60
+ recipientType: QuoteRequest.recipientType.DESTINATION_CHAIN,
61
+ deadline: deadline?.toISOString() || generateDeadline(1),
62
+ referral
63
+ };
64
+ try {
65
+ const response = await OneClickService.getQuote(quoteRequest);
66
+ const quote = response.quote;
67
+ return {
68
+ depositAddress: quote.depositAddress || "",
69
+ memo: quote.depositMemo,
70
+ amountIn: quote.amountIn,
71
+ amountOut: quote.amountOut,
72
+ amountOutFormatted: quote.amountOutFormatted,
73
+ amountOutUsd: quote.amountOutUsd,
74
+ deadline: quote.deadline,
75
+ timeWhenInactive: quote.timeWhenInactive,
76
+ correlationId: response.correlationId
77
+ };
78
+ } catch (error) {
79
+ if (error instanceof ApiError) {
80
+ throw new Error(
81
+ `Quote failed (${error.status}): ${JSON.stringify(error.body)}`
82
+ );
83
+ }
84
+ throw error;
85
+ }
86
+ }
87
+ async function getExecutionStatus(depositAddress, memo) {
88
+ ensureInitialized();
89
+ try {
90
+ const response = await OneClickService.getExecutionStatus(
91
+ depositAddress,
92
+ memo
93
+ );
94
+ const status = response.status;
95
+ const isComplete = ["SUCCESS", "REFUNDED", "FAILED"].includes(status);
96
+ const isSuccess = status === "SUCCESS";
97
+ const swapDetails = response.swapDetails;
98
+ const destinationTxHashes = swapDetails?.destinationChainTxHashes?.map((tx) => tx.hash);
99
+ const originTxHashes = swapDetails?.originChainTxHashes?.map(
100
+ (tx) => tx.hash
101
+ );
102
+ return {
103
+ status,
104
+ isComplete,
105
+ isSuccess,
106
+ correlationId: response.correlationId,
107
+ destinationTxHashes,
108
+ originTxHashes
109
+ };
110
+ } catch (error) {
111
+ if (error instanceof ApiError) {
112
+ throw new Error(
113
+ `Status check failed (${error.status}): ${JSON.stringify(error.body)}`
114
+ );
115
+ }
116
+ throw error;
117
+ }
118
+ }
119
+
120
+ // src/core/tokens.ts
121
+ var TOKEN_ICONS = {
122
+ // Stablecoins
123
+ USDC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
124
+ USDT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",
125
+ DAI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EesdfdsfdC495271d0F/logo.png",
126
+ // Major tokens
127
+ ETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
128
+ WETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png",
129
+ BTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoin/info/logo.png",
130
+ WBTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/logo.png",
131
+ // L1s & L2s
132
+ SUI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png",
133
+ SOL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png",
134
+ NEAR: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/near/info/logo.png",
135
+ ARB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png",
136
+ OP: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/info/logo.png",
137
+ POL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png",
138
+ AVAX: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png",
139
+ BNB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
140
+ BASE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png",
141
+ // Other L1s
142
+ ADA: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cardano/info/logo.png",
143
+ XRP: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png",
144
+ DOGE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/doge/info/logo.png",
145
+ LTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png",
146
+ BCH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png",
147
+ TON: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ton/info/logo.png",
148
+ TRX: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png",
149
+ XLM: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stellar/info/logo.png",
150
+ APT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/aptos/info/logo.png",
151
+ // DeFi & Others
152
+ AAVE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x7Fc66500c84A76Ad7e9c93437BFc5Ac33E2DDaE9/logo.png",
153
+ UNI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984/logo.png",
154
+ LINK: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x514910771AF9Ca656af840dff83E8264EcF986CA/logo.png",
155
+ SHIB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE/logo.png",
156
+ PEPE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6982508145454Ce325dDbE47a25d4ec3d2311933/logo.png",
157
+ // Ecosystem tokens
158
+ STRK: "https://assets.coingecko.com/coins/images/26433/standard/starknet.png",
159
+ BERA: "https://assets.coingecko.com/coins/images/34286/standard/bera.png",
160
+ GNO: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6810e776880C02933D47DB1b9fc05908e5386b96/logo.png",
161
+ MON: "https://assets.coingecko.com/coins/images/35887/standard/monad.png",
162
+ ZEC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png",
163
+ // Meme coins
164
+ TRUMP: "https://assets.coingecko.com/coins/images/53746/standard/trump.jpg",
165
+ WIF: "https://assets.coingecko.com/coins/images/33566/standard/dogwifhat.jpg",
166
+ BRETT: "https://assets.coingecko.com/coins/images/35529/standard/brett.png",
167
+ TURBO: "https://assets.coingecko.com/coins/images/30116/standard/turbo.png",
168
+ // Default fallback
169
+ DEFAULT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png"
170
+ };
171
+ var CHAIN_ICONS = {
172
+ sui: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png",
173
+ eth: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
174
+ arb: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png",
175
+ base: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png",
176
+ op: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/info/logo.png",
177
+ sol: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png",
178
+ btc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoin/info/logo.png",
179
+ near: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/near/info/logo.png",
180
+ pol: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png",
181
+ avax: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png",
182
+ bsc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
183
+ ton: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ton/info/logo.png",
184
+ tron: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png",
185
+ stellar: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stellar/info/logo.png",
186
+ cardano: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cardano/info/logo.png",
187
+ aptos: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/aptos/info/logo.png",
188
+ gnosis: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/xdai/info/logo.png",
189
+ starknet: "https://assets.coingecko.com/coins/images/26433/standard/starknet.png",
190
+ bera: "https://assets.coingecko.com/coins/images/34286/standard/bera.png",
191
+ monad: "https://assets.coingecko.com/coins/images/35887/standard/monad.png",
192
+ doge: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/doge/info/logo.png",
193
+ ltc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png",
194
+ bch: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png",
195
+ xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png",
196
+ zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png"
197
+ };
198
+ function createToken(chain, symbol, assetId, decimals, contractAddress) {
199
+ const name = `${chain}${symbol.replace("$", "").replace(" ", "")}`;
200
+ const icon = TOKEN_ICONS[symbol] || TOKEN_ICONS.DEFAULT;
201
+ const chainIcon = CHAIN_ICONS[chain];
202
+ return {
203
+ name,
204
+ symbol,
205
+ assetId,
206
+ chain,
207
+ decimals,
208
+ icon,
209
+ chainIcon,
210
+ contractAddress
211
+ };
212
+ }
213
+ var suiSUI = createToken("sui", "SUI", "nep141:sui.omft.near", 9);
214
+ var suiUSDC = createToken("sui", "USDC", "nep141:sui-c1b81ecaf27933252d31a963bc5e9458f13c18ce.omft.near", 6, "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC");
215
+ var ethereumETH = createToken("eth", "ETH", "nep141:eth.omft.near", 18);
216
+ var ethereumUSDC = createToken("eth", "USDC", "nep141:eth-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.omft.near", 6, "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48");
217
+ var ethereumUSDT = createToken("eth", "USDT", "nep141:eth-0xdac17f958d2ee523a2206206994597c13d831ec7.omft.near", 6, "0xdac17f958d2ee523a2206206994597c13d831ec7");
218
+ var ethereumWBTC = createToken("eth", "WBTC", "nep141:eth-0x2260fac5e5542a773aa44fbcfedf7c193bc2c599.omft.near", 8, "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599");
219
+ var ethereumDAI = createToken("eth", "DAI", "nep141:eth-0x6b175474e89094c44da98b954eedeac495271d0f.omft.near", 18, "0x6b175474e89094c44da98b954eedeac495271d0f");
220
+ var ethereumAAVE = createToken("eth", "AAVE", "nep141:eth-0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.omft.near", 18, "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9");
221
+ var ethereumUNI = createToken("eth", "UNI", "nep141:eth-0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.omft.near", 18, "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984");
222
+ var ethereumLINK = createToken("eth", "LINK", "nep141:eth-0x514910771af9ca656af840dff83e8264ecf986ca.omft.near", 18, "0x514910771af9ca656af840dff83e8264ecf986ca");
223
+ var ethereumSHIB = createToken("eth", "SHIB", "nep141:eth-0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce.omft.near", 18, "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce");
224
+ var ethereumPEPE = createToken("eth", "PEPE", "nep141:eth-0x6982508145454ce325ddbe47a25d4ec3d2311933.omft.near", 18, "0x6982508145454ce325ddbe47a25d4ec3d2311933");
225
+ var ethereumTURBO = createToken("eth", "TURBO", "nep141:eth-0xa35923162c49cf95e6bf26623385eb431ad920d3.omft.near", 18, "0xa35923162c49cf95e6bf26623385eb431ad920d3");
226
+ var ethereumSAFE = createToken("eth", "SAFE", "nep141:eth-0x5afe3855358e112b5647b952709e6165e1c1eeee.omft.near", 18, "0x5afe3855358e112b5647b952709e6165e1c1eeee");
227
+ var arbitrumETH = createToken("arb", "ETH", "nep141:arb.omft.near", 18);
228
+ var arbitrumUSDC = createToken("arb", "USDC", "nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near", 6, "0xaf88d065e77c8cc2239327c5edb3a432268e5831");
229
+ var arbitrumUSDT = createToken("arb", "USDT", "nep141:arb-0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9.omft.near", 6, "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9");
230
+ var arbitrumARB = createToken("arb", "ARB", "nep141:arb-0x912ce59144191c1204e64559fe8253a0e49e6548.omft.near", 18, "0x912ce59144191c1204e64559fe8253a0e49e6548");
231
+ var arbitrumGMX = createToken("arb", "GMX", "nep141:arb-0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a.omft.near", 18, "0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a");
232
+ var baseETH = createToken("base", "ETH", "nep141:base.omft.near", 18);
233
+ var baseUSDC = createToken("base", "USDC", "nep141:base-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913.omft.near", 6, "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913");
234
+ var baseCbBTC = createToken("base", "cbBTC", "nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near", 8, "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf");
235
+ var baseBRETT = createToken("base", "BRETT", "nep141:base-0x532f27101965dd16442e59d40670faf5ebb142e4.omft.near", 18, "0x532f27101965dd16442e59d40670faf5ebb142e4");
236
+ var optimismETH = createToken("op", "ETH", "nep245:v2_1.omni.hot.tg:10_11111111111111111111", 18);
237
+ var optimismUSDC = createToken("op", "USDC", "nep245:v2_1.omni.hot.tg:10_A2ewyUyDp6qsue1jqZsGypkCxRJ", 6, "0x0b2c639c533813f4aa9d7837caf62653d097ff85");
238
+ var optimismUSDT = createToken("op", "USDT", "nep245:v2_1.omni.hot.tg:10_359RPSJVdTxwTJT9TyGssr2rFoWo", 6, "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58");
239
+ var optimismOP = createToken("op", "OP", "nep245:v2_1.omni.hot.tg:10_vLAiSt9KfUGKpw5cD3vsSyNYBo7", 18, "0x4200000000000000000000000000000000000042");
240
+ var solanaSOL = createToken("sol", "SOL", "nep141:sol.omft.near", 9);
241
+ var solanaUSDC = createToken("sol", "USDC", "nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near", 6, "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
242
+ var solanaUSDT = createToken("sol", "USDT", "nep141:sol-c800a4bd850783ccb82c2b2c7e84175443606352.omft.near", 6, "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
243
+ var solanaTRUMP = createToken("sol", "TRUMP", "nep141:sol-c58e6539c2f2e097c251f8edf11f9c03e581f8d4.omft.near", 6, "6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN");
244
+ var solanaWIF = createToken("sol", "$WIF", "nep141:sol-b9c68f94ec8fd160137af8cdfe5e61cd68e2afba.omft.near", 6, "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm");
245
+ var solanaMELANIA = createToken("sol", "MELANIA", "nep141:sol-d600e625449a4d9380eaf5e3265e54c90d34e260.omft.near", 6, "FUAfBo2jgks6gB4Z4LfZkqSZgzNucisEHqnNebaRxM1P");
246
+ var bitcoinBTC = createToken("btc", "BTC", "nep141:btc.omft.near", 8);
247
+ var polygonPOL = createToken("pol", "POL", "nep245:v2_1.omni.hot.tg:137_11111111111111111111", 18);
248
+ var polygonUSDC = createToken("pol", "USDC", "nep245:v2_1.omni.hot.tg:137_qiStmoQJDQPTebaPjgx5VBxZv6L", 6, "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359");
249
+ var polygonUSDT = createToken("pol", "USDT", "nep245:v2_1.omni.hot.tg:137_3hpYoaLtt8MP1Z2GH1U473DMRKgr", 6, "0xc2132d05d31c914a87c6611c10748aeb04b58e8f");
250
+ var avalancheAVAX = createToken("avax", "AVAX", "nep245:v2_1.omni.hot.tg:43114_11111111111111111111", 18);
251
+ var avalancheUSDC = createToken("avax", "USDC", "nep245:v2_1.omni.hot.tg:43114_3atVJH3r5c4GqiSYmg9fECvjc47o", 6, "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e");
252
+ var avalancheUSDT = createToken("avax", "USDT", "nep245:v2_1.omni.hot.tg:43114_372BeH7ENZieCaabwkbWkBiTTgXp", 6, "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7");
253
+ var bscBNB = createToken("bsc", "BNB", "nep245:v2_1.omni.hot.tg:56_11111111111111111111", 18);
254
+ var bscUSDC = createToken("bsc", "USDC", "nep245:v2_1.omni.hot.tg:56_2w93GqMcEmQFDru84j3HZZWt557r", 18, "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d");
255
+ var bscUSDT = createToken("bsc", "USDT", "nep245:v2_1.omni.hot.tg:56_2CMMyVTGZkeyNZTSvS5sarzfir6g", 18, "0x55d398326f99059ff775485246999027b3197955");
256
+ var tonTON = createToken("ton", "TON", "nep245:v2_1.omni.hot.tg:1117_", 9);
257
+ var tonUSDT = createToken("ton", "USDT", "nep245:v2_1.omni.hot.tg:1117_3tsdfyziyc7EJbP2aULWSKU4toBaAcN4FdTgfm5W1mC4ouR", 6, "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs");
258
+ var tronTRX = createToken("tron", "TRX", "nep141:tron.omft.near", 6);
259
+ var tronUSDT = createToken("tron", "USDT", "nep141:tron-d28a265909efecdcee7c5028585214ea0b96f015.omft.near", 6, "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t");
260
+ var cardanoADA = createToken("cardano", "ADA", "nep141:cardano.omft.near", 6);
261
+ var rippleXRP = createToken("xrp", "XRP", "nep141:xrp.omft.near", 6);
262
+ var dogecoinDOGE = createToken("doge", "DOGE", "nep141:doge.omft.near", 8);
263
+ var litecoinLTC = createToken("ltc", "LTC", "nep141:ltc.omft.near", 8);
264
+ var bitcoinCashBCH = createToken("bch", "BCH", "nep141:bch.omft.near", 8);
265
+ var aptosAPT = createToken("aptos", "APT", "nep141:aptos.omft.near", 8);
266
+ var starknetSTRK = createToken("starknet", "STRK", "nep141:starknet.omft.near", 18);
267
+ var berachainBERA = createToken("bera", "BERA", "nep141:bera.omft.near", 18);
268
+ var zcashZEC = createToken("zec", "ZEC", "nep141:zec.omft.near", 8);
269
+ var nearNEAR = createToken("near", "wNEAR", "nep141:wrap.near", 24, "wrap.near");
270
+ var nearUSDC = createToken("near", "USDC", "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1", 6, "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1");
271
+ var nearUSDT = createToken("near", "USDT", "nep141:usdt.tether-token.near", 6, "usdt.tether-token.near");
272
+ var CHAINS = {
273
+ sui: {
274
+ id: "sui",
275
+ name: "Sui",
276
+ icon: CHAIN_ICONS.sui,
277
+ tokens: [suiSUI, suiUSDC]
278
+ },
279
+ eth: {
280
+ id: "eth",
281
+ name: "Ethereum",
282
+ icon: CHAIN_ICONS.eth,
283
+ tokens: [ethereumETH, ethereumUSDC, ethereumUSDT, ethereumWBTC, ethereumDAI, ethereumAAVE, ethereumUNI, ethereumLINK, ethereumSHIB, ethereumPEPE, ethereumTURBO, ethereumSAFE]
284
+ },
285
+ arb: {
286
+ id: "arb",
287
+ name: "Arbitrum",
288
+ icon: CHAIN_ICONS.arb,
289
+ tokens: [arbitrumETH, arbitrumUSDC, arbitrumUSDT, arbitrumARB, arbitrumGMX]
290
+ },
291
+ base: {
292
+ id: "base",
293
+ name: "Base",
294
+ icon: CHAIN_ICONS.base,
295
+ tokens: [baseETH, baseUSDC, baseCbBTC, baseBRETT]
296
+ },
297
+ op: {
298
+ id: "op",
299
+ name: "Optimism",
300
+ icon: CHAIN_ICONS.op,
301
+ tokens: [optimismETH, optimismUSDC, optimismUSDT, optimismOP]
302
+ },
303
+ sol: {
304
+ id: "sol",
305
+ name: "Solana",
306
+ icon: CHAIN_ICONS.sol,
307
+ tokens: [solanaSOL, solanaUSDC, solanaUSDT, solanaTRUMP, solanaWIF, solanaMELANIA]
308
+ },
309
+ btc: {
310
+ id: "btc",
311
+ name: "Bitcoin",
312
+ icon: CHAIN_ICONS.btc,
313
+ tokens: [bitcoinBTC]
314
+ },
315
+ pol: {
316
+ id: "pol",
317
+ name: "Polygon",
318
+ icon: CHAIN_ICONS.pol,
319
+ tokens: [polygonPOL, polygonUSDC, polygonUSDT]
320
+ },
321
+ avax: {
322
+ id: "avax",
323
+ name: "Avalanche",
324
+ icon: CHAIN_ICONS.avax,
325
+ tokens: [avalancheAVAX, avalancheUSDC, avalancheUSDT]
326
+ },
327
+ bsc: {
328
+ id: "bsc",
329
+ name: "BNB Chain",
330
+ icon: CHAIN_ICONS.bsc,
331
+ tokens: [bscBNB, bscUSDC, bscUSDT]
332
+ },
333
+ ton: {
334
+ id: "ton",
335
+ name: "TON",
336
+ icon: CHAIN_ICONS.ton,
337
+ tokens: [tonTON, tonUSDT]
338
+ },
339
+ tron: {
340
+ id: "tron",
341
+ name: "Tron",
342
+ icon: CHAIN_ICONS.tron,
343
+ tokens: [tronTRX, tronUSDT]
344
+ },
345
+ near: {
346
+ id: "near",
347
+ name: "NEAR",
348
+ icon: CHAIN_ICONS.near,
349
+ tokens: [nearNEAR, nearUSDC, nearUSDT]
350
+ },
351
+ cardano: {
352
+ id: "cardano",
353
+ name: "Cardano",
354
+ icon: CHAIN_ICONS.cardano,
355
+ tokens: [cardanoADA]
356
+ },
357
+ xrp: {
358
+ id: "xrp",
359
+ name: "XRP Ledger",
360
+ icon: CHAIN_ICONS.xrp,
361
+ tokens: [rippleXRP]
362
+ },
363
+ doge: {
364
+ id: "doge",
365
+ name: "Dogecoin",
366
+ icon: CHAIN_ICONS.doge,
367
+ tokens: [dogecoinDOGE]
368
+ },
369
+ ltc: {
370
+ id: "ltc",
371
+ name: "Litecoin",
372
+ icon: CHAIN_ICONS.ltc,
373
+ tokens: [litecoinLTC]
374
+ },
375
+ bch: {
376
+ id: "bch",
377
+ name: "Bitcoin Cash",
378
+ icon: CHAIN_ICONS.bch,
379
+ tokens: [bitcoinCashBCH]
380
+ },
381
+ aptos: {
382
+ id: "aptos",
383
+ name: "Aptos",
384
+ icon: CHAIN_ICONS.aptos,
385
+ tokens: [aptosAPT]
386
+ },
387
+ starknet: {
388
+ id: "starknet",
389
+ name: "Starknet",
390
+ icon: CHAIN_ICONS.starknet,
391
+ tokens: [starknetSTRK]
392
+ },
393
+ bera: {
394
+ id: "bera",
395
+ name: "Berachain",
396
+ icon: CHAIN_ICONS.bera,
397
+ tokens: [berachainBERA]
398
+ },
399
+ zec: {
400
+ id: "zec",
401
+ name: "Zcash",
402
+ icon: CHAIN_ICONS.zec,
403
+ tokens: [zcashZEC]
404
+ },
405
+ gnosis: {
406
+ id: "gnosis",
407
+ name: "Gnosis",
408
+ icon: CHAIN_ICONS.gnosis,
409
+ tokens: []
410
+ },
411
+ monad: {
412
+ id: "monad",
413
+ name: "Monad",
414
+ icon: CHAIN_ICONS.monad,
415
+ tokens: []
416
+ },
417
+ stellar: {
418
+ id: "stellar",
419
+ name: "Stellar",
420
+ icon: CHAIN_ICONS.stellar,
421
+ tokens: []
422
+ }
423
+ };
424
+ Object.values(CHAINS).flatMap((chain) => chain.tokens);
425
+ function getSupportedChains() {
426
+ return Object.values(CHAINS).filter((c) => c.tokens.length > 0);
427
+ }
428
+ function getSuiDestinationTokens() {
429
+ return CHAINS.sui.tokens;
430
+ }
431
+
432
+ // src/hooks/useUniportPayment.ts
433
+ function useUniportPayment(options) {
434
+ const { recipient, refundAddress, destinationToken, onSuccess, onError } = options;
435
+ const destToken = destinationToken === "suiSUI" ? suiSUI : suiUSDC;
436
+ const [paymentState, setPaymentState] = useState("idle");
437
+ const [quote, setQuote] = useState(null);
438
+ const [previewQuote, setPreviewQuote] = useState(null);
439
+ const [isLoadingPreview, setIsLoadingPreview] = useState(false);
440
+ const [status, setStatus] = useState(null);
441
+ const [error, setError] = useState(null);
442
+ const [selectedChain, setSelectedChain] = useState(null);
443
+ const [selectedToken, setSelectedToken] = useState(null);
444
+ const [amount, setAmountState] = useState("");
445
+ const pollingRef = useRef(null);
446
+ const lastStatusRef = useRef(null);
447
+ const previewDebounceRef = useRef(null);
448
+ const chains = getSupportedChains().filter((c) => c.id !== "sui");
449
+ const tokens = selectedChain?.tokens || [];
450
+ const destinationTokens = getSuiDestinationTokens();
451
+ const setAmount = useCallback(
452
+ (newAmount) => {
453
+ setAmountState(newAmount);
454
+ setPreviewQuote(null);
455
+ if (previewDebounceRef.current) {
456
+ clearTimeout(previewDebounceRef.current);
457
+ }
458
+ if (newAmount && selectedToken && refundAddress) {
459
+ setIsLoadingPreview(true);
460
+ previewDebounceRef.current = setTimeout(async () => {
461
+ try {
462
+ const result = await getQuote({
463
+ originToken: selectedToken,
464
+ destinationToken: destToken,
465
+ amount: newAmount,
466
+ recipient,
467
+ refundTo: refundAddress,
468
+ dry: true
469
+ // Dry run for preview
470
+ });
471
+ setPreviewQuote(result);
472
+ } catch (err) {
473
+ console.warn("Preview quote failed:", err);
474
+ } finally {
475
+ setIsLoadingPreview(false);
476
+ }
477
+ }, 3e3);
478
+ } else {
479
+ setIsLoadingPreview(false);
480
+ }
481
+ },
482
+ [selectedToken, refundAddress, recipient, destToken]
483
+ );
484
+ const handleChainSelect = useCallback((chain) => {
485
+ setSelectedChain(chain);
486
+ setSelectedToken(chain.tokens[0] || null);
487
+ setPaymentState("selecting");
488
+ setPreviewQuote(null);
489
+ }, []);
490
+ const handleTokenSelect = useCallback((token) => {
491
+ setSelectedToken(token);
492
+ setPaymentState("selecting");
493
+ setPreviewQuote(null);
494
+ }, []);
495
+ const fetchQuote = useCallback(async () => {
496
+ if (!selectedToken || !amount || !refundAddress) {
497
+ setError(new Error("Missing required fields"));
498
+ return;
499
+ }
500
+ setPaymentState("quoting");
501
+ setError(null);
502
+ try {
503
+ const result = await getQuote({
504
+ originToken: selectedToken,
505
+ destinationToken: destToken,
506
+ amount,
507
+ recipient,
508
+ refundTo: refundAddress,
509
+ dry: false
510
+ });
511
+ setQuote(result);
512
+ setPaymentState("awaiting_deposit");
513
+ } catch (err) {
514
+ const error2 = err instanceof Error ? err : new Error("Failed to get quote");
515
+ setError(error2);
516
+ setPaymentState("error");
517
+ onError?.(error2);
518
+ }
519
+ }, [
520
+ selectedToken,
521
+ amount,
522
+ refundAddress,
523
+ recipient,
524
+ destToken,
525
+ onError
526
+ ]);
527
+ const pollStatus = useCallback(async () => {
528
+ if (!quote?.depositAddress) return;
529
+ try {
530
+ const result = await getExecutionStatus(
531
+ quote.depositAddress,
532
+ quote.memo
533
+ );
534
+ setStatus(result);
535
+ if (result.status !== lastStatusRef.current) {
536
+ lastStatusRef.current = result.status;
537
+ if (result.status === "PROCESSING") {
538
+ setPaymentState("processing");
539
+ } else if (result.isSuccess) {
540
+ setPaymentState("success");
541
+ stopPolling();
542
+ onSuccess?.({
543
+ txHash: result.destinationTxHashes?.[0] || "",
544
+ amount: quote.amountOut
545
+ });
546
+ } else if (result.status === "FAILED") {
547
+ setPaymentState("error");
548
+ stopPolling();
549
+ const err = new Error("Payment failed");
550
+ setError(err);
551
+ onError?.(err);
552
+ }
553
+ }
554
+ } catch (err) {
555
+ console.error("Status poll error:", err);
556
+ }
557
+ }, [quote, onSuccess, onError]);
558
+ const startPolling = useCallback(() => {
559
+ if (pollingRef.current) return;
560
+ pollStatus();
561
+ pollingRef.current = setInterval(pollStatus, 3e3);
562
+ }, [pollStatus]);
563
+ const stopPolling = useCallback(() => {
564
+ if (pollingRef.current) {
565
+ clearInterval(pollingRef.current);
566
+ pollingRef.current = null;
567
+ }
568
+ }, []);
569
+ const copyToClipboard = useCallback(async (text) => {
570
+ try {
571
+ await navigator.clipboard.writeText(text);
572
+ return true;
573
+ } catch {
574
+ return false;
575
+ }
576
+ }, []);
577
+ const reset = useCallback(() => {
578
+ stopPolling();
579
+ if (previewDebounceRef.current) {
580
+ clearTimeout(previewDebounceRef.current);
581
+ }
582
+ setPaymentState("idle");
583
+ setQuote(null);
584
+ setPreviewQuote(null);
585
+ setIsLoadingPreview(false);
586
+ setStatus(null);
587
+ setError(null);
588
+ setSelectedChain(null);
589
+ setSelectedToken(null);
590
+ setAmountState("");
591
+ lastStatusRef.current = null;
592
+ }, [stopPolling]);
593
+ useEffect(() => {
594
+ return () => {
595
+ stopPolling();
596
+ if (previewDebounceRef.current) {
597
+ clearTimeout(previewDebounceRef.current);
598
+ }
599
+ };
600
+ }, [stopPolling]);
601
+ return {
602
+ paymentState,
603
+ quote,
604
+ previewQuote,
605
+ isLoadingPreview,
606
+ status,
607
+ error,
608
+ selectedChain,
609
+ selectedToken,
610
+ amount,
611
+ destinationToken: destToken,
612
+ chains,
613
+ tokens,
614
+ destinationTokens,
615
+ setSelectedChain: handleChainSelect,
616
+ setSelectedToken: handleTokenSelect,
617
+ setAmount,
618
+ fetchQuote,
619
+ startPolling,
620
+ stopPolling,
621
+ reset,
622
+ copyToClipboard
623
+ };
624
+ }
625
+ var styles = {
626
+ overlay: {
627
+ position: "fixed",
628
+ inset: 0,
629
+ backgroundColor: "rgba(0, 0, 0, 0.8)",
630
+ backdropFilter: "blur(8px)",
631
+ display: "flex",
632
+ alignItems: "center",
633
+ justifyContent: "center",
634
+ zIndex: 9999,
635
+ padding: "16px",
636
+ animation: "uniport-fade-in 0.2s ease"
637
+ },
638
+ modal: {
639
+ position: "relative",
640
+ width: "100%",
641
+ maxWidth: "380px",
642
+ background: "rgba(22, 22, 30, 0.95)",
643
+ backdropFilter: "blur(24px)",
644
+ border: "1px solid rgba(255, 255, 255, 0.08)",
645
+ borderRadius: "24px",
646
+ padding: "24px",
647
+ boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05)",
648
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
649
+ animation: "uniport-slide-up 0.3s ease"
650
+ },
651
+ header: {
652
+ display: "flex",
653
+ flexDirection: "column",
654
+ alignItems: "center",
655
+ marginBottom: "24px"
656
+ },
657
+ headerIcon: {
658
+ width: "48px",
659
+ height: "48px",
660
+ borderRadius: "16px",
661
+ background: "linear-gradient(135deg, rgba(255,255,255,0.1), transparent)",
662
+ border: "1px solid rgba(255,255,255,0.05)",
663
+ display: "flex",
664
+ alignItems: "center",
665
+ justifyContent: "center",
666
+ marginBottom: "16px"
667
+ },
668
+ title: {
669
+ fontSize: "18px",
670
+ fontWeight: 500,
671
+ color: "white",
672
+ margin: 0,
673
+ textShadow: "0 0 15px rgba(255,255,255,0.3)"
674
+ },
675
+ subtitle: {
676
+ fontSize: "12px",
677
+ color: "rgba(255,255,255,0.4)",
678
+ marginTop: "4px",
679
+ fontWeight: 300,
680
+ letterSpacing: "0.5px"
681
+ },
682
+ closeButton: {
683
+ position: "absolute",
684
+ top: "16px",
685
+ right: "16px",
686
+ width: "32px",
687
+ height: "32px",
688
+ borderRadius: "8px",
689
+ background: "rgba(255,255,255,0.05)",
690
+ border: "1px solid rgba(255,255,255,0.1)",
691
+ color: "rgba(255,255,255,0.6)",
692
+ cursor: "pointer",
693
+ display: "flex",
694
+ alignItems: "center",
695
+ justifyContent: "center",
696
+ transition: "all 0.2s"
697
+ },
698
+ selectorsRow: {
699
+ display: "grid",
700
+ gridTemplateColumns: "1fr 1fr",
701
+ gap: "12px",
702
+ marginBottom: "24px"
703
+ },
704
+ selector: {
705
+ display: "flex",
706
+ alignItems: "center",
707
+ justifyContent: "space-between",
708
+ padding: "12px",
709
+ background: "rgba(255,255,255,0.05)",
710
+ border: "1px solid rgba(255,255,255,0.05)",
711
+ borderRadius: "16px",
712
+ cursor: "pointer",
713
+ transition: "all 0.2s"
714
+ },
715
+ selectorIcon: {
716
+ width: "32px",
717
+ height: "32px",
718
+ borderRadius: "50%",
719
+ background: "#1c1c26",
720
+ border: "1px solid rgba(255,255,255,0.1)",
721
+ display: "flex",
722
+ alignItems: "center",
723
+ justifyContent: "center",
724
+ overflow: "hidden"
725
+ },
726
+ selectorLabel: {
727
+ fontSize: "10px",
728
+ textTransform: "uppercase",
729
+ letterSpacing: "1.5px",
730
+ color: "rgba(255,255,255,0.3)",
731
+ fontWeight: 500
732
+ },
733
+ selectorValue: {
734
+ fontSize: "14px",
735
+ color: "rgba(255,255,255,0.9)",
736
+ fontWeight: 500
737
+ },
738
+ amountInput: {
739
+ width: "100%",
740
+ textAlign: "center",
741
+ fontSize: "48px",
742
+ fontWeight: 500,
743
+ color: "white",
744
+ background: "transparent",
745
+ border: "none",
746
+ outline: "none",
747
+ marginBottom: "24px",
748
+ caretColor: "#4F46E5"
749
+ },
750
+ details: {
751
+ marginBottom: "20px",
752
+ padding: "0 4px"
753
+ },
754
+ detailRow: {
755
+ display: "flex",
756
+ justifyContent: "space-between",
757
+ alignItems: "center",
758
+ fontSize: "12px",
759
+ color: "rgba(255,255,255,0.4)",
760
+ marginBottom: "8px"
761
+ },
762
+ detailValue: {
763
+ fontWeight: 500,
764
+ color: "rgba(255,255,255,0.7)",
765
+ display: "flex",
766
+ alignItems: "center",
767
+ gap: "6px"
768
+ },
769
+ button: {
770
+ width: "100%",
771
+ position: "relative",
772
+ overflow: "hidden",
773
+ borderRadius: "16px",
774
+ padding: "2px",
775
+ background: "linear-gradient(90deg, #4F46E5, #7C3AED, #4F46E5)",
776
+ backgroundSize: "200% 200%",
777
+ animation: "uniport-gradient 3s ease infinite",
778
+ border: "none",
779
+ cursor: "pointer"
780
+ },
781
+ buttonInner: {
782
+ display: "flex",
783
+ alignItems: "center",
784
+ justifyContent: "center",
785
+ gap: "8px",
786
+ height: "48px",
787
+ borderRadius: "14px",
788
+ background: "#0A0A0F",
789
+ color: "white",
790
+ fontSize: "14px",
791
+ fontWeight: 500,
792
+ transition: "background 0.3s"
793
+ },
794
+ buttonDisabled: {
795
+ opacity: 0.5,
796
+ cursor: "not-allowed"
797
+ },
798
+ // QR container - dark background, no white box
799
+ qrContainer: {
800
+ display: "flex",
801
+ flexDirection: "column",
802
+ alignItems: "center",
803
+ padding: "24px",
804
+ background: "transparent",
805
+ marginBottom: "16px"
806
+ },
807
+ // Address with copy button
808
+ addressContainer: {
809
+ display: "flex",
810
+ alignItems: "center",
811
+ justifyContent: "center",
812
+ gap: "8px",
813
+ marginTop: "16px"
814
+ },
815
+ addressText: {
816
+ fontSize: "12px",
817
+ color: "rgba(255,255,255,0.6)",
818
+ wordBreak: "break-all",
819
+ textAlign: "center",
820
+ fontFamily: "monospace"
821
+ },
822
+ copyButton: {
823
+ display: "flex",
824
+ alignItems: "center",
825
+ justifyContent: "center",
826
+ width: "32px",
827
+ height: "32px",
828
+ borderRadius: "8px",
829
+ background: "rgba(255,255,255,0.1)",
830
+ border: "1px solid rgba(255,255,255,0.15)",
831
+ cursor: "pointer",
832
+ transition: "all 0.2s",
833
+ flexShrink: 0
834
+ },
835
+ statusBadge: {
836
+ display: "inline-flex",
837
+ alignItems: "center",
838
+ gap: "6px",
839
+ padding: "6px 12px",
840
+ borderRadius: "20px",
841
+ fontSize: "12px",
842
+ fontWeight: 500
843
+ },
844
+ processingBadge: {
845
+ background: "rgba(79, 70, 229, 0.2)",
846
+ color: "#818CF8"
847
+ },
848
+ dropdown: {
849
+ position: "absolute",
850
+ top: "calc(100% + 8px)",
851
+ left: 0,
852
+ right: 0,
853
+ background: "rgba(22, 22, 30, 0.98)",
854
+ border: "1px solid rgba(255,255,255,0.1)",
855
+ borderRadius: "16px",
856
+ maxHeight: "200px",
857
+ overflowY: "auto",
858
+ zIndex: 10,
859
+ boxShadow: "0 20px 40px rgba(0,0,0,0.5)"
860
+ },
861
+ dropdownItem: {
862
+ display: "flex",
863
+ alignItems: "center",
864
+ gap: "12px",
865
+ padding: "12px 16px",
866
+ cursor: "pointer",
867
+ transition: "background 0.2s"
868
+ },
869
+ loadingDot: {
870
+ width: "8px",
871
+ height: "8px",
872
+ borderRadius: "50%",
873
+ background: "#818CF8",
874
+ animation: "uniport-pulse 1s ease infinite"
875
+ },
876
+ tokenBadge: {
877
+ display: "inline-flex",
878
+ alignItems: "center",
879
+ gap: "4px",
880
+ padding: "2px 8px",
881
+ borderRadius: "12px",
882
+ background: "rgba(255,255,255,0.08)",
883
+ fontSize: "11px"
884
+ }
885
+ };
886
+ var injectStyles = () => {
887
+ if (typeof document === "undefined") return;
888
+ if (document.getElementById("uniport-styles")) return;
889
+ const style = document.createElement("style");
890
+ style.id = "uniport-styles";
891
+ style.textContent = `
892
+ @keyframes uniport-fade-in {
893
+ from { opacity: 0; }
894
+ to { opacity: 1; }
895
+ }
896
+ @keyframes uniport-slide-up {
897
+ from { opacity: 0; transform: translateY(20px) scale(0.95); }
898
+ to { opacity: 1; transform: translateY(0) scale(1); }
899
+ }
900
+ @keyframes uniport-gradient {
901
+ 0% { background-position: 0% 50%; }
902
+ 50% { background-position: 100% 50%; }
903
+ 100% { background-position: 0% 50%; }
904
+ }
905
+ @keyframes uniport-pulse {
906
+ 0%, 100% { opacity: 1; }
907
+ 50% { opacity: 0.3; }
908
+ }
909
+ `;
910
+ document.head.appendChild(style);
911
+ };
912
+ function UniportModal({
913
+ open,
914
+ onClose,
915
+ recipient,
916
+ refundAddress,
917
+ destinationToken = "suiUSDC",
918
+ amount: initialAmount,
919
+ onSuccess,
920
+ onError
921
+ }) {
922
+ const payment = useUniportPayment({
923
+ recipient,
924
+ refundAddress,
925
+ destinationToken,
926
+ onSuccess,
927
+ onError
928
+ });
929
+ const [chainDropdownOpen, setChainDropdownOpen] = React.useState(false);
930
+ const [tokenDropdownOpen, setTokenDropdownOpen] = React.useState(false);
931
+ const [copied, setCopied] = useState(false);
932
+ const [showReceipt, setShowReceipt] = useState(false);
933
+ useEffect(() => {
934
+ injectStyles();
935
+ }, []);
936
+ useEffect(() => {
937
+ if (payment.paymentState === "awaiting_deposit") {
938
+ payment.startPolling();
939
+ }
940
+ }, [payment.paymentState]);
941
+ useEffect(() => {
942
+ return () => payment.stopPolling();
943
+ }, []);
944
+ const handleClose = useCallback(() => {
945
+ payment.reset();
946
+ onClose();
947
+ }, [payment, onClose]);
948
+ useEffect(() => {
949
+ const handleEscape = (e) => {
950
+ if (e.key === "Escape") handleClose();
951
+ };
952
+ if (open) {
953
+ document.addEventListener("keydown", handleEscape);
954
+ return () => document.removeEventListener("keydown", handleEscape);
955
+ }
956
+ }, [open, handleClose]);
957
+ const handleCopy = useCallback(async () => {
958
+ if (payment.quote?.depositAddress) {
959
+ const success = await payment.copyToClipboard(payment.quote.depositAddress);
960
+ if (success) {
961
+ setCopied(true);
962
+ setTimeout(() => setCopied(false), 2e3);
963
+ }
964
+ }
965
+ }, [payment]);
966
+ if (!open) return null;
967
+ const canSubmit = payment.selectedToken && payment.amount && refundAddress;
968
+ const isProcessing = payment.paymentState === "quoting" || payment.paymentState === "processing";
969
+ const showQR = payment.paymentState === "awaiting_deposit" || payment.paymentState === "processing";
970
+ const isSuccess = payment.paymentState === "success";
971
+ return /* @__PURE__ */ jsx("div", { style: styles.overlay, onClick: handleClose, children: /* @__PURE__ */ jsxs("div", { style: styles.modal, onClick: (e) => e.stopPropagation(), children: [
972
+ /* @__PURE__ */ jsx(
973
+ "button",
974
+ {
975
+ style: styles.closeButton,
976
+ onClick: handleClose,
977
+ onMouseEnter: (e) => {
978
+ e.currentTarget.style.background = "rgba(255,255,255,0.1)";
979
+ },
980
+ onMouseLeave: (e) => {
981
+ e.currentTarget.style.background = "rgba(255,255,255,0.05)";
982
+ },
983
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
984
+ }
985
+ ),
986
+ isSuccess ? /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", paddingTop: "20px" }, children: [
987
+ /* @__PURE__ */ jsx("h2", { style: { ...styles.title, marginBottom: "32px", fontSize: "20px" }, children: "Payment Successful" }),
988
+ /* @__PURE__ */ jsx(
989
+ "div",
990
+ {
991
+ style: {
992
+ width: "100px",
993
+ height: "100px",
994
+ borderRadius: "50%",
995
+ background: "rgba(22, 22, 30, 0.9)",
996
+ border: "3px solid #10B981",
997
+ display: "flex",
998
+ alignItems: "center",
999
+ justifyContent: "center",
1000
+ margin: "0 auto 24px",
1001
+ boxShadow: "0 0 30px rgba(16, 185, 129, 0.3)"
1002
+ },
1003
+ children: /* @__PURE__ */ jsx("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", stroke: "#10B981", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" }) })
1004
+ }
1005
+ ),
1006
+ /* @__PURE__ */ jsx("p", { style: { color: "white", fontSize: "18px", fontWeight: 500, marginBottom: "8px" }, children: "Payment Completed" }),
1007
+ /* @__PURE__ */ jsxs("p", { style: { color: "rgba(255,255,255,0.5)", fontSize: "14px", marginBottom: "32px" }, children: [
1008
+ payment.amount,
1009
+ " ",
1010
+ payment.selectedToken?.symbol,
1011
+ " \u2192 ~",
1012
+ payment.quote?.amountOutFormatted || "",
1013
+ " ",
1014
+ payment.destinationToken.symbol,
1015
+ " on Sui"
1016
+ ] }),
1017
+ /* @__PURE__ */ jsx(
1018
+ "button",
1019
+ {
1020
+ onClick: () => setShowReceipt(!showReceipt),
1021
+ style: { background: "transparent", border: "none", color: "rgba(255,255,255,0.6)", fontSize: "14px", cursor: "pointer", textDecoration: "underline", marginBottom: showReceipt ? "16px" : "0" },
1022
+ children: showReceipt ? "Hide receipt" : "Show receipt"
1023
+ }
1024
+ ),
1025
+ showReceipt && /* @__PURE__ */ jsxs("div", { style: { background: "rgba(255,255,255,0.05)", borderRadius: "12px", padding: "16px", textAlign: "left", marginTop: "8px" }, children: [
1026
+ payment.status?.originTxHashes?.map((hash, i) => /* @__PURE__ */ jsxs("div", { style: { marginBottom: "12px" }, children: [
1027
+ /* @__PURE__ */ jsxs("p", { style: { color: "rgba(255,255,255,0.5)", fontSize: "12px", marginBottom: "4px" }, children: [
1028
+ "Source TX (",
1029
+ payment.selectedChain?.name,
1030
+ ")"
1031
+ ] }),
1032
+ /* @__PURE__ */ 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: [
1033
+ hash.slice(0, 10),
1034
+ "...",
1035
+ hash.slice(-8),
1036
+ " \u2197"
1037
+ ] })
1038
+ ] }, `origin-${i}`)),
1039
+ payment.status?.destinationTxHashes?.map((hash, i) => /* @__PURE__ */ jsxs("div", { children: [
1040
+ /* @__PURE__ */ jsx("p", { style: { color: "rgba(255,255,255,0.5)", fontSize: "12px", marginBottom: "4px" }, children: "Destination TX (Sui)" }),
1041
+ /* @__PURE__ */ jsxs("a", { href: `https://suiscan.xyz/mainnet/tx/${hash}`, target: "_blank", rel: "noopener noreferrer", style: { color: "#60A5FA", fontSize: "13px", textDecoration: "none", fontFamily: "monospace" }, children: [
1042
+ hash.slice(0, 10),
1043
+ "...",
1044
+ hash.slice(-8),
1045
+ " \u2197"
1046
+ ] })
1047
+ ] }, `dest-${i}`)),
1048
+ !payment.status?.originTxHashes?.length && !payment.status?.destinationTxHashes?.length && /* @__PURE__ */ jsx("p", { style: { color: "rgba(255,255,255,0.4)", fontSize: "13px" }, children: "Transaction details loading..." })
1049
+ ] }),
1050
+ /* @__PURE__ */ jsx("button", { onClick: handleClose, style: { ...styles.button, marginTop: "24px", background: "linear-gradient(135deg, #10B981, #059669)" }, children: "Done" })
1051
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1052
+ /* @__PURE__ */ jsxs("div", { style: styles.header, children: [
1053
+ /* @__PURE__ */ jsx("div", { style: styles.headerIcon, children: /* @__PURE__ */ jsx(CardIcon, {}) }),
1054
+ /* @__PURE__ */ jsx("h2", { style: styles.title, children: showQR ? "Send Payment" : "Pay with any token" }),
1055
+ /* @__PURE__ */ jsx("p", { style: styles.subtitle, children: showQR ? "Scan QR or copy address below" : "Secure, gasless transactions" })
1056
+ ] }),
1057
+ showQR && payment.quote && /* @__PURE__ */ jsxs(Fragment, { children: [
1058
+ /* @__PURE__ */ jsx("div", { style: styles.qrContainer, children: /* @__PURE__ */ jsx(
1059
+ QRCodeSVG,
1060
+ {
1061
+ value: payment.quote.depositAddress,
1062
+ size: 180,
1063
+ level: "M",
1064
+ bgColor: "transparent",
1065
+ fgColor: "white"
1066
+ }
1067
+ ) }),
1068
+ /* @__PURE__ */ jsxs("div", { style: styles.addressContainer, children: [
1069
+ /* @__PURE__ */ jsxs("span", { style: styles.addressText, children: [
1070
+ payment.quote.depositAddress.slice(0, 8),
1071
+ "...",
1072
+ payment.quote.depositAddress.slice(-8)
1073
+ ] }),
1074
+ /* @__PURE__ */ jsx(
1075
+ "button",
1076
+ {
1077
+ style: styles.copyButton,
1078
+ onClick: handleCopy,
1079
+ onMouseEnter: (e) => {
1080
+ e.currentTarget.style.background = "rgba(255,255,255,0.2)";
1081
+ },
1082
+ onMouseLeave: (e) => {
1083
+ e.currentTarget.style.background = "rgba(255,255,255,0.1)";
1084
+ },
1085
+ children: copied ? /* @__PURE__ */ jsx(CheckSmallIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {})
1086
+ }
1087
+ )
1088
+ ] }),
1089
+ /* @__PURE__ */ jsxs("div", { style: { ...styles.details, marginTop: "20px" }, children: [
1090
+ /* @__PURE__ */ jsxs("div", { style: styles.detailRow, children: [
1091
+ /* @__PURE__ */ jsx("span", { children: "Status" }),
1092
+ /* @__PURE__ */ jsxs(
1093
+ "span",
1094
+ {
1095
+ style: {
1096
+ ...styles.statusBadge,
1097
+ ...styles.processingBadge
1098
+ },
1099
+ children: [
1100
+ /* @__PURE__ */ jsx(PulseIcon, {}),
1101
+ " ",
1102
+ payment.paymentState === "processing" ? "Processing deposit..." : "Waiting for deposit"
1103
+ ]
1104
+ }
1105
+ )
1106
+ ] }),
1107
+ /* @__PURE__ */ jsxs("div", { style: styles.detailRow, children: [
1108
+ /* @__PURE__ */ jsx("span", { children: "Amount to send" }),
1109
+ /* @__PURE__ */ jsxs("span", { style: styles.detailValue, children: [
1110
+ payment.amount,
1111
+ " ",
1112
+ payment.selectedToken?.symbol,
1113
+ /* @__PURE__ */ jsx("span", { style: styles.tokenBadge, children: payment.selectedChain?.name })
1114
+ ] })
1115
+ ] }),
1116
+ /* @__PURE__ */ jsxs("div", { style: styles.detailRow, children: [
1117
+ /* @__PURE__ */ jsx("span", { children: "You receive" }),
1118
+ /* @__PURE__ */ jsxs("span", { style: styles.detailValue, children: [
1119
+ "~",
1120
+ payment.quote.amountOutFormatted,
1121
+ " ",
1122
+ payment.destinationToken.symbol,
1123
+ /* @__PURE__ */ jsx("span", { style: styles.tokenBadge, children: "Sui" })
1124
+ ] })
1125
+ ] })
1126
+ ] })
1127
+ ] }),
1128
+ !showQR && !isSuccess && /* @__PURE__ */ jsxs(Fragment, { children: [
1129
+ /* @__PURE__ */ jsxs("div", { style: styles.selectorsRow, children: [
1130
+ /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
1131
+ /* @__PURE__ */ jsxs(
1132
+ "div",
1133
+ {
1134
+ style: styles.selector,
1135
+ onClick: () => {
1136
+ setChainDropdownOpen(!chainDropdownOpen);
1137
+ setTokenDropdownOpen(false);
1138
+ },
1139
+ children: [
1140
+ /* @__PURE__ */ jsxs(
1141
+ "div",
1142
+ {
1143
+ style: {
1144
+ display: "flex",
1145
+ alignItems: "center",
1146
+ gap: "12px"
1147
+ },
1148
+ children: [
1149
+ /* @__PURE__ */ jsx("div", { style: styles.selectorIcon, children: payment.selectedChain ? /* @__PURE__ */ jsx(
1150
+ "img",
1151
+ {
1152
+ src: payment.selectedChain.icon,
1153
+ alt: "",
1154
+ style: {
1155
+ width: "100%",
1156
+ height: "100%"
1157
+ }
1158
+ }
1159
+ ) : /* @__PURE__ */ jsx(GlobeIcon, {}) }),
1160
+ /* @__PURE__ */ jsxs("div", { children: [
1161
+ /* @__PURE__ */ jsx("div", { style: styles.selectorLabel, children: "Chain" }),
1162
+ /* @__PURE__ */ jsx("div", { style: styles.selectorValue, children: payment.selectedChain?.name || "Select" })
1163
+ ] })
1164
+ ]
1165
+ }
1166
+ ),
1167
+ /* @__PURE__ */ jsx(ChevronIcon, {})
1168
+ ]
1169
+ }
1170
+ ),
1171
+ chainDropdownOpen && /* @__PURE__ */ jsx("div", { style: styles.dropdown, children: payment.chains.map((chain) => /* @__PURE__ */ jsxs(
1172
+ "div",
1173
+ {
1174
+ style: styles.dropdownItem,
1175
+ onClick: () => {
1176
+ payment.setSelectedChain(chain);
1177
+ setChainDropdownOpen(false);
1178
+ },
1179
+ onMouseEnter: (e) => {
1180
+ e.currentTarget.style.background = "rgba(255,255,255,0.1)";
1181
+ },
1182
+ onMouseLeave: (e) => {
1183
+ e.currentTarget.style.background = "transparent";
1184
+ },
1185
+ children: [
1186
+ /* @__PURE__ */ jsx(
1187
+ "img",
1188
+ {
1189
+ src: chain.icon,
1190
+ alt: "",
1191
+ style: {
1192
+ width: "24px",
1193
+ height: "24px",
1194
+ borderRadius: "50%"
1195
+ }
1196
+ }
1197
+ ),
1198
+ /* @__PURE__ */ jsx(
1199
+ "span",
1200
+ {
1201
+ style: {
1202
+ color: "white",
1203
+ fontSize: "14px"
1204
+ },
1205
+ children: chain.name
1206
+ }
1207
+ )
1208
+ ]
1209
+ },
1210
+ chain.id
1211
+ )) })
1212
+ ] }),
1213
+ /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
1214
+ /* @__PURE__ */ jsxs(
1215
+ "div",
1216
+ {
1217
+ style: {
1218
+ ...styles.selector,
1219
+ opacity: payment.selectedChain ? 1 : 0.5,
1220
+ pointerEvents: payment.selectedChain ? "auto" : "none"
1221
+ },
1222
+ onClick: () => {
1223
+ if (payment.selectedChain) {
1224
+ setTokenDropdownOpen(!tokenDropdownOpen);
1225
+ setChainDropdownOpen(false);
1226
+ }
1227
+ },
1228
+ children: [
1229
+ /* @__PURE__ */ jsxs(
1230
+ "div",
1231
+ {
1232
+ style: {
1233
+ display: "flex",
1234
+ alignItems: "center",
1235
+ gap: "12px"
1236
+ },
1237
+ children: [
1238
+ /* @__PURE__ */ jsx("div", { style: styles.selectorIcon, children: payment.selectedToken ? /* @__PURE__ */ jsx(
1239
+ "img",
1240
+ {
1241
+ src: payment.selectedToken.icon,
1242
+ alt: "",
1243
+ style: {
1244
+ width: "100%",
1245
+ height: "100%"
1246
+ }
1247
+ }
1248
+ ) : /* @__PURE__ */ jsx(DollarIcon, {}) }),
1249
+ /* @__PURE__ */ jsxs("div", { children: [
1250
+ /* @__PURE__ */ jsx("div", { style: styles.selectorLabel, children: "Token" }),
1251
+ /* @__PURE__ */ jsx("div", { style: styles.selectorValue, children: payment.selectedToken?.symbol || "Select" })
1252
+ ] })
1253
+ ]
1254
+ }
1255
+ ),
1256
+ /* @__PURE__ */ jsx(ChevronIcon, {})
1257
+ ]
1258
+ }
1259
+ ),
1260
+ tokenDropdownOpen && /* @__PURE__ */ jsx("div", { style: styles.dropdown, children: payment.tokens.map((token) => /* @__PURE__ */ jsxs(
1261
+ "div",
1262
+ {
1263
+ style: styles.dropdownItem,
1264
+ onClick: () => {
1265
+ payment.setSelectedToken(token);
1266
+ setTokenDropdownOpen(false);
1267
+ },
1268
+ onMouseEnter: (e) => {
1269
+ e.currentTarget.style.background = "rgba(255,255,255,0.1)";
1270
+ },
1271
+ onMouseLeave: (e) => {
1272
+ e.currentTarget.style.background = "transparent";
1273
+ },
1274
+ children: [
1275
+ /* @__PURE__ */ jsx(
1276
+ "img",
1277
+ {
1278
+ src: token.icon,
1279
+ alt: "",
1280
+ style: {
1281
+ width: "24px",
1282
+ height: "24px",
1283
+ borderRadius: "50%"
1284
+ }
1285
+ }
1286
+ ),
1287
+ /* @__PURE__ */ jsx(
1288
+ "span",
1289
+ {
1290
+ style: {
1291
+ color: "white",
1292
+ fontSize: "14px"
1293
+ },
1294
+ children: token.symbol
1295
+ }
1296
+ )
1297
+ ]
1298
+ },
1299
+ token.assetId
1300
+ )) })
1301
+ ] })
1302
+ ] }),
1303
+ /* @__PURE__ */ jsx(
1304
+ "input",
1305
+ {
1306
+ type: "text",
1307
+ inputMode: "decimal",
1308
+ placeholder: "0.00",
1309
+ value: payment.amount,
1310
+ onChange: (e) => payment.setAmount(e.target.value),
1311
+ style: styles.amountInput
1312
+ }
1313
+ ),
1314
+ /* @__PURE__ */ jsxs("div", { style: styles.details, children: [
1315
+ payment.amount && /* @__PURE__ */ jsxs("div", { style: styles.detailRow, children: [
1316
+ /* @__PURE__ */ jsx("span", { children: "You receive" }),
1317
+ payment.isLoadingPreview ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "4px" }, children: [
1318
+ /* @__PURE__ */ jsx("div", { style: styles.loadingDot }),
1319
+ /* @__PURE__ */ jsx("div", { style: { ...styles.loadingDot, animationDelay: "0.2s" } }),
1320
+ /* @__PURE__ */ jsx("div", { style: { ...styles.loadingDot, animationDelay: "0.4s" } })
1321
+ ] }) : payment.previewQuote ? /* @__PURE__ */ jsxs("span", { style: styles.detailValue, children: [
1322
+ "~",
1323
+ payment.previewQuote.amountOutFormatted,
1324
+ " ",
1325
+ payment.destinationToken.symbol
1326
+ ] }) : /* @__PURE__ */ jsx("span", { style: { color: "rgba(255,255,255,0.3)" }, children: "Enter amount..." })
1327
+ ] }),
1328
+ /* @__PURE__ */ jsxs("div", { style: styles.detailRow, children: [
1329
+ /* @__PURE__ */ jsx("span", { children: "Destination" }),
1330
+ /* @__PURE__ */ jsxs("span", { style: styles.detailValue, children: [
1331
+ payment.destinationToken.symbol,
1332
+ " on Sui"
1333
+ ] })
1334
+ ] })
1335
+ ] }),
1336
+ /* @__PURE__ */ jsx(
1337
+ "button",
1338
+ {
1339
+ style: {
1340
+ ...styles.button,
1341
+ ...!canSubmit || isProcessing ? styles.buttonDisabled : {}
1342
+ },
1343
+ disabled: !canSubmit || isProcessing,
1344
+ onClick: () => payment.fetchQuote(),
1345
+ children: /* @__PURE__ */ jsx("div", { style: styles.buttonInner, children: isProcessing ? /* @__PURE__ */ jsxs(Fragment, { children: [
1346
+ /* @__PURE__ */ jsx(SpinnerIcon, {}),
1347
+ " Processing..."
1348
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1349
+ "Confirm Payment",
1350
+ /* @__PURE__ */ jsx(ArrowIcon, {})
1351
+ ] }) })
1352
+ }
1353
+ )
1354
+ ] })
1355
+ ] }),
1356
+ /* @__PURE__ */ jsx(
1357
+ "p",
1358
+ {
1359
+ style: {
1360
+ textAlign: "center",
1361
+ fontSize: "10px",
1362
+ color: "rgba(255,255,255,0.3)",
1363
+ marginTop: "16px"
1364
+ },
1365
+ children: "Powered by Uniport \u2022 NEAR Intents"
1366
+ }
1367
+ )
1368
+ ] }) });
1369
+ }
1370
+ function CloseIcon() {
1371
+ return /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
1372
+ "path",
1373
+ {
1374
+ d: "M18 6L6 18M6 6L18 18",
1375
+ stroke: "currentColor",
1376
+ strokeWidth: "2",
1377
+ strokeLinecap: "round"
1378
+ }
1379
+ ) });
1380
+ }
1381
+ function CardIcon() {
1382
+ return /* @__PURE__ */ jsx(
1383
+ "svg",
1384
+ {
1385
+ width: "24",
1386
+ height: "24",
1387
+ viewBox: "0 0 24 24",
1388
+ fill: "none",
1389
+ stroke: "rgba(255,255,255,0.9)",
1390
+ strokeWidth: "1.5",
1391
+ children: /* @__PURE__ */ 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" })
1392
+ }
1393
+ );
1394
+ }
1395
+ function GlobeIcon() {
1396
+ return /* @__PURE__ */ jsxs(
1397
+ "svg",
1398
+ {
1399
+ width: "18",
1400
+ height: "18",
1401
+ viewBox: "0 0 24 24",
1402
+ fill: "none",
1403
+ stroke: "#818CF8",
1404
+ strokeWidth: "1.5",
1405
+ children: [
1406
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
1407
+ /* @__PURE__ */ 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" })
1408
+ ]
1409
+ }
1410
+ );
1411
+ }
1412
+ function DollarIcon() {
1413
+ return /* @__PURE__ */ jsxs(
1414
+ "svg",
1415
+ {
1416
+ width: "18",
1417
+ height: "18",
1418
+ viewBox: "0 0 24 24",
1419
+ fill: "none",
1420
+ stroke: "#22D3EE",
1421
+ strokeWidth: "1.5",
1422
+ children: [
1423
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
1424
+ /* @__PURE__ */ 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" })
1425
+ ]
1426
+ }
1427
+ );
1428
+ }
1429
+ function ChevronIcon() {
1430
+ return /* @__PURE__ */ jsx(
1431
+ "svg",
1432
+ {
1433
+ width: "16",
1434
+ height: "16",
1435
+ viewBox: "0 0 24 24",
1436
+ fill: "none",
1437
+ stroke: "rgba(255,255,255,0.4)",
1438
+ strokeWidth: "2",
1439
+ children: /* @__PURE__ */ jsx("path", { d: "M6 9l6 6 6-6" })
1440
+ }
1441
+ );
1442
+ }
1443
+ function CheckSmallIcon() {
1444
+ return /* @__PURE__ */ jsx(
1445
+ "svg",
1446
+ {
1447
+ width: "16",
1448
+ height: "16",
1449
+ viewBox: "0 0 24 24",
1450
+ fill: "none",
1451
+ stroke: "#10B981",
1452
+ strokeWidth: "2",
1453
+ children: /* @__PURE__ */ jsx("path", { d: "M20 6L9 17l-5-5" })
1454
+ }
1455
+ );
1456
+ }
1457
+ function CopyIcon() {
1458
+ return /* @__PURE__ */ jsxs(
1459
+ "svg",
1460
+ {
1461
+ width: "16",
1462
+ height: "16",
1463
+ viewBox: "0 0 24 24",
1464
+ fill: "none",
1465
+ stroke: "rgba(255,255,255,0.7)",
1466
+ strokeWidth: "2",
1467
+ children: [
1468
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1469
+ /* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" })
1470
+ ]
1471
+ }
1472
+ );
1473
+ }
1474
+ function PulseIcon() {
1475
+ return /* @__PURE__ */ jsx("svg", { width: "8", height: "8", viewBox: "0 0 8 8", children: /* @__PURE__ */ jsx(
1476
+ "circle",
1477
+ {
1478
+ cx: "4",
1479
+ cy: "4",
1480
+ r: "4",
1481
+ fill: "#818CF8",
1482
+ style: { animation: "uniport-pulse 1s ease infinite" }
1483
+ }
1484
+ ) });
1485
+ }
1486
+ function SpinnerIcon() {
1487
+ return /* @__PURE__ */ jsxs(
1488
+ "svg",
1489
+ {
1490
+ width: "16",
1491
+ height: "16",
1492
+ viewBox: "0 0 24 24",
1493
+ fill: "none",
1494
+ style: { animation: "spin 1s linear infinite" },
1495
+ children: [
1496
+ /* @__PURE__ */ jsx(
1497
+ "circle",
1498
+ {
1499
+ cx: "12",
1500
+ cy: "12",
1501
+ r: "10",
1502
+ stroke: "rgba(255,255,255,0.2)",
1503
+ strokeWidth: "3"
1504
+ }
1505
+ ),
1506
+ /* @__PURE__ */ jsx(
1507
+ "path",
1508
+ {
1509
+ d: "M12 2a10 10 0 019.95 9",
1510
+ stroke: "white",
1511
+ strokeWidth: "3",
1512
+ strokeLinecap: "round"
1513
+ }
1514
+ )
1515
+ ]
1516
+ }
1517
+ );
1518
+ }
1519
+ function ArrowIcon() {
1520
+ return /* @__PURE__ */ jsx(
1521
+ "svg",
1522
+ {
1523
+ width: "16",
1524
+ height: "16",
1525
+ viewBox: "0 0 24 24",
1526
+ fill: "none",
1527
+ stroke: "currentColor",
1528
+ strokeWidth: "2",
1529
+ children: /* @__PURE__ */ jsx("path", { d: "M5 12h14M12 5l7 7-7 7" })
1530
+ }
1531
+ );
1532
+ }
1533
+ var buttonStyles = {
1534
+ default: {
1535
+ display: "inline-flex",
1536
+ alignItems: "center",
1537
+ justifyContent: "center",
1538
+ gap: "8px",
1539
+ padding: "12px 24px",
1540
+ fontSize: "14px",
1541
+ fontWeight: 500,
1542
+ color: "white",
1543
+ background: "linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%)",
1544
+ border: "none",
1545
+ borderRadius: "12px",
1546
+ cursor: "pointer",
1547
+ transition: "all 0.2s ease",
1548
+ boxShadow: "0 4px 14px rgba(79, 70, 229, 0.3)",
1549
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1550
+ },
1551
+ compact: {
1552
+ display: "inline-flex",
1553
+ alignItems: "center",
1554
+ justifyContent: "center",
1555
+ gap: "6px",
1556
+ padding: "8px 16px",
1557
+ fontSize: "13px",
1558
+ fontWeight: 500,
1559
+ color: "white",
1560
+ background: "linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%)",
1561
+ border: "none",
1562
+ borderRadius: "8px",
1563
+ cursor: "pointer",
1564
+ transition: "all 0.2s ease",
1565
+ boxShadow: "0 2px 8px rgba(79, 70, 229, 0.25)",
1566
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1567
+ },
1568
+ outline: {
1569
+ display: "inline-flex",
1570
+ alignItems: "center",
1571
+ justifyContent: "center",
1572
+ gap: "8px",
1573
+ padding: "12px 24px",
1574
+ fontSize: "14px",
1575
+ fontWeight: 500,
1576
+ color: "#4F46E5",
1577
+ background: "transparent",
1578
+ border: "2px solid #4F46E5",
1579
+ borderRadius: "12px",
1580
+ cursor: "pointer",
1581
+ transition: "all 0.2s ease",
1582
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1583
+ },
1584
+ disabled: {
1585
+ opacity: 0.5,
1586
+ cursor: "not-allowed"
1587
+ }
1588
+ };
1589
+ function UniportButton({
1590
+ recipient,
1591
+ refundAddress,
1592
+ destinationToken = "suiUSDC",
1593
+ amount,
1594
+ label = "Pay with Crypto",
1595
+ variant = "default",
1596
+ disabled = false,
1597
+ className,
1598
+ onSuccess,
1599
+ onError,
1600
+ onOpenChange
1601
+ }) {
1602
+ const [isOpen, setIsOpen] = useState(false);
1603
+ const handleOpen = () => {
1604
+ if (!disabled) {
1605
+ setIsOpen(true);
1606
+ onOpenChange?.(true);
1607
+ }
1608
+ };
1609
+ const handleClose = () => {
1610
+ setIsOpen(false);
1611
+ onOpenChange?.(false);
1612
+ };
1613
+ const style = {
1614
+ ...buttonStyles[variant],
1615
+ ...disabled ? buttonStyles.disabled : {}
1616
+ };
1617
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1618
+ /* @__PURE__ */ jsxs(
1619
+ "button",
1620
+ {
1621
+ type: "button",
1622
+ onClick: handleOpen,
1623
+ disabled,
1624
+ className,
1625
+ style,
1626
+ children: [
1627
+ /* @__PURE__ */ jsx(UniportIcon, {}),
1628
+ label
1629
+ ]
1630
+ }
1631
+ ),
1632
+ /* @__PURE__ */ jsx(
1633
+ UniportModal,
1634
+ {
1635
+ open: isOpen,
1636
+ onClose: handleClose,
1637
+ recipient,
1638
+ refundAddress,
1639
+ destinationToken,
1640
+ amount,
1641
+ onSuccess,
1642
+ onError
1643
+ }
1644
+ )
1645
+ ] });
1646
+ }
1647
+ function UniportIcon() {
1648
+ return /* @__PURE__ */ jsxs(
1649
+ "svg",
1650
+ {
1651
+ width: "18",
1652
+ height: "18",
1653
+ viewBox: "0 0 24 24",
1654
+ fill: "none",
1655
+ xmlns: "http://www.w3.org/2000/svg",
1656
+ children: [
1657
+ /* @__PURE__ */ jsx(
1658
+ "path",
1659
+ {
1660
+ d: "M12 2L2 7L12 12L22 7L12 2Z",
1661
+ stroke: "currentColor",
1662
+ strokeWidth: "2",
1663
+ strokeLinecap: "round",
1664
+ strokeLinejoin: "round"
1665
+ }
1666
+ ),
1667
+ /* @__PURE__ */ jsx(
1668
+ "path",
1669
+ {
1670
+ d: "M2 17L12 22L22 17",
1671
+ stroke: "currentColor",
1672
+ strokeWidth: "2",
1673
+ strokeLinecap: "round",
1674
+ strokeLinejoin: "round"
1675
+ }
1676
+ ),
1677
+ /* @__PURE__ */ jsx(
1678
+ "path",
1679
+ {
1680
+ d: "M2 12L12 17L22 12",
1681
+ stroke: "currentColor",
1682
+ strokeWidth: "2",
1683
+ strokeLinecap: "round",
1684
+ strokeLinejoin: "round"
1685
+ }
1686
+ )
1687
+ ]
1688
+ }
1689
+ );
1690
+ }
1691
+
1692
+ export { UniportButton, UniportModal };
1693
+ //# sourceMappingURL=index.js.map
1694
+ //# sourceMappingURL=index.js.map