-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmod.rs
60 lines (51 loc) · 2.5 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::error::Error;
/// All known subgraph endpoints
#[derive(Debug, Clone)]
pub struct KnownSubgraphs;
impl KnownSubgraphs {
/// Rain known subgraphs on ethereum mainnet
pub const ETHEREUM: [&'static str; 3] = [
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry-ethereum", // legacy endpoint
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry-np-eth", // np endpoint
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry-npe2-eth", // npe2 endpoint
];
/// Rain known subgraphs on polygon mainnet
pub const POLYGON: [&'static str; 3] = [
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry-polygon", // legacy endpoint
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry-np-matic", // np endpoint
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry-npe2-mati", // npe2 endpoint
];
/// Rain known subgraphs on mumbai (polygon testnet)
pub const MUMBAI: [&'static str; 3] = [
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry", // legacy endpoint
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry-np", // np endpoint
"https://api.thegraph.com/subgraphs/name/rainlanguage/interpreter-registry-npe2", // npe2 endpoint
];
/// Rain NPE2 subgraphs of all supported networks
pub const NPE2: [&'static str; 3] = [Self::ETHEREUM[2], Self::POLYGON[2], Self::MUMBAI[2]];
/// Rain NativeParser subgraphs of all supported networks
pub const NP: [&'static str; 3] = [Self::ETHEREUM[1], Self::POLYGON[1], Self::MUMBAI[1]];
/// Rain legacy(non NativeParser) subgraphs of all supported networks
pub const LEGACY: [&'static str; 3] = [Self::ETHEREUM[0], Self::POLYGON[0], Self::MUMBAI[0]];
/// All Rain known subgraph endpoint URLs
pub const ALL: [&'static str; 9] = [
Self::ETHEREUM[0],
Self::ETHEREUM[1],
Self::ETHEREUM[2],
Self::POLYGON[0],
Self::POLYGON[1],
Self::POLYGON[2],
Self::MUMBAI[0],
Self::MUMBAI[1],
Self::MUMBAI[2],
];
/// get the subgraph endpoint from a chain id
pub fn of_chain(chain_id: u64) -> Result<[&'static str; 3], Error> {
match chain_id {
1 => Ok(Self::ETHEREUM),
137 => Ok(Self::POLYGON),
80001 => Ok(Self::MUMBAI),
_ => Err(Error::UnsupportedNetwork),
}
}
}