Skip to content

Commit

Permalink
fix: Remove lastChainId fallback in useChainId
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Feb 25, 2025
1 parent fe2bd0e commit 15f8326
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
9 changes: 0 additions & 9 deletions apps/web/src/hooks/__tests__/useChainId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,4 @@ describe('useChainId hook', () => {
const { result } = renderHook(() => useChainId())
expect(result.current).toBe('1337')
})

it('should return the last chain id', () => {
;(useParams as any).mockImplementation(() => ({}))

localStorage.setItem('SAFE_v2__session', `{"lastChainId": "100"}`)

const { result } = renderHook(() => useChainId())
expect(result.current).toBe('100')
})
})
5 changes: 1 addition & 4 deletions apps/web/src/hooks/useChainId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { useParams } from 'next/navigation'
import { parse, type ParsedUrlQuery } from 'querystring'
import { IS_PRODUCTION } from '@/config/constants'
import chains from '@/config/chains'
import { useAppSelector } from '@/store'
import { selectSession } from '@/store/sessionSlice'
import { parsePrefixedAddress } from '@/utils/addresses'
import useWallet from './wallets/useWallet'
import useChains from './useChains'
Expand Down Expand Up @@ -43,11 +41,10 @@ const useWalletChainId = (): string | undefined => {
}

export const useChainId = (): string => {
const session = useAppSelector(selectSession)
const urlChainId = useUrlChainId()
const walletChainId = useWalletChainId()

return urlChainId || session.lastChainId || walletChainId || defaultChainId
return urlChainId || walletChainId || defaultChainId
}

export default useChainId

0 comments on commit 15f8326

Please sign in to comment.