@b3dotfun/sdk 0.0.16 → 0.0.17-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +5 -2
  2. package/dist/cjs/anyspend/react/components/AnySpend.js +264 -55
  3. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +25 -29
  4. package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +15 -0
  5. package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +49 -0
  6. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +20 -0
  7. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +118 -0
  8. package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.d.ts +15 -0
  9. package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +71 -0
  10. package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -0
  11. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +41 -60
  12. package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +18 -0
  13. package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +42 -0
  14. package/dist/cjs/anyspend/react/components/common/OrderStatus.js +28 -5
  15. package/dist/cjs/anyspend/react/components/common/OrderTokenAmountFiat.d.ts +13 -0
  16. package/dist/cjs/anyspend/react/components/common/OrderTokenAmountFiat.js +50 -0
  17. package/dist/cjs/anyspend/react/components/common/OrderTokenAmountNew.d.ts +16 -0
  18. package/dist/cjs/anyspend/react/components/common/OrderTokenAmountNew.js +63 -0
  19. package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +11 -1
  20. package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +53 -15
  21. package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +1 -12
  22. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +4 -12
  23. package/dist/cjs/anyspend/react/components/common/StepProgress.d.ts +11 -0
  24. package/dist/cjs/anyspend/react/components/common/StepProgress.js +22 -0
  25. package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +16 -0
  26. package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +73 -0
  27. package/dist/cjs/anyspend/react/components/index.d.ts +3 -0
  28. package/dist/cjs/anyspend/react/components/index.js +7 -1
  29. package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +1 -10
  30. package/dist/cjs/anyspend/utils/format.d.ts +1 -0
  31. package/dist/cjs/anyspend/utils/format.js +23 -10
  32. package/dist/cjs/anyspend/utils/number.d.ts +7 -0
  33. package/dist/cjs/anyspend/utils/number.js +18 -0
  34. package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -2
  35. package/dist/esm/anyspend/react/components/AnySpend.js +266 -57
  36. package/dist/esm/anyspend/react/components/AnySpendCustom.js +27 -31
  37. package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +15 -0
  38. package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +46 -0
  39. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +20 -0
  40. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +114 -0
  41. package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.d.ts +15 -0
  42. package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +67 -0
  43. package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -0
  44. package/dist/esm/anyspend/react/components/common/OrderDetails.js +43 -62
  45. package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +18 -0
  46. package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +36 -0
  47. package/dist/esm/anyspend/react/components/common/OrderStatus.js +27 -4
  48. package/dist/esm/anyspend/react/components/common/OrderTokenAmountFiat.d.ts +13 -0
  49. package/dist/esm/anyspend/react/components/common/OrderTokenAmountFiat.js +47 -0
  50. package/dist/esm/anyspend/react/components/common/OrderTokenAmountNew.d.ts +16 -0
  51. package/dist/esm/anyspend/react/components/common/OrderTokenAmountNew.js +60 -0
  52. package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +11 -1
  53. package/dist/esm/anyspend/react/components/common/PanelOnramp.js +54 -16
  54. package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +1 -12
  55. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +7 -15
  56. package/dist/esm/anyspend/react/components/common/StepProgress.d.ts +11 -0
  57. package/dist/esm/anyspend/react/components/common/StepProgress.js +19 -0
  58. package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +16 -0
  59. package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +70 -0
  60. package/dist/esm/anyspend/react/components/index.d.ts +3 -0
  61. package/dist/esm/anyspend/react/components/index.js +3 -0
  62. package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +1 -10
  63. package/dist/esm/anyspend/utils/format.d.ts +1 -0
  64. package/dist/esm/anyspend/utils/format.js +23 -10
  65. package/dist/esm/anyspend/utils/number.d.ts +7 -0
  66. package/dist/esm/anyspend/utils/number.js +17 -0
  67. package/dist/styles/index.css +1 -1
  68. package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -2
  69. package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +15 -0
  70. package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +20 -0
  71. package/dist/types/anyspend/react/components/common/FiatPaymentMethod.d.ts +15 -0
  72. package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -0
  73. package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +18 -0
  74. package/dist/types/anyspend/react/components/common/OrderTokenAmountFiat.d.ts +13 -0
  75. package/dist/types/anyspend/react/components/common/OrderTokenAmountNew.d.ts +16 -0
  76. package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +11 -1
  77. package/dist/types/anyspend/react/components/common/StepProgress.d.ts +11 -0
  78. package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +16 -0
  79. package/dist/types/anyspend/react/components/index.d.ts +3 -0
  80. package/dist/types/anyspend/utils/format.d.ts +1 -0
  81. package/dist/types/anyspend/utils/number.d.ts +7 -0
  82. package/package.json +1 -1
  83. package/src/anyspend/react/components/AnySpend.tsx +535 -177
  84. package/src/anyspend/react/components/AnySpendCustom.tsx +33 -38
  85. package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +124 -0
  86. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +227 -0
  87. package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +173 -0
  88. package/src/anyspend/react/components/common/OrderDetails.tsx +123 -250
  89. package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +156 -0
  90. package/src/anyspend/react/components/common/OrderStatus.tsx +47 -24
  91. package/src/anyspend/react/components/common/OrderTokenAmountFiat.tsx +147 -0
  92. package/src/anyspend/react/components/common/OrderTokenAmountNew.tsx +215 -0
  93. package/src/anyspend/react/components/common/PanelOnramp.tsx +215 -62
  94. package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +1 -14
  95. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +42 -99
  96. package/src/anyspend/react/components/common/StepProgress.tsx +104 -0
  97. package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +261 -0
  98. package/src/anyspend/react/components/index.ts +3 -0
  99. package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +1 -11
  100. package/src/anyspend/utils/format.ts +24 -11
  101. package/src/anyspend/utils/number.ts +18 -0
  102. package/src/styles/index.css +30 -11
