@0xsquid/ui 0.13.6 → 0.13.7

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/esm/index.js CHANGED
@@ -2549,6 +2549,16 @@ function debounce(func, delay) {
2549
2549
  };
2550
2550
  return debounced;
2551
2551
  }
2552
+ const formatTime = (elapsedTime) => {
2553
+ const totalSeconds = Math.floor(elapsedTime / 1000);
2554
+ const minutes = Math.floor(totalSeconds / 60);
2555
+ // Show only seconds if total time is less than 1 minute
2556
+ if (minutes === 0) {
2557
+ return `${totalSeconds}s`;
2558
+ }
2559
+ // Show only minutes if total time is 1 minute or more
2560
+ return `${minutes}m`;
2561
+ };
2552
2562
 
2553
2563
  const badgeSizeClassMap = {
2554
2564
  sm: 'tw-w-4 tw-h-4',
@@ -2662,7 +2672,6 @@ const roundedClassMap = {
2662
2672
  md: 'tw-rounded-squid-m',
2663
2673
  lg: 'tw-rounded-squid-xxl',
2664
2674
  };
2665
- const buttonBorderClassName = 'tw-border-material-light-thin hover:tw-border-material-light-average';
2666
2675
  const buttonVariantClassMap = {
2667
2676
  primary: 'tw-bg-royal-500 group-data-[squid-theme-type=light]:tw-text-grey-900 group-data-[squid-theme-type=dark]:tw-text-grey-100',
2668
2677
  secondary: 'tw-bg-grey-100 tw-text-grey-800',
@@ -2680,7 +2689,7 @@ function Button(_a) {
2680
2689
  icon) : (
2681
2690
  // icon and label
2682
2691
  jsxs(Fragment, { children: [icon, jsx(BodyText, { className: "tw-pr-1", size: "small", children: label })] }))) : null })] }));
2683
- const className = cn(baseButtonClassName, buttonSizeClassMap[size], buttonVariantClassMap[variant], buttonBorderClassName, roundedClassMap[size],
2692
+ const className = cn(baseButtonClassName, buttonSizeClassMap[size], buttonVariantClassMap[variant], 'tw-border-material-light-thin', !disabled && 'hover:tw-border-material-light-average', roundedClassMap[size],
2684
2693
  // disabled styles
2685
2694
  disabled && buttonDisabledClass,
2686
2695
  // custom classes from props
@@ -2720,15 +2729,15 @@ function ChevronRightSmallIcon() {
2720
2729
  function ArrowLeftIcon({ className, size = '24', }) {
2721
2730
  return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", className: className, children: jsx("path", { d: "M10 6L4 12L10 18M5 12H20", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }) }));
2722
2731
  }
2723
- function ArrowRightUpCircleIcon() {
2724
- return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: jsx("path", { d: "M9 15L14.5 9.5M15 14V9H10M21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12Z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }) }));
2725
- }
2726
2732
  function ChevronGrabberVerticalIcon({ size = '16', className, }) {
2727
2733
  return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 16 16", fill: "none", className: className, children: jsx("path", { d: "M5.33301 6.00002L7.52827 3.80476C7.78862 3.54441 8.21073 3.54441 8.47108 3.80476L10.6663 6.00002M5.33301 10L7.52827 12.1953C7.78862 12.4556 8.21073 12.4556 8.47108 12.1953L10.6663 10", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }) }));
2728
2734
  }
2729
2735
  function SquareArrowTopRight2Icon({ className, size = '16', }) {
2730
2736
  return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 16 16", fill: "none", className: className, children: jsx("path", { d: "M6.00033 2.66663H4.80033C4.05359 2.66663 3.68022 2.66663 3.395 2.81195C3.14412 2.93978 2.94015 3.14376 2.81232 3.39464C2.66699 3.67985 2.66699 4.05322 2.66699 4.79996L2.66699 11.2C2.66699 11.9467 2.66699 12.3201 2.81232 12.6053C2.94015 12.8562 3.14412 13.0601 3.395 13.188C3.68022 13.3333 4.05359 13.3333 4.80033 13.3333L11.2003 13.3333C11.9471 13.3333 12.3204 13.3333 12.6056 13.188C12.8565 13.0601 13.0605 12.8562 13.1883 12.6053C13.3337 12.3201 13.3337 11.9467 13.3337 11.2V9.99996M9.33366 2.66663L13.3337 2.66663M13.3337 2.66663V6.66663M13.3337 2.66663L7.33366 8.66663", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }) }));
2731
2737
  }
2738
+ function ArrowsSwapIcon({ size = '24', className, }) {
2739
+ return (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", className: className, children: [jsx("path", { d: "M14 4L20 9.99998H4", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }), jsx("path", { d: "M10 20L4 14H20", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })] }));
2740
+ }
2732
2741
 
2733
2742
  function ArrowButton(_a) {
2734
2743
  var { label, disabled } = _a, props = __rest(_a, ["label", "disabled"]);
@@ -2840,16 +2849,26 @@ const CSS_VARS = {
2840
2849
  SCALE_AND_FADE_UP_DURATION: '--squid-animation-scale-and-fade-up-duration',
2841
2850
  SCALE_AND_FADE_DOWN_DURATION: '--squid-animation-scale-and-fade-down-duration',
2842
2851
  TRANSLATE_TOP_OR_BOTTOM: '--squid-animation-translate-top-or-bottom',
2852
+ SHOW_MODAL_DURATION: '--squid-animation-show-modal-duration',
2853
+ HIDE_MODAL_DURATION: '--squid-animation-hide-modal-duration',
2854
+ SLIDE_TO_TOP_DURATION: '--squid-animation-slide-to-top-duration',
2855
+ SLIDE_TO_BOTTOM_DURATION: '--squid-animation-slide-to-bottom-duration',
2856
+ BLUR_IN_DURATION: '--squid-animation-blur-in-duration',
2857
+ BLUR_OUT_DURATION: '--squid-animation-blur-out-duration',
2843
2858
  };
2844
2859
  const ANIMATION_DURATIONS = {
2845
2860
  SHOW_ROUTE: 300,
2846
2861
  HIDE_ROUTE: 300,
2847
2862
  CHANGE_SWAP_STEP: 300,
2863
+ SHOW_MODAL: 400,
2864
+ HIDE_MODAL: 400,
2848
2865
  };
2849
2866
  const ANIMATION_TIMINGS = {
2850
2867
  EXPAND_ROUTE: 'linear', //'cubic-bezier(.32, .72, 0, 1)',
2851
2868
  COLLAPSE_ROUTE: 'linear', //'cubic-bezier(.32, .72, 0, 1)',
2852
2869
  CHANGE_SWAP_STEP: 'linear', //'cubic-bezier(.4,0,.2,1)',
2870
+ SHOW_ROUTE: 'cubic-bezier(.165,.84,.44,1)',
2871
+ HIDE_ROUTE: 'cubic-bezier(.165,.84,.44,1)',
2853
2872
  };
2854
2873
 
2855
2874
  function SearchIcon() {
@@ -3426,7 +3445,7 @@ function SwapStepItem({ descriptionBlocks, chipContent, showStepSeparator = fals
3426
3445
  .map((word, i) => (jsx(BodyText, { size: "small", className: "!tw-leading-[13px]", children: word }, i))));
3427
3446
  }
3428
3447
  else if (type === 'image') {
3429
- return (jsx("img", { src: value, className: "tw-h-squid-m tw-w-squid-m tw-rounded-full" }, index));
3448
+ return (jsx("img", { src: value, className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs" }, index));
3430
3449
  }
3431
3450
  return null;
3432
3451
  }) })] })] }));
