@voyage_ai/v402-web-ts 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +38 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react/chunk-WDPIFLXY.mjs +633 -0
- package/dist/react/chunk-WDPIFLXY.mjs.map +1 -0
- package/dist/react/index.d.mts +1 -28
- package/dist/react/index.d.ts +1 -28
- package/dist/react/index.js +474 -870
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +128 -1130
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/styles.css +1 -1
- package/dist/react/wallet-discovery-RN3DPV6V.mjs +35 -0
- package/dist/react/wallet-discovery-RN3DPV6V.mjs.map +1 -0
- package/package.json +4 -12
package/dist/react/index.js
CHANGED
|
@@ -314,12 +314,320 @@ var init_wallet = __esm({
|
|
|
314
314
|
}
|
|
315
315
|
});
|
|
316
316
|
|
|
317
|
+
// src/utils/wallet-discovery.ts
|
|
318
|
+
var wallet_discovery_exports = {};
|
|
319
|
+
__export(wallet_discovery_exports, {
|
|
320
|
+
clearConnectedWallet: () => clearConnectedWallet,
|
|
321
|
+
connectEVMWallet: () => connectEVMWallet,
|
|
322
|
+
connectSolanaWallet: () => connectSolanaWallet,
|
|
323
|
+
connectToWallet: () => connectToWallet,
|
|
324
|
+
getCurrentConnectedWallet: () => getCurrentConnectedWallet,
|
|
325
|
+
getEVMWallets: () => getEVMWallets,
|
|
326
|
+
getSolanaWallets: () => getSolanaWallets,
|
|
327
|
+
getValidatedWalletProvider: () => getValidatedWalletProvider,
|
|
328
|
+
getWalletById: () => getWalletById,
|
|
329
|
+
getWalletByName: () => getWalletByName,
|
|
330
|
+
getWalletProviderForPayment: () => getWalletProviderForPayment,
|
|
331
|
+
getWalletsForNetwork: () => getWalletsForNetwork,
|
|
332
|
+
initEVMWalletDiscovery: () => initEVMWalletDiscovery,
|
|
333
|
+
onEVMWalletsChanged: () => onEVMWalletsChanged,
|
|
334
|
+
setCurrentConnectedWallet: () => setCurrentConnectedWallet
|
|
335
|
+
});
|
|
336
|
+
function initEVMWalletDiscovery() {
|
|
337
|
+
if (typeof window === "undefined" || evmDiscoveryInitialized) return;
|
|
338
|
+
evmDiscoveryInitialized = true;
|
|
339
|
+
window.addEventListener("eip6963:announceProvider", ((event) => {
|
|
340
|
+
const { info, provider } = event.detail;
|
|
341
|
+
evmWallets.set(info.uuid, { info, provider });
|
|
342
|
+
evmDiscoveryListeners.forEach((listener) => listener());
|
|
343
|
+
}));
|
|
344
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
345
|
+
}
|
|
346
|
+
function getEVMWallets() {
|
|
347
|
+
const wallets = [];
|
|
348
|
+
const detectedNames = /* @__PURE__ */ new Set();
|
|
349
|
+
evmWallets.forEach((detail, uuid) => {
|
|
350
|
+
if (!detectedNames.has(detail.info.name)) {
|
|
351
|
+
wallets.push({
|
|
352
|
+
id: uuid,
|
|
353
|
+
name: detail.info.name,
|
|
354
|
+
icon: detail.info.icon,
|
|
355
|
+
networkType: "evm" /* EVM */,
|
|
356
|
+
provider: detail.provider,
|
|
357
|
+
installed: true
|
|
358
|
+
});
|
|
359
|
+
detectedNames.add(detail.info.name);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
if (wallets.length === 0 && typeof window !== "undefined" && window.ethereum) {
|
|
363
|
+
const ethereum = window.ethereum;
|
|
364
|
+
const walletName = ethereum.isMetaMask ? "MetaMask" : ethereum.isCoinbaseWallet ? "Coinbase Wallet" : ethereum.isOkxWallet ? "OKX Wallet" : "Browser Wallet";
|
|
365
|
+
if (!detectedNames.has(walletName)) {
|
|
366
|
+
wallets.push({
|
|
367
|
+
id: "injected",
|
|
368
|
+
name: walletName,
|
|
369
|
+
icon: "",
|
|
370
|
+
// Will use first letter as avatar
|
|
371
|
+
networkType: "evm" /* EVM */,
|
|
372
|
+
provider: ethereum,
|
|
373
|
+
installed: true
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return wallets;
|
|
378
|
+
}
|
|
379
|
+
function onEVMWalletsChanged(callback) {
|
|
380
|
+
evmDiscoveryListeners.add(callback);
|
|
381
|
+
return () => {
|
|
382
|
+
evmDiscoveryListeners.delete(callback);
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function getSolanaWallets() {
|
|
386
|
+
if (typeof window === "undefined") return [];
|
|
387
|
+
const wallets = [];
|
|
388
|
+
const detectedProviders = /* @__PURE__ */ new Set();
|
|
389
|
+
const detectedNames = /* @__PURE__ */ new Set();
|
|
390
|
+
for (const wallet of SOLANA_WALLETS) {
|
|
391
|
+
const provider = wallet.detect();
|
|
392
|
+
if (provider && !detectedNames.has(wallet.name)) {
|
|
393
|
+
wallets.push({
|
|
394
|
+
id: wallet.id,
|
|
395
|
+
name: wallet.name,
|
|
396
|
+
icon: wallet.icon,
|
|
397
|
+
networkType: "solana" /* SOLANA */,
|
|
398
|
+
provider,
|
|
399
|
+
installed: true
|
|
400
|
+
});
|
|
401
|
+
detectedProviders.add(provider);
|
|
402
|
+
detectedNames.add(wallet.name);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const windowSolana = window.solana;
|
|
406
|
+
if (windowSolana && !detectedProviders.has(windowSolana)) {
|
|
407
|
+
const walletName = windowSolana.isPhantom ? "Phantom" : windowSolana.isSolflare ? "Solflare" : windowSolana.isBackpack ? "Backpack" : windowSolana.walletName || "Solana Wallet";
|
|
408
|
+
if (!detectedNames.has(walletName)) {
|
|
409
|
+
wallets.push({
|
|
410
|
+
id: "solana-unknown",
|
|
411
|
+
name: walletName,
|
|
412
|
+
icon: "",
|
|
413
|
+
// Will use first letter as avatar
|
|
414
|
+
networkType: "solana" /* SOLANA */,
|
|
415
|
+
provider: windowSolana,
|
|
416
|
+
installed: true
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return wallets;
|
|
421
|
+
}
|
|
422
|
+
function getWalletsForNetwork(networkType) {
|
|
423
|
+
switch (networkType) {
|
|
424
|
+
case "evm" /* EVM */:
|
|
425
|
+
return getEVMWallets();
|
|
426
|
+
case "solana" /* SOLANA */:
|
|
427
|
+
case "svm" /* SVM */:
|
|
428
|
+
return getSolanaWallets();
|
|
429
|
+
default:
|
|
430
|
+
return [];
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function getWalletById(id, networkType) {
|
|
434
|
+
const wallets = getWalletsForNetwork(networkType);
|
|
435
|
+
return wallets.find((w) => w.id === id) || null;
|
|
436
|
+
}
|
|
437
|
+
function getWalletByName(name, networkType) {
|
|
438
|
+
const wallets = getWalletsForNetwork(networkType);
|
|
439
|
+
return wallets.find((w) => w.name === name) || null;
|
|
440
|
+
}
|
|
441
|
+
async function connectEVMWallet(wallet) {
|
|
442
|
+
if (!wallet.provider) {
|
|
443
|
+
throw new Error(`Wallet ${wallet.name} is not available`);
|
|
444
|
+
}
|
|
445
|
+
const accounts = await wallet.provider.request({
|
|
446
|
+
method: "eth_requestAccounts",
|
|
447
|
+
params: []
|
|
448
|
+
});
|
|
449
|
+
if (!accounts || accounts.length === 0) {
|
|
450
|
+
throw new Error("Failed to get wallet address");
|
|
451
|
+
}
|
|
452
|
+
return accounts[0];
|
|
453
|
+
}
|
|
454
|
+
async function connectSolanaWallet(wallet) {
|
|
455
|
+
if (!wallet.provider) {
|
|
456
|
+
throw new Error(`Wallet ${wallet.name} is not available`);
|
|
457
|
+
}
|
|
458
|
+
if (wallet.provider.isConnected) {
|
|
459
|
+
try {
|
|
460
|
+
await wallet.provider.disconnect();
|
|
461
|
+
} catch (err) {
|
|
462
|
+
console.warn("Failed to disconnect before connecting:", err);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const response = await wallet.provider.connect();
|
|
466
|
+
return response.publicKey.toString();
|
|
467
|
+
}
|
|
468
|
+
async function connectToWallet(wallet) {
|
|
469
|
+
let address;
|
|
470
|
+
switch (wallet.networkType) {
|
|
471
|
+
case "evm" /* EVM */:
|
|
472
|
+
address = await connectEVMWallet(wallet);
|
|
473
|
+
break;
|
|
474
|
+
case "solana" /* SOLANA */:
|
|
475
|
+
case "svm" /* SVM */:
|
|
476
|
+
address = await connectSolanaWallet(wallet);
|
|
477
|
+
break;
|
|
478
|
+
default:
|
|
479
|
+
throw new Error("Unsupported network type");
|
|
480
|
+
}
|
|
481
|
+
currentConnectedWallet = wallet;
|
|
482
|
+
saveConnectedWalletId(wallet.networkType, wallet.name);
|
|
483
|
+
return address;
|
|
484
|
+
}
|
|
485
|
+
function getCurrentConnectedWallet() {
|
|
486
|
+
return currentConnectedWallet;
|
|
487
|
+
}
|
|
488
|
+
function setCurrentConnectedWallet(wallet) {
|
|
489
|
+
currentConnectedWallet = wallet;
|
|
490
|
+
}
|
|
491
|
+
function clearConnectedWallet(networkType) {
|
|
492
|
+
if (networkType) {
|
|
493
|
+
removeConnectedWalletId(networkType);
|
|
494
|
+
}
|
|
495
|
+
currentConnectedWallet = null;
|
|
496
|
+
}
|
|
497
|
+
function restoreConnectedWallet(networkType) {
|
|
498
|
+
const savedWalletName = getConnectedWalletId(networkType);
|
|
499
|
+
if (!savedWalletName) {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
const wallet = getWalletByName(savedWalletName, networkType);
|
|
503
|
+
if (wallet) {
|
|
504
|
+
currentConnectedWallet = wallet;
|
|
505
|
+
if ((networkType === "solana" /* SOLANA */ || networkType === "svm" /* SVM */) && wallet.provider) {
|
|
506
|
+
const providerPublicKey = wallet.provider.publicKey?.toString();
|
|
507
|
+
const cachedAddress = getCachedWalletAddress(networkType);
|
|
508
|
+
if (providerPublicKey && cachedAddress && providerPublicKey !== cachedAddress) {
|
|
509
|
+
saveWalletAddress(networkType, providerPublicKey);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return wallet;
|
|
513
|
+
}
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
function getWalletProviderForPayment(networkType) {
|
|
517
|
+
if (currentConnectedWallet && currentConnectedWallet.networkType === networkType) {
|
|
518
|
+
return currentConnectedWallet.provider;
|
|
519
|
+
}
|
|
520
|
+
const restoredWallet = restoreConnectedWallet(networkType);
|
|
521
|
+
if (restoredWallet) {
|
|
522
|
+
return restoredWallet.provider;
|
|
523
|
+
}
|
|
524
|
+
if (typeof window === "undefined") return null;
|
|
525
|
+
switch (networkType) {
|
|
526
|
+
case "evm" /* EVM */:
|
|
527
|
+
return window.ethereum;
|
|
528
|
+
case "solana" /* SOLANA */:
|
|
529
|
+
case "svm" /* SVM */:
|
|
530
|
+
return window.phantom?.solana || window.solana;
|
|
531
|
+
default:
|
|
532
|
+
return null;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
async function getValidatedWalletProvider(networkType, expectedAddress) {
|
|
536
|
+
const provider = getWalletProviderForPayment(networkType);
|
|
537
|
+
if (!provider) {
|
|
538
|
+
return { provider: null, isValid: false };
|
|
539
|
+
}
|
|
540
|
+
if (networkType === "evm" /* EVM */) {
|
|
541
|
+
try {
|
|
542
|
+
const accounts = await provider.request({ method: "eth_accounts", params: [] });
|
|
543
|
+
const currentAddress = accounts?.[0];
|
|
544
|
+
const isValid = currentAddress?.toLowerCase() === expectedAddress?.toLowerCase();
|
|
545
|
+
if (!isValid) {
|
|
546
|
+
console.warn(`\u26A0\uFE0F Account mismatch: expected ${expectedAddress}, got ${currentAddress}`);
|
|
547
|
+
}
|
|
548
|
+
return { provider, isValid, currentAddress };
|
|
549
|
+
} catch (error) {
|
|
550
|
+
console.error("Failed to get current account:", error);
|
|
551
|
+
return { provider, isValid: false };
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (networkType === "solana" /* SOLANA */ || networkType === "svm" /* SVM */) {
|
|
555
|
+
if (provider.isConnected && provider.publicKey) {
|
|
556
|
+
const currentAddress = provider.publicKey.toString();
|
|
557
|
+
const isValid = currentAddress === expectedAddress;
|
|
558
|
+
if (!isValid) {
|
|
559
|
+
console.warn(`\u26A0\uFE0F Account mismatch: expected ${expectedAddress}, got ${currentAddress}`);
|
|
560
|
+
}
|
|
561
|
+
return { provider, isValid, currentAddress };
|
|
562
|
+
}
|
|
563
|
+
return { provider, isValid: false };
|
|
564
|
+
}
|
|
565
|
+
return { provider, isValid: true };
|
|
566
|
+
}
|
|
567
|
+
var SOLANA_WALLETS, evmWallets, evmDiscoveryListeners, evmDiscoveryInitialized, currentConnectedWallet;
|
|
568
|
+
var init_wallet_discovery = __esm({
|
|
569
|
+
"src/utils/wallet-discovery.ts"() {
|
|
570
|
+
"use strict";
|
|
571
|
+
init_wallet();
|
|
572
|
+
SOLANA_WALLETS = [
|
|
573
|
+
{
|
|
574
|
+
id: "phantom",
|
|
575
|
+
name: "Phantom",
|
|
576
|
+
// Phantom official icon
|
|
577
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZD0iTTExMC41IDY0QzExMC41IDg5Ljk1NjggODkuMjAxIDExMSA2My41IDExMUg0MS41QzM2LjI1MzMgMTExIDMyIDEwNi43NDcgMzIgMTAxLjVWNTQuNUMzMiAzMS4wMjggNTEuMDI4IDEyIDc0LjUgMTJDOTcuOTcyIDEyIDExNyAzMS4wMjggMTE3IDU0LjVWNTUuNUMxMTcgNTguNTM3NiAxMTQuNTM4IDYxIDExMS41IDYxSDEwOS41QzEwNi40NjIgNjEgMTA0IDYzLjQ2MjQgMTA0IDY2LjVWNjhDMTA0IDcxLjg2NiAxMDcuMTM0IDc1IDExMSA3NUgxMTEuNUMxMTQuNTM4IDc1IDExNyA3Mi41Mzc2IDExNyA2OS41VjY0SDExMC41WiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzEyOF8xMjgpIi8+CjxwYXRoIGQ9Ik00OC41IDY3QzUxLjUzNzYgNjcgNTQgNjQuNTM3NiA1NCA2MS41QzU0IDU4LjQ2MjQgNTEuNTM3NiA1NiA0OC41IDU2QzQ1LjQ2MjQgNTYgNDMgNTguNDYyNCA0MyA2MS41QzQzIDY0LjUzNzYgNDUuNDYyNCA2NyA0OC41IDY3WiIgZmlsbD0iIzFCMUIxQiIvPgo8cGF0aCBkPSJNNzMuNSA2N0M3Ni41Mzc2IDY3IDc5IDY0LjUzNzYgNzkgNjEuNUM3OSA1OC40NjI0IDc2LjUzNzYgNTYgNzMuNSA1NkM3MC40NjI0IDU2IDY4IDU4LjQ2MjQgNjggNjEuNUM2OCA2NC41Mzc2IDcwLjQ2MjQgNjcgNzMuNSA2N1oiIGZpbGw9IiMxQjFCMUIiLz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl8xMjhfMTI4IiB4MT0iMTE3IiB5MT0iMTIiIHgyPSIxMTciIHkyPSIxMTEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGRkZGRkYiIHN0b3Atb3BhY2l0eT0iMC44MiIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPg==",
|
|
578
|
+
detect: () => window.phantom?.solana
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
id: "solflare",
|
|
582
|
+
name: "Solflare",
|
|
583
|
+
// Solflare icon
|
|
584
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiNGQzZEMDEiLz4KPHBhdGggZD0iTTk2IDY0TDY0IDMyTDMyIDY0TDY0IDk2TDk2IDY0WiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+",
|
|
585
|
+
detect: () => window.solflare
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
id: "backpack",
|
|
589
|
+
name: "Backpack",
|
|
590
|
+
// Backpack icon (red coral color)
|
|
591
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiNFMzM0MzAiLz4KPHBhdGggZD0iTTQwIDQ4SDg4VjgwQzg4IDg4LjgzNjYgODAuODM2NiA5NiA3MiA5Nkg1NkM0Ny4xNjM0IDk2IDQwIDg4LjgzNjYgNDAgODBWNDhaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNNTIgMzJINzZWNDhINTJWMzJaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4=",
|
|
592
|
+
detect: () => window.backpack
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
id: "okx-solana",
|
|
596
|
+
name: "OKX Wallet",
|
|
597
|
+
// OKX icon
|
|
598
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9ImJsYWNrIi8+CjxyZWN0IHg9IjI0IiB5PSIyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iNCIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iNTIiIHk9IjI0IiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHJ4PSI0IiBmaWxsPSJ3aGl0ZSIvPgo8cmVjdCB4PSI4MCIgeT0iMjQiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgcng9IjQiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjI0IiB5PSI1MiIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iNCIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iODAiIHk9IjUyIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHJ4PSI0IiBmaWxsPSJ3aGl0ZSIvPgo8cmVjdCB4PSIyNCIgeT0iODAiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgcng9IjQiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjUyIiB5PSI4MCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iNCIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iODAiIHk9IjgwIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHJ4PSI0IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4=",
|
|
599
|
+
detect: () => window.okxwallet?.solana
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
id: "coinbase-solana",
|
|
603
|
+
name: "Coinbase Wallet",
|
|
604
|
+
// Coinbase icon (blue)
|
|
605
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiMwMDUyRkYiLz4KPGNpcmNsZSBjeD0iNjQiIGN5PSI2NCIgcj0iMzYiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjQ4IiB5PSI1NiIgd2lkdGg9IjMyIiBoZWlnaHQ9IjE2IiByeD0iNCIgZmlsbD0iIzAwNTJGRiIvPgo8L3N2Zz4=",
|
|
606
|
+
detect: () => window.coinbaseSolana
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
id: "trust-solana",
|
|
610
|
+
name: "Trust Wallet",
|
|
611
|
+
// Trust Wallet icon
|
|
612
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiMwNTAwRkYiLz4KPHBhdGggZD0iTTY0IDI0QzY0IDI0IDk2IDQwIDk2IDY0Qzk2IDg4IDY0IDEwNCA2NCAxMDRDNjQgMTA0IDMyIDg4IDMyIDY0QzMyIDQwIDY0IDI0IDY0IDI0WiIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSI2IiBmaWxsPSJub25lIi8+Cjwvc3ZnPg==",
|
|
613
|
+
detect: () => window.trustwallet?.solana
|
|
614
|
+
}
|
|
615
|
+
];
|
|
616
|
+
evmWallets = /* @__PURE__ */ new Map();
|
|
617
|
+
evmDiscoveryListeners = /* @__PURE__ */ new Set();
|
|
618
|
+
evmDiscoveryInitialized = false;
|
|
619
|
+
currentConnectedWallet = null;
|
|
620
|
+
if (typeof window !== "undefined") {
|
|
621
|
+
initEVMWalletDiscovery();
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
|
|
317
626
|
// src/react/index.ts
|
|
318
627
|
var index_exports = {};
|
|
319
628
|
__export(index_exports, {
|
|
320
629
|
AnimationStyles: () => AnimationStyles,
|
|
321
630
|
Toast: () => Toast,
|
|
322
|
-
V402Checkout: () => V402Checkout,
|
|
323
631
|
V402CheckoutV2: () => V402CheckoutV2,
|
|
324
632
|
WalletConnect: () => WalletConnect,
|
|
325
633
|
WalletSelectModal: () => WalletSelectModal,
|
|
@@ -503,317 +811,77 @@ async function getCurrentWallet(networkType) {
|
|
|
503
811
|
return null;
|
|
504
812
|
}
|
|
505
813
|
}
|
|
506
|
-
return null;
|
|
507
|
-
}
|
|
508
|
-
if (type === "solana" /* SOLANA */ || type === "svm" /* SVM */) {
|
|
509
|
-
const solana = window.solana;
|
|
510
|
-
if (!solana || !solana.isConnected) {
|
|
511
|
-
return cachedAddress;
|
|
512
|
-
}
|
|
513
|
-
return solana.publicKey?.toString() || cachedAddress;
|
|
514
|
-
}
|
|
515
|
-
return cachedAddress;
|
|
516
|
-
}
|
|
517
|
-
function onAccountsChanged(callback) {
|
|
518
|
-
if (typeof window === "undefined" || !window.ethereum) {
|
|
519
|
-
return () => {
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
const ethereum = window.ethereum;
|
|
523
|
-
const handler = (accounts) => {
|
|
524
|
-
callback(accounts);
|
|
525
|
-
};
|
|
526
|
-
ethereum.on("accountsChanged", handler);
|
|
527
|
-
return () => {
|
|
528
|
-
ethereum.removeListener?.("accountsChanged", handler);
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
function onChainChanged(callback) {
|
|
532
|
-
if (typeof window === "undefined" || !window.ethereum) {
|
|
533
|
-
return () => {
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
const ethereum = window.ethereum;
|
|
537
|
-
const handler = (chainId) => {
|
|
538
|
-
console.log("\u{1F504} Chain changed to:", chainId);
|
|
539
|
-
callback(chainId);
|
|
540
|
-
};
|
|
541
|
-
ethereum.on("chainChanged", handler);
|
|
542
|
-
return () => {
|
|
543
|
-
ethereum.removeListener?.("chainChanged", handler);
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
function onWalletDisconnect(callback) {
|
|
547
|
-
if (typeof window === "undefined") {
|
|
548
|
-
return () => {
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
const solana = window.solana;
|
|
552
|
-
if (!solana) {
|
|
553
|
-
return () => {
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
const handler = () => {
|
|
557
|
-
console.log("\u{1F50C} Solana wallet disconnected");
|
|
558
|
-
callback();
|
|
559
|
-
};
|
|
560
|
-
solana.on("disconnect", handler);
|
|
561
|
-
return () => {
|
|
562
|
-
solana.removeListener?.("disconnect", handler);
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
async function switchNetwork(networkType) {
|
|
566
|
-
const cachedAddress = getCachedWalletAddress(networkType);
|
|
567
|
-
if (cachedAddress) {
|
|
568
|
-
saveConnectedNetworkType(networkType);
|
|
569
|
-
clearWalletDisconnection(networkType);
|
|
570
|
-
const currentAddress = await getCurrentWallet(networkType);
|
|
571
|
-
if (currentAddress) {
|
|
572
|
-
return currentAddress;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
return null;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// src/utils/wallet-discovery.ts
|
|
579
|
-
init_wallet();
|
|
580
|
-
var SOLANA_WALLETS = [
|
|
581
|
-
{
|
|
582
|
-
id: "phantom",
|
|
583
|
-
name: "Phantom",
|
|
584
|
-
// Phantom official icon
|
|
585
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZD0iTTExMC41IDY0QzExMC41IDg5Ljk1NjggODkuMjAxIDExMSA2My41IDExMUg0MS41QzM2LjI1MzMgMTExIDMyIDEwNi43NDcgMzIgMTAxLjVWNTQuNUMzMiAzMS4wMjggNTEuMDI4IDEyIDc0LjUgMTJDOTcuOTcyIDEyIDExNyAzMS4wMjggMTE3IDU0LjVWNTUuNUMxMTcgNTguNTM3NiAxMTQuNTM4IDYxIDExMS41IDYxSDEwOS41QzEwNi40NjIgNjEgMTA0IDYzLjQ2MjQgMTA0IDY2LjVWNjhDMTA0IDcxLjg2NiAxMDcuMTM0IDc1IDExMSA3NUgxMTEuNUMxMTQuNTM4IDc1IDExNyA3Mi41Mzc2IDExNyA2OS41VjY0SDExMC41WiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzEyOF8xMjgpIi8+CjxwYXRoIGQ9Ik00OC41IDY3QzUxLjUzNzYgNjcgNTQgNjQuNTM3NiA1NCA2MS41QzU0IDU4LjQ2MjQgNTEuNTM3NiA1NiA0OC41IDU2QzQ1LjQ2MjQgNTYgNDMgNTguNDYyNCA0MyA2MS41QzQzIDY0LjUzNzYgNDUuNDYyNCA2NyA0OC41IDY3WiIgZmlsbD0iIzFCMUIxQiIvPgo8cGF0aCBkPSJNNzMuNSA2N0M3Ni41Mzc2IDY3IDc5IDY0LjUzNzYgNzkgNjEuNUM3OSA1OC40NjI0IDc2LjUzNzYgNTYgNzMuNSA1NkM3MC40NjI0IDU2IDY4IDU4LjQ2MjQgNjggNjEuNUM2OCA2NC41Mzc2IDcwLjQ2MjQgNjcgNzMuNSA2N1oiIGZpbGw9IiMxQjFCMUIiLz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl8xMjhfMTI4IiB4MT0iMTE3IiB5MT0iMTIiIHgyPSIxMTciIHkyPSIxMTEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGRkZGRkYiIHN0b3Atb3BhY2l0eT0iMC44MiIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPg==",
|
|
586
|
-
detect: () => window.phantom?.solana
|
|
587
|
-
},
|
|
588
|
-
{
|
|
589
|
-
id: "solflare",
|
|
590
|
-
name: "Solflare",
|
|
591
|
-
// Solflare icon
|
|
592
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiNGQzZEMDEiLz4KPHBhdGggZD0iTTk2IDY0TDY0IDMyTDMyIDY0TDY0IDk2TDk2IDY0WiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+",
|
|
593
|
-
detect: () => window.solflare
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
id: "backpack",
|
|
597
|
-
name: "Backpack",
|
|
598
|
-
// Backpack icon (red coral color)
|
|
599
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiNFMzM0MzAiLz4KPHBhdGggZD0iTTQwIDQ4SDg4VjgwQzg4IDg4LjgzNjYgODAuODM2NiA5NiA3MiA5Nkg1NkM0Ny4xNjM0IDk2IDQwIDg4LjgzNjYgNDAgODBWNDhaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNNTIgMzJINzZWNDhINTJWMzJaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4=",
|
|
600
|
-
detect: () => window.backpack
|
|
601
|
-
},
|
|
602
|
-
{
|
|
603
|
-
id: "okx-solana",
|
|
604
|
-
name: "OKX Wallet",
|
|
605
|
-
// OKX icon
|
|
606
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9ImJsYWNrIi8+CjxyZWN0IHg9IjI0IiB5PSIyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iNCIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iNTIiIHk9IjI0IiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHJ4PSI0IiBmaWxsPSJ3aGl0ZSIvPgo8cmVjdCB4PSI4MCIgeT0iMjQiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgcng9IjQiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjI0IiB5PSI1MiIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iNCIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iODAiIHk9IjUyIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHJ4PSI0IiBmaWxsPSJ3aGl0ZSIvPgo8cmVjdCB4PSIyNCIgeT0iODAiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgcng9IjQiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjUyIiB5PSI4MCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iNCIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iODAiIHk9IjgwIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHJ4PSI0IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4=",
|
|
607
|
-
detect: () => window.okxwallet?.solana
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
id: "coinbase-solana",
|
|
611
|
-
name: "Coinbase Wallet",
|
|
612
|
-
// Coinbase icon (blue)
|
|
613
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiMwMDUyRkYiLz4KPGNpcmNsZSBjeD0iNjQiIGN5PSI2NCIgcj0iMzYiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjQ4IiB5PSI1NiIgd2lkdGg9IjMyIiBoZWlnaHQ9IjE2IiByeD0iNCIgZmlsbD0iIzAwNTJGRiIvPgo8L3N2Zz4=",
|
|
614
|
-
detect: () => window.coinbaseSolana
|
|
615
|
-
},
|
|
616
|
-
{
|
|
617
|
-
id: "trust-solana",
|
|
618
|
-
name: "Trust Wallet",
|
|
619
|
-
// Trust Wallet icon
|
|
620
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4IiByeD0iMjYiIGZpbGw9IiMwNTAwRkYiLz4KPHBhdGggZD0iTTY0IDI0QzY0IDI0IDk2IDQwIDk2IDY0Qzk2IDg4IDY0IDEwNCA2NCAxMDRDNjQgMTA0IDMyIDg4IDMyIDY0QzMyIDQwIDY0IDI0IDY0IDI0WiIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSI2IiBmaWxsPSJub25lIi8+Cjwvc3ZnPg==",
|
|
621
|
-
detect: () => window.trustwallet?.solana
|
|
622
|
-
}
|
|
623
|
-
];
|
|
624
|
-
var evmWallets = /* @__PURE__ */ new Map();
|
|
625
|
-
var evmDiscoveryListeners = /* @__PURE__ */ new Set();
|
|
626
|
-
var evmDiscoveryInitialized = false;
|
|
627
|
-
var currentConnectedWallet = null;
|
|
628
|
-
function initEVMWalletDiscovery() {
|
|
629
|
-
if (typeof window === "undefined" || evmDiscoveryInitialized) return;
|
|
630
|
-
evmDiscoveryInitialized = true;
|
|
631
|
-
window.addEventListener("eip6963:announceProvider", ((event) => {
|
|
632
|
-
const { info, provider } = event.detail;
|
|
633
|
-
evmWallets.set(info.uuid, { info, provider });
|
|
634
|
-
evmDiscoveryListeners.forEach((listener) => listener());
|
|
635
|
-
}));
|
|
636
|
-
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
637
|
-
}
|
|
638
|
-
function getEVMWallets() {
|
|
639
|
-
const wallets = [];
|
|
640
|
-
const detectedNames = /* @__PURE__ */ new Set();
|
|
641
|
-
evmWallets.forEach((detail, uuid) => {
|
|
642
|
-
if (!detectedNames.has(detail.info.name)) {
|
|
643
|
-
wallets.push({
|
|
644
|
-
id: uuid,
|
|
645
|
-
name: detail.info.name,
|
|
646
|
-
icon: detail.info.icon,
|
|
647
|
-
networkType: "evm" /* EVM */,
|
|
648
|
-
provider: detail.provider,
|
|
649
|
-
installed: true
|
|
650
|
-
});
|
|
651
|
-
detectedNames.add(detail.info.name);
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
if (wallets.length === 0 && typeof window !== "undefined" && window.ethereum) {
|
|
655
|
-
const ethereum = window.ethereum;
|
|
656
|
-
const walletName = ethereum.isMetaMask ? "MetaMask" : ethereum.isCoinbaseWallet ? "Coinbase Wallet" : ethereum.isOkxWallet ? "OKX Wallet" : "Browser Wallet";
|
|
657
|
-
if (!detectedNames.has(walletName)) {
|
|
658
|
-
wallets.push({
|
|
659
|
-
id: "injected",
|
|
660
|
-
name: walletName,
|
|
661
|
-
icon: "",
|
|
662
|
-
// Will use first letter as avatar
|
|
663
|
-
networkType: "evm" /* EVM */,
|
|
664
|
-
provider: ethereum,
|
|
665
|
-
installed: true
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
return wallets;
|
|
670
|
-
}
|
|
671
|
-
function onEVMWalletsChanged(callback) {
|
|
672
|
-
evmDiscoveryListeners.add(callback);
|
|
673
|
-
return () => {
|
|
674
|
-
evmDiscoveryListeners.delete(callback);
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
function getSolanaWallets() {
|
|
678
|
-
if (typeof window === "undefined") return [];
|
|
679
|
-
const wallets = [];
|
|
680
|
-
const detectedProviders = /* @__PURE__ */ new Set();
|
|
681
|
-
const detectedNames = /* @__PURE__ */ new Set();
|
|
682
|
-
for (const wallet of SOLANA_WALLETS) {
|
|
683
|
-
const provider = wallet.detect();
|
|
684
|
-
if (provider && !detectedNames.has(wallet.name)) {
|
|
685
|
-
wallets.push({
|
|
686
|
-
id: wallet.id,
|
|
687
|
-
name: wallet.name,
|
|
688
|
-
icon: wallet.icon,
|
|
689
|
-
networkType: "solana" /* SOLANA */,
|
|
690
|
-
provider,
|
|
691
|
-
installed: true
|
|
692
|
-
});
|
|
693
|
-
detectedProviders.add(provider);
|
|
694
|
-
detectedNames.add(wallet.name);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
const windowSolana = window.solana;
|
|
698
|
-
if (windowSolana && !detectedProviders.has(windowSolana)) {
|
|
699
|
-
const walletName = windowSolana.isPhantom ? "Phantom" : windowSolana.isSolflare ? "Solflare" : windowSolana.isBackpack ? "Backpack" : windowSolana.walletName || "Solana Wallet";
|
|
700
|
-
if (!detectedNames.has(walletName)) {
|
|
701
|
-
wallets.push({
|
|
702
|
-
id: "solana-unknown",
|
|
703
|
-
name: walletName,
|
|
704
|
-
icon: "",
|
|
705
|
-
// Will use first letter as avatar
|
|
706
|
-
networkType: "solana" /* SOLANA */,
|
|
707
|
-
provider: windowSolana,
|
|
708
|
-
installed: true
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
return wallets;
|
|
713
|
-
}
|
|
714
|
-
function getWalletsForNetwork(networkType) {
|
|
715
|
-
switch (networkType) {
|
|
716
|
-
case "evm" /* EVM */:
|
|
717
|
-
return getEVMWallets();
|
|
718
|
-
case "solana" /* SOLANA */:
|
|
719
|
-
case "svm" /* SVM */:
|
|
720
|
-
return getSolanaWallets();
|
|
721
|
-
default:
|
|
722
|
-
return [];
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
function getWalletByName(name, networkType) {
|
|
726
|
-
const wallets = getWalletsForNetwork(networkType);
|
|
727
|
-
return wallets.find((w) => w.name === name) || null;
|
|
728
|
-
}
|
|
729
|
-
async function connectEVMWallet(wallet) {
|
|
730
|
-
if (!wallet.provider) {
|
|
731
|
-
throw new Error(`Wallet ${wallet.name} is not available`);
|
|
732
|
-
}
|
|
733
|
-
const accounts = await wallet.provider.request({
|
|
734
|
-
method: "eth_requestAccounts",
|
|
735
|
-
params: []
|
|
736
|
-
});
|
|
737
|
-
if (!accounts || accounts.length === 0) {
|
|
738
|
-
throw new Error("Failed to get wallet address");
|
|
739
|
-
}
|
|
740
|
-
return accounts[0];
|
|
741
|
-
}
|
|
742
|
-
async function connectSolanaWallet(wallet) {
|
|
743
|
-
if (!wallet.provider) {
|
|
744
|
-
throw new Error(`Wallet ${wallet.name} is not available`);
|
|
745
|
-
}
|
|
746
|
-
if (wallet.provider.isConnected) {
|
|
747
|
-
try {
|
|
748
|
-
await wallet.provider.disconnect();
|
|
749
|
-
} catch (err) {
|
|
750
|
-
console.warn("Failed to disconnect before connecting:", err);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
const response = await wallet.provider.connect();
|
|
754
|
-
return response.publicKey.toString();
|
|
755
|
-
}
|
|
756
|
-
async function connectToWallet(wallet) {
|
|
757
|
-
let address;
|
|
758
|
-
switch (wallet.networkType) {
|
|
759
|
-
case "evm" /* EVM */:
|
|
760
|
-
address = await connectEVMWallet(wallet);
|
|
761
|
-
break;
|
|
762
|
-
case "solana" /* SOLANA */:
|
|
763
|
-
case "svm" /* SVM */:
|
|
764
|
-
address = await connectSolanaWallet(wallet);
|
|
765
|
-
break;
|
|
766
|
-
default:
|
|
767
|
-
throw new Error("Unsupported network type");
|
|
768
|
-
}
|
|
769
|
-
currentConnectedWallet = wallet;
|
|
770
|
-
saveConnectedWalletId(wallet.networkType, wallet.name);
|
|
771
|
-
return address;
|
|
772
|
-
}
|
|
773
|
-
function setCurrentConnectedWallet(wallet) {
|
|
774
|
-
currentConnectedWallet = wallet;
|
|
775
|
-
}
|
|
776
|
-
function clearConnectedWallet(networkType) {
|
|
777
|
-
if (networkType) {
|
|
778
|
-
removeConnectedWalletId(networkType);
|
|
814
|
+
return null;
|
|
779
815
|
}
|
|
780
|
-
|
|
816
|
+
if (type === "solana" /* SOLANA */ || type === "svm" /* SVM */) {
|
|
817
|
+
return cachedAddress;
|
|
818
|
+
}
|
|
819
|
+
return cachedAddress;
|
|
781
820
|
}
|
|
782
|
-
function
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
if (wallet) {
|
|
787
|
-
currentConnectedWallet = wallet;
|
|
788
|
-
console.log(`\u2705 Restored wallet provider: ${wallet.name}`);
|
|
789
|
-
return wallet;
|
|
821
|
+
function onAccountsChanged(callback) {
|
|
822
|
+
if (typeof window === "undefined" || !window.ethereum) {
|
|
823
|
+
return () => {
|
|
824
|
+
};
|
|
790
825
|
}
|
|
791
|
-
|
|
792
|
-
|
|
826
|
+
const ethereum = window.ethereum;
|
|
827
|
+
const handler = (accounts) => {
|
|
828
|
+
callback(accounts);
|
|
829
|
+
};
|
|
830
|
+
ethereum.on("accountsChanged", handler);
|
|
831
|
+
return () => {
|
|
832
|
+
ethereum.removeListener?.("accountsChanged", handler);
|
|
833
|
+
};
|
|
793
834
|
}
|
|
794
|
-
function
|
|
795
|
-
if (
|
|
796
|
-
return
|
|
835
|
+
function onChainChanged(callback) {
|
|
836
|
+
if (typeof window === "undefined" || !window.ethereum) {
|
|
837
|
+
return () => {
|
|
838
|
+
};
|
|
797
839
|
}
|
|
798
|
-
const
|
|
799
|
-
|
|
800
|
-
|
|
840
|
+
const ethereum = window.ethereum;
|
|
841
|
+
const handler = (chainId) => {
|
|
842
|
+
console.log("\u{1F504} Chain changed to:", chainId);
|
|
843
|
+
callback(chainId);
|
|
844
|
+
};
|
|
845
|
+
ethereum.on("chainChanged", handler);
|
|
846
|
+
return () => {
|
|
847
|
+
ethereum.removeListener?.("chainChanged", handler);
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
function onWalletDisconnect(callback) {
|
|
851
|
+
if (typeof window === "undefined") {
|
|
852
|
+
return () => {
|
|
853
|
+
};
|
|
801
854
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
case "solana" /* SOLANA */:
|
|
807
|
-
case "svm" /* SVM */:
|
|
808
|
-
return window.phantom?.solana || window.solana;
|
|
809
|
-
default:
|
|
810
|
-
return null;
|
|
855
|
+
const solana = window.solana;
|
|
856
|
+
if (!solana) {
|
|
857
|
+
return () => {
|
|
858
|
+
};
|
|
811
859
|
}
|
|
860
|
+
const handler = () => {
|
|
861
|
+
console.log("\u{1F50C} Solana wallet disconnected");
|
|
862
|
+
callback();
|
|
863
|
+
};
|
|
864
|
+
solana.on("disconnect", handler);
|
|
865
|
+
return () => {
|
|
866
|
+
solana.removeListener?.("disconnect", handler);
|
|
867
|
+
};
|
|
812
868
|
}
|
|
813
|
-
|
|
814
|
-
|
|
869
|
+
async function switchNetwork(networkType) {
|
|
870
|
+
const cachedAddress = getCachedWalletAddress(networkType);
|
|
871
|
+
if (cachedAddress) {
|
|
872
|
+
saveConnectedNetworkType(networkType);
|
|
873
|
+
clearWalletDisconnection(networkType);
|
|
874
|
+
const currentAddress = await getCurrentWallet(networkType);
|
|
875
|
+
if (currentAddress) {
|
|
876
|
+
return currentAddress;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
return null;
|
|
815
880
|
}
|
|
816
881
|
|
|
882
|
+
// src/utils/index.ts
|
|
883
|
+
init_wallet_discovery();
|
|
884
|
+
|
|
817
885
|
// src/services/svm/payment-header.ts
|
|
818
886
|
var import_web3 = require("@solana/web3.js");
|
|
819
887
|
var import_spl_token = require("@solana/spl-token");
|
|
@@ -1269,6 +1337,7 @@ async function handleEvmPayment(endpoint, config, requestInit) {
|
|
|
1269
1337
|
// src/utils/payment-helpers.ts
|
|
1270
1338
|
var import_ethers2 = require("ethers");
|
|
1271
1339
|
init_common();
|
|
1340
|
+
init_wallet_discovery();
|
|
1272
1341
|
function parsePaymentRequired(response) {
|
|
1273
1342
|
if (response && typeof response === "object") {
|
|
1274
1343
|
if ("x402Version" in response && "accepts" in response) {
|
|
@@ -1309,8 +1378,8 @@ async function makePayment(networkType, merchantId, endpoint = PROD_BACK_URL, ad
|
|
|
1309
1378
|
if (!solana.isConnected) {
|
|
1310
1379
|
await solana.connect();
|
|
1311
1380
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1381
|
+
const currentAddress = solana.publicKey?.toString();
|
|
1382
|
+
if (expectedAddress && currentAddress) {
|
|
1314
1383
|
if (currentAddress !== expectedAddress) {
|
|
1315
1384
|
throw new Error(
|
|
1316
1385
|
`Wallet account mismatch: the current wallet account is ${currentAddress.slice(0, 8)}...\uFF0CBut the desired account is ${expectedAddress.slice(0, 8)}.... Please switch to the correct account in your wallet.`
|
|
@@ -1337,8 +1406,8 @@ async function makePayment(networkType, merchantId, endpoint = PROD_BACK_URL, ad
|
|
|
1337
1406
|
}
|
|
1338
1407
|
const wallet = {
|
|
1339
1408
|
address: currentAddress,
|
|
1340
|
-
signTypedData: async (domain, types,
|
|
1341
|
-
return await signer.signTypedData(domain, types,
|
|
1409
|
+
signTypedData: async (domain, types, message) => {
|
|
1410
|
+
return await signer.signTypedData(domain, types, message);
|
|
1342
1411
|
},
|
|
1343
1412
|
// Get current chain ID from wallet
|
|
1344
1413
|
getChainId: async () => {
|
|
@@ -1676,8 +1745,22 @@ var WalletStore = class {
|
|
|
1676
1745
|
}
|
|
1677
1746
|
this.setState({ isConnecting: true, error: null });
|
|
1678
1747
|
try {
|
|
1679
|
-
|
|
1748
|
+
let address = await switchNetwork(type);
|
|
1680
1749
|
if (address) {
|
|
1750
|
+
const wallets = getWalletsForNetwork(type);
|
|
1751
|
+
if (wallets.length > 0) {
|
|
1752
|
+
const { getWalletProviderForPayment: getWalletProviderForPayment2 } = await Promise.resolve().then(() => (init_wallet_discovery(), wallet_discovery_exports));
|
|
1753
|
+
const provider = getWalletProviderForPayment2(type);
|
|
1754
|
+
if (provider) {
|
|
1755
|
+
if (type === "solana" /* SOLANA */ || type === "svm" /* SVM */) {
|
|
1756
|
+
const providerAddress = provider.publicKey?.toString();
|
|
1757
|
+
if (providerAddress && providerAddress !== address) {
|
|
1758
|
+
address = providerAddress;
|
|
1759
|
+
saveWalletAddress(type, providerAddress);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1681
1764
|
this.setState({
|
|
1682
1765
|
address,
|
|
1683
1766
|
networkType: type,
|
|
@@ -1728,6 +1811,16 @@ var WalletStore = class {
|
|
|
1728
1811
|
return;
|
|
1729
1812
|
}
|
|
1730
1813
|
if (this.state.networkType === expectedNetwork && this.state.address) {
|
|
1814
|
+
const { getWalletProviderForPayment: getWalletProviderForPayment2 } = await Promise.resolve().then(() => (init_wallet_discovery(), wallet_discovery_exports));
|
|
1815
|
+
const provider = getWalletProviderForPayment2(expectedNetwork);
|
|
1816
|
+
if (provider && (expectedNetwork === "solana" /* SOLANA */ || expectedNetwork === "svm" /* SVM */)) {
|
|
1817
|
+
const providerAddress = provider.publicKey?.toString();
|
|
1818
|
+
if (providerAddress && providerAddress !== this.state.address) {
|
|
1819
|
+
this.setState({ address: providerAddress });
|
|
1820
|
+
saveWalletAddress(expectedNetwork, providerAddress);
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1731
1824
|
return;
|
|
1732
1825
|
}
|
|
1733
1826
|
if (this.state.networkType !== expectedNetwork) {
|
|
@@ -1867,7 +1960,7 @@ var import_react6 = __toESM(require("react"));
|
|
|
1867
1960
|
// src/react/components/ui/Toast.tsx
|
|
1868
1961
|
var import_react5 = __toESM(require("react"));
|
|
1869
1962
|
var import_react_dom = require("react-dom");
|
|
1870
|
-
var Toast = ({ message
|
|
1963
|
+
var Toast = ({ message, type, onClose }) => {
|
|
1871
1964
|
(0, import_react5.useEffect)(() => {
|
|
1872
1965
|
const timer = setTimeout(onClose, 3e3);
|
|
1873
1966
|
return () => clearTimeout(timer);
|
|
@@ -1890,7 +1983,7 @@ var Toast = ({ message: message2, type, onClose }) => {
|
|
|
1890
1983
|
style: { backgroundColor: bgColor, minWidth: "280px" }
|
|
1891
1984
|
},
|
|
1892
1985
|
/* @__PURE__ */ import_react5.default.createElement("span", { className: "text-lg" }, icon),
|
|
1893
|
-
/* @__PURE__ */ import_react5.default.createElement("span", { className: "flex-1" },
|
|
1986
|
+
/* @__PURE__ */ import_react5.default.createElement("span", { className: "flex-1" }, message),
|
|
1894
1987
|
/* @__PURE__ */ import_react5.default.createElement(
|
|
1895
1988
|
"button",
|
|
1896
1989
|
{
|
|
@@ -1909,9 +2002,9 @@ var Toast = ({ message: message2, type, onClose }) => {
|
|
|
1909
2002
|
var useToast = () => {
|
|
1910
2003
|
const [toasts, setToasts] = (0, import_react6.useState)([]);
|
|
1911
2004
|
const toastIdRef = (0, import_react6.useRef)(0);
|
|
1912
|
-
const showToast = (0, import_react6.useCallback)((
|
|
2005
|
+
const showToast = (0, import_react6.useCallback)((message, type) => {
|
|
1913
2006
|
const id = ++toastIdRef.current;
|
|
1914
|
-
setToasts((prev) => [...prev, { id, message
|
|
2007
|
+
setToasts((prev) => [...prev, { id, message, type }]);
|
|
1915
2008
|
}, []);
|
|
1916
2009
|
const removeToast = (0, import_react6.useCallback)((id) => {
|
|
1917
2010
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
@@ -1938,6 +2031,7 @@ var import_react8 = __toESM(require("react"));
|
|
|
1938
2031
|
// src/react/components/wallet/WalletSelectModal.tsx
|
|
1939
2032
|
var import_react7 = __toESM(require("react"));
|
|
1940
2033
|
var import_react_dom2 = require("react-dom");
|
|
2034
|
+
init_wallet_discovery();
|
|
1941
2035
|
var overlayStyle = {
|
|
1942
2036
|
position: "fixed",
|
|
1943
2037
|
top: 0,
|
|
@@ -2386,10 +2480,8 @@ function WalletConnect({
|
|
|
2386
2480
|
));
|
|
2387
2481
|
}
|
|
2388
2482
|
|
|
2389
|
-
// src/react/components/checkout/
|
|
2390
|
-
var
|
|
2391
|
-
var import_antd = require("antd");
|
|
2392
|
-
var import_icons = require("@ant-design/icons");
|
|
2483
|
+
// src/react/components/checkout/V402CheckoutV2.tsx
|
|
2484
|
+
var import_react14 = __toESM(require("react"));
|
|
2393
2485
|
init_common();
|
|
2394
2486
|
|
|
2395
2487
|
// src/react/utils/CryptoIcons.tsx
|
|
@@ -2458,495 +2550,8 @@ var getNetworkIcon = (network) => {
|
|
|
2458
2550
|
return BaseIcon;
|
|
2459
2551
|
};
|
|
2460
2552
|
|
|
2461
|
-
// src/react/components/checkout/V402Checkout.tsx
|
|
2462
|
-
var { Title, Text } = import_antd.Typography;
|
|
2463
|
-
var notify = {
|
|
2464
|
-
success: (title, msg) => {
|
|
2465
|
-
import_antd.message.success(`${title}: ${msg}`);
|
|
2466
|
-
},
|
|
2467
|
-
error: (title, msg) => {
|
|
2468
|
-
import_antd.message.error(`${title}: ${msg}`);
|
|
2469
|
-
},
|
|
2470
|
-
info: (title, msg) => {
|
|
2471
|
-
import_antd.message.info(`${title}: ${msg}`);
|
|
2472
|
-
}
|
|
2473
|
-
};
|
|
2474
|
-
function V402Checkout({
|
|
2475
|
-
checkoutId,
|
|
2476
|
-
headerInfo = {},
|
|
2477
|
-
isModal = false,
|
|
2478
|
-
onPaymentComplete,
|
|
2479
|
-
additionalParams = {},
|
|
2480
|
-
expectedNetwork
|
|
2481
|
-
}) {
|
|
2482
|
-
const {
|
|
2483
|
-
title = "V402Pay - Make x402Pay Easier",
|
|
2484
|
-
subtitle = "onvoyage.ai",
|
|
2485
|
-
tooltipText = "V402Pay - Accept Crypto Payments Easier"
|
|
2486
|
-
} = headerInfo;
|
|
2487
|
-
const endpoint = PROD_BACK_URL;
|
|
2488
|
-
const {
|
|
2489
|
-
supportedNetworks,
|
|
2490
|
-
isLoading: fetchingPaymentInfo,
|
|
2491
|
-
paymentInfo
|
|
2492
|
-
} = usePaymentInfo(checkoutId, endpoint, additionalParams);
|
|
2493
|
-
const targetNetwork = expectedNetwork || supportedNetworks[0];
|
|
2494
|
-
const { address, networkType, disconnect, ensureNetwork } = usePageNetwork(
|
|
2495
|
-
targetNetwork,
|
|
2496
|
-
{ autoSwitch: !!targetNetwork, switchOnMount: true }
|
|
2497
|
-
);
|
|
2498
|
-
const { isProcessing, setIsProcessing, result, setResult, error, setError } = usePayment();
|
|
2499
|
-
const [paymentDetails, setPaymentDetails] = (0, import_react10.useState)(null);
|
|
2500
|
-
const handleDisconnect = () => {
|
|
2501
|
-
disconnect();
|
|
2502
|
-
setResult(null);
|
|
2503
|
-
setError(null);
|
|
2504
|
-
notify.info("Wallet Disconnected", "Your wallet has been disconnected successfully.");
|
|
2505
|
-
};
|
|
2506
|
-
(0, import_react10.useEffect)(() => {
|
|
2507
|
-
if (paymentInfo && paymentInfo.length > 0) {
|
|
2508
|
-
const firstPayment = paymentInfo[0];
|
|
2509
|
-
const rawAmount = firstPayment.maxAmountRequired?.toString() || "0";
|
|
2510
|
-
const decimals = 6;
|
|
2511
|
-
const humanReadableAmount = (Number(rawAmount) / Math.pow(10, decimals)).toFixed(2);
|
|
2512
|
-
const network = firstPayment.network || "Unknown";
|
|
2513
|
-
const currency = "USDC";
|
|
2514
|
-
setPaymentDetails({
|
|
2515
|
-
amount: humanReadableAmount,
|
|
2516
|
-
currency,
|
|
2517
|
-
network
|
|
2518
|
-
});
|
|
2519
|
-
}
|
|
2520
|
-
}, [paymentInfo]);
|
|
2521
|
-
(0, import_react10.useEffect)(() => {
|
|
2522
|
-
if (targetNetwork && !fetchingPaymentInfo && ensureNetwork) {
|
|
2523
|
-
ensureNetwork(targetNetwork).catch((err) => {
|
|
2524
|
-
console.error("Failed to ensure network:", err);
|
|
2525
|
-
});
|
|
2526
|
-
}
|
|
2527
|
-
}, [targetNetwork, fetchingPaymentInfo]);
|
|
2528
|
-
const handlePayment = async () => {
|
|
2529
|
-
if (!networkType) {
|
|
2530
|
-
notify.error("Wallet Not Connected", "Please connect your wallet first.");
|
|
2531
|
-
return;
|
|
2532
|
-
}
|
|
2533
|
-
setResult(null);
|
|
2534
|
-
setError(null);
|
|
2535
|
-
setIsProcessing(true);
|
|
2536
|
-
try {
|
|
2537
|
-
const response = await makePayment(networkType, checkoutId, endpoint, additionalParams, address || void 0);
|
|
2538
|
-
const data = await response.json();
|
|
2539
|
-
setResult(data);
|
|
2540
|
-
notify.success("Payment Successful!", "Your payment has been processed successfully.");
|
|
2541
|
-
if (onPaymentComplete) {
|
|
2542
|
-
onPaymentComplete(data);
|
|
2543
|
-
}
|
|
2544
|
-
} catch (err) {
|
|
2545
|
-
const errorMessage = err.message || "Payment failed";
|
|
2546
|
-
setError(errorMessage);
|
|
2547
|
-
notify.error("Payment Failed", errorMessage);
|
|
2548
|
-
} finally {
|
|
2549
|
-
setIsProcessing(false);
|
|
2550
|
-
}
|
|
2551
|
-
};
|
|
2552
|
-
const getNetworkColor = (network) => {
|
|
2553
|
-
if (network.toLowerCase().includes("solana")) return "#14F195";
|
|
2554
|
-
if (network.toLowerCase().includes("evm") || network.toLowerCase().includes("base")) return "#0052FF";
|
|
2555
|
-
return "#8c8c8c";
|
|
2556
|
-
};
|
|
2557
|
-
const NetworkIcon = paymentDetails ? getNetworkIcon(paymentDetails.network) : null;
|
|
2558
|
-
const networkColor = paymentDetails ? getNetworkColor(paymentDetails.network) : "#8c8c8c";
|
|
2559
|
-
const loadingColor = "#8c8c8c";
|
|
2560
|
-
const hasInvalidCheckoutId = !fetchingPaymentInfo && (!paymentInfo || paymentInfo.length === 0);
|
|
2561
|
-
return /* @__PURE__ */ import_react10.default.createElement(
|
|
2562
|
-
"div",
|
|
2563
|
-
{
|
|
2564
|
-
className: isModal ? "bg-white" : "h-screen bg-white flex items-center justify-center p-4 overflow-hidden"
|
|
2565
|
-
},
|
|
2566
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
2567
|
-
"div",
|
|
2568
|
-
{
|
|
2569
|
-
className: "flex gap-4 items-center justify-center",
|
|
2570
|
-
style: {
|
|
2571
|
-
maxWidth: isProcessing || result || error ? "1200px" : "480px",
|
|
2572
|
-
transition: "max-width 0.4s ease-in-out",
|
|
2573
|
-
width: "100%"
|
|
2574
|
-
}
|
|
2575
|
-
},
|
|
2576
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
2577
|
-
import_antd.Card,
|
|
2578
|
-
{
|
|
2579
|
-
className: "flex-shrink-0",
|
|
2580
|
-
style: {
|
|
2581
|
-
border: isModal ? "none" : "1px solid #e8e8e8",
|
|
2582
|
-
borderRadius: isModal ? "0" : "16px",
|
|
2583
|
-
boxShadow: isModal ? "none" : "0 4px 24px rgba(0, 0, 0, 0.06)",
|
|
2584
|
-
maxHeight: isModal ? "calc(100vh - 100px)" : "calc(100vh - 32px)",
|
|
2585
|
-
overflow: "auto",
|
|
2586
|
-
width: isModal ? "100%" : "480px",
|
|
2587
|
-
transition: "all 0.4s ease-in-out",
|
|
2588
|
-
transform: result || error ? "translateX(0)" : "translateX(0)"
|
|
2589
|
-
},
|
|
2590
|
-
styles: { body: { padding: isModal ? "0px" : "32px 24px" } }
|
|
2591
|
-
},
|
|
2592
|
-
/* @__PURE__ */ import_react10.default.createElement("div", { className: "flex items-center gap-3 mb-4" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
2593
|
-
"div",
|
|
2594
|
-
{
|
|
2595
|
-
className: "w-12 h-12 rounded-xl flex items-center justify-center",
|
|
2596
|
-
style: {
|
|
2597
|
-
background: hasInvalidCheckoutId ? "#ff4d4f" : paymentDetails ? networkColor : loadingColor,
|
|
2598
|
-
transition: "background 0.3s ease"
|
|
2599
|
-
}
|
|
2600
|
-
},
|
|
2601
|
-
hasInvalidCheckoutId ? /* @__PURE__ */ import_react10.default.createElement("span", { style: { fontSize: "20px", color: "white", fontWeight: "bold" } }, "\u2717") : paymentDetails && NetworkIcon ? /* @__PURE__ */ import_react10.default.createElement(NetworkIcon, { width: 24, height: 24 }) : /* @__PURE__ */ import_react10.default.createElement(import_icons.LoadingOutlined, { style: { fontSize: "20px", color: "white" }, spin: true })
|
|
2602
|
-
), /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex-1" }, /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ import_react10.default.createElement(Title, { level: 4, style: { margin: 0, fontSize: "18px", fontWeight: 600 } }, title || "Echo Payment OnVoyage"), !hasInvalidCheckoutId && /* @__PURE__ */ import_react10.default.createElement(
|
|
2603
|
-
import_antd.Tooltip,
|
|
2604
|
-
{
|
|
2605
|
-
title: tooltipText,
|
|
2606
|
-
placement: "top"
|
|
2607
|
-
},
|
|
2608
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
2609
|
-
import_icons.InfoCircleOutlined,
|
|
2610
|
-
{
|
|
2611
|
-
style: { fontSize: "14px", color: "#8c8c8c", cursor: "help" }
|
|
2612
|
-
}
|
|
2613
|
-
)
|
|
2614
|
-
)), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "13px", color: "#8c8c8c" } }, subtitle))),
|
|
2615
|
-
/* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center mb-5" }, /* @__PURE__ */ import_react10.default.createElement("div", { className: "inline-flex items-center justify-center w-12 h-12 rounded-full bg-gray-50 mb-3" }, /* @__PURE__ */ import_react10.default.createElement(import_icons.LockOutlined, { style: { fontSize: "20px", color: "#595959" } })), /* @__PURE__ */ import_react10.default.createElement(Title, { level: 3, style: { margin: "0 0 6px 0", fontSize: "20px", fontWeight: 600 } }, "Payment Required"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "13px", color: "#8c8c8c" } }, "Pay ", paymentDetails ? `$${paymentDetails.amount} ${paymentDetails.currency}` : "the required amount", " to access")),
|
|
2616
|
-
hasInvalidCheckoutId && /* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center py-6" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
2617
|
-
"div",
|
|
2618
|
-
{
|
|
2619
|
-
className: "inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",
|
|
2620
|
-
style: {
|
|
2621
|
-
background: "linear-gradient(135deg, #ef4444 0%, #f87171 100%)",
|
|
2622
|
-
boxShadow: "0 4px 20px rgba(239, 68, 68, 0.3)"
|
|
2623
|
-
}
|
|
2624
|
-
},
|
|
2625
|
-
/* @__PURE__ */ import_react10.default.createElement("span", { style: { fontSize: "32px", color: "white" } }, "!")
|
|
2626
|
-
), /* @__PURE__ */ import_react10.default.createElement(
|
|
2627
|
-
Title,
|
|
2628
|
-
{
|
|
2629
|
-
level: 4,
|
|
2630
|
-
style: { margin: "0 0 12px 0", fontSize: "18px", fontWeight: 600, color: "#262626" }
|
|
2631
|
-
},
|
|
2632
|
-
"Invalid Checkout ID"
|
|
2633
|
-
), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "14px", color: "#8c8c8c", display: "block", marginBottom: "16px" } }, "The checkout ID you provided is invalid or has expired."), /* @__PURE__ */ import_react10.default.createElement(
|
|
2634
|
-
"div",
|
|
2635
|
-
{
|
|
2636
|
-
style: {
|
|
2637
|
-
background: "#fef2f2",
|
|
2638
|
-
padding: "16px",
|
|
2639
|
-
borderRadius: "12px",
|
|
2640
|
-
border: "1px solid #fee2e2",
|
|
2641
|
-
marginTop: "16px"
|
|
2642
|
-
}
|
|
2643
|
-
},
|
|
2644
|
-
/* @__PURE__ */ import_react10.default.createElement(Text, { style: {
|
|
2645
|
-
fontSize: "13px",
|
|
2646
|
-
color: "#dc2626",
|
|
2647
|
-
lineHeight: "1.6",
|
|
2648
|
-
fontWeight: 500
|
|
2649
|
-
} }, "Failed to load payment information. Please check your checkout ID.")
|
|
2650
|
-
)),
|
|
2651
|
-
!hasInvalidCheckoutId && fetchingPaymentInfo && /* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center py-6" }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { color: "#8c8c8c" } }, "Loading payment information...")),
|
|
2652
|
-
!hasInvalidCheckoutId && !fetchingPaymentInfo && !address && /* @__PURE__ */ import_react10.default.createElement("div", null, /* @__PURE__ */ import_react10.default.createElement(WalletConnect, { supportedNetworks })),
|
|
2653
|
-
!hasInvalidCheckoutId && address && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
2654
|
-
"div",
|
|
2655
|
-
{
|
|
2656
|
-
className: "bg-gray-50 rounded-lg p-3 mb-4",
|
|
2657
|
-
style: { border: "1px solid #f0f0f0" }
|
|
2658
|
-
},
|
|
2659
|
-
/* @__PURE__ */ import_react10.default.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex items-center gap-3 flex-1" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
2660
|
-
"div",
|
|
2661
|
-
{
|
|
2662
|
-
className: "w-10 h-10 rounded-full bg-black flex items-center justify-center text-white text-sm font-semibold"
|
|
2663
|
-
},
|
|
2664
|
-
address.slice(0, 2).toUpperCase()
|
|
2665
|
-
), /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex-1 min-w-0" }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: {
|
|
2666
|
-
display: "block",
|
|
2667
|
-
fontSize: "12px",
|
|
2668
|
-
color: "#8c8c8c",
|
|
2669
|
-
marginBottom: "2px"
|
|
2670
|
-
} }, "Connected Wallet"), /* @__PURE__ */ import_react10.default.createElement(
|
|
2671
|
-
Text,
|
|
2672
|
-
{
|
|
2673
|
-
style: {
|
|
2674
|
-
fontSize: "13px",
|
|
2675
|
-
fontWeight: 600,
|
|
2676
|
-
fontFamily: "Monaco, monospace"
|
|
2677
|
-
}
|
|
2678
|
-
},
|
|
2679
|
-
formatAddress(address)
|
|
2680
|
-
))), /* @__PURE__ */ import_react10.default.createElement(
|
|
2681
|
-
import_antd.Button,
|
|
2682
|
-
{
|
|
2683
|
-
type: "text",
|
|
2684
|
-
size: "small",
|
|
2685
|
-
icon: /* @__PURE__ */ import_react10.default.createElement(import_icons.DisconnectOutlined, null),
|
|
2686
|
-
onClick: handleDisconnect,
|
|
2687
|
-
style: { color: "#ff4d4f" }
|
|
2688
|
-
}
|
|
2689
|
-
))
|
|
2690
|
-
), paymentDetails && /* @__PURE__ */ import_react10.default.createElement("div", { className: "bg-gray-50 rounded-lg p-3 mb-4", style: { border: "1px solid #f0f0f0" } }, /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex justify-between items-center mb-2" }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "13px", color: "#8c8c8c" } }, "Payment Amount"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "18px", fontWeight: 600 } }, "$", paymentDetails.amount)), /* @__PURE__ */ import_react10.default.createElement(import_antd.Divider, { style: { margin: "6px 0" } }), /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex justify-between items-center mb-2" }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "13px", color: "#8c8c8c" } }, "Currency"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "14px", fontWeight: 500 } }, paymentDetails.currency)), /* @__PURE__ */ import_react10.default.createElement(import_antd.Divider, { style: { margin: "6px 0" } }), /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex justify-between items-center mb-2" }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "13px", color: "#8c8c8c" } }, "Network"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "14px", fontWeight: 500 } }, paymentDetails.network)), /* @__PURE__ */ import_react10.default.createElement(import_antd.Divider, { style: { margin: "6px 0" } }), /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex justify-between items-start" }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "13px", color: "#8c8c8c" } }, "Wallet Address"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: {
|
|
2691
|
-
fontSize: "11px",
|
|
2692
|
-
fontWeight: 500,
|
|
2693
|
-
fontFamily: "Monaco, monospace",
|
|
2694
|
-
wordBreak: "break-all",
|
|
2695
|
-
textAlign: "right",
|
|
2696
|
-
maxWidth: "60%",
|
|
2697
|
-
lineHeight: 1.4
|
|
2698
|
-
} }, address))), /* @__PURE__ */ import_react10.default.createElement(
|
|
2699
|
-
"div",
|
|
2700
|
-
{
|
|
2701
|
-
className: "flex items-center justify-center gap-2 mb-3 p-2 rounded-lg",
|
|
2702
|
-
style: { background: "#f6ffed", border: "1px solid #d9f7be" }
|
|
2703
|
-
},
|
|
2704
|
-
/* @__PURE__ */ import_react10.default.createElement(import_icons.SafetyOutlined, { style: { color: "#52c41a", fontSize: "13px" } }),
|
|
2705
|
-
/* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "12px", color: "#52c41a", fontWeight: 500 } }, "Secure payment powered by v402pay")
|
|
2706
|
-
), /* @__PURE__ */ import_react10.default.createElement(
|
|
2707
|
-
import_antd.Button,
|
|
2708
|
-
{
|
|
2709
|
-
type: "primary",
|
|
2710
|
-
size: "large",
|
|
2711
|
-
onClick: handlePayment,
|
|
2712
|
-
disabled: isProcessing || !paymentDetails,
|
|
2713
|
-
loading: isProcessing,
|
|
2714
|
-
block: true,
|
|
2715
|
-
style: {
|
|
2716
|
-
height: "44px",
|
|
2717
|
-
fontSize: "14px",
|
|
2718
|
-
fontWeight: 600,
|
|
2719
|
-
borderRadius: "8px",
|
|
2720
|
-
...!isProcessing && paymentDetails && {
|
|
2721
|
-
background: "#1a1a1a",
|
|
2722
|
-
borderColor: "#1a1a1a"
|
|
2723
|
-
},
|
|
2724
|
-
marginBottom: "10px"
|
|
2725
|
-
}
|
|
2726
|
-
},
|
|
2727
|
-
isProcessing ? "Processing..." : !paymentDetails ? "Loading..." : `Pay $${paymentDetails.amount} ${paymentDetails.currency}`
|
|
2728
|
-
), /* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center" }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "13px", color: "#8c8c8c" } }, "Don't have USDC?", " "), /* @__PURE__ */ import_react10.default.createElement(
|
|
2729
|
-
"a",
|
|
2730
|
-
{
|
|
2731
|
-
href: "https://faucet.circle.com/",
|
|
2732
|
-
target: "_blank",
|
|
2733
|
-
rel: "noopener noreferrer",
|
|
2734
|
-
className: "text-blue-600 hover:text-blue-700 text-sm font-medium inline-flex items-center gap-1"
|
|
2735
|
-
},
|
|
2736
|
-
"Get it here ",
|
|
2737
|
-
/* @__PURE__ */ import_react10.default.createElement(import_icons.LinkOutlined, { style: { fontSize: "12px" } })
|
|
2738
|
-
)), isModal && result && /* @__PURE__ */ import_react10.default.createElement(
|
|
2739
|
-
"div",
|
|
2740
|
-
{
|
|
2741
|
-
className: "mt-4 p-4 rounded-lg",
|
|
2742
|
-
style: { background: "#f6ffed", border: "1px solid #b7eb8f" }
|
|
2743
|
-
},
|
|
2744
|
-
/* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center" }, /* @__PURE__ */ import_react10.default.createElement("span", { style: { fontSize: "20px" } }, "\u2713"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: {
|
|
2745
|
-
fontSize: "14px",
|
|
2746
|
-
color: "#52c41a",
|
|
2747
|
-
fontWeight: 600,
|
|
2748
|
-
marginLeft: "8px"
|
|
2749
|
-
} }, "Payment Successful!"))
|
|
2750
|
-
), isModal && error && /* @__PURE__ */ import_react10.default.createElement(
|
|
2751
|
-
"div",
|
|
2752
|
-
{
|
|
2753
|
-
className: "mt-4 p-4 rounded-lg",
|
|
2754
|
-
style: { background: "#fff2f0", border: "1px solid #ffccc7" }
|
|
2755
|
-
},
|
|
2756
|
-
/* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center mb-3" }, /* @__PURE__ */ import_react10.default.createElement("span", { style: { fontSize: "20px" } }, "\u2717"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: {
|
|
2757
|
-
fontSize: "14px",
|
|
2758
|
-
color: "#ff4d4f",
|
|
2759
|
-
fontWeight: 600,
|
|
2760
|
-
marginLeft: "8px",
|
|
2761
|
-
display: "block",
|
|
2762
|
-
marginTop: "4px"
|
|
2763
|
-
} }, "Payment Failed")),
|
|
2764
|
-
/* @__PURE__ */ import_react10.default.createElement(Text, { style: {
|
|
2765
|
-
fontSize: "13px",
|
|
2766
|
-
color: "#ff4d4f",
|
|
2767
|
-
display: "block",
|
|
2768
|
-
textAlign: "center"
|
|
2769
|
-
} }, error)
|
|
2770
|
-
))
|
|
2771
|
-
),
|
|
2772
|
-
!isModal && (isProcessing || result || error) && /* @__PURE__ */ import_react10.default.createElement(
|
|
2773
|
-
import_antd.Card,
|
|
2774
|
-
{
|
|
2775
|
-
title: /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex items-center gap-2" }, isProcessing && !result && !error ? /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(import_icons.LoadingOutlined, { style: { color: "#14b8a6", fontSize: "16px" } }), /* @__PURE__ */ import_react10.default.createElement(Text, { strong: true, style: { fontSize: "16px", color: "#262626" } }, "Processing Payment")) : result ? /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement("span", { style: { color: "#52c41a", fontSize: "18px" } }, "\u2713"), /* @__PURE__ */ import_react10.default.createElement(Text, { strong: true, style: { fontSize: "16px", color: "#262626" } }, "Payment Successful")) : /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement("span", { style: { color: "#ff4d4f", fontSize: "18px" } }, "\u2717"), /* @__PURE__ */ import_react10.default.createElement(Text, { strong: true, style: { fontSize: "16px", color: "#262626" } }, "Payment Failed"))),
|
|
2776
|
-
extra: !isProcessing && /* @__PURE__ */ import_react10.default.createElement(
|
|
2777
|
-
import_antd.Button,
|
|
2778
|
-
{
|
|
2779
|
-
type: "text",
|
|
2780
|
-
size: "small",
|
|
2781
|
-
onClick: () => {
|
|
2782
|
-
setResult(null);
|
|
2783
|
-
setError(null);
|
|
2784
|
-
}
|
|
2785
|
-
},
|
|
2786
|
-
"Close"
|
|
2787
|
-
),
|
|
2788
|
-
style: {
|
|
2789
|
-
border: "1px solid #e8e8e8",
|
|
2790
|
-
borderRadius: "16px",
|
|
2791
|
-
boxShadow: "0 4px 24px rgba(0, 0, 0, 0.06)",
|
|
2792
|
-
maxHeight: "calc(100vh - 32px)",
|
|
2793
|
-
width: "480px",
|
|
2794
|
-
animation: "slideInRight 0.4s ease-out"
|
|
2795
|
-
},
|
|
2796
|
-
styles: {
|
|
2797
|
-
body: {
|
|
2798
|
-
padding: "24px",
|
|
2799
|
-
maxHeight: "calc(100vh - 120px)",
|
|
2800
|
-
overflow: "auto"
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
},
|
|
2804
|
-
isProcessing && !result && !error && /* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center py-10" }, /* @__PURE__ */ import_react10.default.createElement("div", { className: "relative inline-block" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
2805
|
-
"div",
|
|
2806
|
-
{
|
|
2807
|
-
className: "absolute inset-0 rounded-full blur-xl opacity-40",
|
|
2808
|
-
style: {
|
|
2809
|
-
background: "linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%)",
|
|
2810
|
-
animation: "pulse 2s ease-in-out infinite"
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
), /* @__PURE__ */ import_react10.default.createElement(
|
|
2814
|
-
import_antd.Spin,
|
|
2815
|
-
{
|
|
2816
|
-
indicator: /* @__PURE__ */ import_react10.default.createElement(import_icons.LoadingOutlined, { style: { fontSize: 56, color: "#14b8a6" } })
|
|
2817
|
-
}
|
|
2818
|
-
)), /* @__PURE__ */ import_react10.default.createElement("div", { className: "mt-6" }, /* @__PURE__ */ import_react10.default.createElement(Text, { strong: true, style: { fontSize: "18px", color: "#262626", letterSpacing: "-0.02em" } }, "Verifying Payment")), /* @__PURE__ */ import_react10.default.createElement("div", { className: "mt-2 mb-6" }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "14px", color: "#8c8c8c", lineHeight: "1.6" } }, "Please wait while we confirm your transaction")), /* @__PURE__ */ import_react10.default.createElement(
|
|
2819
|
-
"div",
|
|
2820
|
-
{
|
|
2821
|
-
className: "mt-4 p-4 rounded-xl",
|
|
2822
|
-
style: {
|
|
2823
|
-
background: "linear-gradient(135deg, #f0fdfa 0%, #ecfeff 100%)",
|
|
2824
|
-
border: "1px solid #ccfbf1"
|
|
2825
|
-
}
|
|
2826
|
-
},
|
|
2827
|
-
/* @__PURE__ */ import_react10.default.createElement("div", { className: "flex items-center justify-center gap-2" }, /* @__PURE__ */ import_react10.default.createElement("span", { style: { fontSize: "16px" } }, "\u23F1\uFE0F"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "13px", color: "#0f766e", fontWeight: 500 } }, "This may take a few moments"))
|
|
2828
|
-
)),
|
|
2829
|
-
result && /* @__PURE__ */ import_react10.default.createElement("div", null, /* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center mb-6" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
2830
|
-
"div",
|
|
2831
|
-
{
|
|
2832
|
-
className: "inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",
|
|
2833
|
-
style: {
|
|
2834
|
-
background: "linear-gradient(135deg, #10b981 0%, #34d399 100%)",
|
|
2835
|
-
boxShadow: "0 4px 20px rgba(16, 185, 129, 0.3)"
|
|
2836
|
-
}
|
|
2837
|
-
},
|
|
2838
|
-
/* @__PURE__ */ import_react10.default.createElement("span", { style: { fontSize: "32px", color: "white" } }, "\u2713")
|
|
2839
|
-
), /* @__PURE__ */ import_react10.default.createElement("div", null, /* @__PURE__ */ import_react10.default.createElement(Text, { strong: true, style: {
|
|
2840
|
-
fontSize: "20px",
|
|
2841
|
-
color: "#262626",
|
|
2842
|
-
display: "block",
|
|
2843
|
-
marginBottom: "8px"
|
|
2844
|
-
} }, "Payment Successful!"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "14px", color: "#8c8c8c" } }, "Your transaction has been confirmed"))), /* @__PURE__ */ import_react10.default.createElement(import_antd.Divider, { style: { margin: "20px 0", borderColor: "#f0f0f0" } }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "12px", color: "#8c8c8c", fontWeight: 500 } }, "RESPONSE DATA")), /* @__PURE__ */ import_react10.default.createElement(
|
|
2845
|
-
"pre",
|
|
2846
|
-
{
|
|
2847
|
-
style: {
|
|
2848
|
-
background: "#fafafa",
|
|
2849
|
-
padding: "20px",
|
|
2850
|
-
borderRadius: "12px",
|
|
2851
|
-
fontSize: "12px",
|
|
2852
|
-
lineHeight: "1.8",
|
|
2853
|
-
overflow: "auto",
|
|
2854
|
-
margin: 0,
|
|
2855
|
-
fontFamily: "Monaco, Courier New, monospace",
|
|
2856
|
-
whiteSpace: "pre-wrap",
|
|
2857
|
-
wordBreak: "break-word",
|
|
2858
|
-
border: "1px solid #e8e8e8",
|
|
2859
|
-
color: "#262626"
|
|
2860
|
-
}
|
|
2861
|
-
},
|
|
2862
|
-
JSON.stringify(result, null, 2)
|
|
2863
|
-
)),
|
|
2864
|
-
error && /* @__PURE__ */ import_react10.default.createElement("div", null, /* @__PURE__ */ import_react10.default.createElement("div", { className: "text-center mb-6" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
2865
|
-
"div",
|
|
2866
|
-
{
|
|
2867
|
-
className: "inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",
|
|
2868
|
-
style: {
|
|
2869
|
-
background: "linear-gradient(135deg, #ef4444 0%, #f87171 100%)",
|
|
2870
|
-
boxShadow: "0 4px 20px rgba(239, 68, 68, 0.3)"
|
|
2871
|
-
}
|
|
2872
|
-
},
|
|
2873
|
-
/* @__PURE__ */ import_react10.default.createElement("span", { style: { fontSize: "32px", color: "white" } }, "\u2717")
|
|
2874
|
-
), /* @__PURE__ */ import_react10.default.createElement("div", null, /* @__PURE__ */ import_react10.default.createElement(Text, { strong: true, style: {
|
|
2875
|
-
fontSize: "20px",
|
|
2876
|
-
color: "#262626",
|
|
2877
|
-
display: "block",
|
|
2878
|
-
marginBottom: "8px"
|
|
2879
|
-
} }, "Payment Failed"), /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "14px", color: "#8c8c8c" } }, "Something went wrong with your transaction"))), /* @__PURE__ */ import_react10.default.createElement(import_antd.Divider, { style: { margin: "20px 0", borderColor: "#f0f0f0" } }, /* @__PURE__ */ import_react10.default.createElement(Text, { style: { fontSize: "12px", color: "#8c8c8c", fontWeight: 500 } }, "ERROR DETAILS")), /* @__PURE__ */ import_react10.default.createElement(
|
|
2880
|
-
"div",
|
|
2881
|
-
{
|
|
2882
|
-
style: {
|
|
2883
|
-
background: "#fef2f2",
|
|
2884
|
-
padding: "20px",
|
|
2885
|
-
borderRadius: "12px",
|
|
2886
|
-
border: "1px solid #fee2e2"
|
|
2887
|
-
}
|
|
2888
|
-
},
|
|
2889
|
-
/* @__PURE__ */ import_react10.default.createElement(Text, { style: {
|
|
2890
|
-
fontSize: "14px",
|
|
2891
|
-
color: "#dc2626",
|
|
2892
|
-
lineHeight: "1.6",
|
|
2893
|
-
fontWeight: 500
|
|
2894
|
-
} }, error)
|
|
2895
|
-
), /* @__PURE__ */ import_react10.default.createElement("div", { className: "mt-4 text-center" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
2896
|
-
import_antd.Button,
|
|
2897
|
-
{
|
|
2898
|
-
size: "large",
|
|
2899
|
-
onClick: handlePayment,
|
|
2900
|
-
style: {
|
|
2901
|
-
height: "44px",
|
|
2902
|
-
fontSize: "14px",
|
|
2903
|
-
fontWeight: 600,
|
|
2904
|
-
borderRadius: "8px",
|
|
2905
|
-
background: "#1a1a1a",
|
|
2906
|
-
borderColor: "#1a1a1a",
|
|
2907
|
-
color: "white",
|
|
2908
|
-
paddingLeft: "32px",
|
|
2909
|
-
paddingRight: "32px"
|
|
2910
|
-
}
|
|
2911
|
-
},
|
|
2912
|
-
"Try Again"
|
|
2913
|
-
)))
|
|
2914
|
-
)
|
|
2915
|
-
),
|
|
2916
|
-
/* @__PURE__ */ import_react10.default.createElement("style", { dangerouslySetInnerHTML: {
|
|
2917
|
-
__html: `
|
|
2918
|
-
@keyframes slideInRight {
|
|
2919
|
-
from {
|
|
2920
|
-
opacity: 0;
|
|
2921
|
-
transform: translateX(100px);
|
|
2922
|
-
}
|
|
2923
|
-
to {
|
|
2924
|
-
opacity: 1;
|
|
2925
|
-
transform: translateX(0);
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
|
-
@keyframes pulse {
|
|
2930
|
-
0%, 100% {
|
|
2931
|
-
transform: scale(1);
|
|
2932
|
-
opacity: 0.4;
|
|
2933
|
-
}
|
|
2934
|
-
50% {
|
|
2935
|
-
transform: scale(1.1);
|
|
2936
|
-
opacity: 0.6;
|
|
2937
|
-
}
|
|
2938
|
-
}
|
|
2939
|
-
`
|
|
2940
|
-
} })
|
|
2941
|
-
);
|
|
2942
|
-
}
|
|
2943
|
-
|
|
2944
|
-
// src/react/components/checkout/V402CheckoutV2.tsx
|
|
2945
|
-
var import_react15 = __toESM(require("react"));
|
|
2946
|
-
init_common();
|
|
2947
|
-
|
|
2948
2553
|
// src/react/styles/animations.tsx
|
|
2949
|
-
var
|
|
2554
|
+
var import_react10 = __toESM(require("react"));
|
|
2950
2555
|
var checkoutAnimations = `
|
|
2951
2556
|
@keyframes spin {
|
|
2952
2557
|
from { transform: rotate(0deg); }
|
|
@@ -2974,10 +2579,10 @@ var checkoutAnimations = `
|
|
|
2974
2579
|
50% { opacity: 0.4; }
|
|
2975
2580
|
}
|
|
2976
2581
|
`;
|
|
2977
|
-
var AnimationStyles = () => /* @__PURE__ */
|
|
2582
|
+
var AnimationStyles = () => /* @__PURE__ */ import_react10.default.createElement("style", { dangerouslySetInnerHTML: { __html: checkoutAnimations } });
|
|
2978
2583
|
|
|
2979
2584
|
// src/react/components/checkout/Receipt.tsx
|
|
2980
|
-
var
|
|
2585
|
+
var import_react11 = __toESM(require("react"));
|
|
2981
2586
|
var Receipt = ({
|
|
2982
2587
|
isLoading,
|
|
2983
2588
|
isVisible,
|
|
@@ -2990,8 +2595,8 @@ var Receipt = ({
|
|
|
2990
2595
|
receiptTitle,
|
|
2991
2596
|
tempReceiptId
|
|
2992
2597
|
}) => {
|
|
2993
|
-
const [animationState, setAnimationState] = (0,
|
|
2994
|
-
(0,
|
|
2598
|
+
const [animationState, setAnimationState] = (0, import_react11.useState)("hidden");
|
|
2599
|
+
(0, import_react11.useEffect)(() => {
|
|
2995
2600
|
if (isLoading) {
|
|
2996
2601
|
setAnimationState("printing");
|
|
2997
2602
|
} else if (isVisible && (result || error)) {
|
|
@@ -3002,7 +2607,7 @@ var Receipt = ({
|
|
|
3002
2607
|
setAnimationState("hidden");
|
|
3003
2608
|
}
|
|
3004
2609
|
}, [isLoading, isVisible, result, error]);
|
|
3005
|
-
(0,
|
|
2610
|
+
(0, import_react11.useEffect)(() => {
|
|
3006
2611
|
if (animationState === "bounce") {
|
|
3007
2612
|
const timer = setTimeout(() => setAnimationState("visible"), 150);
|
|
3008
2613
|
return () => clearTimeout(timer);
|
|
@@ -3076,13 +2681,13 @@ var Receipt = ({
|
|
|
3076
2681
|
}
|
|
3077
2682
|
};
|
|
3078
2683
|
if (animationState === "hidden" && !isLoading) return null;
|
|
3079
|
-
return /* @__PURE__ */
|
|
2684
|
+
return /* @__PURE__ */ import_react11.default.createElement(
|
|
3080
2685
|
"div",
|
|
3081
2686
|
{
|
|
3082
2687
|
className: "w-full flex justify-center",
|
|
3083
2688
|
style: getAnimationStyles()
|
|
3084
2689
|
},
|
|
3085
|
-
/* @__PURE__ */
|
|
2690
|
+
/* @__PURE__ */ import_react11.default.createElement(
|
|
3086
2691
|
"div",
|
|
3087
2692
|
{
|
|
3088
2693
|
className: "relative bg-white shadow-2xl",
|
|
@@ -3100,7 +2705,7 @@ var Receipt = ({
|
|
|
3100
2705
|
`
|
|
3101
2706
|
}
|
|
3102
2707
|
},
|
|
3103
|
-
/* @__PURE__ */
|
|
2708
|
+
/* @__PURE__ */ import_react11.default.createElement(
|
|
3104
2709
|
"div",
|
|
3105
2710
|
{
|
|
3106
2711
|
className: "absolute top-0 left-0 right-0",
|
|
@@ -3114,7 +2719,7 @@ var Receipt = ({
|
|
|
3114
2719
|
}
|
|
3115
2720
|
}
|
|
3116
2721
|
),
|
|
3117
|
-
/* @__PURE__ */
|
|
2722
|
+
/* @__PURE__ */ import_react11.default.createElement(
|
|
3118
2723
|
"div",
|
|
3119
2724
|
{
|
|
3120
2725
|
className: "absolute left-0 right-0 bg-white",
|
|
@@ -3124,7 +2729,7 @@ var Receipt = ({
|
|
|
3124
2729
|
}
|
|
3125
2730
|
}
|
|
3126
2731
|
),
|
|
3127
|
-
!isLoading && /* @__PURE__ */
|
|
2732
|
+
!isLoading && /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement(
|
|
3128
2733
|
"div",
|
|
3129
2734
|
{
|
|
3130
2735
|
className: "absolute bottom-0 left-0 right-0",
|
|
@@ -3137,7 +2742,7 @@ var Receipt = ({
|
|
|
3137
2742
|
backgroundRepeat: "repeat-x"
|
|
3138
2743
|
}
|
|
3139
2744
|
}
|
|
3140
|
-
), /* @__PURE__ */
|
|
2745
|
+
), /* @__PURE__ */ import_react11.default.createElement(
|
|
3141
2746
|
"div",
|
|
3142
2747
|
{
|
|
3143
2748
|
className: "absolute left-0 right-0 bg-white",
|
|
@@ -3147,16 +2752,16 @@ var Receipt = ({
|
|
|
3147
2752
|
}
|
|
3148
2753
|
}
|
|
3149
2754
|
)),
|
|
3150
|
-
!isLoading && (result || error) && /* @__PURE__ */
|
|
2755
|
+
!isLoading && (result || error) && /* @__PURE__ */ import_react11.default.createElement(
|
|
3151
2756
|
"button",
|
|
3152
2757
|
{
|
|
3153
2758
|
onClick: onClose,
|
|
3154
2759
|
className: "absolute top-3 right-3 text-gray-300 hover:text-gray-500 transition-colors bg-transparent border-none outline-none p-0 cursor-pointer",
|
|
3155
2760
|
style: { background: "none", border: "none" }
|
|
3156
2761
|
},
|
|
3157
|
-
/* @__PURE__ */
|
|
2762
|
+
/* @__PURE__ */ import_react11.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" }, /* @__PURE__ */ import_react11.default.createElement("path", { d: "M18 6L6 18M6 6l12 12" }))
|
|
3158
2763
|
),
|
|
3159
|
-
/* @__PURE__ */
|
|
2764
|
+
/* @__PURE__ */ import_react11.default.createElement("div", { className: "p-4 font-mono text-sm", style: getContentStyles() }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-center mb-3" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-base font-bold tracking-wider text-gray-800" }, receiptTitle), /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex justify-between text-xs text-gray-500 mt-1" }, /* @__PURE__ */ import_react11.default.createElement("span", null, "ID: ", receiptId), /* @__PURE__ */ import_react11.default.createElement("span", null, dateStr, " ", timeStr))), /* @__PURE__ */ import_react11.default.createElement("div", { className: "border-t border-dashed border-gray-300 my-2" }), /* @__PURE__ */ import_react11.default.createElement(
|
|
3160
2765
|
"div",
|
|
3161
2766
|
{
|
|
3162
2767
|
className: "max-h-64 overflow-y-auto pr-1",
|
|
@@ -3165,7 +2770,7 @@ var Receipt = ({
|
|
|
3165
2770
|
scrollbarColor: "#d1d5db transparent"
|
|
3166
2771
|
}
|
|
3167
2772
|
},
|
|
3168
|
-
isLoading ? /* @__PURE__ */
|
|
2773
|
+
isLoading ? /* @__PURE__ */ import_react11.default.createElement(LoadingContent, { primaryColor }) : error ? /* @__PURE__ */ import_react11.default.createElement(ErrorContent, { error }) : result ? /* @__PURE__ */ import_react11.default.createElement(
|
|
3169
2774
|
SuccessContent,
|
|
3170
2775
|
{
|
|
3171
2776
|
result,
|
|
@@ -3174,7 +2779,7 @@ var Receipt = ({
|
|
|
3174
2779
|
primaryColor
|
|
3175
2780
|
}
|
|
3176
2781
|
) : null
|
|
3177
|
-
), /* @__PURE__ */
|
|
2782
|
+
), /* @__PURE__ */ import_react11.default.createElement("div", { className: "border-t border-dashed border-gray-300 my-2" }), /* @__PURE__ */ import_react11.default.createElement(Barcode, null), /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-center text-xs text-gray-400 mt-1 tracking-widest" }, "POWERED BY", " ", /* @__PURE__ */ import_react11.default.createElement(
|
|
3178
2783
|
"a",
|
|
3179
2784
|
{
|
|
3180
2785
|
href: "https://v402pay.onvoyage.ai",
|
|
@@ -3187,7 +2792,7 @@ var Receipt = ({
|
|
|
3187
2792
|
)
|
|
3188
2793
|
);
|
|
3189
2794
|
};
|
|
3190
|
-
var LoadingContent = ({ primaryColor }) => /* @__PURE__ */
|
|
2795
|
+
var LoadingContent = ({ primaryColor }) => /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-center py-4" }, /* @__PURE__ */ import_react11.default.createElement(
|
|
3191
2796
|
"div",
|
|
3192
2797
|
{
|
|
3193
2798
|
className: "inline-block w-8 h-8 border-2 border-gray-200 rounded-full mb-2",
|
|
@@ -3196,15 +2801,15 @@ var LoadingContent = ({ primaryColor }) => /* @__PURE__ */ import_react12.defaul
|
|
|
3196
2801
|
animation: "spin 0.8s linear infinite"
|
|
3197
2802
|
}
|
|
3198
2803
|
}
|
|
3199
|
-
), /* @__PURE__ */
|
|
3200
|
-
var ErrorContent = ({ error }) => /* @__PURE__ */
|
|
2804
|
+
), /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-gray-700 font-semibold text-sm" }, "Processing..."), /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-gray-400 text-xs mt-1" }, "Please wait"));
|
|
2805
|
+
var ErrorContent = ({ error }) => /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-center py-3" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-red-500 text-2xl mb-2" }, "\u2717"), /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-red-600 font-semibold mb-1 text-sm" }, "FAILED"), /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-red-500 text-xs break-words px-2" }, error));
|
|
3201
2806
|
var SuccessContent = ({
|
|
3202
2807
|
result,
|
|
3203
2808
|
paymentDetails,
|
|
3204
2809
|
address,
|
|
3205
2810
|
primaryColor
|
|
3206
2811
|
}) => {
|
|
3207
|
-
const [copied, setCopied] = (0,
|
|
2812
|
+
const [copied, setCopied] = (0, import_react11.useState)(false);
|
|
3208
2813
|
const handleCopy = async () => {
|
|
3209
2814
|
try {
|
|
3210
2815
|
await navigator.clipboard.writeText(JSON.stringify(result, null, 2));
|
|
@@ -3214,15 +2819,15 @@ var SuccessContent = ({
|
|
|
3214
2819
|
console.error("Failed to copy:", err);
|
|
3215
2820
|
}
|
|
3216
2821
|
};
|
|
3217
|
-
return /* @__PURE__ */
|
|
2822
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", null, /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-center mb-2" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-2xl mb-1", style: { color: primaryColor } }, "\u2713"), /* @__PURE__ */ import_react11.default.createElement("div", { className: "font-semibold text-sm", style: { color: primaryColor } }, "SUCCESS")), /* @__PURE__ */ import_react11.default.createElement("div", { className: "space-y-1 text-xs" }, paymentDetails && /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex justify-between" }, /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-gray-500" }, "Amount:"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "font-semibold" }, "$", paymentDetails.amount, " ", paymentDetails.currency)), /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex justify-between" }, /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-gray-500" }, "Network:"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "font-semibold" }, paymentDetails.network))), address && /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex justify-between" }, /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-gray-500" }, "From:"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "font-semibold" }, formatAddress(address))), result.transactionHash && /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex justify-between" }, /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-gray-500" }, "TX:"), /* @__PURE__ */ import_react11.default.createElement("span", { className: "font-semibold" }, formatAddress(result.transactionHash)))), /* @__PURE__ */ import_react11.default.createElement("div", { className: "border-t border-dashed border-gray-300 my-2" }), /* @__PURE__ */ import_react11.default.createElement("div", { className: "text-xs" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex justify-between items-center mb-1" }, /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-gray-500" }, "Response:"), /* @__PURE__ */ import_react11.default.createElement(
|
|
3218
2823
|
"button",
|
|
3219
2824
|
{
|
|
3220
2825
|
onClick: handleCopy,
|
|
3221
2826
|
className: "text-gray-300 hover:text-gray-500 transition-colors flex items-center gap-1 bg-transparent border-none outline-none p-0 cursor-pointer",
|
|
3222
2827
|
style: { background: "none", border: "none" }
|
|
3223
2828
|
},
|
|
3224
|
-
copied ? /* @__PURE__ */
|
|
3225
|
-
)), /* @__PURE__ */
|
|
2829
|
+
copied ? /* @__PURE__ */ import_react11.default.createElement("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" }, /* @__PURE__ */ import_react11.default.createElement("path", { d: "M20 6L9 17l-5-5" })) : /* @__PURE__ */ import_react11.default.createElement("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }, /* @__PURE__ */ import_react11.default.createElement("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }), /* @__PURE__ */ import_react11.default.createElement("path", { d: "M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" }))
|
|
2830
|
+
)), /* @__PURE__ */ import_react11.default.createElement(
|
|
3226
2831
|
"pre",
|
|
3227
2832
|
{
|
|
3228
2833
|
className: "bg-gray-50 p-2 rounded text-xs overflow-auto whitespace-pre-wrap break-words",
|
|
@@ -3234,7 +2839,7 @@ var SuccessContent = ({
|
|
|
3234
2839
|
var Barcode = () => {
|
|
3235
2840
|
const pattern = [2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1];
|
|
3236
2841
|
const heights = [10, 12, 11, 13, 10, 14, 11, 12, 13, 10, 11, 14, 12, 10, 13, 11, 12, 14, 10, 11];
|
|
3237
|
-
return /* @__PURE__ */
|
|
2842
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex items-center justify-center gap-0.5 h-4 opacity-60" }, pattern.map((width, i) => /* @__PURE__ */ import_react11.default.createElement(
|
|
3238
2843
|
"div",
|
|
3239
2844
|
{
|
|
3240
2845
|
key: i,
|
|
@@ -3248,7 +2853,7 @@ var Barcode = () => {
|
|
|
3248
2853
|
};
|
|
3249
2854
|
|
|
3250
2855
|
// src/react/components/checkout/TerminalScreen.tsx
|
|
3251
|
-
var
|
|
2856
|
+
var import_react12 = __toESM(require("react"));
|
|
3252
2857
|
var TerminalScreen = ({
|
|
3253
2858
|
title,
|
|
3254
2859
|
tooltipText,
|
|
@@ -3259,7 +2864,7 @@ var TerminalScreen = ({
|
|
|
3259
2864
|
screenText,
|
|
3260
2865
|
supportedNetworks
|
|
3261
2866
|
}) => {
|
|
3262
|
-
return /* @__PURE__ */
|
|
2867
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
3263
2868
|
"div",
|
|
3264
2869
|
{
|
|
3265
2870
|
className: "rounded-xl p-3 mb-3",
|
|
@@ -3269,7 +2874,7 @@ var TerminalScreen = ({
|
|
|
3269
2874
|
border: "3px solid rgba(0,0,0,0.3)"
|
|
3270
2875
|
}
|
|
3271
2876
|
},
|
|
3272
|
-
/* @__PURE__ */
|
|
2877
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "flex justify-between items-center mb-2" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "flex items-center gap-1.5 flex-1 min-w-0" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "w-2.5 h-2.5 rounded border border-green-700 flex-shrink-0" }), title ? /* @__PURE__ */ import_react12.default.createElement(
|
|
3273
2878
|
"span",
|
|
3274
2879
|
{
|
|
3275
2880
|
className: "text-xs font-mono",
|
|
@@ -3277,29 +2882,29 @@ var TerminalScreen = ({
|
|
|
3277
2882
|
title
|
|
3278
2883
|
},
|
|
3279
2884
|
title.length > 26 ? `${title.slice(0, 13)}...${title.slice(-13)}` : title
|
|
3280
|
-
) : /* @__PURE__ */
|
|
2885
|
+
) : /* @__PURE__ */ import_react12.default.createElement("span", { className: "text-xs font-mono", style: { color: "#22c55e80" } }, "CHECKOUT")), /* @__PURE__ */ import_react12.default.createElement(
|
|
3281
2886
|
"div",
|
|
3282
2887
|
{
|
|
3283
2888
|
className: "flex gap-0.5 flex-shrink-0 cursor-help",
|
|
3284
2889
|
title: tooltipText
|
|
3285
2890
|
},
|
|
3286
|
-
/* @__PURE__ */
|
|
2891
|
+
/* @__PURE__ */ import_react12.default.createElement(
|
|
3287
2892
|
"div",
|
|
3288
2893
|
{
|
|
3289
2894
|
className: "w-1 h-1.5 rounded-sm",
|
|
3290
2895
|
style: { backgroundColor: address ? "#22c55e80" : "#22c55e30" }
|
|
3291
2896
|
}
|
|
3292
2897
|
),
|
|
3293
|
-
/* @__PURE__ */
|
|
2898
|
+
/* @__PURE__ */ import_react12.default.createElement(
|
|
3294
2899
|
"div",
|
|
3295
2900
|
{
|
|
3296
2901
|
className: "w-1 h-1.5 rounded-sm",
|
|
3297
2902
|
style: { backgroundColor: address ? "#22c55e80" : "#22c55e30" }
|
|
3298
2903
|
}
|
|
3299
2904
|
),
|
|
3300
|
-
/* @__PURE__ */
|
|
2905
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "w-1 h-1.5 rounded-sm", style: { backgroundColor: "#22c55e80" } })
|
|
3301
2906
|
)),
|
|
3302
|
-
/* @__PURE__ */
|
|
2907
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "min-h-[120px]" }, hasInvalidCheckoutId ? /* @__PURE__ */ import_react12.default.createElement(InvalidIdContent, null) : fetchingPaymentInfo ? /* @__PURE__ */ import_react12.default.createElement(LoadingContent2, null) : !address ? /* @__PURE__ */ import_react12.default.createElement(ConnectWalletContent, { supportedNetworks }) : /* @__PURE__ */ import_react12.default.createElement(
|
|
3303
2908
|
PaymentInfoContent,
|
|
3304
2909
|
{
|
|
3305
2910
|
screenText,
|
|
@@ -3309,8 +2914,8 @@ var TerminalScreen = ({
|
|
|
3309
2914
|
))
|
|
3310
2915
|
);
|
|
3311
2916
|
};
|
|
3312
|
-
var InvalidIdContent = () => /* @__PURE__ */
|
|
3313
|
-
var LoadingContent2 = () => /* @__PURE__ */
|
|
2917
|
+
var InvalidIdContent = () => /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-center py-3" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-red-500 text-xl mb-1" }, "\u2717"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-red-500 font-mono text-sm mb-1" }, "INVALID ID"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-red-400 font-mono text-xs" }, "Check your checkout ID"));
|
|
2918
|
+
var LoadingContent2 = () => /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-center py-4" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
3314
2919
|
"div",
|
|
3315
2920
|
{
|
|
3316
2921
|
className: "inline-block w-5 h-5 border-2 rounded-full mb-2",
|
|
@@ -3320,30 +2925,30 @@ var LoadingContent2 = () => /* @__PURE__ */ import_react13.default.createElement
|
|
|
3320
2925
|
animation: "spin 1s linear infinite"
|
|
3321
2926
|
}
|
|
3322
2927
|
}
|
|
3323
|
-
), /* @__PURE__ */
|
|
3324
|
-
var ConnectWalletContent = ({ supportedNetworks }) => /* @__PURE__ */
|
|
2928
|
+
), /* @__PURE__ */ import_react12.default.createElement("div", { className: "font-mono text-sm", style: { color: "#22c55e" } }, "LOADING..."));
|
|
2929
|
+
var ConnectWalletContent = ({ supportedNetworks }) => /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement(
|
|
3325
2930
|
"div",
|
|
3326
2931
|
{
|
|
3327
2932
|
className: "font-mono text-base mb-3 tracking-wider",
|
|
3328
2933
|
style: { color: "#f97316", textShadow: "0 0 10px #f9731640" }
|
|
3329
2934
|
},
|
|
3330
2935
|
"CONNECT WALLET..."
|
|
3331
|
-
), /* @__PURE__ */
|
|
2936
|
+
), /* @__PURE__ */ import_react12.default.createElement(WalletConnect, { supportedNetworks, showSwitchWallet: false }));
|
|
3332
2937
|
var PaymentInfoContent = ({
|
|
3333
2938
|
screenText,
|
|
3334
2939
|
paymentDetails,
|
|
3335
2940
|
address
|
|
3336
|
-
}) => /* @__PURE__ */
|
|
2941
|
+
}) => /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement(
|
|
3337
2942
|
"div",
|
|
3338
2943
|
{
|
|
3339
2944
|
className: "font-mono text-base mb-3 tracking-wider",
|
|
3340
2945
|
style: { color: "#f97316", textShadow: "0 0 10px #f9731640" }
|
|
3341
2946
|
},
|
|
3342
2947
|
screenText
|
|
3343
|
-
), paymentDetails && /* @__PURE__ */
|
|
2948
|
+
), paymentDetails && /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-xs font-mono" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "grid grid-cols-2 gap-1.5 mb-1.5" }, /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement("div", { style: { color: "#22c55e60" } }, "AMOUNT"), /* @__PURE__ */ import_react12.default.createElement("div", { style: { color: "#22c55e" } }, "$", paymentDetails.amount)), /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement("div", { style: { color: "#22c55e60" } }, "CURRENCY"), /* @__PURE__ */ import_react12.default.createElement("div", { style: { color: "#22c55e" } }, paymentDetails.currency))), /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement("div", { style: { color: "#22c55e60" } }, "WALLET"), /* @__PURE__ */ import_react12.default.createElement("div", { style: { color: "#22c55e", wordBreak: "break-all" } }, address))));
|
|
3344
2949
|
|
|
3345
2950
|
// src/react/components/checkout/TerminalButtons.tsx
|
|
3346
|
-
var
|
|
2951
|
+
var import_react13 = __toESM(require("react"));
|
|
3347
2952
|
var TerminalButtons = ({
|
|
3348
2953
|
address,
|
|
3349
2954
|
showReceipt,
|
|
@@ -3355,7 +2960,7 @@ var TerminalButtons = ({
|
|
|
3355
2960
|
onPayment
|
|
3356
2961
|
}) => {
|
|
3357
2962
|
const isPayDisabled = isProcessing || !paymentDetails || !address || hasInvalidCheckoutId;
|
|
3358
|
-
return /* @__PURE__ */
|
|
2963
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center justify-between px-1" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex gap-2" }, /* @__PURE__ */ import_react13.default.createElement(
|
|
3359
2964
|
CircleButton,
|
|
3360
2965
|
{
|
|
3361
2966
|
onClick: () => address && onDisconnect(),
|
|
@@ -3363,8 +2968,8 @@ var TerminalButtons = ({
|
|
|
3363
2968
|
title: "Disconnect",
|
|
3364
2969
|
size: "small"
|
|
3365
2970
|
},
|
|
3366
|
-
/* @__PURE__ */
|
|
3367
|
-
), /* @__PURE__ */
|
|
2971
|
+
/* @__PURE__ */ import_react13.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2" }, /* @__PURE__ */ import_react13.default.createElement("path", { d: "M18 6L6 18M6 6l12 12" }))
|
|
2972
|
+
), /* @__PURE__ */ import_react13.default.createElement(
|
|
3368
2973
|
CircleButton,
|
|
3369
2974
|
{
|
|
3370
2975
|
onClick: onClearReceipt,
|
|
@@ -3372,8 +2977,8 @@ var TerminalButtons = ({
|
|
|
3372
2977
|
title: "Clear",
|
|
3373
2978
|
size: "small"
|
|
3374
2979
|
},
|
|
3375
|
-
/* @__PURE__ */
|
|
3376
|
-
)), /* @__PURE__ */
|
|
2980
|
+
/* @__PURE__ */ import_react13.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2" }, /* @__PURE__ */ import_react13.default.createElement("path", { d: "M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2m3 0v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6h14z" }))
|
|
2981
|
+
)), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex flex-col gap-0.5 opacity-40" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "w-6 h-0.5 rounded", style: { backgroundColor: "rgba(0,0,0,0.3)" } }), /* @__PURE__ */ import_react13.default.createElement("div", { className: "w-6 h-0.5 rounded", style: { backgroundColor: "rgba(0,0,0,0.3)" } }), /* @__PURE__ */ import_react13.default.createElement("div", { className: "w-6 h-0.5 rounded", style: { backgroundColor: "rgba(0,0,0,0.3)" } })), /* @__PURE__ */ import_react13.default.createElement(
|
|
3377
2982
|
"button",
|
|
3378
2983
|
{
|
|
3379
2984
|
onClick: onPayment,
|
|
@@ -3385,13 +2990,13 @@ var TerminalButtons = ({
|
|
|
3385
2990
|
cursor: isPayDisabled ? "not-allowed" : "pointer"
|
|
3386
2991
|
}
|
|
3387
2992
|
},
|
|
3388
|
-
isProcessing ? /* @__PURE__ */
|
|
2993
|
+
isProcessing ? /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
|
|
3389
2994
|
"div",
|
|
3390
2995
|
{
|
|
3391
2996
|
className: "w-4 h-4 border-2 border-white/30 border-t-white rounded-full",
|
|
3392
2997
|
style: { animation: "spin 0.8s linear infinite" }
|
|
3393
2998
|
}
|
|
3394
|
-
), /* @__PURE__ */
|
|
2999
|
+
), /* @__PURE__ */ import_react13.default.createElement("span", { className: "font-mono tracking-wider text-sm" }, "PAYING...")) : /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("span", { className: "font-mono tracking-wider text-sm" }, "PAY"), /* @__PURE__ */ import_react13.default.createElement(
|
|
3395
3000
|
"svg",
|
|
3396
3001
|
{
|
|
3397
3002
|
width: "18",
|
|
@@ -3401,13 +3006,13 @@ var TerminalButtons = ({
|
|
|
3401
3006
|
stroke: "currentColor",
|
|
3402
3007
|
strokeWidth: "2"
|
|
3403
3008
|
},
|
|
3404
|
-
/* @__PURE__ */
|
|
3009
|
+
/* @__PURE__ */ import_react13.default.createElement("path", { d: "M12 2v20M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6" })
|
|
3405
3010
|
))
|
|
3406
3011
|
));
|
|
3407
3012
|
};
|
|
3408
3013
|
var CircleButton = ({ onClick, disabled, title, size = "normal", children }) => {
|
|
3409
3014
|
const sizeClass = size === "small" ? "w-10 h-10" : "w-12 h-12";
|
|
3410
|
-
return /* @__PURE__ */
|
|
3015
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
3411
3016
|
"button",
|
|
3412
3017
|
{
|
|
3413
3018
|
onClick,
|
|
@@ -3456,9 +3061,9 @@ function V402CheckoutV2({
|
|
|
3456
3061
|
{ autoSwitch: !!targetNetwork, switchOnMount: true }
|
|
3457
3062
|
);
|
|
3458
3063
|
const { isProcessing, setIsProcessing, result, setResult, error, setError } = usePayment();
|
|
3459
|
-
const [paymentDetails, setPaymentDetails] = (0,
|
|
3460
|
-
const [showReceipt, setShowReceipt] = (0,
|
|
3461
|
-
const [tempReceiptId, setTempReceiptId] = (0,
|
|
3064
|
+
const [paymentDetails, setPaymentDetails] = (0, import_react14.useState)(null);
|
|
3065
|
+
const [showReceipt, setShowReceipt] = (0, import_react14.useState)(false);
|
|
3066
|
+
const [tempReceiptId, setTempReceiptId] = (0, import_react14.useState)(() => generateRandomId());
|
|
3462
3067
|
const handleDisconnect = () => {
|
|
3463
3068
|
disconnect();
|
|
3464
3069
|
setResult(null);
|
|
@@ -3490,7 +3095,7 @@ function V402CheckoutV2({
|
|
|
3490
3095
|
setResult(null);
|
|
3491
3096
|
setError(null);
|
|
3492
3097
|
};
|
|
3493
|
-
(0,
|
|
3098
|
+
(0, import_react14.useEffect)(() => {
|
|
3494
3099
|
if (paymentInfo && paymentInfo.length > 0) {
|
|
3495
3100
|
const firstPayment = paymentInfo[0];
|
|
3496
3101
|
const rawAmount = firstPayment.maxAmountRequired?.toString() || "0";
|
|
@@ -3501,14 +3106,14 @@ function V402CheckoutV2({
|
|
|
3501
3106
|
setPaymentDetails({ amount: humanReadableAmount, currency, network });
|
|
3502
3107
|
}
|
|
3503
3108
|
}, [paymentInfo]);
|
|
3504
|
-
(0,
|
|
3109
|
+
(0, import_react14.useEffect)(() => {
|
|
3505
3110
|
if (targetNetwork && !fetchingPaymentInfo && ensureNetwork) {
|
|
3506
3111
|
ensureNetwork(targetNetwork).catch((err) => {
|
|
3507
3112
|
console.error("Failed to ensure network:", err);
|
|
3508
3113
|
});
|
|
3509
3114
|
}
|
|
3510
3115
|
}, [targetNetwork, fetchingPaymentInfo]);
|
|
3511
|
-
(0,
|
|
3116
|
+
(0, import_react14.useEffect)(() => {
|
|
3512
3117
|
if (isProcessing || result || error) {
|
|
3513
3118
|
setShowReceipt(true);
|
|
3514
3119
|
}
|
|
@@ -3523,13 +3128,13 @@ function V402CheckoutV2({
|
|
|
3523
3128
|
if (isProcessing) return "PAYING";
|
|
3524
3129
|
return "READY";
|
|
3525
3130
|
};
|
|
3526
|
-
return /* @__PURE__ */
|
|
3131
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", { className: isModal ? "bg-transparent" : "min-h-screen bg-gray-100 flex items-center justify-center p-4" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
3527
3132
|
"div",
|
|
3528
3133
|
{
|
|
3529
3134
|
className: "flex flex-col items-center",
|
|
3530
3135
|
style: { width: isModal ? "100%" : "380px", maxWidth: "100%" }
|
|
3531
3136
|
},
|
|
3532
|
-
/* @__PURE__ */
|
|
3137
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
3533
3138
|
Receipt,
|
|
3534
3139
|
{
|
|
3535
3140
|
isLoading: isProcessing,
|
|
@@ -3544,7 +3149,7 @@ function V402CheckoutV2({
|
|
|
3544
3149
|
tempReceiptId
|
|
3545
3150
|
}
|
|
3546
3151
|
),
|
|
3547
|
-
/* @__PURE__ */
|
|
3152
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
3548
3153
|
"div",
|
|
3549
3154
|
{
|
|
3550
3155
|
className: "relative rounded-2xl p-3 shadow-2xl w-full",
|
|
@@ -3553,14 +3158,14 @@ function V402CheckoutV2({
|
|
|
3553
3158
|
boxShadow: `0 16px 48px -8px ${primaryColor}66, 0 8px 24px -4px rgba(0,0,0,0.3);padding-bottom: 0px`
|
|
3554
3159
|
}
|
|
3555
3160
|
},
|
|
3556
|
-
/* @__PURE__ */
|
|
3161
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
3557
3162
|
"div",
|
|
3558
3163
|
{
|
|
3559
3164
|
className: "absolute top-0 left-1/2 -translate-x-1/2 w-1/3 h-2.5 rounded-b-lg",
|
|
3560
3165
|
style: { backgroundColor: "rgba(0,0,0,0.4)" }
|
|
3561
3166
|
}
|
|
3562
3167
|
),
|
|
3563
|
-
/* @__PURE__ */
|
|
3168
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "flex justify-between items-center mb-2 mt-1 px-1" }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center gap-1.5" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
3564
3169
|
"div",
|
|
3565
3170
|
{
|
|
3566
3171
|
className: "w-2 h-2 rounded-full",
|
|
@@ -3569,15 +3174,15 @@ function V402CheckoutV2({
|
|
|
3569
3174
|
animation: "pulse 2s ease-in-out infinite"
|
|
3570
3175
|
}
|
|
3571
3176
|
}
|
|
3572
|
-
), /* @__PURE__ */
|
|
3177
|
+
), /* @__PURE__ */ import_react14.default.createElement(
|
|
3573
3178
|
"span",
|
|
3574
3179
|
{
|
|
3575
3180
|
className: "text-xs font-mono font-bold tracking-wider",
|
|
3576
3181
|
style: { color: "rgba(0,0,0,0.7)" }
|
|
3577
3182
|
},
|
|
3578
3183
|
getStatusText()
|
|
3579
|
-
)), /* @__PURE__ */
|
|
3580
|
-
/* @__PURE__ */
|
|
3184
|
+
)), /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center gap-1.5" }, paymentDetails && NetworkIcon && /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center gap-1" }, /* @__PURE__ */ import_react14.default.createElement(NetworkIcon, { width: 12, height: 12, style: { color: "rgba(0,0,0,0.7)" } }), /* @__PURE__ */ import_react14.default.createElement("span", { className: "text-xs font-mono font-bold", style: { color: "rgba(0,0,0,0.7)" } }, paymentDetails.network)))),
|
|
3185
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
3581
3186
|
TerminalScreen,
|
|
3582
3187
|
{
|
|
3583
3188
|
title,
|
|
@@ -3590,7 +3195,7 @@ function V402CheckoutV2({
|
|
|
3590
3195
|
supportedNetworks
|
|
3591
3196
|
}
|
|
3592
3197
|
),
|
|
3593
|
-
/* @__PURE__ */
|
|
3198
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
3594
3199
|
TerminalButtons,
|
|
3595
3200
|
{
|
|
3596
3201
|
address,
|
|
@@ -3603,7 +3208,7 @@ function V402CheckoutV2({
|
|
|
3603
3208
|
onPayment: handlePayment
|
|
3604
3209
|
}
|
|
3605
3210
|
),
|
|
3606
|
-
brandName && /* @__PURE__ */
|
|
3211
|
+
brandName && /* @__PURE__ */ import_react14.default.createElement("div", { className: "text-center mt-0 mb-0" }, /* @__PURE__ */ import_react14.default.createElement(
|
|
3607
3212
|
"div",
|
|
3608
3213
|
{
|
|
3609
3214
|
className: "inline-block px-2 py-0.5 rounded text-[10px] font-mono font-bold tracking-[0.2em]",
|
|
@@ -3618,13 +3223,12 @@ function V402CheckoutV2({
|
|
|
3618
3223
|
brandName
|
|
3619
3224
|
))
|
|
3620
3225
|
)
|
|
3621
|
-
), /* @__PURE__ */
|
|
3226
|
+
), /* @__PURE__ */ import_react14.default.createElement(AnimationStyles, null));
|
|
3622
3227
|
}
|
|
3623
3228
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3624
3229
|
0 && (module.exports = {
|
|
3625
3230
|
AnimationStyles,
|
|
3626
3231
|
Toast,
|
|
3627
|
-
V402Checkout,
|
|
3628
3232
|
V402CheckoutV2,
|
|
3629
3233
|
WalletConnect,
|
|
3630
3234
|
WalletSelectModal,
|