@@ -9,9 +9,12 @@ export declare enum PanelView {
9
9
  HISTORY = 1,
10
10
  ORDER_DETAILS = 2,
11
11
  LOADING = 3,
12
- FIAT_PAYMENT = 4
12
+ FIAT_PAYMENT = 4,
13
+ RECIPIENT_SELECTION = 5,
14
+ CRYPTO_PAYMENT_METHOD = 6,
15
+ FIAT_PAYMENT_METHOD = 7
13
16
  }
14
- export declare function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet, mode, defaultActiveTab, loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }: {
17
+ export declare function AnySpend(props: {
15
18
  destinationTokenAddress?: string;
16
19
  destinationTokenChainId?: number;
17
20
  isMainnet?: boolean;
@@ -20,6 +20,10 @@ const react_4 = require("react");
20
20
  const sonner_1 = require("sonner");
21
21
  const viem_1 = require("viem");
22
22
  const chains_1 = require("viem/chains");
23
+ const wagmi_1 = require("wagmi");
24
+ const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
25
+ const CryptoPaymentMethod_1 = require("./common/CryptoPaymentMethod");
26
+ const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
23
27
  const OrderDetails_1 = require("./common/OrderDetails");
24
28
  const OrderHistory_1 = require("./common/OrderHistory");
25
29
  const OrderStatus_1 = require("./common/OrderStatus");
@@ -27,7 +31,6 @@ const OrderTokenAmount_1 = require("./common/OrderTokenAmount");
27
31
  const PanelOnramp_1 = require("./common/PanelOnramp");
28
32
  const PanelOnrampPayment_1 = require("./common/PanelOnrampPayment");
29
33
  const TokenBalance_1 = require("./common/TokenBalance");
30
- const EnterRecipientModal_1 = require("./modals/EnterRecipientModal");
31
34
  var PanelView;
32
35
  (function (PanelView) {
33
36
  PanelView[PanelView["MAIN"] = 0] = "MAIN";
@@ -35,11 +38,20 @@ var PanelView;
35
38
  PanelView[PanelView["ORDER_DETAILS"] = 2] = "ORDER_DETAILS";
36
39
  PanelView[PanelView["LOADING"] = 3] = "LOADING";
37
40
  PanelView[PanelView["FIAT_PAYMENT"] = 4] = "FIAT_PAYMENT";
41
+ PanelView[PanelView["RECIPIENT_SELECTION"] = 5] = "RECIPIENT_SELECTION";
42
+ PanelView[PanelView["CRYPTO_PAYMENT_METHOD"] = 6] = "CRYPTO_PAYMENT_METHOD";
43
+ PanelView[PanelView["FIAT_PAYMENT_METHOD"] = 7] = "FIAT_PAYMENT_METHOD";
38
44
  })(PanelView || (exports.PanelView = PanelView = {}));
39
45
  const ANYSPEND_RECIPIENTS_KEY = "anyspend_recipients";
40
- function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet = true, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }) {
46
+ function AnySpend(props) {
47
+ const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
48
+ return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendInner, { ...props }) }));
49
+ }
50
+ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMainnet = true, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }) {
41
51
  const searchParams = (0, react_2.useSearchParamsSSR)();
42
52
  const router = (0, react_2.useRouter)();
53
+ // Get wagmi account state for wallet connection
54
+ const wagmiAccount = (0, wagmi_1.useAccount)();
43
55
  // Determine if we're in "buy mode" based on whether destination token props are provided
44
56
  const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
45
57
  // Add refs to track URL state
@@ -51,6 +63,10 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
51
63
  !!getOrderAndTransactionsError && console.log("getOrderAndTransactionsError", getOrderAndTransactionsError);
52
64
  const [activePanel, setActivePanel] = (0, react_4.useState)(loadOrder ? PanelView.ORDER_DETAILS : PanelView.MAIN);
53
65
  const [customRecipients, setCustomRecipients] = (0, react_4.useState)([]);
66
+ // Add state for selected payment method
67
+ const [selectedPaymentMethod, setSelectedPaymentMethod] = (0, react_4.useState)(CryptoPaymentMethod_1.PaymentMethod.NONE);
68
+ // Add state for selected fiat payment method
69
+ const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = (0, react_4.useState)(FiatPaymentMethod_1.FiatPaymentMethod.NONE);
54
70
  // const [newRecipientAddress, setNewRecipientAddress] = useState("");
55
71
  // const recipientInputRef = useRef<HTMLInputElement>(null);
56
72
  // Get initial chain IDs from URL or defaults
@@ -472,9 +488,36 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
472
488
  setOrderId(orderId);
473
489
  // setNewRecipientAddress("");
474
490
  setActivePanel(PanelView.ORDER_DETAILS);
475
- // Add orderId to URL for persistence
476
- const params = new URLSearchParams();
491
+ // Debug: Check payment method before setting URL
492
+ console.log("Creating order - selectedPaymentMethod:", selectedPaymentMethod);
493
+ // Add orderId and payment method to URL for persistence
494
+ const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
495
+ params.set("orderId", orderId);
496
+ if (selectedPaymentMethod !== CryptoPaymentMethod_1.PaymentMethod.NONE) {
497
+ console.log("Setting paymentMethod in URL:", selectedPaymentMethod);
498
+ params.set("paymentMethod", selectedPaymentMethod);
499
+ }
500
+ else {
501
+ console.log("Payment method is NONE, not setting in URL");
502
+ }
503
+ console.log("Final URL params:", params.toString());
504
+ router.push(`${window.location.pathname}?${params.toString()}`);
505
+ },
506
+ onError: error => {
507
+ console.error(error);
508
+ sonner_1.toast.error("Failed to create order: " + error.message);
509
+ },
510
+ });
511
+ // Add onramp order creation hook
512
+ const { createOrder: createOnrampOrder, isCreatingOrder: isCreatingOnrampOrder } = (0, react_1.useAnyspendCreateOnrampOrder)({
513
+ onSuccess: data => {
514
+ const orderId = data.data.id;
515
+ setOrderId(orderId);
516
+ setActivePanel(PanelView.ORDER_DETAILS);
517
+ // Add orderId and payment method to URL for persistence
518
+ const params = new URLSearchParams(searchParams.toString());
477
519
  params.set("orderId", orderId);
520
+ params.set("paymentMethod", "fiat");
478
521
  router.push(`${window.location.pathname}?${params.toString()}`);
479
522
  },
480
523
  onError: error => {
@@ -482,6 +525,8 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
482
525
  sonner_1.toast.error("Failed to create order: " + error.message);
483
526
  },
484
527
  });
