Added AccountType to enforce strict typing on Accounts
Also a tpyo was fixed, probably introduced by me.
This commit is contained in:
parent
9b04633bb7
commit
26b33aa09d
|
@ -686,7 +686,7 @@ func TestConvertAccount(t *testing.T) {
|
||||||
|
|
||||||
keycardSettings := settings.Settings{
|
keycardSettings := settings.Settings{
|
||||||
KeycardInstanceUID: "0xdeadbeef",
|
KeycardInstanceUID: "0xdeadbeef",
|
||||||
KeycardPAiredOn: 1,
|
KeycardPairedOn: 1,
|
||||||
KeycardPairing: "pairing",
|
KeycardPairing: "pairing",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -561,7 +561,7 @@ func (b *GethStatusBackend) ConvertToKeycardAccount(keyStoreDir string, account
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = accountDB.SaveSettingField(settings.KeycardPairedOn, s.KeycardPAiredOn)
|
err = accountDB.SaveSettingField(settings.KeycardPairedOn, s.KeycardPairedOn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ type Account struct {
|
||||||
Address types.Address `json:"address"`
|
Address types.Address `json:"address"`
|
||||||
Wallet bool `json:"wallet"`
|
Wallet bool `json:"wallet"`
|
||||||
Chat bool `json:"chat"`
|
Chat bool `json:"chat"`
|
||||||
Type string `json:"type,omitempty"`
|
Type AccountType `json:"type,omitempty"`
|
||||||
Storage string `json:"storage,omitempty"`
|
Storage string `json:"storage,omitempty"`
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
PublicKey types.HexBytes `json:"public-key,omitempty"`
|
PublicKey types.HexBytes `json:"public-key,omitempty"`
|
||||||
|
@ -35,11 +35,17 @@ type Account struct {
|
||||||
Removed bool `json:"removed,omitempty"`
|
Removed bool `json:"removed,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AccountType string
|
||||||
|
|
||||||
|
func (a AccountType) String() string {
|
||||||
|
return string(a)
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AccountTypeGenerated = "generated"
|
AccountTypeGenerated AccountType = "generated"
|
||||||
AccountTypeKey = "key"
|
AccountTypeKey AccountType = "key"
|
||||||
AccountTypeSeed = "seed"
|
AccountTypeSeed AccountType = "seed"
|
||||||
AccountTypeWatch = "watch"
|
AccountTypeWatch AccountType = "watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsOwnAccount returns true if this is an account we have the private key for
|
// IsOwnAccount returns true if this is an account we have the private key for
|
||||||
|
@ -55,7 +61,7 @@ func (a *Account) MarshalJSON() ([]byte, error) {
|
||||||
MixedcaseAddress string `json:"mixedcase-address"`
|
MixedcaseAddress string `json:"mixedcase-address"`
|
||||||
Wallet bool `json:"wallet"`
|
Wallet bool `json:"wallet"`
|
||||||
Chat bool `json:"chat"`
|
Chat bool `json:"chat"`
|
||||||
Type string `json:"type,omitempty"`
|
Type AccountType `json:"type,omitempty"`
|
||||||
Storage string `json:"storage,omitempty"`
|
Storage string `json:"storage,omitempty"`
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
PublicKey types.HexBytes `json:"public-key,omitempty"`
|
PublicKey types.HexBytes `json:"public-key,omitempty"`
|
||||||
|
|
|
@ -123,7 +123,7 @@ INSERT INTO settings (
|
||||||
s.InstallationID,
|
s.InstallationID,
|
||||||
s.KeyUID,
|
s.KeyUID,
|
||||||
s.KeycardInstanceUID,
|
s.KeycardInstanceUID,
|
||||||
s.KeycardPAiredOn,
|
s.KeycardPairedOn,
|
||||||
s.KeycardPairing,
|
s.KeycardPairing,
|
||||||
s.LatestDerivedPath,
|
s.LatestDerivedPath,
|
||||||
s.Mnemonic,
|
s.Mnemonic,
|
||||||
|
@ -286,7 +286,7 @@ func (db *Database) GetSettings() (Settings, error) {
|
||||||
&s.InstallationID,
|
&s.InstallationID,
|
||||||
&s.KeyUID,
|
&s.KeyUID,
|
||||||
&s.KeycardInstanceUID,
|
&s.KeycardInstanceUID,
|
||||||
&s.KeycardPAiredOn,
|
&s.KeycardPairedOn,
|
||||||
&s.KeycardPairing,
|
&s.KeycardPairing,
|
||||||
&s.LastUpdated,
|
&s.LastUpdated,
|
||||||
&s.LatestDerivedPath,
|
&s.LatestDerivedPath,
|
||||||
|
|
|
@ -126,7 +126,7 @@ type Settings struct {
|
||||||
InstallationID string `json:"installation-id"`
|
InstallationID string `json:"installation-id"`
|
||||||
KeyUID string `json:"key-uid"`
|
KeyUID string `json:"key-uid"`
|
||||||
KeycardInstanceUID string `json:"keycard-instance-uid,omitempty"`
|
KeycardInstanceUID string `json:"keycard-instance-uid,omitempty"`
|
||||||
KeycardPAiredOn int64 `json:"keycard-paired-on,omitempty"`
|
KeycardPairedOn int64 `json:"keycard-paired-on,omitempty"`
|
||||||
KeycardPairing string `json:"keycard-pairing,omitempty"`
|
KeycardPairing string `json:"keycard-pairing,omitempty"`
|
||||||
LastUpdated *int64 `json:"last-updated,omitempty"`
|
LastUpdated *int64 `json:"last-updated,omitempty"`
|
||||||
LatestDerivedPath uint `json:"latest-derived-path"`
|
LatestDerivedPath uint `json:"latest-derived-path"`
|
||||||
|
|
|
@ -3019,7 +3019,7 @@ func (m *Messenger) syncWallets(accs []*accounts.Account) error {
|
||||||
Address: acc.Address.Bytes(),
|
Address: acc.Address.Bytes(),
|
||||||
Wallet: acc.Wallet,
|
Wallet: acc.Wallet,
|
||||||
Chat: acc.Chat,
|
Chat: acc.Chat,
|
||||||
Type: acc.Type,
|
Type: acc.Type.String(),
|
||||||
Storage: acc.Storage,
|
Storage: acc.Storage,
|
||||||
Path: acc.Path,
|
Path: acc.Path,
|
||||||
PublicKey: acc.PublicKey,
|
PublicKey: acc.PublicKey,
|
||||||
|
|
|
@ -2037,7 +2037,7 @@ func (m *Messenger) HandleSyncWalletAccount(state *ReceivedMessageState, message
|
||||||
Address: types.BytesToAddress(message.Address),
|
Address: types.BytesToAddress(message.Address),
|
||||||
Wallet: message.Wallet,
|
Wallet: message.Wallet,
|
||||||
Chat: message.Chat,
|
Chat: message.Chat,
|
||||||
Type: message.Type,
|
Type: accounts.AccountType(message.Type),
|
||||||
Storage: message.Storage,
|
Storage: message.Storage,
|
||||||
PublicKey: types.HexBytes(message.PublicKey),
|
PublicKey: types.HexBytes(message.PublicKey),
|
||||||
Path: message.Path,
|
Path: message.Path,
|
||||||
|
|
|
@ -90,7 +90,7 @@ func (api *API) DeleteAccount(ctx context.Context, address types.Address) error
|
||||||
func (api *API) AddAccountWatch(ctx context.Context, address string, name string, color string, emoji string) error {
|
func (api *API) AddAccountWatch(ctx context.Context, address string, name string, color string, emoji string) error {
|
||||||
account := &accounts.Account{
|
account := &accounts.Account{
|
||||||
Address: types.Address(common.HexToAddress(address)),
|
Address: types.Address(common.HexToAddress(address)),
|
||||||
Type: "watch",
|
Type: accounts.AccountTypeWatch,
|
||||||
Name: name,
|
Name: name,
|
||||||
Emoji: emoji,
|
Emoji: emoji,
|
||||||
Color: color,
|
Color: color,
|
||||||
|
|
Loading…
Reference in New Issue