chore: Add ColorId for Wallet accounts that can be shared with mobile (#3521)

This commit is contained in:
Khushboo-dev-cpp 2023-06-02 17:06:51 +02:00 committed by GitHub
parent e620633eb7
commit 8b91e3aaaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 696 additions and 835 deletions

View File

@ -29,6 +29,7 @@ import (
"github.com/status-im/status-go/logutils"
"github.com/status-im/status-go/multiaccounts"
"github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/multiaccounts/common"
"github.com/status-im/status-go/multiaccounts/settings"
"github.com/status-im/status-go/node"
"github.com/status-im/status-go/nodecfg"
@ -958,7 +959,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, request *re
account := multiaccounts.Account{
KeyUID: info.KeyUID,
Name: request.DisplayName,
CustomizationColor: multiaccounts.CustomizationColor(request.CustomizationColor),
CustomizationColor: common.CustomizationColor(request.CustomizationColor),
KDFIterations: sqlite.ReducedKDFIterationsNumber,
}
@ -989,7 +990,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, request *re
PublicKey: types.Hex2Bytes(walletDerivedAccount.PublicKey),
KeyUID: info.KeyUID,
Address: types.HexToAddress(walletDerivedAccount.Address),
Color: "",
ColorID: "",
Wallet: true,
Path: pathDefaultWallet,
Name: walletAccountDefaultName,

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
UPDATE keypairs_accounts SET color = 'yinyang' WHERE color = '#000000';
UPDATE keypairs_accounts SET color = 'yinyang' WHERE color = '#FFFFFF';
UPDATE keypairs_accounts SET color = 'primary' WHERE color = '#2946C4';
UPDATE keypairs_accounts SET color = 'purple' WHERE color = '#887AF9';
UPDATE keypairs_accounts SET color = 'sky' WHERE color = '#51D0F0';
UPDATE keypairs_accounts SET color = 'orange' WHERE color = '#D37EF4';
UPDATE keypairs_accounts SET color = 'magenta' WHERE color = '#FA6565';
UPDATE keypairs_accounts SET color = 'yellow' WHERE color = '#FFCA0F';
UPDATE keypairs_accounts SET color = 'army' WHERE color = '#7CDA00';
UPDATE keypairs_accounts SET color = 'turquoise' WHERE color = '#26A69A';
UPDATE keypairs_accounts SET color = 'copper' WHERE color = '#8B3131';
UPDATE keypairs_accounts SET color = 'camel' WHERE color = '#9B832F';
UPDATE keypairs_accounts SET color = 'primary' WHERE color = '';

File diff suppressed because it is too large Load Diff

View File

@ -414,7 +414,7 @@ func ImportAccount(seedPhrase string, backend *api.GethStatusBackend) error {
PublicKey: types.Hex2Bytes(walletDerivedAccount.PublicKey),
KeyUID: generatedAccountInfo.KeyUID,
Address: types.HexToAddress(walletDerivedAccount.Address),
Color: "",
ColorID: "",
Wallet: true,
Path: pathDefaultWallet,
Name: "Ethereum account",

View File

@ -479,7 +479,7 @@ func ImportAccount(seedPhrase string, backend *api.GethStatusBackend) error {
PublicKey: types.Hex2Bytes(walletDerivedAccount.PublicKey),
KeyUID: generatedAccountInfo.KeyUID,
Address: types.HexToAddress(walletDerivedAccount.Address),
Color: "",
ColorID: "",
Wallet: true,
Path: pathDefaultWallet,
Name: "Ethereum account",

View File

@ -375,7 +375,7 @@ func ImportAccount(seedPhrase string, backend *api.GethStatusBackend) error {
PublicKey: types.Hex2Bytes(walletDerivedAccount.PublicKey),
KeyUID: generatedAccountInfo.KeyUID,
Address: types.HexToAddress(walletDerivedAccount.Address),
Color: "",
ColorID: "",
Wallet: true,
Path: pathDefaultWallet,
Name: "Ethereum account",

View File

@ -5,6 +5,8 @@ import (
"testing"
"github.com/stretchr/testify/require"
"github.com/status-im/status-go/multiaccounts/common"
)
func TestIsOwnAccount(t *testing.T) {
@ -41,7 +43,7 @@ func TestUnmarshal(t *testing.T) {
"key-uid": "0xbc14c321b74652e57c7f26eb30d597ea27cbdf36cba5c85d24f12748153a035e",
"public-key": "0x0465f6d4f1172524fc057954c8a3f8e34f991558b3d1097189975062f67adda7835da61acb5cda3348b41d211ed0cb07aba668eb12e19e29d98745bebf68d93b61",
"address": "0xf09c9f5Fb9faa22d0C6C593e7157Ceac8B2b0fe4",
"color": "#4360df",
"colorId": "primary",
"wallet": true,
"chat": true,
"path": "m/44'/60'/0'/0/0",
@ -61,7 +63,7 @@ func TestUnmarshal(t *testing.T) {
require.Equal(t, "0xbc14c321b74652e57c7f26eb30d597ea27cbdf36cba5c85d24f12748153a035e", account.KeyUID)
require.Equal(t, []byte("0x0465f6d4f1172524fc057954c8a3f8e34f991558b3d1097189975062f67adda7835da61acb5cda3348b41d211ed0cb07aba668eb12e19e29d98745bebf68d93b61"), account.PublicKey.Bytes())
require.Equal(t, "0xf09c9f5Fb9faa22d0C6C593e7157Ceac8B2b0fe4", account.Address.String())
require.Equal(t, "#4360df", account.Color)
require.Equal(t, common.CustomizationColorPrimary, account.ColorID)
require.Equal(t, true, account.Wallet)
require.Equal(t, true, account.Chat)
require.Equal(t, "m/44'/60'/0'/0/0", account.Path)

View File

@ -9,6 +9,7 @@ import (
"strings"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/multiaccounts/common"
"github.com/status-im/status-go/multiaccounts/settings"
notificationssettings "github.com/status-im/status-go/multiaccounts/settings_notifications"
sociallinkssettings "github.com/status-im/status-go/multiaccounts/settings_social_links"
@ -43,20 +44,20 @@ type Keypair struct {
}
type Account struct {
Address types.Address `json:"address"`
KeyUID string `json:"key-uid"`
Wallet bool `json:"wallet"`
Chat bool `json:"chat"`
Type AccountType `json:"type,omitempty"`
Path string `json:"path,omitempty"`
PublicKey types.HexBytes `json:"public-key,omitempty"`
Name string `json:"name"`
Emoji string `json:"emoji"`
Color string `json:"color"`
Hidden bool `json:"hidden"`
Clock uint64 `json:"clock,omitempty"`
Removed bool `json:"removed,omitempty"`
Operable AccountOperable `json:"operable"` // describes an account's operability (read an explanation at the top of this file)
Address types.Address `json:"address"`
KeyUID string `json:"key-uid"`
Wallet bool `json:"wallet"`
Chat bool `json:"chat"`
Type AccountType `json:"type,omitempty"`
Path string `json:"path,omitempty"`
PublicKey types.HexBytes `json:"public-key,omitempty"`
Name string `json:"name"`
Emoji string `json:"emoji"`
ColorID common.CustomizationColor `json:"colorId,omitempty"`
Hidden bool `json:"hidden"`
Clock uint64 `json:"clock,omitempty"`
Removed bool `json:"removed,omitempty"`
Operable AccountOperable `json:"operable"` // describes an account's operability (read an explanation at the top of this file)
}
type KeypairType string
@ -103,21 +104,21 @@ func (a *Account) IsOwnAccount() bool {
func (a *Account) MarshalJSON() ([]byte, error) {
item := struct {
Address types.Address `json:"address"`
MixedcaseAddress string `json:"mixedcase-address"`
KeyUID string `json:"key-uid"`
Wallet bool `json:"wallet"`
Chat bool `json:"chat"`
Type AccountType `json:"type"`
Path string `json:"path"`
PublicKey types.HexBytes `json:"public-key"`
Name string `json:"name"`
Emoji string `json:"emoji"`
Color string `json:"color"`
Hidden bool `json:"hidden"`
Clock uint64 `json:"clock"`
Removed bool `json:"removed"`
Operable AccountOperable `json:"operable"`
Address types.Address `json:"address"`
MixedcaseAddress string `json:"mixedcase-address"`
KeyUID string `json:"key-uid"`
Wallet bool `json:"wallet"`
Chat bool `json:"chat"`
Type AccountType `json:"type"`
Path string `json:"path"`
PublicKey types.HexBytes `json:"public-key"`
Name string `json:"name"`
Emoji string `json:"emoji"`
ColorID common.CustomizationColor `json:"colorId"`
Hidden bool `json:"hidden"`
Clock uint64 `json:"clock"`
Removed bool `json:"removed"`
Operable AccountOperable `json:"operable"`
}{
Address: a.Address,
MixedcaseAddress: a.Address.Hex(),
@ -129,7 +130,7 @@ func (a *Account) MarshalJSON() ([]byte, error) {
PublicKey: a.PublicKey,
Name: a.Name,
Emoji: a.Emoji,
Color: a.Color,
ColorID: a.ColorID,
Hidden: a.Hidden,
Clock: a.Clock,
Removed: a.Removed,
@ -186,7 +187,7 @@ func (a *Keypair) CopyKeypair() *Keypair {
PublicKey: acc.PublicKey,
Name: acc.Name,
Emoji: acc.Emoji,
Color: acc.Color,
ColorID: acc.ColorID,
Hidden: acc.Hidden,
Clock: acc.Clock,
Removed: acc.Removed,
@ -270,7 +271,7 @@ func (db *Database) processKeypairs(rows *sql.Rows) ([]*Keypair, error) {
accKeyUID sql.NullString
accPath sql.NullString
accName sql.NullString
accColor sql.NullString
accColorID sql.NullString
accEmoji sql.NullString
accWallet sql.NullBool
accChat sql.NullBool
@ -285,7 +286,7 @@ func (db *Database) processKeypairs(rows *sql.Rows) ([]*Keypair, error) {
pubkey := []byte{}
err := rows.Scan(
&kpKeyUID, &kpName, &kpType, &kpDerivedFrom, &kpLastUsedDerivationIndex, &kpSyncedFrom, &kpClock,
&accAddress, &accKeyUID, &pubkey, &accPath, &accName, &accColor, &accEmoji,
&accAddress, &accKeyUID, &pubkey, &accPath, &accName, &accColorID, &accEmoji,
&accWallet, &accChat, &accHidden, &accOperable, &accClock)
if err != nil {
return nil, err
@ -327,8 +328,8 @@ func (db *Database) processKeypairs(rows *sql.Rows) ([]*Keypair, error) {
if accName.Valid {
acc.Name = accName.String
}
if accColor.Valid {
acc.Color = accColor.String
if accColorID.Valid {
acc.ColorID = common.CustomizationColor(accColorID.String)
}
if accEmoji.Valid {
acc.Emoji = accEmoji.String
@ -393,7 +394,7 @@ func (db *Database) getKeypairs(tx *sql.Tx, keyUID string) ([]*Keypair, error) {
ka.pubkey,
ka.path,
ka.name,
ka.color,
ka.color,
ka.emoji,
ka.wallet,
ka.chat,
@ -474,7 +475,7 @@ func (db *Database) getAccounts(tx *sql.Tx, address types.Address) ([]*Account,
ka.pubkey,
ka.path,
ka.name,
ka.color,
ka.color,
ka.emoji,
ka.wallet,
ka.chat,
@ -718,7 +719,7 @@ func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account) (err e
keypairs_accounts
SET
name = ?,
color = ?,
color = ?,
emoji = ?,
hidden = ?,
operable = ?,
@ -727,7 +728,7 @@ func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account) (err e
address = ?;
`,
acc.Address, keyUID, acc.PublicKey, acc.Path, acc.Wallet, acc.Chat,
acc.Name, acc.Color, acc.Emoji, acc.Hidden, acc.Operable, acc.Clock, acc.Address)
acc.Name, acc.ColorID, acc.Emoji, acc.Hidden, acc.Operable, acc.Clock, acc.Address)
if err != nil {
return err
}

View File

@ -8,6 +8,7 @@ import (
"github.com/status-im/status-go/appdatabase"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/multiaccounts/common"
)
func setupTestDB(t *testing.T) (*Database, func()) {
@ -135,7 +136,7 @@ func TestWatchOnlyAccounts(t *testing.T) {
Address: types.Address{0x14},
Type: AccountTypeWatch,
Name: "WatchOnlyAcc4",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Emoji: "emoji-1",
}
err = db.SaveOrUpdateAccounts([]*Account{wo4})
@ -149,7 +150,7 @@ func TestWatchOnlyAccounts(t *testing.T) {
// updated watch onl to save the same account after it's saved
wo4.Name = wo4.Name + "updated"
wo4.Color = "lightgreen"
wo4.ColorID = common.CustomizationColorCamel
wo4.Emoji = wo4.Emoji + "updated"
err = db.SaveOrUpdateAccounts([]*Account{wo4})
require.NoError(t, err)
@ -277,7 +278,7 @@ func TestKeypairs(t *testing.T) {
// update an existing account
accToUpdate.Name = accToUpdate.Name + "updated"
accToUpdate.Color = "green"
accToUpdate.ColorID = common.CustomizationColorBrown
accToUpdate.Emoji = accToUpdate.Emoji + "updated"
err = db.SaveOrUpdateAccounts([]*Account{accToUpdate})

View File

@ -2,6 +2,7 @@ package accounts
import (
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/multiaccounts/common"
)
func GetWatchOnlyAccountsForTest() []*Account {
@ -9,21 +10,21 @@ func GetWatchOnlyAccountsForTest() []*Account {
Address: types.Address{0x11},
Type: AccountTypeWatch,
Name: "WatchOnlyAcc1",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Emoji: "emoji-1",
}
wo2 := &Account{
Address: types.Address{0x12},
Type: AccountTypeWatch,
Name: "WatchOnlyAcc2",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Emoji: "emoji-1",
}
wo3 := &Account{
Address: types.Address{0x13},
Type: AccountTypeWatch,
Name: "WatchOnlyAcc3",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Emoji: "emoji-1",
}
@ -64,7 +65,7 @@ func GetProfileKeypairForTest(includeChatAccount bool, includeDefaultWalletAccou
PublicKey: types.Hex2Bytes("0x000000002"),
Name: "Generated Acc 1",
Emoji: "emoji-1",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Hidden: false,
Clock: 0,
Removed: false,
@ -85,7 +86,7 @@ func GetProfileKeypairForTest(includeChatAccount bool, includeDefaultWalletAccou
PublicKey: types.Hex2Bytes("0x000000003"),
Name: "Generated Acc 2",
Emoji: "emoji-2",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Hidden: false,
Clock: 0,
Removed: false,
@ -104,7 +105,7 @@ func GetProfileKeypairForTest(includeChatAccount bool, includeDefaultWalletAccou
PublicKey: types.Hex2Bytes("0x000000004"),
Name: "Generated Acc 3",
Emoji: "emoji-3",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Hidden: false,
Clock: 0,
Removed: false,
@ -135,7 +136,7 @@ func GetSeedImportedKeypair1ForTest() *Keypair {
PublicKey: types.Hex2Bytes("0x000000021"),
Name: "Seed Impo 1 Acc 1",
Emoji: "emoji-1",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Hidden: false,
Clock: 0,
Removed: false,
@ -154,7 +155,7 @@ func GetSeedImportedKeypair1ForTest() *Keypair {
PublicKey: types.Hex2Bytes("0x000000022"),
Name: "Seed Impo 1 Acc 2",
Emoji: "emoji-2",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Hidden: false,
Clock: 0,
Removed: false,
@ -184,7 +185,7 @@ func GetSeedImportedKeypair2ForTest() *Keypair {
PublicKey: types.Hex2Bytes("0x000000031"),
Name: "Seed Impo 2 Acc 1",
Emoji: "emoji-1",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Hidden: false,
Clock: 0,
Removed: false,
@ -203,7 +204,7 @@ func GetSeedImportedKeypair2ForTest() *Keypair {
PublicKey: types.Hex2Bytes("0x000000032"),
Name: "Seed Impo 2 Acc 2",
Emoji: "emoji-2",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Hidden: false,
Clock: 0,
Removed: false,
@ -233,7 +234,7 @@ func GetPrivKeyImportedKeypairForTest() *Keypair {
PublicKey: types.Hex2Bytes("0x000000041"),
Name: "Priv Key Impo Acc",
Emoji: "emoji-1",
Color: "blue",
ColorID: common.CustomizationColorPrimary,
Hidden: false,
Clock: 0,
Removed: false,
@ -302,7 +303,7 @@ func SameAccounts(expected, real *Account) bool {
string(expected.PublicKey) == string(real.PublicKey) &&
expected.Name == real.Name &&
expected.Emoji == real.Emoji &&
expected.Color == real.Color &&
expected.ColorID == real.ColorID &&
expected.Hidden == real.Hidden &&
expected.Clock == real.Clock &&
expected.Removed == real.Removed

View File

@ -0,0 +1,24 @@
package common
type CustomizationColor string
const (
CustomizationColorPrimary CustomizationColor = "primary"
CustomizationColorPurple CustomizationColor = "purple"
CustomizationColorIndigo CustomizationColor = "indigo"
CustomizationColorTurquoise CustomizationColor = "turquoise"
CustomizationColorBlue CustomizationColor = "blue"
CustomizationColorGreen CustomizationColor = "green"
CustomizationColorYellow CustomizationColor = "yellow"
CustomizationColorOrange CustomizationColor = "orange"
CustomizationColorRed CustomizationColor = "red"
CustomizationColorPink CustomizationColor = "pink"
CustomizationColorBrown CustomizationColor = "brown"
CustomizationColorSky CustomizationColor = "sky"
CustomizationColorArmy CustomizationColor = "army"
CustomizationColorMagenta CustomizationColor = "magenta"
CustomizationColorCopper CustomizationColor = "copper"
CustomizationColorCamel CustomizationColor = "camel"
CustomizationColorYinYang CustomizationColor = "yinyang"
CustomizationColorBeige CustomizationColor = "beige"
)

View File

@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/images"
"github.com/status-im/status-go/multiaccounts/common"
"github.com/status-im/status-go/multiaccounts/migrations"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/sqlite"
@ -14,41 +15,18 @@ import (
type ColorHash [][2]int
type CustomizationColor string
const (
CustomizationColorPrimary CustomizationColor = "primary"
CustomizationColorPurple CustomizationColor = "purple"
CustomizationColorIndigo CustomizationColor = "indigo"
CustomizationColorTurquoise CustomizationColor = "turquoise"
CustomizationColorBlue CustomizationColor = "blue"
CustomizationColorGreen CustomizationColor = "green"
CustomizationColorYellow CustomizationColor = "yellow"
CustomizationColorOrange CustomizationColor = "orange"
CustomizationColorRed CustomizationColor = "red"
CustomizationColorPink CustomizationColor = "pink"
CustomizationColorBrown CustomizationColor = "brown"
CustomizationColorSky CustomizationColor = "sky"
CustomizationColorArmy CustomizationColor = "army"
CustomizationColorMagenta CustomizationColor = "magenta"
CustomizationColorCopper CustomizationColor = "copper"
CustomizationColorCamel CustomizationColor = "camel"
CustomizationColorYinYang CustomizationColor = "yinyang"
CustomizationColorBeige CustomizationColor = "beige"
)
// Account stores public information about account.
type Account struct {
Name string `json:"name"`
Timestamp int64 `json:"timestamp"`
Identicon string `json:"identicon"`
ColorHash ColorHash `json:"colorHash"`
ColorID int64 `json:"colorId"`
CustomizationColor CustomizationColor `json:"customizationColor,omitempty"`
KeycardPairing string `json:"keycard-pairing"`
KeyUID string `json:"key-uid"`
Images []images.IdentityImage `json:"images"`
KDFIterations int `json:"kdfIterations,omitempty"`
Name string `json:"name"`
Timestamp int64 `json:"timestamp"`
Identicon string `json:"identicon"`
ColorHash ColorHash `json:"colorHash"`
ColorID int64 `json:"colorId"`
CustomizationColor common.CustomizationColor `json:"customizationColor,omitempty"`
KeycardPairing string `json:"keycard-pairing"`
KeyUID string `json:"key-uid"`
Images []images.IdentityImage `json:"images"`
KDFIterations int `json:"kdfIterations,omitempty"`
}
func (a *Account) ToProtobuf() *protobuf.MultiAccount {
@ -72,7 +50,7 @@ func (a *Account) ToProtobuf() *protobuf.MultiAccount {
Timestamp: a.Timestamp,
Identicon: a.Identicon,
ColorHash: colorHashes,
ColorId: a.ColorID,
ColorID: a.ColorID,
CustomizationColor: string(a.CustomizationColor),
KeycardPairing: a.KeycardPairing,
KeyUid: a.KeyUID,
@ -102,9 +80,9 @@ func (a *Account) FromProtobuf(ma *protobuf.MultiAccount) {
a.Timestamp = ma.Timestamp
a.Identicon = ma.Identicon
a.ColorHash = colorHash
a.ColorID = ma.ColorId
a.ColorID = ma.ColorID
a.KeycardPairing = ma.KeycardPairing
a.CustomizationColor = CustomizationColor(ma.CustomizationColor)
a.CustomizationColor = common.CustomizationColor(ma.CustomizationColor)
a.KeyUID = ma.KeyUid
a.Images = identityImages
}

View File

@ -10,6 +10,8 @@ import (
"github.com/status-im/status-go/protocol/sqlite"
"github.com/stretchr/testify/require"
"github.com/status-im/status-go/multiaccounts/common"
)
func setupTestDB(t *testing.T) (*Database, func()) {
@ -26,7 +28,7 @@ func setupTestDB(t *testing.T) (*Database, func()) {
func TestAccounts(t *testing.T) {
db, stop := setupTestDB(t)
defer stop()
expected := Account{Name: "string", KeyUID: "string", CustomizationColor: CustomizationColorBlue, ColorHash: ColorHash{{4, 3}, {4, 0}, {4, 3}, {4, 0}}, ColorID: 10, KDFIterations: sqlite.ReducedKDFIterationsNumber}
expected := Account{Name: "string", KeyUID: "string", CustomizationColor: common.CustomizationColorBlue, ColorHash: ColorHash{{4, 3}, {4, 0}, {4, 3}, {4, 0}}, ColorID: 10, KDFIterations: sqlite.ReducedKDFIterationsNumber}
require.NoError(t, db.SaveAccount(expected))
accounts, err := db.GetAccounts()
require.NoError(t, err)
@ -37,10 +39,10 @@ func TestAccounts(t *testing.T) {
func TestAccountsUpdate(t *testing.T) {
db, stop := setupTestDB(t)
defer stop()
expected := Account{KeyUID: "string", CustomizationColor: CustomizationColorBlue, ColorHash: ColorHash{{4, 3}, {4, 0}, {4, 3}, {4, 0}}, ColorID: 10, KDFIterations: sqlite.ReducedKDFIterationsNumber}
expected := Account{KeyUID: "string", CustomizationColor: common.CustomizationColorBlue, ColorHash: ColorHash{{4, 3}, {4, 0}, {4, 3}, {4, 0}}, ColorID: 10, KDFIterations: sqlite.ReducedKDFIterationsNumber}
require.NoError(t, db.SaveAccount(expected))
expected.Name = "chars"
expected.CustomizationColor = CustomizationColorMagenta
expected.CustomizationColor = common.CustomizationColorMagenta
require.NoError(t, db.UpdateAccount(expected))
rst, err := db.GetAccounts()
require.NoError(t, err)

View File

@ -2876,7 +2876,7 @@ func mapSyncAccountToAccount(message *protobuf.SyncAccount, accountOperability a
PublicKey: types.HexBytes(message.PublicKey),
Path: message.Path,
Name: message.Name,
Color: message.Color,
ColorID: message.ColorID,
Emoji: message.Emoji,
Wallet: message.Wallet,
Chat: message.Chat,

View File

@ -268,7 +268,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWallets() {
accountsToUpdate := profileKpUpdated.Accounts[2:]
for _, acc := range accountsToUpdate {
acc.Name = acc.Name + "Updated"
acc.Color = acc.Color + "Updated"
acc.ColorID = acc.ColorID + "Updated"
acc.Emoji = acc.Emoji + "Updated"
err = s.m.SaveOrUpdateAccount(acc)
s.Require().NoError(err, "updated account on alice primary device")

View File

@ -163,7 +163,7 @@ func (m *Messenger) prepareSyncAccountMessage(acc *accounts.Account) *protobuf.S
PublicKey: acc.PublicKey,
Path: acc.Path,
Name: acc.Name,
Color: acc.Color,
ColorID: acc.ColorID,
Emoji: acc.Emoji,
Wallet: acc.Wallet,
Chat: acc.Chat,

View File

@ -5,8 +5,11 @@ package protobuf
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
proto "github.com/golang/protobuf/proto"
"github.com/status-im/status-go/multiaccounts/common"
)
// Reference imports to suppress errors if they are not otherwise used.
@ -348,7 +351,7 @@ type MultiAccount struct {
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Identicon string `protobuf:"bytes,3,opt,name=identicon,proto3" json:"identicon,omitempty"`
ColorHash []*MultiAccount_ColorHash `protobuf:"bytes,4,rep,name=color_hash,json=colorHash,proto3" json:"color_hash,omitempty"`
ColorId int64 `protobuf:"varint,5,opt,name=color_id,json=colorId,proto3" json:"color_id,omitempty"`
ColorID int64 `protobuf:"varint,5,opt,name=color_id,json=colorId,proto3" json:"color_id,omitempty"`
KeycardPairing string `protobuf:"bytes,6,opt,name=keycard_pairing,json=keycardPairing,proto3" json:"keycard_pairing,omitempty"`
KeyUid string `protobuf:"bytes,7,opt,name=key_uid,json=keyUid,proto3" json:"key_uid,omitempty"`
Images []*MultiAccount_IdentityImage `protobuf:"bytes,8,rep,name=images,proto3" json:"images,omitempty"`
@ -411,9 +414,9 @@ func (m *MultiAccount) GetColorHash() []*MultiAccount_ColorHash {
return nil
}
func (m *MultiAccount) GetColorId() int64 {
func (m *MultiAccount) GetColorID() int64 {
if m != nil {
return m.ColorId
return m.ColorID
}
return 0
}
@ -2041,21 +2044,21 @@ func (m *SyncProfilePictures) GetPictures() []*SyncProfilePicture {
}
type SyncAccount struct {
Clock uint64 `protobuf:"varint,1,opt,name=clock,proto3" json:"clock,omitempty"`
Address []byte `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
KeyUid string `protobuf:"bytes,3,opt,name=key_uid,json=keyUid,proto3" json:"key_uid,omitempty"`
PublicKey []byte `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
Path string `protobuf:"bytes,5,opt,name=path,proto3" json:"path,omitempty"`
Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"`
Color string `protobuf:"bytes,7,opt,name=color,proto3" json:"color,omitempty"`
Emoji string `protobuf:"bytes,8,opt,name=emoji,proto3" json:"emoji,omitempty"`
Wallet bool `protobuf:"varint,9,opt,name=wallet,proto3" json:"wallet,omitempty"`
Chat bool `protobuf:"varint,10,opt,name=chat,proto3" json:"chat,omitempty"`
Hidden bool `protobuf:"varint,11,opt,name=hidden,proto3" json:"hidden,omitempty"`
Removed bool `protobuf:"varint,12,opt,name=removed,proto3" json:"removed,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Clock uint64 `protobuf:"varint,1,opt,name=clock,proto3" json:"clock,omitempty"`
Address []byte `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
KeyUid string `protobuf:"bytes,3,opt,name=key_uid,json=keyUid,proto3" json:"key_uid,omitempty"`
PublicKey []byte `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
Path string `protobuf:"bytes,5,opt,name=path,proto3" json:"path,omitempty"`
Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"`
ColorID common.CustomizationColor `protobuf:"bytes,7,opt,name=colorId,proto3" json:"colorId,omitempty"`
Emoji string `protobuf:"bytes,8,opt,name=emoji,proto3" json:"emoji,omitempty"`
Wallet bool `protobuf:"varint,9,opt,name=wallet,proto3" json:"wallet,omitempty"`
Chat bool `protobuf:"varint,10,opt,name=chat,proto3" json:"chat,omitempty"`
Hidden bool `protobuf:"varint,11,opt,name=hidden,proto3" json:"hidden,omitempty"`
Removed bool `protobuf:"varint,12,opt,name=removed,proto3" json:"removed,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SyncAccount) Reset() { *m = SyncAccount{} }
@ -2125,9 +2128,9 @@ func (m *SyncAccount) GetName() string {
return ""
}
func (m *SyncAccount) GetColor() string {
func (m *SyncAccount) GetColorID() common.CustomizationColor {
if m != nil {
return m.Color
return m.ColorID
}
return ""
}

View File

@ -231,7 +231,7 @@ message SyncAccount {
bytes public_key = 4;
string path = 5;
string name = 6;
string color = 7;
string colorId = 7;
string emoji = 8;
bool wallet = 9;
bool chat = 10;

View File

@ -91,7 +91,7 @@ func (s *SyncDeviceSuite) prepareBackendWithAccount(tmpdir string) *api.GethStat
PublicKey: types.Hex2Bytes(walletDerivedAccount.PublicKey),
KeyUID: generatedAccountInfo.KeyUID,
Address: types.HexToAddress(walletDerivedAccount.Address),
Color: "",
ColorID: "",
Wallet: true,
Path: pathDefaultWallet,
Name: "Ethereum account",

View File

@ -213,8 +213,8 @@ func (api *API) checkAccountValidity(account *accounts.Account) error {
return errors.New("`Emoji` field of an account must be set")
}
if len(account.Color) == 0 {
return errors.New("`Color` field of an account must be set")
if len(account.ColorID) == 0 {
return errors.New("`ColorID` field of an account must be set")
}
if account.Type != accounts.AccountTypeWatch {