528
+ // Get geo-based onramp options for fiat payments
529
+ const { geoData, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(isMainnet, srcAmountOnRamp);
485
530
  // Determine button state and text
486
531
  const btnInfo = (0, react_4.useMemo)(() => {
487
532
  if (activeInputAmountInWei === "0")
@@ -490,38 +535,102 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
490
535
  return { text: "Loading...", disable: true, error: false };
491
536
  if (!recipientAddress)
492
537
  return { text: "Select recipient", disable: false, error: false };
493
- if (isCreatingOrder)
538
+ if (isCreatingOrder || isCreatingOnrampOrder)
494
539
  return { text: "Creating order...", disable: true, error: false };
495
540
  if (!anyspendQuote || !anyspendQuote.success)
496
541
  return { text: "Get rate error", disable: true, error: true };
497
- if (activeTab === "fiat")
498
- return { text: "Continue to payment", disable: false, error: false };
499
- return { text: isBuyMode ? `Buy ${selectedDstToken.symbol}` : "Swap", disable: false, error: false };
542
+ if (activeTab === "crypto") {
543
+ // If no payment method selected, show "Choose payment method"
544
+ if (selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.NONE) {
545
+ return { text: "Choose payment method", disable: false, error: false };
546
+ }
547
+ // If payment method selected, show appropriate action
548
+ if (selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.CONNECT_WALLET) {
549
+ return { text: "Swap", disable: false, error: false };
550
+ }
551
+ if (selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.TRANSFER_CRYPTO) {
552
+ return { text: "Continue to payment", disable: false, error: false };
553
+ }
554
+ }
555
+ if (activeTab === "fiat") {
556
+ // If no fiat payment method selected, show "Select payment method"
557
+ if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.NONE) {
558
+ return { text: "Select payment method", disable: false, error: false };
559
+ }
560
+ // If payment method is selected, show "Buy"
561
+ return { text: "Buy", disable: false, error: false };
562
+ }
563
+ return { text: "Buy", disable: false, error: false };
500
564
  }, [
501
565
  activeInputAmountInWei,
502
566
  isLoadingAnyspendQuote,
503
567
  recipientAddress,
504
568
  isCreatingOrder,
569
+ isCreatingOnrampOrder,
505
570
  anyspendQuote,
506
571
  activeTab,
507
- isBuyMode,
508
- selectedDstToken.symbol,
572
+ selectedPaymentMethod,
573
+ selectedFiatPaymentMethod,
509
574
  ]);
