Skip to content

Commit

Permalink
chore: useValue cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Aug 10, 2024
1 parent cd6c0cf commit a965b10
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
5 changes: 1 addition & 4 deletions src/swap/components/SwapAmountInput.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -8,10 +9,6 @@ import type { Token } from '../../token';
import type { SwapAmountInputReact } from '../types';
import { useSwapContext } from './SwapProvider';

function useValue<T>(object: T): T {
return useMemo(() => object, [object]);
}

// istanbul ignore next
export function SwapAmountInput({
className,
Expand Down
13 changes: 2 additions & 11 deletions src/swap/components/SwapProvider.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -17,10 +12,6 @@ import { getSwapQuote } from '../utils/getSwapQuote';
import { isSwapError } from '../utils/isSwapError';
import { processSwapTransaction } from '../utils/processSwapTransaction';

function useValue<T>(object: T): T {
return useMemo(() => object, [object]);
}

const emptyContext = {} as SwapContextType;

export const SwapContext = createContext<SwapContextType>(emptyContext);
Expand Down
6 changes: 1 addition & 5 deletions src/swap/hooks/useSwapBalances.tsx
Original file line number Diff line number Diff line change
@@ -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<T>(object: T): T {
return useMemo(() => object, [object]);
}

export function useSwapBalances({
address,
fromToken,
Expand Down
4 changes: 2 additions & 2 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down

0 comments on commit a965b10

Please sign in to comment.