Skip to content

Commit

Permalink
preview
Browse files Browse the repository at this point in the history
  • Loading branch information
woobin committed Jul 17, 2023
2 parents 982e3c0 + 3ba2714 commit 5d5bac3
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 228 deletions.
162 changes: 0 additions & 162 deletions app/.cache/ts-import/home/woobin/Desktop/zoo/app/utils/chains.mjs

This file was deleted.

18 changes: 9 additions & 9 deletions core/config/token-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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/'

Expand All @@ -30,21 +30,21 @@ 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,
...UNSUPPORTED_LIST_URLS, // need to load unsupported tokens as well
]

// 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]
4 changes: 2 additions & 2 deletions core/features/kashi/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions core/hooks/useActiveWeb3React.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@

import { ethers } from "ethers";
import { Web3Provider } from '@ethersproject/providers'
import { ChainId } from '@zoolabs/zdk'
/**
* Dummy for backwards compat
*/
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,
}
}
Expand Down
11 changes: 6 additions & 5 deletions core/hooks/useContract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AddressZero } from "@ethersproject/constants";
import { Web3Provider } from "@ethersproject/providers";
import { Contract } from "@ethersproject/contracts";
import {
AddressMap,
Expand Down Expand Up @@ -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";
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion core/modals/BridgeSearchModal/sorting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion core/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
45 changes: 0 additions & 45 deletions core/state/application/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 5d5bac3

Please sign in to comment.