510
575
  // Handle main button click
511
576
  const onMainButtonClick = async () => {
512
577
  if (btnInfo.disable)
513
578
  return;
514
579
  if (!recipientAddress) {
515
- setIsOpenPasteRecipientAddressModal(true);
580
+ setActivePanel(PanelView.RECIPIENT_SELECTION);
516
581
  return;
517
582
  }
518
583
  try {
519
584
  (0, invariant_1.default)(anyspendQuote, "Relay price is not found");
520
585
  (0, invariant_1.default)(recipientAddress, "Recipient address is not found");
521
586
  if (activeTab === "fiat") {
522
- setActivePanel(PanelView.FIAT_PAYMENT);
587
+ // If no fiat payment method selected, show payment method selection
588
+ if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.NONE) {
589
+ setActivePanel(PanelView.FIAT_PAYMENT_METHOD);
590
+ return;
591
+ }
592
+ // If payment method is selected, create order directly
593
+ await handleFiatOrder(selectedFiatPaymentMethod);
523
594
  return;
524
595
  }
596
+ if (activeTab === "crypto") {
597
+ // If no payment method selected, show payment method selection
598
+ if (selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.NONE) {
599
+ console.log("No payment method selected, showing selection panel");
600
+ setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD);
601
+ return;
602
+ }
603
+ // If payment method is selected, create order with payment method info
604
+ if (selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.CONNECT_WALLET ||
605
+ selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.TRANSFER_CRYPTO) {
606
+ console.log("Creating crypto order with payment method:", selectedPaymentMethod);
607
+ await handleCryptoSwap(selectedPaymentMethod);
608
+ return;
609
+ }
610
+ }
611
+ }
612
+ catch (err) {
613
+ console.error(err);
614
+ sonner_1.toast.error("Failed to create order: " + err.message);
615
+ }
616
+ };
617
+ const onClickHistory = () => {
618
+ setOrderId(undefined);
619
+ setActivePanel(PanelView.HISTORY);
620
+ // Remove orderId and paymentMethod from URL when going back to history
621
+ const params = new URLSearchParams(searchParams.toString());
622
+ params.delete("orderId");
623
+ params.delete("paymentMethod");
624
+ router.push(`${window.location.pathname}?${params.toString()}`);
625
+ };
626
+ // Handle crypto swap creation
627
+ const handleCryptoSwap = async (method) => {
628
+ try {
629
+ (0, invariant_1.default)(anyspendQuote, "Relay price is not found");
630
+ (0, invariant_1.default)(recipientAddress, "Recipient address is not found");
631
+ // Debug: Check payment method values
632
+ console.log("handleCryptoSwap - method parameter:", method);
633
+ console.log("handleCryptoSwap - selectedPaymentMethod state:", selectedPaymentMethod);
525
634
  const srcAmountBigInt = (0, viem_1.parseUnits)(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals);
526
635
  createOrder({
527
636
  isMainnet,
@@ -543,13 +652,71 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
543
652
  sonner_1.toast.error("Failed to create order: " + err.message);
544
653
  }
545
654
  };
546
- const onClickHistory = () => {
547
- setOrderId(undefined);
548
- setActivePanel(PanelView.HISTORY);
549
- // Remove orderId from URL when going back to history
550
- const params = new URLSearchParams(searchParams.toString());
551
- params.delete("orderId");
552
- router.push(`${window.location.pathname}?${params.toString()}`);
655
+ // Handle fiat onramp order creation
656
+ const handleFiatOrder = async (paymentMethod) => {
657
+ try {
658
+ (0, invariant_1.default)(anyspendQuote, "Relay price is not found");
659
+ (0, invariant_1.default)(recipientAddress, "Recipient address is not found");
660
+ if (!srcAmountOnRamp || parseFloat(srcAmountOnRamp) <= 0) {
661
+ sonner_1.toast.error("Please enter a valid amount");
662
+ return;
663
+ }
664
+ // Determine vendor and payment method string based on selected payment method
665
+ let vendor;
666
+ let paymentMethodString = "";
667
+ if (paymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.COINBASE_PAY) {
668
+ if (coinbaseAvailablePaymentMethods.length === 0) {
669
+ sonner_1.toast.error("Coinbase Pay not available");
670
+ return;
671
+ }
672
+ vendor = "coinbase";
673
+ paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || ""; // Use first available payment method ID
674
+ }
675
+ else if (paymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.STRIPE) {
676
+ if (!isStripeOnrampSupported && (!stripeWeb2Support || !stripeWeb2Support.isSupport)) {
677
+ sonner_1.toast.error("Stripe not available");
678
+ return;
679
+ }
680
+ vendor = stripeWeb2Support && stripeWeb2Support.isSupport ? "stripe-web2" : "stripe";
681
+ paymentMethodString = "";
682
+ }
683
+ else {
684
+ sonner_1.toast.error("Please select a payment method");
685
+ return;
686
+ }
687
+ const getDstToken = () => {
688
+ if (isBuyMode) {
689
+ (0, invariant_1.default)(destinationTokenAddress, "destinationTokenAddress is required");
690
+ return {
691
+ ...selectedDstToken,
692
+ chainId: destinationTokenChainId || selectedDstChainId,
693
+ address: destinationTokenAddress,
694
+ };
695
+ }
696
+ return selectedDstToken;
697
+ };
698
+ createOnrampOrder({
699
+ isMainnet,
700
+ recipientAddress,
701
+ orderType: "swap",
702
+ dstChain: getDstToken().chainId,
703
+ dstToken: getDstToken(),
704
+ srcFiatAmount: srcAmountOnRamp,
705
+ onramp: {
706
+ vendor: vendor,
707
+ paymentMethod: paymentMethodString,
708
+ country: geoData?.country || "US",
709
+ ipAddress: geoData?.ip,
710
+ redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
711
+ },
712
+ expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
713
+ creatorAddress: globalAddress,
714
+ });
715
+ }
716
+ catch (err) {
717
+ console.error(err);
718
+ sonner_1.toast.error("Failed to create order: " + err.message);
719
+ }
553
720
  };
554
721
  // Open a dynamic modal
555
722
  // const setIsDynamicModalOpen = useModalStore(state => state.setB3ModalOpen);
@@ -567,9 +734,10 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
567
734
  const onSelectOrder = (selectedOrderId) => {
568
735
  setActivePanel(PanelView.MAIN);
569
736
  setOrderId(selectedOrderId);
570
- // Update URL with the new orderId
737
+ // Update URL with the new orderId and preserve existing parameters
571
738
  const params = new URLSearchParams(searchParams.toString());
572
739
  params.set("orderId", selectedOrderId);
740
+ // Keep existing paymentMethod if present
573
741
  router.push(`${window.location.pathname}?${params.toString()}`);
574
742
  };
575
743
  // Save custom recipients to local storage when they change
@@ -585,7 +753,6 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
585
753
  (0, react_4.useEffect)(() => {
586
754
  window.scrollTo({ top: 0, behavior: "smooth" });
587
755
  }, [activePanel]);
588
- const [isOpenPasteRecipientAddressModal, setIsOpenPasteRecipientAddressModal] = (0, react_4.useState)(false);
589
756
  const calculatePriceImpact = (inputUsd, outputUsd) => {
590
757
  if (!inputUsd || !outputUsd) {
591
758
  return { percentage: "0.00", isNegative: false };
@@ -609,17 +776,26 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
609
776
  // Add state for rate details toggle
610
777
  // const [showRateDetails, setShowRateDetails] = useState(false);
611
778
  const historyView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto flex w-[560px] max-w-full flex-col items-center", children: (0, jsx_runtime_1.jsx)(OrderHistory_1.OrderHistory, { mode: mode, onBack: () => setActivePanel(PanelView.MAIN), onSelectOrder: onSelectOrder }) }));
612
- const orderDetailsView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex flex-col gap-4", children: [oat && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: oat.data.order }), (0, jsx_runtime_1.jsx)(OrderDetails_1.OrderDetails, { isMainnet: isMainnet, mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
613
- setOrderId(undefined);
614
- setActivePanel(PanelView.MAIN);
615
- } })] })), mode === "page" && (0, jsx_runtime_1.jsx)("div", { className: "h-12" })] }) }));
616
- const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-1 relative mx-auto mb-4 grid h-10 w-fit min-w-[180px] grid-cols-2 rounded-xl", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("bg-as-brand absolute bottom-0 left-0 top-0 z-0 rounded-xl transition-transform duration-100", "h-full w-1/2", activeTab === "fiat" ? "translate-x-full" : "translate-x-0"), style: { willChange: "transform" } }), (0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("relative z-10 h-full w-full rounded-xl px-6 text-sm font-medium transition-colors duration-100", activeTab === "crypto" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => setActiveTab("crypto"), children: "Crypto" }), (0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("relative z-10 h-full w-full rounded-xl px-6 text-sm font-medium transition-colors duration-100", activeTab === "fiat" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => setActiveTab("fiat"), children: "Fiat" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "bg-as-on-surface-1 relative flex w-full flex-col gap-2 rounded-2xl p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Send" }), (0, jsx_runtime_1.jsx)(TokenBalance_1.TokenBalance, { token: selectedSrcToken, walletAddress: globalAddress, onChangeInput: value => {
617
- setIsSrcInputDirty(true);
618
- setSrcAmount(value);
619
- } })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
779
+ const orderDetailsView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex flex-col gap-4", children: oat && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: oat.data.order }), (0, jsx_runtime_1.jsx)(OrderDetails_1.OrderDetails, { isMainnet: isMainnet, mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
780
+ setOrderId(undefined);
781
+ setActivePanel(PanelView.MAIN);
782
+ setSelectedPaymentMethod(CryptoPaymentMethod_1.PaymentMethod.NONE); // Reset payment method when going back
783
+ } })] })) }) }));
784
+ const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), (0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-surface-secondary relative mb-4 grid h-10 grid-cols-2 rounded-xl", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("bg-as-brand absolute bottom-0 left-0 top-0 z-0 rounded-xl transition-transform duration-100", "h-full w-1/2", activeTab === "fiat" ? "translate-x-full" : "translate-x-0"), style: { willChange: "transform" } }), (0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "crypto" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
785
+ setActiveTab("crypto");
786
+ setSelectedPaymentMethod(CryptoPaymentMethod_1.PaymentMethod.NONE); // Reset payment method when switching to crypto
787
+ setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to crypto
788
+ }, children: "Pay with crypto" }), (0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "fiat" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
789
+ setActiveTab("fiat");
790
+ setSelectedPaymentMethod(CryptoPaymentMethod_1.PaymentMethod.NONE); // Reset crypto payment method when switching to fiat
791
+ setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to fiat
792
+ }, children: "Pay with Fiat" })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/50 hover:text-as-primary/70 flex h-7 items-center gap-1 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalAddress || wagmiAccount.address ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalWallet?.meta?.icon && ((0, jsx_runtime_1.jsx)("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-4 w-4 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { children: (0, formatAddress_1.shortenAddress)(globalAddress || wagmiAccount.address || "") })] })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "h-4 w-4" })] })) : selectedPaymentMethod === CryptoPaymentMethod_1.PaymentMethod.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transfer crypto", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "h-4 w-4" })] })) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
620
793
  setIsSrcInputDirty(true);
