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
52790ac9
Unverified
Commit
52790ac9
authored
Jul 12, 2021
by
Justin Domingue
Committed by
GitHub
Jul 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support optimism and arbitrum subgraphs (#2001)
parent
380ca11d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
slice.ts
src/state/data/slice.ts
+16
-15
No files found.
src/state/data/slice.ts
View file @
52790ac9
...
...
@@ -5,7 +5,12 @@ import { DocumentNode } from 'graphql'
import
{
ClientError
,
gql
,
GraphQLClient
}
from
'
graphql-request
'
import
{
AppState
}
from
'
state
'
const
UNISWAP_V3_GRAPH_URL
=
'
https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3
'
// List of supported subgraphs. Note that the app currently only support one active subgraph at a time
const
CHAIN_SUBGRAPH_URL
:
Record
<
number
,
string
>
=
{
[
SupportedChainId
.
MAINNET
]:
'
https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3
'
,
[
SupportedChainId
.
ARBITRUM_ONE
]:
'
https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-arbitrum-one
'
,
[
SupportedChainId
.
OPTIMISM
]:
'
https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-optimism
'
,
}
export
const
api
=
createApi
({
reducerPath
:
'
dataApi
'
,
...
...
@@ -78,23 +83,19 @@ function graphqlRequestBaseQuery(): BaseQueryFn<
try
{
const
chainId
=
(
getState
()
as
AppState
).
application
.
chainId
let
client
:
GraphQLClient
|
null
=
null
const
subgraphUrl
=
chainId
?
CHAIN_SUBGRAPH_URL
[
chainId
]
:
undefined
switch
(
chainId
)
{
case
SupportedChainId
.
MAINNET
:
client
=
new
GraphQLClient
(
UNISWAP_V3_GRAPH_URL
)
break
default
:
return
{
error
:
{
name
:
'
UnsupportedChainId
'
,
message
:
`Subgraph queries again ChainId
${
chainId
}
are not supported.`
,
stack
:
''
,
},
}
if
(
!
subgraphUrl
)
{
return
{
error
:
{
name
:
'
UnsupportedChainId
'
,
message
:
`Subgraph queries against ChainId
${
chainId
}
are not supported.`
,
stack
:
''
,
},
}
}
return
{
data
:
await
client
.
request
(
document
,
variables
),
meta
:
{}
}
return
{
data
:
await
new
GraphQLClient
(
subgraphUrl
)
.
request
(
document
,
variables
),
meta
:
{}
}
}
catch
(
error
)
{
if
(
error
instanceof
ClientError
)
{
const
{
name
,
message
,
stack
,
request
,
response
}
=
error
...
...
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