@b3dotfun/sdk 0.0.43 → 0.0.44

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.
@@ -59,11 +59,27 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
59
59
  const lastUrlUpdate = (0, react_4.useRef)(null);
60
60
  // Track if onSuccess has been called for the current order
61
61
  const onSuccessCalled = (0, react_4.useRef)(false);
62
+ // Track animation direction for TransitionPanel
63
+ const animationDirection = (0, react_4.useRef)(null);
64
+ // Track previous panel for proper back navigation
65
+ const previousPanel = (0, react_4.useRef)(PanelView.MAIN);
62
66
  const [activeTab, setActiveTab] = (0, react_4.useState)(defaultActiveTab);
63
67
  const [orderId, setOrderId] = (0, react_4.useState)(loadOrder);
64
68
  const { orderAndTransactions: oat, getOrderAndTransactionsError } = (0, react_1.useAnyspendOrderAndTransactions)(orderId);
65
69
  !!getOrderAndTransactionsError && console.log("getOrderAndTransactionsError", getOrderAndTransactionsError);
66
70
  const [activePanel, setActivePanel] = (0, react_4.useState)(loadOrder ? PanelView.ORDER_DETAILS : PanelView.MAIN);
71
+ // Helper functions to navigate with animation direction
72
+ const navigateToPanel = (0, react_4.useCallback)((panel, direction = "forward") => {
73
+ previousPanel.current = activePanel;
74
+ animationDirection.current = direction;
75
+ setActivePanel(panel);
76
+ }, [activePanel]);
77
+ const navigateBack = (0, react_4.useCallback)(() => {
78
+ animationDirection.current = "back";
79
+ // Navigate back to previous panel or default to MAIN
80
+ const targetPanel = previousPanel.current !== activePanel ? previousPanel.current : PanelView.MAIN;
81
+ setActivePanel(targetPanel);
82
+ }, [activePanel]);
67
83
  const [customRecipients, setCustomRecipients] = (0, react_4.useState)([]);
68
84
  // Add state for selected payment method
69
85
  const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = (0, react_4.useState)(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE);
@@ -412,7 +428,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
412
428
  const orderId = data.data.id;
413
429
  setOrderId(orderId);
414
430
  // setNewRecipientAddress("");
415
- setActivePanel(PanelView.ORDER_DETAILS);
431
+ navigateToPanel(PanelView.ORDER_DETAILS, "forward");
416
432
  // Debug: Check payment method before setting URL
417
433
  console.log("Creating order - selectedCryptoPaymentMethod:", selectedCryptoPaymentMethod);
418
434
  // Add orderId and payment method to URL for persistence
@@ -438,7 +454,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
438
454
  onSuccess: data => {
439
455
  const orderId = data.data.id;
440
456
  setOrderId(orderId);
441
- setActivePanel(PanelView.ORDER_DETAILS);
457
+ navigateToPanel(PanelView.ORDER_DETAILS, "forward");
442
458
  // Add orderId and payment method to URL for persistence
443
459
  const params = new URLSearchParams(searchParams.toString());
444
460
  params.set("orderId", orderId);
@@ -501,7 +517,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
501
517
  if (btnInfo.disable)
502
518
  return;
503
519
  if (!recipientAddress) {
504
- setActivePanel(PanelView.RECIPIENT_SELECTION);
520
+ navigateToPanel(PanelView.RECIPIENT_SELECTION, "forward");
505
521
  return;
506
522
  }
507
523
  try {
@@ -510,7 +526,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
510
526
  if (activeTab === "fiat") {
511
527
  // If no fiat payment method selected, show payment method selection
512
528
  if (selectedFiatPaymentMethod === FiatPaymentMethod_1.FiatPaymentMethod.NONE) {
513
- setActivePanel(PanelView.FIAT_PAYMENT_METHOD);
529
+ navigateToPanel(PanelView.FIAT_PAYMENT_METHOD, "forward");
514
530
  return;
515
531
  }
516
532
  // If payment method is selected, create order directly
@@ -521,7 +537,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
521
537
  // If no payment method selected, show payment method selection
522
538
  if (selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE) {
523
539
  console.log("No payment method selected, showing selection panel");
524
- setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD);
540
+ navigateToPanel(PanelView.CRYPTO_PAYMENT_METHOD, "forward");
525
541
  return;
526
542
  }
527
543
  // If payment method is selected, create order with payment method info
@@ -541,7 +557,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
541
557
  };
542
558
  const onClickHistory = () => {
543
559
  setOrderId(undefined);
544
- setActivePanel(PanelView.HISTORY);
560
+ navigateToPanel(PanelView.HISTORY, "forward");
545
561
  // Remove orderId and paymentMethod from URL when going back to history
546
562
  const params = new URLSearchParams(searchParams.toString());
547
563
  params.delete("orderId");
@@ -654,8 +670,8 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
654
670
  }
655
671
  }, [searchParams, loadOrder]);