621
794
  setSrcAmount(value);
622
- }, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: (0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyIn?.amountUsd, { style: "currency", fallback: "" }) })] })) : ((0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp }) })), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", className: (0, cn_1.cn)("bg-as-n-8 border-as-stroke absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-2xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", (activeTab === "fiat" || isBuyMode) && "top-[calc(50%+56px)] cursor-default"), onClick: () => {
795
+ }, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: (0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyIn?.amountUsd, { style: "currency", fallback: "" }) }), (0, jsx_runtime_1.jsx)(TokenBalance_1.TokenBalance, { token: selectedSrcToken, walletAddress: globalAddress, onChangeInput: value => {
796
+ setIsSrcInputDirty(true);
797
+ setSrcAmount(value);
798
+ } })] })] })) : ((0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId }) })), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", className: (0, cn_1.cn)("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
623
799
  if (activeTab === "fiat" || isBuyMode) {
624
800
  return;
625
801
  }
@@ -638,9 +814,7 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
638
814
  const tempDstAmount = dstAmount;
639
815
  setSrcAmount(tempDstAmount);
640
816
  setDstAmount(tempSrcAmount);
641
- }, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), (0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-on-surface-1 relative flex w-full flex-col gap-2 rounded-2xl p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? ((0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("text-as-primary/50 flex h-7 items-center gap-1 rounded-lg px-2", globalAddress && recipientAddress === globalAddress
642
- ? "bg-as-on-surface-2 hover:bg-as-on-surface-3"
643
- : "bg-as-yellow/70 hover:bg-as-yellow text-as-primary"), onClick: () => setIsOpenPasteRecipientAddressModal(true), children: [globalAddress && recipientAddress === globalAddress && globalWallet?.meta?.icon ? ((0, jsx_runtime_1.jsx)("img", { src: globalWallet?.meta?.icon, alt: "Current wallet", className: "bg-as-primary h-4 w-4 rounded-full" })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.ClipboardIcon, { className: "h-4 w-4" })), (0, jsx_runtime_1.jsx)("div", { className: "text-sm", children: recipientName ? recipientName : (0, formatAddress_1.shortenAddress)(recipientAddress) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-3 w-3" })] })) : ((0, jsx_runtime_1.jsxs)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setIsOpenPasteRecipientAddressModal(true), children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-3 w-3" })] }))] }), isBuyMode ? (
817
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab !== "fiat" && ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Receive" }), recipientAddress ? ((0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("text-as-primary/70 flex h-7 items-center gap-2 rounded-lg px-2"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: [globalAddress && recipientAddress === globalAddress && globalWallet?.meta?.icon ? ((0, jsx_runtime_1.jsx)("img", { src: globalWallet?.meta?.icon, alt: "Current wallet", className: "bg-as-primary h-6 w-6 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-orange-500 text-xs text-white", children: "\uD83E\uDD8A" })), (0, jsx_runtime_1.jsx)("div", { className: "text-sm", children: recipientName ? recipientName : (0, formatAddress_1.shortenAddress)(recipientAddress) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-3 w-3" })] }))] }), isBuyMode ? (
644
818
  // Fixed destination token display in buy mode
645
819
  (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "h-8 w-8 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-brand text-lg font-bold", children: selectedDstToken.symbol })] })] })) : ((0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: recipientAddress, context: "to", inputValue: dstAmount, onChangeInput: value => {
646
820
  setIsSrcInputDirty(false);
@@ -657,33 +831,68 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
657
831
  }
658
832
  // Using inline style to ensure color displays
659
833
  return ((0, jsx_runtime_1.jsxs)("span", { className: "ml-2", style: { color: percentageNum >= 10 ? "red" : "#FFD700" }, children: ["(", isNegative ? "-" : "", percentage, "%)"] }));
660
- })()] })] })] }), getAnyspendQuoteError && ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl p-4", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), (0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "flex w-full max-w-[460px] flex-col gap-2", children: [(0, jsx_runtime_1.jsxs)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: (0, cn_1.cn)(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: [btnInfo.text, !btnInfo.disable && !btnInfo.error && ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "absolute right-0 top-1/2 h-6 w-6 -translate-y-1/2 opacity-70" }))] }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? ((0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.HistoryIcon, { className: "h-4 w-4" }), " ", (0, jsx_runtime_1.jsx)("span", { className: "pr-4", children: "Transaction History" })] })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-2 w-full" }))] })] }));
834
+ })()] })] }))] }), getAnyspendQuoteError && ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl p-4", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), (0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "mt-4 flex w-full max-w-[460px] flex-col gap-2 pb-2", children: [(0, jsx_runtime_1.jsxs)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: (0, cn_1.cn)(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: [btnInfo.text, !btnInfo.disable && !btnInfo.error && ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "absolute right-0 top-1/2 h-6 w-6 -translate-y-1/2 opacity-70" }))] }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? ((0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.HistoryIcon, { className: "h-4 w-4" }), " ", (0, jsx_runtime_1.jsx)("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
661
835
  const onrampPaymentView = ((0, jsx_runtime_1.jsx)(PanelOnrampPayment_1.PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName, recipientAddress: recipientAddress, isMainnet: isMainnet, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
662
836
  setOrderId(orderId);
663
837
  setActivePanel(PanelView.ORDER_DETAILS);
664
- // Add orderId to URL for persistence
665
- const params = new URLSearchParams();
838
+ // Add orderId and payment method to URL for persistence
839
+ const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
666
840
  params.set("orderId", orderId);
841
+ // For fiat payments, the payment method is always fiat (but we use the active tab context)
842
+ if (activeTab === "fiat") {
843
+ params.set("paymentMethod", "fiat");
844
+ }
845
+ else if (selectedPaymentMethod !== CryptoPaymentMethod_1.PaymentMethod.NONE) {
846
+ params.set("paymentMethod", selectedPaymentMethod);
847
+ }
667
848
  router.push(`${window.location.pathname}?${params.toString()}`);
668
849
  }, onBack: () => setActivePanel(PanelView.MAIN), recipientEnsName: globalWallet?.ensName, recipientImageUrl: globalWallet?.meta?.icon }));
850
+ const recipientSelectionView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex justify-around", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setActivePanel(PanelView.MAIN), className: "text-as-quaternary hover:text-as-primary flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-6 w-6" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex-1 text-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: "Add recipient address or ENS" }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/60 text-sm", children: "Swap and send tokens to another address" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "bg-as-surface-secondary border-as-border-secondary flex h-12 w-full overflow-hidden rounded-xl border", children: [(0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: "Enter recipient address", value: recipientAddress || "", onChange: e => setRecipientAddress(e.target.value), onKeyDown: e => {
851
+ if (e.key === "Enter" && recipientAddress) {
852
+ setActivePanel(PanelView.MAIN);
853
+ }
854
+ }, className: "text-as-primary placeholder:text-as-primary/50 flex-1 bg-transparent px-4 text-base focus:outline-none", autoFocus: true }), (0, jsx_runtime_1.jsx)("div", { className: "border-as-border-secondary border-l", children: (0, jsx_runtime_1.jsx)("button", { onClick: async () => {
855
+ try {
856
+ const text = await navigator.clipboard.readText();
857
+ setRecipientAddress(text);
858
+ }
859
+ catch (err) {
860
+ console.error("Failed to read clipboard:", err);
861
+ }
862
+ }, className: "text-as-primary/70 hover:text-as-primary hover:bg-as-surface-primary h-full px-4 font-semibold transition-colors", children: "Paste" }) })] }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
863
+ if (recipientAddress) {
864
+ setActivePanel(PanelView.MAIN);
865
+ }
866
+ }, disabled: !recipientAddress, className: "bg-as-brand hover:bg-as-brand/90 disabled:bg-as-on-surface-2 disabled:text-as-secondary h-12 w-full rounded-xl font-medium text-white transition-colors disabled:cursor-not-allowed", children: "Confirm recipient address" })] })] }) }));
867
+ const cryptoPaymentMethodView = ((0, jsx_runtime_1.jsx)(CryptoPaymentMethod_1.CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod: selectedPaymentMethod, setSelectedPaymentMethod: setSelectedPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
868
+ setSelectedPaymentMethod(method);
869
+ setActivePanel(PanelView.MAIN);
870
+ } }));
871
+ const fiatPaymentMethodView = ((0, jsx_runtime_1.jsx)(FiatPaymentMethod_1.FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
872
+ setSelectedFiatPaymentMethod(method);
873
+ setActivePanel(PanelView.MAIN); // Go back to main panel to show updated pricing
874
+ }, srcAmountOnRamp: srcAmountOnRamp, isMainnet: isMainnet }));
669
875
  // Add tabs to the main component when no order is loaded
