|
1 | 1 | /**
|
2 | 2 | * @see https://docs.sablier.com/api/overview
|
3 | 3 | */
|
4 |
| -import { ChainId } from "./chains/ids"; |
5 |
| -import type { Sablier } from "./types"; |
| 4 | +import { ChainId } from "@src/chains/ids"; |
| 5 | +import type { Sablier } from "@src/types"; |
6 | 6 |
|
7 |
| -const ENVIO_BASE_URL = "https://indexer.hyperindex.xyz"; |
8 | 7 | const THEGRAPH_ORG_ID = 57079; // Sablier organization ID on The Graph
|
9 | 8 |
|
10 |
| -const envio = { |
11 |
| - endpoints: { |
12 |
| - airdrops: `${ENVIO_BASE_URL}/508d217/v1/graphql`, |
13 |
| - flow: `${ENVIO_BASE_URL}/3b4ea6b/v1/graphql`, |
14 |
| - lockup: `${ENVIO_BASE_URL}/53b7e25/v1/graphql`, |
15 |
| - }, |
16 |
| - /** |
17 |
| - * Chains not supported by Envio. Monitor their docs for updates. |
18 |
| - * @see https://docs.envio.dev/docs/HyperSync/hypersync-supported-networks |
19 |
| - * @see https://github.com/enviodev/docs/issues/619 |
20 |
| - */ |
21 |
| - unsupportedChains: { |
22 |
| - [ChainId.CORE_DAO]: true, |
23 |
| - [ChainId.FORM]: true, |
24 |
| - [ChainId.IOTEX]: true, |
25 |
| - [ChainId.LIGHTLINK]: true, |
26 |
| - [ChainId.SEI]: true, |
27 |
| - [ChainId.SUPERSEED]: true, |
28 |
| - [ChainId.TAIKO]: true, |
29 |
| - [ChainId.TANGLE]: true, |
30 |
| - [ChainId.ULTRA]: true, |
31 |
| - }, |
32 |
| -}; |
| 9 | +type OfficialSubgraphMap = Record<number, { id: string; name: string }>; |
33 | 10 |
|
34 |
| -const subgraphs: Record<Sablier.Protocol, Sablier.Subgraphs> = { |
| 11 | +const officialSubgraphs: Record<Sablier.Protocol, OfficialSubgraphMap> = { |
35 | 12 | airdrops: {
|
36 | 13 | // ────────────────────────────────────────────────────────────────────────────────
|
37 | 14 | // Mainnets
|
@@ -162,27 +139,82 @@ const subgraphs: Record<Sablier.Protocol, Sablier.Subgraphs> = {
|
162 | 139 | },
|
163 | 140 | };
|
164 | 141 |
|
165 |
| -/** @internal */ |
166 |
| -export function getEnvioEndpoint(protocol: Sablier.Protocol, chainId: number): string | undefined { |
167 |
| - if (protocol === "legacy" || chainId in envio.unsupportedChains) { |
168 |
| - return undefined; |
169 |
| - } |
170 |
| - return envio.endpoints[protocol]; |
171 |
| -} |
| 142 | +type CustomSubgraphMap = Record<number, { explorer?: string; url: string }>; |
| 143 | + |
| 144 | +const baseURLs = { |
| 145 | + LIGHTLINK: "https://graph.phoenix.lightlink.io/query/subgraphs/name/lightlink", |
| 146 | + ULTRA: "https://graph.evm.ultra.io/subgraphs/name/sablier", |
| 147 | + XDC: "https://graphql.xinfin.network/subgraphs/name/xdc", |
| 148 | +}; |
| 149 | + |
| 150 | +const customSubgraphs: Record<Sablier.Protocol, CustomSubgraphMap> = { |
| 151 | + airdrops: { |
| 152 | + [ChainId.LIGHTLINK]: { |
| 153 | + explorer: `${baseURLs.LIGHTLINK}/sablier-airdrops-lightlink/graphql`, |
| 154 | + url: `${baseURLs.LIGHTLINK}/sablier-airdrops-lightlink`, |
| 155 | + }, |
| 156 | + [ChainId.ULTRA]: { |
| 157 | + url: `${baseURLs.ULTRA}/sablier-airdrops-ultra`, |
| 158 | + }, |
| 159 | + [ChainId.XDC]: { |
| 160 | + explorer: `${baseURLs.XDC}/sablier-airdrops-xdc/graphql`, |
| 161 | + url: `${baseURLs.XDC}/sablier-airdrops-xdc`, |
| 162 | + }, |
| 163 | + }, |
| 164 | + flow: { |
| 165 | + [ChainId.LIGHTLINK]: { |
| 166 | + explorer: `${baseURLs.LIGHTLINK}/sablier-flow-lightlink/graphql`, |
| 167 | + url: `${baseURLs.LIGHTLINK}/sablier-flow-lightlink`, |
| 168 | + }, |
| 169 | + [ChainId.ULTRA]: { |
| 170 | + url: `${baseURLs.ULTRA}/sablier-flow-ultra`, |
| 171 | + }, |
| 172 | + [ChainId.XDC]: { |
| 173 | + explorer: `${baseURLs.XDC}/sablier-flow-xdc/graphql`, |
| 174 | + url: `${baseURLs.XDC}/sablier-flow-xdc`, |
| 175 | + }, |
| 176 | + }, |
| 177 | + legacy: { |
| 178 | + [ChainId.RONIN]: { |
| 179 | + url: "https://subgraph.satsuma-prod.com/d8d041c49d56/sablierlabs/sablier-ronin/api", |
| 180 | + }, |
| 181 | + }, |
| 182 | + lockup: { |
| 183 | + [ChainId.LIGHTLINK]: { |
| 184 | + explorer: `${baseURLs.LIGHTLINK}/sablier-lockup-lightlink/graphql`, |
| 185 | + url: `${baseURLs.LIGHTLINK}/sablier-lockup-lightlink`, |
| 186 | + }, |
| 187 | + [ChainId.ULTRA]: { |
| 188 | + url: `${baseURLs.ULTRA}/sablier-lockup-ultra`, |
| 189 | + }, |
| 190 | + [ChainId.XDC]: { |
| 191 | + explorer: `${baseURLs.XDC}/sablier-lockup-xdc/graphql`, |
| 192 | + url: `${baseURLs.XDC}/sablier-lockup-xdc`, |
| 193 | + }, |
| 194 | + }, |
| 195 | +}; |
172 | 196 |
|
173 | 197 | /** @internal */
|
174 | 198 | export function getTheGraph(protocol: Sablier.Protocol, chainId: number): Sablier.TheGraph | undefined {
|
175 |
| - const subgraph = subgraphs[protocol][chainId]; |
176 |
| - if (!subgraph) { |
177 |
| - return undefined; |
| 199 | + const officialSubgraph = officialSubgraphs[protocol][chainId]; |
| 200 | + if (officialSubgraph) { |
| 201 | + return { |
| 202 | + explorer: `https://thegraph.com/explorer/subgraphs/${officialSubgraph.id}`, |
| 203 | + studio: `https://api.studio.thegraph.com/query/${THEGRAPH_ORG_ID}/${officialSubgraph.name}/version/latest`, |
| 204 | + subgraph: { |
| 205 | + id: officialSubgraph.id, |
| 206 | + url: (apiKey: string) => `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/${officialSubgraph.id}`, |
| 207 | + }, |
| 208 | + }; |
| 209 | + } |
| 210 | + |
| 211 | + const customSubgraph = customSubgraphs[protocol][chainId]; |
| 212 | + if (customSubgraph) { |
| 213 | + return { |
| 214 | + customURL: customSubgraph.url, |
| 215 | + explorer: customSubgraph.explorer, |
| 216 | + }; |
178 | 217 | }
|
179 | 218 |
|
180 |
| - return { |
181 |
| - explorer: `https://thegraph.com/explorer/subgraphs/${subgraph.id}`, |
182 |
| - studio: `https://api.studio.thegraph.com/query/${THEGRAPH_ORG_ID}/${subgraph.name}/version/latest`, |
183 |
| - subgraph: { |
184 |
| - id: subgraph.id, |
185 |
| - url: (apiKey: string) => `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/${subgraph.id}`, |
186 |
| - }, |
187 |
| - }; |
| 219 | + return undefined; |
188 | 220 | }
|
0 commit comments