656
672
  const onSelectOrder = (selectedOrderId) => {
657
- setActivePanel(PanelView.MAIN);
658
673
  setOrderId(selectedOrderId);
674
+ navigateToPanel(PanelView.ORDER_DETAILS, "forward");
659
675
  // Update URL with the new orderId and preserve existing parameters
660
676
  const params = new URLSearchParams(searchParams.toString());
661
677
  params.set("orderId", selectedOrderId);
@@ -675,13 +691,49 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
675
691
  (0, react_4.useEffect)(() => {
676
692
  window.scrollTo({ top: 0, behavior: "smooth" });
677
693
  }, [activePanel]);
678
- 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 }) }));
694
+ // Handle browser back button for recipient selection and payment method views
695
+ (0, react_4.useEffect)(() => {
696
+ // Push a new history state when navigating to specific panels
697
+ if (activePanel === PanelView.RECIPIENT_SELECTION) {
698
+ window.history.pushState({ panel: "recipient-selection" }, "");
699
+ }
700
+ else if (activePanel === PanelView.CRYPTO_PAYMENT_METHOD) {
701
+ window.history.pushState({ panel: "crypto-payment-method" }, "");
702
+ }
703
+ else if (activePanel === PanelView.FIAT_PAYMENT_METHOD) {
704
+ window.history.pushState({ panel: "fiat-payment-method" }, "");
705
+ }
706
+ // Listen for popstate event (browser back button)
707
+ const handlePopState = (event) => {
708
+ if (activePanel === PanelView.RECIPIENT_SELECTION ||
709
+ activePanel === PanelView.CRYPTO_PAYMENT_METHOD ||
710
+ activePanel === PanelView.FIAT_PAYMENT_METHOD) {
711
+ // User pressed back while on these panels
712
+ event.preventDefault();
713
+ navigateBack();
714
+ }
715
+ };
716
+ window.addEventListener("popstate", handlePopState);
717
+ return () => {
718
+ window.removeEventListener("popstate", handlePopState);
719
+ };
720
+ }, [activePanel, navigateBack]);
721
+ 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: navigateBack, onSelectOrder: onSelectOrder }) }));
679
722
  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.jsx)(OrderDetails_1.OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTxs: oat.data.relayTxs, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onPaymentMethodChange: setSelectedCryptoPaymentMethod, onBack: () => {
680
723
  setOrderId(undefined);
681
- setActivePanel(PanelView.MAIN);
724
+ navigateBack();
682
725
  setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset payment method when going back
683
726
  } })) }) }));
