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
09b00c99
Unverified
Commit
09b00c99
authored
Sep 09, 2022
by
Zach Pomerantz
Committed by
GitHub
Sep 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: use static rpc urls (#4599)
parent
b74fb817
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
17 deletions
+28
-17
index.ts
src/connection/index.ts
+2
-2
networks.ts
src/constants/networks.ts
+17
-3
useFetchListCallback.ts
src/hooks/useFetchListCallback.ts
+5
-2
useBlockNumber.tsx
src/lib/hooks/useBlockNumber.tsx
+2
-7
slice.ts
src/state/routing/slice.ts
+2
-3
No files found.
src/connection/index.ts
View file @
09b00c99
...
@@ -8,7 +8,7 @@ import { WalletConnect } from '@web3-react/walletconnect'
...
@@ -8,7 +8,7 @@ import { WalletConnect } from '@web3-react/walletconnect'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
UNISWAP_LOGO_URL
from
'
../assets/svg/logo.svg
'
import
UNISWAP_LOGO_URL
from
'
../assets/svg/logo.svg
'
import
{
RPC_URLS
}
from
'
../constants/networks
'
import
{
RPC_
PROVIDERS
,
RPC_
URLS
}
from
'
../constants/networks
'
export
enum
ConnectionType
{
export
enum
ConnectionType
{
INJECTED
=
'
INJECTED
'
,
INJECTED
=
'
INJECTED
'
,
...
@@ -29,7 +29,7 @@ function onError(error: Error) {
...
@@ -29,7 +29,7 @@ function onError(error: Error) {
}
}
const
[
web3Network
,
web3NetworkHooks
]
=
initializeConnector
<
Network
>
(
const
[
web3Network
,
web3NetworkHooks
]
=
initializeConnector
<
Network
>
(
(
actions
)
=>
new
Network
({
actions
,
urlMap
:
RPC_
URL
S
,
defaultChainId
:
1
})
(
actions
)
=>
new
Network
({
actions
,
urlMap
:
RPC_
PROVIDER
S
,
defaultChainId
:
1
})
)
)
export
const
networkConnection
:
Connection
=
{
export
const
networkConnection
:
Connection
=
{
connector
:
web3Network
,
connector
:
web3Network
,
...
...
src/constants/networks.ts
View file @
09b00c99
import
{
JsonRpcProvider
}
from
'
@ethersproject/providers
'
import
{
Static
JsonRpcProvider
}
from
'
@ethersproject/providers
'
import
{
SupportedChainId
}
from
'
./chains
'
import
{
SupportedChainId
}
from
'
./chains
'
...
@@ -7,8 +7,6 @@ if (typeof INFURA_KEY === 'undefined') {
...
@@ -7,8 +7,6 @@ if (typeof INFURA_KEY === 'undefined') {
throw
new
Error
(
`REACT_APP_INFURA_KEY must be a defined environment variable`
)
throw
new
Error
(
`REACT_APP_INFURA_KEY must be a defined environment variable`
)
}
}
export
const
MAINNET_PROVIDER
=
new
JsonRpcProvider
(
`https://mainnet.infura.io/v3/
${
INFURA_KEY
}
`
)
/**
/**
* These are the network URLs used by the interface when there is not another available source of chain data
* These are the network URLs used by the interface when there is not another available source of chain data
*/
*/
...
@@ -27,3 +25,19 @@ export const RPC_URLS: { [key in SupportedChainId]: string } = {
...
@@ -27,3 +25,19 @@ export const RPC_URLS: { [key in SupportedChainId]: string } = {
[
SupportedChainId
.
CELO
]:
`https://forno.celo.org`
,
[
SupportedChainId
.
CELO
]:
`https://forno.celo.org`
,
[
SupportedChainId
.
CELO_ALFAJORES
]:
`https://alfajores-forno.celo-testnet.org`
,
[
SupportedChainId
.
CELO_ALFAJORES
]:
`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
]),
}
src/hooks/useFetchListCallback.ts
View file @
09b00c99
import
{
nanoid
}
from
'
@reduxjs/toolkit
'
import
{
nanoid
}
from
'
@reduxjs/toolkit
'
import
{
TokenList
}
from
'
@uniswap/token-lists
'
import
{
TokenList
}
from
'
@uniswap/token-lists
'
import
{
MAINNET_PROVIDER
}
from
'
constants/networks
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
{
RPC_PROVIDERS
}
from
'
constants/networks
'
import
getTokenList
from
'
lib/hooks/useTokenList/fetchTokenList
'
import
getTokenList
from
'
lib/hooks/useTokenList/fetchTokenList
'
import
resolveENSContentHash
from
'
lib/utils/resolveENSContentHash
'
import
resolveENSContentHash
from
'
lib/utils/resolveENSContentHash
'
import
{
useCallback
}
from
'
react
'
import
{
useCallback
}
from
'
react
'
...
@@ -16,7 +17,9 @@ export function useFetchListCallback(): (listUrl: string, sendDispatch?: boolean
...
@@ -16,7 +17,9 @@ export function useFetchListCallback(): (listUrl: string, sendDispatch?: boolean
async
(
listUrl
:
string
,
sendDispatch
=
true
)
=>
{
async
(
listUrl
:
string
,
sendDispatch
=
true
)
=>
{
const
requestId
=
nanoid
()
const
requestId
=
nanoid
()
sendDispatch
&&
dispatch
(
fetchTokenList
.
pending
({
requestId
,
url
:
listUrl
}))
sendDispatch
&&
dispatch
(
fetchTokenList
.
pending
({
requestId
,
url
:
listUrl
}))
return
getTokenList
(
listUrl
,
(
ensName
:
string
)
=>
resolveENSContentHash
(
ensName
,
MAINNET_PROVIDER
))
return
getTokenList
(
listUrl
,
(
ensName
:
string
)
=>
resolveENSContentHash
(
ensName
,
RPC_PROVIDERS
[
SupportedChainId
.
MAINNET
])
)
.
then
((
tokenList
)
=>
{
.
then
((
tokenList
)
=>
{
sendDispatch
&&
dispatch
(
fetchTokenList
.
fulfilled
({
url
:
listUrl
,
tokenList
,
requestId
}))
sendDispatch
&&
dispatch
(
fetchTokenList
.
fulfilled
({
url
:
listUrl
,
tokenList
,
requestId
}))
return
tokenList
return
tokenList
...
...
src/lib/hooks/useBlockNumber.tsx
View file @
09b00c99
...
@@ -59,7 +59,6 @@ export function BlockNumberProvider({ children }: { children: ReactNode }) {
...
@@ -59,7 +59,6 @@ export function BlockNumberProvider({ children }: { children: ReactNode }) {
})
})
provider
.
on
(
'
block
'
,
onBlock
)
provider
.
on
(
'
block
'
,
onBlock
)
return
()
=>
{
return
()
=>
{
stale
=
true
stale
=
true
provider
.
removeListener
(
'
block
'
,
onBlock
)
provider
.
removeListener
(
'
block
'
,
onBlock
)
...
@@ -69,11 +68,7 @@ export function BlockNumberProvider({ children }: { children: ReactNode }) {
...
@@ -69,11 +68,7 @@ export function BlockNumberProvider({ children }: { children: ReactNode }) {
return
void
0
return
void
0
},
[
activeChainId
,
provider
,
onBlock
,
setChainBlock
,
windowVisible
])
},
[
activeChainId
,
provider
,
onBlock
,
setChainBlock
,
windowVisible
])
const
value
=
useMemo
(
const
blockValue
=
useMemo
(()
=>
(
chainId
===
activeChainId
?
block
:
undefined
),
[
activeChainId
,
block
,
chainId
])
()
=>
({
const
value
=
useMemo
(()
=>
({
value
:
blockValue
}),
[
blockValue
])
value
:
chainId
===
activeChainId
?
block
:
undefined
,
}),
[
activeChainId
,
block
,
chainId
]
)
return
<
BlockNumberContext
.
Provider
value=
{
value
}
>
{
children
}
</
BlockNumberContext
.
Provider
>
return
<
BlockNumberContext
.
Provider
value=
{
value
}
>
{
children
}
</
BlockNumberContext
.
Provider
>
}
}
src/state/routing/slice.ts
View file @
09b00c99
import
{
JsonRpcProvider
}
from
'
@ethersproject/providers
'
import
{
createApi
,
fetchBaseQuery
,
FetchBaseQueryError
}
from
'
@reduxjs/toolkit/query/react
'
import
{
createApi
,
fetchBaseQuery
,
FetchBaseQueryError
}
from
'
@reduxjs/toolkit/query/react
'
import
{
Protocol
}
from
'
@uniswap/router-sdk
'
import
{
Protocol
}
from
'
@uniswap/router-sdk
'
import
{
AlphaRouter
,
ChainId
}
from
'
@uniswap/smart-order-router
'
import
{
AlphaRouter
,
ChainId
}
from
'
@uniswap/smart-order-router
'
import
{
RPC_
URL
S
}
from
'
constants/networks
'
import
{
RPC_
PROVIDER
S
}
from
'
constants/networks
'
import
{
getClientSideQuote
,
toSupportedChainId
}
from
'
lib/hooks/routing/clientSideSmartOrderRouter
'
import
{
getClientSideQuote
,
toSupportedChainId
}
from
'
lib/hooks/routing/clientSideSmartOrderRouter
'
import
ms
from
'
ms.macro
'
import
ms
from
'
ms.macro
'
import
qs
from
'
qs
'
import
qs
from
'
qs
'
...
@@ -22,7 +21,7 @@ function getRouter(chainId: ChainId): AlphaRouter {
...
@@ -22,7 +21,7 @@ function getRouter(chainId: ChainId): AlphaRouter {
const
supportedChainId
=
toSupportedChainId
(
chainId
)
const
supportedChainId
=
toSupportedChainId
(
chainId
)
if
(
supportedChainId
)
{
if
(
supportedChainId
)
{
const
provider
=
new
JsonRpcProvider
(
RPC_URLS
[
supportedChainId
])
const
provider
=
RPC_PROVIDERS
[
supportedChainId
]
const
router
=
new
AlphaRouter
({
chainId
,
provider
})
const
router
=
new
AlphaRouter
({
chainId
,
provider
})
routers
.
set
(
chainId
,
router
)
routers
.
set
(
chainId
,
router
)
return
router
return
router
...
...
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