diff --git a/app/.cache/ts-import/home/woobin/Desktop/zoo/app/utils/chains.mjs b/app/.cache/ts-import/home/woobin/Desktop/zoo/app/utils/chains.mjs deleted file mode 100644 index c27c33314..000000000 --- a/app/.cache/ts-import/home/woobin/Desktop/zoo/app/utils/chains.mjs +++ /dev/null @@ -1,162 +0,0 @@ -import { arbitrum, mainnet, polygon, optimism, bsc } from 'wagmi/chains'; -//Chains that are missing from wagmi: -export const zora = { - id: 7777777, - name: 'Zora', - network: 'zora', - nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, - rpcUrls: { - default: { - http: ['https://rpc.zora.co'], - }, - public: { - http: ['https://rpc.zora.co'], - }, - }, - blockExplorers: { - etherscan: { - name: 'Zora explorer', - url: 'https://explorer.zora.co', - }, - default: { - name: 'Zora explorer', - url: 'https://explorer.zora.co', - }, - }, -}; -//Chains that are missing from wagmi: -export const arbitrumNova = { - id: 42170, - name: 'Arbitrum Nova', - network: 'arbitrum-nova', - nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, - rpcUrls: { - blast: { - http: ['https://arbitrum-nova.public.blastapi.io'], - webSocket: ['wss://arbitrum-nova.public.blastapi.io'], - }, - default: { - http: ['https://nova.arbitrum.io/rpc'], - }, - public: { - http: ['https://nova.arbitrum.io/rpc'], - }, - }, - blockExplorers: { - etherscan: { name: 'Arbiscan', url: 'https://nova.arbiscan.io' }, - blockScout: { - name: 'BlockScout', - url: 'https://nova-explorer.arbitrum.io/', - }, - default: { name: 'Arbiscan', url: 'https://nova.arbiscan.io' }, - }, - contracts: { - multicall3: { - address: '0xca11bde05977b3631167028862be2a173976ca11', - blockCreated: 1746963, - }, - }, -}; -export const DefaultChain = { - ...mainnet, - // Any url to display the logo of the chain in light mode - lightIconUrl: '/icons/eth-icon-dark.svg', - // Any url to display the logo of the chain in dark mode - darkIconUrl: '/icons/eth-icon-light.svg', - // The base url of the reservoir api, this is used in the app when - // directly interacting with the reservoir indexer servers (in the api proxy for example) - // or when prefetching server side rendered data - reservoirBaseUrl: 'https://api.reservoir.tools', - // Used on the client side portions of the marketplace that need an api key added - // Prevents the api key from being leaked in the clientside requests - // If you'd like to disable proxying you can just change the proxyApi to the reservoirBaseUrl - // Doing so will omit the api key unless further changes are made - proxyApi: '/api/reservoir/ethereum', - // A prefix used in the asset specific routes on the app (tokens/collections) - routePrefix: 'ethereum', - // Reservoir API key which you can generate at https://reservoir.tools/ - // This is a protected key and displays as 'undefined' on the browser - // DO NOT add NEXT_PUBLIC to the key or you'll risk leaking it on the browser - apiKey: process.env.ETH_RESERVOIR_API_KEY, - // Coingecko id, used to convert the chain's native prices to usd. Can be found here: - // https://www.coingecko.com/en/api/documentation#operations-coins-get_coins_list - coingeckoId: 'ethereum', - collectionSetId: process.env.NEXT_PUBLIC_ETH_COLLECTION_SET_ID, - community: process.env.NEXT_PUBLIC_ETH_COMMUNITY, -}; -export default [ - DefaultChain, - { - ...polygon, - lightIconUrl: '/icons/polygon-icon-dark.svg', - darkIconUrl: '/icons/polygon-icon-light.svg', - reservoirBaseUrl: 'https://api-polygon.reservoir.tools', - proxyApi: '/api/reservoir/polygon', - routePrefix: 'polygon', - apiKey: process.env.POLYGON_RESERVOIR_API_KEY, - coingeckoId: 'matic-network', - collectionSetId: process.env.NEXT_PUBLIC_POLYGON_COLLECTION_SET_ID, - community: process.env.NEXT_PUBLIC_POLYGON_COMMUNITY, - }, - { - ...arbitrum, - name: 'Arbitrum', - lightIconUrl: '/icons/arbitrum-icon-dark.svg', - darkIconUrl: '/icons/arbitrum-icon-light.svg', - reservoirBaseUrl: 'https://api-arbitrum.reservoir.tools', - proxyApi: '/api/reservoir/arbitrum', - routePrefix: 'arbitrum', - apiKey: process.env.ARBITRUM_RESERVOIR_API_KEY, - coingeckoId: 'arbitrum-iou', - collectionSetId: process.env.NEXT_PUBLIC_ARBITRUM_COLLECTION_SET_ID, - community: process.env.NEXT_PUBLIC_ARBITRUM_COMMUNITY, - }, - { - ...arbitrumNova, - lightIconUrl: '/icons/arbitrum-nova-icon-dark.svg', - darkIconUrl: '/icons/arbitrum-nova-icon-light.svg', - reservoirBaseUrl: 'https://api-arbitrum-nova.reservoir.tools', - proxyApi: '/api/reservoir/arbitrum-nova', - routePrefix: 'arbitrum-nova', - apiKey: process.env.ARBITRUM_NOVA_RESERVOIR_API_KEY, - coingeckoId: 'ethereum', - collectionSetId: process.env.NEXT_PUBLIC_ARBITRUM_NOVA_COLLECTION_SET_ID, - community: process.env.NEXT_PUBLIC_ARBITRUM_NOVA_COMMUNITY, - }, - { - ...optimism, - name: 'Optimism', - lightIconUrl: '/icons/optimism-icon-dark.svg', - darkIconUrl: '/icons/optimism-icon-light.svg', - reservoirBaseUrl: 'https://api-optimism.reservoir.tools', - proxyApi: '/api/reservoir/optimism', - routePrefix: 'optimism', - apiKey: process.env.OPTIMISM_RESERVOIR_API_KEY, - coingeckoId: 'optimism', - collectionSetId: process.env.NEXT_PUBLIC_OPTIMISM_COLLECTION_SET_ID, - community: process.env.NEXT_PUBLIC_OPTIMISM_COMMUNITY, - }, - { - ...zora, - name: 'Zora', - lightIconUrl: '/icons/zora-icon-dark.svg', - darkIconUrl: '/icons/zora-icon-light.svg', - reservoirBaseUrl: 'https://api-zora.reservoir.tools', - proxyApi: '/api/reservoir/zora', - routePrefix: 'zora', - apiKey: process.env.ZORA_RESERVOIR_API_KEY, - coingeckoId: 'ethereum', - }, - { - ...bsc, - lightIconUrl: '/icons/bsc-icon-dark.svg', - darkIconUrl: '/icons/bsc-icon-light.svg', - reservoirBaseUrl: 'https://api-bsc.reservoir.tools', - proxyApi: '/api/reservoir/bsc', - routePrefix: 'bsc', - apiKey: process.env.BSC_RESERVOIR_API_KEY, - coingeckoId: 'binancecoin', - collectionSetId: process.env.NEXT_PUBLIC_BSC_COLLECTION_SET_ID, - community: process.env.NEXT_PUBLIC_BSC_COMMUNITY, - }, -]; diff --git a/core/config/token-lists.ts b/core/config/token-lists.ts index dda12ec6b..f381e2997 100644 --- a/core/config/token-lists.ts +++ b/core/config/token-lists.ts @@ -6,10 +6,10 @@ const BA_LIST = 'https://raw.githubusercontent.com/The-Blockchain-Association/se */ export const UNSUPPORTED_LIST_URLS: string[] = [BA_LIST] -const YEARN_LIST = 'https://yearn.science/static/tokenlist.json' -const NFTX_LIST = 'https://nftx.ethereumdb.com/v2/tokenlist/' +//const YEARN_LIST = 'https://yearn.science/static/tokenlist.json' +//const NFTX_LIST = 'https://nftx.ethereumdb.com/v2/tokenlist/' const SYNTHETIX_LIST = 'synths.snx.eth' -const OPYN_LIST = 'https://raw.githubusercontent.com/opynfinance/opyn-tokenlist/master/opyn-v1.tokenlist.json' +//const OPYN_LIST = 'https://raw.githubusercontent.com/opynfinance/opyn-tokenlist/master/opyn-v1.tokenlist.json' const AAVE_LIST = 'tokenlist.aave.eth' const CMC_ALL_LIST = 'defi.cmc.eth' const CMC_STABLECOIN = 'stablecoin.cmc.eth' @@ -20,7 +20,7 @@ const KLEROS_LIST = 't2crtokens.eth' export const OPTIMISM_LIST = 'https://static.optimism.io/optimism.tokenlist.json' const ROLL_LIST = 'https://app.tryroll.com/tokens.json' const SET_LIST = 'https://raw.githubusercontent.com/SetProtocol/uniswap-tokenlist/main/set.tokenlist.json' -const UMA_LIST = 'https://umaproject.org/uma.tokenlist.json' +//const UMA_LIST = 'https://umaproject.org/uma.tokenlist.json' const WRAPPED_LIST = 'wrapped.tokensoft.eth' const DHEDGE_LIST = 'https://list.dhedge.eth.link/' @@ -30,16 +30,16 @@ export const DEFAULT_LIST_OF_LISTS: string[] = [ AAVE_LIST, CMC_ALL_LIST, CMC_STABLECOIN, - UMA_LIST, - YEARN_LIST, + //UMA_LIST, + //YEARN_LIST, SYNTHETIX_LIST, WRAPPED_LIST, SET_LIST, ROLL_LIST, COINGECKO_LIST, KLEROS_LIST, - OPYN_LIST, - NFTX_LIST, + //OPYN_LIST, + //NFTX_LIST, OPTIMISM_LIST, GEMINI_LIST, DHEDGE_LIST, @@ -47,4 +47,4 @@ export const DEFAULT_LIST_OF_LISTS: string[] = [ ] // default lists to be 'active' aka searched across -export const DEFAULT_ACTIVE_LIST_URLS: string[] = [NFTX_LIST, YEARN_LIST, GEMINI_LIST] +export const DEFAULT_ACTIVE_LIST_URLS: string[] = [GEMINI_LIST] diff --git a/core/features/kashi/context/index.tsx b/core/features/kashi/context/index.tsx index a5e753fa8..c1c704db0 100644 --- a/core/features/kashi/context/index.tsx +++ b/core/features/kashi/context/index.tsx @@ -272,7 +272,7 @@ export function KashiProvider({ children }) { const allPairAddresses = logPairs .filter((pair) => { - const oracle = getOracle(pair, chainId, tokens); + const oracle = getOracle(pair, chainId, Object.values(tokens)); if (!oracle.valid) { // console.log(pair, oracle.valid, oracle.error) @@ -533,7 +533,7 @@ export function KashiProvider({ children }) { "/" + pair.collateral.tokenInfo.symbol; - pair.oracle = getOracle(pair, chainId, tokens); + pair.oracle = getOracle(pair, chainId, Object.values(tokens)); pair.interestPerYear = { value: pair.interestPerYear, diff --git a/core/hooks/useActiveWeb3React.ts b/core/hooks/useActiveWeb3React.ts index 3fd680397..27a534236 100644 --- a/core/hooks/useActiveWeb3React.ts +++ b/core/hooks/useActiveWeb3React.ts @@ -1,4 +1,5 @@ - +import { ethers } from "ethers"; +import { Web3Provider } from '@ethersproject/providers' import { ChainId } from '@zoolabs/zdk' /** * Dummy for backwards compat @@ -6,13 +7,15 @@ import { ChainId } from '@zoolabs/zdk' export function useActiveWeb3React(): { account: string chainId: ChainId - library: any + library: Web3Provider connector: any } { + + const provider = new ethers.providers.Web3Provider(window.ethereum) return { account: '0x0000000000000000000000', chainId: 1, - library: {}, + library: provider, connector: null, } } diff --git a/core/hooks/useContract.ts b/core/hooks/useContract.ts index 14f4facc3..9aca0871e 100644 --- a/core/hooks/useContract.ts +++ b/core/hooks/useContract.ts @@ -1,4 +1,5 @@ import { AddressZero } from "@ethersproject/constants"; +import { Web3Provider } from "@ethersproject/providers"; import { Contract } from "@ethersproject/contracts"; import { AddressMap, @@ -80,7 +81,7 @@ export function useContract( ): Contract | null { const { library, account, chainId } = useActiveWeb3React(); - const provider = ethers.getDefaultProvider() + //const provider = ethers.getDefaultProvider() let address: string | AddressMap | undefined = nameOrAddress; let chainIdStr = chainId ? chainId.toString() : "1"; @@ -93,22 +94,22 @@ export function useContract( : null; } - const newLibrary = library ?? (canUseDefaultProvider && provider); + //const newLibrary = library ?? (canUseDefaultProvider && provider); return useMemo(() => { - if (!address || !ABI || !newLibrary) return null; + if (!address || !ABI || !library) return null; try { return getContract( altAddress ?? address.toString(), ABI, - newLibrary, + library, withSignerIfPossible && account ? account : undefined ); } catch (error) { console.error("Failed to get contract", error); return null; } - }, [address, ABI, newLibrary, withSignerIfPossible, account]); + }, [address, ABI, library, withSignerIfPossible, account]); } export function useApp(): Contract | null { diff --git a/core/modals/BridgeSearchModal/sorting.ts b/core/modals/BridgeSearchModal/sorting.ts index e95293c80..20554fe44 100644 --- a/core/modals/BridgeSearchModal/sorting.ts +++ b/core/modals/BridgeSearchModal/sorting.ts @@ -39,7 +39,8 @@ function getTokenComparator(balances: Balance[]): (tokenA: Token, tokenB: Token) export function useTokenComparator(inverted: boolean): (tokenA: Token, tokenB: Token) => number { const balances = useAllTokenBalances() - const comparator = useMemo(() => getTokenComparator(balances ?? Balance[]), [balances]) + const allBalances = Object.values(balances).flat(); + const comparator = useMemo(() => getTokenComparator(allBalances), [balances]) return useMemo(() => { if (inverted) { diff --git a/core/pages/_app.tsx b/core/pages/_app.tsx index 27237eb63..20c34f190 100644 --- a/core/pages/_app.tsx +++ b/core/pages/_app.tsx @@ -25,7 +25,6 @@ import NextNProgress from 'nextjs-progressbar' // import Web3ReactManager from "../components/Web3ReactManager"; // import { Web3ReactProvider } from "@web3-react/core"; import dynamic from "next/dynamic"; -import getLibrary from "../functions/getLibrary"; import { i18n } from "@lingui/core"; import { nanoid } from "@reduxjs/toolkit"; import { remoteLoader } from "@lingui/remote-loader"; diff --git a/core/state/application/updater.ts b/core/state/application/updater.ts index d2cdc19af..62061639d 100644 --- a/core/state/application/updater.ts +++ b/core/state/application/updater.ts @@ -19,50 +19,5 @@ export default function Updater(): null { blockNumber: null, }) - const blockNumberCallback = useCallback( - (blockNumber: number) => { - setState((state) => { - if (chainId === state.chainId) { - if (typeof state.blockNumber !== 'number') return { chainId, blockNumber } - return { - chainId, - blockNumber: Math.max(blockNumber, state.blockNumber), - } - } - return state - }) - }, - [chainId, setState] - ) - - // attach/detach listeners - useEffect(() => { - if (!library || !chainId || !windowVisible) return undefined - - setState({ chainId, blockNumber: null }) - - library - .getBlockNumber() - .then(blockNumberCallback) - .catch((error) => console.error(`Failed to get block number for chainId: ${chainId}`, error)) - - library.on('block', blockNumberCallback) - return () => { - library.removeListener('block', blockNumberCallback) - } - }, [dispatch, chainId, library, blockNumberCallback, windowVisible]) - - const debouncedState = useDebounce(state, 100) - - useEffect(() => { - if (!debouncedState.chainId || !debouncedState.blockNumber || !windowVisible) return - dispatch( - updateBlockNumber({ - chainId: debouncedState.chainId, - blockNumber: debouncedState.blockNumber, - }) - ) - }, [windowVisible, dispatch, debouncedState.blockNumber, debouncedState.chainId]) - return null }