684
- 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)(TabSection_1.TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), (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.jsx)(CryptoPaySection_1.CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : ((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, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL), customUsdInputValues: customUsdInputValues }) })), (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: () => {
727
+ 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)(TabSection_1.TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), (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.jsx)(CryptoPaySection_1.CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => navigateToPanel(PanelView.CRYPTO_PAYMENT_METHOD, "forward"), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : ((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: (panelIndex) => {
728
+ // Map panel index to navigation with direction
729
+ const panelsWithForwardNav = [PanelView.FIAT_PAYMENT_METHOD, PanelView.RECIPIENT_SELECTION];
730
+ if (panelsWithForwardNav.includes(panelIndex)) {
731
+ navigateToPanel(panelIndex, "forward");
732
+ }
733
+ else {
734
+ setActivePanel(panelIndex);
735
+ }
736
+ }, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => navigateToPanel(PanelView.POINTS_DETAIL, "forward"), customUsdInputValues: customUsdInputValues }) })), (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: () => {
685
737
  if (activeTab === "fiat" || isBuyMode) {
686
738
  return;
687
739
  }
@@ -700,13 +752,13 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
700
752
  const tempDstAmount = dstAmount;
701
753
  setSrcAmount(tempDstAmount);
702
754
  setDstAmount(tempSrcAmount);
703
- }, 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 === "crypto" && ((0, jsx_runtime_1.jsx)(CryptoReceiveSection_1.CryptoReceiveSection, { isDepositMode: false, isBuyMode: isBuyMode, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: selectedDstToken, selectedDstChainId: selectedDstChainId, setSelectedDstChainId: setSelectedDstChainId, setSelectedDstToken: setSelectedDstToken, onChangeDstAmount: value => {
755
+ }, 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 === "crypto" && ((0, jsx_runtime_1.jsx)(CryptoReceiveSection_1.CryptoReceiveSection, { isDepositMode: false, isBuyMode: isBuyMode, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => navigateToPanel(PanelView.RECIPIENT_SELECTION, "forward"), dstAmount: dstAmount, dstToken: selectedDstToken, selectedDstChainId: selectedDstChainId, setSelectedDstChainId: setSelectedDstChainId, setSelectedDstToken: setSelectedDstToken, onChangeDstAmount: value => {
704
756
  setIsSrcInputDirty(false);
705
757
  setDstAmount(value);
706
- }, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }))] }), (0, jsx_runtime_1.jsx)(ErrorSection_1.ErrorSection, { error: getAnyspendQuoteError }), (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: (0, cn_1.cn)("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [(0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("as-main-button 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 }), !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] })] }));
758
+ }, anyspendQuote: anyspendQuote, onShowPointsDetail: () => navigateToPanel(PanelView.POINTS_DETAIL, "forward") }))] }), (0, jsx_runtime_1.jsx)(ErrorSection_1.ErrorSection, { error: getAnyspendQuoteError }), (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: (0, cn_1.cn)("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [(0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("as-main-button 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 }), !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] })] }));
707
759
  const onrampPaymentView = ((0, jsx_runtime_1.jsx)(PanelOnrampPayment_1.PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName || undefined, recipientAddress: recipientAddress, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
708
760
  setOrderId(orderId);
709
- setActivePanel(PanelView.ORDER_DETAILS);
761
+ navigateToPanel(PanelView.ORDER_DETAILS, "forward");
710
762
  // Add orderId and payment method to URL for persistence
711
763
  const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
712
764
  params.set("orderId", orderId);
@@ -718,20 +770,20 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
718
770
  params.set("paymentMethod", selectedCryptoPaymentMethod);
719
771
  }
720
772
  router.push(`${window.location.pathname}?${params.toString()}`);
721
- }, onBack: () => setActivePanel(PanelView.MAIN), recipientEnsName: globalWallet?.ensName, recipientImageUrl: globalWallet?.meta?.icon }));
722
- const recipientSelectionView = ((0, jsx_runtime_1.jsx)(RecipientSelection_1.RecipientSelection, { initialValue: recipientAddress || "", onBack: () => setActivePanel(PanelView.MAIN), onConfirm: address => {
773
+ }, onBack: navigateBack, recipientEnsName: globalWallet?.ensName, recipientImageUrl: globalWallet?.meta?.icon }));
774
+ const recipientSelectionView = ((0, jsx_runtime_1.jsx)(RecipientSelection_1.RecipientSelection, { initialValue: recipientAddress || "", onBack: navigateBack, onConfirm: address => {
723
775
  setRecipientAddress(address);
724
- setActivePanel(PanelView.MAIN);
776
+ navigateBack();
725
777
  } }));
