Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove censorship #4

Merged
merged 5 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions scripts/fetch-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@

const exec = promisify(child_process.exec)

function fetchSchema(url, outputFile) {
exec(`yarn --silent get-graphql-schema --h Origin=https://app.uniswap.org ${url}`)
.then(({ stderr, stdout }) => {
if (stderr) {
throw new Error(stderr)
} else {
fs.writeFile(outputFile, stdout)
}
})
.catch((err) => {
console.error(err)
console.error(`Failed to fetch schema from ${url}`)
})
async function fetchSchema(url, outputFile) {
try {
const { stdout } = await exec(`yarn --silent get-graphql-schema --h Origin=https://app.uniswap.org ${url}`);

Check failure on line 14 in scripts/fetch-schema.js

View workflow job for this annotation

GitHub Actions / lint

Delete `;`
await fs.writeFile(outputFile, stdout);

Check failure on line 15 in scripts/fetch-schema.js

View workflow job for this annotation

GitHub Actions / lint

Delete `;`
} catch(err){

Check failure on line 16 in scripts/fetch-schema.js

View workflow job for this annotation

GitHub Actions / lint

Replace `(err)` with `·(err)·`
console.error(`Failed to fetch schema from ${url}`)
}
}

fetchSchema(process.env.THE_GRAPH_SCHEMA_ENDPOINT, thegraphConfig.schema)
Expand Down
5 changes: 0 additions & 5 deletions src/constants/lists.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export const UNI_LIST = 'https://cloudflare-ipfs.com/ipns/tokens.uniswap.org'
export const UNI_EXTENDED_LIST = 'https://cloudflare-ipfs.com/ipns/extendedtokens.uniswap.org'
const UNI_UNSUPPORTED_LIST = 'https://cloudflare-ipfs.com/ipns/unsupportedtokens.uniswap.org'
const AAVE_LIST = 'tokenlist.aave.eth'
const BA_LIST = 'https://raw.githubusercontent.com/The-Blockchain-Association/sec-notice-list/master/ba-sec-list.json'
// TODO(WEB-2282): Re-enable CMC list once we have a better solution for handling large lists.
// const CMC_ALL_LIST = 'https://s3.coinmarketcap.com/generated/dex/tokens/eth-tokens-all.json'
const COINGECKO_LIST = 'https://tokens.coingecko.com/uniswap/all.json'
Expand All @@ -27,8 +25,6 @@ export const AVALANCHE_LIST =
export const BASE_LIST =
'https://raw.githubusercontent.com/ethereum-optimism/ethereum-optimism.github.io/master/optimism.tokenlist.json'

export const UNSUPPORTED_LIST_URLS: string[] = [BA_LIST, UNI_UNSUPPORTED_LIST]

// default lists to be 'active' aka searched across
export const DEFAULT_ACTIVE_LIST_URLS: string[] = [UNI_LIST]
export const DEFAULT_INACTIVE_LIST_URLS: string[] = [
Expand All @@ -53,7 +49,6 @@ export const DEFAULT_INACTIVE_LIST_URLS: string[] = [
PLASMA_BNB_LIST,
AVALANCHE_LIST,
BASE_LIST,
...UNSUPPORTED_LIST_URLS,
]

export const DEFAULT_LIST_OF_LISTS: string[] = [...DEFAULT_ACTIVE_LIST_URLS, ...DEFAULT_INACTIVE_LIST_URLS]
2 changes: 1 addition & 1 deletion src/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
* These are the URLs used by the interface when there is not another available source of chain data.
*/
export const RPC_URLS = {
[ChainId.MAINNET]: [

Check failure on line 129 in src/constants/networks.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎····`https://rpc.mevblocker.io/fast`,⏎····QUICKNODE_MAINNET_RPC_URL,⏎····...FALLBACK_URLS[ChainId.MAINNET],⏎··` with ``https://rpc.mevblocker.io/fast`,·QUICKNODE_MAINNET_RPC_URL,·...FALLBACK_URLS[ChainId.MAINNET]`
`https://mainnet.infura.io/v3/${INFURA_KEY}`,
`https://rpc.mevblocker.io/fast`,
QUICKNODE_MAINNET_RPC_URL,
...FALLBACK_URLS[ChainId.MAINNET],
],
Expand Down
4 changes: 0 additions & 4 deletions src/constants/tokenSafety.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
canProceed: false,
}

export function checkWarning(tokenAddress: string, chainId?: number | null) {

Check failure on line 87 in src/constants/tokenSafety.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Not all code paths return a value.
if (tokenAddress === NATIVE_CHAIN_ID || tokenAddress === ZERO_ADDRESS) {
return null
}
Expand All @@ -93,10 +93,6 @@
return null
case TOKEN_LIST_TYPES.UNI_EXTENDED:
return MediumWarning
case TOKEN_LIST_TYPES.UNKNOWN:
return StrongWarning
case TOKEN_LIST_TYPES.BLOCKED:
return BlockedWarning
case TOKEN_LIST_TYPES.BROKEN:
return BlockedWarning
}
Expand Down
10 changes: 1 addition & 9 deletions src/constants/tokenSafetyLookup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TokenInfo } from '@uniswap/token-lists'

Check warning on line 1 in src/constants/tokenSafetyLookup.ts

View workflow job for this annotation

GitHub Actions / lint

'TokenInfo' is defined but never used

Check failure on line 1 in src/constants/tokenSafetyLookup.ts

View workflow job for this annotation

GitHub Actions / lint

'TokenInfo' is defined but never used
import { ListsState } from 'state/lists/reducer'

import store from '../state'
import { UNI_EXTENDED_LIST, UNI_LIST, UNSUPPORTED_LIST_URLS } from './lists'
import { UNI_EXTENDED_LIST, UNI_LIST } from './lists'
import { COMMON_BASES } from './routing'
import brokenTokenList from './tokenLists/broken.tokenlist.json'
import { NATIVE_CHAIN_ID } from './tokens'
Expand Down Expand Up @@ -37,14 +37,6 @@
brokenTokenList.tokens.forEach((token) => {
this.dict[token.address.toLowerCase()] = TOKEN_LIST_TYPES.BROKEN
})

// Initialize blocked tokens from all urls included
UNSUPPORTED_LIST_URLS.map((url) => lists.byUrl[url]?.current?.tokens)
.filter((x): x is TokenInfo[] => !!x)
.flat(1)
.forEach((token) => {
this.dict[token.address.toLowerCase()] = TOKEN_LIST_TYPES.BLOCKED
})
}

