feat: Added emoji params for a wallet account (#2582)

This commit is contained in:
Khushboo-dev-cpp 2022-03-11 11:59:15 +01:00 committed by GitHub
parent 9e833cd4c7
commit 5f81b3acf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 285 additions and 341 deletions

View file

@ -4,6 +4,7 @@
// 1642666031_add_removed_clock_to_bookmarks.up.sql
// 1643644541_gif_api_key_setting.up.sql
// 1644188994_recent_stickers.up.sql
// 1646841105_add_emoji_account.up.sql
// doc.go
// DO NOT EDIT!
@ -87,7 +88,7 @@ func _1640111208_dummyUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(436), modTime: time.Unix(1645543084, 0)}
info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(436), modTime: time.Unix(1646839963, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -107,7 +108,7 @@ func _1642666031_add_removed_clock_to_bookmarksUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1642666031_add_removed_clock_to_bookmarks.up.sql", size: 117, mode: os.FileMode(436), modTime: time.Unix(1646418868, 0)}
info := bindataFileInfo{name: "1642666031_add_removed_clock_to_bookmarks.up.sql", size: 117, mode: os.FileMode(436), modTime: time.Unix(1646839963, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -127,7 +128,7 @@ func _1643644541_gif_api_key_settingUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1643644541_gif_api_key_setting.up.sql", size: 108, mode: os.FileMode(436), modTime: time.Unix(1645543084, 0)}
info := bindataFileInfo{name: "1643644541_gif_api_key_setting.up.sql", size: 108, mode: os.FileMode(436), modTime: time.Unix(1646839963, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -147,7 +148,27 @@ func _1644188994_recent_stickersUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(436), modTime: time.Unix(1646661962, 0)}
info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(436), modTime: time.Unix(1646839963, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
var __1646841105_add_emoji_accountUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x4c\x4e\xce\x2f\xcd\x2b\x29\x56\x70\x74\x71\x51\x70\xf6\xf7\x09\xf5\xf5\x53\x48\xcd\xcd\xcf\xca\x54\x08\x71\x8d\x08\x51\xf0\xf3\x0f\x51\xf0\x0b\xf5\xf1\x51\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\x52\xb2\xe6\x0a\x0d\x70\x71\x0c\x41\xd2\x1a\xec\x1a\x02\xd5\x63\x0b\x96\x07\x04\x00\x00\xff\xff\x2b\x1c\x4e\xaa\x60\x00\x00\x00")
func _1646841105_add_emoji_accountUpSqlBytes() ([]byte, error) {
return bindataRead(
__1646841105_add_emoji_accountUpSql,
"1646841105_add_emoji_account.up.sql",
)
}
func _1646841105_add_emoji_accountUpSql() (*asset, error) {
bytes, err := _1646841105_add_emoji_accountUpSqlBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(436), modTime: time.Unix(1646839402, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -167,7 +188,7 @@ func docGo() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(436), modTime: time.Unix(1643209233, 0)}
info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(436), modTime: time.Unix(1646818623, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -228,6 +249,7 @@ var _bindata = map[string]func() (*asset, error){
"1642666031_add_removed_clock_to_bookmarks.up.sql": _1642666031_add_removed_clock_to_bookmarksUpSql,
"1643644541_gif_api_key_setting.up.sql": _1643644541_gif_api_key_settingUpSql,
"1644188994_recent_stickers.up.sql": _1644188994_recent_stickersUpSql,
"1646841105_add_emoji_account.up.sql": _1646841105_add_emoji_accountUpSql,
"doc.go": docGo,
}
@ -275,6 +297,7 @@ var _bintree = &bintree{nil, map[string]*bintree{
"1642666031_add_removed_clock_to_bookmarks.up.sql": &bintree{_1642666031_add_removed_clock_to_bookmarksUpSql, map[string]*bintree{}},
"1643644541_gif_api_key_setting.up.sql": &bintree{_1643644541_gif_api_key_settingUpSql, map[string]*bintree{}},
"1644188994_recent_stickers.up.sql": &bintree{_1644188994_recent_stickersUpSql, map[string]*bintree{}},
"1646841105_add_emoji_account.up.sql": &bintree{_1646841105_add_emoji_accountUpSql, map[string]*bintree{}},
"doc.go": &bintree{docGo, map[string]*bintree{}},
}}

View file

@ -0,0 +1,2 @@
ALTER TABLE accounts ADD COLUMN emoji TEXT NOT NULL DEFAULT "";
UPDATE accounts SET emoji = "";

File diff suppressed because it is too large Load diff

View file

@ -51,6 +51,7 @@ type Account struct {
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"`
}
@ -570,7 +571,7 @@ func (db *Database) GetSettings() (Settings, error) {
}
func (db *Database) GetAccounts() ([]Account, error) {
rows, err := db.db.Query("SELECT address, wallet, chat, type, storage, pubkey, path, name, color, hidden FROM accounts ORDER BY created_at")
rows, err := db.db.Query("SELECT address, wallet, chat, type, storage, pubkey, path, name, emoji, color, hidden FROM accounts ORDER BY created_at")
if err != nil {
return nil, err
}
@ -581,7 +582,7 @@ func (db *Database) GetAccounts() ([]Account, error) {
acc := Account{}
err := rows.Scan(
&acc.Address, &acc.Wallet, &acc.Chat, &acc.Type, &acc.Storage,
&pubkey, &acc.Path, &acc.Name, &acc.Color, &acc.Hidden)
&pubkey, &acc.Path, &acc.Name, &acc.Emoji, &acc.Color, &acc.Hidden)
if err != nil {
return nil, err
}
@ -595,13 +596,13 @@ func (db *Database) GetAccounts() ([]Account, error) {
}
func (db *Database) GetAccountByAddress(address types.Address) (rst *Account, err error) {
row := db.db.QueryRow("SELECT address, wallet, chat, type, storage, pubkey, path, name, color, hidden FROM accounts WHERE address = ? COLLATE NOCASE", address)
row := db.db.QueryRow("SELECT address, wallet, chat, type, storage, pubkey, path, name, emoji, color, hidden FROM accounts WHERE address = ? COLLATE NOCASE", address)
acc := &Account{}
pubkey := []byte{}
err = row.Scan(
&acc.Address, &acc.Wallet, &acc.Chat, &acc.Type, &acc.Storage,
&pubkey, &acc.Path, &acc.Name, &acc.Color, &acc.Hidden)
&pubkey, &acc.Path, &acc.Name, &acc.Emoji, &acc.Color, &acc.Hidden)
if err != nil {
return nil, err
@ -633,7 +634,7 @@ func (db *Database) SaveAccounts(accounts []Account) (err error) {
if err != nil {
return err
}
update, err = tx.Prepare("UPDATE accounts SET wallet = ?, chat = ?, type = ?, storage = ?, pubkey = ?, path = ?, name = ?, color = ?, hidden = ?, updated_at = datetime('now') WHERE address = ?")
update, err = tx.Prepare("UPDATE accounts SET wallet = ?, chat = ?, type = ?, storage = ?, pubkey = ?, path = ?, name = ?, emoji = ?, color = ?, hidden = ?, updated_at = datetime('now') WHERE address = ?")
if err != nil {
return err
}
@ -643,7 +644,7 @@ func (db *Database) SaveAccounts(accounts []Account) (err error) {
if err != nil {
return
}
_, err = update.Exec(acc.Wallet, acc.Chat, acc.Type, acc.Storage, acc.PublicKey, acc.Path, acc.Name, acc.Color, acc.Hidden, acc.Address)
_, err = update.Exec(acc.Wallet, acc.Chat, acc.Type, acc.Storage, acc.PublicKey, acc.Path, acc.Name, acc.Emoji, acc.Color, acc.Hidden, acc.Address)
if err != nil {
switch err.Error() {
case uniqueChatConstraint:

View file

@ -50,11 +50,12 @@ func (api *API) DeleteAccount(ctx context.Context, address types.Address) error
return api.db.DeleteAccount(address)
}
func (api *API) AddAccountWatch(ctx context.Context, address string, name string, color string) error {
func (api *API) AddAccountWatch(ctx context.Context, address string, name string, color string, emoji string) error {
account := accounts.Account{
Address: types.Address(common.HexToAddress(address)),
Type: "watch",
Name: name,
Emoji: emoji,
Color: color,
}
return api.SaveAccounts(ctx, []accounts.Account{account})
@ -66,6 +67,7 @@ func (api *API) AddAccountWithMnemonic(
password string,
name string,
color string,
emoji string,
) error {
mnemonicNoExtraSpaces := strings.Join(strings.Fields(mnemonic), " ")
@ -95,6 +97,7 @@ func (api *API) AddAccountWithMnemonic(
PublicKey: types.HexBytes(infos[pathWalletRoot].PublicKey),
Type: "seed",
Name: name,
Emoji: emoji,
Color: color,
Path: pathDefaultWallet,
}
@ -107,6 +110,7 @@ func (api *API) AddAccountWithPrivateKey(
password string,
name string,
color string,
emoji string,
) error {
err := api.verifyPassword(password)
if err != nil {
@ -128,6 +132,7 @@ func (api *API) AddAccountWithPrivateKey(
PublicKey: types.HexBytes(info.PublicKey),
Type: "key",
Name: name,
Emoji: emoji,
Color: color,
Path: pathDefaultWallet,
}
@ -140,6 +145,7 @@ func (api *API) GenerateAccount(
password string,
name string,
color string,
emoji string,
) error {
err := api.verifyPassword(password)
if err != nil {
@ -177,6 +183,7 @@ func (api *API) GenerateAccount(
PublicKey: types.HexBytes(infos[path].PublicKey),
Type: "generated",
Name: name,
Emoji: emoji,
Color: color,
Path: path,
}