Skip to content

Commit

Permalink
CP-9267: fix husky eslint output (#1763)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruijialin-avalabs authored Sep 19, 2024
1 parent a899865 commit 4a92954
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
yarn lint-staged --quiet
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"packages/*"
],
"scripts": {
"prepare": "husky install",
"prepare": "husky",
"setup": "yarn workspaces foreach -p run setup",
"lint": "yarn workspaces foreach -p run lint",
"tsc": "yarn workspaces foreach -p run tsc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { ReactQueryKeys } from 'consts/reactQueryKeys'
import { useSelector } from 'react-redux'
import { selectAllCustomTokens } from 'store/customToken'
import { selectIsDeveloperMode } from 'store/settings/advanced'
import { useMemo } from 'react'
import { getNetworkContractTokens } from './utils/getNetworkContractTokens'

export const useNetworkContractTokens = (
const useNetworkContractTokensInternal = (
network: Network
): NetworkContractToken[] => {
const allCustomTokens = useSelector(selectAllCustomTokens)
Expand All @@ -31,3 +32,11 @@ export const useNetworkContractTokens = (
}
return tokens
}

export const useNetworkContractTokens = (
network: Network
): NetworkContractToken[] => {
const tokens = useNetworkContractTokensInternal(network)
// eslint-disable-next-line react-hooks/exhaustive-deps
return useMemo(() => tokens, [network])
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useDispatch } from 'react-redux'
import { isAddress } from 'ethers'
import { addCustomToken as addCustomTokenAction } from 'store/customToken'
import { useState, useEffect, useMemo } from 'react'
import { useState, useEffect } from 'react'
import { Network } from '@avalabs/core-chains-sdk'
import Logger from 'utils/Logger'
import AnalyticsService from 'services/analytics/AnalyticsService'
Expand Down Expand Up @@ -71,10 +71,8 @@ const useAddCustomToken = (callback: () => void): CustomToken => {
const chainId = activeNetwork.chainId
const [isLoading, setIsLoading] = useState(false)

const memoizedTokens = useMemo(() => tokens, [activeNetwork])

useEffect(() => {
const validationStatus = validateAddress(tokenAddress, memoizedTokens)
const validationStatus = validateAddress(tokenAddress, tokens)
switch (validationStatus) {
case AddressValidationStatus.Invalid:
setToken(undefined)
Expand All @@ -87,8 +85,8 @@ const useAddCustomToken = (callback: () => void): CustomToken => {
case AddressValidationStatus.Valid:
setIsLoading(true)
fetchTokenData(activeNetwork, tokenAddress)
.then(token => {
setToken(token)
.then(t => {
setToken(t)
setErrorMessage('')
})
.catch(err => {
Expand All @@ -106,7 +104,7 @@ const useAddCustomToken = (callback: () => void): CustomToken => {
setErrorMessage('')
setToken(undefined)
}
}, [activeNetwork, tokenAddress, memoizedTokens])
}, [activeNetwork, tokenAddress, tokens])

const addCustomToken = (): void => {
if (token) {
Expand Down

0 comments on commit 4a92954

Please sign in to comment.