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
fb389137
Unverified
Commit
fb389137
authored
Sep 13, 2022
by
Zach Pomerantz
Committed by
GitHub
Sep 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: adds ethers provider tracing (#4614)
parent
c14b6a78
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
260 additions
and
85 deletions
+260
-85
.eslintrc.json
.eslintrc.json
+12
-0
ethereum.ts
cypress/support/ethereum.ts
+1
-0
FeatureFlagModal.tsx
src/components/FeatureFlagModal/FeatureFlagModal.tsx
+9
-0
index.tsx
src/components/Web3Provider/index.tsx
+35
-2
ClaimRewardModal.tsx
src/components/earn/ClaimRewardModal.tsx
+1
-1
StakingModal.tsx
src/components/earn/StakingModal.tsx
+1
-1
UnstakingModal.tsx
src/components/earn/UnstakingModal.tsx
+1
-1
index.ts
src/connection/index.ts
+3
-2
networks.ts
src/constants/networks.ts
+125
-31
providers.ts
src/constants/providers.ts
+31
-0
featureFlags.ts
src/featureFlags/flags/featureFlags.ts
+1
-0
traceJsonRpc.ts
src/featureFlags/flags/traceJsonRpc.ts
+7
-0
useFetchListCallback.ts
src/hooks/useFetchListCallback.ts
+1
-1
useSendSwapTransaction.tsx
src/lib/hooks/swap/useSendSwapTransaction.tsx
+1
-1
useSwapCallback.tsx
src/lib/hooks/swap/useSwapCallback.tsx
+1
-1
useApproval.ts
src/lib/hooks/useApproval.ts
+1
-1
useSendTransaction.ts
src/nft/hooks/useSendTransaction.ts
+1
-1
useWalletBalance.ts
src/nft/hooks/useWalletBalance.ts
+1
-1
claimLooks.ts
src/nft/utils/claimLooks.ts
+1
-1
listNfts.ts
src/nft/utils/listNfts.ts
+1
-1
x2y2.ts
src/nft/utils/x2y2.ts
+1
-1
index.tsx
src/pages/AddLiquidity/index.tsx
+1
-1
index.tsx
src/pages/AddLiquidityV2/index.tsx
+1
-1
MigrateV2Pair.tsx
src/pages/MigrateV2/MigrateV2Pair.tsx
+1
-1
CTACards.test.tsx
src/pages/Pool/CTACards.test.tsx
+1
-1
PositionPage.tsx
src/pages/Pool/PositionPage.tsx
+1
-1
V3.tsx
src/pages/RemoveLiquidity/V3.tsx
+1
-1
index.tsx
src/pages/RemoveLiquidity/index.tsx
+1
-1
hooks.ts
src/state/claim/hooks.ts
+1
-1
hooks.ts
src/state/governance/hooks.ts
+1
-1
hooks.ts
src/state/logs/hooks.ts
+1
-1
slice.ts
src/state/logs/slice.ts
+1
-1
updater.ts
src/state/logs/updater.ts
+1
-1
utils.ts
src/state/logs/utils.ts
+1
-1
slice.ts
src/state/routing/slice.ts
+1
-1
hooks.tsx
src/state/transactions/hooks.tsx
+1
-1
index.ts
src/utils/index.ts
+1
-1
switchChain.ts
src/utils/switchChain.ts
+8
-22
No files found.
.eslintrc.json
View file @
fb389137
...
...
@@ -81,6 +81,18 @@
}
]
}
],
"@typescript-eslint/no-restricted-imports"
:
[
"error"
,
{
"paths"
:
[
{
"name"
:
"@ethersproject/providers"
,
"message"
:
"Please only use Providers instantiated in constants/providers to improve traceability."
,
"allowTypeImports"
:
true
}
]
}
]
}
}
cypress/support/ethereum.ts
View file @
fb389137
...
...
@@ -3,6 +3,7 @@
*/
import
{
Eip1193Bridge
}
from
'
@ethersproject/experimental/lib/eip1193-bridge
'
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import
{
JsonRpcProvider
}
from
'
@ethersproject/providers
'
import
{
Wallet
}
from
'
@ethersproject/wallet
'
...
...
src/components/FeatureFlagModal/FeatureFlagModal.tsx
View file @
fb389137
...
...
@@ -5,6 +5,7 @@ import { RedesignVariant, useRedesignFlag } from 'featureFlags/flags/redesign'
import
{
TokensVariant
,
useTokensFlag
}
from
'
featureFlags/flags/tokens
'
import
{
TokenSafetyVariant
,
useTokenSafetyFlag
}
from
'
featureFlags/flags/tokenSafety
'
import
{
TokensNetworkFilterVariant
,
useTokensNetworkFilterFlag
}
from
'
featureFlags/flags/tokensNetworkFilter
'
import
{
TraceJsonRpcVariant
,
useTraceJsonRpcFlag
}
from
'
featureFlags/flags/traceJsonRpc
'
import
{
useAtomValue
,
useUpdateAtom
}
from
'
jotai/utils
'
import
{
Children
,
PropsWithChildren
,
ReactElement
,
ReactNode
,
useCallback
,
useState
}
from
'
react
'
import
{
X
}
from
'
react-feather
'
...
...
@@ -241,6 +242,14 @@ export default function FeatureFlagModal() {
<
FeatureFlagGroup
name=
"Phase 1"
>
<
FeatureFlagOption
variant=
{
NftVariant
}
value=
{
useNftFlag
()
}
featureFlag=
{
FeatureFlag
.
nft
}
label=
"NFTs"
/>
</
FeatureFlagGroup
>
<
FeatureFlagGroup
name=
"Debug"
>
<
FeatureFlagOption
variant=
{
TraceJsonRpcVariant
}
value=
{
useTraceJsonRpcFlag
()
}
featureFlag=
{
FeatureFlag
.
traceJsonRpc
}
label=
"Enables JSON-RPC tracing"
/>
</
FeatureFlagGroup
>
<
SaveButton
onClick=
{
()
=>
window
.
location
.
reload
()
}
>
Reload
</
SaveButton
>
</
Modal
>
)
...
...
src/components/Web3Provider/index.tsx
View file @
fb389137
import
{
Web3ReactHooks
,
Web3ReactProvider
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
@uniswap/widgets
'
import
{
useWeb3React
,
Web3ReactHooks
,
Web3ReactProvider
}
from
'
@web3-react/core
'
import
{
Connector
}
from
'
@web3-react/types
'
import
{
Connection
}
from
'
connection
'
import
{
getConnectionName
}
from
'
connection/utils
'
import
{
RPC_PROVIDERS
}
from
'
constants/providers
'
import
{
TraceJsonRpcVariant
,
useTraceJsonRpcFlag
}
from
'
featureFlags/flags/traceJsonRpc
'
import
useEagerlyConnect
from
'
hooks/useEagerlyConnect
'
import
useOrderedConnections
from
'
hooks/useOrderedConnections
'
import
{
ReactNode
,
useMemo
}
from
'
react
'
import
{
ReactNode
,
use
Effect
,
use
Memo
}
from
'
react
'
export
default
function
Web3Provider
({
children
}:
{
children
:
ReactNode
})
{
useEagerlyConnect
()
...
...
@@ -15,7 +18,37 @@ export default function Web3Provider({ children }: { children: ReactNode }) {
return
(
<
Web3ReactProvider
connectors=
{
connectors
}
key=
{
key
}
>
<
Tracer
/>
{
children
}
</
Web3ReactProvider
>
)
}
function
Tracer
()
{
const
{
chainId
,
provider
}
=
useWeb3React
()
const
networkProvider
=
RPC_PROVIDERS
[(
chainId
||
SupportedChainId
.
MAINNET
)
as
SupportedChainId
]
const
shouldTrace
=
useTraceJsonRpcFlag
()
===
TraceJsonRpcVariant
.
Enabled
useEffect
(()
=>
{
if
(
shouldTrace
)
{
provider
?.
on
(
'
debug
'
,
trace
)
if
(
provider
!==
networkProvider
)
{
networkProvider
.
on
(
'
debug
'
,
trace
)
}
}
return
()
=>
{
provider
?.
off
(
'
debug
'
,
trace
)
networkProvider
.
off
(
'
debug
'
,
trace
)
}
},
[
networkProvider
,
provider
,
shouldTrace
])
return
null
}
function
trace
(
event
:
any
)
{
if
(
event
.
action
!==
'
request
'
)
return
const
{
method
,
id
,
params
}
=
event
.
request
console
.
groupCollapsed
(
method
,
id
)
console
.
debug
(
params
)
console
.
groupEnd
()
}
src/components/earn/ClaimRewardModal.tsx
View file @
fb389137
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
StakingRewardsJson
from
'
@uniswap/liquidity-staker/build/StakingRewards.json
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
...
...
src/components/earn/StakingModal.tsx
View file @
fb389137
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
StakingRewardsJson
from
'
@uniswap/liquidity-staker/build/StakingRewards.json
'
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
...
...
src/components/earn/UnstakingModal.tsx
View file @
fb389137
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
StakingRewardsJson
from
'
@uniswap/liquidity-staker/build/StakingRewards.json
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
...
...
src/connection/index.ts
View file @
fb389137
...
...
@@ -8,7 +8,8 @@ import { WalletConnect } from '@web3-react/walletconnect'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
UNISWAP_LOGO_URL
from
'
../assets/svg/logo.svg
'
import
{
RPC_PROVIDERS
,
RPC_URLS
}
from
'
../constants/networks
'
import
{
RPC_URLS
}
from
'
../constants/networks
'
import
{
RPC_PROVIDERS
}
from
'
../constants/providers
'
export
enum
ConnectionType
{
INJECTED
=
'
INJECTED
'
,
...
...
@@ -73,7 +74,7 @@ const [web3CoinbaseWallet, web3CoinbaseWalletHooks] = initializeConnector<Coinba
new
CoinbaseWallet
({
actions
,
options
:
{
url
:
RPC_URLS
[
SupportedChainId
.
MAINNET
],
url
:
RPC_URLS
[
SupportedChainId
.
MAINNET
]
[
0
]
,
appName
:
'
Uniswap
'
,
appLogoUrl
:
UNISWAP_LOGO_URL
,
reloadOnDisconnect
:
false
,
...
...
src/constants/networks.ts
View file @
fb389137
import
{
StaticJsonRpcProvider
}
from
'
@ethersproject/providers
'
import
{
SupportedChainId
}
from
'
./chains
'
const
INFURA_KEY
=
process
.
env
.
REACT_APP_INFURA_KEY
...
...
@@ -8,36 +6,132 @@ if (typeof INFURA_KEY === 'undefined') {
}
/**
* These are the network URLs used by the interface when there is not another available source of chain data
* Fallback JSON-RPC endpoints.
* These are used if the integrator does not provide an endpoint, or if the endpoint does not work.
*
* MetaMask allows switching to any URL, but displays a warning if it is not on the "Safe" list:
* https://github.com/MetaMask/metamask-mobile/blob/bdb7f37c90e4fc923881a07fca38d4e77c73a579/app/core/RPCMethods/wallet_addEthereumChain.js#L228-L235
* https://chainid.network/chains.json
*
* These "Safe" URLs are listed first, followed by other fallback URLs, which are taken from chainlist.org.
*/
export
const
RPC_URLS
:
{
[
key
in
SupportedChainId
]:
string
}
=
{
[
SupportedChainId
.
MAINNET
]:
`https://mainnet.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
RINKEBY
]:
`https://rinkeby.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
ROPSTEN
]:
`https://ropsten.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
GOERLI
]:
`https://goerli.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
KOVAN
]:
`https://kovan.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
OPTIMISM
]:
`https://optimism-mainnet.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
OPTIMISTIC_KOVAN
]:
`https://optimism-kovan.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
ARBITRUM_ONE
]:
`https://arbitrum-mainnet.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
ARBITRUM_RINKEBY
]:
`https://arbitrum-rinkeby.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
POLYGON
]:
`https://polygon-mainnet.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
POLYGON_MUMBAI
]:
`https://polygon-mumbai.infura.io/v3/
${
INFURA_KEY
}
`
,
[
SupportedChainId
.
CELO
]:
`https://forno.celo.org`
,
[
SupportedChainId
.
CELO_ALFAJORES
]:
`https://alfajores-forno.celo-testnet.org`
,
export
const
FALLBACK_URLS
:
{
[
key
in
SupportedChainId
]:
string
[]
}
=
{
[
SupportedChainId
.
MAINNET
]:
[
// "Safe" URLs
'
https://api.mycryptoapi.com/eth
'
,
'
https://cloudflare-eth.com
'
,
// "Fallback" URLs
'
https://rpc.ankr.com/eth
'
,
'
https://eth-mainnet.public.blastapi.io
'
,
],
[
SupportedChainId
.
ROPSTEN
]:
[
// "Fallback" URLs
'
https://rpc.ankr.com/eth_ropsten
'
,
],
[
SupportedChainId
.
RINKEBY
]:
[
// "Fallback" URLs
'
https://rinkeby-light.eth.linkpool.io/
'
,
],
[
SupportedChainId
.
GOERLI
]:
[
// "Safe" URLs
'
https://rpc.goerli.mudit.blog/
'
,
// "Fallback" URLs
'
https://rpc.ankr.com/eth_goerli
'
,
],
[
SupportedChainId
.
KOVAN
]:
[
// "Safe" URLs
'
https://kovan.poa.network
'
,
// "Fallback" URLs
'
https://eth-kovan.public.blastapi.io
'
,
],
[
SupportedChainId
.
POLYGON
]:
[
// "Safe" URLs
'
https://polygon-rpc.com/
'
,
'
https://rpc-mainnet.matic.network
'
,
'
https://matic-mainnet.chainstacklabs.com
'
,
'
https://rpc-mainnet.maticvigil.com
'
,
'
https://rpc-mainnet.matic.quiknode.pro
'
,
'
https://matic-mainnet-full-rpc.bwarelabs.com
'
,
],
[
SupportedChainId
.
POLYGON_MUMBAI
]:
[
// "Safe" URLs
'
https://matic-mumbai.chainstacklabs.com
'
,
'
https://rpc-mumbai.maticvigil.com
'
,
'
https://matic-testnet-archive-rpc.bwarelabs.com
'
,
],
[
SupportedChainId
.
ARBITRUM_ONE
]:
[
// "Safe" URLs
'
https://arb1.arbitrum.io/rpc
'
,
// "Fallback" URLs
'
https://arbitrum.public-rpc.com
'
,
],
[
SupportedChainId
.
ARBITRUM_RINKEBY
]:
[
// "Safe" URLs
'
https://rinkeby.arbitrum.io/rpc
'
,
],
[
SupportedChainId
.
OPTIMISM
]:
[
// "Safe" URLs
'
https://mainnet.optimism.io/
'
,
// "Fallback" URLs
'
https://rpc.ankr.com/optimism
'
,
],
[
SupportedChainId
.
OPTIMISTIC_KOVAN
]:
[
// "Safe" URLs
'
https://kovan.optimism.io
'
,
],
[
SupportedChainId
.
CELO
]:
[
// "Safe" URLs
`https://forno.celo.org`
,
],
[
SupportedChainId
.
CELO_ALFAJORES
]:
[
// "Safe" URLs
`https://alfajores-forno.celo-testnet.org`
,
],
}
export
const
RPC_PROVIDERS
:
{
[
key
in
SupportedChainId
]:
StaticJsonRpcProvider
}
=
{
[
SupportedChainId
.
MAINNET
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
MAINNET
]),
[
SupportedChainId
.
RINKEBY
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
RINKEBY
]),
[
SupportedChainId
.
ROPSTEN
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
ROPSTEN
]),
[
SupportedChainId
.
GOERLI
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
GOERLI
]),
[
SupportedChainId
.
KOVAN
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
KOVAN
]),
[
SupportedChainId
.
OPTIMISM
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
OPTIMISM
]),
[
SupportedChainId
.
OPTIMISTIC_KOVAN
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
OPTIMISTIC_KOVAN
]),
[
SupportedChainId
.
ARBITRUM_ONE
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
ARBITRUM_ONE
]),
[
SupportedChainId
.
ARBITRUM_RINKEBY
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
ARBITRUM_RINKEBY
]),
[
SupportedChainId
.
POLYGON
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
POLYGON
]),
[
SupportedChainId
.
POLYGON_MUMBAI
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
POLYGON_MUMBAI
]),
[
SupportedChainId
.
CELO
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
CELO
]),
[
SupportedChainId
.
CELO_ALFAJORES
]:
new
StaticJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
CELO_ALFAJORES
]),
/**
* Known JSON-RPC endpoints.
* These are the URLs used by the interface when there is not another available source of chain data.
*/
export
const
RPC_URLS
:
{
[
key
in
SupportedChainId
]:
string
[]
}
=
{
[
SupportedChainId
.
MAINNET
]:
[
`https://mainnet.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
MAINNET
],
],
[
SupportedChainId
.
RINKEBY
]:
[
`https://rinkeby.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
RINKEBY
],
],
[
SupportedChainId
.
ROPSTEN
]:
[
`https://ropsten.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
ROPSTEN
],
],
[
SupportedChainId
.
GOERLI
]:
[
`https://goerli.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
GOERLI
]],
[
SupportedChainId
.
KOVAN
]:
[
`https://kovan.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
KOVAN
]],
[
SupportedChainId
.
OPTIMISM
]:
[
`https://optimism-mainnet.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
OPTIMISM
],
],
[
SupportedChainId
.
OPTIMISTIC_KOVAN
]:
[
`https://optimism-kovan.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
OPTIMISTIC_KOVAN
],
],
[
SupportedChainId
.
ARBITRUM_ONE
]:
[
`https://arbitrum-mainnet.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
ARBITRUM_ONE
],
],
[
SupportedChainId
.
ARBITRUM_RINKEBY
]:
[
`https://arbitrum-rinkeby.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
ARBITRUM_RINKEBY
],
],
[
SupportedChainId
.
POLYGON
]:
[
`https://polygon-mainnet.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
POLYGON
],
],
[
SupportedChainId
.
POLYGON_MUMBAI
]:
[
`https://polygon-mumbai.infura.io/v3/
${
INFURA_KEY
}
`
,
...
FALLBACK_URLS
[
SupportedChainId
.
POLYGON_MUMBAI
],
],
[
SupportedChainId
.
CELO
]:
FALLBACK_URLS
[
SupportedChainId
.
CELO
],
[
SupportedChainId
.
CELO_ALFAJORES
]:
FALLBACK_URLS
[
SupportedChainId
.
CELO_ALFAJORES
],
}
src/constants/providers.ts
0 → 100644
View file @
fb389137
// This is the only file which should instantiate new Providers.
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import
{
StaticJsonRpcProvider
}
from
'
@ethersproject/providers
'
import
{
SupportedChainId
}
from
'
./chains
'
import
{
RPC_URLS
}
from
'
./networks
'
class
AppJsonRpcProvider
extends
StaticJsonRpcProvider
{
constructor
(
urls
:
string
[])
{
super
(
urls
[
0
])
}
}
/**
* These are the only JsonRpcProviders used directly by the interface.
*/
export
const
RPC_PROVIDERS
:
{
[
key
in
SupportedChainId
]:
StaticJsonRpcProvider
}
=
{
[
SupportedChainId
.
MAINNET
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
MAINNET
]),
[
SupportedChainId
.
RINKEBY
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
RINKEBY
]),
[
SupportedChainId
.
ROPSTEN
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
ROPSTEN
]),
[
SupportedChainId
.
GOERLI
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
GOERLI
]),
[
SupportedChainId
.
KOVAN
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
KOVAN
]),
[
SupportedChainId
.
OPTIMISM
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
OPTIMISM
]),
[
SupportedChainId
.
OPTIMISTIC_KOVAN
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
OPTIMISTIC_KOVAN
]),
[
SupportedChainId
.
ARBITRUM_ONE
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
ARBITRUM_ONE
]),
[
SupportedChainId
.
ARBITRUM_RINKEBY
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
ARBITRUM_RINKEBY
]),
[
SupportedChainId
.
POLYGON
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
POLYGON
]),
[
SupportedChainId
.
POLYGON_MUMBAI
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
POLYGON_MUMBAI
]),
[
SupportedChainId
.
CELO
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
CELO
]),
[
SupportedChainId
.
CELO_ALFAJORES
]:
new
AppJsonRpcProvider
(
RPC_URLS
[
SupportedChainId
.
CELO_ALFAJORES
]),
}
src/featureFlags/flags/featureFlags.ts
View file @
fb389137
...
...
@@ -5,4 +5,5 @@ export enum FeatureFlag {
tokens
=
'
tokens
'
,
tokensNetworkFilter
=
'
tokensNetworkFilter
'
,
tokenSafety
=
'
tokenSafety
'
,
traceJsonRpc
=
'
traceJsonRpc
'
,
}
src/featureFlags/flags/traceJsonRpc.ts
0 → 100644
View file @
fb389137
import
{
BaseVariant
,
FeatureFlag
,
useBaseFlag
}
from
'
../index
'
export
function
useTraceJsonRpcFlag
():
BaseVariant
{
return
useBaseFlag
(
FeatureFlag
.
traceJsonRpc
)
}
export
{
BaseVariant
as
TraceJsonRpcVariant
}
src/hooks/useFetchListCallback.ts
View file @
fb389137
import
{
nanoid
}
from
'
@reduxjs/toolkit
'
import
{
TokenList
}
from
'
@uniswap/token-lists
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
{
RPC_PROVIDERS
}
from
'
constants/
network
s
'
import
{
RPC_PROVIDERS
}
from
'
constants/
provider
s
'
import
getTokenList
from
'
lib/hooks/useTokenList/fetchTokenList
'
import
resolveENSContentHash
from
'
lib/utils/resolveENSContentHash
'
import
{
useCallback
}
from
'
react
'
...
...
src/lib/hooks/swap/useSendSwapTransaction.tsx
View file @
fb389137
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
JsonRpcProvider
,
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
JsonRpcProvider
,
TransactionResponse
}
from
'
@ethersproject/providers
'
// eslint-disable-next-line no-restricted-imports
import
{
t
,
Trans
}
from
'
@lingui/macro
'
import
{
Trade
}
from
'
@uniswap/router-sdk
'
...
...
src/lib/hooks/swap/useSwapCallback.tsx
View file @
fb389137
// eslint-disable-next-line no-restricted-imports
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Trade
}
from
'
@uniswap/router-sdk
'
import
{
Currency
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
...
...
src/lib/hooks/useApproval.ts
View file @
fb389137
import
{
MaxUint256
}
from
'
@ethersproject/constants
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Currency
,
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
sendAnalyticsEvent
}
from
'
components/AmplitudeAnalytics
'
...
...
src/nft/hooks/useSendTransaction.ts
View file @
fb389137
...
...
@@ -2,7 +2,7 @@ import { Interface } from '@ethersproject/abi'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
hexStripZeros
}
from
'
@ethersproject/bytes
'
import
{
ContractReceipt
}
from
'
@ethersproject/contracts
'
import
{
JsonRpcSigner
}
from
'
@ethersproject/providers
'
import
type
{
JsonRpcSigner
}
from
'
@ethersproject/providers
'
import
create
from
'
zustand
'
import
{
devtools
}
from
'
zustand/middleware
'
...
...
src/nft/hooks/useWalletBalance.ts
View file @
fb389137
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
Web3Provider
}
from
'
@ethersproject/providers
'
import
type
{
Web3Provider
}
from
'
@ethersproject/providers
'
import
{
parseEther
}
from
'
@ethersproject/units
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useNativeCurrencyBalances
}
from
'
state/connection/hooks
'
...
...
src/nft/utils/claimLooks.ts
View file @
fb389137
import
{
Signer
}
from
'
@ethersproject/abstract-signer
'
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
{
BaseProvider
}
from
'
@ethersproject/providers
'
import
type
{
BaseProvider
}
from
'
@ethersproject/providers
'
const
looksRareContract
=
new
Contract
(
'
0xea37093ce161f090e443f304e1bf3a8f14d7bb40
'
,
[
{
...
...
src/nft/utils/listNfts.ts
View file @
fb389137
import
{
Signer
}
from
'
@ethersproject/abstract-signer
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
{
JsonRpcSigner
,
Web3Provider
}
from
'
@ethersproject/providers
'
import
type
{
JsonRpcSigner
,
Web3Provider
}
from
'
@ethersproject/providers
'
import
{
parseEther
}
from
'
@ethersproject/units
'
import
{
addressesByNetwork
,
MakerOrder
,
signMakerOrder
,
SupportedChainId
}
from
'
@looksrare/sdk
'
import
{
Seaport
}
from
'
@opensea/seaport-js
'
...
...
src/nft/utils/x2y2.ts
View file @
fb389137
...
...
@@ -3,7 +3,7 @@ import { BigNumber, BigNumberish } from '@ethersproject/bignumber'
import
{
hexZeroPad
}
from
'
@ethersproject/bytes
'
import
{
AddressZero
}
from
'
@ethersproject/constants
'
import
{
keccak256
}
from
'
@ethersproject/keccak256
'
import
{
Web3Provider
}
from
'
@ethersproject/providers
'
import
type
{
Web3Provider
}
from
'
@ethersproject/providers
'
import
{
randomBytes
}
from
'
@ethersproject/random
'
const
dataParamType
=
`tuple(address token, uint256 tokenId)[]`
...
...
src/pages/AddLiquidity/index.tsx
View file @
fb389137
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
FeeAmount
,
NonfungiblePositionManager
}
from
'
@uniswap/v3-sdk
'
...
...
src/pages/AddLiquidityV2/index.tsx
View file @
fb389137
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
CurrencyAmount
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
...
...
src/pages/MigrateV2/MigrateV2Pair.tsx
View file @
fb389137
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
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
'
...
...
src/pages/Pool/CTACards.test.tsx
View file @
fb389137
...
...
@@ -9,7 +9,7 @@ jest.mock('@web3-react/core', () => {
return
{
...
web3React
,
useWeb3React
:
()
=>
({
chainId
:
99999
,
chainId
:
42
,
}),
}
})
...
...
src/pages/Pool/PositionPage.tsx
View file @
fb389137
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
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
'
...
...
src/pages/RemoveLiquidity/V3.tsx
View file @
fb389137
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
CurrencyAmount
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
NonfungiblePositionManager
}
from
'
@uniswap/v3-sdk
'
...
...
src/pages/RemoveLiquidity/index.tsx
View file @
fb389137
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Currency
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
...
...
src/state/claim/hooks.ts
View file @
fb389137
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
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
'
...
...
src/state/governance/hooks.ts
View file @
fb389137
...
...
@@ -2,7 +2,7 @@ import { defaultAbiCoder, Interface } from '@ethersproject/abi'
import
{
isAddress
}
from
'
@ethersproject/address
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
toUtf8String
,
Utf8ErrorFuncs
,
Utf8ErrorReason
}
from
'
@ethersproject/strings
'
// eslint-disable-next-line no-restricted-imports
import
{
t
}
from
'
@lingui/macro
'
...
...
src/state/logs/hooks.ts
View file @
fb389137
import
{
Filter
}
from
'
@ethersproject/providers
'
import
type
{
Filter
}
from
'
@ethersproject/providers
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
import
{
useEffect
,
useMemo
}
from
'
react
'
...
...
src/state/logs/slice.ts
View file @
fb389137
import
{
Filter
}
from
'
@ethersproject/providers
'
import
type
{
Filter
}
from
'
@ethersproject/providers
'
import
{
createSlice
,
PayloadAction
}
from
'
@reduxjs/toolkit
'
import
{
filterToKey
,
Log
}
from
'
./utils
'
...
...
src/state/logs/updater.ts
View file @
fb389137
import
{
Filter
}
from
'
@ethersproject/providers
'
import
type
{
Filter
}
from
'
@ethersproject/providers
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
useBlockNumber
from
'
lib/hooks/useBlockNumber
'
import
{
useEffect
,
useMemo
}
from
'
react
'
...
...
src/state/logs/utils.ts
View file @
fb389137
import
{
Filter
}
from
'
@ethersproject/providers
'
import
type
{
Filter
}
from
'
@ethersproject/providers
'
export
interface
Log
{
topics
:
Array
<
string
>
...
...
src/state/routing/slice.ts
View file @
fb389137
import
{
createApi
,
fetchBaseQuery
,
FetchBaseQueryError
}
from
'
@reduxjs/toolkit/query/react
'
import
{
Protocol
}
from
'
@uniswap/router-sdk
'
import
{
AlphaRouter
,
ChainId
}
from
'
@uniswap/smart-order-router
'
import
{
RPC_PROVIDERS
}
from
'
constants/
network
s
'
import
{
RPC_PROVIDERS
}
from
'
constants/
provider
s
'
import
{
getClientSideQuote
,
toSupportedChainId
}
from
'
lib/hooks/routing/clientSideSmartOrderRouter
'
import
ms
from
'
ms.macro
'
import
qs
from
'
qs
'
...
...
src/state/transactions/hooks.tsx
View file @
fb389137
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
type
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useCallback
,
useMemo
}
from
'
react
'
...
...
src/utils/index.ts
View file @
fb389137
import
{
getAddress
}
from
'
@ethersproject/address
'
import
{
AddressZero
}
from
'
@ethersproject/constants
'
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
{
JsonRpcProvider
,
JsonRpcSigner
}
from
'
@ethersproject/providers
'
import
type
{
JsonRpcProvider
,
JsonRpcSigner
}
from
'
@ethersproject/providers
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
ChainTokenMap
}
from
'
lib/hooks/useTokenList/utils
'
...
...
src/utils/switchChain.ts
View file @
fb389137
...
...
@@ -2,36 +2,22 @@ import { Connector } from '@web3-react/types'
import
{
networkConnection
,
walletConnectConnection
}
from
'
connection
'
import
{
getChainInfo
}
from
'
constants/chainInfo
'
import
{
isSupportedChain
,
SupportedChainId
}
from
'
constants/chains
'
import
{
RPC_URLS
}
from
'
constants/networks
'
import
{
FALLBACK_URLS
,
RPC_URLS
}
from
'
constants/networks
'
function
getRpcUrl
s
(
chainId
:
SupportedChainId
):
[
string
]
{
function
getRpcUrl
(
chainId
:
SupportedChainId
):
string
{
switch
(
chainId
)
{
case
SupportedChainId
.
MAINNET
:
case
SupportedChainId
.
RINKEBY
:
case
SupportedChainId
.
ROPSTEN
:
case
SupportedChainId
.
KOVAN
:
case
SupportedChainId
.
GOERLI
:
return
[
RPC_URLS
[
chainId
]]
case
SupportedChainId
.
OPTIMISM
:
return
[
'
https://mainnet.optimism.io
'
]
case
SupportedChainId
.
OPTIMISTIC_KOVAN
:
return
[
'
https://kovan.optimism.io
'
]
case
SupportedChainId
.
ARBITRUM_ONE
:
return
[
'
https://arb1.arbitrum.io/rpc
'
]
case
SupportedChainId
.
ARBITRUM_RINKEBY
:
return
[
'
https://rinkeby.arbitrum.io/rpc
'
]
case
SupportedChainId
.
POLYGON
:
return
[
'
https://polygon-rpc.com/
'
]
case
SupportedChainId
.
POLYGON_MUMBAI
:
return
[
'
https://rpc-endpoints.superfluid.dev/mumbai
'
]
case
SupportedChainId
.
CELO
:
return
[
'
https://forno.celo.org
'
]
case
SupportedChainId
.
CELO_ALFAJORES
:
return
[
'
https://alfajores-forno.celo-testnet.org
'
]
return
RPC_URLS
[
chainId
][
0
]
// Attempting to add a chain using an infura URL will not work, as the URL will be unreachable from the MetaMask background page.
// MetaMask allows switching to any publicly reachable URL, but for novel chains, it will display a warning if it is not on the "Safe" list.
// See the definition of FALLBACK_URLS for more details.
default
:
return
FALLBACK_URLS
[
chainId
][
0
]
}
// Our API-keyed URLs will fail security checks when used with external wallets.
throw
new
Error
(
'
RPC URLs must use public endpoints
'
)
}
export
const
switchChain
=
async
(
connector
:
Connector
,
chainId
:
SupportedChainId
)
=>
{
...
...
@@ -44,7 +30,7 @@ export const switchChain = async (connector: Connector, chainId: SupportedChainI
const
addChainParameter
=
{
chainId
,
chainName
:
info
.
label
,
rpcUrls
:
getRpcUrls
(
chainId
)
,
rpcUrls
:
[
getRpcUrl
(
chainId
)]
,
nativeCurrency
:
info
.
nativeCurrency
,
blockExplorerUrls
:
[
info
.
explorer
],
}
...
...
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