670
- return ((0, jsx_runtime_1.jsx)(react_2.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("mx-auto max-w-[calc(100vw-32px)]"), children: [(0, jsx_runtime_1.jsx)(react_2.TransitionPanel, { activeIndex: orderId
671
- ? oat
672
- ? PanelView.ORDER_DETAILS
673
- : PanelView.LOADING
674
- : activePanel === PanelView.ORDER_DETAILS
675
- ? PanelView.MAIN
676
- : activePanel, className: (0, cn_1.cn)("w-full", {
677
- "mt-0": mode === "modal",
678
- }), variants: {
679
- enter: { x: 300, opacity: 0 },
680
- center: { x: 0, opacity: 1 },
681
- exit: { x: -300, opacity: 0 },
682
- }, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
683
- (0, jsx_runtime_1.jsx)("div", { children: mainView }, "main-view"),
684
- (0, jsx_runtime_1.jsx)("div", { children: historyView }, "history-view"),
685
- (0, jsx_runtime_1.jsx)("div", { children: orderDetailsView }, "order-details-view"),
686
- (0, jsx_runtime_1.jsx)("div", { children: OrderDetails_1.OrderDetailsLoadingView }, "loading-view"),
687
- (0, jsx_runtime_1.jsx)("div", { children: onrampPaymentView }, "fiat-payment-view"),
688
- ] }), (0, jsx_runtime_1.jsx)(EnterRecipientModal_1.EnterRecipientModal, { isOpenPasteRecipientAddress: isOpenPasteRecipientAddressModal, setIsOpenPasteRecipientAddress: setIsOpenPasteRecipientAddressModal, recipientAddress: recipientAddress, setRecipientAddress: setRecipientAddress })] }) }));
876
+ return ((0, jsx_runtime_1.jsx)(react_2.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("mx-auto w-full max-w-[460px]", mode === "page" && "bg-as-surface-primary border-as-border-secondary rounded-2xl border p-6 shadow-xl"), children: (0, jsx_runtime_1.jsx)(react_2.TransitionPanel, { activeIndex: orderId
877
+ ? oat
878
+ ? PanelView.ORDER_DETAILS
879
+ : PanelView.LOADING
880
+ : activePanel === PanelView.ORDER_DETAILS
881
+ ? PanelView.MAIN
882
+ : activePanel, className: (0, cn_1.cn)("overflow-hidden", {
883
+ "mt-0": mode === "modal",
884
+ }), variants: {
885
+ enter: { x: 300, opacity: 0 },
886
+ center: { x: 0, opacity: 1 },
887
+ exit: { x: -300, opacity: 0 },
888
+ }, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
889
+ (0, jsx_runtime_1.jsx)("div", { children: mainView }, "main-view"),
890
+ (0, jsx_runtime_1.jsx)("div", { children: historyView }, "history-view"),
891
+ (0, jsx_runtime_1.jsx)("div", { children: orderDetailsView }, "order-details-view"),
892
+ (0, jsx_runtime_1.jsx)("div", { children: OrderDetails_1.OrderDetailsLoadingView }, "loading-view"),
893
+ (0, jsx_runtime_1.jsx)("div", { children: onrampPaymentView }, "fiat-payment-view"),
894
+ (0, jsx_runtime_1.jsx)("div", { children: recipientSelectionView }, "recipient-selection-view"),
895
+ (0, jsx_runtime_1.jsx)("div", { children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
896
+ (0, jsx_runtime_1.jsx)("div", { children: fiatPaymentMethodView }, "fiat-payment-method-view"),
897
+ ] }) }) }));
689
898
  }