checkToken(address: string, chainId?: number | null) {
Expand Down
7 changes: 2 additions & 5 deletions src/state/lists/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sortByListPriority from 'utils/listSort'

import BROKEN_LIST from '../../constants/tokenLists/broken.tokenlist.json'
import { DEFAULT_ACTIVE_LIST_URLS, UNSUPPORTED_LIST_URLS } from './../../constants/lists'
import { DEFAULT_ACTIVE_LIST_URLS } from './../../constants/lists'

type Mutable<T> = {
-readonly [P in keyof T]: Mutable<T[P]>
Expand Down Expand Up @@ -75,9 +75,6 @@
// get hard-coded broken tokens
const brokenListMap = useMemo(() => tokensToChainTokenMap(BROKEN_LIST), [])

// get dynamic list of unsupported tokens
const loadedUnsupportedListMap = useCombinedTokenMapFromUrls(UNSUPPORTED_LIST_URLS)

// format into one token address map
return useMemo(() => combineMaps(brokenListMap, loadedUnsupportedListMap), [brokenListMap, loadedUnsupportedListMap])
return brokenListMap;

Check failure on line 79 in src/state/lists/hooks.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `;`
}
12 changes: 2 additions & 10 deletions src/state/lists/updater.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getVersionUpgrade, VersionUpgrade } from '@uniswap/token-lists'
import { useWeb3React } from '@web3-react/core'
import { DEFAULT_LIST_OF_LISTS, UNSUPPORTED_LIST_URLS } from 'constants/lists'
import { DEFAULT_LIST_OF_LISTS } from 'constants/lists'
import TokenSafetyLookupTable from 'constants/tokenSafetyLookup'
import { useStateRehydrated } from 'hooks/useStateRehydrated'
import useInterval from 'lib/hooks/useInterval'
Expand Down Expand Up @@ -32,7 +32,7 @@ export default function Updater(): null {
if (!isWindowVisible) return
DEFAULT_LIST_OF_LISTS.forEach((url) => {
// Skip validation on unsupported lists
const isUnsupportedList = UNSUPPORTED_LIST_URLS.includes(url)
const isUnsupportedList = false
fetchList(url, isUnsupportedList).catch((error) => console.debug('interval list fetching error', error))
})
}, [fetchList, isWindowVisible])
Expand All @@ -50,14 +50,6 @@ export default function Updater(): null {
fetchList(listUrl).catch((error) => console.debug('list added fetching error', error))
}
})
UNSUPPORTED_LIST_URLS.forEach((listUrl) => {
const list = lists[listUrl]
if (!list || (!list.current && !list.loadingRequestId && !list.error)) {
fetchList(listUrl, /* isUnsupportedList= */ true).catch((error) =>
console.debug('list added fetching error', error)
)
}
})
}, [dispatch, fetchList, lists, rehydrated])

// automatically update lists for every version update
Expand Down
Loading