-
Notifications
You must be signed in to change notification settings - Fork 242
/
create_account.go
89 lines (69 loc) · 3.05 KB
/
create_account.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
package requests
import (
"errors"
)
var ErrCreateAccountInvalidDisplayName = errors.New("create-account: invalid display name")
var ErrCreateAccountInvalidPassword = errors.New("create-account: invalid password")
var ErrCreateAccountInvalidCustomizationColor = errors.New("create-account: invalid customization color")
var ErrCreateAccountInvalidRootKeystoreDir = errors.New("create-account: invalid root keystore directory")
var ErrCreateAccountInvalidBackupDisabledDataDir = errors.New("create-account: invalid backup disabled data directory")
var ErrCreateAccountInvalidLogFilePath = errors.New("create-account: invalid log file path")
type CreateAccount struct {
// BackupDisabledDataDir is the directory where backup is disabled
BackupDisabledDataDir string `json:"backupDisabledDataDir"`
DeviceName string `json:"deviceName"`
DisplayName string `json:"displayName"`
Password string `json:"password"`
ImagePath string `json:"imagePath"`
CustomizationColor string `json:"customizationColor"`
WakuV2Nameserver *string `json:"wakuV2Nameserver"`
WakuV2LightClient bool `json:"wakuV2LightClient"`
LogLevel *string `json:"logLevel"`
LogFilePath string `json:"logFilePath"`
LogEnabled bool `json:"logEnabled"`
PreviewPrivacy bool `json:"previewPrivacy"`
VerifyTransactionURL *string `json:"verifyTransactionURL"`
VerifyENSURL *string `json:"verifyENSURL"`
VerifyENSContractAddress *string `json:"verifyENSContractAddress"`
VerifyTransactionChainID *int64 `json:"verifyTransactionChainID"`
UpstreamConfig string `json:"upstreamConfig"`
CurrentNetwork string `json:"currentNetwork"`
NetworkID uint64 `json:"networkId"`
WalletSecretsConfig
}
type WalletSecretsConfig struct {
PoktToken string `json:"poktToken"`
InfuraToken string `json:"infuraToken"`
InfuraSecret string `json:"infuraSecret"`
OpenseaAPIKey string `json:"openseaApiKey"`
// Testing
GanacheURL string `json:"ganacheURL"`
AlchemyEthereumMainnetToken string `json:"alchemyEthereumMainnetToken"`
AlchemyEthereumGoerliToken string `json:"alchemyEthereumGoerliToken"`
AlchemyArbitrumMainnetToken string `json:"alchemyArbitrumMainnetToken"`
AlchemyArbitrumGoerliToken string `json:"alchemyArbitrumGoerliToken"`
AlchemyOptimismMainnetToken string `json:"alchemyOptimismMainnetToken"`
AlchemyOptimismGoerliToken string `json:"alchemyOptimismGoerliToken"`
}
func (c *CreateAccount) Validate() error {
return ValidateAccountCreationRequest(*c)
}
func ValidateAccountCreationRequest(c CreateAccount) error {
// TODO(cammellos): Add proper validation for password/displayname/etc
if len(c.DisplayName) == 0 {
return ErrCreateAccountInvalidDisplayName
}
if len(c.Password) == 0 {
return ErrCreateAccountInvalidPassword
}
if len(c.CustomizationColor) == 0 {
return ErrCreateAccountInvalidCustomizationColor
}
if len(c.BackupDisabledDataDir) == 0 {
return ErrCreateAccountInvalidBackupDisabledDataDir
}
if len(c.LogFilePath) == 0 {
return ErrCreateAccountInvalidLogFilePath
}
return nil
}