@@ -3447,7 +3466,7 @@ function Modal({ children, className, onBackdropClick, isOpen: _isOpen = true, m
3447
3466
  return setIsOpen(true);
3448
3467
  const timeoutId = setTimeout(() => {
3449
3468
  setIsOpen(false);
3450
- }, 300);
3469
+ }, ANIMATION_DURATIONS.HIDE_MODAL);
3451
3470
  return () => {
3452
3471
  clearTimeout(timeoutId);
3453
3472
  };
@@ -3460,7 +3479,13 @@ function Modal({ children, className, onBackdropClick, isOpen: _isOpen = true, m
3460
3479
  onBackdropClick();
3461
3480
  }
3462
3481
  }
3463
- : undefined, className: cn('tw-absolute tw-inset-0 tw-z-40 tw-flex tw-items-start tw-justify-center tw-bg-material-dark-average tw-px-squid-xs tw-py-squid-xl tw-pb-squid-m tw-transition-all', _isOpen ? 'tw-animate-blur-in' : 'tw-animate-blur-out'), children: jsx("div", { className: cn('tw-relative tw-flex tw-max-h-[600px] tw-w-[400px] tw-flex-col tw-items-start tw-justify-end tw-gap-squid-xxs tw-self-end', className, _isOpen ? 'tw-animate-slide-to-top' : 'tw-animate-slide-to-bottom', maxHeight && 'tw-h-full'), children: children }) })));
3482
+ : undefined, style: {
3483
+ [CSS_VARS.BLUR_IN_DURATION]: `${ANIMATION_DURATIONS.SHOW_MODAL}ms`,
3484
+ [CSS_VARS.BLUR_OUT_DURATION]: `${ANIMATION_DURATIONS.HIDE_MODAL}ms`,
3485
+ }, className: cn('tw-absolute tw-inset-0 tw-z-40 tw-flex tw-items-start tw-justify-center tw-px-squid-xs tw-py-squid-xl tw-pb-squid-m', _isOpen ? 'tw-animate-blur-in' : 'tw-animate-blur-out'), children: jsx("div", { style: {
3486
+ [CSS_VARS.SLIDE_TO_TOP_DURATION]: `${ANIMATION_DURATIONS.SHOW_MODAL}ms`,
3487
+ [CSS_VARS.SLIDE_TO_BOTTOM_DURATION]: `${ANIMATION_DURATIONS.HIDE_MODAL}ms`,
3488
+ }, className: cn('tw-relative tw-flex tw-max-h-[600px] tw-w-[400px] tw-flex-col tw-items-start tw-justify-end tw-gap-squid-xxs tw-self-end', className, _isOpen ? 'tw-animate-slide-to-top' : 'tw-animate-slide-to-bottom', maxHeight && 'tw-h-full'), children: children }) })));
3464
3489
  }
3465
3490
 
