diff --git a/src/components/sweep/SweepPreconditionAlert.tsx b/src/components/sweep/SweepPreconditionAlert.tsx
index fc5c6eb5..afb1440e 100644
--- a/src/components/sweep/SweepPreconditionAlert.tsx
+++ b/src/components/sweep/SweepPreconditionAlert.tsx
@@ -1,10 +1,97 @@
+import { AlertTriangleIcon } from 'lucide-react'
+import { Trans, useTranslation } from 'react-i18next'
+import { Link } from 'react-router-dom'
import type { SweepPreconditionSummary } from '@/components/sweep/preconditions'
-import { PreconditionAlert } from '@/components/ui/jam/PreconditionAlert'
+import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
+import { Balance } from '@/components/ui/jam/Balance'
+import { JAM_JM_RETRIES_DOCS_URL } from '@/constants/jam'
+import { routes } from '@/constants/routes'
+import { shortenStringMiddle } from '@/lib/utils'
+import { JarBadge } from '../earn/fidelity-bond/FidelityBondDialogParts'
interface SweepPreconditionAlertProps {
summary: SweepPreconditionSummary
}
-export const SweepPreconditionAlert = ({ summary }: SweepPreconditionAlertProps) => {
- return
+const RetryLockedUtxoList = ({ summary }: SweepPreconditionAlertProps) => {
+ const { t } = useTranslation()
+
+ return (
+ <>
+
+ ),
+ }}
+ />
+
+
{t('global.utxos')}
+
+ {summary.retryLockedUtxos.map((utxo) => (
+ -
+
+
+
+ {shortenStringMiddle(utxo.utxo, 26)}
+
+
+ ))}
+
+
+ >
+ )
+}
+
+export const SweepPreconditionAlert = ({ summary }: SweepPreconditionAlertProps) => {
+ const { t } = useTranslation()
+
+ if (summary.isFulfilled) {
+ return null
+ }
+
+ return (
+
+
+ {t('scheduler.precondition.title')}
+
+
+ {summary.numberOfNonFrozenFidelityBondOutputs === 0 ? null : (
+ -
+ ,
+ }}
+ />
+
+ )}
+ {summary.numberOfMissingUtxos === 0 ? null : (
+ -
+ {t('scheduler.precondition.hint_missing_utxos', {
+ minConfirmations: summary.options.minConfirmations,
+ })}
+
+ )}
+ {summary.numberOfMissingConfirmations === 0 ? null : (
+ -
+ {t('scheduler.precondition.hint_missing_confirmations', {
+ minConfirmations: summary.options.minConfirmations,
+ amountOfMissingConfirmations: summary.numberOfMissingConfirmations,
+ })}
+
+ )}
+ {summary.retryLockedUtxos.length === 0 ? null : - {}
}
+
+
+
+ )
}
diff --git a/src/components/ui/button-variants.ts b/src/components/ui/button-variants.ts
index ec705830..ee782c92 100644
--- a/src/components/ui/button-variants.ts
+++ b/src/components/ui/button-variants.ts
@@ -40,7 +40,6 @@ const buttonVariants = cva(
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
'icon-sm': 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
'icon-lg': 'size-9',
- 'icon-xxl': 'size-12',
},
},
defaultVariants: {
diff --git a/src/components/ui/jam/Balance.test.tsx b/src/components/ui/jam/Balance.test.tsx
index 49d0355a..b5c8ce40 100644
--- a/src/components/ui/jam/Balance.test.tsx
+++ b/src/components/ui/jam/Balance.test.tsx
@@ -5,8 +5,6 @@ import user from '@testing-library/user-event'
import { describe, it, expect, vi } from 'vitest'
import { Balance } from '@/components/ui/jam/Balance'
import { JamDisplayContextProvider } from '@/context/JamDisplayContextProvider'
-import '@/i18n/config'
-import { withRuntimeLocale } from '@/test/withRuntimeLocale'
const render = (ui: React.ReactNode, options?: Omit
) => {
const providers = ({ children }: { children: React.ReactNode }) => {
@@ -37,13 +35,11 @@ describe('', () => {
})
it('should render balance in SATS', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId('sats-amount')).toHaveTextContent(`12,345,600,000`)
- expect(screen.getByTestId('sats-symbol')).toBeVisible()
- expect(screen.queryByTestId('bitcoin-symbol')).not.toBeInTheDocument()
- expect(screen.queryByTestId('frozen-symbol')).not.toBeInTheDocument()
- })
+ render()
+ expect(screen.getByTestId('sats-amount')).toHaveTextContent(`12,345,600,000`)
+ expect(screen.getByTestId('sats-symbol')).toBeVisible()
+ expect(screen.queryByTestId('bitcoin-symbol')).not.toBeInTheDocument()
+ expect(screen.queryByTestId('frozen-symbol')).not.toBeInTheDocument()
})
it('should render a string BTC value correctly as BTC', () => {
@@ -53,11 +49,9 @@ describe('', () => {
})
it('should render a string BTC value correctly as SATS', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`12,303,224,961`)
- expect(screen.getByTestId('sats-symbol')).toBeVisible()
- })
+ render()
+ expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`12,303,224,961`)
+ expect(screen.getByTestId('sats-symbol')).toBeVisible()
})
it('should render a zero string BTC value correctly as BTC', () => {
@@ -71,31 +65,23 @@ describe('', () => {
})
it('should render a large string BTC value correctly as BTC', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId('bitcoin-amount').dataset.formattedValue).toBe(`20,999,999.97690000`)
- })
+ render()
+ expect(screen.getByTestId('bitcoin-amount').dataset.formattedValue).toBe(`20,999,999.97690000`)
})
it('should render a large string BTC value correctly as SATS', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`2,099,999,997,690,000`)
- })
+ render()
+ expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`2,099,999,997,690,000`)
})
it('should render a max string BTC value correctly as BTC', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId('bitcoin-amount').dataset.formattedValue).toBe(`21,000,000.00000000`)
- })
+ render()
+ expect(screen.getByTestId('bitcoin-amount').dataset.formattedValue).toBe(`21,000,000.00000000`)
})
it('should render a max string BTC value correctly as SATS', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`2,100,000,000,000,000`)
- })
+ render()
+ expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`2,100,000,000,000,000`)
})
it('should render a string SATS value correctly as SATS', () => {
@@ -119,31 +105,23 @@ describe('', () => {
})
it('should render a large string SATS value correctly as BTC', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId('bitcoin-amount').dataset.formattedValue).toBe(`20,999,999.97690000`)
- })
+ render()
+ expect(screen.getByTestId('bitcoin-amount').dataset.formattedValue).toBe(`20,999,999.97690000`)
})
it('should render a large string SATS value correctly as SATS', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`2,099,999,997,690,000`)
- })
+ render()
+ expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`2,099,999,997,690,000`)
})
it('should render a max string SATS value correctly as BTC', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId('bitcoin-amount').dataset.formattedValue).toBe(`21,000,000.00000000`)
- })
+ render()
+ expect(screen.getByTestId('bitcoin-amount').dataset.formattedValue).toBe(`21,000,000.00000000`)
})
it('should render a max string SATS value correctly as SATS', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`2,100,000,000,000,000`)
- })
+ render()
+ expect(screen.getByTestId(`sats-amount`)).toHaveTextContent(`2,100,000,000,000,000`)
})
it('should render frozen balance in BTC', () => {
@@ -154,12 +132,10 @@ describe('', () => {
})
it('should render frozen balance in SATS', () => {
- withRuntimeLocale('en-US', () => {
- render()
- expect(screen.getByTestId('sats-amount')).toHaveTextContent(`12,345,600,000`)
- expect(screen.getByTestId('sats-symbol')).toBeVisible()
- expect(screen.getByTestId('frozen-symbol')).toBeVisible()
- })
+ render()
+ expect(screen.getByTestId('sats-amount')).toHaveTextContent(`12,345,600,000`)
+ expect(screen.getByTestId('sats-symbol')).toBeVisible()
+ expect(screen.getByTestId('frozen-symbol')).toBeVisible()
})
it('should render balance without symbol', () => {
@@ -222,51 +198,4 @@ describe('', () => {
expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
})
-
- it('should render the visibility toggle as a keyboard-focusable button with an accessible name', () => {
- render()
-
- const toggleButton = screen.getByRole('button', { name: 'Show balance' })
- expect(toggleButton).toBeInTheDocument()
- expect(toggleButton).toHaveAttribute('aria-pressed', 'true')
- })
-
- it('should update the accessible name and aria-pressed after toggling', async () => {
- render()
-
- await user.click(screen.getByRole('button', { name: 'Show balance' }))
-
- const toggleButton = screen.getByRole('button', { name: 'Hide balance' })
- expect(toggleButton).toBeInTheDocument()
- expect(toggleButton).toHaveAttribute('aria-pressed', 'false')
- })
-
- it('should toggle visibility via keyboard (Enter)', async () => {
- render()
-
- await user.tab()
- expect(screen.getByRole('button', { name: 'Show balance' })).toHaveFocus()
-
- await user.keyboard('{Enter}')
-
- expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
- expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
- })
-
- it('should toggle visibility via keyboard (Space)', async () => {
- render()
-
- await user.tab()
- expect(screen.getByRole('button', { name: 'Show balance' })).toHaveFocus()
-
- await user.keyboard(' ')
-
- expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
- expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
- })
-
- it('should not render a focusable button when the visibility toggle is disabled', () => {
- render()
- expect(screen.queryByRole('button')).not.toBeInTheDocument()
- })
})
diff --git a/src/components/ui/jam/Balance.tsx b/src/components/ui/jam/Balance.tsx
index c61215cd..11740b9a 100644
--- a/src/components/ui/jam/Balance.tsx
+++ b/src/components/ui/jam/Balance.tsx
@@ -1,6 +1,5 @@
import { useEffect, useMemo, useState, type MouseEvent, type MouseEventHandler, type PropsWithChildren } from 'react'
import { SnowflakeIcon } from 'lucide-react'
-import { useTranslation } from 'react-i18next'
import { CurrencySymbol } from '@/components/ui/jam/CurrencySymbol'
import { useJamDisplayContext } from '@/context/JamDisplayContext'
import { cn, satsToBtc, tryBtcToSat, isValidNumber, getBtcParts, formatSats } from '@/lib/utils'
@@ -24,8 +23,6 @@ type ElementWithSymbolsProps = PropsWithChildren<{
frozenSymbol?: boolean
className?: string
onClick?: MouseEventHandler
- 'aria-label'?: string
- 'aria-pressed'?: boolean
}>
const ElementWithSymbols = ({
@@ -36,40 +33,23 @@ const ElementWithSymbols = ({
className,
children,
onClick,
- 'aria-label': ariaLabel,
- 'aria-pressed': ariaPressed,
}: ElementWithSymbolsProps) => {
- const sharedClassName = cn(
- 'balance-hook inline-flex items-center',
- {
- 'text-brand-info': frozen,
- },
- className,
- )
-
- const content = (
- <>
+ return (
+
{children}
{showSymbol && symbol}
{frozen && frozenSymbol && FROZEN_SYMBOL}
- >
+
)
-
- if (onClick) {
- return (
-
- )
- }
-
- return {content}
}
const DECIMAL_POINT_CHAR = '.'
@@ -176,7 +156,6 @@ export const BalanceComponent = ({
enableVisibilityToggle,
...props
}: BalanceComponentProps) => {
- const { t } = useTranslation()
const [isBalanceVisible, setIsBalanceVisible] = useState(showBalance)
const displayMode = useMemo(() => {
return isBalanceVisible ? (convertToUnit ?? 'default') : 'hidden'
@@ -194,25 +173,18 @@ export const BalanceComponent = ({
setIsBalanceVisible((current) => !current)
}
const onClickHandler = enableVisibilityToggle === false ? undefined : toggleVisibility
- const isInteractive = Boolean(onClickHandler || props.onClick)
return {
...props,
className: cn(props.className, {
- 'cursor-pointer': isInteractive,
+ 'cursor-pointer': onClickHandler || props.onClick,
}),
- onClick: isInteractive
- ? (event: MouseEvent) => {
- onClickHandler?.(event)
- props.onClick?.(event)
- }
- : undefined,
- 'aria-label': onClickHandler
- ? t(isBalanceVisible ? 'settings.hide_balance' : 'settings.show_balance')
- : undefined,
- 'aria-pressed': onClickHandler ? !isBalanceVisible : undefined,
+ onClick: (event: MouseEvent) => {
+ onClickHandler?.(event)
+ props.onClick?.(event)
+ },
}
- }, [props, enableVisibilityToggle, isBalanceVisible, t])
+ }, [props, enableVisibilityToggle])
const element = useMemo(() => {
if (displayMode === 'hidden') {
diff --git a/src/components/ui/jam/CookingPotIcon.tsx b/src/components/ui/jam/CookingPotIcon.tsx
deleted file mode 100644
index 1dd2d288..00000000
--- a/src/components/ui/jam/CookingPotIcon.tsx
+++ /dev/null
@@ -1,163 +0,0 @@
-import { jarBadgeVariant } from '@/components/ui/badge-variants'
-import { cn } from '@/lib/utils'
-
-export interface CookingPotIconProps {
- sourceJarIndex?: number
- destinationJarIndex?: number
- className?: string
-}
-
-const STROKE_CLASSES: Record = {
- jar0: 'stroke-jar0',
- jar1: 'stroke-jar1',
- jar2: 'stroke-jar2',
- jar3: 'stroke-jar3',
- jar4: 'stroke-jar4',
- jarUnknown: 'stroke-jar-unknown',
-}
-
-export const CookingPotIcon = ({ sourceJarIndex, destinationJarIndex, className }: CookingPotIconProps) => {
- const sourceVariant = jarBadgeVariant(sourceJarIndex)
- const destinationVariant = jarBadgeVariant(destinationJarIndex) ?? sourceVariant
-
- const sourceStrokeClass = (sourceVariant && STROKE_CLASSES[sourceVariant]) || 'stroke-jar-unknown'
- const destinationStrokeClass = (destinationVariant && STROKE_CLASSES[destinationVariant]) || sourceStrokeClass
-
- return (
-
-
-
-
-
-
-
- )
-}
diff --git a/src/components/ui/jam/LanguageSelector.tsx b/src/components/ui/jam/LanguageSelector.tsx
deleted file mode 100644
index d0553a45..00000000
--- a/src/components/ui/jam/LanguageSelector.tsx
+++ /dev/null
@@ -1,116 +0,0 @@
-import type { ComponentProps, PropsWithChildren } from 'react'
-import { LanguagesIcon } from 'lucide-react'
-import { useTranslation } from 'react-i18next'
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
- SelectGroup,
- SelectLabel,
-} from '@/components/ui/select'
-import languages from '@/i18n/languages'
-import { cn } from '@/lib/utils'
-import { Button } from '../button'
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuGroup,
- DropdownMenuLabel,
- DropdownMenuRadioGroup,
- DropdownMenuRadioItem,
- DropdownMenuTrigger,
-} from '../dropdown-menu'
-
-export const LanguageSelector = ({
- className,
- ...props
-}: ComponentProps & { className?: string } = {}) => {
- const { i18n, t } = useTranslation()
- const currentLanguage = languages.find((lang) => lang.key === i18n.resolvedLanguage)
- const currentLanguageDescription = currentLanguage?.description || 'English'
-
- return (
-
- )
-}
-
-export const LanguageSelectorDropdownMenu = ({
- className,
- align,
- loop = true,
- ...props
-}: PropsWithChildren<
- ComponentProps & {
- className?: string
- align?: ComponentProps['align']
- loop?: ComponentProps['loop']
- }
-> = {}) => {
- const { i18n, t } = useTranslation()
-
- return (
-
-
- {props.children ?? (
-
- )}
-
-
-
-
-
- {t('settings.label_select_language')}
-
- {
- void i18n.changeLanguage(value)
- }}
- >
- {languages.map((language) => (
-
- {language.description}
-
- ))}
-
-
-
-
- )
-}
diff --git a/src/components/ui/jam/OrderbookEmptyAlert.test.tsx b/src/components/ui/jam/OrderbookEmptyAlert.test.tsx
deleted file mode 100644
index aae12d42..00000000
--- a/src/components/ui/jam/OrderbookEmptyAlert.test.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import type { ReactNode } from 'react'
-import { render, screen } from '@testing-library/react'
-import { describe, expect, it, vi } from 'vitest'
-import { OrderbookEmptyAlert } from './OrderbookEmptyAlert'
-
-vi.mock('react-i18next', () => ({
- useTranslation: () => ({
- t: (key: string) => key,
- }),
- Trans: ({ i18nKey, components }: { i18nKey: string; components?: Record }) => (
-
- {i18nKey}
- {components?.['1']}
-
- ),
-}))
-
-vi.mock('react-router-dom', () => ({
- Link: ({ children, to }: { children?: ReactNode; to: string }) => {children},
-}))
-
-describe('OrderbookEmptyAlert', () => {
- it('renders title, description, button and link to orderbook page', () => {
- render( {}} />)
-
- expect(screen.getByText('orderbook.alert_precheck_empty_title')).toBeInTheDocument()
- expect(screen.getByText(/orderbook.alert_precheck_empty_description/u)).toBeInTheDocument()
- expect(screen.getByRole('link')).toHaveAttribute('href', '/orderbook')
-
- const actionCheck = screen.getByRole('button', { name: 'orderbook.alert_precheck_empty_text_button_check' })
- expect(actionCheck).toBeEnabled()
-
- const actionChecking = screen.queryByRole('button', { name: 'orderbook.alert_precheck_empty_text_button_checking' })
- expect(actionChecking).not.toBeInTheDocument()
- })
-
- it('disables button while checking', () => {
- render( {}} />)
-
- const actionChecking = screen.getByRole('button', { name: 'orderbook.alert_precheck_empty_text_button_checking' })
- expect(actionChecking).toBeDisabled()
-
- const actionCheck = screen.queryByRole('button', { name: 'orderbook.alert_precheck_empty_text_button_check' })
- expect(actionCheck).not.toBeInTheDocument()
- })
-})
diff --git a/src/components/ui/jam/OrderbookEmptyAlert.tsx b/src/components/ui/jam/OrderbookEmptyAlert.tsx
deleted file mode 100644
index 95de8d79..00000000
--- a/src/components/ui/jam/OrderbookEmptyAlert.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { AlertTriangleIcon, RefreshCwIcon } from 'lucide-react'
-import { Trans, useTranslation } from 'react-i18next'
-import { Link } from 'react-router-dom'
-import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
-import { routes } from '@/constants/routes'
-import { Button } from '../button'
-
-interface OrderbookEmptyAlertProps {
- className?: string
- isChecking?: boolean
- onCheckClick?: () => Promise
-}
-
-export const OrderbookEmptyAlert = ({ className, isChecking, onCheckClick }: OrderbookEmptyAlertProps) => {
- const { t } = useTranslation()
-
- return (
-
-
- {t('orderbook.alert_precheck_empty_title')}
-
-
- ,
- }}
- />
-
-
- {onCheckClick && (
-
- )}
-
-
-
- )
-}
diff --git a/src/components/ui/jam/PreconditionAlert.tsx b/src/components/ui/jam/PreconditionAlert.tsx
deleted file mode 100644
index ce42d921..00000000
--- a/src/components/ui/jam/PreconditionAlert.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-import { AlertTriangleIcon } from 'lucide-react'
-import { Trans, useTranslation } from 'react-i18next'
-import { Link } from 'react-router-dom'
-import { JarBadge } from '@/components/earn/fidelity-bond/FidelityBondDialogParts'
-import type { SweepPreconditionSummary } from '@/components/sweep/preconditions'
-import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
-import { Balance } from '@/components/ui/jam/Balance'
-import { JAM_JM_RETRIES_DOCS_URL } from '@/constants/jam'
-import { routes } from '@/constants/routes'
-import { shortenStringMiddle } from '@/lib/utils'
-
-export interface PreconditionAlertProps {
- summary: SweepPreconditionSummary
- i18nPrefix: 'send.coinjoin_precondition' | 'scheduler.precondition'
-}
-
-const RetryLockedUtxoList = ({ summary, i18nPrefix }: PreconditionAlertProps) => {
- const { t } = useTranslation()
-
- return (
- <>
-
- ),
- }}
- />
-
-
{t('global.utxos')}
-
- {summary.retryLockedUtxos.map((utxo) => (
- -
-
-
-
- {shortenStringMiddle(utxo.utxo, 26)}
-
-
- ))}
-
-
- >
- )
-}
-
-export const PreconditionAlert = ({ summary, i18nPrefix }: PreconditionAlertProps) => {
- const { t } = useTranslation()
-
- if (summary.isFulfilled) {
- return null
- }
-
- return (
-
-
- {t(`${i18nPrefix}.title`)}
-
-
- {summary.numberOfNonFrozenFidelityBondOutputs === 0 ? null : (
- -
- ,
- }}
- />
-
- )}
- {summary.numberOfMissingUtxos === 0 ? null : (
- -
- {t(`${i18nPrefix}.hint_missing_utxos`, {
- minConfirmations: summary.options.minConfirmations,
- })}
-
- )}
- {summary.numberOfMissingConfirmations === 0 ? null : (
- -
- {t(`${i18nPrefix}.hint_missing_confirmations`, {
- minConfirmations: summary.options.minConfirmations,
- amountOfMissingConfirmations: summary.numberOfMissingConfirmations,
- })}
-
- )}
- {summary.retryLockedUtxos.length === 0 ? null : (
- -
-
-
- )}
-
-
-
- )
-}
diff --git a/src/components/wallet/TxHistoryContent.test.tsx b/src/components/wallet/TxHistoryContent.test.tsx
deleted file mode 100644
index b22a61a9..00000000
--- a/src/components/wallet/TxHistoryContent.test.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import type { WalletHistoryResponse } from '@joinmarket-webui/joinmarket-ng-api-ts/jm'
-import type { UseQueryResult } from '@tanstack/react-query'
-import { render, screen, fireEvent } from '@testing-library/react'
-import { describe, expect, it, vi } from 'vitest'
-import { useQueryWalletHistory } from '@/hooks/useQueryWalletHistory'
-import { TxHistoryContent } from './TxHistoryContent'
-
-vi.mock('react-i18next', () => ({
- useTranslation: () => ({
- t: (key: string) => key,
- }),
-}))
-
-vi.mock('@/hooks/useQueryWalletHistory', () => ({
- useQueryWalletHistory: vi.fn(),
-}))
-
-vi.mock('./TxHistoryTable', () => ({
- TxHistoryTable: ({ history, compact }: { history: unknown[]; compact: boolean }) => (
-
- Mock Table (Rows: {history.length})
-
- ),
-}))
-
-vi.mock('@/components/ui/alert', () => ({
- Alert: ({ children, variant }: { children: React.ReactNode; variant?: string }) => (
-
- {children}
-
- ),
- AlertDescription: ({ children }: { children: React.ReactNode }) => {children}
,
-}))
-
-vi.mock('@/components/ui/spinner', () => ({
- Spinner: () => ,
-}))
-
-const mockUseQuery = useQueryWalletHistory as unknown as ReturnType
-
-const mockQueryResult = (overrides: Partial>) =>
- ({
- isLoading: false,
- error: null,
- isFetching: false,
- refetch: vi.fn(),
- ...overrides,
- }) as UseQueryResult
-
-describe('TxHistoryContent', () => {
- it('renders loading state', () => {
- mockUseQuery.mockReturnValue({
- history: [],
- queryResult: mockQueryResult({ isLoading: true }),
- })
-
- render()
- expect(screen.getByTestId('mock-loading')).toBeInTheDocument()
- })
-
- it('renders error state', () => {
- mockUseQuery.mockReturnValue({
- history: [],
- queryResult: mockQueryResult({ error: new Error('failed') }),
- })
-
- render()
- expect(screen.getByTestId('mock-alert')).toBeInTheDocument()
- expect(screen.getByText('tx_history.error_loading')).toBeInTheDocument()
- })
-
- it('renders the table with data', () => {
- const mockHistory = [{ txid: '1' }, { txid: '2' }]
- mockUseQuery.mockReturnValue({
- history: mockHistory,
- queryResult: mockQueryResult({}),
- })
-
- render()
- expect(screen.getByTestId('mock-table')).toHaveAttribute('data-compact', 'true')
- expect(screen.getByText('Mock Table (Rows: 2)')).toBeInTheDocument()
- })
-
- it('renders Load More button when not compact and handles clicks', () => {
- const mockHistory = Array.from({ length: 10 }, () => ({ txid: 'mock' }))
- const refetch = vi.fn()
-
- mockUseQuery.mockReturnValue({
- history: mockHistory,
- queryResult: mockQueryResult({ refetch, isFetching: false }),
- })
-
- render()
-
- const loadMoreButton = screen.getByRole('button', { name: 'tx_history.button_load_more' })
- expect(loadMoreButton).toBeInTheDocument()
-
- fireEvent.click(loadMoreButton)
- expect(mockUseQuery).toHaveBeenLastCalledWith(expect.objectContaining({ limit: 20 }))
- })
-
- it('hides Load More button if history length is less than limit', () => {
- const mockHistory = Array.from({ length: 5 }, () => ({ txid: 'mock' }))
-
- mockUseQuery.mockReturnValue({
- history: mockHistory,
- queryResult: mockQueryResult({}),
- })
-
- render()
- expect(screen.queryByRole('button', { name: 'tx_history.button_load_more' })).not.toBeInTheDocument()
- })
-})
diff --git a/src/components/wallet/TxHistoryContent.tsx b/src/components/wallet/TxHistoryContent.tsx
deleted file mode 100644
index f73118e4..00000000
--- a/src/components/wallet/TxHistoryContent.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-import { useMemo, useState } from 'react'
-import { AlertTriangleIcon, ListIcon, PlusIcon, RefreshCwIcon } from 'lucide-react'
-import { useTranslation } from 'react-i18next'
-import { DevBadge } from '@/components/dev/DevBadge'
-import { Alert, AlertDescription } from '@/components/ui/alert'
-import { Button } from '@/components/ui/button'
-import { Spinner } from '@/components/ui/spinner'
-import { useJamWalletInfoContext } from '@/context/JamWalletInfoContext'
-import { useQueryWalletHistory, type HistoryEntry } from '@/hooks/useQueryWalletHistory'
-import { cn, type WalletFileName } from '@/lib/utils'
-import { useDeveloperMode } from '@/store/jamSettingsStore'
-import { TxHistoryTable } from './TxHistoryTable'
-
-interface TxHistoryContentProps {
- walletFileName: WalletFileName
- className?: string
- initialLimit?: number
- compact?: boolean
- enabled?: boolean
- onViewAll?: () => void
-}
-
-const useSafeUtxosHashHex = () => {
- try {
- const context = useJamWalletInfoContext()
- return context?.utxosHashHex
- } catch {
- return undefined
- }
-}
-
-export const TxHistoryContent = ({
- walletFileName,
- className,
- initialLimit = 10,
- compact = false,
- enabled = true,
- onViewAll,
-}: TxHistoryContentProps) => {
- const { t } = useTranslation()
- const [limit, setLimit] = useState(initialLimit)
- const { enabled: isDeveloperMode } = useDeveloperMode()
- const [demoEntries, setDemoEntries] = useState([])
- const utxosHashHex = useSafeUtxosHashHex()
-
- const { history, queryResult } = useQueryWalletHistory({
- walletFileName,
- limit,
- enabled,
- utxosHashHex,
- })
-
- const combinedHistory = useMemo(() => [...demoEntries, ...history], [demoEntries, history])
-
- return (
-
-
-
{t('tx_history.section_title')}
-
- {isDeveloperMode && (
-
- )}
-
-
-
- {compact && onViewAll ? (
-
- ) : null}
-
-
-
- {queryResult.isLoading ? (
-
-
- {t('global.loading')}
-
- ) : queryResult.error ? (
-
-
- {t('tx_history.error_loading')}
-
- ) : (
-
- )}
-
- {!compact && combinedHistory.length >= limit ? (
-
-
-
- ) : null}
-
- )
-}
diff --git a/src/components/wallet/TxHistoryOverlay.test.tsx b/src/components/wallet/TxHistoryOverlay.test.tsx
deleted file mode 100644
index f2f44194..00000000
--- a/src/components/wallet/TxHistoryOverlay.test.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import type { ReactNode } from 'react'
-import { fireEvent, render, screen } from '@testing-library/react'
-import { describe, expect, it, vi } from 'vitest'
-import { TxHistoryOverlay } from './TxHistoryOverlay'
-
-type ChildrenProps = { children: ReactNode }
-type DialogProps = ChildrenProps & { open?: boolean; onOpenChange?: (open: boolean) => void }
-
-vi.mock('react-i18next', () => ({
- useTranslation: () => ({
- t: (key: string) => key,
- }),
-}))
-
-vi.mock('./TxHistoryContent', () => ({
- TxHistoryContent: ({ walletFileName }: { walletFileName: string }) => (
-
- Content
-
- ),
-}))
-
-vi.mock('../ui/jam/PageTitle', () => ({
- default: ({ title }: { title: string }) => {title}
,
-}))
-
-// Mock Dialog to avoid dealing with portals and radix UI internals
-vi.mock('@/components/ui/dialog', () => ({
- Dialog: ({ children, open, onOpenChange }: DialogProps) =>
- open ? (
-
-
- {children}
-
- ) : null,
- DialogContent: ({ children }: ChildrenProps) => {children}
,
- DialogHeader: ({ children }: ChildrenProps) => {children}
,
- DialogTitle: ({ children }: ChildrenProps) => {children}
,
-}))
-
-describe('TxHistoryOverlay', () => {
- it('renders dialog content when open', () => {
- render()
-
- expect(screen.getByTestId('page-title')).toHaveTextContent('tx_history.overlay_title')
-
- const content = screen.getByTestId('tx-history-content')
- expect(content).toBeInTheDocument()
- expect(content).toHaveAttribute('data-wallet', 'test-wallet.jmdat')
- })
-
- it('calls onOpenChange when closed', () => {
- const onOpenChange = vi.fn()
- render()
-
- const closeButton = screen.getByText('Close')
- fireEvent.click(closeButton)
-
- expect(onOpenChange).toHaveBeenCalledWith(false)
- })
-
- it('does not render when closed', () => {
- render()
- expect(screen.queryByTestId('dialog')).not.toBeInTheDocument()
- })
-})
diff --git a/src/components/wallet/TxHistoryOverlay.tsx b/src/components/wallet/TxHistoryOverlay.tsx
deleted file mode 100644
index 6b77b12d..00000000
--- a/src/components/wallet/TxHistoryOverlay.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import type { ComponentProps } from 'react'
-import { useTranslation } from 'react-i18next'
-import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
-import type { WithRequiredProperty } from '@/types/global'
-import PageTitle from '../ui/jam/PageTitle'
-import { TxHistoryContent } from './TxHistoryContent'
-
-type TxHistoryOverlayProps = WithRequiredProperty<
- Omit, 'children'>,
- 'open' | 'onOpenChange'
-> &
- Pick, 'walletFileName'>
-
-export function TxHistoryOverlay({ open, onOpenChange, walletFileName, ...dialogProps }: TxHistoryOverlayProps) {
- const { t } = useTranslation()
-
- return (
-
- )
-}
diff --git a/src/components/wallet/TxHistoryPage.test.tsx b/src/components/wallet/TxHistoryPage.test.tsx
deleted file mode 100644
index c96405d0..00000000
--- a/src/components/wallet/TxHistoryPage.test.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { render, screen } from '@testing-library/react'
-import { describe, expect, it, vi } from 'vitest'
-import { TxHistoryPage } from './TxHistoryPage'
-
-vi.mock('react-i18next', () => ({
- useTranslation: () => ({
- t: (key: string) => key,
- }),
-}))
-
-vi.mock('./TxHistoryContent', () => ({
- TxHistoryContent: ({ compact }: { compact: boolean }) => (
-
- ),
-}))
-
-describe('TxHistoryPage', () => {
- it('renders TxHistoryContent in non-compact page mode with title', () => {
- render()
-
- expect(screen.getByText('tx_history.title')).toBeInTheDocument()
- const content = screen.getByTestId('tx-history-content')
- expect(content).toBeInTheDocument()
- expect(content).toHaveAttribute('data-compact', 'false')
- })
-})
diff --git a/src/components/wallet/TxHistoryPage.tsx b/src/components/wallet/TxHistoryPage.tsx
deleted file mode 100644
index b7c2576f..00000000
--- a/src/components/wallet/TxHistoryPage.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { useTranslation } from 'react-i18next'
-import PageTitle from '@/components/ui/jam/PageTitle'
-import type { WalletFileName } from '@/lib/utils'
-import { TxHistoryContent } from './TxHistoryContent'
-
-interface TxHistoryPageProps {
- walletFileName: WalletFileName
-}
-
-export function TxHistoryPage({ walletFileName }: TxHistoryPageProps) {
- const { t } = useTranslation()
-
- return (
-
- )
-}
diff --git a/src/components/wallet/TxHistoryTable.test.tsx b/src/components/wallet/TxHistoryTable.test.tsx
deleted file mode 100644
index f9dc23ac..00000000
--- a/src/components/wallet/TxHistoryTable.test.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-import { fireEvent, render, screen } from '@testing-library/react'
-import { beforeEach, describe, expect, it, vi } from 'vitest'
-import type { HistoryEntry } from '@/hooks/useQueryWalletHistory'
-import { TxHistoryTable } from './TxHistoryTable'
-
-const mocks = vi.hoisted(() => ({
- toastSuccess: vi.fn(),
- toastError: vi.fn(),
-}))
-
-vi.mock('react-i18next', () => ({
- useTranslation: () => ({
- t: (key: string) => key,
- }),
-}))
-
-vi.mock('sonner', () => ({
- toast: {
- success: mocks.toastSuccess,
- error: mocks.toastError,
- },
-}))
-
-vi.mock('../ui/jam/Address', () => ({
- Address: ({ value }: { value: string }) => {value},
-}))
-
-vi.mock('../ui/jam/Balance', () => ({
- Balance: ({ valueString }: { valueString: string }) => {valueString},
-}))
-
-const mockDeposit: HistoryEntry = {
- timestamp: '2026-07-28T12:00:00Z',
- role: 'deposit',
- txid: 'tx1',
- cj_amount: 5000,
- net_fee: 0,
- confirmations: 10,
- success: true,
- source_mixdepth: 0,
-}
-
-const mockSend: HistoryEntry = {
- timestamp: '2026-07-28T13:00:00Z',
- role: 'send',
- txid: 'tx2',
- cj_amount: 10000,
- net_fee: -100,
- confirmations: 0,
- success: true,
- source_mixdepth: 0,
-}
-
-const mockFailed: HistoryEntry = {
- timestamp: '2026-07-28T14:00:00Z',
- role: 'taker',
- txid: 'tx3',
- cj_amount: 0,
- net_fee: 0,
- confirmations: 0,
- success: false,
- failure_reason: 'aborted',
- source_mixdepth: 1,
-}
-
-describe('TxHistoryTable', () => {
- beforeEach(() => {
- mocks.toastSuccess.mockReset()
- mocks.toastError.mockReset()
- })
-
- it('renders history rows and sorts by date', () => {
- render()
-
- expect(screen.getByText('tx_history.label_role_deposit')).toBeInTheDocument()
- expect(screen.getByText('tx_history.label_role_send')).toBeInTheDocument()
-
- const dateHeader = screen.getByText('tx_history.column_title_date')
- fireEvent.click(dateHeader)
- expect(dateHeader).toBeInTheDocument()
- })
-
- it('renders empty history alert', () => {
- render()
- expect(screen.getByText('tx_history.empty_history')).toBeInTheDocument()
- })
-
- it('expands row details to show raw JSON', () => {
- render()
-
- const detailsButton = screen.getByRole('button', { name: 'jar_details.utxo_list.row_button_details' })
- fireEvent.click(detailsButton)
-
- // Check if the JSON is rendered
- expect(screen.getByText(/"txid": "tx1"/u)).toBeInTheDocument()
- })
-
- it('sorts columns correctly', () => {
- render()
-
- fireEvent.click(screen.getByText('tx_history.column_title_amount'))
- fireEvent.click(screen.getByText('tx_history.column_title_net_fee'))
- fireEvent.click(screen.getByText('tx_history.column_title_confirmations'))
- fireEvent.click(screen.getByText('tx_history.column_title_role'))
-
- expect(screen.getByText('tx_history.label_role_taker')).toBeInTheDocument()
- })
-})
diff --git a/src/components/wallet/TxHistoryTable.tsx b/src/components/wallet/TxHistoryTable.tsx
deleted file mode 100644
index 8abb3ba5..00000000
--- a/src/components/wallet/TxHistoryTable.tsx
+++ /dev/null
@@ -1,317 +0,0 @@
-import { useEffect, useMemo, useState } from 'react'
-import {
- createColumnHelper,
- flexRender,
- getCoreRowModel,
- getExpandedRowModel,
- getPaginationRowModel,
- getSortedRowModel,
- type CellContext,
- type PaginationState,
- type Row,
- type SortingState,
- useReactTable,
-} from '@tanstack/react-table'
-import type { TFunction } from 'i18next'
-import { CheckIcon, ChevronDownIcon, CopyIcon } from 'lucide-react'
-import { useTranslation } from 'react-i18next'
-import { toast } from 'sonner'
-import { TablePagination } from '@/components/ui/jam/TablePagination'
-import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
-import type { HistoryEntry } from '@/hooks/useQueryWalletHistory'
-import { cn, shortenStringMiddle } from '@/lib/utils'
-import { Alert, AlertDescription } from '../ui/alert'
-import { Button } from '../ui/button'
-import { buttonVariants } from '../ui/button-variants'
-import { Card, CardContent } from '../ui/card'
-import { Balance } from '../ui/jam/Balance'
-import { CopyButton } from '../ui/jam/CopyButton'
-import { SortIcon } from '../ui/jam/SortIcon'
-import { StatusBadge } from '../ui/jam/StatusBadge'
-
-const ITEMS_PER_PAGE = 25
-
-type KnownHistoryRole = 'maker' | 'taker' | 'send' | 'deposit'
-type StatusBadgeVariant = NonNullable[0]['variant']>
-
-const ROLE_VARIANT: Record = {
- maker: 'cj-out',
- taker: 'cj-change',
- send: 'used-empty',
- deposit: 'deposit',
-}
-
-const columnHelper = createColumnHelper()
-
-const historyRole = (entry: HistoryEntry): KnownHistoryRole | undefined => {
- return ['maker', 'taker', 'send', 'deposit'].includes(entry.role ?? '') ? (entry.role as KnownHistoryRole) : undefined
-}
-
-const roleLabel = (entry: HistoryEntry, t: TFunction) => {
- const role = historyRole(entry)
- return role ? t(`tx_history.label_role_${role}`) : entry.role || ''
-}
-
-const dateTimeValue = (value: string) => {
- const date = new Date(value)
- return Number.isNaN(date.getTime()) ? 0 : date.getTime()
-}
-
-const formatDateTime = (value: string) => {
- const date = new Date(value)
- return Number.isNaN(date.getTime()) ? value : date.toLocaleString()
-}
-
-const TxHistoryDetails = ({ entry }: { entry: HistoryEntry }) => {
- return (
-
-
- {JSON.stringify(entry, null, 2)}
-
-
- )
-}
-
-const TxHistoryTableRow = ({ row }: { row: Row }) => {
- return (
- <>
-
- {row.getVisibleCells().map((cell) => {
- const alignCenter = cell.column.columnDef.meta?.align === 'center'
- const alignRight = cell.column.columnDef.meta?.align === 'right'
- return (
-
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
-
- )
- })}
-
- {row.getIsExpanded() && (
-
-
-
-
-
- )}
- >
- )
-}
-
-const txHistoryTableColumns = (t: TFunction) => {
- return [
- columnHelper.accessor('timestamp', {
- header: () => t('tx_history.column_title_date'),
- sortingFn: (a, b) => dateTimeValue(a.original.timestamp) - dateTimeValue(b.original.timestamp),
- cell: (info) => {formatDateTime(info.getValue())},
- meta: {
- alphabetic: true,
- },
- }),
- columnHelper.accessor('role', {
- header: () => t('tx_history.column_title_role'),
- sortingFn: (a, b) => roleLabel(a.original, t).localeCompare(roleLabel(b.original, t)),
- cell: (info) => {
- const role = historyRole(info.row.original)
- return (
- {roleLabel(info.row.original, t)}
- )
- },
- }),
- columnHelper.accessor('cj_amount', {
- header: () => t('tx_history.column_title_amount'),
- sortingFn: (a, b) => (a.original.cj_amount ?? 0) - (b.original.cj_amount ?? 0),
- cell: (info) => ,
- meta: {
- numeric: true,
- align: 'right',
- },
- }),
- columnHelper.accessor('net_fee', {
- header: () => t('tx_history.column_title_net_fee'),
- sortingFn: (a, b) => (a.original.net_fee ?? 0) - (b.original.net_fee ?? 0),
- cell: (info) => ,
- meta: {
- numeric: true,
- align: 'right',
- },
- }),
- columnHelper.accessor('confirmations', {
- header: () => t('tx_history.column_title_confirmations'),
- sortingFn: (a, b) => (a.original.confirmations ?? 0) - (b.original.confirmations ?? 0),
- cell: (info) => <>{info.getValue() ?? 0}>,
- meta: {
- numeric: true,
- align: 'center',
- },
- }),
- columnHelper.accessor('txid', {
- header: () => t('tx_history.column_title_txid'),
- cell: (info) => {
- const txid = info.getValue() ?? ''
- return txid ? (
-
- {shortenStringMiddle(txid, 16)}
- }
- successText={}
- className={cn(buttonVariants({ variant: 'outline', size: 'icon-xs' }), 'shrink-0')}
- onSuccess={() => toast.success(t('tx_history.copy_txid_success'))}
- onError={() => toast.error(t('tx_history.copy_txid_error'))}
- />
-
- ) : (
- ''
- )
- },
- enableSorting: false,
- }),
- {
- id: 'expand-col',
- cell: ({ row }: CellContext) => {
- return row.getCanExpand() ? (
-
- ) : (
- ''
- )
- },
- enableSorting: false,
- },
- ]
-}
-
-interface TxHistoryTableProps {
- history: HistoryEntry[]
- compact?: boolean
-}
-
-export const TxHistoryTable = ({ history, compact = false }: TxHistoryTableProps) => {
- const { t } = useTranslation()
- const [sorting, setSorting] = useState([{ id: 'timestamp', desc: true }])
- const [isShowAll, setIsShowAll] = useState(false)
- const [pagination, setPagination] = useState({
- pageIndex: 0,
- pageSize: compact ? 5 : ITEMS_PER_PAGE,
- })
-
- useEffect(() => {
- if (isShowAll) {
- setPagination((previous) => ({
- ...previous,
- pageSize: Math.max(1, history.length),
- pageIndex: 0,
- }))
- }
- }, [history.length, isShowAll])
-
- const columns = useMemo(() => txHistoryTableColumns(t), [t])
-
- const table = useReactTable({
- data: history,
- columns,
- state: {
- sorting,
- pagination,
- },
- autoResetPageIndex: true,
- getRowId: (row, index) => `${row.txid || 'notxid'}-${row.source_mixdepth ?? 0}-${row.timestamp}-${index}`,
- onSortingChange: setSorting,
- onPaginationChange: setPagination,
- getCoreRowModel: getCoreRowModel(),
- getSortedRowModel: getSortedRowModel(),
- getPaginationRowModel: getPaginationRowModel(),
- getRowCanExpand: () => true,
- getExpandedRowModel: getExpandedRowModel(),
- paginateExpandedRows: false,
- })
-
- if (history.length === 0) {
- return (
-
- {t('tx_history.empty_history')}
-
- )
- }
-
- return (
-
-
-
-
- {table.getHeaderGroups().map((headerGroup) => (
-
- {headerGroup.headers.map((header) => {
- const canSort = header.column.getCanSort()
- const alignCenter = header.column.columnDef.meta?.align === 'center'
- const alignRight = header.column.columnDef.meta?.align === 'right'
- return (
- header.column.toggleSorting() : undefined}
- >
- 0 && !header.column.getIsSorted(),
- })}
- >
- {flexRender(header.column.columnDef.header, header.getContext())}
- {canSort ? : undefined}
-
-
- )
- })}
-
- ))}
-
-
- {table.getRowModel().rows.map((row) => (
-
- ))}
-
-
-
-
- {!compact && (
-
table.setPageIndex(page - 1)}
- onItemsPerPageChange={(newItemsPerPage) => {
- if (newItemsPerPage === -1) {
- setIsShowAll(true)
- table.setPageSize(history.length || 1)
- } else {
- setIsShowAll(false)
- table.setPageSize(newItemsPerPage)
- }
- table.setPageIndex(0)
- }}
- />
- )}
-
- )
-}
diff --git a/src/constants/jam.ts b/src/constants/jam.ts
index 13d62497..11c91024 100644
--- a/src/constants/jam.ts
+++ b/src/constants/jam.ts
@@ -78,54 +78,6 @@ export const JAM_RESCAN_PROGRESS_INTERVAL: Milliseconds = Math.max(
JAM_RESCAN_PROGRESS_MIN_INTERVAL,
)
-export const WAIT_FOR_UPDATE_SESSION_POLLING_INTERVAL: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_WAIT_FOR_UPDATE_SESSION_POLLING_INTERVAL, 3_000),
- 1_000,
-)
-export const WAIT_FOR_UPDATE_SESSION_POLLING_DELAY: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_WAIT_FOR_UPDATE_SESSION_POLLING_DELAY, 1_000),
- 1,
-)
-
-export const WAIT_FOR_UPDATE_ORDERBOOK_POLLING_INTERVAL: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_WAIT_FOR_UPDATE_ORDERBOOK_POLLING_INTERVAL, 15_000),
- 1_000,
-)
-export const VISIBLE_ORDERBOOK_POLLING_INTERVAL: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_VISIBLE_ORDERBOOK_POLLING_INTERVAL, 120_000),
- 1_000,
-)
-
-export const RUNNING_COINJOIN_POLLING_INTERVAL: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_RUNNING_COINJOIN_POLLING_INTERVAL, 5_000),
- 1_000,
-)
-export const RUNNING_COINJOIN_POLLING_DELAY: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_RUNNING_COINJOIN_POLLING_DELAY, 1_000),
- 1,
-)
-
-export const RUNNING_SCHEDULE_POLLING_INTERVAL: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_RUNNING_SCHEDULE_POLLING_INTERVAL, 10_000),
- 1_000,
-)
-
-/**
- * In order to prevent state mismatch, the 'maker stop' response is delayed shortly.
- * Even though the API response suggests that the maker has started or stopped immediately, it seems that this is not always the case.
- * There is currently no way to know for sure - adding a delay at least mitigates the problem.
- * 2022-04-26: With value of 2_000ms, no state corruption could be provoked in a local dev setup.
- */
-export const MAKER_STOP_RESPONSE_DELAY: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_MAKER_STOP_RESPONSE_DELAY, 2_000),
- 1,
-)
-
-export const JMWALLETD_LOGS_POLLING_INTERVAL: Milliseconds = Math.max(
- parseAsIntOrDefault(import.meta.env.VITE_JAM_JMWALLETD_LOGS_POLLING_INTERVAL, 2_500),
- 500,
-)
-
const JAM_SEED_MODAL_MIN_TIMEOUT: Milliseconds = 5_000
const JAM_SEED_MODAL_DEFAULT_TIMEOUT: Milliseconds = 30_000
export const JAM_SEED_MODAL_TIMEOUT: Milliseconds = Math.max(
diff --git a/src/constants/routes.ts b/src/constants/routes.ts
index d307413d..150fb238 100644
--- a/src/constants/routes.ts
+++ b/src/constants/routes.ts
@@ -13,7 +13,6 @@ export const routes = {
orderbook: '/orderbook',
logs: '/logs',
walletJarsDetails: '/wallet/jars',
- txHistory: '/wallet/history',
/* walletList: '/', wallet: '/wallet' */
__dev: '/dev',
__devErrorExample: '/dev/error-example',
diff --git a/src/context/JamDisplayContextProvider.test.tsx b/src/context/JamDisplayContextProvider.test.tsx
index e2c2d2a4..acba726c 100644
--- a/src/context/JamDisplayContextProvider.test.tsx
+++ b/src/context/JamDisplayContextProvider.test.tsx
@@ -1,7 +1,6 @@
import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it } from 'vitest'
import { jamSettingsStore } from '@/store/jamSettingsStore'
-import { withRuntimeLocale } from '@/test/withRuntimeLocale'
import { useJamDisplayContext } from './JamDisplayContext'
import { JamDisplayContextProvider } from './JamDisplayContextProvider'
@@ -25,18 +24,16 @@ describe('JamDisplayContextProvider', () => {
})
it('should format amounts with the current display settings', () => {
- withRuntimeLocale('en-US', () => {
- render(
-
-
- ,
- )
+ render(
+
+
+ ,
+ )
- expect(screen.getByTestId('default-amount')).toHaveTextContent('123,456,789')
- expect(screen.getByTestId('btc-amount')).toHaveTextContent('1.23456789')
- expect(screen.getByTestId('hidden-amount')).toHaveTextContent('*****')
- expect(screen.getByTestId('sats-symbol')).toBeInTheDocument()
- })
+ expect(screen.getByTestId('default-amount')).toHaveTextContent('123,456,789')
+ expect(screen.getByTestId('btc-amount')).toHaveTextContent('1.23456789')
+ expect(screen.getByTestId('hidden-amount')).toHaveTextContent('*****')
+ expect(screen.getByTestId('sats-symbol')).toBeInTheDocument()
})
it('should hide default amounts when privacy mode is enabled', () => {
diff --git a/src/context/JamWalletInfoContext.ts b/src/context/JamWalletInfoContext.ts
index 70b225d2..70840d82 100644
--- a/src/context/JamWalletInfoContext.ts
+++ b/src/context/JamWalletInfoContext.ts
@@ -84,7 +84,6 @@ interface JamWalletInfoContextType {
walletName: string | null
walletBalanceSummary: WalletBalanceSummary
maxJarAvailableBalance: AmountSats
- hasEligibleFidelityBondUtxo: boolean
fidelityBondSummary: FidelityBondSummary
addressSummary: AddressSummary
accountSummary: AccountSummary
diff --git a/src/context/JamWalletInfoContextProvider.test.tsx b/src/context/JamWalletInfoContextProvider.test.tsx
index 984aed9f..27738364 100644
--- a/src/context/JamWalletInfoContextProvider.test.tsx
+++ b/src/context/JamWalletInfoContextProvider.test.tsx
@@ -1,5 +1,3 @@
-import { sha256 } from '@noble/hashes/sha2.js'
-import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js'
import { render, screen, waitFor } from '@testing-library/react'
import { Network } from 'bitcoin-address-validation'
import { beforeEach, describe, expect, it, vi } from 'vitest'
@@ -77,7 +75,7 @@ const utxo = (overrides: Partial): Utxo => ({
...overrides,
})
-const walletInfo = (status = 'new'): WalletInfoApiObject =>
+const walletInfo = (): WalletInfoApiObject =>
({
wallet_name: 'testing.jmdat',
total_balance: '0',
@@ -91,7 +89,7 @@ const walletInfo = (status = 'new'): WalletInfoApiObject =>
{
address,
hd_path: "m/84'/1'/0'/0/0",
- status,
+ status: 'new',
label: '',
balance: 0,
used_count: 0,
@@ -147,7 +145,6 @@ describe('', () => {
expect(context?.jars.map((jar) => jar.jarIndex)).toEqual([0, 1, 2, 3, 4, 7])
expect(context?.jars.find((jar) => jar.jarIndex === 7)?.name).toBe('Jar #7')
expect(context?.fidelityBondSummary.fbOutputs.map((entry) => entry.utxo)).toEqual([`${txid('c')}:2`])
- expect(context?.hasEligibleFidelityBondUtxo).toBe(false)
expect(context?.accountSummary[0].branches[0]).toMatchObject({
type: 'external addresses',
derivation: "m/84'/1'/0'/0",
@@ -163,19 +160,6 @@ describe('', () => {
expect(context?.error).toBeNull()
})
- it('reports when an eligible fidelity-bond UTXO is available', () => {
- let context: ReturnType | undefined
- mocks.walletInfo = walletInfo('cj-out')
-
- render(
-
- (context = value)} />
- ,
- )
-
- expect(context?.hasEligibleFidelityBondUtxo).toBe(true)
- })
-
it('handles malformed accounts, missing branches, and entries without a status', () => {
let context: ReturnType | undefined
mocks.walletInfo = {
@@ -285,92 +269,3 @@ describe('', () => {
expect(balanceSummary?.calculatedTotalBalanceInSats).toBe(25_000)
})
})
-
-/**
- * Reference implementation of the old O(n²) combinedUtxosHash logic.
- * Used only in tests to verify the optimized implementation is a drop-in replacement.
- */
-const combinedUtxosHashReference = (utxoList: Utxo[]): string => {
- const utxoIds = utxoList.map((it) => hexToBytes(it.utxo.split(':', 1)[0]))
- const combinedUtxoIds = new Uint8Array(utxoIds.reduce((acc, current) => [...acc, ...current], [] as number[]))
- return bytesToHex(sha256(combinedUtxoIds))
-}
-
-describe('combinedUtxosHash — optimized vs reference (regression)', () => {
- beforeEach(() => {
- vi.clearAllMocks()
- mocks.waitQueryError = null
- mocks.walletInfo = undefined
- mocks.utxosRefetch.mockResolvedValue({ data: { utxos: [] } })
- mocks.displayWalletRefetch.mockResolvedValue({ data: { walletinfo: undefined } })
- })
-
- /** Render the provider with the given UTXO list and capture the computed utxosHashHex. */
- const captureHash = (utxoList: Utxo[]): string => {
- mocks.utxos = utxoList
- let captured = ''
- render(
-
- (captured = context.utxosHashHex)} />
- ,
- )
- return captured
- }
-
- it('produces the same hash for an empty UTXO list', () => {
- const utxoList: Utxo[] = []
- const actual = captureHash(utxoList)
- expect(actual).toBe(combinedUtxosHashReference(utxoList))
- expect(actual).toBe('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')
- })
-
- it('produces the same hash for a single UTXO', () => {
- const utxoList = [utxo({ utxo: `${txid('a')}:0` })]
- const actual = captureHash(utxoList)
- expect(actual).toBe(combinedUtxosHashReference(utxoList))
- expect(actual).toBe('e0e77a507412b120f6ede61f62295b1a7b2ff19d3dcc8f7253e51663470c888e')
- })
-
- it('is okay for it to produce the same hash for different output in same txid', () => {
- const utxoList0 = [utxo({ utxo: `${txid('a')}:0` })]
- const actual0 = captureHash(utxoList0)
- expect(actual0).toBe(combinedUtxosHashReference(utxoList0))
- expect(actual0).toBe('e0e77a507412b120f6ede61f62295b1a7b2ff19d3dcc8f7253e51663470c888e')
-
- const utxoList1 = [utxo({ utxo: `${txid('a')}:1` })]
- const actual1 = captureHash(utxoList1)
- expect(actual1).toBe(combinedUtxosHashReference(utxoList1))
- expect(actual1).toBe('e0e77a507412b120f6ede61f62295b1a7b2ff19d3dcc8f7253e51663470c888e')
- expect(actual1).toBe(actual0)
- })
-
- it('produces the same hash for multiple UTXOs', () => {
- const utxoList = [
- utxo({ utxo: `${txid('a')}:0` }),
- utxo({ utxo: `${txid('b')}:1` }),
- utxo({ utxo: `${txid('c')}:2` }),
- ]
-
- const actual = captureHash(utxoList)
- expect(actual).toBe(combinedUtxosHashReference(utxoList))
- expect(actual).toBe('6bdaf8651d78f983ab7ce864414ace095b2942cbe5ff43deade48d51aa34b2cd')
- })
-
- it('produces the same hash for UTXOs whose txid bytes vary across the full byte range', () => {
- const utxoList = [
- utxo({ utxo: `${txid('1')}:0` }),
- utxo({ utxo: `${'ab'.repeat(32)}:3` }),
- utxo({ utxo: `${'ff'.repeat(32)}:7` }),
- ]
- expect(captureHash(utxoList)).toBe(combinedUtxosHashReference(utxoList))
- })
-
- it('produces the same hash for a large UTXO set (50 entries)', () => {
- const chars = '0123456789abcdef'
- const utxoList = Array.from({ length: 50 }, (_, i) => {
- const ch = chars[i % chars.length]
- return utxo({ utxo: `${ch.repeat(64)}:${i}`, mixdepth: i % 5 })
- })
- expect(captureHash(utxoList)).toBe(combinedUtxosHashReference(utxoList))
- })
-})
diff --git a/src/context/JamWalletInfoContextProvider.tsx b/src/context/JamWalletInfoContextProvider.tsx
index 7962f4f2..430bfa21 100644
--- a/src/context/JamWalletInfoContextProvider.tsx
+++ b/src/context/JamWalletInfoContextProvider.tsx
@@ -1,6 +1,6 @@
import { useMemo, useState, type Dispatch, type PropsWithChildren, type SetStateAction } from 'react'
import { sha256 } from '@noble/hashes/sha2.js'
-import { bytesToHex, concatBytes, hexToBytes } from '@noble/hashes/utils.js'
+import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js'
import { CancelledError, useMutation, useQuery } from '@tanstack/react-query'
import { getAddressInfo } from 'bitcoin-address-validation'
import { useQueryDisplayWallet, type WalletInfoApiObject } from '@/hooks/useQueryDisplayWallet'
@@ -131,7 +131,7 @@ interface JamWalletInfoContextProviderProps {
const combinedUtxosHash = (utxos: Utxo[]) => {
const utxoIds = utxos.map((it) => hexToBytes(it.utxo.split(':', 1)[0]))
- const combinedUtxoIds = concatBytes(...utxoIds)
+ const combinedUtxoIds = new Uint8Array(utxoIds.reduce((acc, current) => [...acc, ...current], [] as number[]))
return sha256(combinedUtxoIds)
}
@@ -198,9 +198,6 @@ export const JamWalletInfoContextProvider = ({
: toAccountSummary(displayWalletQuery.walletInfo)
const addressSummary =
displayWalletQuery.walletInfo === undefined ? EMPTY_ADDRESS_SUMMARY : toAddressSummary(accountSummary)
- const hasEligibleFidelityBondUtxo = utxos.some((utxo) =>
- fb.utxo.isEligibleForCreation(utxo, addressSummary[utxo.address]?.status),
- )
const detectedNetwork = useMemo(() => {
const eligibleAddress = Object.values(addressSummary).find((it) => it.info !== undefined)
@@ -251,7 +248,6 @@ export const JamWalletInfoContextProvider = ({
walletName: walletFileName ? walletDisplayName(walletFileName) : null,
walletBalanceSummary: walletBalanceSummary,
maxJarAvailableBalance,
- hasEligibleFidelityBondUtxo,
fidelityBondSummary,
addressSummary,
accountSummary,
diff --git a/src/hooks/useQueryOrderbook.test.ts b/src/hooks/useQueryOrderbook.test.ts
deleted file mode 100644
index 3314324b..00000000
--- a/src/hooks/useQueryOrderbook.test.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { renderHook } from '@testing-library/react'
-import { describe, expect, it, vi } from 'vitest'
-import { useQueryOrderbook } from './useQueryOrderbook'
-
-const queryMock = vi.fn<(options: unknown) => unknown>()
-
-vi.mock('@/lib/queryClient', () => ({
- withQueryDelay: (queryFn: unknown) => queryFn,
-}))
-
-vi.mock('@tanstack/react-query', () => ({
- useQuery: (options: unknown): unknown => queryMock(options),
-}))
-
-vi.mock('@/lib/api/orderbook', () => ({
- fetchOrderbook: vi.fn(),
-}))
-
-describe('useQueryOrderbook', () => {
- it('returns hasOrders: true when orderbook offers exist', () => {
- const mockOrderbook = {
- offers: [{ counterparty: 'maker1' }],
- }
- queryMock.mockReturnValue({ data: mockOrderbook, isLoading: false, isError: false })
-
- const { result } = renderHook(() => useQueryOrderbook())
-
- expect(result.current.hasOrders).toBe(true)
- expect(result.current.queryResult.data).toEqual(mockOrderbook)
- })
-
- it('returns hasOrders: false when orderbook offers array is empty', () => {
- queryMock.mockReturnValue({ data: { offers: [] }, isLoading: false, isError: false })
-
- const { result } = renderHook(() => useQueryOrderbook())
-
- expect(result.current.hasOrders).toBe(false)
- })
-
- it('returns hasOrders: false when data is undefined', () => {
- queryMock.mockReturnValue({ data: undefined, isLoading: false, isError: false })
-
- const { result } = renderHook(() => useQueryOrderbook())
-
- expect(result.current.hasOrders).toBe(false)
- })
-})
diff --git a/src/hooks/useQueryOrderbook.ts b/src/hooks/useQueryOrderbook.ts
deleted file mode 100644
index 1249d4f6..00000000
--- a/src/hooks/useQueryOrderbook.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { useQuery, type UseQueryResult } from '@tanstack/react-query'
-import { fetchOrderbook, type OrderbookResponse } from '@/lib/api/orderbook'
-import { withQueryDelay } from '@/lib/queryClient'
-
-export type UseQueryOrderbookResult = {
- hasOrders: boolean
- queryResult: UseQueryResult
-}
-
-export function useQueryOrderbook(
- options: Omit>[0], 'queryFn' | 'queryKey'> = {},
-): UseQueryOrderbookResult {
- const queryResult = useQuery({
- queryKey: ['orderbook-precheck'],
- queryFn: withQueryDelay(fetchOrderbook, {
- // avoid flickering and let user briefly know that something is happening in the background
- delayBefore: 1_000,
- }),
- retry: false,
- staleTime: 30 * 1_000,
- ...options,
- })
-
- return {
- hasOrders: (queryResult.data?.offers.length ?? 0) > 0,
- queryResult,
- }
-}
diff --git a/src/hooks/useQueryWalletHistory.test.ts b/src/hooks/useQueryWalletHistory.test.ts
deleted file mode 100644
index 440e5fa8..00000000
--- a/src/hooks/useQueryWalletHistory.test.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { renderHook } from '@testing-library/react'
-import { describe, expect, it, vi } from 'vitest'
-import type { WalletFileName } from '@/lib/utils'
-import { useQueryWalletHistory } from './useQueryWalletHistory'
-
-const queryMock = vi.fn<(options: unknown) => unknown>()
-
-vi.mock('@tanstack/react-query', () => ({
- useQuery: (options: unknown) => queryMock(options),
-}))
-
-vi.mock('zustand', () => ({
- useStore: () => ({ session: 'mock-session' }),
-}))
-
-vi.mock('@/hooks/useApiClient', () => ({
- useApiClient: () => ({}),
-}))
-
-vi.mock('@/constants/debugFeatures', () => ({
- isDevMode: () => false,
-}))
-
-vi.mock('@/lib/queryClient', () => ({
- withQueryDelay: (function_: unknown) => function_,
-}))
-
-vi.mock('@/store/jmSessionStore', () => ({
- jmSessionStore: {},
-}))
-
-vi.mock('@joinmarket-webui/joinmarket-ng-api-ts/@tanstack/react-query', () => ({
- wallethistoryOptions: () => ({ queryKey: ['history'], queryFn: vi.fn() }),
-}))
-
-describe('useQueryWalletHistory', () => {
- it('returns history and queryResult when data exists', () => {
- const mockHistory = [{ txid: 'tx1', timestamp: '2026-07-28' }]
- queryMock.mockReturnValue({ data: { history: mockHistory } })
-
- const { result } = renderHook(() => useQueryWalletHistory({ walletFileName: 'wallet.jmdat' }))
-
- expect(result.current.history).toEqual(mockHistory)
- expect(result.current.queryResult.data?.history).toEqual(mockHistory)
- })
-
- it('returns empty array when data does not exist', () => {
- queryMock.mockReturnValue({ data: null })
-
- const { result } = renderHook(() => useQueryWalletHistory({ walletFileName: 'wallet.jmdat' }))
-
- expect(result.current.history).toEqual([])
- })
-
- it('is not enabled if walletFileName is empty', () => {
- queryMock.mockImplementation((options) => options)
-
- const { result } = renderHook(() =>
- useQueryWalletHistory({ walletFileName: undefined as unknown as WalletFileName }),
- )
-
- expect((result.current.queryResult as { enabled?: boolean }).enabled).toBe(false)
- })
-
- it('is not enabled if explicitly disabled', () => {
- queryMock.mockImplementation((options) => options)
-
- const { result } = renderHook(() => useQueryWalletHistory({ walletFileName: 'wallet.jmdat', enabled: false }))
-
- expect((result.current.queryResult as { enabled?: boolean }).enabled).toBe(false)
- })
-})
diff --git a/src/hooks/useQueryWalletHistory.ts b/src/hooks/useQueryWalletHistory.ts
deleted file mode 100644
index 978030cb..00000000
--- a/src/hooks/useQueryWalletHistory.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import { useEffect } from 'react'
-import { wallethistoryOptions } from '@joinmarket-webui/joinmarket-ng-api-ts/@tanstack/react-query'
-import type { HistoryEntry, WalletHistoryResponse } from '@joinmarket-webui/joinmarket-ng-api-ts/jm'
-import { useQuery, type UseQueryResult } from '@tanstack/react-query'
-import { useStore } from 'zustand'
-import { isDevMode } from '@/constants/debugFeatures'
-import { useApiClient } from '@/hooks/useApiClient'
-import { withQueryDelay } from '@/lib/queryClient'
-import type { WalletFileName } from '@/lib/utils'
-import { jmSessionStore } from '@/store/jmSessionStore'
-
-export type { HistoryEntry } from '@joinmarket-webui/joinmarket-ng-api-ts/jm'
-
-export type UseQueryWalletHistoryResult = {
- history: HistoryEntry[]
- queryResult: UseQueryResult
-}
-
-interface UseQueryWalletHistoryProps {
- walletFileName: WalletFileName
- limit?: number
- enabled?: boolean
- utxosHashHex?: string
-}
-
-const EMPTY_HISTORY: HistoryEntry[] = []
-
-export function useQueryWalletHistory({
- walletFileName,
- limit,
- enabled = true,
- utxosHashHex = '',
-}: UseQueryWalletHistoryProps): UseQueryWalletHistoryResult {
- const client = useApiClient()
- const jmSession = useStore(jmSessionStore, (state) => state.state?.session)
-
- const queryOptions = wallethistoryOptions({
- client,
- path: { walletname: walletFileName || '' },
- query: { limit },
- meta: {
- cacheBuster: utxosHashHex,
- },
- })
-
- const queryResult = useQuery({
- ...queryOptions,
- queryFn: withQueryDelay(queryOptions.queryFn, {
- // simulate slow mainnet responses in dev mode
- throttle: isDevMode() ? 210 : 0,
- }),
- enabled: enabled && !!walletFileName && !!jmSession,
- })
-
- const { refetch } = queryResult
-
- useEffect(() => {
- if (utxosHashHex && enabled) {
- void refetch()
- }
- }, [utxosHashHex, enabled, refetch])
-
- return {
- history: queryResult.data?.history ?? EMPTY_HISTORY,
- queryResult,
- }
-}
diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json
index b5bb57a2..40b2d072 100644
--- a/src/i18n/locales/en/translation.json
+++ b/src/i18n/locales/en/translation.json
@@ -80,9 +80,6 @@
"item_jars": {
"label": "Jars"
},
- "item_history": {
- "label": "History"
- },
"item_tour": {
"label": "Tour"
},
@@ -293,8 +290,6 @@
"use_address_chunking_enabled": "Address display chunking enabled",
"use_address_chunking_disabled": "Address display chunking disabled",
"label_select_language": "Language",
- "label_select_language_title": "Select language",
- "label_select_language_aria_label": "$t(settings.label_select_language_title)",
"show_seed": "Show seed phrase",
"show_xpubs": "Show account xpubs",
"reveal_seed": "Reveal seed phrase",
@@ -574,14 +569,7 @@
"text_txfee": "Transaction Fee",
"text_offer_id": "Offer ID",
"text_offer_type_absolute": "absolute",
- "text_offer_type_relative": "relative",
- "text_orderbook_checking": "Checking local orderbook...",
- "text_orderbook_visible": "Visible in local orderbook",
- "text_orderbook_missing": "Not found in local orderbook yet",
- "text_orderbook_error": "Could not check local orderbook",
- "text_fidelity_bond": "Fidelity Bond",
- "text_bond_value": "Bond value",
- "text_bond_locktime": "locked until {{date}}"
+ "text_offer_type_relative": "relative"
},
"report": {
"title": "Earnings Report",
@@ -597,6 +585,7 @@
"heading_earned": "Earned",
"heading_notes": "Notes",
"text_button_generate_demo_report": "Generate demo entry",
+ "text_button_download_csv": "Download",
"stats": {
"earned_total": "Earned (total)",
"earned_90days": "Earned (90 days)",
@@ -686,8 +675,6 @@
"create_form": {
"confirmation_toggle_title": "I have reviewed my inputs carefully",
"confirmation_toggle_subtitle": "I understand that the locked funds will be inaccessible for the given duration",
- "alert_no_eligible_utxos_title": "No eligible UTXOs",
- "alert_no_eligible_utxos_description": "A Fidelity Bond must be funded by an unfrozen collaborative transaction output (cj-out). <1>Complete a collaborative transaction1> or <3>unfreeze an eligible UTXO3> to continue.",
"button_create": "Create Fidelity Bond"
},
"existing": {
@@ -764,10 +751,6 @@
"text_orderbook_summary_filtered_one": "found {{ count }} offer by {{ counterpartyCount }} counterparty",
"text_orderbook_summary_filtered_other": "found {{ count }} offers by {{ counterpartyCount }} counterparties",
"alert_empty_orderbook": "Orderbook is empty",
- "alert_precheck_empty_title": "No active makers found",
- "alert_precheck_empty_description": "Your local Orderbook appears to be empty right now. Collaborative transactions might fail. Please check <1>your local Orderbook1>.",
- "alert_precheck_empty_text_button_check": "Check again",
- "alert_precheck_empty_text_button_checking": "Checking...",
"error_loading_orderbook_failed": "Error while loading the orderbook. Your current local setup might not support fetching the orderbook. Reason: {{ reason }}",
"text_offer_type_absolute": "absolute",
"text_offer_type_relative": "relative",
@@ -916,30 +899,5 @@
"subtitle_one": "The selected UTXO is eligible for inclusion in the transaction.",
"subtitle_other": "The selected UTXOs are eligible for inclusion in the transaction.",
"text_subtitle_addon": "Unselected UTXOs will be frozen and can be unfrozen later anytime."
- },
- "tx_history": {
- "title": "Transaction History (Experimental)",
- "section_title": "Recent Activity",
- "overlay_title": "Transaction History (Experimental)",
- "button_view_all": "View All",
- "button_load_more": "Load More",
- "button_generate_demo_entry": "Add Demo Entry",
- "button_reload_title": "Reload",
- "expand_history": "Show transaction history",
- "collapse_history": "Hide transaction history",
- "empty_history": "No transactions found.",
- "error_loading": "Failed to load transaction history.",
- "copy_txid_success": "Transaction ID copied.",
- "copy_txid_error": "Failed to copy transaction ID.",
- "column_title_date": "Date",
- "column_title_role": "Type",
- "column_title_amount": "Amount",
- "column_title_net_fee": "Net Fee",
- "column_title_confirmations": "Confs.",
- "column_title_txid": "Transaction",
- "label_role_maker": "Maker",
- "label_role_taker": "Taker",
- "label_role_send": "Send",
- "label_role_deposit": "Deposit"
}
}
diff --git a/src/lib/api/orderbook.ts b/src/lib/api/orderbook.ts
index 388f6108..5fe18b8d 100644
--- a/src/lib/api/orderbook.ts
+++ b/src/lib/api/orderbook.ts
@@ -5,18 +5,11 @@ export interface OrderbookOffer {
counterparty: string
oid: number
ordertype: OfferType
- minsize?: AmountSats | null
- maxsize?: AmountSats | null
- txfee?: number | null
- cjfee?: number | null
- fidelity_bond_value?: number | null
- fidelity_bond_verification_stale?: boolean | null
- directory_nodes?: string[] | null
- directly_reachable?: boolean | null
- // TODO: many more fields, e.g.:
- // fidelity_bond_value
- // fidelity_bond_verified
- // features { neutrino_compat: true, nick_auth: true, peerlist_features: true, … }
+ minsize: AmountSats | null | undefined
+ maxsize: AmountSats | null | undefined
+ txfee: number | null | undefined
+ cjfee: number | null | undefined
+ fidelity_bond_value: number | null | undefined
}
export interface OrderbookFidelityBond {
diff --git a/src/lib/fidelityBondUtils.test.ts b/src/lib/fidelityBondUtils.test.ts
index d90452be..47bde1df 100644
--- a/src/lib/fidelityBondUtils.test.ts
+++ b/src/lib/fidelityBondUtils.test.ts
@@ -180,19 +180,6 @@ describe('utils', () => {
expect(fb.utxo.allAreFrozen(utxos)).toBe(false)
})
- it('should identify UTXOs eligible for fidelity-bond creation', () => {
- expect(fb.utxo.isEligibleForCreation(makeUtxo('foo:0'), 'cj-out')).toBe(true)
- expect(fb.utxo.isEligibleForCreation(makeUtxo('foo:0', '', true), 'cj-out')).toBe(false)
- expect(fb.utxo.isEligibleForCreation(makeUtxo('foo:0'), 'deposit')).toBe(false)
- expect(fb.utxo.isEligibleForCreation(makeUtxo('foo:0'))).toBe(false)
-
- const fidelityBond = {
- ...makeUtxo('foo:0'),
- locktime: '2999-01-01 00:00:00',
- } as Utxo
- expect(fb.utxo.isEligibleForCreation(fidelityBond, 'cj-out')).toBe(false)
- })
-
describe('isLocked', () => {
const now = Date.UTC(2009, 0, 3)
diff --git a/src/lib/fidelityBondUtils.ts b/src/lib/fidelityBondUtils.ts
index 12452b19..ad38fd6e 100644
--- a/src/lib/fidelityBondUtils.ts
+++ b/src/lib/fidelityBondUtils.ts
@@ -98,10 +98,6 @@ export const utxo = (() => {
const isFidelityBond = (utxo: Utxo): utxo is FidelityBondUtxo => !!utxo.locktime
- // TODO: allow selecting frozen UTXOs and unfreeze them before sending the transaction
- const isEligibleForCreation = (utxo: Utxo, addressStatus?: string) =>
- !utxo.frozen && !isFidelityBond(utxo) && addressStatus === 'cj-out'
-
const getLocktime = (utxo: Utxo): Milliseconds | null => {
if (!isFidelityBond(utxo)) return null
@@ -119,14 +115,5 @@ export const utxo = (() => {
return locktime !== null && locktime >= refTime
}
- return {
- isEqual,
- isInList,
- utxosToFreeze,
- allAreFrozen,
- isFidelityBond,
- isEligibleForCreation,
- isLocked,
- getLocktime,
- }
+ return { isEqual, isInList, utxosToFreeze, allAreFrozen, isFidelityBond, isLocked, getLocktime }
})()
diff --git a/src/lib/formValidation.test.ts b/src/lib/formValidation.test.ts
index 1c87f48f..6957b190 100644
--- a/src/lib/formValidation.test.ts
+++ b/src/lib/formValidation.test.ts
@@ -1,4 +1,4 @@
-import { getAddressInfo, Network } from 'bitcoin-address-validation'
+import { Network } from 'bitcoin-address-validation'
import { describe, expect, it } from 'vitest'
import type { AddressSummary } from '@/context/JamWalletInfoContext'
import {
@@ -7,41 +7,23 @@ import {
isReusedAddress,
isValidAddress,
sourceJarField,
- blockHeightField,
- INPUT_BLOCK_HEIGHT_MIN,
} from './formValidation'
const mainnetAddress = '1BitcoinEaterAddressDontSend8MUo1T'
const testnetAddress = 'mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn'
const regtestBech32Address = 'bcrt1q6rz28mcfaxtmd6v789l9rrlrusdprr9pz3cppk'
-const testnetBech32Address = 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx'
-// bech32m/taproot pair - same witness program, differing only by HRP (tb1p vs bcrt1p)
-const testnetTaprootAddress = 'tb1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vq47zagq'
-const regtestTaprootAddress = 'bcrt1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqc8gma6'
-const regtestLegacyAddressLabelledTestnet = 'mkpZhYtJu2r87Js3pDiWJDmPte2NRZ8bJV'
+const regtestLegacyAddressLabeledTestnet = 'mkpZhYtJu2r87Js3pDiWJDmPte2NRZ8bJV'
const addressSummary = {
[mainnetAddress]: { address: mainnetAddress, used: false },
} as unknown as AddressSummary
describe('isValidAddress', () => {
- it.each([
- mainnetAddress,
- testnetAddress,
- regtestBech32Address,
- testnetBech32Address,
- testnetTaprootAddress,
- regtestTaprootAddress,
- regtestLegacyAddressLabelledTestnet,
- ])('accepts valid addresses', (address) => {
- expect(isValidAddress(address)).toBe(true)
- })
-
- it('reject invalid addresses', () => {
+ it('accepts a valid address and rejects everything else', () => {
+ expect(isValidAddress(mainnetAddress)).toBe(true)
expect(isValidAddress('not-an-address')).toBe(false)
expect(isValidAddress('')).toBe(false)
expect(isValidAddress(undefined)).toBe(false)
- expect(isValidAddress(null)).toBe(false)
expect(isValidAddress(42)).toBe(false)
})
})
@@ -50,7 +32,6 @@ describe('isAddressOnNetwork', () => {
it('matches the address network', () => {
expect(isAddressOnNetwork(mainnetAddress, Network.mainnet)).toBe(true)
expect(isAddressOnNetwork(mainnetAddress, Network.testnet)).toBe(false)
- expect(isAddressOnNetwork(testnetAddress, Network.mainnet)).toBe(false)
expect(isAddressOnNetwork(testnetAddress, Network.testnet)).toBe(true)
})
@@ -58,33 +39,17 @@ describe('isAddressOnNetwork', () => {
expect(isAddressOnNetwork('not-an-address', Network.mainnet)).toBe(false)
})
- it('distinguishes testnet and regtest for bech32 and bech32m addresses via their distinct HRP', () => {
- // bech32/bech32m addresses carry a network-specific prefix (tb1 vs bcrt1), so each is only
- // valid on its own network - a regtest address must not pass on a testnet wallet, nor vice versa.
- // bech32 (segwit v0):
+ it('treats testnet and regtest as interchangeable for base58 addresses ambiguous between the two', () => {
+ // bech32 regtest addresses are unambiguous and match regtest directly...
expect(isAddressOnNetwork(regtestBech32Address, Network.regtest)).toBe(true)
- expect(isAddressOnNetwork(regtestBech32Address, Network.testnet)).toBe(false)
- expect(isAddressOnNetwork(testnetBech32Address, Network.testnet)).toBe(true)
- expect(isAddressOnNetwork(testnetBech32Address, Network.regtest)).toBe(false)
- // bech32m (taproot):
- expect(isAddressOnNetwork(regtestTaprootAddress, Network.regtest)).toBe(true)
- expect(isAddressOnNetwork(regtestTaprootAddress, Network.testnet)).toBe(false)
- expect(isAddressOnNetwork(testnetTaprootAddress, Network.testnet)).toBe(true)
- expect(isAddressOnNetwork(testnetTaprootAddress, Network.regtest)).toBe(false)
- // ...and none pass on mainnet.
+ expect(isAddressOnNetwork(regtestBech32Address, Network.testnet)).toBe(true) // TODO: can be detected and differentiated for `p2wpkh`
+ // ...but a legacy address on a regtest wallet is labeled "testnet" by the library, so it
+ // must still be accepted when the wallet's detected network is regtest.
+ expect(isAddressOnNetwork(regtestLegacyAddressLabeledTestnet, Network.regtest)).toBe(true)
+ expect(isAddressOnNetwork(regtestLegacyAddressLabeledTestnet, Network.testnet)).toBe(true)
+ // mainnet is never ambiguous with testnet/regtest.
+ expect(isAddressOnNetwork(mainnetAddress, Network.regtest)).toBe(false)
expect(isAddressOnNetwork(regtestBech32Address, Network.mainnet)).toBe(false)
- expect(isAddressOnNetwork(testnetBech32Address, Network.mainnet)).toBe(false)
- expect(isAddressOnNetwork(regtestTaprootAddress, Network.mainnet)).toBe(false)
- expect(isAddressOnNetwork(testnetTaprootAddress, Network.mainnet)).toBe(false)
- })
-
- it('treats testnet and regtest as interchangeable for ambiguous base58 addresses', () => {
- expect(getAddressInfo(regtestLegacyAddressLabelledTestnet).network, 'sanity check').toBe(Network.testnet)
-
- // A base58 (P2PKH here; P2SH shares the trait) address on a regtest wallet is labeled "testnet"
- // by the library because the two share version bytes, so it must still be accepted on regtest.
- expect(isAddressOnNetwork(regtestLegacyAddressLabelledTestnet, Network.regtest)).toBe(true)
- expect(isAddressOnNetwork(regtestLegacyAddressLabelledTestnet, Network.testnet)).toBe(true)
})
})
@@ -166,53 +131,3 @@ describe('destinationAddressField', () => {
expect(() => reusedSchema.validateSync(mainnetAddress)).toThrow('reused')
})
})
-
-describe('blockHeightField', () => {
- // eslint-disable-next-line unicorn/consistent-function-scoping -- okay in tests
- const invalidMessage = ({ min, max }: { min: number; max: number }) => `Invalid blockheight ${min}-${max}`
-
- it('handles currentBlockHeight = 0', () => {
- const schema = blockHeightField({ currentBlockHeight: 0, messages: { invalid: invalidMessage } })
- // min should be 0, max should be 0
- expect(schema.isValidSync(-1)).toBe(false)
- expect(schema.isValidSync(0)).toBe(true)
- expect(schema.isValidSync(1)).toBe(false)
- })
-
- it('handles currentBlockHeight = undefined', () => {
- const schema = blockHeightField({ currentBlockHeight: undefined, messages: { invalid: invalidMessage } })
- // min should be 0, max should be Number.MAX_SAFE_INTEGER
- expect(schema.isValidSync(-1)).toBe(false)
- expect(schema.isValidSync(0)).toBe(true)
- expect(schema.isValidSync(100)).toBe(true)
- expect(schema.isValidSync(Number.MAX_SAFE_INTEGER + 1)).toBe(false)
- })
-
- it('handles currentBlockHeight = null', () => {
- // @ts-expect-error Intentionally pass null to test JS boundary cases
- const schema = blockHeightField({ currentBlockHeight: null, messages: { invalid: invalidMessage } })
- expect(schema.isValidSync(-1)).toBe(false)
- expect(schema.isValidSync(0)).toBe(true)
- expect(schema.isValidSync(100)).toBe(true)
- })
-
- it('handles currentBlockHeight > minBlockHeight', () => {
- const schema = blockHeightField({ currentBlockHeight: 100, messages: { invalid: invalidMessage } })
- // min should be 0, max should be 100
- expect(schema.isValidSync(-1)).toBe(false)
- expect(schema.isValidSync(0)).toBe(true)
- expect(schema.isValidSync(50)).toBe(true)
- expect(schema.isValidSync(100)).toBe(true)
- expect(schema.isValidSync(101)).toBe(false)
- })
-
- it('handles currentBlockHeight == minBlockHeight (0)', () => {
- const schema = blockHeightField({
- currentBlockHeight: INPUT_BLOCK_HEIGHT_MIN,
- messages: { invalid: invalidMessage },
- })
- expect(schema.isValidSync(INPUT_BLOCK_HEIGHT_MIN - 1)).toBe(false)
- expect(schema.isValidSync(INPUT_BLOCK_HEIGHT_MIN)).toBe(true)
- expect(schema.isValidSync(INPUT_BLOCK_HEIGHT_MIN + 1)).toBe(false)
- })
-})
diff --git a/src/lib/formValidation.ts b/src/lib/formValidation.ts
index fee03563..591e68f1 100644
--- a/src/lib/formValidation.ts
+++ b/src/lib/formValidation.ts
@@ -1,10 +1,4 @@
-import {
- getAddressInfo,
- Network,
- validate as isValidBitcoinAddress,
- AddressType,
- type AddressInfo,
-} from 'bitcoin-address-validation'
+import { getAddressInfo, Network, validate as isValidBitcoinAddress } from 'bitcoin-address-validation'
import * as yup from 'yup'
import type { AddressSummary } from '@/context/JamWalletInfoContext'
import type { BitcoinAddress, BlockHeight, JarIndex } from '@/types/global'
@@ -17,32 +11,17 @@ import { isValidInteger } from './utils'
export const isValidAddress = (value: unknown): value is BitcoinAddress =>
typeof value === 'string' && isValidBitcoinAddress(value)
-// p2pkh/p2sh addresses (base58) share the same version bytes on testnet and regtest, so
-// address validation can't tell them apart and always labels them "testnet".
-// Treat the two as interchangeable for those so a regtest wallet doesn't reject its own
-// legacy-style addresses as "wrong network".
-// Types like p2wpkh/p2tr (bech32) carry a distinct HRP per network (tb1 vs bcrt1), so they are
-// already identified correctly - don't relax them, or a bcrt1… (regtest) address would
-// wrongly pass on a testnet wallet and vice versa. Only base58 addresses are ambiguous.
-const AMBIGUOUS_NETWORKS_BY_ADDRESS_TYPE: ReadonlyMap = new Map([
- [AddressType.p2pkh, [Network.testnet, Network.regtest]],
- [AddressType.p2sh, [Network.testnet, Network.regtest]],
-])
+// Legacy (base58) addresses share the same version bytes on testnet and regtest, so
+// bitcoin-address-validation can't tell them apart and always labels them "testnet" -
+// only bech32 addresses carry a distinct "bcrt1" prefix. Treat the two as interchangeable
+// so a regtest wallet doesn't reject its own legacy-style addresses as "wrong network".
+const AMBIGUOUS_TESTNET_REGTEST_NETWORKS: ReadonlySet = new Set([Network.testnet, Network.regtest])
-const isAmbiguousAddressForNetwork = (info: AddressInfo, expectedNetwork: Network) => {
- // Bech32/bech32m addresses carry a distinct HRP per network (tb1 vs bcrt1), so they are
- // already identified correctly - don't relax them, or a bcrt1… (regtest) address would
- // wrongly pass on a testnet wallet and vice versa. Only base58 addresses are ambiguous.
- return [info.network, expectedNetwork].every(
- (it) => AMBIGUOUS_NETWORKS_BY_ADDRESS_TYPE.get(info.type)?.includes(it) ?? false,
- )
-}
-
-export const isAddressOnNetwork = (value: string, expectedNetwork: Network): boolean => {
+export const isAddressOnNetwork = (value: string, network: Network): boolean => {
try {
- const addressInfo = getAddressInfo(value)
- if (addressInfo.network === expectedNetwork) return true
- return isAmbiguousAddressForNetwork(addressInfo, expectedNetwork)
+ const addressNetwork = getAddressInfo(value).network
+ if (addressNetwork === network) return true
+ return AMBIGUOUS_TESTNET_REGTEST_NETWORKS.has(addressNetwork) && AMBIGUOUS_TESTNET_REGTEST_NETWORKS.has(network)
} catch (_ignoredOnPurpose) {
return false
}
@@ -121,7 +100,7 @@ export const blockHeightField = ({
}
}) => {
const minBlockHeight = Math.min(INPUT_BLOCK_HEIGHT_MIN, currentBlockHeight || INPUT_BLOCK_HEIGHT_MIN)
- const maxBlockheight = Math.max(minBlockHeight, currentBlockHeight ?? INPUT_BLOCK_HEIGHT_MAX)
+ const maxBlockheight = Math.max(minBlockHeight, currentBlockHeight || INPUT_BLOCK_HEIGHT_MAX)
const invalidBlockheightMessage = invalid({ min: minBlockHeight, max: maxBlockheight })
return yup
diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts
index f63bcad5..63e14d6a 100644
--- a/src/lib/utils.test.ts
+++ b/src/lib/utils.test.ts
@@ -1,6 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { JM_WALLET_FILE_EXTENSION } from '@/constants/jm'
-import { withRuntimeLocale } from '@/test/withRuntimeLocale'
import {
cn,
debounce,
@@ -38,6 +37,24 @@ import {
} from './utils'
import type { WalletFileName } from './utils'
+const withRuntimeLocale = (locale: string, callback: () => void) => {
+ /* eslint-disable unicorn/no-this-outside-of-class -- mocking Number.prototype.toLocaleString requires `this` */
+ const numberToLocaleStringMock = vi.spyOn(Number.prototype, 'toLocaleString').mockImplementation(function (
+ this: number,
+ locales,
+ options,
+ ) {
+ return Intl.NumberFormat(locales ?? locale, options).format(this)
+ })
+ /* eslint-enable unicorn/no-this-outside-of-class */
+
+ try {
+ callback()
+ } finally {
+ numberToLocaleStringMock.mockRestore()
+ }
+}
+
describe('cn', () => {
it('should merge class names correctly', () => {
expect(cn('text-red-500', 'bg-blue-500')).toBe('text-red-500 bg-blue-500')
@@ -485,10 +502,8 @@ describe('formatBtc', () => {
})
it('should handle large BTC values', () => {
- withRuntimeLocale('en-US', () => {
- expect(formatBtc(21000000)).toBe('21,000,000.00000000')
- expect(formatBtc(100.99999999)).toBe('100.99999999')
- })
+ expect(formatBtc(21000000)).toBe('21,000,000.00000000')
+ expect(formatBtc(100.99999999)).toBe('100.99999999')
})
it('should handle very small BTC values', () => {
@@ -540,11 +555,9 @@ describe('getBtcParts', () => {
describe('formatSats', () => {
it('should format satoshi values with locale-specific thousands separators', () => {
- withRuntimeLocale('en-US', () => {
- expect(formatSats(1000)).toBe('1,000')
- expect(formatSats(1000000)).toBe('1,000,000')
- expect(formatSats(100000000)).toBe('100,000,000') // 1 BTC in sats
- })
+ expect(formatSats(1000)).toBe('1,000')
+ expect(formatSats(1000000)).toBe('1,000,000')
+ expect(formatSats(100000000)).toBe('100,000,000') // 1 BTC in sats
})
it('should handle small satoshi values', () => {
@@ -555,17 +568,13 @@ describe('formatSats', () => {
})
it('should handle large satoshi values', () => {
- withRuntimeLocale('en-US', () => {
- expect(formatSats(2100000000000000)).toBe('2,100,000,000,000,000') // 21M BTC in sats
- expect(formatSats(12345678901)).toBe('12,345,678,901')
- })
+ expect(formatSats(2100000000000000)).toBe('2,100,000,000,000,000') // 21M BTC in sats
+ expect(formatSats(12345678901)).toBe('12,345,678,901')
})
it('should handle negative satoshi values', () => {
- withRuntimeLocale('en-US', () => {
- expect(formatSats(-1000)).toBe('-1,000')
- expect(formatSats(-1234567)).toBe('-1,234,567')
- })
+ expect(formatSats(-1000)).toBe('-1,000')
+ expect(formatSats(-1234567)).toBe('-1,234,567')
})
it('should follow runtime locale when no explicit locale is provided', () => {
diff --git a/src/main.tsx b/src/main.tsx
index b69cfcd0..e1161d82 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -2,28 +2,8 @@ import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from '@/App.tsx'
import '@/i18n/config'
-import { JAM_REPO_URL } from './constants/jam'
import './index.css'
-console.debug(
- `%c/${'*'.repeat(42)}
-* Thanks for testing! Please report anything that looks off.
-* Found a bug? Open an issue at ${JAM_REPO_URL}/issues/new?labels=bug&template=bug_report.md
-*
-* This message should be dropped from preview/prod builds.
-* Use the above link and open a bug report if you see this message outside development builds.
-${'*'.repeat(42)}/`,
- 'color:#e2b86a;font-size:14px;',
-)
-
-setTimeout(() => {
- console.log('%cWarning!', 'color:oklch(0.577 0.245 27.325);font-size:48px;font-weight:bold;')
- console.log(
- "%cYou opened the browser console, a developer tool. Don't enter or paste code you do not understand. Never share your seed phrase or any other info with anyone. If someone told you to do this, it is very likely a scam.",
- 'color:oklch(0.777 0.245 27.325);font-size:16px;',
- )
-}, 2_100)
-
createRoot(document.querySelector('#root')!).render(
diff --git a/src/store/jamSettingsStore.ts b/src/store/jamSettingsStore.ts
index 3363386d..1ba6fd65 100644
--- a/src/store/jamSettingsStore.ts
+++ b/src/store/jamSettingsStore.ts
@@ -3,15 +3,8 @@ import { persist, createJSONStorage } from 'zustand/middleware'
import { isDevMode } from '@/constants/debugFeatures'
import type { Currency } from '@/types/global'
-type PreviewFeatures = {
- 'tx-history'?: boolean
- // add more entries on demand
- // 'myCoolNewFeature'?: boolean
-}
-
export type JamSettings = {
developerMode: boolean
- previewFeatures: PreviewFeatures | undefined
privateMode: boolean
addressChunking: boolean
currencyUnit: Currency
@@ -26,7 +19,6 @@ interface JamSettingsStoreState {
const initial: JamSettings = {
developerMode: isDevMode(),
- previewFeatures: isDevMode() ? {} : undefined,
privateMode: false,
addressChunking: true,
currencyUnit: 'sats',
@@ -51,7 +43,3 @@ export const useDeveloperMode = () => {
const isDeveloperMode = useStore(jamSettingsStore, (state) => state.state.developerMode)
return { enabled: isDeveloperMode }
}
-
-export const usePreviewFeatures = () => {
- return useStore(jamSettingsStore, (state) => state.state.previewFeatures)
-}
diff --git a/src/stories/jam/ActiveCollaborativeSendAlert.stories.tsx b/src/stories/jam/ActiveCollaborativeSendAlert.stories.tsx
deleted file mode 100644
index 4299292f..00000000
--- a/src/stories/jam/ActiveCollaborativeSendAlert.stories.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/react-vite'
-import { ActiveCollaborativeSendAlert } from '@/components/send/ActiveCollaborativeSendAlert'
-import type { PaymentAttempt } from '@/context/JamSessionInfoContext'
-import type { Jar } from '@/context/JamWalletInfoContext'
-import { TX_FEE_UNITS } from '@/lib/feeConfig'
-
-const meta: Meta = {
- title: 'Jam/ActiveCollaborativeSendAlert',
- component: ActiveCollaborativeSendAlert,
- tags: ['autodocs'],
- args: {
- jars: [],
- isAborting: false,
- onAbort: () => alert('onAbort clicked'),
- },
-}
-export default meta
-
-type Story = StoryObj
-
-export const Default: Story = {
- args: {},
-}
-
-const jars: Jar[] = [
- {
- balanceSummary: {
- calculatedAvailableBalanceInSats: 100_000,
- calculatedConfirmedAvailableBalanceInSats: 100_000,
- calculatedAvailableFrozenBalanceInSats: 0,
- calculatedFrozenOrLockedBalanceInSats: 0,
- calculatedTotalBalanceInSats: 100_000,
- },
- color: '#e2b86a',
- jarIndex: 0,
- name: 'Jar Zero',
- utxos: [],
- },
-]
-
-const paymentAttempt: PaymentAttempt = {
- createdAt: 1_000,
- utxosHashHex: 'abc123hash',
- walletFileName: 'Satoshi.jmdat',
- data: {
- amount: { amount: 21_000, isSweep: false as const, sweepAmount: undefined },
- destination: { address: 'bcrt1qdestinationaddress123456789', fromJar: undefined },
- isCoinJoin: true,
- numCollaborators: 5,
- source: { fromJar: 0 as const },
- txFee: { txFeeInBlocks: 3, txFeeInSatsPerVbyte: undefined, txFeeUnit: TX_FEE_UNITS.BLOCKS },
- },
-}
-
-export const WithPaymentAttempt: Story = {
- args: {
- paymentAttempt,
- jars,
- },
-}
-
-export const WithSweepPaymentAttempt: Story = {
- args: {
- paymentAttempt: {
- ...paymentAttempt,
- data: {
- ...paymentAttempt.data,
- amount: { amount: undefined, isSweep: true, sweepAmount: 21_000 },
- destination: { address: 'bcrt1qdestinationaddress123456789', fromJar: paymentAttempt.data.source.fromJar },
- },
- },
- jars,
- },
-}
diff --git a/src/stories/jam/OfferCard.stories.tsx b/src/stories/jam/OfferCard.stories.tsx
deleted file mode 100644
index b89f48c5..00000000
--- a/src/stories/jam/OfferCard.stories.tsx
+++ /dev/null
@@ -1,151 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/react-vite'
-import { OfferCard } from '@/components/earn/OfferCard'
-
-const meta: Meta = {
- title: 'Jam/OfferCard',
- component: OfferCard,
- tags: ['autodocs'],
-}
-export default meta
-
-type Story = StoryObj
-
-export const Absolute: Story = {
- args: {
- value: {
- oid: 0,
- ordertype: 'sw0absoffer',
- minsize: 90_463,
- maxsize: 9_008_744_958,
- txfee: 0,
- cjfee: '21',
- },
- nickname: 'TEST7i74jfC9M8MV',
- },
-}
-
-export const Relative: Story = {
- args: {
- value: {
- oid: 0,
- ordertype: 'sw0reloffer',
- minsize: 90_463,
- maxsize: 9_008_744_958,
- txfee: 0,
- cjfee: '0.000021',
- },
- nickname: 'TESTCKqXnDjxnFHN',
- },
-}
-
-export const Checking: Story = {
- args: {
- value: {
- oid: 0,
- ordertype: 'sw0reloffer',
- minsize: 90_463,
- maxsize: 9_008_744_958,
- txfee: 0,
- cjfee: '0.000021',
- },
- nickname: 'TESTCKqXnDjxnFHN',
- orderbookStatus: 'checking',
- },
-}
-
-export const Visible: Story = {
- args: {
- value: {
- oid: 0,
- ordertype: 'sw0reloffer',
- minsize: 90_463,
- maxsize: 9_008_744_958,
- txfee: 0,
- cjfee: '0.000021',
- },
- nickname: 'TESTCKqXnDjxnFHN',
- orderbookStatus: 'visible',
- },
-}
-
-export const Missing: Story = {
- args: {
- value: {
- oid: 0,
- ordertype: 'sw0reloffer',
- minsize: 90_463,
- maxsize: 9_008_744_958,
- txfee: 0,
- cjfee: '0.000021',
- },
- nickname: 'TESTCKqXnDjxnFHN',
- orderbookStatus: 'missing',
- },
-}
-
-export const Error: Story = {
- args: {
- value: {
- oid: 0,
- ordertype: 'sw0reloffer',
- minsize: 90_463,
- maxsize: 9_008_744_958,
- txfee: 0,
- cjfee: '0.000021',
- },
- nickname: 'TESTCKqXnDjxnFHN',
- orderbookStatus: 'error',
- },
-}
-
-export const RelativeWithFidelityBondNotYetInLocalOrderbook: Story = {
- args: {
- value: {
- oid: 0,
- ordertype: 'sw0reloffer',
- minsize: 90_463,
- maxsize: 9_008_744_958,
- txfee: 0,
- cjfee: '0.000021',
- },
- nickname: 'TESTCKqXnDjxnFHN',
- orderbookStatus: 'visible',
- orderbookOffer: {
- counterparty: 'TESTCKqXnDjxnFHN',
- oid: 0,
- ordertype: 'sw0reloffer',
- fidelity_bond_value: 0,
- },
- fidelityBond: {
- counterparty: 'TESTCKqXnDjxnFHN',
- amount: 123_456_789,
- locktime: 1_000_000,
- },
- },
-}
-
-export const RelativeWithFidelityBondInLocalOrderbook: Story = {
- args: {
- value: {
- oid: 0,
- ordertype: 'sw0reloffer',
- minsize: 90_463,
- maxsize: 9_008_744_958,
- txfee: 0,
- cjfee: '0.000021',
- },
- nickname: 'TESTCKqXnDjxnFHN',
- orderbookStatus: 'visible',
- orderbookOffer: {
- counterparty: 'TESTCKqXnDjxnFHN',
- oid: 0,
- ordertype: 'sw0reloffer',
- fidelity_bond_value: 123_456_789.1337,
- },
- fidelityBond: {
- counterparty: 'TESTCKqXnDjxnFHN',
- amount: 123_456_789,
- locktime: 0,
- },
- },
-}
diff --git a/src/stories/jam/OrderbookEmptyAlert.stories.tsx b/src/stories/jam/OrderbookEmptyAlert.stories.tsx
deleted file mode 100644
index c7a39a0f..00000000
--- a/src/stories/jam/OrderbookEmptyAlert.stories.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/react-vite'
-import { OrderbookEmptyAlert } from '@/components/ui/jam/OrderbookEmptyAlert'
-
-const meta: Meta = {
- title: 'Jam/OrderbookEmptyAlert',
- component: OrderbookEmptyAlert,
- tags: ['autodocs'],
-}
-export default meta
-
-type Story = StoryObj
-
-export const Default: Story = {
- args: {
- isChecking: false,
- onCheckClick: async () => alert('onCheck clicked'),
- },
-}
-
-export const Checking: Story = {
- args: {
- isChecking: true,
- onCheckClick: async () => alert('onCheck clicked'),
- },
-}
diff --git a/src/stories/jam/PreconditionAlert.stories.tsx b/src/stories/jam/PreconditionAlert.stories.tsx
deleted file mode 100644
index 45b2d11c..00000000
--- a/src/stories/jam/PreconditionAlert.stories.tsx
+++ /dev/null
@@ -1,179 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/react-vite'
-import { SWEEP_PRECONDITION_DEFAULT_OPTIONS } from '@/components/sweep/preconditions'
-import { PreconditionAlert } from '@/components/ui/jam/PreconditionAlert'
-import type { Utxo } from '@/hooks/useQueryUtxos'
-
-const DEFAULT_SUMMARY = Object.freeze({
- isFulfilled: false,
- options: SWEEP_PRECONDITION_DEFAULT_OPTIONS,
- numberOfMissingUtxos: 0,
- numberOfMissingConfirmations: 0,
- numberOfNonFrozenFidelityBondOutputs: 0,
- retryLockedUtxos: [],
-})
-
-const makeUtxo = (overrides: Partial = {}): Utxo =>
- ({
- address: 'bc1qsource',
- confirmations: 6,
- frozen: false,
- label: '',
- locktime: undefined,
- mixdepth: 0,
- path: '',
- tries_remaining: 3,
- utxo: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0',
- value: 100_000,
- ...overrides,
- }) as Utxo
-
-const meta: Meta = {
- title: 'Jam/PreconditionAlert',
- component: PreconditionAlert,
- tags: ['autodocs'],
- args: {
- summary: DEFAULT_SUMMARY,
- i18nPrefix: 'send.coinjoin_precondition',
- },
-}
-export default meta
-
-type Story = StoryObj
-
-// --- Send Flow Stories ---
-
-export const SendDefault: Story = {
- args: {
- i18nPrefix: 'send.coinjoin_precondition',
- },
-}
-
-export const SendMissingUtxos: Story = {
- args: {
- i18nPrefix: 'send.coinjoin_precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- numberOfMissingUtxos: 3,
- },
- },
-}
-
-export const SendMissingConfirmations: Story = {
- args: {
- i18nPrefix: 'send.coinjoin_precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- numberOfMissingConfirmations: 3,
- },
- },
-}
-
-export const SendNonFrozenFidelityBondsPresent: Story = {
- args: {
- i18nPrefix: 'send.coinjoin_precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- numberOfNonFrozenFidelityBondOutputs: 3,
- },
- },
-}
-
-export const SendRetryLockedUtxos: Story = {
- args: {
- i18nPrefix: 'send.coinjoin_precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- retryLockedUtxos: [
- makeUtxo({ mixdepth: 0, value: 21 }),
- makeUtxo({ mixdepth: 1, value: 21_000 }),
- makeUtxo({ mixdepth: 2, value: 21_000_000 }),
- ],
- },
- },
-}
-
-export const SendMultiple: Story = {
- args: {
- i18nPrefix: 'send.coinjoin_precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- numberOfMissingUtxos: 3,
- numberOfMissingConfirmations: 3,
- numberOfNonFrozenFidelityBondOutputs: 3,
- retryLockedUtxos: [
- makeUtxo({ mixdepth: 0, value: 21 }),
- makeUtxo({ mixdepth: 1, value: 21_000 }),
- makeUtxo({ mixdepth: 2, value: 21_000_000 }),
- ],
- },
- },
-}
-
-// --- Sweep Flow Stories ---
-
-export const SweepDefault: Story = {
- args: {
- i18nPrefix: 'scheduler.precondition',
- },
-}
-
-export const SweepMissingUtxos: Story = {
- args: {
- i18nPrefix: 'scheduler.precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- numberOfMissingUtxos: 3,
- },
- },
-}
-
-export const SweepMissingConfirmations: Story = {
- args: {
- i18nPrefix: 'scheduler.precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- numberOfMissingConfirmations: 3,
- },
- },
-}
-
-export const SweepNonFrozenFidelityBondsPresent: Story = {
- args: {
- i18nPrefix: 'scheduler.precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- numberOfNonFrozenFidelityBondOutputs: 3,
- },
- },
-}
-
-export const SweepRetryLockedUtxos: Story = {
- args: {
- i18nPrefix: 'scheduler.precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- retryLockedUtxos: [
- makeUtxo({ mixdepth: 0, value: 21 }),
- makeUtxo({ mixdepth: 1, value: 21_000 }),
- makeUtxo({ mixdepth: 2, value: 21_000_000 }),
- ],
- },
- },
-}
-
-export const SweepMultiple: Story = {
- args: {
- i18nPrefix: 'scheduler.precondition',
- summary: {
- ...DEFAULT_SUMMARY,
- numberOfMissingUtxos: 3,
- numberOfMissingConfirmations: 3,
- numberOfNonFrozenFidelityBondOutputs: 3,
- retryLockedUtxos: [
- makeUtxo({ mixdepth: 0, value: 21 }),
- makeUtxo({ mixdepth: 1, value: 21_000 }),
- makeUtxo({ mixdepth: 2, value: 21_000_000 }),
- ],
- },
- },
-}
diff --git a/src/stories/jam/ScheduleEntryItem.stories.tsx b/src/stories/jam/ScheduleEntryItem.stories.tsx
index e303631f..da69cace 100644
--- a/src/stories/jam/ScheduleEntryItem.stories.tsx
+++ b/src/stories/jam/ScheduleEntryItem.stories.tsx
@@ -2,7 +2,6 @@ import type { TumblerPhaseResponse } from '@joinmarket-webui/joinmarket-ng-api-t
import type { Meta, StoryObj } from '@storybook/react-vite'
import { ScheduleEntryItem } from '@/components/sweep/ScheduleEntryItem'
import { toScheduleEntry } from '@/components/sweep/scheduleUtils'
-import type { Jar } from '@/context/JamWalletInfoContext'
const meta: Meta = {
title: 'Jam/ScheduleEntryItem',
@@ -13,22 +12,6 @@ export default meta
type Story = StoryObj
-const jars: Jar[] = [
- {
- balanceSummary: {
- calculatedAvailableBalanceInSats: 100_000,
- calculatedConfirmedAvailableBalanceInSats: 100_000,
- calculatedAvailableFrozenBalanceInSats: 0,
- calculatedFrozenOrLockedBalanceInSats: 0,
- calculatedTotalBalanceInSats: 100_000,
- },
- color: '#e2b86a',
- jarIndex: 0,
- name: 'Jar Zero',
- utxos: [],
- },
-]
-
const takerPhase: TumblerPhaseResponse = {
kind: 'taker_coinjoin',
index: 0,
@@ -37,7 +20,7 @@ const takerPhase: TumblerPhaseResponse = {
started_at: '2026-07-19T10:35:52.775747+00:00',
finished_at: null,
error: null,
- mixdepth: jars[0].jarIndex,
+ mixdepth: 0,
amount: 0,
amount_fraction: null,
counterparty_count: 21,
@@ -71,28 +54,9 @@ const makerPhase: TumblerPhaseResponse = {
attempt_count: 0,
}
-export const Maker: Story = {
- args: {
- value: toScheduleEntry(makerPhase, jars),
- },
-}
-
export const Active: Story = {
args: {
- value: toScheduleEntry(takerPhase, jars),
- active: true,
- },
-}
-
-export const ActiveExternal: Story = {
- args: {
- value: toScheduleEntry(
- {
- ...takerPhase,
- destination: 'bcrt1qdestinationaddress123456789',
- },
- jars,
- ),
+ value: toScheduleEntry(takerPhase, []),
active: true,
},
}
@@ -104,7 +68,7 @@ export const Running: Story = {
...takerPhase,
status: 'running',
},
- jars,
+ [],
),
active: false,
},
@@ -117,7 +81,7 @@ export const Pending: Story = {
...takerPhase,
status: 'pending',
},
- jars,
+ [],
),
active: false,
},
@@ -129,9 +93,8 @@ export const Completed: Story = {
{
...takerPhase,
status: 'completed',
- finished_at: '2026-07-19T10:35:52.775747+00:00',
},
- jars,
+ [],
),
active: false,
},
@@ -144,7 +107,7 @@ export const Skipped: Story = {
...takerPhase,
status: 'skipped',
},
- jars,
+ [],
),
active: false,
},
@@ -157,7 +120,7 @@ export const Cancelled: Story = {
...takerPhase,
status: 'cancelled',
},
- jars,
+ [],
),
active: false,
},
@@ -171,8 +134,14 @@ export const Failed: Story = {
status: 'failed',
error: 'Error description',
},
- jars,
+ [],
),
active: false,
},
}
+
+export const Maker: Story = {
+ args: {
+ value: toScheduleEntry(makerPhase, []),
+ },
+}
diff --git a/src/stories/jam/SendCoinJoinPreconditionAlert.stories.tsx b/src/stories/jam/SendCoinJoinPreconditionAlert.stories.tsx
new file mode 100644
index 00000000..cca58e5c
--- /dev/null
+++ b/src/stories/jam/SendCoinJoinPreconditionAlert.stories.tsx
@@ -0,0 +1,116 @@
+import type { Meta, StoryObj } from '@storybook/react-vite'
+import { SendCoinjoinPreconditionAlert } from '@/components/send/SendCoinjoinPreconditionAlert'
+import { SWEEP_PRECONDITION_DEFAULT_OPTIONS } from '@/components/sweep/preconditions'
+import type { Utxo } from '@/hooks/useQueryUtxos'
+
+const DEFAULT_SUMMARY = Object.freeze({
+ isFulfilled: false,
+ options: SWEEP_PRECONDITION_DEFAULT_OPTIONS,
+ numberOfMissingUtxos: 0,
+ numberOfMissingConfirmations: 0,
+ numberOfNonFrozenFidelityBondOutputs: 0,
+ retryLockedUtxos: [],
+})
+
+const makeUtxo = (overrides: Partial = {}): Utxo =>
+ ({
+ address: 'bc1qsource',
+ confirmations: 6,
+ frozen: false,
+ label: '',
+ locktime: undefined,
+ mixdepth: 0,
+ path: '',
+ tries_remaining: 3,
+ utxo: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0',
+ value: 100_000,
+ ...overrides,
+ }) as Utxo
+
+const meta: Meta = {
+ title: 'Jam/SendCoinjoinPreconditionAlert',
+ component: SendCoinjoinPreconditionAlert,
+ tags: ['autodocs'],
+ args: {
+ summary: DEFAULT_SUMMARY,
+ },
+}
+export default meta
+
+type Story = StoryObj
+
+export const Default: Story = {}
+
+export const MissingUtxos: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ numberOfMissingUtxos: 3,
+ },
+ },
+}
+
+export const MissingConfirmations: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ numberOfMissingConfirmations: 3,
+ },
+ },
+}
+
+export const NonFrozenFidelityBondsPresent: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ numberOfNonFrozenFidelityBondOutputs: 3,
+ },
+ },
+}
+
+export const RetryLockedUtxos: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ retryLockedUtxos: [
+ makeUtxo({
+ mixdepth: 0,
+ value: 21,
+ }),
+ makeUtxo({
+ mixdepth: 1,
+ value: 21_000,
+ }),
+ makeUtxo({
+ mixdepth: 2,
+ value: 21_000_000,
+ }),
+ ],
+ },
+ },
+}
+
+export const Multiple: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ numberOfMissingUtxos: 3,
+ numberOfMissingConfirmations: 3,
+ numberOfNonFrozenFidelityBondOutputs: 3,
+ retryLockedUtxos: [
+ makeUtxo({
+ mixdepth: 0,
+ value: 21,
+ }),
+ makeUtxo({
+ mixdepth: 1,
+ value: 21_000,
+ }),
+ makeUtxo({
+ mixdepth: 2,
+ value: 21_000_000,
+ }),
+ ],
+ },
+ },
+}
diff --git a/src/stories/jam/SweepPreconditionAlert.stories.tsx b/src/stories/jam/SweepPreconditionAlert.stories.tsx
new file mode 100644
index 00000000..9e8cbef5
--- /dev/null
+++ b/src/stories/jam/SweepPreconditionAlert.stories.tsx
@@ -0,0 +1,116 @@
+import type { Meta, StoryObj } from '@storybook/react-vite'
+import { SweepPreconditionAlert } from '@/components/sweep/SweepPreconditionAlert'
+import { SWEEP_PRECONDITION_DEFAULT_OPTIONS } from '@/components/sweep/preconditions'
+import type { Utxo } from '@/hooks/useQueryUtxos'
+
+const DEFAULT_SUMMARY = Object.freeze({
+ isFulfilled: false,
+ options: SWEEP_PRECONDITION_DEFAULT_OPTIONS,
+ numberOfMissingUtxos: 0,
+ numberOfMissingConfirmations: 0,
+ numberOfNonFrozenFidelityBondOutputs: 0,
+ retryLockedUtxos: [],
+})
+
+const makeUtxo = (overrides: Partial = {}): Utxo =>
+ ({
+ address: 'bc1qsource',
+ confirmations: 6,
+ frozen: false,
+ label: '',
+ locktime: undefined,
+ mixdepth: 0,
+ path: '',
+ tries_remaining: 3,
+ utxo: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0',
+ value: 100_000,
+ ...overrides,
+ }) as Utxo
+
+const meta: Meta = {
+ title: 'Jam/SweepPreconditionAlert',
+ component: SweepPreconditionAlert,
+ tags: ['autodocs'],
+ args: {
+ summary: DEFAULT_SUMMARY,
+ },
+}
+export default meta
+
+type Story = StoryObj
+
+export const Default: Story = {}
+
+export const MissingUtxos: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ numberOfMissingUtxos: 3,
+ },
+ },
+}
+
+export const MissingConfirmations: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ numberOfMissingConfirmations: 3,
+ },
+ },
+}
+
+export const NonFrozenFidelityBondsPresent: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ numberOfNonFrozenFidelityBondOutputs: 3,
+ },
+ },
+}
+
+export const RetryLockedUtxos: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ retryLockedUtxos: [
+ makeUtxo({
+ mixdepth: 0,
+ value: 21,
+ }),
+ makeUtxo({
+ mixdepth: 1,
+ value: 21_000,
+ }),
+ makeUtxo({
+ mixdepth: 2,
+ value: 21_000_000,
+ }),
+ ],
+ },
+ },
+}
+
+export const Multiple: Story = {
+ args: {
+ summary: {
+ ...DEFAULT_SUMMARY,
+ numberOfMissingUtxos: 3,
+ numberOfMissingConfirmations: 3,
+ numberOfNonFrozenFidelityBondOutputs: 3,
+ retryLockedUtxos: [
+ makeUtxo({
+ mixdepth: 0,
+ value: 21,
+ }),
+ makeUtxo({
+ mixdepth: 1,
+ value: 21_000,
+ }),
+ makeUtxo({
+ mixdepth: 2,
+ value: 21_000_000,
+ }),
+ ],
+ },
+ },
+}
diff --git a/src/test/withRuntimeLocale.ts b/src/test/withRuntimeLocale.ts
deleted file mode 100644
index d8d41354..00000000
--- a/src/test/withRuntimeLocale.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { vi } from 'vitest'
-
-const OriginalIntlNumberFormat = Intl.NumberFormat
-
-/**
- * Runs `callback` with `Number.prototype.toLocaleString` and `Intl.NumberFormat`
- * mocked so that calls without an explicit locale argument format using
- * `locale` instead of the host machine's default locale. Calls that already
- * pass an explicit locale are left untouched. This keeps locale-dependent
- * assertions deterministic across contributors' machines and CI without
- * pinning a locale in app code.
- */
-export function withRuntimeLocale(locale: string, callback: () => Promise): Promise
-export function withRuntimeLocale(locale: string, callback: () => void): void
-export function withRuntimeLocale(locale: string, callback: () => void | Promise): void | Promise {
- /* eslint-disable unicorn/no-this-outside-of-class -- mocking Number.prototype.toLocaleString requires `this` */
- const numberToLocaleStringMock = vi.spyOn(Number.prototype, 'toLocaleString').mockImplementation(function (
- this: number,
- locales,
- options,
- ) {
- return Intl.NumberFormat(locales ?? locale, options).format(this)
- })
- /* eslint-enable unicorn/no-this-outside-of-class */
-
- const intlNumberFormatMock = vi.spyOn(Intl, 'NumberFormat').mockImplementation(function (
- locales?: string | string[],
- options?: Intl.NumberFormatOptions,
- ) {
- return new OriginalIntlNumberFormat(locales ?? locale, options)
- } as unknown as typeof Intl.NumberFormat)
-
- const restore = () => {
- numberToLocaleStringMock.mockRestore()
- intlNumberFormatMock.mockRestore()
- }
-
- let result: void | Promise
- try {
- result = callback()
- } catch (error) {
- restore()
- throw error
- }
-
- if (result instanceof Promise) {
- return result.finally(restore)
- }
-
- restore()
- return undefined
-}
diff --git a/vite.config.ts b/vite.config.ts
index 56362412..0dad02fe 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -78,18 +78,6 @@ export default defineConfig((config): UserConfig => {
'@': path.resolve(import.meta.dirname, './src'),
},
},
- build: {
- rolldownOptions: {
- output: {
- minify: {
- compress: {
- dropConsole: buildOrPreview,
- dropDebugger: buildOrPreview,
- },
- },
- },
- },
- },
server: {
...server,
open: true,