This repository has been archived by the owner on Nov 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
testnet.go
90 lines (77 loc) · 2.49 KB
/
testnet.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
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
package loader
import (
"fmt"
"log"
"github.com/Varunram/essentials/email"
"github.com/pkg/errors"
"github.com/spf13/viper"
algorand "github.com/Varunram/essentials/algorand"
stablecoin "github.com/Varunram/essentials/xlm/stablecoin"
// utils "github.com/Varunram/essentials/utils"
consts "github.com/YaleOpenLab/openx/consts"
database "github.com/YaleOpenLab/openx/database"
openx "github.com/YaleOpenLab/openx/platforms"
)
// Testnet loads the stuff needed for testnet. Ordering is very important since some consts need the others
// to function correctly
func Testnet() error {
log.Println("initializing openx testnet..")
consts.SetConsts(false)
database.CreateHomeDir()
var err error
// init stablecoin before platform so we don't have to create a stablecoin in case our dbdir is wiped
consts.StablecoinPublicKey, consts.StablecoinSeed, err = stablecoin.InitStableCoin()
if err != nil {
return errors.Wrap(err, "errored out while starting stablecoin")
}
// start platform
err = openx.InitializePlatform()
if err != nil {
return err
}
// read from consts
viper.SetConfigType("yaml")
viper.SetConfigName("config")
viper.AddConfigPath(".")
err = viper.ReadInConfig()
if err != nil {
log.Println("Error while reading platform email from config file")
return err
}
if viper.IsSet("algodAddress") {
consts.AlgodAddress = viper.GetString("algodAddress")
}
if viper.IsSet("algodToken") {
consts.AlgodToken = viper.GetString("algodToken")
}
if viper.IsSet("kmdAddress") {
consts.KmdAddress = viper.GetString("kmdAddress")
}
if viper.IsSet("kmdToken") {
consts.KmdToken = viper.GetString("kmdToken")
}
err = algorand.Init()
if err != nil {
return err
}
if !viper.IsSet("platformemail") {
log.Println("platform email not set")
} else {
consts.PlatformEmail = viper.GetString("platformemail")
log.Println("PLATFORM EMAIL: ", consts.PlatformEmail)
}
if !viper.IsSet("platformpass") {
log.Println("platform email password not set")
} else {
consts.PlatformEmailPass = viper.GetString("platformpass")
}
if !viper.IsSet("kycapikey") {
log.Println("kyc api key not set, kyc will be disabled")
} else {
consts.KYCAPIKey = viper.GetString("kycapikey")
}
email.SetConsts(consts.PlatformEmail, consts.PlatformEmailPass)
fmt.Printf("PLATFORM SEED IS: %s\n PLATFORM PUBLIC KEY IS: %s\n", consts.PlatformSeed, consts.PlatformPublicKey)
fmt.Printf("STABLECOIN PUBLICKEY IS: %s\nSTABLECOIN SEED is: %s\n\n", consts.StablecoinPublicKey, consts.StablecoinSeed)
return nil
}