726
- const cryptoPaymentMethodView = ((0, jsx_runtime_1.jsx)(CryptoPaymentMethod_1.CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod: selectedCryptoPaymentMethod, setSelectedPaymentMethod: setSelectedCryptoPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
778
+ const cryptoPaymentMethodView = ((0, jsx_runtime_1.jsx)(CryptoPaymentMethod_1.CryptoPaymentMethod, { globalAddress: globalAddress, globalWallet: globalWallet, selectedPaymentMethod: selectedCryptoPaymentMethod, setSelectedPaymentMethod: setSelectedCryptoPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: navigateBack, onSelectPaymentMethod: (method) => {
727
779
  setSelectedCryptoPaymentMethod(method);
728
- setActivePanel(PanelView.MAIN);
780
+ navigateBack();
729
781
  } }));
730
- const fiatPaymentMethodView = ((0, jsx_runtime_1.jsx)(FiatPaymentMethod_1.FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
782
+ const fiatPaymentMethodView = ((0, jsx_runtime_1.jsx)(FiatPaymentMethod_1.FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: navigateBack, onSelectPaymentMethod: (method) => {
731
783
  setSelectedFiatPaymentMethod(method);
732
- setActivePanel(PanelView.MAIN); // Go back to main panel to show updated pricing
784
+ navigateBack(); // Go back to main panel to show updated pricing
733
785
  }, srcAmountOnRamp: srcAmountOnRamp }));
734
- const pointsDetailView = ((0, jsx_runtime_1.jsx)(PointsDetailPanel_1.PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: () => setActivePanel(PanelView.MAIN) }));
786
+ const pointsDetailView = ((0, jsx_runtime_1.jsx)(PointsDetailPanel_1.PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: navigateBack }));
735
787
  // Add tabs to the main component when no order is loaded
736
788
  return ((0, jsx_runtime_1.jsx)(react_2.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("anyspend-container font-inter mx-auto w-full max-w-[460px]", mode === "page" &&
737
789
  "bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: (0, jsx_runtime_1.jsx)(react_2.TransitionPanel, { activeIndex: orderId
@@ -742,10 +794,16 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
742
794
  ? PanelView.MAIN
743
795
  : activePanel, className: (0, cn_1.cn)("rounded-2xl", {
744
796
  "mt-0": mode === "modal",
745
- }), variants: {
746
- enter: { x: 300, opacity: 0 },
797
+ }), custom: animationDirection.current, variants: {
798
+ enter: direction => ({
799
+ x: direction === "back" ? -300 : 300,
800
+ opacity: 0,
801
+ }),
747
802
  center: { x: 0, opacity: 1 },
748
- exit: { x: -300, opacity: 0 },
803
+ exit: direction => ({
804
+ x: direction === "back" ? 300 : -300,
805
+ opacity: 0,
806
+ }),
749
807
  }, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
750
808
  (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: mainView }, "main-view"),
751
809
  (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: historyView }, "history-view"),
@@ -487,7 +487,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
487
487
  ? "Funding Tournament"
488
488
  : "Processing Transaction", chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 })) : ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
489
489
  ? `Waiting for payment`
490
- : `Waiting for deposit ${formattedDepositDeficit} ${srcToken.symbol}`, chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 }))] }) })] }) }), !depositEnoughAmount && order.status !== "expired" && ((0, jsx_runtime_1.jsx)(InsufficientDepositPayment_1.InsufficientDepositPayment, { order: order, srcToken: srcToken, depositDeficit: depositDeficit, phantomWalletAddress: phantomWalletAddress, txLoading: txLoading, isSwitchingOrExecuting: isSwitchingOrExecuting, onPayment: handlePayment }))] }));
490
+ : `Waiting for deposit ${formattedDepositDeficit} ${srcToken.symbol}`, chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 }))] }) })] }) }), depositTxs?.length > 0 && !depositEnoughAmount && order.status === "scanning_deposit_transaction" && ((0, jsx_runtime_1.jsx)(InsufficientDepositPayment_1.InsufficientDepositPayment, { order: order, srcToken: srcToken, depositDeficit: depositDeficit, phantomWalletAddress: phantomWalletAddress, txLoading: txLoading, isSwitchingOrExecuting: isSwitchingOrExecuting, onPayment: handlePayment }))] }));
491
491
  }
492
492
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), statusDisplay === "processing" && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: order.onrampMetadata ? ((0, jsx_runtime_1.jsx)(PaymentVendorUI_1.default, { order: order, dstTokenSymbol: dstToken.symbol })) : effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ||
493
493
  effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET ? ((0, jsx_runtime_1.jsx)(ConnectWalletPayment_1.default, { order: order, onPayment: handlePayment, onCancel: handleBack, txLoading: txLoading, isSwitchingOrExecuting: isSwitchingOrExecuting, phantomWalletAddress: phantomWalletAddress, tournament: tournament, nft: nft, cryptoPaymentMethod: effectiveCryptoPaymentMethod, onPaymentMethodChange: onPaymentMethodChange })) : effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
@@ -12,6 +12,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
12
12
  errorDetails: string | null;
13
13
  createdAt: number;
14
14
  expiredAt: number;
