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