Skip to content

Commit

Permalink
fix(tokens-selector): add native token to the top of the list if it's…
Browse files Browse the repository at this point in the history
… not there already (#3471)
  • Loading branch information
shoom3301 authored Dec 6, 2023
1 parent 8b14e71 commit 887a076
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions libs/tokens/src/state/tokens/allTokensAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { userAddedTokensAtom } from './userAddedTokensAtom'
import { favouriteTokensAtom } from './favouriteTokensAtom'
import { listsEnabledStateAtom, listsStatesListAtom } from '../tokenLists/tokenListsStateAtom'
import { lowerCaseTokensMap } from '../../utils/lowerCaseTokensMap'
import type { TokenInfo } from '@uniswap/token-lists'

export interface TokensByAddress {
[address: string]: TokenWithLogo
Expand Down Expand Up @@ -65,15 +66,12 @@ export const activeTokensAtom = atom<TokenWithLogo[]>((get) => {
const tokensMap = get(tokensStateAtom)
const nativeToken = NATIVE_CURRENCY_BUY_TOKEN[chainId]

const tokens = tokenMapToListWithLogo({
return tokenMapToListWithLogo({
[nativeToken.address.toLowerCase()]: nativeToken as TokenInfo,
...tokensMap.activeTokens,
...lowerCaseTokensMap(userAddedTokens[chainId]),
...lowerCaseTokensMap(favouriteTokensState[chainId]),
})

tokens.unshift(nativeToken)

return tokens
})

export const inactiveTokensAtom = atom<TokenWithLogo[]>((get) => {
Expand Down

0 comments on commit 887a076

Please sign in to comment.