3466
3491
  const borderTypeClassMap = {
@@ -38487,14 +38512,6 @@ const transactionRejectedAnimation = TransactionRejectedAnimation;
38487
38512
  const useTimer = ({ immediateStart = true, }) => {
38488
38513
  const [timer, setTimer] = useState('0s');
38489
38514
  const intervalRef = useRef(null);
38490
- const formatTime = (elapsedTime) => {
38491
- const totalSeconds = Math.floor(elapsedTime / 1000);
38492
- const minutes = Math.floor(totalSeconds / 60);
38493
- const seconds = totalSeconds % 60;
38494
- const formattedMinutes = minutes > 0 ? `${minutes}m` : '';
38495
- const formattedSeconds = seconds > 0 ? `${seconds}s` : '';
38496
- return `${formattedMinutes}${formattedSeconds}`.trim();
38497
- };
38498
38515
  const startTimer = () => {
38499
38516
  if (intervalRef.current !== null)
38500
38517
  return; // Prevent multiple intervals
@@ -38521,26 +38538,34 @@ const useTimer = ({ immediateStart = true, }) => {
38521
38538
  return { timer, stopTimer, startTimer };
38522
38539
  };
38523
38540
 
38524
- var TransactionStatus;
38525
- (function (TransactionStatus) {
38526
- // Submitted transaction, returned by squid axelar
38527
- TransactionStatus["SUCCESS"] = "success";
38528
- TransactionStatus["NEEDS_GAS"] = "needs_gas";
38529
- TransactionStatus["ONGOING"] = "ongoing";
38530
- TransactionStatus["PARTIAL_SUCCESS"] = "partial_success";
38531
- TransactionStatus["NOT_FOUND"] = "not_found";
38532
- // Unsubmitted Transaction, can be status from wallet
38533
- TransactionStatus["INITIAL_LOADING"] = "initialLoading";
38534
- TransactionStatus["ERROR"] = "error";
38535
- TransactionStatus["WARNING"] = "warning";
38536
- TransactionStatus["PENDING"] = "pending";
38537
- TransactionStatus["REJECTED"] = "rejected";
38538
- })(TransactionStatus || (TransactionStatus = {}));
38541
+ var SwapState;
38542
+ (function (SwapState) {
38543
+ // user needs to sign the transaction in their wallet
38544
+ SwapState[SwapState["CONFIRM"] = 0] = "CONFIRM";
38545
+ // transaction is ongoing
38546
+ SwapState[SwapState["PROGRESS"] = 1] = "PROGRESS";
38547
+ // transaction is successful
38548
+ SwapState[SwapState["COMPLETED"] = 2] = "COMPLETED";
38549
+ // transaction failed
38550
+ SwapState[SwapState["ERROR"] = 3] = "ERROR";
38551
+ // transaction failed halfway and user received fallback tokens
38552
+ SwapState[SwapState["PARTIAL_SUCCESS"] = 4] = "PARTIAL_SUCCESS";
38553
+ // user hasn't signed the transaction in their wallet after some time
38554
+ SwapState[SwapState["CONFIRMATION_TOO_LONG"] = 5] = "CONFIRMATION_TOO_LONG";
38555
+ // user rejected the transaction in their wallet
38556
+ SwapState[SwapState["CONFIRMATION_REJECTED"] = 6] = "CONFIRMATION_REJECTED";
38557
+ // user needs to add gas to the transaction to complete its execution
38558
+ SwapState[SwapState["NEEDS_GAS"] = 7] = "NEEDS_GAS";
38559
+ })(SwapState || (SwapState = {}));
38539
38560
 
38540
38561
  function ChainLink({ size = '16', strokeWidth = '2', }) {
38541
38562
  return (jsx("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M6.66667 3.66667L7.16763 3.17225C8.73063 1.60925 11.2648 1.60925 12.8278 3.17225C14.3907 4.73525 14.3907 7.26937 12.8278 8.83237L12.3333 9.33333M3.66667 6.66667L3.17225 7.16763C1.60925 8.73063 1.60925 11.2648 3.17225 12.8278C4.73525 14.3907 7.26937 14.3907 8.83237 12.8278L9.33333 12.3333M6.66667 9.33333L9.33333 6.66667", stroke: "currentColor", strokeWidth: strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }) }));
38542
38563
  }
38543
38564
 
