-
Notifications
You must be signed in to change notification settings - Fork 16
/
config.ts
126 lines (114 loc) · 3.97 KB
/
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
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
import { OAuthProvider } from "@interep/reputation"
import getNextConfig from "next/config"
import { Provider } from "./types/groups"
import { NetworkData } from "./types/network"
const defaultEnv = {
CRON_INTERVAL: 1, // Minutes.
API_WHITELIST: [
/^http:\/\/localhost/,
/^http:\/\/127.0.0.1/,
/^https:\/\/kovan\.interep\.link/,
/^https:\/\/goerli\.interep\.link/,
/^https:\/\/auti\.sm/,
/^https:\/\/www\.auti\.sm/,
/^https:\/\/vercel\.app/,
/^https:\/\/[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.varcel\.app/
]
}
export const merkleTreeDepths: Record<Provider, number> = {
[OAuthProvider.TWITTER]: 20,
[OAuthProvider.REDDIT]: 20,
[OAuthProvider.GITHUB]: 20,
telegram: 20,
email: 20,
poap: 20
}
export enum Environment {
TEST = "test",
DEVELOPMENT = "development",
PRODUCTION = "production"
}
export enum ContractName {
INTEREP = "Interep"
}
export enum SupportedChainId {
LOCALHOST = 31337,
GOERLI = 5,
KOVAN = 42,
ARBITRUM = 42161
}
export const contractAddresses: Record<SupportedChainId, Record<ContractName, any>> = {
[SupportedChainId.LOCALHOST]: {
[ContractName.INTEREP]: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
},
[SupportedChainId.GOERLI]: {
[ContractName.INTEREP]: "0xF1bFF6E09C7d66a1AAb44b822C629f5dd9c97174"
},
[SupportedChainId.KOVAN]: {
[ContractName.INTEREP]: "0xF58D3b710cDD337df432e20a806Ad04f6CfE53De"
},
[SupportedChainId.ARBITRUM]: {
[ContractName.INTEREP]: "0xa2A7f256B4Ea653eef95965D09bbdBb4b4526419"
}
}
export const supportedNetworks: Record<string, NetworkData> = {
localhost: {
name: "localhost",
chainId: SupportedChainId.LOCALHOST
},
goerli: {
name: "goerli",
chainId: SupportedChainId.GOERLI
},
kovan: {
name: "kovan",
chainId: SupportedChainId.KOVAN
},
arbitrum: {
name: "arbitrum",
chainId: SupportedChainId.ARBITRUM
}
}
export const currentNetwork: NetworkData = (function IIFE(): NetworkData {
switch (process.env.NODE_ENV as Environment) {
case Environment.PRODUCTION: {
const nextConfig = getNextConfig()
let defaultNetwork
if (nextConfig) {
defaultNetwork = getNextConfig().publicRuntimeConfig.defaultNetwork
} else {
// nextConfig is undefined when this file is imported from an external resource to nextJS.
defaultNetwork = process.env.DEFAULT_NETWORK
}
if (!(defaultNetwork in supportedNetworks)) {
throw new Error("DEFAULT_NETWORK variable has not been defined correctly")
}
return supportedNetworks[defaultNetwork]
}
default:
return supportedNetworks.localhost
}
})()
export default {
MONGO_URL: process.env.MONGO_URL,
TWITTER_CONSUMER_KEY: process.env.TWITTER_CONSUMER_KEY,
TWITTER_CONSUMER_SECRET: process.env.TWITTER_CONSUMER_SECRET,
TWITTER_ACCESS_TOKEN: process.env.TWITTER_ACCESS_TOKEN,
TWITTER_ACCESS_TOKEN_SECRET: process.env.TWITTER_ACCESS_TOKEN_SECRET,
GITHUB_CLIENT_ID: process.env.GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET,
REDDIT_CLIENT_ID: process.env.REDDIT_CLIENT_ID,
REDDIT_CLIENT_SECRET: process.env.REDDIT_CLIENT_SECRET,
GMAIL_ADDRESS: process.env.GMAIL_ADDRESS,
GMAIL_CLIENT_ID: process.env.GMAIL_CLIENT_ID,
GMAIL_CLIENT_SECRET: process.env.GMAIL_CLIENT_SECRET,
GMAIL_REFRESH_TOKEN: process.env.GMAIL_REFRESH_TOKEN,
GMAIL_ACCESS_TOKEN: process.env.GMAIL_ACCESS_TOKEN,
RAPIDAPI_KEY: process.env.RAPIDAPI_KEY,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
JWT_SIGNING_PRIVATE_KEY: process.env.JWT_SIGNING_PRIVATE_KEY,
JWT_SECRET: process.env.JWT_SECRET,
CRON_INTERVAL: defaultEnv.CRON_INTERVAL,
API_WHITELIST: defaultEnv.API_WHITELIST
}