2022-10-14 08:50:36 +00:00
|
|
|
package requests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ErrCreateAccountInvalidDisplayName = errors.New("create-account: invalid display name")
|
|
|
|
var ErrCreateAccountInvalidPassword = errors.New("create-account: invalid password")
|
2023-03-22 17:48:42 +00:00
|
|
|
var ErrCreateAccountInvalidCustomizationColor = errors.New("create-account: invalid customization color")
|
2023-03-16 14:49:25 +00:00
|
|
|
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")
|
2022-10-14 08:50:36 +00:00
|
|
|
|
|
|
|
type CreateAccount struct {
|
2023-04-25 12:00:17 +00:00
|
|
|
// BackupDisabledDataDir is the directory where backup is disabled
|
|
|
|
BackupDisabledDataDir string `json:"backupDisabledDataDir"`
|
|
|
|
|
2023-06-27 07:54:49 +00:00
|
|
|
DeviceName string `json:"deviceName"`
|
2023-03-22 17:48:42 +00:00
|
|
|
DisplayName string `json:"displayName"`
|
|
|
|
Password string `json:"password"`
|
|
|
|
ImagePath string `json:"imagePath"`
|
|
|
|
CustomizationColor string `json:"customizationColor"`
|
2023-12-06 10:47:38 +00:00
|
|
|
Emoji string `json:"emoji"`
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2023-07-03 12:48:21 +00:00
|
|
|
WakuV2Nameserver *string `json:"wakuV2Nameserver"`
|
|
|
|
WakuV2LightClient bool `json:"wakuV2LightClient"`
|
2023-04-25 12:00:17 +00:00
|
|
|
|
|
|
|
LogLevel *string `json:"logLevel"`
|
|
|
|
LogFilePath string `json:"logFilePath"`
|
|
|
|
LogEnabled bool `json:"logEnabled"`
|
|
|
|
|
|
|
|
PreviewPrivacy bool `json:"previewPrivacy"`
|
2023-03-16 14:49:25 +00:00
|
|
|
|
|
|
|
VerifyTransactionURL *string `json:"verifyTransactionURL"`
|
|
|
|
VerifyENSURL *string `json:"verifyENSURL"`
|
|
|
|
VerifyENSContractAddress *string `json:"verifyENSContractAddress"`
|
|
|
|
VerifyTransactionChainID *int64 `json:"verifyTransactionChainID"`
|
2023-03-28 14:47:58 +00:00
|
|
|
UpstreamConfig string `json:"upstreamConfig"`
|
2023-04-25 12:00:17 +00:00
|
|
|
|
|
|
|
CurrentNetwork string `json:"currentNetwork"`
|
|
|
|
NetworkID uint64 `json:"networkId"`
|
2023-05-24 15:02:53 +00:00
|
|
|
|
|
|
|
WalletSecretsConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
type WalletSecretsConfig struct {
|
2023-10-12 19:40:13 +00:00
|
|
|
PoktToken string `json:"poktToken"`
|
|
|
|
InfuraToken string `json:"infuraToken"`
|
|
|
|
InfuraSecret string `json:"infuraSecret"`
|
|
|
|
OpenseaAPIKey string `json:"openseaApiKey"`
|
|
|
|
RaribleMainnetAPIKey string `json:"raribleMainnetApiKey"`
|
|
|
|
RaribleTestnetAPIKey string `json:"raribleTestnetApiKey"`
|
2023-04-25 12:00:17 +00:00
|
|
|
|
|
|
|
// Testing
|
|
|
|
GanacheURL string `json:"ganacheURL"`
|
2023-10-03 11:47:27 +00:00
|
|
|
AlchemyEthereumMainnetToken string `json:"alchemyEthereumMainnetToken"`
|
|
|
|
AlchemyEthereumGoerliToken string `json:"alchemyEthereumGoerliToken"`
|
2023-11-16 20:46:01 +00:00
|
|
|
AlchemyEthereumSepoliaToken string `json:"alchemyEthereumSepoliaToken"`
|
2023-04-25 12:00:17 +00:00
|
|
|
AlchemyArbitrumMainnetToken string `json:"alchemyArbitrumMainnetToken"`
|
|
|
|
AlchemyArbitrumGoerliToken string `json:"alchemyArbitrumGoerliToken"`
|
2023-11-16 20:46:01 +00:00
|
|
|
AlchemyArbitrumSepoliaToken string `json:"alchemyArbitrumSepoliaToken"`
|
2023-04-25 12:00:17 +00:00
|
|
|
AlchemyOptimismMainnetToken string `json:"alchemyOptimismMainnetToken"`
|
|
|
|
AlchemyOptimismGoerliToken string `json:"alchemyOptimismGoerliToken"`
|
2023-11-16 20:46:01 +00:00
|
|
|
AlchemyOptimismSepoliaToken string `json:"alchemyOptimismSepoliaToken"`
|
2022-10-14 08:50:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateAccount) Validate() error {
|
2023-03-21 17:02:04 +00:00
|
|
|
return ValidateAccountCreationRequest(*c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ValidateAccountCreationRequest(c CreateAccount) error {
|
2022-10-14 08:50:36 +00:00
|
|
|
// TODO(cammellos): Add proper validation for password/displayname/etc
|
|
|
|
if len(c.DisplayName) == 0 {
|
|
|
|
return ErrCreateAccountInvalidDisplayName
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(c.Password) == 0 {
|
|
|
|
return ErrCreateAccountInvalidPassword
|
|
|
|
}
|
|
|
|
|
2023-03-22 17:48:42 +00:00
|
|
|
if len(c.CustomizationColor) == 0 {
|
|
|
|
return ErrCreateAccountInvalidCustomizationColor
|
2022-10-14 08:50:36 +00:00
|
|
|
}
|
|
|
|
|
2023-03-16 14:49:25 +00:00
|
|
|
if len(c.BackupDisabledDataDir) == 0 {
|
|
|
|
return ErrCreateAccountInvalidBackupDisabledDataDir
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(c.LogFilePath) == 0 {
|
|
|
|
return ErrCreateAccountInvalidLogFilePath
|
|
|
|
}
|
|
|
|
|
2022-10-14 08:50:36 +00:00
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|