38565
+ function TimeFliesIcon({ size = '24', className, }) {
38566
+ return (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", className: className, children: [jsx("circle", { cx: "15", cy: "12", r: "7", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }), jsx("path", { d: "M2 12H4M3 16H5M3 8H5", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }), jsx("path", { d: "M15 9V12L16.5 13.5", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })] }));
38567
+ }
38568
+
38544
38569
  function XSocial({ className, size = '24', }) {
38545
38570
  return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", className: className, children: jsx("path", { d: "M17.4033 3.5H20.2852L13.989 10.701L21.396 20.5H15.5964L11.054 14.557L5.85637 20.5H2.97269L9.70709 12.7977L2.60156 3.5H8.54839L12.6544 8.93215L17.4033 3.5ZM16.3918 18.7738H17.9887L7.68067 5.13549H5.96702L16.3918 18.7738Z", fill: "currentColor" }) }));
38546
38571
  }
@@ -38588,68 +38613,79 @@ const AnimationWrapper = ({ lottieJsonFile, animReplacement, hideAnimations = fa
38588
38613
  };
38589
38614
 
38590
38615
  const swapProgressAnimations = {
38591
- confirm: transactionPendingAnimation,
38592
- error: transactionErrorPauseAnimation,
38593
- partialSuccess: transactionHalfSuccessAnimation,
38594
- progress: transactionProcessinganimation,
38595
- completed: transactionSuccessAnimation,
38596
- confirmationTooLong: transactionPendingAnimation,
38597
- confirmationRejected: transactionRejectedAnimation,
38598
- needsGas: transactionErrorPauseAnimation,
38616
+ [SwapState.CONFIRM]: transactionPendingAnimation,
38617
+ [SwapState.ERROR]: transactionErrorPauseAnimation,
38618
+ [SwapState.PARTIAL_SUCCESS]: transactionHalfSuccessAnimation,
38619
+ [SwapState.PROGRESS]: transactionProcessinganimation,
38620
+ [SwapState.COMPLETED]: transactionSuccessAnimation,
38621
+ [SwapState.CONFIRMATION_TOO_LONG]: transactionPendingAnimation,
38622
+ [SwapState.CONFIRMATION_REJECTED]: transactionRejectedAnimation,
38623
+ [SwapState.NEEDS_GAS]: transactionErrorPauseAnimation,
38599
38624
  };
38600
- const swapProgressTitles = {
38601
- confirm: 'Confirm swap',
38602
- progress: 'Swapping tokens',
38603
- completed: 'Swap complete',
38604
- error: 'Swap failed',
38605
- confirmationTooLong: 'Confirmation taking too long',
38606
- confirmationRejected: 'Swap rejected',
38607
- partialSuccess: 'Swap failed halfway',
38608
- // means that the user needs to add gas to the transaction in the destination chain
38609
- // in order to complete the swap
38610
- needsGas: 'Needs gas on destination',
38625
+ const getSwapProgressTitle = ({ fromToken, toToken, swapState, }) => {
38626
+ switch (swapState) {
38627
+ case SwapState.CONFIRM:
38628
+ return 'Confirm swap';
38629
+ case SwapState.PROGRESS:
38630
+ return `Swap ${fromToken.symbol} to ${toToken.symbol}`;
38631
+ case SwapState.COMPLETED:
38632
+ return 'Swap complete';
38633
+ case SwapState.ERROR:
38634
+ return 'Swap failed';
38635
+ case SwapState.CONFIRMATION_TOO_LONG:
38636
+ return 'Confirmation taking too long';
38637
+ case SwapState.CONFIRMATION_REJECTED:
38638
+ return 'Swap rejected';
38639
+ case SwapState.PARTIAL_SUCCESS:
38640
+ return 'Swap failed halfway';
38641
+ case SwapState.NEEDS_GAS:
38642
+ return 'Needs gas on destination';
38643
+ }
38611
38644
  };
38612
- const getSwapProgressDescriptions = ({ state, toAmount, toChain, toToken, }) => {
38613
- switch (state) {
38614
- case 'confirm': {
38645
+ const getSwapProgressDescriptions = ({ swapState, toAmount, toChain, toToken, }) => {
38646
+ switch (swapState) {
38647
+ case SwapState.CONFIRM: {
38615
38648
  return 'Authenticate the transaction in your wallet.';
38616
38649
  }
38617
- case 'progress': {
38650
+ case SwapState.PROGRESS: {
38618
38651
  return 'Feel free to dismiss this dialog, we’ll notify you when the swap is complete.';
38619
38652
  }
38620
- case 'completed': {
38653
+ case SwapState.COMPLETED: {
38621
38654
  return `You received ${toAmount} ${toToken === null || toToken === void 0 ? void 0 : toToken.symbol} on ${toChain === null || toChain === void 0 ? void 0 : toChain.networkName}`;
38622
38655
  }
38623
- case 'error': {
38656
+ case SwapState.ERROR: {
38624
38657
  return 'Your tokens were safely returned to your wallet.';
38625
38658
  }
38626
- case 'confirmationTooLong': {
38659
+ case SwapState.CONFIRMATION_TOO_LONG: {
38627
38660
  return 'Please go back and get a new quote.';
38628
38661
  }
38629
- case 'confirmationRejected': {
38662
+ case SwapState.CONFIRMATION_REJECTED: {
38630
38663
  return 'You declined the transaction in your wallet.';
38631
38664
  }
38632
- case 'partialSuccess': {
38665
+ case SwapState.PARTIAL_SUCCESS: {
38633
38666
  return `You received a refund of axlUSDC on ${toChain === null || toChain === void 0 ? void 0 : toChain.networkName}`;
38634
38667
  }
38635
- case 'needsGas': {
38668
+ case SwapState.NEEDS_GAS: {
38636
38669
  return 'Add gas to the transaction via Axelarscan to complete the swap';
38637
38670
  }
38638
38671
  }
38639
38672
  };
38640
38673
  const swapProgressButtonTexts = {
38641
- confirm: 'Cancel',
38642
- progress: 'Ok, done',
38643
- completed: 'Ok, done',
38644
- error: 'Ok, go back',
38645
- confirmationTooLong: 'Cancel',
38646
- confirmationRejected: 'Ok, go back',
38647
- partialSuccess: 'Ok, done',
38648
- needsGas: 'Go to Axelarscan',
38674
+ [SwapState.CONFIRM]: 'Cancel',
38675
+ [SwapState.PROGRESS]: 'Ok, done',
38676
+ [SwapState.COMPLETED]: 'Ok, done',
38677
+ [SwapState.ERROR]: 'Ok, go back',
38678
+ [SwapState.CONFIRMATION_TOO_LONG]: 'Cancel',
38679
+ [SwapState.CONFIRMATION_REJECTED]: 'Ok, go back',
38680
+ [SwapState.PARTIAL_SUCCESS]: 'Ok, done',
38681
+ [SwapState.NEEDS_GAS]: 'Go to Axelarscan',
38649
38682
  };
38650
- function SwapProgressView({ steps, isOpen = true, handleClose, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, txStatus, }) {
38683
+ function SwapProgressView({ steps, isOpen = true, handleClose, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, }) {
38651
38684
  const [showSwapInfoSection, setShowSwapInfoSection] = useState(true);
38652
38685
  const isFirstRenderRef = useRef(true);
38686
+ const { timer, stopTimer, startTimer } = useTimer({
38687
+ immediateStart: false,
38688
+ });
38653
38689
  const handleRouteStepsOpen = useCallback(() => {
38654
38690
  if (isFirstRenderRef.current) {
38655
38691
  isFirstRenderRef.current = false;
@@ -38662,28 +38698,23 @@ function SwapProgressView({ steps, isOpen = true, handleClose, socialLink, suppo
38662
38698
  }
38663
38699
  setShowSwapInfoSection(true);
38664
38700
  }, []);
38665
- const animationProgressState = useMemo(() => {
38666
- switch (txStatus) {
38667
- case 'warning':
38668
- return 'confirmationTooLong';
38669
- case 'partial_success':
38670
- return 'partialSuccess';
38671
- case 'needs_gas':
38672
- return 'needsGas';
38673
- case 'error':
38674
- return 'error';
38675
- case 'rejected':
38676
- return 'confirmationRejected';
38677
- case 'success':
38678
- return 'completed';
38679
- case 'ongoing':
38680
- case 'initialLoading':
38681
- return 'progress';
38682
- case 'pending':
38683
- default:
38684
- return 'confirm';
38685
- }
38686
- }, [txStatus]);
38701
+ const { headerDescription, headerTitle } = useMemo(() => {
38702
+ const headerTitle = getSwapProgressTitle({
38703
+ swapState: swapState,
38704
+ fromToken,
38705
+ toToken,
38706
+ });
38707
+ const headerDescription = getSwapProgressDescriptions({
38708
+ swapState: swapState,
38709
+ toAmount,
38710
+ toChain,
38711
+ toToken,
38712
+ });
38713
+ return {
38714
+ headerTitle,
38715
+ headerDescription,
38716
+ };
38717
+ }, [swapState, fromToken, toToken, toAmount, toChain]);
38687
38718
  return (jsxs(Modal, { isOpen: isOpen, onBackdropClick: handleClose, children: [jsxs(ModalContent, { style: {
38688
38719
  [CSS_VARS.SCALE_AND_FADE_DOWN_DURATION]: `${ANIMATION_DURATIONS.SHOW_ROUTE}ms`,
38689
38720
  [CSS_VARS.SCALE_AND_FADE_UP_DURATION]: `${ANIMATION_DURATIONS.HIDE_ROUTE}ms`,
@@ -38696,26 +38727,18 @@ function SwapProgressView({ steps, isOpen = true, handleClose, socialLink, suppo
38696
38727
  : 'tw-animate-scale-and-fade-down'), children: [jsx("div", { className: "tw-flex tw-h-[160px] tw-w-full tw-items-center tw-justify-center tw-rounded-tl-squid-l tw-rounded-tr-squid-l tw-bg-royal-500 tw-text-material-light-thin", style: {
38697
38728
  // box shadow simulating bottom outline (we do not use css outline because cannot apply it to only one side)
38698
38729
  boxShadow: '0 1px 0 currentColor',
38699
- }, children: jsx("div", { children: jsx(AnimationWrapper, { lottieJsonFile: swapProgressAnimations[animationProgressState], hideAnimations: false, animReplacement: jsx(Loader, { size: "60" }) }) }) }), jsx("div", { className: "tw-relative tw-flex tw-h-squid-m tw-w-full tw-items-end tw-justify-between tw-self-stretch tw-px-squid-m", children: animationProgressState === 'completed' ? (jsxs(Fragment, { children: [jsx("span", { className: "-tw-mb-1 -tw-ml-1", children: jsx(CircleCheckIcon, {}) }), jsx(Button, { size: "md", variant: "secondary", icon: jsx(XSocial, {}), label: "Share", link: socialLink, title: "Share on X" })] })) : animationProgressState === 'error' ||
38700
- animationProgressState === 'partialSuccess' ? (jsxs(Fragment, { children: [jsx("span", { className: "-tw-mb-1 -tw-ml-1", children: jsx(EmojiSadFilledIcon, {}) }), jsx(Button, { size: "md", variant: "secondary", label: "Get help", link: supportLink, title: "Contact support" })] })) : (jsx(TokenPair, { firstToken: {
38730
+ }, children: jsx("div", { children: jsx(AnimationWrapper, { lottieJsonFile: swapProgressAnimations[swapState], hideAnimations: false, animReplacement: jsx(Loader, { size: "60" }) }) }) }), jsx("div", { className: "tw-relative tw-flex tw-h-squid-m tw-w-full tw-items-end tw-justify-between tw-self-stretch tw-px-squid-m", children: swapState === SwapState.COMPLETED ? (jsxs(Fragment, { children: [jsx("span", { className: "-tw-mb-1 -tw-ml-1", children: jsx(CircleCheckIcon, {}) }), jsx(Button, { size: "md", variant: "secondary", icon: jsx(XSocial, {}), label: "Share", link: socialLink, title: "Share on X" })] })) : swapState === SwapState.ERROR ||
38731
+ swapState === SwapState.PARTIAL_SUCCESS ? (jsxs(Fragment, { children: [jsx("span", { className: "-tw-mb-1 -tw-ml-1", children: jsx(EmojiSadFilledIcon, {}) }), jsx(Button, { size: "md", variant: "secondary", label: "Get help", link: supportLink, title: "Contact support" })] })) : (jsx(TokenPair, { firstToken: {
38701
38732
  bgColor: fromToken.bgColor,
38702
38733
  imageUrl: fromToken.logoUrl,
38703
38734
  }, secondToken: {
38704
38735
  bgColor: toToken.bgColor,
38705
38736
  imageUrl: toToken.logoUrl,
38706
- } })) }), jsx(SwapProgressViewHeader, { title: swapProgressTitles[animationProgressState], description: getSwapProgressDescriptions({
38707
- state: animationProgressState,
38708
- toAmount,
38709
- toChain,
38710
- toToken,
38711
- }) }), jsxs("ul", { className: "tw-flex tw-h-[195px] tw-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xxs tw-rounded-squid-l tw-py-squid-s", children: [jsx(SwapDetailListItem, { icon: jsx(ArrowRightUpCircleIcon, {}), label: `Swap ${fromToken === null || fromToken === void 0 ? void 0 : fromToken.symbol}`, detail: jsxs("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xxs", children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: fromToken.logoUrl }), animationProgressState === 'error' ? (jsx(CaptionText, { children: "0" })) : (fromAmount)] }) }), jsx(SwapDetailListItem, { icon: jsx("span", { className: "tw-inline-block tw-rotate-90", children: jsx(ArrowRightUpCircleIcon, {}) }), label: `Receive ${toToken === null || toToken === void 0 ? void 0 : toToken.symbol}`, detail: jsxs("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xxs", children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: toToken.logoUrl }), animationProgressState === 'error' ? (jsx(CaptionText, { children: "0" })) : (toAmount)] }) }), jsx(SwapDetailListItem, { icon: jsx(ChainLink, { size: "24", strokeWidth: "1.5" }), label: "Chain", detail: jsxs("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xxs", children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: fromChain.logoUrl }), jsx(CaptionText, { children: fromChain.networkName }), jsx("span", { className: "tw-text-grey-500", children: jsx(ChevronLargeRightIcon, {}) }), jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: toChain.logoUrl }), jsx(CaptionText, { children: toChain.networkName })] }) }), jsx(SwapDetailListItem, { icon: jsx(WalletFilledIcon, { size: "24" }), label: "Wallet", detail: jsxs("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xxs", children: [jsx(CaptionText, { children: fromAddressFormatted }), jsx("span", { className: "tw-text-grey-500", children: jsx(ChevronLargeRightIcon, {}) }), jsx(CaptionText, { children: toAddressFormatted })] }) })] })] }), jsx(TrackTransactionView, { rawSteps: steps, onClose: handleRouteStepsClosed, onOpen: handleRouteStepsOpen, txStatus: txStatus }), jsx(Button, { size: "lg", variant: "primary", label: swapProgressButtonTexts[animationProgressState], onClick: handleClose, className: "tw-min-h-button" })] }));
38737
+ } })) }), jsx(SwapProgressViewHeader, { title: headerTitle, description: headerDescription }), jsxs("ul", { className: "tw-flex tw-h-[195px] tw-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xxs tw-rounded-squid-l tw-py-squid-s", children: [jsx(SwapDetailListItem, { icon: jsx(ArrowsSwapIcon, {}), label: "Swap", detail: jsx(SwapDetailItemValues, { fromContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: fromToken.logoUrl }), jsx(CaptionText, { children: fromAmount })] }), toContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: toToken.logoUrl }), jsx(CaptionText, { children: toAmount })] }) }) }), jsx(SwapDetailListItem, { icon: jsx(ChainLink, { size: "24", strokeWidth: "1.5" }), label: "Chain", detail: jsx(SwapDetailItemValues, { fromContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: fromChain.logoUrl }), jsx(CaptionText, { children: fromChain.networkName })] }), toContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: toChain.logoUrl }), jsx(CaptionText, { children: toChain.networkName })] }) }) }), jsx(SwapDetailListItem, { icon: jsx(WalletFilledIcon, { size: "24" }), label: "Wallet", detail: jsx(SwapDetailItemValues, { fromContent: fromAddressFormatted, toContent: toAddressFormatted }) }), jsx(SwapDetailListItem, { icon: jsx(TimeFliesIcon, {}), label: "Time to complete", detail: jsx(SwapDetailItemValues, { fromContent: timer, toContent: estimatedTimeToComplete }) })] })] }), jsx(TrackTransactionView, { onTxEnd: () => stopTimer(), onTxStart: () => startTimer(), rawSteps: steps, onClose: handleRouteStepsClosed, onOpen: handleRouteStepsOpen, swapState: swapState }), jsx(Button, { size: "lg", variant: "primary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" })] }));
38712
38738
  }
