forked from passportxyz/passport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chains.ts
182 lines (165 loc) · 4.59 KB
/
chains.ts
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import { TEST_MODE } from "../context/testModeState";
import {
AttestationProvider,
AttestationProviderConfig,
EASAttestationProvider,
VeraxAndEASAttestationProvider,
} from "./AttestationProvider";
// RPC urls
const MAINNET_RPC_URL = process.env.NEXT_PUBLIC_PASSPORT_MAINNET_RPC_URL as string;
const sepoliaChainId = "0xaa36a7";
const hardhatChainId = "0x7a69";
const baseGoerliChainId = "0x14a33";
const pgnChainId = "0x1a8";
const lineaChainId = "0xe708";
const lineaGoerliChainId = "0xe704";
const optimismChainId = "0xa";
const sepoliaOPChainId = "0xaa37dc";
type ChainConfig = {
id: string;
token: string;
label: string;
rpcUrl: string;
icon: string;
attestationProviderConfig?: AttestationProviderConfig;
};
export class Chain {
id: string;
token: string;
label: string;
rpcUrl: string;
icon: string;
attestationProvider?: AttestationProvider;
constructor({ id, token, label, rpcUrl, icon, attestationProviderConfig }: ChainConfig) {
this.id = id;
this.token = token;
this.label = label;
this.rpcUrl = rpcUrl;
this.icon = icon;
if (attestationProviderConfig) {
const attestationConfig = { ...attestationProviderConfig, chainId: this.id };
switch (attestationConfig.name) {
case "Ethereum Attestation Service":
this.attestationProvider = new EASAttestationProvider(attestationConfig);
break;
case "Verax + EAS":
this.attestationProvider = new VeraxAndEASAttestationProvider(attestationConfig);
break;
default:
break;
}
}
}
}
const chainConfigs: ChainConfig[] = [
{
id: "0x1",
token: "ETH",
label: "Ethereum Mainnet",
rpcUrl: MAINNET_RPC_URL,
icon: "./assets/eth-network-logo.svg",
},
];
const usingTestEnvironment = process.env.NEXT_PUBLIC_ENABLE_TESTNET === "on" || TEST_MODE;
if (usingTestEnvironment) {
chainConfigs.push({
id: sepoliaChainId,
token: "ETH",
label: "Sepolia",
rpcUrl: process.env.NEXT_PUBLIC_PASSPORT_SEPOLIA_RPC_URL as string,
icon: "./assets/eth-network-logo.svg",
});
chainConfigs.push({
id: hardhatChainId,
token: "ETH",
label: "Hardhat",
rpcUrl: "http://127.0.0.1:8545/",
icon: "./assets/eth-network-logo.svg",
});
chainConfigs.push({
id: sepoliaOPChainId,
token: "ETH",
label: "OP Sepolia Testnet",
rpcUrl: "https://sepolia.optimism.io",
icon: "./assets/op-logo.svg",
attestationProviderConfig: {
name: "Ethereum Attestation Service",
status: "enabled",
easScanUrl: "https://optimism-sepolia.easscan.org",
},
});
chainConfigs.push({
id: lineaGoerliChainId,
token: "ETH",
label: "Linea Goerli",
rpcUrl: "https://rpc.goerli.linea.build",
icon: "./assets/linea-logo.png",
attestationProviderConfig: {
name: "Verax + EAS",
status: "enabled",
easScanUrl: "https://linea-goerli.easscan.org",
},
});
}
if (!TEST_MODE) {
if (process.env.NEXT_PUBLIC_FF_MULTICHAIN_SIGNATURE === "on") {
chainConfigs.push({
id: "0x89",
token: "MATIC",
label: "Polygon Mainnet",
rpcUrl: "https://matic-mainnet.chainstacklabs.com",
icon: "./assets/eth-network-logo.svg",
});
chainConfigs.push({
id: "0xfa",
token: "FTM",
label: "Fantom Mainnet",
rpcUrl: "https://rpc.ftm.tools/",
icon: "./assets/eth-network-logo.svg",
});
}
chainConfigs.push({
id: optimismChainId,
token: "ETH",
label: "Optimism",
rpcUrl: process.env.NEXT_PUBLIC_PASSPORT_OP_RPC_URL as string,
icon: "./assets/op-logo.svg",
attestationProviderConfig: {
name: "Ethereum Attestation Service",
status: usingTestEnvironment ? "disabled" : "enabled",
easScanUrl: "https://optimism.easscan.org",
},
});
chainConfigs.push({
id: lineaChainId,
token: "ETH",
label: "Linea",
rpcUrl: "https://rpc.linea.build",
icon: "./assets/linea-logo.png",
attestationProviderConfig: {
name: "Verax + EAS",
status: "enabled",
easScanUrl: "https://linea.easscan.org",
},
});
chainConfigs.push({
id: "0xa86a",
token: "AVAX",
label: "Avalanche",
rpcUrl: "https://api.avax.network/ext/bc/C/rpc",
icon: "./assets/avax-logo.svg",
});
}
chainConfigs.push({
id: pgnChainId,
token: "ETH",
label: "Public Goods Network",
rpcUrl: "https://rpc.publicgoods.network ",
icon: "./assets/pgn-logo.png",
attestationProviderConfig: {
name: "Ethereum Attestation Service",
status: "comingSoon",
easScanUrl: "",
},
});
export const chains: Chain[] = chainConfigs.map((config) => new Chain(config));