15
+ filledAt: number | null;
15
16
  creatorAddress: string | null;
16
17
  partnerId: string | null;
17
18
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -34,6 +35,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
34
35
  errorDetails: string | null;
35
36
  createdAt: number;
36
37
  expiredAt: number;
38
+ filledAt: number | null;
37
39
  creatorAddress: string | null;
38
40
  partnerId: string | null;
39
41
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -56,6 +58,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
56
58
  errorDetails: string | null;
57
59
  createdAt: number;
58
60
  expiredAt: number;
61
+ filledAt: number | null;
59
62
  creatorAddress: string | null;
60
63
  partnerId: string | null;
61
64
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -78,6 +81,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
78
81
  errorDetails: string | null;
79
82
  createdAt: number;
80
83
  expiredAt: number;
84
+ filledAt: number | null;
81
85
  creatorAddress: string | null;
82
86
  partnerId: string | null;
83
87
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -100,6 +104,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
100
104
  errorDetails: string | null;
101
105
  createdAt: number;
102
106
  expiredAt: number;
107
+ filledAt: number | null;
103
108
  creatorAddress: string | null;
104
109
  partnerId: string | null;
105
110
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -122,6 +127,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
122
127
  errorDetails: string | null;
123
128
  createdAt: number;
124
129
  expiredAt: number;
130
+ filledAt: number | null;
125
131
  creatorAddress: string | null;
126
132
  partnerId: string | null;
127
133
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -147,6 +153,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
147
153
  errorDetails: string | null;
148
154
  createdAt: number;
149
155
  expiredAt: number;
156
+ filledAt: number | null;
150
157
  creatorAddress: string | null;
151
158
  partnerId: string | null;
152
159
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -169,6 +176,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
169
176
  errorDetails: string | null;
170
177
  createdAt: number;
171
178
  expiredAt: number;
179
+ filledAt: number | null;
172
180
  creatorAddress: string | null;
173
181
  partnerId: string | null;
174
182
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -191,6 +199,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
191
199
  errorDetails: string | null;
192
200
  createdAt: number;
193
201
  expiredAt: number;
202
+ filledAt: number | null;
194
203
  creatorAddress: string | null;
195
204
  partnerId: string | null;
196
205
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -213,6 +222,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
213
222
  errorDetails: string | null;
214
223
  createdAt: number;
215
224
  expiredAt: number;
225
+ filledAt: number | null;
216
226
  creatorAddress: string | null;
217
227
  partnerId: string | null;
218
228
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -235,6 +245,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
235
245
  errorDetails: string | null;
236
246
  createdAt: number;
237
247
  expiredAt: number;
248
+ filledAt: number | null;
238
249
  creatorAddress: string | null;
239
250
  partnerId: string | null;