38713
- const TrackTransactionView = ({ txStatus, rawSteps, onOpen, onClose, }) => {
38714
- const { timer, stopTimer, startTimer } = useTimer({
38715
- immediateStart: false,
38716
- });
38739
+ const TrackTransactionView = ({ swapState, rawSteps, onOpen, onClose, onTxStart, onTxEnd, }) => {
38717
38740
  const { currentStepIndex, steps } = useMemo(() => {
38718
- if (rawSteps.every((s) => s.status === TransactionStatus.SUCCESS)) {
38741
+ if (rawSteps.every((s) => s.status === SwapState.COMPLETED)) {
38719
38742
  return {
38720
38743
  steps: rawSteps,
38721
38744
  currentStepIndex: rawSteps.length - 1,
@@ -38724,9 +38747,9 @@ const TrackTransactionView = ({ txStatus, rawSteps, onOpen, onClose, }) => {
38724
38747
  // TODO: Fix this
38725
38748
  // Vercel build throws an error for findLastIndex, probably related to the Node version being used
38726
38749
  // @ts-ignore
38727
- const lastSuccessfulStepIndex = rawSteps.findLastIndex((s) => s.status === TransactionStatus.SUCCESS);
38728
- if (txStatus === TransactionStatus.ONGOING) {
38729
- startTimer();
38750
+ const lastSuccessfulStepIndex = rawSteps.findLastIndex((s) => s.status === SwapState.COMPLETED);
38751
+ if (swapState === SwapState.PROGRESS) {
38752
+ onTxStart();
38730
38753
  const noSuccessfulStep = lastSuccessfulStepIndex < 0;
38731
38754
  // If no successful step, but transaction is ongoing, this means user signed the tx in their wallet,
38732
38755
  // so we show the second step, because the first step is "waiting for confirmation"
@@ -38734,13 +38757,13 @@ const TrackTransactionView = ({ txStatus, rawSteps, onOpen, onClose, }) => {
38734
38757
  const currentOngoingStepIndex = noSuccessfulStep
38735
38758
  ? 1
38736
38759
  : lastSuccessfulStepIndex + 1;
38737
- // If current step is not the last one, show the timer
38760
+ // If current step is not the last one, show the loader
38738
38761
  if (currentOngoingStepIndex < rawSteps.length) {
38739
- // Show the timer in the current ongoing step
38762
+ // Show loader in the current ongoing step
38740
38763
  // @ts-ignore Vercel build error - TODO: Fix this
38741
- const stepsWithTimer = rawSteps.with(currentOngoingStepIndex, Object.assign(Object.assign({}, rawSteps[currentOngoingStepIndex]), { chipContent: timer }));
38764
+ const stepsWithLoader = rawSteps.with(currentOngoingStepIndex, Object.assign(Object.assign({}, rawSteps[currentOngoingStepIndex]), { chipContent: jsx(Loader, { size: "16", strokeWidth: "2" }) }));
38742
38765
  return {
38743
- steps: stepsWithTimer,
38766
+ steps: stepsWithLoader,
38744
38767
  currentStepIndex: currentOngoingStepIndex,
38745
38768
  };
38746
38769
  }
@@ -38749,8 +38772,8 @@ const TrackTransactionView = ({ txStatus, rawSteps, onOpen, onClose, }) => {
38749
38772
  currentStepIndex: rawSteps.length - 1,
38750
38773
  };
38751
38774
  }
38752
- else if (txStatus === TransactionStatus.SUCCESS) {
38753
- stopTimer();
38775
+ else if (swapState === SwapState.COMPLETED) {
38776
+ onTxEnd();
38754
38777
  return {
38755
38778
  steps: rawSteps,
38756
38779
  currentStepIndex: rawSteps.length - 1,
@@ -38760,9 +38783,12 @@ const TrackTransactionView = ({ txStatus, rawSteps, onOpen, onClose, }) => {
38760
38783
  steps: rawSteps,
38761
38784
  currentStepIndex: 0,
38762
38785
  };
38763
- }, [txStatus, rawSteps, timer]);
38786
+ }, [swapState, rawSteps]);
38764
38787
  return rawSteps.length > 0 ? (jsx(SwapStepsCollapsed, { steps: steps, currentStepIndex: currentStepIndex, onClose: onClose, onOpen: onOpen })) : null;
38765
38788
  };
38789
+ const SwapDetailItemValues = ({ fromContent, toContent, }) => {
38790
+ return (jsxs("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xxs", children: [typeof fromContent === 'string' ? (jsx(CaptionText, { children: fromContent })) : (fromContent), jsx("span", { className: "tw-text-grey-500", children: jsx(ChevronLargeRightIcon, {}) }), typeof toContent === 'string' ? (jsx(CaptionText, { children: toContent })) : (toContent)] }));
38791
+ };
38766
38792
 
38767
38793
  const lightTheme = {
38768
38794
  // content
@@ -41,3 +41,7 @@ export declare function ReorderIcon({ size, className, }: {
41
41
  size?: string;
42
42
  className?: string;
43
43
  }): import("react/jsx-runtime").JSX.Element;
44
+ export declare function ArrowsSwapIcon({ size, className, }: {
45
+ size?: string;
46
+ className?: string;
47
+ }): import("react/jsx-runtime").JSX.Element;
@@ -14,3 +14,7 @@ export declare const ExplosionIcon: ({ size, className, }: {
14
14
  className?: string;
15
15
  size?: string;
16
16
  }) => import("react/jsx-runtime").JSX.Element;
17
+ export declare function TimeFliesIcon({ size, className, }: {
18
+ size?: string;
19
+ className?: string;
20
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { SwapStep, TransactionStatus } from '../../types/components';
1
+ import { SwapState, SwapStep } from '../../types/components';
2
2
  type ChainData = {
3
3
  networkName: string;
4
4
  logoUrl: string;
@@ -9,7 +9,7 @@ type Token = {
9
9
  logoUrl: string;
10
10
  bgColor: string;
11
11
  };
12
- export declare function SwapProgressView({ steps, isOpen, handleClose, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, txStatus, }: {
12
+ export declare function SwapProgressView({ steps, isOpen, handleClose, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, }: {
13
13
  steps: SwapStep[];
14
14
  handleClose?: () => void;
15
15
  isOpen?: boolean;
@@ -23,13 +23,16 @@ export declare function SwapProgressView({ steps, isOpen, handleClose, socialLin
23
23
  toChain: ChainData;
24
24
  fromAddressFormatted: string;
25
25
  toAddressFormatted: string;
26
- txStatus: TransactionStatus;
26
+ swapState: SwapState;
27
+ estimatedTimeToComplete?: string;
27
28
  }): import("react/jsx-runtime").JSX.Element;
28
29
  interface Props {
29
30
  rawSteps: SwapStep[];
30
- txStatus?: TransactionStatus;
31
+ swapState?: SwapState;
31
32
  onOpen?: () => void;
32
33
  onClose?: () => void;
34
+ onTxStart: () => void;
35
+ onTxEnd: () => void;
33
36
  }
34
- export declare const TrackTransactionView: ({ txStatus, rawSteps, onOpen, onClose, }: Props) => import("react/jsx-runtime").JSX.Element | null;
37
+ export declare const TrackTransactionView: ({ swapState, rawSteps, onOpen, onClose, onTxStart, onTxEnd, }: Props) => import("react/jsx-runtime").JSX.Element | null;
35
38
  export {};
@@ -8,14 +8,24 @@ export declare const CSS_VARS: {
8
8
  SCALE_AND_FADE_UP_DURATION: string;
9
9
  SCALE_AND_FADE_DOWN_DURATION: string;
10
10
  TRANSLATE_TOP_OR_BOTTOM: string;
11
+ SHOW_MODAL_DURATION: string;
12
+ HIDE_MODAL_DURATION: string;
13
+ SLIDE_TO_TOP_DURATION: string;
14
+ SLIDE_TO_BOTTOM_DURATION: string;
15
+ BLUR_IN_DURATION: string;
16
+ BLUR_OUT_DURATION: string;
11
17
  };
12
18
  export declare const ANIMATION_DURATIONS: {
13
19
  SHOW_ROUTE: number;
14
20
  HIDE_ROUTE: number;
15
21
  CHANGE_SWAP_STEP: number;
22
+ SHOW_MODAL: number;
23
+ HIDE_MODAL: number;
16
24
  };
17
25
  export declare const ANIMATION_TIMINGS: {
18
26
  EXPAND_ROUTE: string;
19
27
  COLLAPSE_ROUTE: string;
20
28
  CHANGE_SWAP_STEP: string;
29
+ SHOW_ROUTE: string;
30
+ HIDE_ROUTE: string;
21
31
  };
@@ -14,4 +14,5 @@ interface DebouncedFunction<F extends AnyFunction> {
14
14
  cancel: () => void;
15
15
  }
16
16
  export declare function debounce<F extends AnyFunction>(func: F, delay: number): DebouncedFunction<F>;
17
+ export declare const formatTime: (elapsedTime: number) => string;
17
18
  export {};
@@ -13,21 +13,18 @@ export type SwapStep = {
13
13
  descriptionBlocks: SwapStepDescriptionBlock[];
14
14
  chipContent: React.ReactNode;
15
15
  link?: string;
16
- status: TransactionStatus;
16
+ status: SwapState;
17
17
  };
18
- export type SwapProgressState = 'confirm' | 'progress' | 'completed' | 'error' | 'partialSuccess' | 'confirmationTooLong' | 'confirmationRejected' | 'needsGas';
18
+ export declare enum SwapState {
19
+ CONFIRM = 0,
20
+ PROGRESS = 1,
21
+ COMPLETED = 2,
22
+ ERROR = 3,
23
+ PARTIAL_SUCCESS = 4,
24
+ CONFIRMATION_TOO_LONG = 5,
25
+ CONFIRMATION_REJECTED = 6,
26
+ NEEDS_GAS = 7
27
+ }
19
28
  export type DetailsToolbarState = 'full' | 'loading' | 'empty' | 'error';
20
29
  export type ThemeType = 'light' | 'dark';
21
30
  export type SwapStepItemStatus = 'executed' | 'progress' | 'pending';
22
- export declare enum TransactionStatus {
23
- SUCCESS = "success",
24
- NEEDS_GAS = "needs_gas",
25
- ONGOING = "ongoing",
26
- PARTIAL_SUCCESS = "partial_success",
27
- NOT_FOUND = "not_found",
28
- INITIAL_LOADING = "initialLoading",
29
- ERROR = "error",
30
- WARNING = "warning",
31
- PENDING = "pending",
32
- REJECTED = "rejected"
33
- }
@@ -1 +1,2 @@
1
1
  export type { SquidTheme } from './config';
2
+ export type { SwapState, ThemeType, SwapStep } from './components';