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,1701 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var qrcode_react = require('qrcode.react');
5
+ var oneClickSdkTypescript = require('@defuse-protocol/one-click-sdk-typescript');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefault(React);
11
+
12
+ // src/components/UniportButton.tsx
13
+ function getConfig() {
14
+ {
15
+ throw new Error(
16
+ "Uniport SDK not initialized. Call initUniport() first."
17
+ );
18
+ }
19
+ }
20
+
21
+ // src/core/intents.ts
22
+ function toSmallestUnits(amount, decimals) {
23
+ const [whole, fraction = ""] = amount.split(".");
24
+ const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
25
+ return `${whole}${paddedFraction}`.replace(/^0+/, "") || "0";
26
+ }
27
+ function generateDeadline(hoursFromNow = 1) {
28
+ const deadline = new Date(Date.now() + hoursFromNow * 60 * 60 * 1e3);
29
+ return deadline.toISOString();
30
+ }
31
+ function ensureInitialized() {
32
+ {
33
+ throw new Error(
34
+ "Uniport SDK not initialized. Call initUniport() first."
35
+ );
36
+ }
37
+ }
38
+ async function getQuote(options) {
39
+ ensureInitialized();
40
+ const config = getConfig();
41
+ const {
42
+ originToken,
43
+ destinationToken,
44
+ amount,
45
+ recipient,
46
+ refundTo,
47
+ slippageTolerance = 100,
48
+ // 1% default
49
+ swapType = "EXACT_INPUT",
50
+ deadline,
51
+ dry = false,
52
+ referral = config.referral || "uniport"
53
+ } = options;
54
+ 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
+ };
70
+ 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
+ };
84
+ } catch (error) {
85
+ if (error instanceof oneClickSdkTypescript.ApiError) {
86
+ throw new Error(
87
+ `Quote failed (${error.status}): ${JSON.stringify(error.body)}`
88
+ );
89
+ }
90
+ throw error;
91
+ }
92
+ }
93
+ async function getExecutionStatus(depositAddress, memo) {
94
+ ensureInitialized();
95
+ 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
+ };
116
+ } catch (error) {
117
+ if (error instanceof oneClickSdkTypescript.ApiError) {
118
+ throw new Error(
119
+ `Status check failed (${error.status}): ${JSON.stringify(error.body)}`
120
+ );
121
+ }
122
+ throw error;
123
+ }
124
+ }
125
+
126
+ // src/core/tokens.ts
127
+ var TOKEN_ICONS = {
128
+ // Stablecoins
129
+ USDC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
130
+ 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",
132
+ // Major tokens
133
+ ETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
134
+ WETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png",
135
+ BTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoin/info/logo.png",
136
+ WBTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/logo.png",
137
+ // L1s & L2s
138
+ SUI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png",
139
+ SOL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png",
140
+ NEAR: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/near/info/logo.png",
141
+ ARB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png",
142
+ OP: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/info/logo.png",
143
+ POL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png",
144
+ AVAX: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png",
145
+ BNB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
146
+ BASE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png",
147
+ // Other L1s
148
+ ADA: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cardano/info/logo.png",
149
+ XRP: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png",
150
+ DOGE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/doge/info/logo.png",
151
+ LTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png",
152
+ BCH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png",
153
+ TON: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ton/info/logo.png",
154
+ TRX: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png",
155
+ XLM: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stellar/info/logo.png",
156
+ APT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/aptos/info/logo.png",
157
+ // DeFi & Others
158
+ AAVE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x7Fc66500c84A76Ad7e9c93437BFc5Ac33E2DDaE9/logo.png",
159
+ UNI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984/logo.png",
160
+ LINK: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x514910771AF9Ca656af840dff83E8264EcF986CA/logo.png",
161
+ SHIB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE/logo.png",
162
+ PEPE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6982508145454Ce325dDbE47a25d4ec3d2311933/logo.png",
163
+ // 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",
166
+ 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",
168
+ ZEC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png",
169
+ // 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",
174
+ // Default fallback
175
+ DEFAULT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png"
176
+ };
177
+ var CHAIN_ICONS = {
178
+ sui: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png",
179
+ eth: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
180
+ arb: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png",
181
+ base: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png",
182
+ op: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/info/logo.png",
183
+ sol: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png",
184
+ btc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoin/info/logo.png",
185
+ near: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/near/info/logo.png",
186
+ pol: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png",
187
+ avax: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png",
188
+ bsc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
189
+ ton: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ton/info/logo.png",
190
+ tron: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png",
191
+ stellar: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stellar/info/logo.png",
192
+ cardano: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cardano/info/logo.png",
193
+ aptos: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/aptos/info/logo.png",
194
+ 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",
198
+ doge: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/doge/info/logo.png",
199
+ ltc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png",
200
+ bch: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png",
201
+ xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png",
202
+ zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png"
203
+ };
204
+ function createToken(chain, symbol, assetId, decimals, contractAddress) {
205
+ const name = `${chain}${symbol.replace("$", "").replace(" ", "")}`;
206
+ const icon = TOKEN_ICONS[symbol] || TOKEN_ICONS.DEFAULT;
207
+ const chainIcon = CHAIN_ICONS[chain];
208
+ return {
209
+ name,
210
+ symbol,
211
+ assetId,
212
+ chain,
213
+ decimals,
214
+ icon,
215
+ chainIcon,
216
+ contractAddress
217
+ };
218
+ }
219
+ var suiSUI = createToken("sui", "SUI", "nep141:sui.omft.near", 9);
220
+ var suiUSDC = createToken("sui", "USDC", "nep141:sui-c1b81ecaf27933252d31a963bc5e9458f13c18ce.omft.near", 6, "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC");
221
+ var ethereumETH = createToken("eth", "ETH", "nep141:eth.omft.near", 18);
222
+ var ethereumUSDC = createToken("eth", "USDC", "nep141:eth-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.omft.near", 6, "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48");
223
+ var ethereumUSDT = createToken("eth", "USDT", "nep141:eth-0xdac17f958d2ee523a2206206994597c13d831ec7.omft.near", 6, "0xdac17f958d2ee523a2206206994597c13d831ec7");
224
+ var ethereumWBTC = createToken("eth", "WBTC", "nep141:eth-0x2260fac5e5542a773aa44fbcfedf7c193bc2c599.omft.near", 8, "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599");
225
+ var ethereumDAI = createToken("eth", "DAI", "nep141:eth-0x6b175474e89094c44da98b954eedeac495271d0f.omft.near", 18, "0x6b175474e89094c44da98b954eedeac495271d0f");
226
+ var ethereumAAVE = createToken("eth", "AAVE", "nep141:eth-0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.omft.near", 18, "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9");
227
+ var ethereumUNI = createToken("eth", "UNI", "nep141:eth-0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.omft.near", 18, "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984");
228
+ var ethereumLINK = createToken("eth", "LINK", "nep141:eth-0x514910771af9ca656af840dff83e8264ecf986ca.omft.near", 18, "0x514910771af9ca656af840dff83e8264ecf986ca");
229
+ var ethereumSHIB = createToken("eth", "SHIB", "nep141:eth-0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce.omft.near", 18, "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce");
230
+ var ethereumPEPE = createToken("eth", "PEPE", "nep141:eth-0x6982508145454ce325ddbe47a25d4ec3d2311933.omft.near", 18, "0x6982508145454ce325ddbe47a25d4ec3d2311933");
231
+ var ethereumTURBO = createToken("eth", "TURBO", "nep141:eth-0xa35923162c49cf95e6bf26623385eb431ad920d3.omft.near", 18, "0xa35923162c49cf95e6bf26623385eb431ad920d3");
232
+ var ethereumSAFE = createToken("eth", "SAFE", "nep141:eth-0x5afe3855358e112b5647b952709e6165e1c1eeee.omft.near", 18, "0x5afe3855358e112b5647b952709e6165e1c1eeee");
233
+ var arbitrumETH = createToken("arb", "ETH", "nep141:arb.omft.near", 18);
234
+ var arbitrumUSDC = createToken("arb", "USDC", "nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near", 6, "0xaf88d065e77c8cc2239327c5edb3a432268e5831");
235
+ var arbitrumUSDT = createToken("arb", "USDT", "nep141:arb-0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9.omft.near", 6, "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9");
236
+ var arbitrumARB = createToken("arb", "ARB", "nep141:arb-0x912ce59144191c1204e64559fe8253a0e49e6548.omft.near", 18, "0x912ce59144191c1204e64559fe8253a0e49e6548");
237
+ var arbitrumGMX = createToken("arb", "GMX", "nep141:arb-0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a.omft.near", 18, "0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a");
238
+ var baseETH = createToken("base", "ETH", "nep141:base.omft.near", 18);
239
+ 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");
241
+ var baseBRETT = createToken("base", "BRETT", "nep141:base-0x532f27101965dd16442e59d40670faf5ebb142e4.omft.near", 18, "0x532f27101965dd16442e59d40670faf5ebb142e4");
242
+ var optimismETH = createToken("op", "ETH", "nep245:v2_1.omni.hot.tg:10_11111111111111111111", 18);
243
+ var optimismUSDC = createToken("op", "USDC", "nep245:v2_1.omni.hot.tg:10_A2ewyUyDp6qsue1jqZsGypkCxRJ", 6, "0x0b2c639c533813f4aa9d7837caf62653d097ff85");
244
+ var optimismUSDT = createToken("op", "USDT", "nep245:v2_1.omni.hot.tg:10_359RPSJVdTxwTJT9TyGssr2rFoWo", 6, "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58");
245
+ var optimismOP = createToken("op", "OP", "nep245:v2_1.omni.hot.tg:10_vLAiSt9KfUGKpw5cD3vsSyNYBo7", 18, "0x4200000000000000000000000000000000000042");
246
+ var solanaSOL = createToken("sol", "SOL", "nep141:sol.omft.near", 9);
247
+ var solanaUSDC = createToken("sol", "USDC", "nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near", 6, "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
248
+ var solanaUSDT = createToken("sol", "USDT", "nep141:sol-c800a4bd850783ccb82c2b2c7e84175443606352.omft.near", 6, "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
249
+ var solanaTRUMP = createToken("sol", "TRUMP", "nep141:sol-c58e6539c2f2e097c251f8edf11f9c03e581f8d4.omft.near", 6, "6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN");
250
+ var solanaWIF = createToken("sol", "$WIF", "nep141:sol-b9c68f94ec8fd160137af8cdfe5e61cd68e2afba.omft.near", 6, "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm");
251
+ var solanaMELANIA = createToken("sol", "MELANIA", "nep141:sol-d600e625449a4d9380eaf5e3265e54c90d34e260.omft.near", 6, "FUAfBo2jgks6gB4Z4LfZkqSZgzNucisEHqnNebaRxM1P");
252
+ var bitcoinBTC = createToken("btc", "BTC", "nep141:btc.omft.near", 8);
253
+ var polygonPOL = createToken("pol", "POL", "nep245:v2_1.omni.hot.tg:137_11111111111111111111", 18);
254
+ var polygonUSDC = createToken("pol", "USDC", "nep245:v2_1.omni.hot.tg:137_qiStmoQJDQPTebaPjgx5VBxZv6L", 6, "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359");
255
+ var polygonUSDT = createToken("pol", "USDT", "nep245:v2_1.omni.hot.tg:137_3hpYoaLtt8MP1Z2GH1U473DMRKgr", 6, "0xc2132d05d31c914a87c6611c10748aeb04b58e8f");
256
+ var avalancheAVAX = createToken("avax", "AVAX", "nep245:v2_1.omni.hot.tg:43114_11111111111111111111", 18);
257
+ var avalancheUSDC = createToken("avax", "USDC", "nep245:v2_1.omni.hot.tg:43114_3atVJH3r5c4GqiSYmg9fECvjc47o", 6, "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e");
258
+ var avalancheUSDT = createToken("avax", "USDT", "nep245:v2_1.omni.hot.tg:43114_372BeH7ENZieCaabwkbWkBiTTgXp", 6, "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7");
259
+ var bscBNB = createToken("bsc", "BNB", "nep245:v2_1.omni.hot.tg:56_11111111111111111111", 18);
260
+ var bscUSDC = createToken("bsc", "USDC", "nep245:v2_1.omni.hot.tg:56_2w93GqMcEmQFDru84j3HZZWt557r", 18, "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d");
261
+ var bscUSDT = createToken("bsc", "USDT", "nep245:v2_1.omni.hot.tg:56_2CMMyVTGZkeyNZTSvS5sarzfir6g", 18, "0x55d398326f99059ff775485246999027b3197955");
262
+ var tonTON = createToken("ton", "TON", "nep245:v2_1.omni.hot.tg:1117_", 9);
263
+ var tonUSDT = createToken("ton", "USDT", "nep245:v2_1.omni.hot.tg:1117_3tsdfyziyc7EJbP2aULWSKU4toBaAcN4FdTgfm5W1mC4ouR", 6, "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs");
264
+ var tronTRX = createToken("tron", "TRX", "nep141:tron.omft.near", 6);
265
+ var tronUSDT = createToken("tron", "USDT", "nep141:tron-d28a265909efecdcee7c5028585214ea0b96f015.omft.near", 6, "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t");
266
+ var cardanoADA = createToken("cardano", "ADA", "nep141:cardano.omft.near", 6);
267
+ var rippleXRP = createToken("xrp", "XRP", "nep141:xrp.omft.near", 6);
268
+ var dogecoinDOGE = createToken("doge", "DOGE", "nep141:doge.omft.near", 8);
269
+ var litecoinLTC = createToken("ltc", "LTC", "nep141:ltc.omft.near", 8);
270
+ var bitcoinCashBCH = createToken("bch", "BCH", "nep141:bch.omft.near", 8);
271
+ var aptosAPT = createToken("aptos", "APT", "nep141:aptos.omft.near", 8);
272
+ var starknetSTRK = createToken("starknet", "STRK", "nep141:starknet.omft.near", 18);
273
+ var berachainBERA = createToken("bera", "BERA", "nep141:bera.omft.near", 18);
274
+ var zcashZEC = createToken("zec", "ZEC", "nep141:zec.omft.near", 8);
275
+ var nearNEAR = createToken("near", "wNEAR", "nep141:wrap.near", 24, "wrap.near");
276
+ var nearUSDC = createToken("near", "USDC", "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1", 6, "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1");
277
+ var nearUSDT = createToken("near", "USDT", "nep141:usdt.tether-token.near", 6, "usdt.tether-token.near");
278
+ var CHAINS = {
279
+ sui: {
280
+ id: "sui",
281
+ name: "Sui",
282
+ icon: CHAIN_ICONS.sui,
283
+ tokens: [suiSUI, suiUSDC]
284
+ },
285
+ eth: {
286
+ id: "eth",
287
+ name: "Ethereum",
288
+ icon: CHAIN_ICONS.eth,
289
+ tokens: [ethereumETH, ethereumUSDC, ethereumUSDT, ethereumWBTC, ethereumDAI, ethereumAAVE, ethereumUNI, ethereumLINK, ethereumSHIB, ethereumPEPE, ethereumTURBO, ethereumSAFE]
290
+ },
291
+ arb: {
292
+ id: "arb",
293
+ name: "Arbitrum",
294
+ icon: CHAIN_ICONS.arb,
295
+ tokens: [arbitrumETH, arbitrumUSDC, arbitrumUSDT, arbitrumARB, arbitrumGMX]
296
+ },
297
+ base: {
298
+ id: "base",
299
+ name: "Base",
300
+ icon: CHAIN_ICONS.base,
301
+ tokens: [baseETH, baseUSDC, baseCbBTC, baseBRETT]
302
+ },
303
+ op: {
304
+ id: "op",
305
+ name: "Optimism",
306
+ icon: CHAIN_ICONS.op,
307
+ tokens: [optimismETH, optimismUSDC, optimismUSDT, optimismOP]
308
+ },
309
+ sol: {
310
+ id: "sol",
311
+ name: "Solana",
312
+ icon: CHAIN_ICONS.sol,
313
+ tokens: [solanaSOL, solanaUSDC, solanaUSDT, solanaTRUMP, solanaWIF, solanaMELANIA]
314
+ },
315
+ btc: {
316
+ id: "btc",
317
+ name: "Bitcoin",
318
+ icon: CHAIN_ICONS.btc,
319
+ tokens: [bitcoinBTC]
320
+ },
321
+ pol: {
322
+ id: "pol",
323
+ name: "Polygon",
324
+ icon: CHAIN_ICONS.pol,
325
+ tokens: [polygonPOL, polygonUSDC, polygonUSDT]
326
+ },
327
+ avax: {
328
+ id: "avax",
329
+ name: "Avalanche",
330
+ icon: CHAIN_ICONS.avax,
331
+ tokens: [avalancheAVAX, avalancheUSDC, avalancheUSDT]
332
+ },
333
+ bsc: {
334
+ id: "bsc",
335
+ name: "BNB Chain",
336
+ icon: CHAIN_ICONS.bsc,
337
+ tokens: [bscBNB, bscUSDC, bscUSDT]
338
+ },
339
+ ton: {
340
+ id: "ton",
341
+ name: "TON",
342
+ icon: CHAIN_ICONS.ton,
343
+ tokens: [tonTON, tonUSDT]
344
+ },
345
+ tron: {
346
+ id: "tron",
347
+ name: "Tron",
348
+ icon: CHAIN_ICONS.tron,
349
+ tokens: [tronTRX, tronUSDT]
350
+ },
351
+ near: {
352
+ id: "near",
353
+ name: "NEAR",
354
+ icon: CHAIN_ICONS.near,
355
+ tokens: [nearNEAR, nearUSDC, nearUSDT]
356
+ },
357
+ cardano: {
358
+ id: "cardano",
359
+ name: "Cardano",
360
+ icon: CHAIN_ICONS.cardano,
361
+ tokens: [cardanoADA]
362
+ },
363
+ xrp: {
364
+ id: "xrp",
365
+ name: "XRP Ledger",
366
+ icon: CHAIN_ICONS.xrp,
367
+ tokens: [rippleXRP]
368
+ },
369
+ doge: {
370
+ id: "doge",
371
+ name: "Dogecoin",
372
+ icon: CHAIN_ICONS.doge,
373
+ tokens: [dogecoinDOGE]
374
+ },
375
+ ltc: {
376
+ id: "ltc",
377
+ name: "Litecoin",
378
+ icon: CHAIN_ICONS.ltc,
379
+ tokens: [litecoinLTC]
380
+ },
381
+ bch: {
382
+ id: "bch",
383
+ name: "Bitcoin Cash",
384
+ icon: CHAIN_ICONS.bch,
385
+ tokens: [bitcoinCashBCH]
386
+ },
387
+ aptos: {
388
+ id: "aptos",
389
+ name: "Aptos",
390
+ icon: CHAIN_ICONS.aptos,
391
+ tokens: [aptosAPT]
392
+ },
393
+ starknet: {
394
+ id: "starknet",
395
+ name: "Starknet",
396
+ icon: CHAIN_ICONS.starknet,
397
+ tokens: [starknetSTRK]
398
+ },
399
+ bera: {
400
+ id: "bera",
401
+ name: "Berachain",
402
+ icon: CHAIN_ICONS.bera,
403
+ tokens: [berachainBERA]
404
+ },
405
+ zec: {
406
+ id: "zec",
407
+ name: "Zcash",
408
+ icon: CHAIN_ICONS.zec,
409
+ tokens: [zcashZEC]
410
+ },
411
+ gnosis: {
412
+ id: "gnosis",
413
+ name: "Gnosis",
414
+ icon: CHAIN_ICONS.gnosis,
415
+ tokens: []
416
+ },
417
+ monad: {
418
+ id: "monad",
419
+ name: "Monad",
420
+ icon: CHAIN_ICONS.monad,
421
+ tokens: []
422
+ },
423
+ stellar: {
424
+ id: "stellar",
425
+ name: "Stellar",
426
+ icon: CHAIN_ICONS.stellar,
427
+ tokens: []
428
+ }
429
+ };
430
+ Object.values(CHAINS).flatMap((chain) => chain.tokens);
431
+ function getSupportedChains() {
432
+ return Object.values(CHAINS).filter((c) => c.tokens.length > 0);
433
+ }
434
+ function getSuiDestinationTokens() {
435
+ return CHAINS.sui.tokens;
436
+ }
437
+
438
+ // src/hooks/useUniportPayment.ts
439
+ 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");
455
+ const tokens = selectedChain?.tokens || [];
456
+ const destinationTokens = getSuiDestinationTokens();
457
+ const setAmount = React.useCallback(
458
+ (newAmount) => {
459
+ setAmountState(newAmount);
460
+ setPreviewQuote(null);
461
+ if (previewDebounceRef.current) {
462
+ clearTimeout(previewDebounceRef.current);
463
+ }
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 {
485
+ setIsLoadingPreview(false);
486
+ }
487
+ },
488
+ [selectedToken, refundAddress, recipient, destToken]
489
+ );
490
+ const handleChainSelect = React.useCallback((chain) => {
491
+ setSelectedChain(chain);
492
+ setSelectedToken(chain.tokens[0] || null);
493
+ setPaymentState("selecting");
494
+ setPreviewQuote(null);
495
+ }, []);
496
+ const handleTokenSelect = React.useCallback((token) => {
497
+ setSelectedToken(token);
498
+ setPaymentState("selecting");
499
+ setPreviewQuote(null);
500
+ }, []);
501
+ const fetchQuote = React.useCallback(async () => {
502
+ if (!selectedToken || !amount || !refundAddress) {
503
+ setError(new Error("Missing required fields"));
504
+ return;
505
+ }
506
+ setPaymentState("quoting");
507
+ setError(null);
508
+ try {
509
+ const result = await getQuote({
510
+ originToken: selectedToken,
511
+ destinationToken: destToken,
512
+ amount,
513
+ recipient,
514
+ refundTo: refundAddress,
515
+ dry: false
516
+ });
517
+ setQuote(result);
518
+ setPaymentState("awaiting_deposit");
519
+ } catch (err) {
520
+ const error2 = err instanceof Error ? err : new Error("Failed to get quote");
521
+ setError(error2);
522
+ setPaymentState("error");
523
+ onError?.(error2);
524
+ }
525
+ }, [
526
+ selectedToken,
527
+ amount,
528
+ refundAddress,
529
+ recipient,
530
+ destToken,
531
+ onError
532
+ ]);
533
+ const pollStatus = React.useCallback(async () => {
534
+ if (!quote?.depositAddress) return;
535
+ try {
536
+ const result = await getExecutionStatus(
537
+ quote.depositAddress,
538
+ quote.memo
539
+ );
540
+ setStatus(result);
541
+ if (result.status !== lastStatusRef.current) {
542
+ lastStatusRef.current = result.status;
543
+ if (result.status === "PROCESSING") {
544
+ setPaymentState("processing");
545
+ } else if (result.isSuccess) {
546
+ setPaymentState("success");
547
+ stopPolling();
548
+ onSuccess?.({
549
+ txHash: result.destinationTxHashes?.[0] || "",
550
+ amount: quote.amountOut
551
+ });
552
+ } else if (result.status === "FAILED") {
553
+ setPaymentState("error");
554
+ stopPolling();
555
+ const err = new Error("Payment failed");
556
+ setError(err);
557
+ onError?.(err);
558
+ }
559
+ }
560
+ } catch (err) {
561
+ console.error("Status poll error:", err);
562
+ }
563
+ }, [quote, onSuccess, onError]);
564
+ const startPolling = React.useCallback(() => {
565
+ if (pollingRef.current) return;
566
+ pollStatus();
567
+ pollingRef.current = setInterval(pollStatus, 3e3);
568
+ }, [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) => {
576
+ try {
577
+ await navigator.clipboard.writeText(text);
578
+ return true;
579
+ } catch {
580
+ return false;
581
+ }
582
+ }, []);
583
+ const reset = React.useCallback(() => {
584
+ stopPolling();
585
+ if (previewDebounceRef.current) {
586
+ clearTimeout(previewDebounceRef.current);
587
+ }
588
+ setPaymentState("idle");
589
+ setQuote(null);
590
+ setPreviewQuote(null);
591
+ setIsLoadingPreview(false);
592
+ setStatus(null);
593
+ setError(null);
594
+ setSelectedChain(null);
595
+ setSelectedToken(null);
596
+ setAmountState("");
597
+ lastStatusRef.current = null;
598
+ }, [stopPolling]);
599
+ React.useEffect(() => {
600
+ return () => {
601
+ stopPolling();
602
+ if (previewDebounceRef.current) {
603
+ clearTimeout(previewDebounceRef.current);
604
+ }
605
+ };
606
+ }, [stopPolling]);
607
+ return {
608
+ paymentState,
609
+ quote,
610
+ previewQuote,
611
+ isLoadingPreview,
612
+ status,
613
+ error,
614
+ selectedChain,
615
+ selectedToken,
616
+ amount,
617
+ destinationToken: destToken,
618
+ chains,
619
+ tokens,
620
+ destinationTokens,
621
+ setSelectedChain: handleChainSelect,
622
+ setSelectedToken: handleTokenSelect,
623
+ setAmount,
624
+ fetchQuote,
625
+ startPolling,
626
+ stopPolling,
627
+ reset,
628
+ copyToClipboard
629
+ };
630
+ }
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
+ }
891
+ };
892
+ var injectStyles = () => {
893
+ if (typeof document === "undefined") return;
894
+ if (document.getElementById("uniport-styles")) return;
895
+ const style = document.createElement("style");
896
+ style.id = "uniport-styles";
897
+ style.textContent = `
898
+ @keyframes uniport-fade-in {
899
+ from { opacity: 0; }
900
+ to { opacity: 1; }
901
+ }
902
+ @keyframes uniport-slide-up {
903
+ from { opacity: 0; transform: translateY(20px) scale(0.95); }
904
+ to { opacity: 1; transform: translateY(0) scale(1); }
905
+ }
906
+ @keyframes uniport-gradient {
907
+ 0% { background-position: 0% 50%; }
908
+ 50% { background-position: 100% 50%; }
909
+ 100% { background-position: 0% 50%; }
910
+ }
911
+ @keyframes uniport-pulse {
912
+ 0%, 100% { opacity: 1; }
913
+ 50% { opacity: 0.3; }
914
+ }
915
+ `;
916
+ document.head.appendChild(style);
917
+ };
918
+ function UniportModal({
919
+ open,
920
+ onClose,
921
+ recipient,
922
+ refundAddress,
923
+ destinationToken = "suiUSDC",
924
+ amount: initialAmount,
925
+ onSuccess,
926
+ onError
927
+ }) {
928
+ const payment = useUniportPayment({
929
+ recipient,
930
+ refundAddress,
931
+ destinationToken,
932
+ onSuccess,
933
+ onError
934
+ });
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(() => {
940
+ injectStyles();
941
+ }, []);
942
+ React.useEffect(() => {
943
+ if (payment.paymentState === "awaiting_deposit") {
944
+ payment.startPolling();
945
+ }
946
+ }, [payment.paymentState]);
947
+ React.useEffect(() => {
948
+ return () => payment.stopPolling();
949
+ }, []);
950
+ const handleClose = React.useCallback(() => {
951
+ payment.reset();
952
+ onClose();
953
+ }, [payment, onClose]);
954
+ React.useEffect(() => {
955
+ const handleEscape = (e) => {
956
+ if (e.key === "Escape") handleClose();
957
+ };
958
+ if (open) {
959
+ document.addEventListener("keydown", handleEscape);
960
+ return () => document.removeEventListener("keydown", handleEscape);
961
+ }
962
+ }, [open, handleClose]);
963
+ const handleCopy = React.useCallback(async () => {
964
+ if (payment.quote?.depositAddress) {
965
+ const success = await payment.copyToClipboard(payment.quote.depositAddress);
966
+ if (success) {
967
+ setCopied(true);
968
+ setTimeout(() => setCopied(false), 2e3);
969
+ }
970
+ }
971
+ }, [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(
979
+ "button",
980
+ {
981
+ style: styles.closeButton,
982
+ onClick: handleClose,
983
+ onMouseEnter: (e) => {
984
+ e.currentTarget.style.background = "rgba(255,255,255,0.1)";
985
+ },
986
+ onMouseLeave: (e) => {
987
+ e.currentTarget.style.background = "rgba(255,255,255,0.05)";
988
+ },
989
+ children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
990
+ }
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
+ ")"
1037
+ ] }),
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"
1043
+ ] })
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"
1052
+ ] })
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(
1065
+ qrcode_react.QRCodeSVG,
1066
+ {
1067
+ value: payment.quote.depositAddress,
1068
+ size: 180,
1069
+ level: "M",
1070
+ bgColor: "transparent",
1071
+ fgColor: "white"
1072
+ }
1073
+ ) }),
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
+ ] }),
1080
+ /* @__PURE__ */ jsxRuntime.jsx(
1081
+ "button",
1082
+ {
1083
+ style: styles.copyButton,
1084
+ 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)";
1090
+ },
1091
+ children: copied ? /* @__PURE__ */ jsxRuntime.jsx(CheckSmallIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, {})
1092
+ }
1093
+ )
1094
+ ] }),
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: [
1116
+ payment.amount,
1117
+ " ",
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
+ )) })
1307
+ ] })
1308
+ ] }),
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,
1330
+ " ",
1331
+ 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
+ ] })
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..."
1354
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1355
+ "Confirm Payment",
1356
+ /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, {})
1357
+ ] }) })
1358
+ }
1359
+ )
1360
+ ] })
1361
+ ] }),
1362
+ /* @__PURE__ */ jsxRuntime.jsx(
1363
+ "p",
1364
+ {
1365
+ style: {
1366
+ textAlign: "center",
1367
+ fontSize: "10px",
1368
+ color: "rgba(255,255,255,0.3)",
1369
+ marginTop: "16px"
1370
+ },
1371
+ children: "Powered by Uniport \u2022 NEAR Intents"
1372
+ }
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",
1514
+ {
1515
+ d: "M12 2a10 10 0 019.95 9",
1516
+ stroke: "white",
1517
+ strokeWidth: "3",
1518
+ strokeLinecap: "round"
1519
+ }
1520
+ )
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
+ }
1537
+ );
1538
+ }
1539
+ var buttonStyles = {
1540
+ default: {
1541
+ display: "inline-flex",
1542
+ alignItems: "center",
1543
+ justifyContent: "center",
1544
+ gap: "8px",
1545
+ padding: "12px 24px",
1546
+ fontSize: "14px",
1547
+ fontWeight: 500,
1548
+ color: "white",
1549
+ background: "linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%)",
1550
+ border: "none",
1551
+ borderRadius: "12px",
1552
+ cursor: "pointer",
1553
+ transition: "all 0.2s ease",
1554
+ boxShadow: "0 4px 14px rgba(79, 70, 229, 0.3)",
1555
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1556
+ },
1557
+ compact: {
1558
+ display: "inline-flex",
1559
+ alignItems: "center",
1560
+ justifyContent: "center",
1561
+ gap: "6px",
1562
+ padding: "8px 16px",
1563
+ fontSize: "13px",
1564
+ fontWeight: 500,
1565
+ color: "white",
1566
+ background: "linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%)",
1567
+ border: "none",
1568
+ borderRadius: "8px",
1569
+ cursor: "pointer",
1570
+ transition: "all 0.2s ease",
1571
+ boxShadow: "0 2px 8px rgba(79, 70, 229, 0.25)",
1572
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1573
+ },
1574
+ outline: {
1575
+ display: "inline-flex",
1576
+ alignItems: "center",
1577
+ justifyContent: "center",
1578
+ gap: "8px",
1579
+ padding: "12px 24px",
1580
+ fontSize: "14px",
1581
+ fontWeight: 500,
1582
+ color: "#4F46E5",
1583
+ background: "transparent",
1584
+ border: "2px solid #4F46E5",
1585
+ borderRadius: "12px",
1586
+ cursor: "pointer",
1587
+ transition: "all 0.2s ease",
1588
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1589
+ },
1590
+ disabled: {
1591
+ opacity: 0.5,
1592
+ cursor: "not-allowed"
1593
+ }
1594
+ };
1595
+ function UniportButton({
1596
+ recipient,
1597
+ refundAddress,
1598
+ destinationToken = "suiUSDC",
1599
+ amount,
1600
+ label = "Pay with Crypto",
1601
+ variant = "default",
1602
+ disabled = false,
1603
+ className,
1604
+ onSuccess,
1605
+ onError,
1606
+ onOpenChange
1607
+ }) {
1608
+ const [isOpen, setIsOpen] = React.useState(false);
1609
+ const handleOpen = () => {
1610
+ if (!disabled) {
1611
+ setIsOpen(true);
1612
+ onOpenChange?.(true);
1613
+ }
1614
+ };
1615
+ const handleClose = () => {
1616
+ setIsOpen(false);
1617
+ onOpenChange?.(false);
1618
+ };
1619
+ const style = {
1620
+ ...buttonStyles[variant],
1621
+ ...disabled ? buttonStyles.disabled : {}
1622
+ };
1623
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1624
+ /* @__PURE__ */ jsxRuntime.jsxs(
1625
+ "button",
1626
+ {
1627
+ type: "button",
1628
+ onClick: handleOpen,
1629
+ disabled,
1630
+ className,
1631
+ style,
1632
+ children: [
1633
+ /* @__PURE__ */ jsxRuntime.jsx(UniportIcon, {}),
1634
+ label
1635
+ ]
1636
+ }
1637
+ ),
1638
+ /* @__PURE__ */ jsxRuntime.jsx(
1639
+ UniportModal,
1640
+ {
1641
+ open: isOpen,
1642
+ onClose: handleClose,
1643
+ recipient,
1644
+ refundAddress,
1645
+ destinationToken,
1646
+ amount,
1647
+ onSuccess,
1648
+ onError
1649
+ }
1650
+ )
1651
+ ] });
1652
+ }
1653
+ function UniportIcon() {
1654
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1655
+ "svg",
1656
+ {
1657
+ width: "18",
1658
+ height: "18",
1659
+ viewBox: "0 0 24 24",
1660
+ fill: "none",
1661
+ xmlns: "http://www.w3.org/2000/svg",
1662
+ children: [
1663
+ /* @__PURE__ */ jsxRuntime.jsx(
1664
+ "path",
1665
+ {
1666
+ d: "M12 2L2 7L12 12L22 7L12 2Z",
1667
+ stroke: "currentColor",
1668
+ strokeWidth: "2",
1669
+ strokeLinecap: "round",
1670
+ strokeLinejoin: "round"
1671
+ }
1672
+ ),
1673
+ /* @__PURE__ */ jsxRuntime.jsx(
1674
+ "path",
1675
+ {
1676
+ d: "M2 17L12 22L22 17",
1677
+ stroke: "currentColor",
1678
+ strokeWidth: "2",
1679
+ strokeLinecap: "round",
1680
+ strokeLinejoin: "round"
1681
+ }
1682
+ ),
1683
+ /* @__PURE__ */ jsxRuntime.jsx(
1684
+ "path",
1685
+ {
1686
+ d: "M2 12L12 17L22 12",
1687
+ stroke: "currentColor",
1688
+ strokeWidth: "2",
1689
+ strokeLinecap: "round",
1690
+ strokeLinejoin: "round"
1691
+ }
1692
+ )
1693
+ ]
1694
+ }
1695
+ );
1696
+ }
1697
+
1698
+ exports.UniportButton = UniportButton;
1699
+ exports.UniportModal = UniportModal;
1700
+ //# sourceMappingURL=index.cjs.map
1701
+ //# sourceMappingURL=index.cjs.map