Skip to content

Commit

Permalink
refactor: Replace multicall implementation with library (#2768)
Browse files Browse the repository at this point in the history
- Replace the local implementation of multicall with the new redux-multicall lib
- Create wrappers for redux-multicall hooks to inject block number and chainId
  • Loading branch information
jmrossy committed Dec 3, 2021
1 parent e81e8a8 commit 596ea03
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 1,306 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@uniswap/governance": "^1.0.2",
"@uniswap/liquidity-staker": "^1.0.2",
"@uniswap/merkle-distributor": "1.0.1",
"@uniswap/redux-multicall": "^1.0.0",
"@uniswap/sdk-core": "^3.0.1",
"@uniswap/token-lists": "^1.0.0-beta.27",
"@uniswap/v2-core": "1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useV3Positions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BigNumber } from '@ethersproject/bignumber'
import { useMemo } from 'react'
import { Result, useSingleCallResult, useSingleContractMultipleData } from 'state/multicall/hooks'
import { CallStateResult, useSingleCallResult, useSingleContractMultipleData } from 'state/multicall/hooks'
import { PositionDetails } from 'types/position'

import { useV3NFTPositionManagerContract } from './useContract'
Expand All @@ -22,7 +22,7 @@ function useV3PositionsFromTokenIds(tokenIds: BigNumber[] | undefined): UseV3Pos
if (!loading && !error && tokenIds) {
return results.map((call, i) => {
const tokenId = tokenIds[i]
const result = call.result as Result
const result = call.result as CallStateResult
return {
tokenId,
fee: result.fee,
Expand Down Expand Up @@ -90,7 +90,7 @@ export function useV3Positions(account: string | null | undefined): UseV3Positio
if (account) {
return tokenIdResults
.map(({ result }) => result)
.filter((result): result is Result => !!result)
.filter((result): result is CallStateResult => !!result)
.map((result) => BigNumber.from(result[0]))
}
return []
Expand Down
4 changes: 2 additions & 2 deletions src/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import lists from './lists/reducer'
import logs from './logs/slice'
import mint from './mint/reducer'
import mintV3 from './mint/v3/reducer'
import multicall from './multicall/reducer'
import { multicall } from './multicall/instance'
import { routingApi } from './routing/slice'
import swap from './swap/reducer'
import transactions from './transactions/reducer'
Expand All @@ -29,7 +29,7 @@ const store = configureStore({
mintV3,
burn,
burnV3,
multicall,
multicall: multicall.reducer,
lists,
logs,
[dataApi.reducerPath]: dataApi.reducer,
Expand Down
35 changes: 0 additions & 35 deletions src/state/multicall/actions.test.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/state/multicall/actions.ts

This file was deleted.

2 comments on commit 596ea03

@vercel
Copy link

@vercel vercel bot commented on 596ea03 Dec 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

interface – ./

interface-uniswap.vercel.app
interface-git-main-uniswap.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 596ea03 Dec 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

widgets – ./

widgets-uniswap.vercel.app
widgets-git-main-uniswap.vercel.app

Please sign in to comment.