diff --git a/src/swap/components/SwapAmountInput.tsx b/src/swap/components/SwapAmountInput.tsx index 50a09c5a22..24ee106e1d 100644 --- a/src/swap/components/SwapAmountInput.tsx +++ b/src/swap/components/SwapAmountInput.tsx @@ -1,5 +1,6 @@ import { useCallback, useEffect, useMemo } from 'react'; import { TextInput } from '../../internal/components/TextInput'; +import { useValue } from '../../internal/hooks/useValue'; import { getRoundedAmount } from '../../internal/utils/getRoundedAmount'; import { isValidAmount } from '../../internal/utils/isValidAmount'; import { background, cn, color, pressable, text } from '../../styles/theme'; @@ -8,10 +9,6 @@ import type { Token } from '../../token'; import type { SwapAmountInputReact } from '../types'; import { useSwapContext } from './SwapProvider'; -function useValue(object: T): T { - return useMemo(() => object, [object]); -} - // istanbul ignore next export function SwapAmountInput({ className, diff --git a/src/swap/components/SwapProvider.tsx b/src/swap/components/SwapProvider.tsx index 66ee6d4d5b..c339ebc68d 100644 --- a/src/swap/components/SwapProvider.tsx +++ b/src/swap/components/SwapProvider.tsx @@ -1,12 +1,7 @@ -import { - createContext, - useCallback, - useContext, - useMemo, - useState, -} from 'react'; +import { createContext, useCallback, useContext, useState } from 'react'; import type { Address, TransactionReceipt } from 'viem'; import { type BaseError, useConfig, useSendTransaction } from 'wagmi'; +import { useValue } from '../../internal/hooks/useValue'; import { formatTokenAmount } from '../../internal/utils/formatTokenAmount'; import type { Token } from '../../token'; import { USER_REJECTED_ERROR_CODE } from '../constants'; @@ -17,10 +12,6 @@ import { getSwapQuote } from '../utils/getSwapQuote'; import { isSwapError } from '../utils/isSwapError'; import { processSwapTransaction } from '../utils/processSwapTransaction'; -function useValue(object: T): T { - return useMemo(() => object, [object]); -} - const emptyContext = {} as SwapContextType; export const SwapContext = createContext(emptyContext); diff --git a/src/swap/hooks/useSwapBalances.tsx b/src/swap/hooks/useSwapBalances.tsx index c26be321e1..4f572a417a 100644 --- a/src/swap/hooks/useSwapBalances.tsx +++ b/src/swap/hooks/useSwapBalances.tsx @@ -1,13 +1,9 @@ -import { useMemo } from 'react'; import type { Address } from 'viem'; +import { useValue } from '../../internal/hooks/useValue'; import type { Token } from '../../token'; import { useGetETHBalance } from '../../wallet/hooks/useGetETHBalance'; import { useGetTokenBalance } from '../../wallet/hooks/useGetTokenBalance'; -function useValue(object: T): T { - return useMemo(() => object, [object]); -} - export function useSwapBalances({ address, fromToken, diff --git a/vitest.config.ts b/vitest.config.ts index 7c6a50ee1c..b737f6e4a5 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -23,8 +23,8 @@ export default defineConfig({ reportOnFailure: true, thresholds: { statements: 99.24, - branches: 98.03, - functions: 93.42, + branches: 98.02, + functions: 93.33, lines: 99.24, }, },