forked from sismo-core/sismo-badges
-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper-hardhat-config.ts
79 lines (69 loc) · 2.08 KB
/
helper-hardhat-config.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
import dotenv from 'dotenv';
dotenv.config({});
export type Network = EthereumNetwork | PolygonNetwork | GnosisNetwork;
export enum EthereumNetwork {
kovan = 'kovan',
goerli = 'goerli',
rinkeby = 'rinkeby',
main = 'main',
hardhat = 'hardhat',
tenderlyMain = 'tenderlyMain',
harhatevm = 'harhatevm',
}
export enum PolygonNetwork {
main = 'polygon-mainnet',
mumbai = 'mumbai',
}
export enum GnosisNetwork {
gnosis = 'gnosis',
}
export type ParamsPerNetwork<T> =
| EthereumParamsPerNetwork<T>
| PolygonParamsPerNetwork<T>
| XDaiParamsPerNetwork<T>;
export interface EthereumParamsPerNetwork<Network> {
[EthereumNetwork.harhatevm]: Network;
[EthereumNetwork.rinkeby]: Network;
[EthereumNetwork.main]: Network;
[EthereumNetwork.hardhat]: Network;
[EthereumNetwork.tenderlyMain]: Network;
[EthereumNetwork.goerli]: Network;
}
export interface PolygonParamsPerNetwork<T> {
[PolygonNetwork.main]: T;
[PolygonNetwork.mumbai]: T;
}
export interface XDaiParamsPerNetwork<T> {
[GnosisNetwork.gnosis]: T;
}
export interface ObjectString {
[key: string]: string;
}
export const alchemyUrlOrEnvVar = (defaultAlchemyUrl: string, rpcUrl?: string): string => {
const defaultUrl = `${defaultAlchemyUrl}/${process.env.ALCHEMY_KEY}`;
return rpcUrl ? rpcUrl : defaultUrl;
};
export const NETWORKS_RPC_URL: ParamsPerNetwork<string> = {
[EthereumNetwork.rinkeby]: alchemyUrlOrEnvVar(
'https://eth-rinkeby.alchemyapi.io/v2',
process.env.RINKEBY_RPC_URL
),
[EthereumNetwork.main]: alchemyUrlOrEnvVar(
'https://eth-mainnet.alchemyapi.io/v2',
process.env.MAINNET_RPC_URL
),
[EthereumNetwork.goerli]: alchemyUrlOrEnvVar(
'https://eth-goerli.g.alchemy.com/v2',
process.env.MAINNET_RPC_URL
),
[EthereumNetwork.hardhat]: 'http://localhost:8545',
[PolygonNetwork.mumbai]: alchemyUrlOrEnvVar(
'https://polygon-mumbai.g.alchemy.com/v2',
process.env.MUMBAI_RPC_URL
),
[PolygonNetwork.main]: alchemyUrlOrEnvVar(
'https://polygon-mainnet.g.alchemy.com/v2',
process.env.POLYGON_RPC_URL
),
[GnosisNetwork.gnosis]: 'https://rpc.gnosischain.com',
};