Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
322cdaf8
Unverified
Commit
322cdaf8
authored
Jun 30, 2022
by
Vignesh Mohankumar
Committed by
GitHub
Jun 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: rm useActiveWeb3React (#4004)
* rm activeweb3react * wrap in web3provider?
parent
edcdbfd8
Changes
110
Show whitespace changes
Inline
Side-by-side
Showing
110 changed files
with
254 additions
and
261 deletions
+254
-261
Transaction.tsx
src/components/AccountDetails/Transaction.tsx
+2
-2
index.tsx
src/components/AccountDetails/index.tsx
+2
-2
index.tsx
src/components/AddressInputPanel/index.tsx
+2
-2
index.tsx
src/components/Blocklist/index.tsx
+2
-2
index.tsx
src/components/CurrencyInputPanel/index.tsx
+2
-2
index.tsx
src/components/DowntimeWarning/index.tsx
+2
-2
index.tsx
src/components/FeeSelector/index.tsx
+2
-2
ChainConnectivityWarning.tsx
src/components/Header/ChainConnectivityWarning.tsx
+2
-2
NetworkSelector.tsx
src/components/Header/NetworkSelector.tsx
+3
-3
Polling.tsx
src/components/Header/Polling.tsx
+2
-2
index.tsx
src/components/Header/index.tsx
+2
-2
index.tsx
src/components/Identicon/index.tsx
+2
-2
index.tsx
src/components/Menu/index.tsx
+2
-2
index.tsx
src/components/ModalViews/index.tsx
+2
-2
NetworkAlert.tsx
src/components/NetworkAlert/NetworkAlert.tsx
+2
-2
ClaimPopup.tsx
src/components/Popups/ClaimPopup.tsx
+2
-2
TransactionPopup.tsx
src/components/Popups/TransactionPopup.tsx
+2
-2
index.tsx
src/components/Popups/index.tsx
+2
-2
V2.tsx
src/components/PositionCard/V2.tsx
+2
-2
index.tsx
src/components/PositionCard/index.tsx
+3
-3
CurrencySearch.tsx
src/components/SearchModal/CurrencySearch.tsx
+2
-2
ManageLists.tsx
src/components/SearchModal/ManageLists.tsx
+3
-3
ManageTokens.tsx
src/components/SearchModal/ManageTokens.tsx
+2
-2
TokenImportCard.tsx
src/components/SearchModal/TokenImportCard.tsx
+2
-2
index.tsx
src/components/Settings/index.tsx
+2
-2
index.tsx
src/components/TopLevelModals/index.tsx
+2
-2
index.tsx
src/components/TransactionConfirmationModal/index.tsx
+3
-3
index.tsx
src/components/TransactionSettings/index.tsx
+2
-2
index.ts
src/components/analytics/index.ts
+2
-2
AddressClaimModal.tsx
src/components/claim/AddressClaimModal.tsx
+2
-2
ClaimModal.tsx
src/components/claim/ClaimModal.tsx
+2
-2
ClaimRewardModal.tsx
src/components/earn/ClaimRewardModal.tsx
+2
-2
StakingModal.tsx
src/components/earn/StakingModal.tsx
+2
-2
UnstakingModal.tsx
src/components/earn/UnstakingModal.tsx
+2
-2
AdvancedSwapDetails.tsx
src/components/swap/AdvancedSwapDetails.tsx
+2
-2
SwapDetailsDropdown.tsx
src/components/swap/SwapDetailsDropdown.tsx
+2
-2
SwapRoute.tsx
src/components/swap/SwapRoute.tsx
+2
-2
UnsupportedCurrencyFooter.tsx
src/components/swap/UnsupportedCurrencyFooter.tsx
+2
-2
DelegateModal.tsx
src/components/vote/DelegateModal.tsx
+2
-2
ExecuteModal.tsx
src/components/vote/ExecuteModal.tsx
+2
-2
ProposalEmptyState.tsx
src/components/vote/ProposalEmptyState.tsx
+2
-2
QueueModal.tsx
src/components/vote/QueueModal.tsx
+2
-2
VoteModal.tsx
src/components/vote/VoteModal.tsx
+2
-2
Tokens.ts
src/hooks/Tokens.ts
+4
-4
useActiveWeb3React.ts
src/hooks/useActiveWeb3React.ts
+0
-6
useAllV3Routes.ts
src/hooks/useAllV3Routes.ts
+2
-2
useArgentWalletContract.ts
src/hooks/useArgentWalletContract.ts
+2
-2
useAutoRouterSupported.tsx
src/hooks/useAutoRouterSupported.tsx
+2
-2
useAutoSlippageTolerance.ts
src/hooks/useAutoSlippageTolerance.ts
+2
-2
useClientSideV3Trade.ts
src/hooks/useClientSideV3Trade.ts
+2
-2
useContract.ts
src/hooks/useContract.ts
+4
-4
useENSAvatar.ts
src/hooks/useENSAvatar.ts
+3
-3
useERC20Permit.ts
src/hooks/useERC20Permit.ts
+3
-3
useIsArgentWallet.ts
src/hooks/useIsArgentWallet.ts
+2
-2
usePools.ts
src/hooks/usePools.ts
+2
-2
useSocksBalance.ts
src/hooks/useSocksBalance.ts
+2
-2
useSwapCallArguments.tsx
src/hooks/useSwapCallArguments.tsx
+2
-2
useSwapCallback.tsx
src/hooks/useSwapCallback.tsx
+2
-2
useTokenInfoFromActiveList.ts
src/hooks/useTokenInfoFromActiveList.ts
+2
-2
useTransactionDeadline.ts
src/hooks/useTransactionDeadline.ts
+2
-2
useUSDCPrice.ts
src/hooks/useUSDCPrice.ts
+2
-2
useV3SwapPools.ts
src/hooks/useV3SwapPools.ts
+2
-2
useWrapCallback.tsx
src/hooks/useWrapCallback.tsx
+2
-2
multicall.ts
src/lib/hooks/multicall.ts
+2
-2
useSwapApproval.ts
src/lib/hooks/swap/useSwapApproval.ts
+3
-3
useSwapCallback.tsx
src/lib/hooks/swap/useSwapCallback.tsx
+2
-2
updater.tsx
src/lib/hooks/transactions/updater.tsx
+2
-2
useApproval.ts
src/lib/hooks/useApproval.ts
+3
-3
useBlockNumber.tsx
src/lib/hooks/useBlockNumber.tsx
+2
-2
useCurrency.ts
src/lib/hooks/useCurrency.ts
+3
-3
useCurrencyBalance.ts
src/lib/hooks/useCurrencyBalance.ts
+2
-2
useIsValidBlock.ts
src/lib/hooks/useIsValidBlock.ts
+3
-3
useNativeCurrency.ts
src/lib/hooks/useNativeCurrency.ts
+2
-2
multicall.tsx
src/lib/state/multicall.tsx
+2
-2
index.tsx
src/pages/AddLiquidity/index.tsx
+2
-2
redirects.tsx
src/pages/AddLiquidity/redirects.tsx
+2
-2
index.tsx
src/pages/AddLiquidityV2/index.tsx
+2
-2
index.tsx
src/pages/CreateProposal/index.tsx
+2
-2
Manage.tsx
src/pages/Earn/Manage.tsx
+2
-2
index.tsx
src/pages/Earn/index.tsx
+2
-2
MigrateV2Pair.tsx
src/pages/MigrateV2/MigrateV2Pair.tsx
+3
-3
index.tsx
src/pages/MigrateV2/index.tsx
+2
-2
CTACards.tsx
src/pages/Pool/CTACards.tsx
+2
-2
PositionPage.tsx
src/pages/Pool/PositionPage.tsx
+2
-2
index.tsx
src/pages/Pool/index.tsx
+2
-2
v2.tsx
src/pages/Pool/v2.tsx
+2
-2
index.tsx
src/pages/PoolFinder/index.tsx
+2
-2
V3.tsx
src/pages/RemoveLiquidity/V3.tsx
+2
-2
index.tsx
src/pages/RemoveLiquidity/index.tsx
+2
-2
index.tsx
src/pages/Swap/index.tsx
+2
-2
Landing.tsx
src/pages/Vote/Landing.tsx
+2
-2
VotePage.tsx
src/pages/Vote/VotePage.tsx
+2
-2
updater.ts
src/state/application/updater.ts
+2
-2
hooks.tsx
src/state/burn/hooks.tsx
+2
-2
hooks.tsx
src/state/burn/v3/hooks.tsx
+2
-2
hooks.ts
src/state/claim/hooks.ts
+4
-4
hooks.ts
src/state/governance/hooks.ts
+13
-13
updater.ts
src/state/lists/updater.ts
+2
-2
hooks.ts
src/state/logs/hooks.ts
+2
-2
updater.ts
src/state/logs/updater.ts
+2
-2
hooks.tsx
src/state/mint/hooks.tsx
+2
-2
hooks.tsx
src/state/mint/v3/hooks.tsx
+2
-2
hooks.tsx
src/state/stake/hooks.tsx
+4
-4
hooks.tsx
src/state/swap/hooks.tsx
+3
-3
hooks.tsx
src/state/transactions/hooks.tsx
+3
-3
updater.tsx
src/state/transactions/updater.tsx
+2
-2
hooks.tsx
src/state/user/hooks.tsx
+4
-4
hooks.ts
src/state/wallet/hooks.ts
+3
-3
test-utils.tsx
src/test-utils.tsx
+3
-4
RadialGradientByChainUpdater.ts
src/theme/RadialGradientByChainUpdater.ts
+2
-2
No files found.
src/components/AccountDetails/Transaction.tsx
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
CheckCircle
,
Triangle
}
from
'
react-feather
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -35,7 +35,7 @@ const IconWrapper = styled.div<{ pending: boolean; success?: boolean }>`
`
export
default
function
Transaction
({
hash
}:
{
hash
:
string
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
allTransactions
=
useAllTransactions
()
const
tx
=
allTransactions
?.[
hash
]
...
...
src/components/AccountDetails/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
Connector
}
from
'
@web3-react/types
'
import
CopyHelper
from
'
components/AccountDetails/Copy
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useCallback
,
useContext
}
from
'
react
'
import
{
ExternalLink
as
LinkIcon
}
from
'
react-feather
'
import
{
useAppDispatch
}
from
'
state/hooks
'
...
...
@@ -226,7 +226,7 @@ export default function AccountDetails({
ENSName
,
openOptions
,
}:
AccountDetailsProps
)
{
const
{
chainId
,
account
,
connector
}
=
use
Active
Web3React
()
const
{
chainId
,
account
,
connector
}
=
useWeb3React
()
const
theme
=
useContext
(
ThemeContext
)
const
dispatch
=
useAppDispatch
()
...
...
src/components/AddressInputPanel/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
// eslint-disable-next-line no-restricted-imports
import
{
t
}
from
'
@lingui/macro
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ReactNode
,
useCallback
,
useContext
}
from
'
react
'
import
styled
,
{
ThemeContext
}
from
'
styled-components/macro
'
...
...
@@ -86,7 +86,7 @@ export default function AddressInputPanel({
// triggers whenever the typed value changes
onChange
:
(
value
:
string
)
=>
void
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
theme
=
useContext
(
ThemeContext
)
const
{
address
,
loading
,
name
}
=
useENS
(
value
)
...
...
src/components/Blocklist/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ReactNode
,
useMemo
}
from
'
react
'
const
BLOCKED_ADDRESSES
:
string
[]
=
[
...
...
@@ -38,7 +38,7 @@ const BLOCKED_ADDRESSES: string[] = [
]
export
default
function
Blocklist
({
children
}:
{
children
:
ReactNode
})
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
blocked
:
boolean
=
useMemo
(()
=>
Boolean
(
account
&&
BLOCKED_ADDRESSES
.
indexOf
(
account
)
!==
-
1
),
[
account
])
if
(
blocked
)
{
return
(
...
...
src/components/CurrencyInputPanel/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
AutoColumn
}
from
'
components/Column
'
import
{
LoadingOpacityContainer
,
loadingOpacityMixin
}
from
'
components/Loader/styled
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
darken
}
from
'
polished
'
import
{
ReactNode
,
useCallback
,
useState
}
from
'
react
'
import
{
Lock
}
from
'
react-feather
'
...
...
@@ -201,7 +201,7 @@ export default function CurrencyInputPanel({
...
rest
}:
CurrencyInputPanelProps
)
{
const
[
modalOpen
,
setModalOpen
]
=
useState
(
false
)
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
selectedCurrencyBalance
=
useCurrencyBalance
(
account
??
undefined
,
currency
??
undefined
)
const
theme
=
useTheme
()
...
...
src/components/DowntimeWarning/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
AlertOctagon
}
from
'
react-feather
'
import
styled
from
'
styled-components/macro
'
import
{
ExternalLink
}
from
'
theme
'
...
...
@@ -42,7 +42,7 @@ function Wrapper({ children }: { children: React.ReactNode }) {
* Shows a downtime warning for the network if it's relevant
*/
export
default
function
DowntimeWarning
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
if
(
!
isL2ChainId
(
chainId
))
{
return
null
}
...
...
src/components/FeeSelector/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
{
FeeAmount
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
{
ButtonGray
}
from
'
components/Button
'
import
Card
from
'
components/Card
'
import
{
AutoColumn
}
from
'
components/Column
'
import
{
RowBetween
}
from
'
components/Row
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useFeeTierDistribution
}
from
'
hooks/useFeeTierDistribution
'
import
{
PoolState
,
usePools
}
from
'
hooks/usePools
'
import
usePrevious
from
'
hooks/usePrevious
'
...
...
@@ -59,7 +59,7 @@ export default function FeeSelector({
currencyA
?:
Currency
|
undefined
currencyB
?:
Currency
|
undefined
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
{
isLoading
,
isError
,
largestUsageFeeTier
,
distributions
}
=
useFeeTierDistribution
(
currencyA
,
currencyB
)
...
...
src/components/Header/ChainConnectivityWarning.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
CHAIN_INFO
,
L2ChainInfo
}
from
'
constants/chainInfo
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
AlertOctagon
}
from
'
react-feather
'
import
styled
from
'
styled-components/macro
'
import
{
ExternalLink
,
MEDIA_WIDTHS
}
from
'
theme
'
...
...
@@ -45,7 +45,7 @@ const Wrapper = styled.div`
`
export
function
ChainConnectivityWarning
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
info
=
CHAIN_INFO
[
chainId
??
SupportedChainId
.
MAINNET
]
const
label
=
info
?.
label
...
...
src/components/Header/NetworkSelector.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
getWalletForConnector
}
from
'
connectors
'
import
{
CHAIN_INFO
}
from
'
constants/chainInfo
'
import
{
CHAIN_IDS_TO_NAMES
,
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useOnClickOutside
}
from
'
hooks/useOnClickOutside
'
import
useParsedQueryString
from
'
hooks/useParsedQueryString
'
import
usePrevious
from
'
hooks/usePrevious
'
...
...
@@ -185,7 +185,7 @@ function Row({
targetChain
:
SupportedChainId
onSelectChain
:
(
targetChain
:
number
)
=>
void
})
{
const
{
provider
,
chainId
}
=
use
Active
Web3React
()
const
{
provider
,
chainId
}
=
useWeb3React
()
if
(
!
provider
||
!
chainId
)
{
return
null
}
...
...
@@ -267,7 +267,7 @@ const NETWORK_SELECTOR_CHAINS = [
export
default
function
NetworkSelector
()
{
const
dispatch
=
useAppDispatch
()
const
{
chainId
,
provider
,
connector
}
=
use
Active
Web3React
()
const
{
chainId
,
provider
,
connector
}
=
useWeb3React
()
const
previousChainId
=
usePrevious
(
chainId
)
const
parsedQs
=
useParsedQueryString
()
const
{
urlChain
,
urlChainId
}
=
getParsedChainId
(
parsedQs
)
...
...
src/components/Header/Polling.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
RowFixed
}
from
'
components/Row
'
import
{
CHAIN_INFO
}
from
'
constants/chainInfo
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
useGasPrice
from
'
hooks/useGasPrice
'
import
useMachineTimeMs
from
'
hooks/useMachineTime
'
...
...
@@ -100,7 +100,7 @@ const DEFAULT_MS_BEFORE_WARNING = ms`10m`
const
NETWORK_HEALTH_CHECK_MS
=
ms
`10s`
export
default
function
Polling
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
blockNumber
=
useBlockNumber
()
const
[
isMounting
,
setIsMounting
]
=
useState
(
false
)
const
[
isHover
,
setIsHover
]
=
useState
(
false
)
...
...
src/components/Header/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
useScrollPosition
from
'
@react-hook/window-scroll
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
CHAIN_INFO
}
from
'
constants/chainInfo
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useTheme
from
'
hooks/useTheme
'
import
{
darken
}
from
'
polished
'
import
{
NavLink
}
from
'
react-router-dom
'
...
...
@@ -247,7 +247,7 @@ const StyledExternalLink = styled(ExternalLink).attrs({
`
export
default
function
Header
()
{
const
{
account
,
chainId
,
connector
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
connector
}
=
useWeb3React
()
const
chainAllowed
=
chainId
&&
isChainAllowed
(
connector
,
chainId
)
...
...
src/components/Identicon/index.tsx
View file @
322cdaf8
import
jazzicon
from
'
@metamask/jazzicon
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useENSAvatar
from
'
hooks/useENSAvatar
'
import
{
useLayoutEffect
,
useMemo
,
useRef
,
useState
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -19,7 +19,7 @@ const StyledAvatar = styled.img`
`
export
default
function
Identicon
()
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
{
avatar
}
=
useENSAvatar
(
account
??
undefined
)
const
[
fetchable
,
setFetchable
]
=
useState
(
true
)
...
...
src/components/Menu/index.tsx
View file @
322cdaf8
// eslint-disable-next-line no-restricted-imports
import
{
t
,
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
PrivacyPolicyModal
}
from
'
components/PrivacyPolicy
'
import
{
L2_CHAIN_IDS
}
from
'
constants/chains
'
import
{
LOCALE_LABEL
,
SUPPORTED_LOCALES
,
SupportedLocale
}
from
'
constants/locales
'
import
{
useActiveLocale
}
from
'
hooks/useActiveLocale
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useLocationLinkProps
}
from
'
hooks/useLocationLinkProps
'
import
React
,
{
useEffect
,
useRef
,
useState
}
from
'
react
'
import
{
...
...
@@ -207,7 +207,7 @@ function LanguageMenu({ close }: { close: () => void }) {
}
export
default
function
Menu
()
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
node
=
useRef
<
HTMLDivElement
>
()
const
open
=
useModalOpen
(
ApplicationModal
.
MENU
)
...
...
src/components/ModalViews/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useContext
}
from
'
react
'
import
{
ArrowUpCircle
}
from
'
react-feather
'
import
styled
,
{
ThemeContext
}
from
'
styled-components/macro
'
...
...
@@ -50,7 +50,7 @@ export function SubmittedView({
hash
:
string
|
undefined
})
{
const
theme
=
useContext
(
ThemeContext
)
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
return
(
<
ConfirmOrLoadingWrapper
>
...
...
src/components/NetworkAlert/NetworkAlert.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
CHAIN_INFO
}
from
'
constants/chainInfo
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
ArrowUpRight
}
from
'
react-feather
'
import
{
useDarkModeManager
}
from
'
state/user/hooks
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -140,7 +140,7 @@ function shouldShowAlert(chainId: number | undefined): chainId is NetworkAlertCh
}
export
function
NetworkAlert
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
[
darkMode
]
=
useDarkModeManager
()
if
(
!
shouldShowAlert
(
chainId
))
{
...
...
src/components/Popups/ClaimPopup.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useCallback
,
useEffect
}
from
'
react
'
import
{
Heart
,
X
}
from
'
react-feather
'
import
styled
,
{
keyframes
}
from
'
styled-components/macro
'
...
...
@@ -55,7 +55,7 @@ const UniToken = styled.img`
`
export
default
function
ClaimPopup
()
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
// dont store these in persisted state yet
const
showClaimPopup
:
boolean
=
useShowClaimPopup
()
...
...
src/components/Popups/TransactionPopup.tsx
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useContext
}
from
'
react
'
import
{
AlertCircle
,
CheckCircle
}
from
'
react-feather
'
import
styled
,
{
ThemeContext
}
from
'
styled-components/macro
'
...
...
@@ -16,7 +16,7 @@ const RowNoFlex = styled(AutoRow)`
`
export
default
function
TransactionPopup
({
hash
}:
{
hash
:
string
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
tx
=
useTransaction
(
hash
)
const
theme
=
useContext
(
ThemeContext
)
...
...
src/components/Popups/index.tsx
View file @
322cdaf8
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
styled
from
'
styled-components/macro
'
import
{
MEDIA_WIDTHS
}
from
'
theme
'
...
...
@@ -63,7 +63,7 @@ export default function Popups() {
const
urlWarningActive
=
useURLWarningVisible
()
// need extra padding if network is not L1 Ethereum
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
isNotOnMainnet
=
Boolean
(
chainId
&&
chainId
!==
SupportedChainId
.
MAINNET
)
return
(
...
...
src/components/PositionCard/V2.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Percent
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
transparentize
}
from
'
polished
'
import
{
useState
}
from
'
react
'
...
...
@@ -42,7 +42,7 @@ interface PositionCardProps {
}
export
default
function
V2PositionCard
({
pair
,
border
,
stakedBalance
}:
PositionCardProps
)
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
currency0
=
unwrappedToken
(
pair
.
token0
)
const
currency1
=
unwrappedToken
(
pair
.
token1
)
...
...
src/components/PositionCard/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Percent
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
transparentize
}
from
'
polished
'
import
{
useState
}
from
'
react
'
...
...
@@ -46,7 +46,7 @@ interface PositionCardProps {
}
export
function
MinimalPositionCard
({
pair
,
showUnwrapped
=
false
,
border
}:
PositionCardProps
)
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
currency0
=
showUnwrapped
?
pair
.
token0
:
unwrappedToken
(
pair
.
token0
)
const
currency1
=
showUnwrapped
?
pair
.
token1
:
unwrappedToken
(
pair
.
token1
)
...
...
@@ -158,7 +158,7 @@ export function MinimalPositionCard({ pair, showUnwrapped = false, border }: Pos
}
export
default
function
FullPositionCard
({
pair
,
border
,
stakedBalance
}:
PositionCardProps
)
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
currency0
=
unwrappedToken
(
pair
.
token0
)
const
currency1
=
unwrappedToken
(
pair
.
token1
)
...
...
src/components/SearchModal/CurrencySearch.tsx
View file @
322cdaf8
// eslint-disable-next-line no-restricted-imports
import
{
t
,
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useDebounce
from
'
hooks/useDebounce
'
import
{
useOnClickOutside
}
from
'
hooks/useOnClickOutside
'
import
useTheme
from
'
hooks/useTheme
'
...
...
@@ -71,7 +71,7 @@ export function CurrencySearch({
showImportView
,
setImportToken
,
}:
CurrencySearchProps
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
theme
=
useTheme
()
const
[
tokenLoaderTimerElapsed
,
setTokenLoaderTimerElapsed
]
=
useState
(
false
)
...
...
src/components/SearchModal/ManageLists.tsx
View file @
322cdaf8
// eslint-disable-next-line no-restricted-imports
import
{
t
,
Trans
}
from
'
@lingui/macro
'
import
{
TokenList
}
from
'
@uniswap/token-lists
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
Card
from
'
components/Card
'
import
{
UNSUPPORTED_LIST_URLS
}
from
'
constants/lists
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useListColor
}
from
'
hooks/useColor
'
import
parseENSAddress
from
'
lib/utils/parseENSAddress
'
import
uriToHttp
from
'
lib/utils/uriToHttp
'
...
...
@@ -95,7 +95,7 @@ function listUrlRowHTMLId(listUrl: string) {
}
const
ListRow
=
memo
(
function
ListRow
({
listUrl
}:
{
listUrl
:
string
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
listsByUrl
=
useAppSelector
((
state
)
=>
state
.
lists
.
byUrl
)
const
dispatch
=
useAppDispatch
()
const
{
current
:
list
,
pendingUpdate
:
pending
}
=
listsByUrl
[
listUrl
]
...
...
@@ -242,7 +242,7 @@ export function ManageLists({
setImportList
:
(
list
:
TokenList
)
=>
void
setListUrl
:
(
url
:
string
)
=>
void
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
theme
=
useTheme
()
const
[
listUrlInput
,
setListUrlInput
]
=
useState
<
string
>
(
''
)
...
...
src/components/SearchModal/ManageTokens.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
Card
from
'
components/Card
'
import
Column
from
'
components/Column
'
import
CurrencyLogo
from
'
components/CurrencyLogo
'
import
Row
,
{
RowBetween
,
RowFixed
}
from
'
components/Row
'
import
{
useToken
}
from
'
hooks/Tokens
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
RefObject
,
useCallback
,
useMemo
,
useRef
,
useState
}
from
'
react
'
import
{
useRemoveUserAddedToken
,
useUserAddedTokens
}
from
'
state/user/hooks
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -44,7 +44,7 @@ export default function ManageTokens({
setModalView
:
(
view
:
CurrencyModalView
)
=>
void
setImportToken
:
(
token
:
Token
)
=>
void
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
[
searchQuery
,
setSearchQuery
]
=
useState
<
string
>
(
''
)
const
theme
=
useTheme
()
...
...
src/components/SearchModal/TokenImportCard.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
TokenList
}
from
'
@uniswap/token-lists
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
Card
from
'
components/Card
'
import
{
AutoColumn
}
from
'
components/Column
'
import
CurrencyLogo
from
'
components/CurrencyLogo
'
import
ListLogo
from
'
components/ListLogo
'
import
{
RowFixed
}
from
'
components/Row
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
transparentize
}
from
'
polished
'
import
{
AlertCircle
}
from
'
react-feather
'
import
styled
,
{
useTheme
}
from
'
styled-components/macro
'
...
...
@@ -33,7 +33,7 @@ interface TokenImportCardProps {
}
const
TokenImportCard
=
({
list
,
token
}:
TokenImportCardProps
)
=>
{
const
theme
=
useTheme
()
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
return
(
<
Card
backgroundColor=
{
theme
.
bg2
}
padding=
"2rem"
>
<
AutoColumn
gap=
"10px"
justify=
"center"
>
...
...
src/components/Settings/index.tsx
View file @
322cdaf8
// eslint-disable-next-line no-restricted-imports
import
{
t
,
Trans
}
from
'
@lingui/macro
'
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
AUTO_ROUTER_SUPPORTED_CHAINS
}
from
'
lib/hooks/routing/clientSideSmartOrderRouter
'
import
{
useContext
,
useRef
,
useState
}
from
'
react
'
import
{
Settings
,
X
}
from
'
react-feather
'
...
...
@@ -119,7 +119,7 @@ const ModalContentWrapper = styled.div`
`
export
default
function
SettingsTab
({
placeholderSlippage
}:
{
placeholderSlippage
:
Percent
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
node
=
useRef
<
HTMLDivElement
>
()
const
open
=
useModalOpen
(
ApplicationModal
.
SETTINGS
)
...
...
src/components/TopLevelModals/index.tsx
View file @
322cdaf8
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
AddressClaimModal
from
'
components/claim/AddressClaimModal
'
import
ConnectedAccountBlocked
from
'
components/ConnectedAccountBlocked
'
import
useAccountRiskCheck
from
'
hooks/useAccountRiskCheck
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useModalOpen
,
useToggleModal
}
from
'
state/application/hooks
'
import
{
ApplicationModal
}
from
'
state/application/reducer
'
...
...
@@ -10,7 +10,7 @@ export default function TopLevelModals() {
const
addressClaimToggle
=
useToggleModal
(
ApplicationModal
.
ADDRESS_CLAIM
)
const
blockedAccountModalOpen
=
useModalOpen
(
ApplicationModal
.
BLOCKED_ACCOUNT
)
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
useAccountRiskCheck
(
account
)
const
open
=
Boolean
(
blockedAccountModalOpen
&&
account
)
...
...
src/components/TransactionConfirmationModal/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
Badge
from
'
components/Badge
'
import
{
CHAIN_INFO
}
from
'
constants/chainInfo
'
import
{
L2_CHAIN_IDS
,
SupportedL2ChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useCurrencyLogoURIs
from
'
lib/hooks/useCurrencyLogoURIs
'
import
{
ReactNode
,
useCallback
,
useContext
,
useState
}
from
'
react
'
import
{
AlertCircle
,
AlertTriangle
,
ArrowUpCircle
,
CheckCircle
}
from
'
react-feather
'
...
...
@@ -96,7 +96,7 @@ function TransactionSubmittedContent({
})
{
const
theme
=
useContext
(
ThemeContext
)
const
{
connector
}
=
use
Active
Web3React
()
const
{
connector
}
=
useWeb3React
()
const
token
=
currencyToAdd
?.
wrapped
const
logoURL
=
useCurrencyLogoURIs
(
token
)[
0
]
...
...
@@ -342,7 +342,7 @@ export default function TransactionConfirmationModal({
content
,
currencyToAdd
,
}:
ConfirmationModalProps
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
isL2
=
Boolean
(
chainId
&&
L2_CHAIN_IDS
.
includes
(
chainId
))
...
...
src/components/TransactionSettings/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
L2_CHAIN_IDS
}
from
'
constants/chains
'
import
{
DEFAULT_DEADLINE_FROM_NOW
}
from
'
constants/misc
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
ms
from
'
ms.macro
'
import
{
darken
}
from
'
polished
'
import
{
useContext
,
useState
}
from
'
react
'
...
...
@@ -97,7 +97,7 @@ interface TransactionSettingsProps {
const
THREE_DAYS_IN_SECONDS
=
ms
`3 days`
/
1000
export
default
function
TransactionSettings
({
placeholderSlippage
}:
TransactionSettingsProps
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
theme
=
useContext
(
ThemeContext
)
const
userSlippageTolerance
=
useUserSlippageTolerance
()
...
...
src/components/analytics/index.ts
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useEffect
}
from
'
react
'
import
{
UaEventOptions
}
from
'
react-ga4/types/ga4
'
import
{
RouteComponentProps
}
from
'
react-router-dom
'
...
...
@@ -71,7 +71,7 @@ export function useAnalyticsReporter({ pathname, search }: RouteComponentProps['
getCLS
(
reportWebVitals
)
},
[])
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
useEffect
(()
=>
{
// cd1 - custom dimension 1 - chainId
googleAnalytics
.
set
({
cd1
:
chainId
??
0
})
...
...
src/components/claim/AddressClaimModal.tsx
View file @
322cdaf8
import
{
isAddress
}
from
'
@ethersproject/address
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useState
}
from
'
react
'
import
{
Text
}
from
'
rebass
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -46,7 +46,7 @@ const ConfirmedIcon = styled(ColumnCenter)`
`
export
default
function
AddressClaimModal
({
isOpen
,
onDismiss
}:
{
isOpen
:
boolean
;
onDismiss
:
()
=>
void
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
// state for smart contract input
const
[
typed
,
setTyped
]
=
useState
(
''
)
...
...
src/components/claim/ClaimModal.tsx
View file @
322cdaf8
import
{
isAddress
}
from
'
@ethersproject/address
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
Text
}
from
'
rebass
'
...
...
@@ -51,7 +51,7 @@ export default function ClaimModal() {
const
isOpen
=
useModalOpen
(
ApplicationModal
.
SELF_CLAIM
)
const
toggleClaimModal
=
useToggleSelfClaimModal
()
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
// used for UI loading states
const
[
attempting
,
setAttempting
]
=
useState
<
boolean
>
(
false
)
...
...
src/components/earn/ClaimRewardModal.tsx
View file @
322cdaf8
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
StakingRewardsJson
from
'
@uniswap/liquidity-staker/build/StakingRewards.json
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ReactNode
,
useState
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -34,7 +34,7 @@ interface StakingModalProps {
}
export
default
function
ClaimRewardModal
({
isOpen
,
onDismiss
,
stakingInfo
}:
StakingModalProps
)
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
// monitor call to help UI loading state
const
addTransaction
=
useTransactionAdder
()
...
...
src/components/earn/StakingModal.tsx
View file @
322cdaf8
...
...
@@ -3,7 +3,7 @@ import { Trans } from '@lingui/macro'
import
StakingRewardsJson
from
'
@uniswap/liquidity-staker/build/StakingRewards.json
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useV2LiquidityTokenPermit
}
from
'
hooks/useV2LiquidityTokenPermit
'
import
{
useCallback
,
useState
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -53,7 +53,7 @@ interface StakingModalProps {
}
export
default
function
StakingModal
({
isOpen
,
onDismiss
,
stakingInfo
,
userLiquidityUnstaked
}:
StakingModalProps
)
{
const
{
provider
}
=
use
Active
Web3React
()
const
{
provider
}
=
useWeb3React
()
// track and parse user input
const
[
typedValue
,
setTypedValue
]
=
useState
(
''
)
...
...
src/components/earn/UnstakingModal.tsx
View file @
322cdaf8
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
StakingRewardsJson
from
'
@uniswap/liquidity-staker/build/StakingRewards.json
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ReactNode
,
useState
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -35,7 +35,7 @@ interface StakingModalProps {
}
export
default
function
UnstakingModal
({
isOpen
,
onDismiss
,
stakingInfo
}:
StakingModalProps
)
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
// monitor call to help UI loading state
const
addTransaction
=
useTransactionAdder
()
...
...
src/components/swap/AdvancedSwapDetails.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
Card
from
'
components/Card
'
import
{
LoadingRows
}
from
'
components/Loader/styled
'
import
{
SUPPORTED_GAS_ESTIMATE_CHAIN_IDS
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useNativeCurrency
from
'
lib/hooks/useNativeCurrency
'
import
{
useContext
,
useMemo
}
from
'
react
'
import
{
InterfaceTrade
}
from
'
state/routing/types
'
...
...
@@ -53,7 +53,7 @@ export function AdvancedSwapDetails({
hideInfoTooltips
=
false
,
}:
AdvancedSwapDetailsProps
)
{
const
theme
=
useContext
(
ThemeContext
)
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
nativeCurrency
=
useNativeCurrency
()
const
{
expectedOutputAmount
,
priceImpact
}
=
useMemo
(()
=>
{
...
...
src/components/swap/SwapDetailsDropdown.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
AnimatedDropdown
from
'
components/AnimatedDropdown
'
import
Card
,
{
OutlineCard
}
from
'
components/Card
'
import
{
AutoColumn
}
from
'
components/Column
'
...
...
@@ -7,7 +8,6 @@ import { LoadingOpacityContainer } from 'components/Loader/styled'
import
Row
,
{
RowBetween
,
RowFixed
}
from
'
components/Row
'
import
{
MouseoverTooltipContent
}
from
'
components/Tooltip
'
import
{
SUPPORTED_GAS_ESTIMATE_CHAIN_IDS
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
darken
}
from
'
polished
'
import
{
useState
}
from
'
react
'
import
{
ChevronDown
,
Info
}
from
'
react-feather
'
...
...
@@ -126,7 +126,7 @@ export default function SwapDetailsDropdown({
allowedSlippage
,
}:
SwapDetailsInlineProps
)
{
const
theme
=
useTheme
()
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
[
showDetails
,
setShowDetails
]
=
useState
(
false
)
return
(
...
...
src/components/swap/SwapRoute.tsx
View file @
322cdaf8
...
...
@@ -3,13 +3,13 @@ import { Protocol } from '@uniswap/router-sdk'
import
{
Currency
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
FeeAmount
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
AnimatedDropdown
from
'
components/AnimatedDropdown
'
import
{
AutoColumn
}
from
'
components/Column
'
import
{
LoadingRows
}
from
'
components/Loader/styled
'
import
RoutingDiagram
from
'
components/RoutingDiagram/RoutingDiagram
'
import
{
AutoRow
,
RowBetween
}
from
'
components/Row
'
import
{
SUPPORTED_GAS_ESTIMATE_CHAIN_IDS
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useAutoRouterSupported
from
'
hooks/useAutoRouterSupported
'
import
{
memo
,
useState
}
from
'
react
'
import
{
Plus
}
from
'
react-feather
'
...
...
@@ -50,7 +50,7 @@ export default memo(function SwapRoute({ trade, syncing, fixedOpen = false, ...r
const
autoRouterSupported
=
useAutoRouterSupported
()
const
routes
=
getTokenPath
(
trade
)
const
[
open
,
setOpen
]
=
useState
(
false
)
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
[
darkMode
]
=
useDarkModeManager
()
...
...
src/components/swap/UnsupportedCurrencyFooter.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ButtonEmpty
}
from
'
components/Button
'
import
Card
,
{
OutlineCard
}
from
'
components/Card
'
import
{
AutoColumn
}
from
'
components/Column
'
import
CurrencyLogo
from
'
components/CurrencyLogo
'
import
Modal
from
'
components/Modal
'
import
{
AutoRow
,
RowBetween
}
from
'
components/Row
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useState
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
import
{
CloseIcon
,
ExternalLink
,
ThemedText
,
Z_INDEX
}
from
'
theme
'
...
...
@@ -52,7 +52,7 @@ export default function UnsupportedCurrencyFooter({
show
:
boolean
currencies
:
(
Currency
|
undefined
|
null
)[]
})
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
[
showDetails
,
setShowDetails
]
=
useState
(
false
)
const
tokens
=
...
...
src/components/vote/DelegateModal.tsx
View file @
322cdaf8
import
{
isAddress
}
from
'
@ethersproject/address
'
import
{
Trans
}
from
'
@lingui/macro
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ReactNode
,
useState
}
from
'
react
'
import
{
X
}
from
'
react-feather
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -42,7 +42,7 @@ interface VoteModalProps {
}
export
default
function
DelegateModal
({
isOpen
,
onDismiss
,
title
}:
VoteModalProps
)
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
// state for delegate input
const
[
usingDelegate
,
setUsingDelegate
]
=
useState
(
false
)
...
...
src/components/vote/ExecuteModal.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useContext
,
useState
}
from
'
react
'
import
{
ArrowUpCircle
,
X
}
from
'
react-feather
'
import
styled
,
{
ThemeContext
}
from
'
styled-components/macro
'
...
...
@@ -41,7 +41,7 @@ interface ExecuteModalProps {
}
export
default
function
ExecuteModal
({
isOpen
,
onDismiss
,
proposalId
}:
ExecuteModalProps
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
executeCallback
=
useExecuteCallback
()
// monitor call to help UI loading state
...
...
src/components/vote/ProposalEmptyState.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
styled
from
'
styled-components/macro
'
import
{
ThemedText
}
from
'
theme
'
...
...
@@ -37,7 +37,7 @@ const EmptyState = ({ HeaderContent, SubHeaderContent }: EmptyStateProps) => (
)
export
default
function
ProposalEmptyState
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
if
(
chainId
&&
chainId
!==
SupportedChainId
.
MAINNET
)
{
return
(
<
EmptyState
...
...
src/components/vote/QueueModal.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useContext
,
useState
}
from
'
react
'
import
{
ArrowUpCircle
,
X
}
from
'
react-feather
'
import
styled
,
{
ThemeContext
}
from
'
styled-components/macro
'
...
...
@@ -41,7 +41,7 @@ interface QueueModalProps {
}
export
default
function
QueueModal
({
isOpen
,
onDismiss
,
proposalId
}:
QueueModalProps
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
queueCallback
=
useQueueCallback
()
// monitor call to help UI loading state
...
...
src/components/vote/VoteModal.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useContext
,
useState
}
from
'
react
'
import
{
ArrowUpCircle
,
X
}
from
'
react-feather
'
import
styled
,
{
ThemeContext
}
from
'
styled-components/macro
'
...
...
@@ -44,7 +44,7 @@ interface VoteModalProps {
}
export
default
function
VoteModal
({
isOpen
,
onDismiss
,
proposalId
,
voteOption
}:
VoteModalProps
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
voteCallback
=
useVoteCallback
()
const
{
votes
:
availableVotes
}
=
useUserVotes
()
...
...
src/hooks/Tokens.ts
View file @
322cdaf8
import
{
Currency
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
CHAIN_INFO
}
from
'
constants/chainInfo
'
import
{
L2_CHAIN_IDS
,
SupportedChainId
,
SupportedL2ChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useCurrencyFromMap
,
useTokenFromMapOrNetwork
}
from
'
lib/hooks/useCurrency
'
import
{
getTokenFilter
}
from
'
lib/hooks/useTokenList/filtering
'
import
{
useMemo
}
from
'
react
'
...
...
@@ -13,7 +13,7 @@ import { TokenAddressMap, useUnsupportedTokenList } from './../state/lists/hooks
// reduce token map into standard address <-> Token mapping, optionally include user added tokens
function
useTokensFromMap
(
tokenMap
:
TokenAddressMap
,
includeUserAdded
:
boolean
):
{
[
address
:
string
]:
Token
}
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
userAddedTokens
=
useUserAddedTokens
()
return
useMemo
(()
=>
{
...
...
@@ -63,7 +63,7 @@ type BridgeInfo = Record<
>
export
function
useUnsupportedTokens
():
{
[
address
:
string
]:
Token
}
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
listsByUrl
=
useAllLists
()
const
unsupportedTokensMap
=
useUnsupportedTokenList
()
const
unsupportedTokens
=
useTokensFromMap
(
unsupportedTokensMap
,
false
)
...
...
@@ -108,7 +108,7 @@ export function useUnsupportedTokens(): { [address: string]: Token } {
export
function
useSearchInactiveTokenLists
(
search
:
string
|
undefined
,
minResults
=
10
):
WrappedTokenInfo
[]
{
const
lists
=
useAllLists
()
const
inactiveUrls
=
useInactiveListUrls
()
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
activeTokens
=
useAllTokens
()
return
useMemo
(()
=>
{
if
(
!
search
||
search
.
trim
().
length
===
0
)
return
[]
...
...
src/hooks/useActiveWeb3React.ts
deleted
100644 → 0
View file @
edcdbfd8
// TODO(vm): Rm this file once #3759 is merged.
import
{
useWeb3React
}
from
'
@web3-react/core
'
export
default
function
useActiveWeb3React
()
{
return
useWeb3React
()
}
src/hooks/useAllV3Routes.ts
View file @
322cdaf8
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
{
Pool
,
Route
}
from
'
@uniswap/v3-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useMemo
}
from
'
react
'
import
{
useV3SwapPools
}
from
'
./useV3SwapPools
'
...
...
@@ -63,7 +63,7 @@ export function useAllV3Routes(
currencyIn
?:
Currency
,
currencyOut
?:
Currency
):
{
loading
:
boolean
;
routes
:
Route
<
Currency
,
Currency
>
[]
}
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
{
pools
,
loading
:
poolsLoading
}
=
useV3SwapPools
(
currencyIn
,
currencyOut
)
return
useMemo
(()
=>
{
...
...
src/hooks/useArgentWalletContract.ts
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
ArgentWalletContractABI
from
'
../abis/argent-wallet-contract.json
'
import
{
ArgentWalletContract
}
from
'
../abis/types
'
...
...
@@ -6,7 +6,7 @@ import { useContract } from './useContract'
import
useIsArgentWallet
from
'
./useIsArgentWallet
'
export
function
useArgentWalletContract
():
ArgentWalletContract
|
null
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
isArgentWallet
=
useIsArgentWallet
()
return
useContract
(
isArgentWallet
?
account
??
undefined
:
undefined
,
...
...
src/hooks/useAutoRouterSupported.tsx
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
AUTO_ROUTER_SUPPORTED_CHAINS
}
from
'
lib/hooks/routing/clientSideSmartOrderRouter
'
export
default
function
useAutoRouterSupported
():
boolean
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
return
Boolean
(
chainId
&&
AUTO_ROUTER_SUPPORTED_CHAINS
.
includes
(
chainId
))
}
src/hooks/useAutoSlippageTolerance.ts
View file @
322cdaf8
import
{
Trade
}
from
'
@uniswap/router-sdk
'
import
{
Currency
,
CurrencyAmount
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SUPPORTED_GAS_ESTIMATE_CHAIN_IDS
}
from
'
constants/chains
'
import
{
L2_CHAIN_IDS
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
JSBI
from
'
jsbi
'
import
useNativeCurrency
from
'
lib/hooks/useNativeCurrency
'
import
{
useMemo
}
from
'
react
'
...
...
@@ -35,7 +35,7 @@ const MAX_AUTO_SLIPPAGE_TOLERANCE = new Percent(25, 100) // 25%
export
default
function
useAutoSlippageTolerance
(
trade
:
InterfaceTrade
<
Currency
,
Currency
,
TradeType
>
|
undefined
):
Percent
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
onL2
=
chainId
&&
L2_CHAIN_IDS
.
includes
(
chainId
)
const
outputDollarValue
=
useUSDCValue
(
trade
?.
outputAmount
)
const
nativeGasPrice
=
useGasPrice
()
...
...
src/hooks/useClientSideV3Trade.ts
View file @
322cdaf8
import
{
Currency
,
CurrencyAmount
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Route
,
SwapQuoter
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
JSBI
from
'
jsbi
'
import
{
useSingleContractWithCallData
}
from
'
lib/hooks/multicall
'
import
{
useMemo
}
from
'
react
'
...
...
@@ -35,7 +35,7 @@ export function useClientSideV3Trade<TTradeType extends TradeType>(
const
{
routes
,
loading
:
routesLoading
}
=
useAllV3Routes
(
currencyIn
,
currencyOut
)
const
quoter
=
useV3Quoter
()
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
callData
=
useMemo
(
()
=>
amountSpecified
...
...
src/hooks/useContract.ts
View file @
322cdaf8
...
...
@@ -6,6 +6,7 @@ import TickLensJson from '@uniswap/v3-periphery/artifacts/contracts/lens/TickLen
import
UniswapInterfaceMulticallJson
from
'
@uniswap/v3-periphery/artifacts/contracts/lens/UniswapInterfaceMulticall.sol/UniswapInterfaceMulticall.json
'
import
NonfungiblePositionManagerJson
from
'
@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json
'
import
V3MigratorJson
from
'
@uniswap/v3-periphery/artifacts/contracts/V3Migrator.sol/V3Migrator.json
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
ARGENT_WALLET_DETECTOR_ABI
from
'
abis/argent-wallet-detector.json
'
import
EIP_2612
from
'
abis/eip_2612.json
'
import
ENS_PUBLIC_RESOLVER_ABI
from
'
abis/ens-public-resolver.json
'
...
...
@@ -27,7 +28,6 @@ import {
V3_MIGRATOR_ADDRESSES
,
}
from
'
constants/addresses
'
import
{
WRAPPED_NATIVE_CURRENCY
}
from
'
constants/tokens
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useMemo
}
from
'
react
'
import
{
NonfungiblePositionManager
,
Quoter
,
TickLens
,
UniswapInterfaceMulticall
}
from
'
types/v3
'
import
{
V3Migrator
}
from
'
types/v3/V3Migrator
'
...
...
@@ -48,7 +48,7 @@ export function useContract<T extends Contract = Contract>(
ABI
:
any
,
withSignerIfPossible
=
true
):
T
|
null
{
const
{
provider
,
account
,
chainId
}
=
use
Active
Web3React
()
const
{
provider
,
account
,
chainId
}
=
useWeb3React
()
return
useMemo
(()
=>
{
if
(
!
addressOrAddressMap
||
!
ABI
||
!
provider
||
!
chainId
)
return
null
...
...
@@ -74,7 +74,7 @@ export function useTokenContract(tokenAddress?: string, withSignerIfPossible?: b
}
export
function
useWETHContract
(
withSignerIfPossible
?:
boolean
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
return
useContract
<
Weth
>
(
chainId
?
WRAPPED_NATIVE_CURRENCY
[
chainId
]?.
address
:
undefined
,
WETH_ABI
,
...
...
@@ -135,7 +135,7 @@ export function useV3Quoter() {
}
export
function
useTickLens
():
TickLens
|
null
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
address
=
chainId
?
TICK_LENS_ADDRESSES
[
chainId
]
:
undefined
return
useContract
(
address
,
TickLensABI
)
as
TickLens
|
null
}
src/hooks/useENSAvatar.ts
View file @
322cdaf8
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
hexZeroPad
}
from
'
@ethersproject/bytes
'
import
{
namehash
}
from
'
@ethersproject/hash
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useSingleCallResult
}
from
'
lib/hooks/multicall
'
import
uriToHttp
from
'
lib/utils/uriToHttp
'
import
{
useEffect
,
useMemo
,
useState
}
from
'
react
'
...
...
@@ -112,7 +112,7 @@ function useERC721Uri(
enforceOwnership
:
boolean
):
{
uri
?:
string
;
loading
:
boolean
}
{
const
idArgument
=
useMemo
(()
=>
[
id
],
[
id
])
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
contract
=
useERC721Contract
(
contractAddress
)
const
owner
=
useSingleCallResult
(
contract
,
'
ownerOf
'
,
idArgument
)
const
uri
=
useSingleCallResult
(
contract
,
'
tokenURI
'
,
idArgument
)
...
...
@@ -130,7 +130,7 @@ function useERC1155Uri(
id
:
string
|
undefined
,
enforceOwnership
:
boolean
):
{
uri
?:
string
;
loading
:
boolean
}
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
idArgument
=
useMemo
(()
=>
[
id
],
[
id
])
const
accountArgument
=
useMemo
(()
=>
[
account
||
''
,
id
],
[
account
,
id
])
const
contract
=
useERC1155Contract
(
contractAddress
)
...
...
src/hooks/useERC20Permit.ts
View file @
322cdaf8
...
...
@@ -4,7 +4,7 @@ import { Trade } from '@uniswap/router-sdk'
import
{
Currency
,
CurrencyAmount
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Trade
as
V2Trade
}
from
'
@uniswap/v2-sdk
'
import
{
Trade
as
V3Trade
}
from
'
@uniswap/v3-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
useSingleCallResult
}
from
'
lib/hooks/multicall
'
import
{
useMemo
,
useState
}
from
'
react
'
...
...
@@ -126,7 +126,7 @@ export function useERC20Permit(
state
:
UseERC20PermitState
gatherPermitSignature
:
null
|
(()
=>
Promise
<
void
>
)
}
{
const
{
account
,
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
const
tokenAddress
=
currencyAmount
?.
currency
?.
isToken
?
currencyAmount
.
currency
.
address
:
undefined
const
eip2612Contract
=
useEIP2612Contract
(
tokenAddress
)
const
isArgentWallet
=
useIsArgentWallet
()
...
...
@@ -268,7 +268,7 @@ export function useERC20PermitFromTrade(
allowedSlippage
:
Percent
,
transactionDeadline
:
BigNumber
|
undefined
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
swapRouterAddress
=
chainId
?
// v2 router does not support
trade
instanceof
V2Trade
...
...
src/hooks/useIsArgentWallet.ts
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
NEVER_RELOAD
,
useSingleCallResult
}
from
'
lib/hooks/multicall
'
import
{
useMemo
}
from
'
react
'
import
{
useArgentWalletDetectorContract
}
from
'
./useContract
'
export
default
function
useIsArgentWallet
():
boolean
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
argentWalletDetector
=
useArgentWalletDetectorContract
()
const
inputs
=
useMemo
(()
=>
[
account
??
undefined
],
[
account
])
const
call
=
useSingleCallResult
(
argentWalletDetector
,
'
isArgentWallet
'
,
inputs
,
NEVER_RELOAD
)
...
...
src/hooks/usePools.ts
View file @
322cdaf8
...
...
@@ -3,7 +3,7 @@ import { BigintIsh, Currency, Token } from '@uniswap/sdk-core'
import
{
abi
as
IUniswapV3PoolStateABI
}
from
'
@uniswap/v3-core/artifacts/contracts/interfaces/pool/IUniswapV3PoolState.sol/IUniswapV3PoolState.json
'
import
{
computePoolAddress
}
from
'
@uniswap/v3-sdk
'
import
{
FeeAmount
,
Pool
}
from
'
@uniswap/v3-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
useMultipleContractSingleData
}
from
'
lib/hooks/multicall
'
import
{
useMemo
}
from
'
react
'
...
...
@@ -86,7 +86,7 @@ export enum PoolState {
export
function
usePools
(
poolKeys
:
[
Currency
|
undefined
,
Currency
|
undefined
,
FeeAmount
|
undefined
][]
):
[
PoolState
,
Pool
|
null
][]
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
poolTokens
:
([
Token
,
Token
,
FeeAmount
]
|
undefined
)[]
=
useMemo
(()
=>
{
if
(
!
chainId
)
return
new
Array
(
poolKeys
.
length
)
...
...
src/hooks/useSocksBalance.ts
View file @
322cdaf8
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SOCKS_CONTROLLER_ADDRESSES
}
from
'
constants/addresses
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useMemo
}
from
'
react
'
import
{
useTokenBalance
}
from
'
state/wallet/hooks
'
...
...
@@ -9,7 +9,7 @@ import { useTokenBalance } from 'state/wallet/hooks'
const
SOCKS
=
new
Token
(
SupportedChainId
.
MAINNET
,
SOCKS_CONTROLLER_ADDRESSES
[
SupportedChainId
.
MAINNET
],
0
)
export
function
useHasSocks
():
boolean
|
undefined
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
balance
=
useTokenBalance
(
account
??
undefined
,
chainId
===
SupportedChainId
.
MAINNET
?
SOCKS
:
undefined
)
...
...
src/hooks/useSwapCallArguments.tsx
View file @
322cdaf8
...
...
@@ -3,8 +3,8 @@ import { SwapRouter, Trade } from '@uniswap/router-sdk'
import
{
Currency
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Router
as
V2SwapRouter
,
Trade
as
V2Trade
}
from
'
@uniswap/v2-sdk
'
import
{
FeeOptions
,
SwapRouter
as
V3SwapRouter
,
Trade
as
V3Trade
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SWAP_ROUTER_ADDRESSES
,
V3_ROUTER_ADDRESS
}
from
'
constants/addresses
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useMemo
}
from
'
react
'
import
approveAmountCalldata
from
'
utils/approveAmountCalldata
'
...
...
@@ -39,7 +39,7 @@ export function useSwapCallArguments(
deadline
:
BigNumber
|
undefined
,
feeOptions
:
FeeOptions
|
undefined
):
SwapCall
[]
{
const
{
account
,
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
const
{
address
:
recipientAddress
}
=
useENS
(
recipientAddressOrName
)
const
recipient
=
recipientAddressOrName
===
null
?
account
:
recipientAddress
...
...
src/hooks/useSwapCallback.tsx
View file @
322cdaf8
// eslint-disable-next-line no-restricted-imports
import
{
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SwapCallbackState
,
useSwapCallback
as
useLibSwapCallBack
}
from
'
lib/hooks/swap/useSwapCallback
'
import
{
ReactNode
,
useMemo
}
from
'
react
'
...
...
@@ -20,7 +20,7 @@ export function useSwapCallback(
recipientAddressOrName
:
string
|
null
,
// the ENS name or address of the recipient of the trade, or null if swap should be returned to sender
signatureData
:
SignatureData
|
undefined
|
null
):
{
state
:
SwapCallbackState
;
callback
:
null
|
(()
=>
Promise
<
string
>
);
error
:
ReactNode
|
null
}
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
deadline
=
useTransactionDeadline
()
...
...
src/hooks/useTokenInfoFromActiveList.ts
View file @
322cdaf8
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useMemo
}
from
'
react
'
import
{
useCombinedActiveList
}
from
'
state/lists/hooks
'
...
...
@@ -7,7 +7,7 @@ import { useCombinedActiveList } from 'state/lists/hooks'
* Returns a WrappedTokenInfo from the active token lists when possible,
* or the passed token otherwise. */
export
function
useTokenInfoFromActiveList
(
currency
:
Currency
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
activeList
=
useCombinedActiveList
()
return
useMemo
(()
=>
{
...
...
src/hooks/useTransactionDeadline.ts
View file @
322cdaf8
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
L2_CHAIN_IDS
}
from
'
constants/chains
'
import
{
L2_DEADLINE_FROM_NOW
}
from
'
constants/misc
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useMemo
}
from
'
react
'
import
{
useAppSelector
}
from
'
state/hooks
'
...
...
@@ -9,7 +9,7 @@ import useCurrentBlockTimestamp from './useCurrentBlockTimestamp'
// combines the block timestamp with the user setting to give the deadline that should be used for any submitted transaction
export
default
function
useTransactionDeadline
():
BigNumber
|
undefined
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
ttl
=
useAppSelector
((
state
)
=>
state
.
user
.
userDeadline
)
const
blockTimestamp
=
useCurrentBlockTimestamp
()
return
useMemo
(()
=>
{
...
...
src/hooks/useUSDCPrice.ts
View file @
322cdaf8
import
{
Currency
,
CurrencyAmount
,
Price
,
Token
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
import
{
useMemo
,
useRef
}
from
'
react
'
...
...
@@ -80,7 +80,7 @@ export function useUSDCValue(currencyAmount: CurrencyAmount<Currency> | undefine
* @returns CurrencyAmount where currency is stablecoin on active chain
*/
export
function
useStablecoinAmountFromFiatValue
(
fiatValue
:
string
|
null
|
undefined
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
stablecoin
=
chainId
?
STABLECOIN_AMOUNT_OUT
[
chainId
]?.
currency
:
undefined
return
useMemo
(()
=>
{
...
...
src/hooks/useV3SwapPools.ts
View file @
322cdaf8
import
{
Currency
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
FeeAmount
,
Pool
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useMemo
}
from
'
react
'
import
{
useAllCurrencyCombinations
}
from
'
./useAllCurrencyCombinations
'
...
...
@@ -19,7 +19,7 @@ export function useV3SwapPools(
pools
:
Pool
[]
loading
:
boolean
}
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
allCurrencyCombinations
=
useAllCurrencyCombinations
(
currencyIn
,
currencyOut
)
...
...
src/hooks/useWrapCallback.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useNativeCurrency
from
'
lib/hooks/useNativeCurrency
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
import
{
useMemo
}
from
'
react
'
...
...
@@ -57,7 +57,7 @@ export default function useWrapCallback(
outputCurrency
:
Currency
|
undefined
|
null
,
typedValue
:
string
|
undefined
):
{
wrapType
:
WrapType
;
execute
?:
undefined
|
(()
=>
Promise
<
void
>
);
inputError
?:
WrapInputError
}
{
const
{
chainId
,
account
}
=
use
Active
Web3React
()
const
{
chainId
,
account
}
=
useWeb3React
()
const
wethContract
=
useWETHContract
()
const
balance
=
useCurrencyBalance
(
account
??
undefined
,
inputCurrency
??
undefined
)
// we can always parse the amount typed as the input currency, since wrapping is 1:1
...
...
src/lib/hooks/multicall.ts
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
import
multicall
from
'
lib/state/multicall
'
import
{
SkipFirst
}
from
'
types/tuple
'
...
...
@@ -37,7 +37,7 @@ export function useSingleContractWithCallData(
}
function
useCallContext
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
latestBlock
=
useBlockNumber
()
return
{
chainId
,
latestBlock
}
}
src/lib/hooks/swap/useSwapApproval.ts
View file @
322cdaf8
...
...
@@ -2,8 +2,8 @@ import { Protocol, Trade } from '@uniswap/router-sdk'
import
{
Currency
,
CurrencyAmount
,
Percent
,
Token
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Pair
,
Route
as
V2Route
,
Trade
as
V2Trade
}
from
'
@uniswap/v2-sdk
'
import
{
Pool
,
Route
as
V3Route
,
Trade
as
V3Trade
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SWAP_ROUTER_ADDRESSES
,
V2_ROUTER_ADDRESS
,
V3_ROUTER_ADDRESS
}
from
'
constants/addresses
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useMemo
}
from
'
react
'
import
{
getTxOptimizedSwapRouter
,
SwapRouterVersion
}
from
'
utils/getTxOptimizedSwapRouter
'
...
...
@@ -16,7 +16,7 @@ function useSwapApprovalStates(
allowedSlippage
:
Percent
,
useIsPendingApproval
:
(
token
?:
Token
,
spender
?:
string
)
=>
boolean
):
{
v2
:
ApprovalState
;
v3
:
ApprovalState
;
v2V3
:
ApprovalState
}
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
amountToApprove
=
useMemo
(
()
=>
(
trade
&&
trade
.
inputAmount
.
currency
.
isToken
?
trade
.
maximumAmountIn
(
allowedSlippage
)
:
undefined
),
...
...
@@ -40,7 +40,7 @@ export function useSwapRouterAddress(
|
Trade
<
Currency
,
Currency
,
TradeType
>
|
undefined
)
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
return
useMemo
(
()
=>
chainId
...
...
src/lib/hooks/swap/useSwapCallback.tsx
View file @
322cdaf8
...
...
@@ -4,7 +4,7 @@ import { TransactionResponse } from '@ethersproject/providers'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Percent
}
from
'
@uniswap/sdk-core
'
import
{
FeeOptions
}
from
'
@uniswap/v3-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useENS
from
'
hooks/useENS
'
import
{
SignatureData
}
from
'
hooks/useERC20Permit
'
import
{
AnyTrade
,
useSwapCallArguments
}
from
'
hooks/useSwapCallArguments
'
...
...
@@ -42,7 +42,7 @@ export function useSwapCallback({
deadline
,
feeOptions
,
}:
UseSwapCallbackArgs
):
UseSwapCallbackReturns
{
const
{
account
,
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
const
swapCalls
=
useSwapCallArguments
(
trade
,
...
...
src/lib/hooks/transactions/updater.tsx
View file @
322cdaf8
import
{
TransactionReceipt
}
from
'
@ethersproject/abstract-provider
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useBlockNumber
,
{
useFastForwardBlockNumber
}
from
'
lib/hooks/useBlockNumber
'
import
ms
from
'
ms.macro
'
import
{
useCallback
,
useEffect
}
from
'
react
'
...
...
@@ -45,7 +45,7 @@ interface UpdaterProps {
}
export
default
function
Updater
({
pendingTransactions
,
onCheck
,
onReceipt
}:
UpdaterProps
):
null
{
const
{
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
chainId
,
provider
}
=
useWeb3React
()
const
lastBlockNumber
=
useBlockNumber
()
const
fastForwardBlockNumber
=
useFastForwardBlockNumber
()
...
...
src/lib/hooks/useApproval.ts
View file @
322cdaf8
import
{
MaxUint256
}
from
'
@ethersproject/constants
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Currency
,
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useTokenContract
}
from
'
hooks/useContract
'
import
{
useTokenAllowance
}
from
'
hooks/useTokenAllowance
'
import
{
useCallback
,
useMemo
}
from
'
react
'
...
...
@@ -19,7 +19,7 @@ export function useApprovalStateForSpender(
spender
:
string
|
undefined
,
useIsPendingApproval
:
(
token
?:
Token
,
spender
?:
string
)
=>
boolean
):
ApprovalState
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
token
=
amountToApprove
?.
currency
?.
isToken
?
amountToApprove
.
currency
:
undefined
const
currentAllowance
=
useTokenAllowance
(
token
,
account
??
undefined
,
spender
)
...
...
@@ -48,7 +48,7 @@ export function useApproval(
ApprovalState
,
()
=>
Promise
<
{
response
:
TransactionResponse
;
tokenAddress
:
string
;
spenderAddress
:
string
}
|
undefined
>
]
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
token
=
amountToApprove
?.
currency
?.
isToken
?
amountToApprove
.
currency
:
undefined
// check the current approval status
...
...
src/lib/hooks/useBlockNumber.tsx
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useIsWindowVisible
from
'
hooks/useIsWindowVisible
'
import
{
createContext
,
ReactNode
,
useCallback
,
useContext
,
useEffect
,
useMemo
,
useState
}
from
'
react
'
...
...
@@ -29,7 +29,7 @@ export function useFastForwardBlockNumber(): (block: number) => void {
}
export
function
BlockNumberProvider
({
children
}:
{
children
:
ReactNode
})
{
const
{
chainId
:
activeChainId
,
provider
}
=
use
Active
Web3React
()
const
{
chainId
:
activeChainId
,
provider
}
=
useWeb3React
()
const
[{
chainId
,
block
},
setChainBlock
]
=
useState
<
{
chainId
?:
number
;
block
?:
number
}
>
({
chainId
:
activeChainId
})
const
onBlock
=
useCallback
(
...
...
src/lib/hooks/useCurrency.ts
View file @
322cdaf8
import
{
arrayify
}
from
'
@ethersproject/bytes
'
import
{
parseBytes32String
}
from
'
@ethersproject/strings
'
import
{
Currency
,
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useBytes32TokenContract
,
useTokenContract
}
from
'
hooks/useContract
'
import
{
NEVER_RELOAD
,
useSingleCallResult
}
from
'
lib/hooks/multicall
'
import
useNativeCurrency
from
'
lib/hooks/useNativeCurrency
'
...
...
@@ -30,7 +30,7 @@ function parseStringOrBytes32(str: string | undefined, bytes32: string | undefin
* Returns undefined if tokenAddress is invalid or token does not exist.
*/
export
function
useTokenFromNetwork
(
tokenAddress
:
string
|
null
|
undefined
):
Token
|
null
|
undefined
{
const
{
chainId
,
connector
}
=
use
Active
Web3React
()
const
{
chainId
,
connector
}
=
useWeb3React
()
const
chainAllowed
=
chainId
&&
isChainAllowed
(
connector
,
chainId
)
const
formattedAddress
=
isAddress
(
tokenAddress
)
...
...
@@ -96,7 +96,7 @@ export function useTokenFromMapOrNetwork(tokens: TokenMap, tokenAddress?: string
*/
export
function
useCurrencyFromMap
(
tokens
:
TokenMap
,
currencyId
?:
string
|
null
):
Currency
|
null
|
undefined
{
const
nativeCurrency
=
useNativeCurrency
()
const
{
chainId
,
connector
}
=
use
Active
Web3React
()
const
{
chainId
,
connector
}
=
useWeb3React
()
const
isNative
=
Boolean
(
nativeCurrency
&&
currencyId
?.
toUpperCase
()
===
'
ETH
'
)
const
shorthandMatchAddress
=
useMemo
(()
=>
{
const
chain
=
supportedChainId
(
chainId
)
...
...
src/lib/hooks/useCurrencyBalance.ts
View file @
322cdaf8
import
{
Interface
}
from
'
@ethersproject/abi
'
import
{
Currency
,
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
ERC20ABI
from
'
abis/erc20.json
'
import
{
Erc20Interface
}
from
'
abis/types/Erc20
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
JSBI
from
'
jsbi
'
import
{
useMultipleContractSingleData
,
useSingleContractMultipleData
}
from
'
lib/hooks/multicall
'
import
{
useMemo
}
from
'
react
'
...
...
@@ -17,7 +17,7 @@ import { isAddress } from '../../utils'
export
function
useNativeCurrencyBalances
(
uncheckedAddresses
?:
(
string
|
undefined
)[]):
{
[
address
:
string
]:
CurrencyAmount
<
Currency
>
|
undefined
}
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
multicallContract
=
useInterfaceMulticall
()
const
validAddressInputs
:
[
string
][]
=
useMemo
(
...
...
src/lib/hooks/useIsValidBlock.ts
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
atomWithImmer
}
from
'
jotai/immer
'
import
{
useAtomValue
,
useUpdateAtom
}
from
'
jotai/utils
'
import
{
useCallback
}
from
'
react
'
...
...
@@ -11,7 +11,7 @@ const oldestBlockMapAtom = atomWithImmer<{ [chainId: number]: number }>({})
const
DEFAULT_MAX_BLOCK_AGE
=
10
export
function
useSetOldestValidBlock
():
(
block
:
number
)
=>
void
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
updateValidBlock
=
useUpdateAtom
(
oldestBlockMapAtom
)
return
useCallback
(
(
block
:
number
)
=>
{
...
...
@@ -25,7 +25,7 @@ export function useSetOldestValidBlock(): (block: number) => void {
}
export
function
useGetIsValidBlock
(
maxBlockAge
=
DEFAULT_MAX_BLOCK_AGE
):
(
block
:
number
)
=>
boolean
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
currentBlock
=
useBlockNumber
()
const
oldestBlockMap
=
useAtomValue
(
oldestBlockMapAtom
)
const
oldestBlock
=
chainId
?
oldestBlockMap
[
chainId
]
:
0
...
...
src/lib/hooks/useNativeCurrency.ts
View file @
322cdaf8
import
{
NativeCurrency
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
{
nativeOnChain
}
from
'
constants/tokens
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useMemo
}
from
'
react
'
export
default
function
useNativeCurrency
():
NativeCurrency
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
return
useMemo
(
()
=>
chainId
...
...
src/lib/state/multicall.tsx
View file @
322cdaf8
import
{
createMulticall
}
from
'
@uniswap/redux-multicall
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useInterfaceMulticall
}
from
'
hooks/useContract
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
import
{
combineReducers
,
createStore
}
from
'
redux
'
...
...
@@ -11,7 +11,7 @@ export const store = createStore(reducer)
export
default
multicall
export
function
MulticallUpdater
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
latestBlockNumber
=
useBlockNumber
()
const
contract
=
useInterfaceMulticall
()
return
<
multicall
.
Updater
chainId=
{
chainId
}
latestBlockNumber=
{
latestBlockNumber
}
contract=
{
contract
}
/>
...
...
src/pages/AddLiquidity/index.tsx
View file @
322cdaf8
...
...
@@ -3,9 +3,9 @@ import { TransactionResponse } from '@ethersproject/providers'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
FeeAmount
,
NonfungiblePositionManager
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
UnsupportedCurrencyFooter
from
'
components/swap/UnsupportedCurrencyFooter
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useParsedQueryString
from
'
hooks/useParsedQueryString
'
import
{
useCallback
,
useContext
,
useEffect
,
useState
}
from
'
react
'
import
{
AlertTriangle
}
from
'
react-feather
'
...
...
@@ -81,7 +81,7 @@ export default function AddLiquidity({
},
history
,
}:
RouteComponentProps
<
{
currencyIdA
?:
string
;
currencyIdB
?:
string
;
feeAmount
?:
string
;
tokenId
?:
string
}
>
)
{
const
{
account
,
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
const
theme
=
useContext
(
ThemeContext
)
const
toggleWalletModal
=
useWalletModalToggle
()
// toggle wallet when disconnected
const
expertMode
=
useIsExpertMode
()
...
...
src/pages/AddLiquidity/redirects.tsx
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
Redirect
,
RouteComponentProps
}
from
'
react-router-dom
'
import
{
WRAPPED_NATIVE_CURRENCY
}
from
'
../../constants/tokens
'
...
...
@@ -13,7 +13,7 @@ export function RedirectDuplicateTokenIds(
},
}
=
props
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
// prevent weth + eth
const
isETHOrWETHA
=
...
...
src/pages/AddLiquidityV2/index.tsx
View file @
322cdaf8
...
...
@@ -2,10 +2,10 @@ import { BigNumber } from '@ethersproject/bignumber'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
UnsupportedCurrencyFooter
from
'
components/swap/UnsupportedCurrencyFooter
'
import
{
SwitchLocaleLink
}
from
'
components/SwitchLocaleLink
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useCallback
,
useContext
,
useState
}
from
'
react
'
import
{
Plus
}
from
'
react-feather
'
import
{
RouteComponentProps
}
from
'
react-router-dom
'
...
...
@@ -53,7 +53,7 @@ export default function AddLiquidity({
},
history
,
}:
RouteComponentProps
<
{
currencyIdA
?:
string
;
currencyIdB
?:
string
}
>
)
{
const
{
account
,
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
const
theme
=
useContext
(
ThemeContext
)
...
...
src/pages/CreateProposal/index.tsx
View file @
322cdaf8
...
...
@@ -2,10 +2,10 @@ import { defaultAbiCoder } from '@ethersproject/abi'
import
{
getAddress
,
isAddress
}
from
'
@ethersproject/address
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ButtonError
}
from
'
components/Button
'
import
{
BlueCard
}
from
'
components/Card
'
import
{
AutoColumn
}
from
'
components/Column
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
JSBI
from
'
jsbi
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
import
{
Wrapper
}
from
'
pages/Pool/styleds
'
...
...
@@ -86,7 +86,7 @@ const AutonomousProposalCTA = styled.div`
`
export
default
function
CreateProposal
()
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
latestProposalId
=
useLatestProposalId
(
account
??
undefined
)
??
'
0
'
const
latestProposalData
=
useProposalData
(
LATEST_GOVERNOR_INDEX
,
latestProposalId
)
...
...
src/pages/Earn/Manage.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
useCallback
,
useState
}
from
'
react
'
import
{
Link
}
from
'
react-router-dom
'
...
...
@@ -91,7 +91,7 @@ export default function Manage({
params
:
{
currencyIdA
,
currencyIdB
},
},
}:
RouteComponentProps
<
{
currencyIdA
:
string
;
currencyIdB
:
string
}
>
)
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
// get currencies and pair
const
[
currencyA
,
currencyB
]
=
[
useCurrency
(
currencyIdA
),
useCurrency
(
currencyIdB
)]
...
...
src/pages/Earn/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -40,7 +40,7 @@ flex-direction: column;
`
export
default
function
Earn
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
// staking info for connected account
const
stakingInfos
=
useStakingInfo
()
...
...
src/pages/MigrateV2/MigrateV2Pair.tsx
View file @
322cdaf8
...
...
@@ -3,6 +3,7 @@ import { TransactionResponse } from '@ethersproject/providers'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Fraction
,
Percent
,
Price
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
FeeAmount
,
Pool
,
Position
,
priceToClosestTick
,
TickMath
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
Badge
,
{
BadgeVariant
}
from
'
components/Badge
'
import
{
ButtonConfirmed
}
from
'
components/Button
'
...
...
@@ -13,7 +14,6 @@ import RangeSelector from 'components/RangeSelector'
import
RateToggle
from
'
components/RateToggle
'
import
SettingsTab
from
'
components/Settings
'
import
{
Dots
}
from
'
components/swap/styleds
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
ApprovalState
,
useApproveCallback
}
from
'
hooks/useApproveCallback
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
{
PoolState
,
usePool
}
from
'
hooks/usePools
'
...
...
@@ -124,7 +124,7 @@ function V2PairMigration({
token0
:
Token
token1
:
Token
})
{
const
{
chainId
,
account
}
=
use
Active
Web3React
()
const
{
chainId
,
account
}
=
useWeb3React
()
const
theme
=
useTheme
()
const
v2FactoryAddress
=
chainId
?
V2_FACTORY_ADDRESSES
[
chainId
]
:
undefined
...
...
@@ -676,7 +676,7 @@ export default function MigrateV2Pair({
}
},
[
dispatch
])
const
{
chainId
,
account
}
=
use
Active
Web3React
()
const
{
chainId
,
account
}
=
useWeb3React
()
// get pair contract
const
validatedAddress
=
isAddress
(
address
)
...
...
src/pages/MigrateV2/index.tsx
View file @
322cdaf8
...
...
@@ -3,10 +3,10 @@ import { keccak256, pack } from '@ethersproject/solidity'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
MigrateSushiPositionCard
from
'
components/PositionCard/Sushi
'
import
MigrateV2PositionCard
from
'
components/PositionCard/V2
'
import
{
SwitchLocaleLink
}
from
'
components/SwitchLocaleLink
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
PairState
,
useV2Pairs
}
from
'
hooks/useV2Pairs
'
import
{
ReactNode
,
useContext
,
useMemo
}
from
'
react
'
import
{
Text
}
from
'
rebass
'
...
...
@@ -52,7 +52,7 @@ function toSushiLiquidityToken([tokenA, tokenB]: [Token, Token]): Token {
export
default
function
MigrateV2
()
{
const
theme
=
useContext
(
ThemeContext
)
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
v2FactoryAddress
=
chainId
?
V2_FACTORY_ADDRESSES
[
chainId
]
:
undefined
...
...
src/pages/Pool/CTACards.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
AutoColumn
}
from
'
components/Column
'
import
{
CHAIN_INFO
}
from
'
constants/chainInfo
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
styled
from
'
styled-components/macro
'
import
{
ThemedText
}
from
'
theme
'
...
...
@@ -93,7 +93,7 @@ const ResponsiveColumn = styled(AutoColumn)`
`
export
default
function
CTACards
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
{
infoLink
}
=
CHAIN_INFO
[
chainId
?
chainId
:
SupportedChainId
.
MAINNET
]
return
(
<
CTASection
>
...
...
src/pages/Pool/PositionPage.tsx
View file @
322cdaf8
...
...
@@ -3,6 +3,7 @@ import { TransactionResponse } from '@ethersproject/providers'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Fraction
,
Percent
,
Price
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
NonfungiblePositionManager
,
Pool
,
Position
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
Badge
from
'
components/Badge
'
import
{
ButtonConfirmed
,
ButtonGray
,
ButtonPrimary
}
from
'
components/Button
'
...
...
@@ -16,7 +17,6 @@ import { Dots } from 'components/swap/styleds'
import
Toggle
from
'
components/Toggle
'
import
TransactionConfirmationModal
,
{
ConfirmationModalContent
}
from
'
components/TransactionConfirmationModal
'
import
{
useToken
}
from
'
hooks/Tokens
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useV3NFTPositionManagerContract
}
from
'
hooks/useContract
'
import
useIsTickAtLimit
from
'
hooks/useIsTickAtLimit
'
import
{
PoolState
,
usePool
}
from
'
hooks/usePools
'
...
...
@@ -318,7 +318,7 @@ export function PositionPage({
params
:
{
tokenId
:
tokenIdFromUrl
},
},
}:
RouteComponentProps
<
{
tokenId
?:
string
}
>
)
{
const
{
chainId
,
account
,
provider
}
=
use
Active
Web3React
()
const
{
chainId
,
account
,
provider
}
=
useWeb3React
()
const
theme
=
useTheme
()
const
parsedTokenId
=
tokenIdFromUrl
?
BigNumber
.
from
(
tokenIdFromUrl
)
:
undefined
...
...
src/pages/Pool/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ButtonGray
,
ButtonPrimary
,
ButtonText
}
from
'
components/Button
'
import
{
AutoColumn
}
from
'
components/Column
'
import
{
FlyoutAlignment
,
NewMenu
}
from
'
components/Menu
'
...
...
@@ -6,7 +7,6 @@ import { SwapPoolTabs } from 'components/NavigationTabs'
import
PositionList
from
'
components/PositionList
'
import
{
RowBetween
,
RowFixed
}
from
'
components/Row
'
import
{
SwitchLocaleLink
}
from
'
components/SwitchLocaleLink
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useV3Positions
}
from
'
hooks/useV3Positions
'
import
{
useContext
}
from
'
react
'
import
{
BookOpen
,
ChevronDown
,
ChevronsRight
,
Inbox
,
Layers
,
PlusCircle
}
from
'
react-feather
'
...
...
@@ -127,7 +127,7 @@ function PositionsLoadingPlaceholder() {
}
export
default
function
Pool
()
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
toggleWalletModal
=
useWalletModalToggle
()
const
theme
=
useContext
(
ThemeContext
)
...
...
src/pages/Pool/v2.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
UNSUPPORTED_V2POOL_CHAIN_IDS
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
JSBI
from
'
jsbi
'
import
{
useContext
,
useMemo
}
from
'
react
'
import
{
ChevronsRight
}
from
'
react-feather
'
...
...
@@ -84,7 +84,7 @@ const Layer2Prompt = styled(EmptyProposals)`
export
default
function
Pool
()
{
const
theme
=
useContext
(
ThemeContext
)
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
unsupportedV2Network
=
chainId
&&
UNSUPPORTED_V2POOL_CHAIN_IDS
.
includes
(
chainId
)
// fetch the user's balances of all tracked V2 LP tokens
...
...
src/pages/PoolFinder/index.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
useCallback
,
useEffect
,
useState
}
from
'
react
'
import
{
Plus
}
from
'
react-feather
'
...
...
@@ -39,7 +39,7 @@ function useQuery() {
export
default
function
PoolFinder
()
{
const
query
=
useQuery
()
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
[
showSearch
,
setShowSearch
]
=
useState
<
boolean
>
(
false
)
const
[
activeField
,
setActiveField
]
=
useState
<
number
>
(
Fields
.
TOKEN1
)
...
...
src/pages/RemoveLiquidity/V3.tsx
View file @
322cdaf8
...
...
@@ -3,6 +3,7 @@ import { TransactionResponse } from '@ethersproject/providers'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
NonfungiblePositionManager
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
RangeBadge
from
'
components/Badge/RangeBadge
'
import
{
ButtonConfirmed
,
ButtonPrimary
}
from
'
components/Button
'
...
...
@@ -17,7 +18,6 @@ import { AddRemoveTabs } from 'components/NavigationTabs'
import
{
AutoRow
,
RowBetween
,
RowFixed
}
from
'
components/Row
'
import
Slider
from
'
components/Slider
'
import
Toggle
from
'
components/Toggle
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useV3NFTPositionManagerContract
}
from
'
hooks/useContract
'
import
useDebouncedChangeHandler
from
'
hooks/useDebouncedChangeHandler
'
import
useTheme
from
'
hooks/useTheme
'
...
...
@@ -66,7 +66,7 @@ export default function RemoveLiquidityV3({
function
Remove
({
tokenId
}:
{
tokenId
:
BigNumber
})
{
const
{
position
}
=
useV3PositionFromTokenId
(
tokenId
)
const
theme
=
useTheme
()
const
{
account
,
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
// flag for receiving WETH
const
[
receiveWETH
,
setReceiveWETH
]
=
useState
(
false
)
...
...
src/pages/RemoveLiquidity/index.tsx
View file @
322cdaf8
...
...
@@ -3,8 +3,8 @@ import { Contract } from '@ethersproject/contracts'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useV2LiquidityTokenPermit
}
from
'
hooks/useV2LiquidityTokenPermit
'
import
{
useCallback
,
useContext
,
useMemo
,
useState
}
from
'
react
'
import
{
ArrowDown
,
Plus
}
from
'
react-feather
'
...
...
@@ -52,7 +52,7 @@ export default function RemoveLiquidity({
},
}:
RouteComponentProps
<
{
currencyIdA
:
string
;
currencyIdB
:
string
}
>
)
{
const
[
currencyA
,
currencyB
]
=
[
useCurrency
(
currencyIdA
)
??
undefined
,
useCurrency
(
currencyIdB
)
??
undefined
]
const
{
account
,
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
const
[
tokenA
,
tokenB
]
=
useMemo
(()
=>
[
currencyA
?.
wrapped
,
currencyB
?.
wrapped
],
[
currencyA
,
currencyB
])
const
theme
=
useContext
(
ThemeContext
)
...
...
src/pages/Swap/index.tsx
View file @
322cdaf8
...
...
@@ -3,12 +3,12 @@ import { Trade } from '@uniswap/router-sdk'
import
{
Currency
,
CurrencyAmount
,
Token
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Trade
as
V2Trade
}
from
'
@uniswap/v2-sdk
'
import
{
Trade
as
V3Trade
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendEvent
}
from
'
components/analytics
'
import
{
NetworkAlert
}
from
'
components/NetworkAlert/NetworkAlert
'
import
SwapDetailsDropdown
from
'
components/swap/SwapDetailsDropdown
'
import
UnsupportedCurrencyFooter
from
'
components/swap/UnsupportedCurrencyFooter
'
import
{
MouseoverTooltip
}
from
'
components/Tooltip
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useSwapCallback
}
from
'
hooks/useSwapCallback
'
import
useTransactionDeadline
from
'
hooks/useTransactionDeadline
'
import
JSBI
from
'
jsbi
'
...
...
@@ -64,7 +64,7 @@ const AlertWrapper = styled.div`
`
export
default
function
Swap
({
history
}:
RouteComponentProps
)
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
loadedUrlParams
=
useDefaultsFromURLSearch
()
// token warning stuff
...
...
src/pages/Vote/Landing.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
ButtonPrimary
}
from
'
components/Button
'
import
{
AutoColumn
}
from
'
components/Column
'
import
{
CardBGImage
,
CardNoise
,
CardSection
,
DataCard
}
from
'
components/earn/styled
'
...
...
@@ -10,7 +11,6 @@ import { SwitchLocaleLink } from 'components/SwitchLocaleLink'
import
Toggle
from
'
components/Toggle
'
import
DelegateModal
from
'
components/vote/DelegateModal
'
import
ProposalEmptyState
from
'
components/vote/ProposalEmptyState
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
JSBI
from
'
jsbi
'
import
{
darken
}
from
'
polished
'
import
{
useState
}
from
'
react
'
...
...
@@ -107,7 +107,7 @@ const StyledExternalLink = styled(ExternalLink)`
`
export
default
function
Landing
()
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
[
hideCancelled
,
setHideCancelled
]
=
useState
(
true
)
...
...
src/pages/Vote/VotePage.tsx
View file @
322cdaf8
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Fraction
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
ExecuteModal
from
'
components/vote/ExecuteModal
'
import
QueueModal
from
'
components/vote/QueueModal
'
import
{
useActiveLocale
}
from
'
hooks/useActiveLocale
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
JSBI
from
'
jsbi
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
...
...
@@ -157,7 +157,7 @@ export default function VotePage({
}: RouteComponentProps<{ governorIndex: string; id: string }>) {
const parsedGovernorIndex = Number.parseInt(governorIndex)
const { chainId, account } = use
Active
Web3React()
const { chainId, account } = useWeb3React()
const quorumAmount = useQuorum(parsedGovernorIndex)
...
...
src/state/application/updater.ts
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useDebounce
from
'
hooks/useDebounce
'
import
useIsWindowVisible
from
'
hooks/useIsWindowVisible
'
import
{
useEffect
,
useState
}
from
'
react
'
...
...
@@ -22,7 +22,7 @@ function useQueryCacheInvalidator() {
}
export
default
function
Updater
():
null
{
const
{
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
chainId
,
provider
}
=
useWeb3React
()
const
dispatch
=
useAppDispatch
()
const
windowVisible
=
useIsWindowVisible
()
...
...
src/state/burn/hooks.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
import
{
ReactNode
,
useCallback
}
from
'
react
'
...
...
@@ -30,7 +30,7 @@ export function useDerivedBurnInfo(
}
error
?:
ReactNode
}
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
{
independentField
,
typedValue
}
=
useBurnState
()
...
...
src/state/burn/v3/hooks.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
Position
}
from
'
@uniswap/v3-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useToken
}
from
'
hooks/Tokens
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
usePool
}
from
'
hooks/usePools
'
import
{
useV3PositionFees
}
from
'
hooks/useV3PositionFees
'
import
{
ReactNode
,
useCallback
,
useMemo
}
from
'
react
'
...
...
@@ -30,7 +30,7 @@ export function useDerivedV3BurnInfo(
outOfRange
:
boolean
error
?:
ReactNode
}
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
{
percent
}
=
useBurnV3State
()
const
token0
=
useToken
(
position
?.
token0
)
...
...
src/state/claim/hooks.ts
View file @
322cdaf8
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
abi
as
MERKLE_DISTRIBUTOR_ABI
}
from
'
@uniswap/merkle-distributor/build/MerkleDistributor.json
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
MERKLE_DISTRIBUTOR_ADDRESS
}
from
'
constants/addresses
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
JSBI
from
'
jsbi
'
import
{
useSingleCallResult
}
from
'
lib/hooks/multicall
'
import
{
useEffect
,
useState
}
from
'
react
'
...
...
@@ -100,7 +100,7 @@ function fetchClaim(account: string): Promise<UserClaimData> {
// parse distributorContract blob and detect if user has claim data
// null means we know it does not
export
function
useUserClaimData
(
account
:
string
|
null
|
undefined
):
UserClaimData
|
null
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
[
claimInfo
,
setClaimInfo
]
=
useState
<
{
[
account
:
string
]:
UserClaimData
|
null
}
>
({})
...
...
@@ -139,7 +139,7 @@ export function useUserHasAvailableClaim(account: string | null | undefined): bo
}
export
function
useUserUnclaimedAmount
(
account
:
string
|
null
|
undefined
):
CurrencyAmount
<
Token
>
|
undefined
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
userClaimData
=
useUserClaimData
(
account
)
const
canClaim
=
useUserHasAvailableClaim
(
account
)
...
...
@@ -155,7 +155,7 @@ export function useClaimCallback(account: string | null | undefined): {
claimCallback
:
()
=>
Promise
<
string
>
}
{
// get claim data for this account
const
{
provider
,
chainId
}
=
use
Active
Web3React
()
const
{
provider
,
chainId
}
=
useWeb3React
()
const
claimData
=
useUserClaimData
(
account
)
// used for popup summary
...
...
src/state/governance/hooks.ts
View file @
322cdaf8
...
...
@@ -9,6 +9,7 @@ import { t } from '@lingui/macro'
import
{
abi
as
GOVERNANCE_ABI
}
from
'
@uniswap/governance/build/GovernorAlpha.json
'
import
{
abi
as
UNI_ABI
}
from
'
@uniswap/governance/build/Uni.json
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
GOVERNOR_BRAVO_ABI
from
'
abis/governor-bravo.json
'
import
{
GOVERNANCE_ALPHA_V0_ADDRESSES
,
...
...
@@ -18,7 +19,6 @@ import {
import
{
LATEST_GOVERNOR_INDEX
}
from
'
constants/governance
'
import
{
POLYGON_PROPOSAL_TITLE
}
from
'
constants/proposals/polygon_proposal_title
'
import
{
UNISWAP_GRANTS_PROPOSAL_DESCRIPTION
}
from
'
constants/proposals/uniswap_grants_proposal_description
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useContract
}
from
'
hooks/useContract
'
import
{
useSingleCallResult
,
useSingleContractMultipleData
}
from
'
lib/hooks/multicall
'
import
{
useCallback
,
useMemo
}
from
'
react
'
...
...
@@ -53,7 +53,7 @@ function useGovernanceBravoContract(): Contract | null {
const
useLatestGovernanceContract
=
useGovernanceBravoContract
export
function
useUniContract
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
uniAddress
=
useMemo
(()
=>
(
chainId
?
UNI
[
chainId
]?.
address
:
undefined
),
[
chainId
])
return
useContract
(
uniAddress
,
UNI_ABI
,
true
)
}
...
...
@@ -227,7 +227,7 @@ function countToIndices(count: number | undefined, skip = 0) {
// get data for all past and active proposals
export
function
useAllProposalData
():
{
data
:
ProposalData
[];
loading
:
boolean
}
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
gov0
=
useGovernanceV0Contract
()
const
gov1
=
useGovernanceV1Contract
()
const
gov2
=
useGovernanceBravoContract
()
...
...
@@ -335,7 +335,7 @@ export function useProposalData(governorIndex: number, id: string): ProposalData
export
function
useQuorum
(
governorIndex
:
number
):
CurrencyAmount
<
Token
>
|
undefined
{
const
latestGovernanceContract
=
useLatestGovernanceContract
()
const
quorumVotes
=
useSingleCallResult
(
latestGovernanceContract
,
'
quorumVotes
'
)?.
result
?.[
0
]
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
uni
=
useMemo
(()
=>
(
chainId
?
UNI
[
chainId
]
:
undefined
),
[
chainId
])
if
(
...
...
@@ -352,7 +352,7 @@ export function useQuorum(governorIndex: number): CurrencyAmount<Token> | undefi
// get the users delegatee if it exists
export
function
useUserDelegatee
():
string
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
uniContract
=
useUniContract
()
const
{
result
}
=
useSingleCallResult
(
uniContract
,
'
delegates
'
,
[
account
??
undefined
])
return
result
?.[
0
]
??
undefined
...
...
@@ -360,7 +360,7 @@ export function useUserDelegatee(): string {
// gets the users current votes
export
function
useUserVotes
():
{
loading
:
boolean
;
votes
:
CurrencyAmount
<
Token
>
|
undefined
}
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
uniContract
=
useUniContract
()
// check for available votes
...
...
@@ -373,7 +373,7 @@ export function useUserVotes(): { loading: boolean; votes: CurrencyAmount<Token>
// fetch available votes as of block (usually proposal start block)
export
function
useUserVotesAsOfBlock
(
block
:
number
|
undefined
):
CurrencyAmount
<
Token
>
|
undefined
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
uniContract
=
useUniContract
()
// check for available votes
...
...
@@ -384,7 +384,7 @@ export function useUserVotesAsOfBlock(block: number | undefined): CurrencyAmount
}
export
function
useDelegateCallback
():
(
delegatee
:
string
|
undefined
)
=>
undefined
|
Promise
<
string
>
{
const
{
account
,
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
account
,
chainId
,
provider
}
=
useWeb3React
()
const
addTransaction
=
useTransactionAdder
()
const
uniContract
=
useUniContract
()
...
...
@@ -414,7 +414,7 @@ export function useVoteCallback(): (
proposalId
:
string
|
undefined
,
voteOption
:
VoteOption
)
=>
undefined
|
Promise
<
string
>
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
latestGovernanceContract
=
useLatestGovernanceContract
()
const
addTransaction
=
useTransactionAdder
()
...
...
@@ -442,7 +442,7 @@ export function useVoteCallback(): (
}
export
function
useQueueCallback
():
(
proposalId
:
string
|
undefined
)
=>
undefined
|
Promise
<
string
>
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
latestGovernanceContract
=
useLatestGovernanceContract
()
const
addTransaction
=
useTransactionAdder
()
...
...
@@ -468,7 +468,7 @@ export function useQueueCallback(): (proposalId: string | undefined) => undefine
}
export
function
useExecuteCallback
():
(
proposalId
:
string
|
undefined
)
=>
undefined
|
Promise
<
string
>
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
latestGovernanceContract
=
useLatestGovernanceContract
()
const
addTransaction
=
useTransactionAdder
()
...
...
@@ -496,7 +496,7 @@ export function useExecuteCallback(): (proposalId: string | undefined) => undefi
export
function
useCreateProposalCallback
():
(
createProposalData
:
CreateProposalData
|
undefined
)
=>
undefined
|
Promise
<
string
>
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
latestGovernanceContract
=
useLatestGovernanceContract
()
const
addTransaction
=
useTransactionAdder
()
...
...
@@ -534,7 +534,7 @@ export function useLatestProposalId(address: string | undefined): string | undef
}
export
function
useProposalThreshold
():
CurrencyAmount
<
Token
>
|
undefined
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
latestGovernanceContract
=
useLatestGovernanceContract
()
const
res
=
useSingleCallResult
(
latestGovernanceContract
,
'
proposalThreshold
'
)
...
...
src/state/lists/updater.ts
View file @
322cdaf8
import
{
getVersionUpgrade
,
minVersionBump
,
VersionUpgrade
}
from
'
@uniswap/token-lists
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
{
ARBITRUM_LIST
,
OPTIMISM_LIST
,
UNSUPPORTED_LIST_URLS
}
from
'
constants/lists
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useInterval
from
'
lib/hooks/useInterval
'
import
{
useCallback
,
useEffect
}
from
'
react
'
import
{
useAppDispatch
}
from
'
state/hooks
'
...
...
@@ -13,7 +13,7 @@ import { acceptListUpdate, enableList } from './actions'
import
{
useActiveListUrls
}
from
'
./hooks
'
export
default
function
Updater
():
null
{
const
{
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
chainId
,
provider
}
=
useWeb3React
()
const
dispatch
=
useAppDispatch
()
const
isWindowVisible
=
useIsWindowVisible
()
...
...
src/state/logs/hooks.ts
View file @
322cdaf8
import
{
Filter
}
from
'
@ethersproject/providers
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
import
{
useEffect
,
useMemo
}
from
'
react
'
...
...
@@ -31,7 +31,7 @@ export interface UseLogsResult {
* The filter parameter should _always_ be memoized, or else will trigger constant refetching
*/
export
function
useLogs
(
filter
:
Filter
|
undefined
):
UseLogsResult
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
blockNumber
=
useBlockNumber
()
const
logs
=
useAppSelector
((
state
)
=>
state
.
logs
)
...
...
src/state/logs/updater.ts
View file @
322cdaf8
import
{
Filter
}
from
'
@ethersproject/providers
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
import
{
useEffect
,
useMemo
}
from
'
react
'
...
...
@@ -10,7 +10,7 @@ import { isHistoricalLog, keyToFilter } from './utils'
export
default
function
Updater
():
null
{
const
dispatch
=
useAppDispatch
()
const
state
=
useAppSelector
((
state
)
=>
state
.
logs
)
const
{
chainId
,
provider
}
=
use
Active
Web3React
()
const
{
chainId
,
provider
}
=
useWeb3React
()
const
blockNumber
=
useBlockNumber
()
...
...
src/state/mint/hooks.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
,
Price
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
import
{
ReactNode
,
useCallback
,
useMemo
}
from
'
react
'
...
...
@@ -61,7 +61,7 @@ export function useDerivedMintInfo(
poolTokenPercentage
?:
Percent
error
?:
ReactNode
}
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
{
independentField
,
typedValue
,
otherTypedValue
}
=
useMintState
()
...
...
src/state/mint/v3/hooks.tsx
View file @
322cdaf8
...
...
@@ -11,7 +11,7 @@ import {
TickMath
,
tickToPrice
,
}
from
'
@uniswap/v3-sdk
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
usePool
}
from
'
hooks/usePools
'
import
JSBI
from
'
jsbi
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
...
...
@@ -126,7 +126,7 @@ export function useV3DerivedMintInfo(
invertPrice
:
boolean
ticksAtLimit
:
{
[
bound
in
Bound
]?:
boolean
|
undefined
}
}
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
{
independentField
,
typedValue
,
leftRangeTypedValue
,
rightRangeTypedValue
,
startPriceTypedValue
}
=
useV3MintState
()
...
...
src/state/stake/hooks.tsx
View file @
322cdaf8
...
...
@@ -3,8 +3,8 @@ import { Trans } from '@lingui/macro'
import
{
abi
as
STAKING_REWARDS_ABI
}
from
'
@uniswap/liquidity-staker/build/StakingRewards.json
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
JSBI
from
'
jsbi
'
import
{
NEVER_RELOAD
,
useMultipleContractSingleData
}
from
'
lib/hooks/multicall
'
...
...
@@ -75,7 +75,7 @@ export interface StakingInfo {
// gets the staking info from the network for the active chain id
export
function
useStakingInfo
(
pairToFilterBy
?:
Pair
|
null
):
StakingInfo
[]
{
const
{
chainId
,
account
}
=
use
Active
Web3React
()
const
{
chainId
,
account
}
=
useWeb3React
()
// detect if staking is ended
const
currentBlockTimestamp
=
useCurrentBlockTimestamp
()
...
...
@@ -229,7 +229,7 @@ export function useStakingInfo(pairToFilterBy?: Pair | null): StakingInfo[] {
}
export
function
useTotalUniEarned
():
CurrencyAmount
<
Token
>
|
undefined
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
uni
=
chainId
?
UNI
[
chainId
]
:
undefined
const
stakingInfos
=
useStakingInfo
()
...
...
@@ -253,7 +253,7 @@ export function useDerivedStakeInfo(
parsedAmount
?:
CurrencyAmount
<
Token
>
error
?:
ReactNode
}
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
parsedInput
:
CurrencyAmount
<
Token
>
|
undefined
=
tryParseCurrencyAmount
(
typedValue
,
stakingToken
)
...
...
src/state/swap/hooks.tsx
View file @
322cdaf8
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useAutoSlippageTolerance
from
'
hooks/useAutoSlippageTolerance
'
import
{
useBestTrade
}
from
'
hooks/useBestTrade
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
...
...
@@ -87,7 +87,7 @@ export function useDerivedSwapInfo(): {
}
allowedSlippage
:
Percent
}
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
{
independentField
,
...
...
@@ -247,7 +247,7 @@ export function queryParametersToSwapState(parsedQs: ParsedQs): SwapState {
// updates the swap state to use the defaults for a given network
export
function
useDefaultsFromURLSearch
():
SwapState
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
dispatch
=
useAppDispatch
()
const
parsedQs
=
useParsedQueryString
()
...
...
src/state/transactions/hooks.tsx
View file @
322cdaf8
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
useAppDispatch
,
useAppSelector
}
from
'
state/hooks
'
...
...
@@ -9,7 +9,7 @@ import { TransactionDetails, TransactionInfo, TransactionType } from './types'
// helper that can take a ethers library transaction response and add it to the list of transactions
export
function
useTransactionAdder
():
(
response
:
TransactionResponse
,
info
:
TransactionInfo
)
=>
void
{
const
{
chainId
,
account
}
=
use
Active
Web3React
()
const
{
chainId
,
account
}
=
useWeb3React
()
const
dispatch
=
useAppDispatch
()
return
useCallback
(
...
...
@@ -29,7 +29,7 @@ export function useTransactionAdder(): (response: TransactionResponse, info: Tra
// returns all the transactions for the current chain
export
function
useAllTransactions
():
{
[
txHash
:
string
]:
TransactionDetails
}
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
state
=
useAppSelector
((
state
)
=>
state
.
transactions
)
...
...
src/state/transactions/updater.tsx
View file @
322cdaf8
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
DEFAULT_TXN_DISMISS_MS
,
L2_TXN_DISMISS_MS
}
from
'
constants/misc
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
LibUpdater
from
'
lib/hooks/transactions/updater
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
useAppDispatch
,
useAppSelector
}
from
'
state/hooks
'
...
...
@@ -9,7 +9,7 @@ import { useAddPopup } from '../application/hooks'
import
{
checkedTransaction
,
finalizeTransaction
}
from
'
./reducer
'
export
default
function
Updater
()
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
addPopup
=
useAddPopup
()
// speed up popup dismisall time if on L2
const
isL2
=
Boolean
(
chainId
&&
L2_CHAIN_IDS
.
includes
(
chainId
))
...
...
src/state/user/hooks.tsx
View file @
322cdaf8
import
{
Percent
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
computePairAddress
,
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
L2_CHAIN_IDS
}
from
'
constants/chains
'
import
{
SupportedLocale
}
from
'
constants/locales
'
import
{
L2_DEADLINE_FROM_NOW
}
from
'
constants/misc
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
JSBI
from
'
jsbi
'
import
{
useCallback
,
useMemo
}
from
'
react
'
...
...
@@ -217,7 +217,7 @@ export function useUserSlippageToleranceWithDefault(defaultSlippageTolerance: Pe
}
export
function
useUserTransactionTTL
():
[
number
,
(
slippage
:
number
)
=>
void
]
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
dispatch
=
useAppDispatch
()
const
userDeadline
=
useAppSelector
((
state
)
=>
state
.
user
.
userDeadline
)
const
onL2
=
Boolean
(
chainId
&&
L2_CHAIN_IDS
.
includes
(
chainId
))
...
...
@@ -254,7 +254,7 @@ export function useRemoveUserAddedToken(): (chainId: number, address: string) =>
}
export
function
useUserAddedTokens
():
Token
[]
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
serializedTokensMap
=
useAppSelector
(({
user
:
{
tokens
}
})
=>
tokens
)
return
useMemo
(()
=>
{
...
...
@@ -311,7 +311,7 @@ export function toV2LiquidityToken([tokenA, tokenB]: [Token, Token]): Token {
* Returns all the pairs of tokens that are tracked by the user for the current chain ID.
*/
export
function
useTrackedTokenPairs
():
[
Token
,
Token
][]
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
tokens
=
useAllTokens
()
// pinned pairs
...
...
src/state/wallet/hooks.ts
View file @
322cdaf8
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
useTokenBalance
,
useTokenBalancesWithLoadingIndicator
}
from
'
lib/hooks/useCurrencyBalance
'
import
{
useMemo
}
from
'
react
'
...
...
@@ -20,7 +20,7 @@ export {
// mimics useAllBalances
export
function
useAllTokenBalances
():
[{
[
tokenAddress
:
string
]:
CurrencyAmount
<
Token
>
|
undefined
},
boolean
]
{
const
{
account
}
=
use
Active
Web3React
()
const
{
account
}
=
useWeb3React
()
const
allTokens
=
useAllTokens
()
const
allTokensArray
=
useMemo
(()
=>
Object
.
values
(
allTokens
??
{}),
[
allTokens
])
const
[
balances
,
balancesIsLoading
]
=
useTokenBalancesWithLoadingIndicator
(
account
??
undefined
,
allTokensArray
)
...
...
@@ -29,7 +29,7 @@ export function useAllTokenBalances(): [{ [tokenAddress: string]: CurrencyAmount
// get the total owned, unclaimed, and unharvested UNI for account
export
function
useAggregateUniBalance
():
CurrencyAmount
<
Token
>
|
undefined
{
const
{
account
,
chainId
}
=
use
Active
Web3React
()
const
{
account
,
chainId
}
=
useWeb3React
()
const
uni
=
chainId
?
UNI
[
chainId
]
:
undefined
...
...
src/test-utils.tsx
View file @
322cdaf8
import
{
i18n
}
from
'
@lingui/core
'
import
{
I18nProvider
}
from
'
@lingui/react
'
import
{
render
}
from
'
@testing-library/react
'
import
{
Web3ReactProvider
}
from
'
@web3-react/core
'
import
{
injected
,
injectedHooks
}
from
'
connectors
'
import
Web3Provider
from
'
components/Web3Provider
'
import
{
DEFAULT_LOCALE
}
from
'
constants/locales
'
import
{
en
}
from
'
make-plural/plurals
'
import
{
ReactElement
,
ReactNode
}
from
'
react
'
...
...
@@ -26,9 +25,9 @@ const WithProviders = ({ children }: { children?: ReactNode }) => {
return
(
<
MockedI18nProvider
>
<
Provider
store=
{
store
}
>
<
Web3
ReactProvider
connectors=
{
[[
injected
,
injectedHooks
]]
}
>
<
Web3
Provider
>
<
ThemeProvider
>
{
children
}
</
ThemeProvider
>
</
Web3
React
Provider
>
</
Web3Provider
>
</
Provider
>
</
MockedI18nProvider
>
)
...
...
src/theme/RadialGradientByChainUpdater.ts
View file @
322cdaf8
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useEffect
}
from
'
react
'
import
{
useDarkModeManager
}
from
'
state/user/hooks
'
...
...
@@ -27,7 +27,7 @@ const setBackground = (newValues: TargetBackgroundStyles) =>
}
})
export
default
function
RadialGradientByChainUpdater
():
null
{
const
{
chainId
}
=
use
Active
Web3React
()
const
{
chainId
}
=
useWeb3React
()
const
[
darkMode
]
=
useDarkModeManager
()
// manage background color
useEffect
(()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment