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

add typechain gen scripts (#36)

add typechain generation for core/periphery contracts
parent 878fc9cf
# See https://help.github.com/ignore-files/ for more about ignoring files. # See https://help.github.com/ignore-files/ for more about ignoring files.
# generated contract types
/src/types/v3
# dependencies # dependencies
/node_modules /node_modules
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"@storybook/react": "^6.1.17", "@storybook/react": "^6.1.17",
"@storybook/theming": "^6.1.17", "@storybook/theming": "^6.1.17",
"@styled-system/css": "^5.1.5", "@styled-system/css": "^5.1.5",
"@typechain/ethers-v5": "^6.0.5",
"@types/jest": "^25.2.1", "@types/jest": "^25.2.1",
"@types/lodash.flatmap": "^4.5.6", "@types/lodash.flatmap": "^4.5.6",
"@types/luxon": "^1.24.4", "@types/luxon": "^1.24.4",
...@@ -36,15 +37,19 @@ ...@@ -36,15 +37,19 @@
"@types/styled-components": "^5.1.0", "@types/styled-components": "^5.1.0",
"@types/testing-library__cypress": "^5.0.5", "@types/testing-library__cypress": "^5.0.5",
"@types/wcag-contrast": "^3.0.0", "@types/wcag-contrast": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^2.31.0", "@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^2.31.0", "@typescript-eslint/parser": "^4.20.0",
"@uniswap/default-token-list": "^2.0.0",
"@uniswap/governance": "^1.0.2", "@uniswap/governance": "^1.0.2",
"@uniswap/liquidity-staker": "^1.0.2", "@uniswap/liquidity-staker": "^1.0.2",
"@uniswap/merkle-distributor": "1.0.1", "@uniswap/merkle-distributor": "1.0.1",
"@uniswap/sdk-core": "^1.0.8",
"@uniswap/token-lists": "^1.0.0-beta.19", "@uniswap/token-lists": "^1.0.0-beta.19",
"@uniswap/v2-core": "1.0.0", "@uniswap/v2-core": "1.0.0",
"@uniswap/v2-periphery": "^1.1.0-beta.0", "@uniswap/v2-periphery": "^1.1.0-beta.0",
"@uniswap/v3-periphery": "^1.0.0-beta.7", "@uniswap/v2-sdk": "^1.0.6",
"@uniswap/v3-core": "^1.0.0-rc.0",
"@uniswap/v3-periphery": "^1.0.0-beta.11",
"@web3-react/core": "^6.0.9", "@web3-react/core": "^6.0.9",
"@web3-react/fortmatic-connector": "^6.0.9", "@web3-react/fortmatic-connector": "^6.0.9",
"@web3-react/injected-connector": "^6.0.7", "@web3-react/injected-connector": "^6.0.7",
...@@ -67,6 +72,7 @@ ...@@ -67,6 +72,7 @@
"i18next-xhr-backend": "^2.0.1", "i18next-xhr-backend": "^2.0.1",
"inter-ui": "^3.13.1", "inter-ui": "^3.13.1",
"jazzicon": "^1.5.0", "jazzicon": "^1.5.0",
"lightweight-charts": "^3.3.0",
"lodash.flatmap": "^4.5.0", "lodash.flatmap": "^4.5.0",
"luxon": "^1.25.0", "luxon": "^1.25.0",
"multicodec": "^2.0.0", "multicodec": "^2.0.0",
...@@ -97,7 +103,8 @@ ...@@ -97,7 +103,8 @@
"start-server-and-test": "^1.11.0", "start-server-and-test": "^1.11.0",
"styled-components": "^4.2.0", "styled-components": "^4.2.0",
"styled-system": "^5.1.5", "styled-system": "^5.1.5",
"typescript": "^3.8.3", "typechain": "^4.0.3",
"typescript": "^4.2.3",
"use-count-up": "^2.2.5", "use-count-up": "^2.2.5",
"wcag-contrast": "^3.0.0", "wcag-contrast": "^3.0.0",
"workbox-core": "^6.1.0", "workbox-core": "^6.1.0",
...@@ -110,11 +117,13 @@ ...@@ -110,11 +117,13 @@
"@walletconnect/web3-provider": "1.1.1-alpha.0" "@walletconnect/web3-provider": "1.1.1-alpha.0"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "compile-contract-types": "npx typechain --target ethers-v5 --outDir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'",
"start:service-worker": "yarn build && yarn serve -s build", "build": "yarn compile-contract-types && react-scripts build",
"build": "react-scripts build",
"eject": "react-scripts eject", "eject": "react-scripts eject",
"integration-test": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'", "integration-test": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'",
"postinstall": "yarn compile-contract-types",
"start": "yarn compile-contract-types && react-scripts start",
"start:service-worker": "yarn build && yarn serve -s build",
"storybook": "start-storybook -p 6006", "storybook": "start-storybook -p 6006",
"test": "react-scripts test --env=jsdom" "test": "react-scripts test --env=jsdom"
}, },
...@@ -136,11 +145,5 @@ ...@@ -136,11 +145,5 @@
"last 1 safari version" "last 1 safari version"
] ]
}, },
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later"
"dependencies": {
"@uniswap/default-token-list": "^2.0.0",
"@uniswap/sdk-core": "^1.0.8",
"@uniswap/v2-sdk": "^1.0.6",
"lightweight-charts": "^3.3.0"
}
} }
...@@ -128,7 +128,7 @@ export default function Modal({ ...@@ -128,7 +128,7 @@ export default function Modal({
{...(isMobile {...(isMobile
? { ? {
...bind(), ...bind(),
style: { transform: y.interpolate((y) => `translateY(${y > 0 ? y : 0}px)`) }, style: { transform: y.interpolate((y) => `translateY(${(y as number) > 0 ? y : 0}px)`) },
} }
: {})} : {})}
aria-label="dialog content" aria-label="dialog content"
......
...@@ -7,7 +7,7 @@ import { unwrappedToken } from 'utils/wrappedCurrency' ...@@ -7,7 +7,7 @@ import { unwrappedToken } from 'utils/wrappedCurrency'
import styled, { keyframes } from 'styled-components' import styled, { keyframes } from 'styled-components'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { MEDIA_WIDTHS } from 'theme' import { MEDIA_WIDTHS } from 'theme'
import { Position } from 'types/v3' import { Position } from 'types/position'
const ActiveDot = styled.span` const ActiveDot = styled.span`
background-color: ${({ theme }) => theme.success}; background-color: ${({ theme }) => theme.success};
......
...@@ -27,7 +27,7 @@ export class FortmaticConnector extends FortmaticConnectorCore { ...@@ -27,7 +27,7 @@ export class FortmaticConnector extends FortmaticConnectorCore {
const provider = this.fortmatic.getProvider() const provider = this.fortmatic.getProvider()
const pollForOverlayReady = new Promise((resolve) => { const pollForOverlayReady = new Promise<void>((resolve) => {
const interval = setInterval(() => { const interval = setInterval(() => {
if (provider.overlayReady) { if (provider.overlayReady) {
clearInterval(interval) clearInterval(interval)
......
...@@ -89,14 +89,12 @@ class MiniRpcProvider implements AsyncSendable { ...@@ -89,14 +89,12 @@ class MiniRpcProvider implements AsyncSendable {
reject, reject,
request: { method }, request: { method },
} = byKey[result.id] } = byKey[result.id]
if (resolve && reject) { if ('error' in result) {
if ('error' in result) { reject(new RequestError(result?.error?.message, result?.error?.code, result?.error?.data))
reject(new RequestError(result?.error?.message, result?.error?.code, result?.error?.data)) } else if ('result' in result && resolve) {
} else if ('result' in result) { resolve(result.result)
resolve(result.result) } else {
} else { reject(new RequestError(`Received unexpected JSON-RPC response to ${method} request.`, -32000, result))
reject(new RequestError(`Received unexpected JSON-RPC response to ${method} request.`, -32000, result))
}
} }
} }
} }
......
...@@ -8,7 +8,7 @@ import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair. ...@@ -8,7 +8,7 @@ import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair.
import { abi as NFTPositionManagerABI } from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json' import { abi as NFTPositionManagerABI } from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json'
import { NONFUNGIBLE_POSITION_MANAGER_ADDRESSES } from 'constants/v3' import { NONFUNGIBLE_POSITION_MANAGER_ADDRESSES } from 'constants/v3'
import { useMemo } from 'react' import { useMemo } from 'react'
import { NonfungiblePositionManager } from 'types/v3/contracts/NonfungiblePositionManager' import { NonfungiblePositionManager } from 'types/v3/NonfungiblePositionManager'
import { GOVERNANCE_ADDRESS, MERKLE_DISTRIBUTOR_ADDRESS, UNI } from '../constants' import { GOVERNANCE_ADDRESS, MERKLE_DISTRIBUTOR_ADDRESS, UNI } from '../constants'
import { import {
ARGENT_WALLET_DETECTOR_ABI, ARGENT_WALLET_DETECTOR_ABI,
......
import { OptionalMethodInputs, useSingleCallResult, useSingleContractMultipleData } from 'state/multicall/hooks' import { OptionalMethodInputs, useSingleCallResult, useSingleContractMultipleData } from 'state/multicall/hooks'
import { Position } from 'types/v3' import { Position } from 'types/position'
import { useV3NFTPositionManagerContract } from './useContract' import { useV3NFTPositionManagerContract } from './useContract'
interface UseV3PositionsResults { interface UseV3PositionsResults {
......
import { createStore, Store } from 'redux' import { createStore, Store } from 'redux'
import { Field, typeInput } from './actions' import { Field, typeInput } from './actions'
import reducer, { MintState } from './reducer' import reducer, { initialState, MintState } from './reducer'
describe('mint reducer', () => { describe('mint reducer', () => {
let store: Store<MintState> let store: Store<MintState>
beforeEach(() => { beforeEach(() => {
store = createStore(reducer, { store = createStore(reducer, initialState)
independentField: Field.CURRENCY_A,
typedValue: '',
otherTypedValue: '',
})
}) })
describe('typeInput', () => { describe('typeInput', () => {
it('sets typed value', () => { it('sets typed value', () => {
store.dispatch(typeInput({ field: Field.CURRENCY_A, typedValue: '1.0', noLiquidity: false })) store.dispatch(typeInput({ field: Field.CURRENCY_A, typedValue: '1.0', noLiquidity: false }))
expect(store.getState()).toEqual({ independentField: Field.CURRENCY_A, typedValue: '1.0', otherTypedValue: '' }) expect(store.getState()).toEqual({
...initialState,
independentField: Field.CURRENCY_A,
typedValue: '1.0',
otherTypedValue: '',
})
}) })
it('clears other value', () => { it('clears other value', () => {
store.dispatch(typeInput({ field: Field.CURRENCY_A, typedValue: '1.0', noLiquidity: false })) store.dispatch(typeInput({ field: Field.CURRENCY_A, typedValue: '1.0', noLiquidity: false }))
store.dispatch(typeInput({ field: Field.CURRENCY_B, typedValue: '1.0', noLiquidity: false })) store.dispatch(typeInput({ field: Field.CURRENCY_B, typedValue: '1.0', noLiquidity: false }))
expect(store.getState()).toEqual({ independentField: Field.CURRENCY_B, typedValue: '1.0', otherTypedValue: '' }) expect(store.getState()).toEqual({
...initialState,
independentField: Field.CURRENCY_B,
typedValue: '1.0',
otherTypedValue: '',
})
}) })
}) })
}) })
...@@ -18,7 +18,7 @@ export interface MintState { ...@@ -18,7 +18,7 @@ export interface MintState {
readonly rangeType: RangeType readonly rangeType: RangeType
} }
const initialState: MintState = { export const initialState: MintState = {
independentField: Field.CURRENCY_A, independentField: Field.CURRENCY_A,
typedValue: '', typedValue: '',
otherTypedValue: '', otherTypedValue: '',
......
import { Contract } from '@ethersproject/contracts'
export interface NonfungiblePositionManager extends Contract {
balanceOf(address: string): Promise<BigNumber>
tokenOfOwnerByIndex(address: string, index: BigNumber): Promise<BigNumber>
}
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
"moduleResolution": "node", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "react", "jsx": "react-jsx",
"downlevelIteration": true, "downlevelIteration": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"types": ["react-spring", "jest"], "types": ["react-spring", "jest"],
......
This diff is collapsed.
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