240
251
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -257,6 +268,7 @@ export declare function useAnyspendOrderHistory(creatorAddress: string | undefin
257
268
  errorDetails: string | null;
258
269
  createdAt: number;
259
270
  expiredAt: number;
271
+ filledAt: number | null;
260
272
  creatorAddress: string | null;
261
273
  partnerId: string | null;
262
274
  onrampMetadata: import("../..").components["schemas"]["OnrampMetadata"] | null;
@@ -1117,11 +1117,6 @@ export interface components {
1117
1117
  * @example 990000
1118
1118
  */
1119
1119
  actualDstAmount: string | null;
1120
- /**
1121
- * @description Amount in after fee
1122
- * @example 990000
1123
- */
1124
- amountInAfterFee: string | null;
1125
1120
  };
1126
1121
  /** @description HypeDuel-specific payload */
1127
1122
  HypeDuelPayload: {
@@ -1135,11 +1130,6 @@ export interface components {
1135
1130
  * @example 990000
1136
1131
  */
1137
1132
  actualDstAmount: string | null;
1138
- /**
1139
- * @description Amount in after fee
1140
- * @example 990000
1141
- */
1142
- amountInAfterFee: string | null;
1143
1133
  };
1144
1134
  /** @description Custom execution payload */
1145
1135
  CustomPayload: {
@@ -1307,6 +1297,8 @@ export interface components {
1307
1297
  * @example 1752506694679
1308
1298
  */
1309
1299
  expiredAt: number;
1300
+ /** @description Timestamp when the order was filled/executed */
1301
+ filledAt: number | null;
1310
1302
  /**
1311
1303
  * @description Optional creator address
1312
1304
  * @example 0xb34facb90a200251318e8841c05102366f2158cf
@@ -20,7 +20,7 @@ export declare function useCurrencyConversion(): {
20
20
  /** Base currency used for conversion (typically B3) */
21
21
  baseCurrency: import("../stores/currencyStore").SupportedCurrency;
22
22
  /** Current exchange rate from base to selected currency (undefined while loading) */
23
- exchangeRate: number;
23
+ exchangeRate: number | undefined;
24
24
  /** Format a value with currency conversion and proper symbol/decimal handling */
25
25
  formatCurrencyValue: (value: number, options?: {
26
26
  decimals?: number;
@@ -1,9 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useCurrencyConversion = useCurrencyConversion;
4
- const react_1 = require("../../../global-account/react");
4
+ const react_query_1 = require("@tanstack/react-query");
5
5
  const number_1 = require("../../../shared/utils/number");
6
6
  const currencyStore_1 = require("../stores/currencyStore");
7
+ const COINBASE_API_URL = "https://api.coinbase.com/v2/exchange-rates";
8
+ const REFETCH_INTERVAL_MS = 30000;
9
+ /**
10
+ * Fetches all exchange rates for a given base currency from Coinbase API.
11
+ */
12
+ async function fetchAllExchangeRates(baseCurrency) {
13
+ const response = await fetch(`${COINBASE_API_URL}?currency=${baseCurrency}`);
14
+ if (!response.ok) {
15
+ throw new Error(`Failed to fetch exchange rates for ${baseCurrency}: ${response.status}`);
16
+ }
17
+ const data = await response.json();
18
+ const rates = {};
19
+ for (const [currency, rate] of Object.entries(data.data.rates)) {
20
+ rates[currency] = parseFloat(rate);
21
+ }
22
+ return rates;
23
+ }
7
24
  /**
8
25
  * Hook for currency conversion and formatting with real-time exchange rates.
9
26
  *
@@ -23,16 +40,18 @@ const currencyStore_1 = require("../stores/currencyStore");
23
40
  function useCurrencyConversion() {
24
41
  const selectedCurrency = (0, currencyStore_1.useCurrencyStore)(state => state.selectedCurrency);
25
42
  const baseCurrency = (0, currencyStore_1.useCurrencyStore)(state => state.baseCurrency);
26
- // Get exchange rate for the selected currency
27
- const { rate: exchangeRate } = (0, react_1.useExchangeRate)({
28
- baseCurrency,
29
- quoteCurrency: selectedCurrency === baseCurrency ? "USD" : selectedCurrency,
30
- });
31
- // Always fetch USD rate for tooltip purposes
32
- const { rate: usdRate } = (0, react_1.useExchangeRate)({
33
- baseCurrency,
34
- quoteCurrency: "USD",
43
+ // Fetch all exchange rates for the base currency
44
+ const { data: exchangeRates } = (0, react_query_1.useQuery)({
45
+ queryKey: ["exchangeRates", baseCurrency],
46
+ queryFn: () => fetchAllExchangeRates(baseCurrency),
47
+ refetchInterval: REFETCH_INTERVAL_MS,
48
+ staleTime: REFETCH_INTERVAL_MS / 2,
49
+ retry: 3,
50
+ retryDelay: attemptIndex => Math.min(1000 * 2 ** attemptIndex, REFETCH_INTERVAL_MS),
35
51
  });
52
+ // Extract specific rates from the full rates object
53
+ const exchangeRate = exchangeRates?.[selectedCurrency];
54
+ const usdRate = exchangeRates?.["USD"];
36
55
  /**
37
56
  * Formats a numeric value as a currency string with proper conversion and formatting.
38
57
  *
@@ -78,8 +97,7 @@ function useCurrencyConversion() {
78
97
  });
79
98
  return `${formatted} ${baseCurrency}`;
80
99
  }
81
- // If no exchange rate available, show base currency to prevent showing
82
- // incorrect values with wrong currency symbols during rate fetching
100
+ // If showing base currency, no conversion needed
83
101
  if (selectedCurrency === baseCurrency || !exchangeRate) {
84
102
  const formatted = (0, number_1.formatDisplayNumber)(value, {
85
103
  significantDigits: baseCurrency === "B3" ? 6 : 8,