forked from aurora-is-near/near-api-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
57 lines (52 loc) · 1.01 KB
/
config.go
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
package near
import (
"os"
"path/filepath"
)
// A Config for the NEAR network.
type Config struct {
NetworkID string
NodeURL string
KeyPath string
}
var home string
func init() {
var err error
home, err = os.UserHomeDir()
if err != nil {
panic(err)
}
}
// GetConfig returns the NEAR network config depending on the setting of the
// environment variable NEAR_ENV.
func GetConfig() *Config {
switch os.Getenv("NEAR_ENV") {
case "production":
fallthrough
case "mainnet":
return &Config{
NetworkID: "mainnet",
NodeURL: "https://rpc.mainnet.near.org",
}
case "betanet":
return &Config{
NetworkID: "betanet",
NodeURL: "https://rpc.betanet.near.org",
}
case "local":
return &Config{
NetworkID: "local",
NodeURL: "http://localhost:3030",
KeyPath: filepath.Join(home, ".near", "validator_key.json"),
}
case "development":
fallthrough
case "testnet":
fallthrough
default:
return &Config{
NetworkID: "default",
NodeURL: "https://rpc.testnet.near.org",
}
}
}