Skip to content

Commit d3d96e9

Browse files
committed
chore: address PR feedback
1 parent 9a66439 commit d3d96e9

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

src/features/swap/SwapConfirm.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ export function SwapConfirmCard({ formValues }: Props) {
9595
)
9696
const [isApproveConfirmed, setApproveConfirmed] = useState(false)
9797

98-
const { skipApprove } = useSwapAllowance(
98+
const { skipApprove } = useSwapAllowance({
9999
chainId,
100100
fromTokenId,
101101
toTokenId,
102-
address ?? '',
103-
approveAmount
104-
)
102+
approveAmount,
103+
address,
104+
})
105105

106106
useEffect(() => {
107107
if (skipApprove) {

src/features/swap/hooks/useAllowance.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ export function useAllowance(
3838
chainId: number,
3939
fromTokenId: TokenId,
4040
toTokenId: TokenId,
41-
accountAddress?: string
41+
address?: string
4242
) {
4343
const { data: allowance, isLoading } = useQuery(
44-
['tokenAllowance', chainId, fromTokenId, toTokenId, accountAddress],
44+
['tokenAllowance', chainId, fromTokenId, toTokenId, address],
4545
async () => {
46-
if (!accountAddress) return '0'
47-
return fetchAllowance(fromTokenId, toTokenId, accountAddress, chainId)
46+
if (!address) return '0'
47+
return fetchAllowance(fromTokenId, toTokenId, address, chainId)
4848
},
4949
{
5050
retry: false,
51-
enabled: Boolean(accountAddress && chainId && fromTokenId && toTokenId),
51+
enabled: Boolean(address && chainId && fromTokenId && toTokenId),
5252
staleTime: 5000, // Consider allowance stale after 5 seconds
5353
}
5454
)

src/features/swap/hooks/useSwapAllowance.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ import { logger } from 'src/utils/logger'
55

66
import { useAllowance } from './useAllowance'
77

8-
export function useSwapAllowance(
9-
chainId: number,
10-
fromTokenId: TokenId,
11-
toTokenId: TokenId,
12-
address: string,
8+
interface ISwapAllowanceOptions {
9+
chainId: number
10+
fromTokenId: TokenId
11+
toTokenId: TokenId
1312
approveAmount: string
14-
) {
13+
address?: string
14+
}
15+
16+
export function useSwapAllowance(options: ISwapAllowanceOptions) {
17+
const { chainId, fromTokenId, toTokenId, approveAmount, address } = options
1518
const { allowance, isLoading: isAllowanceLoading } = useAllowance(
1619
chainId,
1720
fromTokenId,

0 commit comments

Comments
 (0)