Commit edf4c474 authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

add external abi types (#37)

parent c0ce6a55
......@@ -26,6 +26,7 @@
"prettier/prettier": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-ts-ignore": "off"
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
......@@ -2,6 +2,7 @@
# generated contract types
/src/types/v3
/src/abis/types
# dependencies
/node_modules
......
......@@ -117,7 +117,9 @@
"@walletconnect/web3-provider": "1.1.1-alpha.0"
},
"scripts": {
"compile-contract-types": "npx typechain --target ethers-v5 --outDir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'",
"compile-contract-types": "yarn compile-external-abi-types && yarn compile-v3-contract-types",
"compile-external-abi-types": "npx typechain --target ethers-v5 --outDir src/abis/types './src/abis/**/*.json'",
"compile-v3-contract-types": "npx typechain --target ethers-v5 --outDir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'",
"build": "yarn compile-contract-types && react-scripts build",
"eject": "react-scripts eject",
"integration-test": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'",
......
......@@ -89,7 +89,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 22405
"gas": "22405"
},
{
"name": "tokenByIndex",
......@@ -108,7 +108,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 631
"gas": "631"
},
{
"name": "tokenOfOwnerByIndex",
......@@ -131,7 +131,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 1248
"gas": "1248"
},
{
"name": "transferFrom",
......@@ -153,7 +153,7 @@
"constant": false,
"payable": false,
"type": "function",
"gas": 259486
"gas": "259486"
},
{
"name": "safeTransferFrom",
......@@ -217,7 +217,7 @@
"constant": false,
"payable": false,
"type": "function",
"gas": 38422
"gas": "38422"
},
{
"name": "setApprovalForAll",
......@@ -235,7 +235,7 @@
"constant": false,
"payable": false,
"type": "function",
"gas": 38016
"gas": "38016"
},
{
"name": "mint",
......@@ -254,7 +254,7 @@
"constant": false,
"payable": false,
"type": "function",
"gas": 182636
"gas": "182636"
},
{
"name": "changeMinter",
......@@ -268,7 +268,7 @@
"constant": false,
"payable": false,
"type": "function",
"gas": 35897
"gas": "35897"
},
{
"name": "changeURI",
......@@ -282,7 +282,7 @@
"constant": false,
"payable": false,
"type": "function",
"gas": 35927
"gas": "35927"
},
{
"name": "name",
......@@ -296,7 +296,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 6612
"gas": "6612"
},
{
"name": "symbol",
......@@ -310,7 +310,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 6642
"gas": "6642"
},
{
"name": "totalSupply",
......@@ -324,7 +324,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 873
"gas": "873"
},
{
"name": "minter",
......@@ -338,7 +338,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 903
"gas": "903"
},
{
"name": "socks",
......@@ -353,7 +353,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 933
"gas": "933"
},
{
"name": "newURI",
......@@ -367,7 +367,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 963
"gas": "963"
},
{
"name": "ownerOf",
......@@ -386,7 +386,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 1126
"gas": "1126"
},
{
"name": "balanceOf",
......@@ -405,7 +405,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 1195
"gas": "1195"
},
{
"name": "getApproved",
......@@ -424,7 +424,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 1186
"gas": "1186"
},
{
"name": "isApprovedForAll",
......@@ -447,7 +447,7 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 1415
"gas": "1415"
},
{
"name": "supportsInterface",
......@@ -466,6 +466,6 @@
"constant": true,
"payable": false,
"type": "function",
"gas": 1246
"gas": "1246"
}
]
import ARGENT_WALLET_DETECTOR_ABI from './argent-wallet-detector.json'
const ARGENT_WALLET_DETECTOR_MAINNET_ADDRESS = '0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8'
export { ARGENT_WALLET_DETECTOR_ABI, ARGENT_WALLET_DETECTOR_MAINNET_ADDRESS }
import { Interface } from '@ethersproject/abi'
import ERC20_ABI from './erc20.json'
import ERC20_BYTES32_ABI from './erc20_bytes32.json'
const ERC20_INTERFACE = new Interface(ERC20_ABI)
const ERC20_BYTES32_INTERFACE = new Interface(ERC20_BYTES32_ABI)
export default ERC20_INTERFACE
export { ERC20_ABI, ERC20_BYTES32_INTERFACE, ERC20_BYTES32_ABI }
import MIGRATOR_ABI from './migrator.json'
const MIGRATOR_ADDRESS = '0x16D4F26C15f3658ec65B1126ff27DD3dF2a2996b'
export { MIGRATOR_ADDRESS, MIGRATOR_ABI }
......@@ -214,3 +214,7 @@ export const BLOCKED_ADDRESSES: string[] = [
'0xA7e5d5A720f06526557c513402f2e6B5fA20b008',
'0x8576aCC5C05D6Ce88f4e49bf65BdF0C62F91353C',
]
export const ARGENT_WALLET_DETECTOR_MAINNET_ADDRESS = '0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8'
export const MIGRATOR_ADDRESS = '0x16D4F26C15f3658ec65B1126ff27DD3dF2a2996b'
......@@ -6,24 +6,28 @@ import { abi as MERKLE_DISTRIBUTOR_ABI } from '@uniswap/merkle-distributor/build
import { ChainId, WETH9 } from '@uniswap/sdk-core'
import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair.json'
import { abi as NFTPositionManagerABI } from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json'
import ARGENT_WALLET_DETECTOR_ABI from 'abis/argent-wallet-detector.json'
import ENS_PUBLIC_RESOLVER_ABI from 'abis/ens-public-resolver.json'
import ENS_ABI from 'abis/ens-registrar.json'
import ERC20_ABI from 'abis/erc20.json'
import ERC20_BYTES32_ABI from 'abis/erc20_bytes32.json'
import MIGRATOR_ABI from 'abis/migrator.json'
import { Unisocks } from 'abis/types/Unisocks'
import UNISOCKS_ABI from 'abis/unisocks.json'
import WETH_ABI from 'abis/weth.json'
import {
ARGENT_WALLET_DETECTOR_MAINNET_ADDRESS,
GOVERNANCE_ADDRESS,
MERKLE_DISTRIBUTOR_ADDRESS,
MIGRATOR_ADDRESS,
UNI,
} from 'constants/index'
import { MULTICALL_ABI, MULTICALL_NETWORKS } from 'constants/multicall'
import { V1_EXCHANGE_ABI, V1_FACTORY_ABI, V1_FACTORY_ADDRESSES } from 'constants/v1'
import { NONFUNGIBLE_POSITION_MANAGER_ADDRESSES } from 'constants/v3'
import { useMemo } from 'react'
import { NonfungiblePositionManager } from 'types/v3/NonfungiblePositionManager'
import { GOVERNANCE_ADDRESS, MERKLE_DISTRIBUTOR_ADDRESS, UNI } from '../constants'
import {
ARGENT_WALLET_DETECTOR_ABI,
ARGENT_WALLET_DETECTOR_MAINNET_ADDRESS,
} from '../constants/abis/argent-wallet-detector'
import ENS_PUBLIC_RESOLVER_ABI from '../constants/abis/ens-public-resolver.json'
import ENS_ABI from '../constants/abis/ens-registrar.json'
import { ERC20_BYTES32_ABI } from '../constants/abis/erc20'
import ERC20_ABI from '../constants/abis/erc20.json'
import { MIGRATOR_ABI, MIGRATOR_ADDRESS } from '../constants/abis/migrator'
import UNISOCKS_ABI from '../constants/abis/unisocks.json'
import WETH_ABI from '../constants/abis/weth.json'
import { MULTICALL_ABI, MULTICALL_NETWORKS } from '../constants/multicall'
import { V1_EXCHANGE_ABI, V1_FACTORY_ABI, V1_FACTORY_ADDRESSES } from '../constants/v1'
import { getContract } from '../utils'
import { getContract } from 'utils'
import { useActiveWeb3React } from './index'
// returns null on errors
......@@ -123,13 +127,13 @@ export function useStakingContract(stakingAddress?: string, withSignerIfPossible
return useContract(stakingAddress, STAKING_REWARDS_ABI, withSignerIfPossible)
}
export function useSocksController(): Contract | null {
export function useSocksController(): Unisocks | null {
const { chainId } = useActiveWeb3React()
return useContract(
chainId === ChainId.MAINNET ? '0x65770b5283117639760beA3F867b69b3697a91dd' : undefined,
UNISOCKS_ABI,
false
)
) as Unisocks | null
}
export function useV3NFTPositionManagerContract(): NonfungiblePositionManager | null {
......
......@@ -14,8 +14,7 @@ import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount'
import QuestionHelper from '../../components/QuestionHelper'
import { AutoRow, RowBetween, RowFixed } from '../../components/Row'
import { Dots } from '../../components/swap/styleds'
import { DEFAULT_DEADLINE_FROM_NOW, INITIAL_ALLOWED_SLIPPAGE } from '../../constants'
import { MIGRATOR_ADDRESS } from '../../constants/abis/migrator'
import { DEFAULT_DEADLINE_FROM_NOW, INITIAL_ALLOWED_SLIPPAGE, MIGRATOR_ADDRESS } from 'constants/index'
import { PairState, usePair } from '../../data/Reserves'
import { useTotalSupply } from '../../data/TotalSupply'
import { useActiveWeb3React } from '../../hooks'
......
......@@ -13,7 +13,7 @@ interface Window {
removeListener?: (...args: any[]) => void
autoRefreshOnNetworkChange?: boolean
}
web3?: {}
web3?: Record<string, unknown>
}
declare module 'content-hash' {
......
......@@ -3,7 +3,7 @@ import { Pair } from '@uniswap/v2-sdk'
import JSBI from 'jsbi'
import { useMemo } from 'react'
import { DAI, UNI, USDC, USDT, WBTC } from '../../constants'
import { STAKING_REWARDS_INTERFACE } from '../../constants/abis/staking-rewards'
import { STAKING_REWARDS_INTERFACE } from '../../abis/staking-rewards'
import { useActiveWeb3React } from '../../hooks'
import { NEVER_RELOAD, useMultipleContractSingleData } from '../multicall/hooks'
import { tryParseAmount } from '../swap/hooks'
......
import { UNI } from './../../constants/index'
import { Currency, CurrencyAmount, ETHER, Token, TokenAmount } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { useMemo } from 'react'
import ERC20_INTERFACE from '../../constants/abis/erc20'
import { useAllTokens } from '../../hooks/Tokens'
import { useActiveWeb3React } from '../../hooks'
import { useAllTokens } from '../../hooks/Tokens'
import { useMulticallContract } from '../../hooks/useContract'
import { isAddress } from '../../utils'
import { useSingleContractMultipleData, useMultipleContractSingleData } from '../multicall/hooks'
import { useUserUnclaimedAmount } from '../claim/hooks'
import { useMultipleContractSingleData, useSingleContractMultipleData } from '../multicall/hooks'
import { useTotalUniEarned } from '../stake/hooks'
import { UNI } from './../../constants/index'
import { Interface } from '@ethersproject/abi'
import ERC20ABI from 'abis/erc20.json'
import { Erc20Interface } from 'abis/types/Erc20'
/**
* Returns a map of the given addresses to their eventually consistent ETH balances.
*/
......@@ -60,8 +61,8 @@ export function useTokenBalancesWithLoadingIndicator(
)
const validatedTokenAddresses = useMemo(() => validatedTokens.map((vt) => vt.address), [validatedTokens])
const balances = useMultipleContractSingleData(validatedTokenAddresses, ERC20_INTERFACE, 'balanceOf', [address])
const ERC20Interface = new Interface(ERC20ABI) as Erc20Interface
const balances = useMultipleContractSingleData(validatedTokenAddresses, ERC20Interface, 'balanceOf', [address])
const anyLoading: boolean = useMemo(() => balances.some((callState) => callState.loading), [balances])
......
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