Commit b258f557 authored by Ian Lapham's avatar Ian Lapham Committed by GitHub

improvement(lists): add BA SEC tokens to unsupported list (#1327)

* show hidden search results by default

* update break styles

* optimize filter, use debounce on input

* increase debounce time

* add ba association list
parent 9d8c7f8e
...@@ -64,7 +64,6 @@ export default function UnsupportedCurrencyFooter({ ...@@ -64,7 +64,6 @@ export default function UnsupportedCurrencyFooter({
<AutoColumn gap="lg"> <AutoColumn gap="lg">
<RowBetween> <RowBetween>
<TYPE.mediumHeader>Unsupported Assets</TYPE.mediumHeader> <TYPE.mediumHeader>Unsupported Assets</TYPE.mediumHeader>
<CloseIcon onClick={() => setShowDetails(false)} /> <CloseIcon onClick={() => setShowDetails(false)} />
</RowBetween> </RowBetween>
{tokens.map(token => { {tokens.map(token => {
......
// used to mark unsupported tokens, these are hosted lists of unsupported tokens // used to mark unsupported tokens, these are hosted lists of unsupported tokens
/**
* @TODO add list from blockchain association
*/
export const UNSUPPORTED_LIST_URLS: string[] = []
const COMPOUND_LIST = 'https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json' const COMPOUND_LIST = 'https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json'
const UMA_LIST = 'https://umaproject.org/uma.tokenlist.json' const UMA_LIST = 'https://umaproject.org/uma.tokenlist.json'
...@@ -17,6 +13,9 @@ const CMC_ALL_LIST = 'defi.cmc.eth' ...@@ -17,6 +13,9 @@ const CMC_ALL_LIST = 'defi.cmc.eth'
const CMC_STABLECOIN = 'stablecoin.cmc.eth' const CMC_STABLECOIN = 'stablecoin.cmc.eth'
const KLEROS_LIST = 't2crtokens.eth' const KLEROS_LIST = 't2crtokens.eth'
const GEMINI_LIST = 'https://www.gemini.com/uniswap/manifest.json' const GEMINI_LIST = 'https://www.gemini.com/uniswap/manifest.json'
const BA_LIST = 'https://raw.githubusercontent.com/The-Blockchain-Association/sec-notice-list/master/ba-sec-list.json'
export const UNSUPPORTED_LIST_URLS: string[] = [BA_LIST]
// lower index == higher priority for token import // lower index == higher priority for token import
export const DEFAULT_LIST_OF_LISTS: string[] = [ export const DEFAULT_LIST_OF_LISTS: string[] = [
......
...@@ -150,18 +150,18 @@ export function useTradeExactOut(currencyIn?: Currency, currencyAmountOut?: Curr ...@@ -150,18 +150,18 @@ export function useTradeExactOut(currencyIn?: Currency, currencyAmountOut?: Curr
} }
export function useIsTransactionUnsupported(currencyIn?: Currency, currencyOut?: Currency): boolean { export function useIsTransactionUnsupported(currencyIn?: Currency, currencyOut?: Currency): boolean {
const unsupportedToken: { [address: string]: Token } = useUnsupportedTokens() const unsupportedTokens: { [address: string]: Token } = useUnsupportedTokens()
const { chainId } = useActiveWeb3React() const { chainId } = useActiveWeb3React()
const tokenIn = wrappedCurrency(currencyIn, chainId) const tokenIn = wrappedCurrency(currencyIn, chainId)
const tokenOut = wrappedCurrency(currencyOut, chainId) const tokenOut = wrappedCurrency(currencyOut, chainId)
// if unsupported list loaded & either token on list, mark as unsupported // if unsupported list loaded & either token on list, mark as unsupported
if (unsupportedToken) { if (unsupportedTokens) {
if (tokenIn && Object.keys(unsupportedToken).includes(tokenIn.address)) { if (tokenIn && Object.keys(unsupportedTokens).includes(tokenIn.address)) {
return true return true
} }
if (tokenOut && Object.keys(unsupportedToken).includes(tokenOut.address)) { if (tokenOut && Object.keys(unsupportedTokens).includes(tokenOut.address)) {
return true return true
} }
} }
......
import { DEFAULT_ACTIVE_LIST_URLS } from './../../constants/lists' import { DEFAULT_ACTIVE_LIST_URLS, UNSUPPORTED_LIST_URLS } from './../../constants/lists'
import { createReducer } from '@reduxjs/toolkit' import { createReducer } from '@reduxjs/toolkit'
import { getVersionUpgrade, VersionUpgrade } from '@uniswap/token-lists' import { getVersionUpgrade, VersionUpgrade } from '@uniswap/token-lists'
import { TokenList } from '@uniswap/token-lists/dist/types' import { TokenList } from '@uniswap/token-lists/dist/types'
...@@ -36,7 +36,7 @@ type Mutable<T> = { -readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U ...@@ -36,7 +36,7 @@ type Mutable<T> = { -readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U
const initialState: ListsState = { const initialState: ListsState = {
lastInitializedDefaultListOfLists: DEFAULT_LIST_OF_LISTS, lastInitializedDefaultListOfLists: DEFAULT_LIST_OF_LISTS,
byUrl: { byUrl: {
...DEFAULT_LIST_OF_LISTS.reduce<Mutable<ListsState['byUrl']>>((memo, listUrl) => { ...DEFAULT_LIST_OF_LISTS.concat(...UNSUPPORTED_LIST_URLS).reduce<Mutable<ListsState['byUrl']>>((memo, listUrl) => {
memo[listUrl] = NEW_LIST_STATE memo[listUrl] = NEW_LIST_STATE
return memo return memo
}, {}) }, {})
......
...@@ -10,6 +10,7 @@ import { AppDispatch } from '../index' ...@@ -10,6 +10,7 @@ import { AppDispatch } from '../index'
import { acceptListUpdate } from './actions' import { acceptListUpdate } from './actions'
import { useActiveListUrls } from './hooks' import { useActiveListUrls } from './hooks'
import { useAllInactiveTokens } from 'hooks/Tokens' import { useAllInactiveTokens } from 'hooks/Tokens'
import { UNSUPPORTED_LIST_URLS } from 'constants/lists'
export default function Updater(): null { export default function Updater(): null {
const { library } = useActiveWeb3React() const { library } = useActiveWeb3React()
...@@ -44,6 +45,16 @@ export default function Updater(): null { ...@@ -44,6 +45,16 @@ export default function Updater(): null {
}) })
}, [dispatch, fetchList, library, lists]) }, [dispatch, fetchList, library, lists])
// if any lists from unsupported lists are loaded, check them too (in case new updates since last visit)
useEffect(() => {
Object.keys(UNSUPPORTED_LIST_URLS).forEach(listUrl => {
const list = lists[listUrl]
if (!list || (!list.current && !list.loadingRequestId && !list.error)) {
fetchList(listUrl).catch(error => console.debug('list added fetching error', error))
}
})
}, [dispatch, fetchList, library, lists])
// automatically update lists if versions are minor/patch // automatically update lists if versions are minor/patch
useEffect(() => { useEffect(() => {
Object.keys(lists).forEach(listUrl => { Object.keys(lists).forEach(listUrl => {
......
...@@ -162,7 +162,7 @@ export function useUserAddedTokens(): Token[] { ...@@ -162,7 +162,7 @@ export function useUserAddedTokens(): Token[] {
return useMemo(() => { return useMemo(() => {
if (!chainId) return [] if (!chainId) return []
return Object.values(serializedTokensMap[chainId as ChainId] ?? {}).map(deserializeToken) return Object.values(serializedTokensMap?.[chainId as ChainId] ?? {}).map(deserializeToken)
}, [serializedTokensMap, chainId]) }, [serializedTokensMap, chainId])
} }
......
...@@ -111,11 +111,17 @@ export default createReducer(initialState, builder => ...@@ -111,11 +111,17 @@ export default createReducer(initialState, builder =>
state.userSingleHopOnly = action.payload.userSingleHopOnly state.userSingleHopOnly = action.payload.userSingleHopOnly
}) })
.addCase(addSerializedToken, (state, { payload: { serializedToken } }) => { .addCase(addSerializedToken, (state, { payload: { serializedToken } }) => {
if (!state.tokens) {
state.tokens = {}
}
state.tokens[serializedToken.chainId] = state.tokens[serializedToken.chainId] || {} state.tokens[serializedToken.chainId] = state.tokens[serializedToken.chainId] || {}
state.tokens[serializedToken.chainId][serializedToken.address] = serializedToken state.tokens[serializedToken.chainId][serializedToken.address] = serializedToken
state.timestamp = currentTimestamp() state.timestamp = currentTimestamp()
}) })
.addCase(removeSerializedToken, (state, { payload: { address, chainId } }) => { .addCase(removeSerializedToken, (state, { payload: { address, chainId } }) => {
if (!state.tokens) {
state.tokens = {}
}
state.tokens[chainId] = state.tokens[chainId] || {} state.tokens[chainId] = state.tokens[chainId] || {}
delete state.tokens[chainId][address] delete state.tokens[chainId][address]
state.timestamp = currentTimestamp() state.timestamp = currentTimestamp()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment