From d5bba5d80f29aa838ac8dfa703816cf1c255b527 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Thu, 20 Jul 2023 17:00:39 +0200 Subject: [PATCH] chore: wallet accounts improvements - soft delete --- VERSION | 2 +- api/geth_backend.go | 4 +- appdatabase/migrations/bindata.go | 188 +++++----- ...ve_column_for_keypairs_and_accounts.up.sql | 9 + multiaccounts/accounts/database.go | 341 +++++++++++++----- multiaccounts/accounts/database_test.go | 56 +-- multiaccounts/accounts/keycard_database.go | 35 +- .../accounts/keycard_database_test.go | 8 +- multiaccounts/accounts/testutils.go | 2 +- ...nities_messenger_token_permissions_test.go | 2 +- protocol/messenger.go | 11 +- protocol/messenger_backup.go | 4 +- protocol/messenger_backup_test.go | 6 +- protocol/messenger_communities.go | 12 +- protocol/messenger_handler.go | 10 +- .../messenger_sync_keycard_change_test.go | 4 +- .../messenger_sync_keycards_state_test.go | 4 +- protocol/messenger_sync_wallets_test.go | 32 +- protocol/messenger_wallet.go | 104 ++++-- services/accounts/accounts.go | 33 +- services/ext/service.go | 2 +- services/stickers/api.go | 2 +- services/stickers/pending.go | 2 +- services/wallet/api.go | 2 +- 24 files changed, 583 insertions(+), 292 deletions(-) create mode 100644 appdatabase/migrations/sql/1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql diff --git a/VERSION b/VERSION index 8672af82e..cc2972b3d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.162.10 +0.162.11 \ No newline at end of file diff --git a/api/geth_backend.go b/api/geth_backend.go index f791653c5..7a37b2b8f 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -694,7 +694,7 @@ func (b *GethStatusBackend) MigrateKeyStoreDir(acc multiaccounts.Account, passwo if err != nil { return err } - accounts, err := accountDB.GetAccounts() + accounts, err := accountDB.GetAccounts(false) if err != nil { return err } @@ -1168,7 +1168,7 @@ func (b *GethStatusBackend) ConvertToRegularAccount(mnemonic string, currPasswor return err } - knownAccounts, err := db.GetAccounts() + knownAccounts, err := db.GetAccounts(false) if err != nil { return err } diff --git a/appdatabase/migrations/bindata.go b/appdatabase/migrations/bindata.go index c1935ce50..93eec136d 100644 --- a/appdatabase/migrations/bindata.go +++ b/appdatabase/migrations/bindata.go @@ -81,6 +81,7 @@ // 1689248269_add_related_chain_id_networks.up.sql (66B) // 1689340211_index_filter_columns.up.sql (633B) // 1689498471_make_wallet_accounts_positions_non_negative.up.sql (1.617kB) +// 1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql (284B) // doc.go (74B) package migrations @@ -165,7 +166,7 @@ func _1640111208_dummyUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(0644), modTime: time.Unix(1645666387, 0)} + info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3e, 0xf0, 0xae, 0x20, 0x6e, 0x75, 0xd1, 0x36, 0x14, 0xf2, 0x40, 0xe5, 0xd6, 0x7a, 0xc4, 0xa5, 0x72, 0xaa, 0xb5, 0x4d, 0x71, 0x97, 0xb8, 0xe8, 0x95, 0x22, 0x95, 0xa2, 0xac, 0xaf, 0x48, 0x58}} return a, nil } @@ -185,7 +186,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(0644), modTime: time.Unix(1645666387, 0)} + info := bindataFileInfo{name: "1642666031_add_removed_clock_to_bookmarks.up.sql", size: 117, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x84, 0x4e, 0x38, 0x99, 0x7a, 0xc, 0x90, 0x13, 0xec, 0xfe, 0x2f, 0x55, 0xff, 0xb7, 0xb6, 0xaa, 0x96, 0xc6, 0x92, 0x79, 0xcc, 0xee, 0x4e, 0x99, 0x53, 0xfe, 0x1c, 0xbb, 0x32, 0x2, 0xa4, 0x27}} return a, nil } @@ -205,7 +206,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(0644), modTime: time.Unix(1645666387, 0)} + info := bindataFileInfo{name: "1643644541_gif_api_key_setting.up.sql", size: 108, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1b, 0x94, 0x28, 0xfb, 0x66, 0xd1, 0x7c, 0xb8, 0x89, 0xe2, 0xb4, 0x71, 0x65, 0x24, 0x57, 0x22, 0x95, 0x38, 0x97, 0x3, 0x9b, 0xc6, 0xa4, 0x41, 0x7b, 0xba, 0xf7, 0xdb, 0x70, 0xf7, 0x20, 0x3a}} return a, nil } @@ -225,7 +226,7 @@ func _1644188994_recent_stickersUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1e, 0xad, 0xaa, 0x30, 0xbf, 0x4, 0x7, 0xf8, 0xc3, 0x3, 0xb8, 0x97, 0x23, 0x2b, 0xbd, 0x1c, 0x60, 0x69, 0xb0, 0x42, 0x5e, 0x6b, 0xd, 0xa7, 0xa3, 0x6b, 0x2e, 0xdc, 0x70, 0x13, 0x72, 0x7}} return a, nil } @@ -245,7 +246,7 @@ func _1646659233_add_address_to_dapp_permisssionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1646659233_add_address_to_dapp_permisssion.up.sql", size: 700, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1646659233_add_address_to_dapp_permisssion.up.sql", size: 700, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xed, 0xb0, 0x35, 0xcc, 0x2e, 0x16, 0xe6, 0x15, 0x86, 0x2c, 0x37, 0x80, 0xae, 0xa3, 0xc5, 0x31, 0x78, 0x5, 0x9d, 0xcd, 0x7b, 0xeb, 0x5f, 0xf2, 0xb3, 0x74, 0x72, 0xdf, 0xcf, 0x88, 0xb, 0x40}} return a, nil } @@ -265,7 +266,7 @@ func _1646841105_add_emoji_accountUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe6, 0x77, 0x29, 0x95, 0x18, 0x64, 0x82, 0x63, 0xe7, 0xaf, 0x6c, 0xa9, 0x15, 0x7d, 0x46, 0xa6, 0xbc, 0xdf, 0xa7, 0xd, 0x2b, 0xd2, 0x2d, 0x97, 0x4d, 0xa, 0x6b, 0xd, 0x6e, 0x90, 0x42, 0x5c}} return a, nil } @@ -285,7 +286,7 @@ func _1647278782_display_nameUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647278782_display_name.up.sql", size: 110, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1647278782_display_name.up.sql", size: 110, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf4, 0xa1, 0x1f, 0x3e, 0x61, 0x65, 0x8d, 0xff, 0xee, 0xde, 0xc5, 0x91, 0xd9, 0x5c, 0xb5, 0xe2, 0xf0, 0xb7, 0xe7, 0x5c, 0x5c, 0x16, 0x25, 0x89, 0xee, 0x78, 0x12, 0xea, 0x3e, 0x48, 0x41, 0xa6}} return a, nil } @@ -305,7 +306,7 @@ func _1647862838_reset_last_backupUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647862838_reset_last_backup.up.sql", size: 37, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1647862838_reset_last_backup.up.sql", size: 37, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x21, 0xe3, 0xd5, 0xf6, 0x5f, 0xfe, 0x65, 0xfa, 0x1d, 0x88, 0xf8, 0x5f, 0x24, 0x71, 0x34, 0x68, 0x96, 0x2a, 0x60, 0x87, 0x15, 0x82, 0x4d, 0x8a, 0x59, 0x3d, 0x1f, 0xd8, 0x56, 0xd4, 0xfb, 0xda}} return a, nil } @@ -325,7 +326,7 @@ func _1647871652_add_settings_sync_clock_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647871652_add_settings_sync_clock_table.up.sql", size: 1044, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1647871652_add_settings_sync_clock_table.up.sql", size: 1044, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd8, 0x58, 0xec, 0x85, 0x90, 0xfa, 0x30, 0x98, 0x98, 0x9a, 0xa6, 0xa8, 0x96, 0x2b, 0x38, 0x93, 0xf3, 0xae, 0x46, 0x74, 0xa4, 0x41, 0x62, 0x9b, 0x2, 0x86, 0xbf, 0xe5, 0x2a, 0xce, 0xe2, 0xc0}} return a, nil } @@ -345,7 +346,7 @@ func _1647880168_add_torrent_configUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647880168_add_torrent_config.up.sql", size: 211, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1647880168_add_torrent_config.up.sql", size: 211, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1, 0x92, 0x22, 0x37, 0x96, 0xf3, 0xb5, 0x5b, 0x27, 0xd0, 0x7d, 0x43, 0x5, 0x4e, 0x9d, 0xe2, 0x49, 0xbe, 0x86, 0x31, 0xa1, 0x89, 0xff, 0xd6, 0x51, 0xe0, 0x9c, 0xb, 0xda, 0xfc, 0xf2, 0x93}} return a, nil } @@ -365,7 +366,7 @@ func _1647882837_add_communities_settings_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647882837_add_communities_settings_table.up.sql", size: 206, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1647882837_add_communities_settings_table.up.sql", size: 206, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xbd, 0x87, 0x78, 0x99, 0xd9, 0x5d, 0xbd, 0xf7, 0x57, 0x9c, 0xca, 0x97, 0xbd, 0xb3, 0xe9, 0xb5, 0x89, 0x31, 0x3f, 0xf6, 0x5c, 0x13, 0xb, 0xc3, 0x54, 0x93, 0x18, 0x40, 0x7, 0x82, 0xfe, 0x7e}} return a, nil } @@ -385,7 +386,7 @@ func _1647956635_add_waku_messages_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647956635_add_waku_messages_table.up.sql", size: 266, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1647956635_add_waku_messages_table.up.sql", size: 266, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd1, 0xe, 0xe1, 0xdc, 0xda, 0x2e, 0x89, 0x8d, 0xdc, 0x2a, 0x1c, 0x13, 0xa1, 0xfc, 0xfe, 0xf, 0xb2, 0xb9, 0x85, 0xc8, 0x45, 0xd6, 0xd1, 0x7, 0x5c, 0xa3, 0x8, 0x47, 0x44, 0x6d, 0x96, 0xe0}} return a, nil } @@ -405,7 +406,7 @@ func _1648554928_network_testUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1648554928_network_test.up.sql", size: 132, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1648554928_network_test.up.sql", size: 132, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9a, 0xc5, 0x7f, 0x87, 0xf3, 0x2c, 0xf7, 0xbb, 0xd3, 0x3a, 0x4e, 0x76, 0x88, 0xca, 0xaf, 0x73, 0xce, 0x8f, 0xa1, 0xf6, 0x3d, 0x4d, 0xed, 0x6f, 0x49, 0xf2, 0xfe, 0x56, 0x2a, 0x60, 0x68, 0xca}} return a, nil } @@ -425,7 +426,7 @@ func _1649174829_add_visitble_tokenUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1649174829_add_visitble_token.up.sql", size: 84, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1649174829_add_visitble_token.up.sql", size: 84, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa3, 0x22, 0xc0, 0x2b, 0x3f, 0x4f, 0x3d, 0x5e, 0x4c, 0x68, 0x7c, 0xd0, 0x15, 0x36, 0x9f, 0xec, 0xa1, 0x2a, 0x7b, 0xb4, 0xe3, 0xc6, 0xc9, 0xb4, 0x81, 0x50, 0x4a, 0x11, 0x3b, 0x35, 0x7, 0xcf}} return a, nil } @@ -445,7 +446,7 @@ func _1649882262_add_derived_from_accountsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1649882262_add_derived_from_accounts.up.sql", size: 110, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1649882262_add_derived_from_accounts.up.sql", size: 110, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x11, 0xb9, 0x44, 0x4d, 0x85, 0x8d, 0x7f, 0xb4, 0xae, 0x4f, 0x5c, 0x66, 0x64, 0xb6, 0xe2, 0xe, 0x3d, 0xad, 0x9d, 0x8, 0x4f, 0xab, 0x6e, 0xa8, 0x7d, 0x76, 0x3, 0xad, 0x96, 0x1, 0xee, 0x5c}} return a, nil } @@ -465,7 +466,7 @@ func _1650612625_add_community_message_archive_hashes_tableUpSql() (*asset, erro return nil, err } - info := bindataFileInfo{name: "1650612625_add_community_message_archive_hashes_table.up.sql", size: 130, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1650612625_add_community_message_archive_hashes_table.up.sql", size: 130, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x48, 0x31, 0xb3, 0x75, 0x23, 0xe2, 0x45, 0xe, 0x47, 0x1b, 0x35, 0xa5, 0x6e, 0x83, 0x4e, 0x64, 0x7d, 0xd7, 0xa2, 0xda, 0xe9, 0x53, 0xf1, 0x16, 0x86, 0x2c, 0x57, 0xad, 0xfa, 0xca, 0x39, 0xde}} return a, nil } @@ -485,7 +486,7 @@ func _1650616788_add_communities_archives_info_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1650616788_add_communities_archives_info_table.up.sql", size: 208, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1650616788_add_communities_archives_info_table.up.sql", size: 208, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd1, 0x4f, 0x80, 0x45, 0xb9, 0xd9, 0x15, 0xe2, 0x78, 0xd0, 0xcb, 0x71, 0xc1, 0x1b, 0xb7, 0x1b, 0x1b, 0x97, 0xfe, 0x47, 0x53, 0x3c, 0x62, 0xbc, 0xdd, 0x3a, 0x94, 0x1a, 0xc, 0x48, 0x76, 0xe}} return a, nil } @@ -505,7 +506,7 @@ func _1652715604_add_clock_accountsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1652715604_add_clock_accounts.up.sql", size: 62, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1652715604_add_clock_accounts.up.sql", size: 62, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb6, 0xd9, 0x8d, 0x73, 0xc9, 0xef, 0xfa, 0xb1, 0x4b, 0xa5, 0xf3, 0x5, 0x19, 0x26, 0x46, 0xf8, 0x47, 0x93, 0xdb, 0xac, 0x2, 0xef, 0xf9, 0x71, 0x56, 0x83, 0xe6, 0x2d, 0xb0, 0xd7, 0x83, 0x5c}} return a, nil } @@ -525,7 +526,7 @@ func _1653037334_add_notifications_settings_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1653037334_add_notifications_settings_table.up.sql", size: 1276, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1653037334_add_notifications_settings_table.up.sql", size: 1276, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4b, 0xc4, 0x65, 0xac, 0xa, 0xf2, 0xef, 0xb6, 0x39, 0x3c, 0xc5, 0xb1, 0xb2, 0x9c, 0x86, 0x58, 0xe0, 0x38, 0xcb, 0x57, 0x3c, 0x76, 0x73, 0x87, 0x79, 0x4e, 0xf6, 0xed, 0xb0, 0x8e, 0x9e, 0xa}} return a, nil } @@ -545,7 +546,7 @@ func _1654702119_add_mutual_contact_settingsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1654702119_add_mutual_contact_settings.up.sql", size: 78, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1654702119_add_mutual_contact_settings.up.sql", size: 78, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x26, 0x66, 0x67, 0x50, 0xfe, 0xd7, 0xe3, 0x29, 0x8b, 0xff, 0x9d, 0x5a, 0x87, 0xa7, 0x99, 0x6e, 0xd6, 0xcd, 0x2e, 0xbb, 0x17, 0xdf, 0x7f, 0xf7, 0xa3, 0xfa, 0x32, 0x7c, 0x2d, 0x92, 0xc8, 0x74}} return a, nil } @@ -565,7 +566,7 @@ func _1655375270_add_clock_field_to_communities_settings_tableUpSql() (*asset, e return nil, err } - info := bindataFileInfo{name: "1655375270_add_clock_field_to_communities_settings_table.up.sql", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1655375270_add_clock_field_to_communities_settings_table.up.sql", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x19, 0xc5, 0xc0, 0xf9, 0x84, 0x53, 0xdf, 0x83, 0xcf, 0xb6, 0x40, 0x6d, 0xf5, 0xdc, 0x77, 0x37, 0xb7, 0xe3, 0xa, 0x75, 0xe7, 0x6, 0x11, 0xca, 0x2b, 0x51, 0x92, 0xdd, 0x7d, 0xdb, 0xc3, 0xf5}} return a, nil } @@ -585,7 +586,7 @@ func _1655385721_drop_networks_configUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1655385721_drop_networks_config.up.sql", size: 27, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1655385721_drop_networks_config.up.sql", size: 27, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfc, 0xa7, 0x20, 0xbb, 0x67, 0x21, 0xe, 0xc6, 0xc8, 0x21, 0x74, 0xe0, 0xce, 0xc8, 0xe2, 0x2, 0xb4, 0xea, 0xf0, 0xe5, 0xc4, 0x4d, 0xdd, 0xd4, 0x52, 0x31, 0xa9, 0x3d, 0xcd, 0xd8, 0x9b, 0xab}} return a, nil } @@ -605,7 +606,7 @@ func _1655385724_networks_chaincolor_shortnameUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1655385724_networks_chainColor_shortName.up.sql", size: 220, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1655385724_networks_chainColor_shortName.up.sql", size: 220, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd9, 0xe7, 0x84, 0xbb, 0x5f, 0xd2, 0x2c, 0x42, 0x88, 0x62, 0x52, 0xb6, 0x58, 0x31, 0xac, 0xc, 0x96, 0x2b, 0x1b, 0xe5, 0x4e, 0x9a, 0x3a, 0xf6, 0xf6, 0xfc, 0xa9, 0x1a, 0x35, 0x62, 0x28, 0x88}} return a, nil } @@ -625,7 +626,7 @@ func _1655456688_add_deleted_at_field_to_bookmarks_tableUpSql() (*asset, error) return nil, err } - info := bindataFileInfo{name: "1655456688_add_deleted_at_field_to_bookmarks_table.up.sql", size: 69, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1655456688_add_deleted_at_field_to_bookmarks_table.up.sql", size: 69, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe7, 0x9a, 0xbd, 0x9a, 0xc9, 0xf, 0xdf, 0x90, 0x0, 0x5d, 0xea, 0x6e, 0x7d, 0x51, 0x95, 0xcd, 0x90, 0xd3, 0x1a, 0x36, 0x6c, 0xf4, 0xbd, 0xa7, 0x6b, 0xbf, 0xe5, 0xdb, 0xa3, 0x88, 0xe3, 0x50}} return a, nil } @@ -645,7 +646,7 @@ func _1655462032_create_bookmarks_deleted_at_indexUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1655462032_create_bookmarks_deleted_at_index.up.sql", size: 81, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1655462032_create_bookmarks_deleted_at_index.up.sql", size: 81, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf, 0x8e, 0x20, 0x6b, 0x14, 0x9e, 0xcd, 0x97, 0xd3, 0xfe, 0x62, 0x3, 0x26, 0x59, 0x1, 0x6c, 0x99, 0xef, 0x6d, 0x21, 0xd4, 0xb5, 0xa3, 0xf4, 0x39, 0x40, 0x54, 0x6, 0xd, 0x60, 0x13, 0x38}} return a, nil } @@ -665,7 +666,7 @@ func _1657617291_add_multi_transactions_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1657617291_add_multi_transactions_table.up.sql", size: 412, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1657617291_add_multi_transactions_table.up.sql", size: 412, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x86, 0xb0, 0x4e, 0x8c, 0x4, 0x82, 0xb4, 0x43, 0xaa, 0xd0, 0x16, 0xdd, 0xcb, 0x88, 0x81, 0xac, 0x4, 0x34, 0x1a, 0x8f, 0x2e, 0xc5, 0x69, 0xb, 0xf0, 0x17, 0xf7, 0xe3, 0x9, 0xe, 0x54, 0xe0}} return a, nil } @@ -685,7 +686,7 @@ func _1660134042_add_social_links_settings_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1660134042_add_social_links_settings_table.up.sql", size: 334, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1660134042_add_social_links_settings_table.up.sql", size: 334, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x84, 0x73, 0xb6, 0xe7, 0x3f, 0xaa, 0x39, 0x9a, 0x56, 0x56, 0x31, 0xf1, 0x8e, 0x26, 0x23, 0x1, 0xe4, 0xfa, 0x98, 0xfe, 0x78, 0x87, 0x20, 0xcb, 0x52, 0xf4, 0x38, 0x7f, 0xc4, 0x1c, 0x4, 0x22}} return a, nil } @@ -705,7 +706,7 @@ func _1660134060_settings_bioUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1660134060_settings_bio.up.sql", size: 91, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1660134060_settings_bio.up.sql", size: 91, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x46, 0x25, 0xa0, 0xa6, 0x47, 0xff, 0xbc, 0x2a, 0x0, 0xff, 0x59, 0x4b, 0xb0, 0xc9, 0x4e, 0x15, 0xe4, 0xd9, 0xda, 0xeb, 0xfe, 0x55, 0x98, 0xc3, 0x9d, 0x96, 0xe7, 0xf, 0xd1, 0x5c, 0x93, 0x73}} return a, nil } @@ -725,7 +726,7 @@ func _1660134070_add_wakuv2_storeUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1660134070_add_wakuv2_store.up.sql", size: 269, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1660134070_add_wakuv2_store.up.sql", size: 269, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1d, 0xe6, 0xc3, 0x9, 0xef, 0xdc, 0xae, 0x49, 0x30, 0x78, 0x54, 0xd6, 0xdb, 0xbf, 0xc0, 0x8e, 0x25, 0x8f, 0xfc, 0x67, 0x80, 0x39, 0x37, 0xd4, 0x86, 0xc1, 0x85, 0xc8, 0x99, 0xc4, 0x59, 0xd4}} return a, nil } @@ -745,7 +746,7 @@ func _1660134072_waku2_store_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1660134072_waku2_store_messages.up.sql", size: 497, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1660134072_waku2_store_messages.up.sql", size: 497, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3e, 0xeb, 0xb4, 0xa0, 0xa1, 0x2b, 0xcb, 0x4c, 0x3c, 0xc6, 0xd0, 0xe8, 0x96, 0xe3, 0x96, 0xf1, 0x4f, 0x1f, 0xe0, 0xe7, 0x1f, 0x85, 0xa3, 0xe, 0xf7, 0x52, 0x56, 0x63, 0x2b, 0xb0, 0x87, 0x7b}} return a, nil } @@ -765,7 +766,7 @@ func _1662365868_add_key_uid_accountsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1662365868_add_key_uid_accounts.up.sql", size: 68, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1662365868_add_key_uid_accounts.up.sql", size: 68, mode: os.FileMode(0644), modTime: time.Unix(1687770677, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc6, 0xd8, 0x2f, 0x2f, 0x3b, 0xa8, 0xbd, 0x6d, 0xf6, 0x87, 0x7e, 0xd2, 0xf1, 0xa2, 0xf7, 0x81, 0x6a, 0x23, 0x10, 0xbc, 0xbf, 0x5b, 0xe7, 0x2b, 0x9c, 0xa9, 0x8a, 0x18, 0xbb, 0xd0, 0x86, 0x91}} return a, nil } @@ -785,7 +786,7 @@ func _1662447680_add_keypairs_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1662447680_add_keypairs_table.up.sql", size: 218, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1662447680_add_keypairs_table.up.sql", size: 218, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xdc, 0x25, 0xa9, 0xc7, 0x63, 0x27, 0x97, 0x35, 0x5f, 0x6b, 0xab, 0x26, 0xcb, 0xf9, 0xbd, 0x5e, 0xac, 0x3, 0xa0, 0x5e, 0xb9, 0x71, 0xa3, 0x1f, 0xb3, 0x4f, 0x7f, 0x79, 0x28, 0x48, 0xbe, 0xc}} return a, nil } @@ -805,7 +806,7 @@ func _1662460056_move_favourites_to_saved_addressesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1662460056_move_favourites_to_saved_addresses.up.sql", size: 233, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1662460056_move_favourites_to_saved_addresses.up.sql", size: 233, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x10, 0xa2, 0x8c, 0xa3, 0xec, 0xad, 0xdf, 0xc3, 0x48, 0x5, 0x9b, 0x50, 0x25, 0x59, 0xae, 0x7d, 0xee, 0x58, 0xd2, 0x41, 0x27, 0xf2, 0x22, 0x2e, 0x9a, 0xb9, 0x4a, 0xcc, 0x38, 0x6e, 0x3a, 0xb2}} return a, nil } @@ -825,7 +826,7 @@ func _1662738097_add_base_fee_transactionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1662738097_add_base_fee_transaction.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1662738097_add_base_fee_transaction.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6b, 0xfb, 0x10, 0xae, 0xfc, 0x77, 0x70, 0x98, 0x6f, 0xec, 0xaa, 0xcd, 0x7, 0xc7, 0x74, 0x23, 0xc, 0xd5, 0x1e, 0x82, 0xdd, 0xfe, 0xff, 0x3b, 0xd2, 0x49, 0x10, 0x5b, 0x30, 0xc, 0x2d, 0xb0}} return a, nil } @@ -845,7 +846,7 @@ func _1662972194_add_keypairs_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1662972194_add_keypairs_table.up.sql", size: 345, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1662972194_add_keypairs_table.up.sql", size: 345, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xab, 0x76, 0xf2, 0x86, 0xe1, 0x7e, 0xe9, 0x47, 0x32, 0x48, 0xd5, 0x6b, 0xe5, 0xd, 0xab, 0xb7, 0xf1, 0xd4, 0xf1, 0xad, 0x38, 0xa6, 0x11, 0xe7, 0xce, 0x5c, 0x11, 0x11, 0xf, 0x47, 0xb2, 0x4}} return a, nil } @@ -865,7 +866,7 @@ func _1664392661_add_third_party_id_to_waku_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1664392661_add_third_party_id_to_waku_messages.up.sql", size: 70, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1664392661_add_third_party_id_to_waku_messages.up.sql", size: 70, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfd, 0x67, 0x66, 0x9e, 0x66, 0x74, 0xce, 0x1c, 0xb, 0x1b, 0x9d, 0xd5, 0xfc, 0x65, 0xe, 0x83, 0x90, 0x4c, 0x61, 0x4e, 0x6b, 0xe7, 0x86, 0xbe, 0x36, 0x4f, 0x91, 0x36, 0x4, 0x47, 0x7b, 0x82}} return a, nil } @@ -885,7 +886,7 @@ func _1664783660_add_sync_info_to_saved_addressesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1664783660_add_sync_info_to_saved_addresses.up.sql", size: 388, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1664783660_add_sync_info_to_saved_addresses.up.sql", size: 388, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x67, 0x7c, 0x3a, 0x95, 0x4e, 0x55, 0xb2, 0xbd, 0xb4, 0x18, 0x93, 0xc1, 0xcf, 0x9f, 0x12, 0xbb, 0x49, 0x8a, 0x2a, 0x6a, 0x2a, 0x7f, 0xad, 0x44, 0xc3, 0xf, 0x3a, 0x79, 0x18, 0xb9, 0x4c, 0x64}} return a, nil } @@ -905,7 +906,7 @@ func _1668109917_wakunodesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1668109917_wakunodes.up.sql", size: 99, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1668109917_wakunodes.up.sql", size: 99, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x29, 0xaa, 0x9e, 0x2, 0x66, 0x85, 0x69, 0xa8, 0xd9, 0xe2, 0x4b, 0x8d, 0x2a, 0x9c, 0xdf, 0xd2, 0xef, 0x64, 0x58, 0xe3, 0xa6, 0xe7, 0xc1, 0xd1, 0xc8, 0x9c, 0xc0, 0x2c, 0x1, 0xa8, 0x7b, 0x81}} return a, nil } @@ -925,7 +926,7 @@ func _1670249678_display_name_to_settings_sync_clock_tableUpSql() (*asset, error return nil, err } - info := bindataFileInfo{name: "1670249678_display_name_to_settings_sync_clock_table.up.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1670249678_display_name_to_settings_sync_clock_table.up.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x39, 0x18, 0xdc, 0xc4, 0x1f, 0x79, 0x22, 0x16, 0x4d, 0xdf, 0x6c, 0x66, 0xd5, 0xa4, 0x88, 0x5d, 0x5, 0x37, 0xa7, 0x41, 0x5, 0x50, 0xae, 0x12, 0xfa, 0x7e, 0x89, 0x24, 0x5c, 0xae, 0x30, 0xfc}} return a, nil } @@ -945,7 +946,7 @@ func _1670836810_add_imported_flag_to_community_archive_hashesUpSql() (*asset, e return nil, err } - info := bindataFileInfo{name: "1670836810_add_imported_flag_to_community_archive_hashes.up.sql", size: 144, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1670836810_add_imported_flag_to_community_archive_hashes.up.sql", size: 144, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6f, 0xf, 0xf0, 0xbd, 0xfe, 0x63, 0x25, 0x8f, 0x5e, 0x46, 0x4b, 0x45, 0x31, 0x8b, 0x3e, 0xd8, 0x6b, 0x5d, 0x9d, 0x6d, 0x10, 0x9a, 0x87, 0x4b, 0x18, 0xc6, 0x39, 0x81, 0x6e, 0xe4, 0x75, 0xfb}} return a, nil } @@ -965,7 +966,7 @@ func _1671438731_add_magnetlink_uri_to_communities_archive_infoUpSql() (*asset, return nil, err } - info := bindataFileInfo{name: "1671438731_add_magnetlink_uri_to_communities_archive_info.up.sql", size: 86, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1671438731_add_magnetlink_uri_to_communities_archive_info.up.sql", size: 86, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xda, 0x8b, 0x4b, 0xd6, 0xd8, 0xe2, 0x3d, 0xf7, 0x6b, 0xcd, 0x1e, 0x70, 0x9, 0x2e, 0x35, 0x4, 0x61, 0xc3, 0xb5, 0x9d, 0xc5, 0x27, 0x21, 0xa, 0x5a, 0xd6, 0x3e, 0xa6, 0x24, 0xa2, 0x12, 0xdf}} return a, nil } @@ -985,7 +986,7 @@ func _1672933930_switcher_cardUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1672933930_switcher_card.up.sql", size: 162, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1672933930_switcher_card.up.sql", size: 162, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x39, 0xba, 0xdc, 0xbb, 0x40, 0x4, 0xf2, 0x10, 0xdf, 0xb4, 0xd2, 0x80, 0x8a, 0x74, 0x4d, 0xf6, 0xbc, 0x50, 0x7, 0xd, 0x22, 0x7f, 0xc4, 0xaf, 0xaa, 0xde, 0xdc, 0x71, 0xe9, 0x42, 0x98, 0x36}} return a, nil } @@ -1005,7 +1006,7 @@ func _1674056187_add_price_cacheUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1674056187_add_price_cache.up.sql", size: 255, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1674056187_add_price_cache.up.sql", size: 255, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb7, 0x79, 0x6a, 0x9b, 0x28, 0xd1, 0x22, 0xf0, 0x84, 0x76, 0x40, 0x39, 0x49, 0x15, 0x5d, 0xaa, 0xfd, 0x11, 0xff, 0x13, 0x27, 0x42, 0x12, 0xfa, 0x82, 0xe6, 0x7a, 0xf0, 0x5e, 0x1f, 0xe3, 0xba}} return a, nil } @@ -1025,7 +1026,7 @@ func _1674136690_ens_usernamesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1674136690_ens_usernames.up.sql", size: 98, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1674136690_ens_usernames.up.sql", size: 98, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x81, 0x7a, 0xf3, 0xa8, 0x88, 0x99, 0xd6, 0x9c, 0x69, 0x48, 0x3c, 0x10, 0xda, 0x72, 0xdc, 0x14, 0xd, 0x6e, 0x8c, 0x82, 0x92, 0x2d, 0x2c, 0xee, 0x4c, 0x70, 0xa4, 0xdc, 0x5c, 0x5, 0x2, 0xc3}} return a, nil } @@ -1045,7 +1046,7 @@ func _1674232431_add_balance_historyUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1674232431_add_balance_history.up.sql", size: 698, mode: os.FileMode(0644), modTime: time.Unix(1675323803, 0)} + info := bindataFileInfo{name: "1674232431_add_balance_history.up.sql", size: 698, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf7, 0xb5, 0x18, 0xca, 0x4a, 0x93, 0xbb, 0x6f, 0xa4, 0xee, 0xe4, 0x3e, 0xff, 0x6a, 0x4b, 0xe2, 0xe1, 0x61, 0x28, 0xee, 0xc5, 0x26, 0x57, 0x61, 0x5e, 0x6d, 0x44, 0x1e, 0x85, 0x43, 0x70, 0xa2}} return a, nil } @@ -1065,7 +1066,7 @@ func _1676368933_keypairs_to_keycardsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1676368933_keypairs_to_keycards.up.sql", size: 639, mode: os.FileMode(0644), modTime: time.Unix(1677122376, 0)} + info := bindataFileInfo{name: "1676368933_keypairs_to_keycards.up.sql", size: 639, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x81, 0x93, 0x27, 0x2, 0xf0, 0x37, 0x81, 0x65, 0xa4, 0xb3, 0x5b, 0x60, 0x36, 0x95, 0xfc, 0x81, 0xf0, 0x3b, 0x7c, 0xc3, 0x2c, 0x85, 0xbd, 0x38, 0x46, 0xa4, 0x95, 0x4a, 0x6, 0x3e, 0x74, 0xd5}} return a, nil } @@ -1085,7 +1086,7 @@ func _1676951398_add_currency_format_cacheUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1676951398_add_currency_format_cache.up.sql", size: 291, mode: os.FileMode(0644), modTime: time.Unix(1677122376, 0)} + info := bindataFileInfo{name: "1676951398_add_currency_format_cache.up.sql", size: 291, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf9, 0xa3, 0x76, 0x35, 0xca, 0xf, 0xe8, 0xdf, 0xd9, 0x61, 0xf9, 0xed, 0xfc, 0x6d, 0xf5, 0xe, 0x11, 0x88, 0xbd, 0x14, 0x92, 0xc6, 0x57, 0x53, 0xe, 0xcd, 0x52, 0xf4, 0xa9, 0xb1, 0xdd, 0xfd}} return a, nil } @@ -1105,7 +1106,7 @@ func _1676968196_keycards_add_clock_columnUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1676968196_keycards_add_clock_column.up.sql", size: 73, mode: os.FileMode(0644), modTime: time.Unix(1677564198, 0)} + info := bindataFileInfo{name: "1676968196_keycards_add_clock_column.up.sql", size: 73, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4c, 0xf, 0x1c, 0x28, 0x41, 0x57, 0x57, 0x6c, 0xe, 0x75, 0x6b, 0x75, 0x12, 0x0, 0x18, 0x1e, 0x88, 0x1e, 0x45, 0xe0, 0x32, 0xb9, 0xd4, 0xd9, 0x2e, 0xc8, 0xb, 0x80, 0x6, 0x51, 0x3d, 0x28}} return a, nil } @@ -1125,7 +1126,7 @@ func _1676968197_add_fallback_rpc_to_networksUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1676968197_add_fallback_rpc_to_networks.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1677576114, 0)} + info := bindataFileInfo{name: "1676968197_add_fallback_rpc_to_networks.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x77, 0x6a, 0xc6, 0x45, 0xfa, 0x62, 0x84, 0x74, 0x6d, 0x7c, 0xd7, 0x1d, 0x79, 0xb6, 0x38, 0x43, 0xa8, 0x8, 0x6b, 0x75, 0x3d, 0x9, 0x2, 0xc5, 0x9f, 0xbb, 0x45, 0x56, 0x4c, 0x4e, 0x17, 0x89}} return a, nil } @@ -1145,7 +1146,7 @@ func _1677674090_add_chains_ens_istest_to_saved_addressesUpSql() (*asset, error) return nil, err } - info := bindataFileInfo{name: "1677674090_add_chains_ens_istest_to_saved_addresses.up.sql", size: 638, mode: os.FileMode(0644), modTime: time.Unix(1678240714, 0)} + info := bindataFileInfo{name: "1677674090_add_chains_ens_istest_to_saved_addresses.up.sql", size: 638, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa8, 0x2d, 0xa4, 0x1b, 0xf6, 0x6a, 0x13, 0x7b, 0xe, 0x59, 0xcd, 0xe2, 0x4e, 0x81, 0x99, 0xc4, 0x33, 0x84, 0xde, 0x66, 0xca, 0xac, 0x2f, 0x5, 0x90, 0xac, 0xfd, 0x4e, 0xfc, 0x55, 0x44, 0xe5}} return a, nil } @@ -1165,7 +1166,7 @@ func _1677681143_accounts_table_type_column_updateUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1677681143_accounts_table_type_column_update.up.sql", size: 135, mode: os.FileMode(0644), modTime: time.Unix(1678240714, 0)} + info := bindataFileInfo{name: "1677681143_accounts_table_type_column_update.up.sql", size: 135, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd2, 0xc4, 0x6, 0x42, 0x50, 0x1d, 0xf4, 0x48, 0x55, 0xbc, 0xa2, 0x19, 0xdd, 0xad, 0xc8, 0xc, 0xa7, 0x30, 0xb6, 0xaf, 0xe, 0x2b, 0xaa, 0x2a, 0xa4, 0xe1, 0xb9, 0x41, 0x23, 0x66, 0xd3, 0x3}} return a, nil } @@ -1185,7 +1186,7 @@ func _1678264207_accounts_table_new_columns_addedUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1678264207_accounts_table_new_columns_added.up.sql", size: 130, mode: os.FileMode(0644), modTime: time.Unix(1680083223, 0)} + info := bindataFileInfo{name: "1678264207_accounts_table_new_columns_added.up.sql", size: 130, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf4, 0xd4, 0xf3, 0x35, 0xef, 0x5c, 0x19, 0x3c, 0x15, 0x90, 0x60, 0xbd, 0x1f, 0x81, 0xf0, 0x86, 0x73, 0x89, 0xa0, 0x70, 0xf2, 0x46, 0xae, 0xea, 0xd0, 0xc6, 0x9e, 0x55, 0x4a, 0x54, 0x62, 0xbb}} return a, nil } @@ -1205,7 +1206,7 @@ func _1680770368_add_bio_to_settings_sync_clock_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1680770368_add_bio_to_settings_sync_clock_table.up.sql", size: 75, mode: os.FileMode(0644), modTime: time.Unix(1681777994, 0)} + info := bindataFileInfo{name: "1680770368_add_bio_to_settings_sync_clock_table.up.sql", size: 75, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4a, 0x52, 0xf6, 0x3f, 0xaa, 0xd, 0xa0, 0xee, 0xe8, 0xe6, 0x16, 0x21, 0x80, 0x61, 0xe4, 0x7a, 0x4e, 0x37, 0x8d, 0x30, 0x51, 0x20, 0x4d, 0x15, 0x47, 0xfb, 0x6, 0xa1, 0xce, 0xc8, 0x27, 0x5a}} return a, nil } @@ -1225,7 +1226,7 @@ func _1681110436_add_mnemonic_to_settings_sync_clock_tableUpSql() (*asset, error return nil, err } - info := bindataFileInfo{name: "1681110436_add_mnemonic_to_settings_sync_clock_table.up.sql", size: 311, mode: os.FileMode(0644), modTime: time.Unix(1681777994, 0)} + info := bindataFileInfo{name: "1681110436_add_mnemonic_to_settings_sync_clock_table.up.sql", size: 311, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3d, 0x74, 0x81, 0x7d, 0x9e, 0x77, 0xb6, 0xfe, 0xe3, 0xcb, 0x48, 0xe5, 0x5f, 0x39, 0x23, 0xa1, 0x7d, 0x53, 0x22, 0xe8, 0x96, 0x15, 0x8a, 0x1e, 0x8e, 0xbc, 0xe2, 0x1d, 0xc4, 0xc2, 0x56, 0x34}} return a, nil } @@ -1245,7 +1246,7 @@ func _1681392602_9d_sync_periodUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1681392602_9d_sync_period.up.sql", size: 60, mode: os.FileMode(0644), modTime: time.Unix(1681777994, 0)} + info := bindataFileInfo{name: "1681392602_9d_sync_period.up.sql", size: 60, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc9, 0xa, 0x90, 0x29, 0x7f, 0x76, 0x98, 0xa7, 0x71, 0x80, 0x5a, 0x2f, 0xbe, 0x23, 0x9a, 0xd4, 0xf4, 0x39, 0x19, 0xd3, 0xa5, 0x34, 0x6e, 0x67, 0x6a, 0xbe, 0x8a, 0xad, 0x21, 0xc7, 0xba, 0x88}} return a, nil } @@ -1265,7 +1266,7 @@ func _1681762078_default_sync_period_9dUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1681762078_default_sync_period_9d.up.sql", size: 3002, mode: os.FileMode(0644), modTime: time.Unix(1682429358, 0)} + info := bindataFileInfo{name: "1681762078_default_sync_period_9d.up.sql", size: 3002, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3e, 0xd9, 0x26, 0xfc, 0xa9, 0x45, 0xc1, 0x81, 0xa8, 0xe2, 0x2c, 0xe9, 0x3c, 0xea, 0x1d, 0x37, 0x11, 0x45, 0x8c, 0x6c, 0xbc, 0xc2, 0x6, 0x69, 0x2, 0x75, 0x29, 0x40, 0x9f, 0xc5, 0xbb, 0x36}} return a, nil } @@ -1285,7 +1286,7 @@ func _1681780680_add_clock_to_social_links_settingsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1681780680_add_clock_to_social_links_settings.up.sql", size: 137, mode: os.FileMode(0644), modTime: time.Unix(1682429358, 0)} + info := bindataFileInfo{name: "1681780680_add_clock_to_social_links_settings.up.sql", size: 137, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x63, 0x11, 0xf5, 0x41, 0xe5, 0x5a, 0xf4, 0xe3, 0xf3, 0x14, 0x87, 0x28, 0xd8, 0xf0, 0x52, 0x31, 0x8, 0xd5, 0xbb, 0xf4, 0xff, 0x55, 0x5f, 0x42, 0x90, 0xcb, 0xf7, 0x46, 0x2, 0x6, 0xbe, 0x42}} return a, nil } @@ -1305,7 +1306,7 @@ func _1682073779_settings_table_remove_latest_derived_path_columnUpSql() (*asset return nil, err } - info := bindataFileInfo{name: "1682073779_settings_table_remove_latest_derived_path_column.up.sql", size: 4470, mode: os.FileMode(0644), modTime: time.Unix(1682429358, 0)} + info := bindataFileInfo{name: "1682073779_settings_table_remove_latest_derived_path_column.up.sql", size: 4470, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7a, 0x36, 0x2, 0x41, 0xd, 0x5c, 0xd1, 0x92, 0x85, 0x6d, 0x84, 0xff, 0x67, 0xa7, 0x4c, 0x67, 0xa4, 0xef, 0x52, 0x69, 0x1f, 0x22, 0x25, 0x92, 0xc, 0xb3, 0x89, 0x50, 0x91, 0xc, 0x49, 0xf9}} return a, nil } @@ -1325,7 +1326,7 @@ func _1682146075_add_created_at_to_saved_addressesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1682146075_add_created_at_to_saved_addresses.up.sql", size: 107, mode: os.FileMode(0644), modTime: time.Unix(1682429358, 0)} + info := bindataFileInfo{name: "1682146075_add_created_at_to_saved_addresses.up.sql", size: 107, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x88, 0xfe, 0x35, 0x9c, 0x6b, 0xdf, 0x67, 0x18, 0x16, 0xe4, 0xc9, 0xd4, 0x77, 0x7c, 0x4, 0xe2, 0x6c, 0x41, 0xd9, 0x53, 0x97, 0xfe, 0x5, 0xa3, 0x23, 0xce, 0x82, 0xad, 0x92, 0x5e, 0xd7, 0x7d}} return a, nil } @@ -1345,7 +1346,7 @@ func _1682393575_sync_ens_nameUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1682393575_sync_ens_name.up.sql", size: 713, mode: os.FileMode(0644), modTime: time.Unix(1682560340, 0)} + info := bindataFileInfo{name: "1682393575_sync_ens_name.up.sql", size: 713, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfb, 0xea, 0xcb, 0x4d, 0x71, 0x5a, 0x49, 0x19, 0x8b, 0xef, 0x66, 0x27, 0x33, 0x89, 0xb0, 0xe, 0x37, 0x1b, 0x41, 0x8, 0x12, 0xcc, 0x56, 0xd8, 0x1b, 0xf, 0xf8, 0x50, 0x4b, 0x93, 0xf1, 0x29}} return a, nil } @@ -1365,7 +1366,7 @@ func _1683457503_add_blocks_ranges_sequential_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1683457503_add_blocks_ranges_sequential_table.up.sql", size: 263, mode: os.FileMode(0644), modTime: time.Unix(1684505071, 0)} + info := bindataFileInfo{name: "1683457503_add_blocks_ranges_sequential_table.up.sql", size: 263, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfe, 0x57, 0x2e, 0x0, 0x6a, 0x6e, 0xd7, 0xeb, 0xe6, 0x66, 0x79, 0x32, 0x22, 0x82, 0x92, 0xf4, 0xc9, 0xf1, 0x58, 0x1a, 0x45, 0x60, 0x77, 0x50, 0xe7, 0x54, 0x4a, 0xc0, 0x42, 0x3a, 0x4f, 0x35}} return a, nil } @@ -1385,7 +1386,7 @@ func _1683627613_accounts_and_keycards_improvementsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1683627613_accounts_and_keycards_improvements.up.sql", size: 3640, mode: os.FileMode(0644), modTime: time.Unix(1685430711, 0)} + info := bindataFileInfo{name: "1683627613_accounts_and_keycards_improvements.up.sql", size: 3640, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8e, 0xbe, 0x62, 0xf5, 0x9, 0x42, 0x8c, 0x8f, 0xa8, 0x45, 0xe7, 0x36, 0xc9, 0xde, 0xf4, 0xe2, 0xfd, 0xc4, 0x8, 0xd0, 0xa3, 0x8, 0x64, 0xe2, 0x56, 0xcc, 0xa7, 0x6d, 0xc5, 0xcc, 0x82, 0x2c}} return a, nil } @@ -1405,7 +1406,7 @@ func _1685041348_settings_table_add_latest_derived_path_columnUpSql() (*asset, e return nil, err } - info := bindataFileInfo{name: "1685041348_settings_table_add_latest_derived_path_column.up.sql", size: 115, mode: os.FileMode(0644), modTime: time.Unix(1685430711, 0)} + info := bindataFileInfo{name: "1685041348_settings_table_add_latest_derived_path_column.up.sql", size: 115, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x21, 0xd4, 0x1b, 0xbf, 0x8, 0xf9, 0xd4, 0xb0, 0xa0, 0x6, 0x5b, 0xfb, 0x7e, 0xff, 0xfa, 0xbf, 0xcc, 0x64, 0x47, 0x81, 0x8b, 0x5e, 0x17, 0x6a, 0xa7, 0xa4, 0x35, 0x8f, 0x30, 0x4f, 0xd9, 0xd}} return a, nil } @@ -1425,7 +1426,7 @@ func _1685440989_update_color_id_accountsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1685440989_update_color_id_accounts.up.sql", size: 918, mode: os.FileMode(0644), modTime: time.Unix(1686319261, 0)} + info := bindataFileInfo{name: "1685440989_update_color_id_accounts.up.sql", size: 918, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x10, 0x2e, 0x51, 0x1d, 0x2d, 0x16, 0x84, 0xd6, 0xe8, 0xbc, 0x20, 0x53, 0x47, 0xb8, 0x40, 0x21, 0x52, 0x5c, 0xd9, 0xbb, 0xea, 0xe2, 0xa5, 0x77, 0xc8, 0x35, 0x4c, 0xe0, 0x9d, 0x42, 0x44, 0x50}} return a, nil } @@ -1445,7 +1446,7 @@ func _1685463947_add_to_asset_to_multitransactionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1685463947_add_to_asset_to_multitransaction.up.sql", size: 61, mode: os.FileMode(0644), modTime: time.Unix(1686319261, 0)} + info := bindataFileInfo{name: "1685463947_add_to_asset_to_multitransaction.up.sql", size: 61, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd3, 0x66, 0x15, 0x10, 0xfa, 0x66, 0x81, 0x68, 0xd9, 0xb4, 0x93, 0x9e, 0x11, 0xed, 0x1d, 0x16, 0x9d, 0x5a, 0xf8, 0xd7, 0x8, 0xea, 0x7a, 0xaf, 0xe4, 0xb3, 0x22, 0x19, 0xca, 0xff, 0x75, 0x7c}} return a, nil } @@ -1465,7 +1466,7 @@ func _1685880973_add_profile_links_settings_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1685880973_add_profile_links_settings_table.up.sql", size: 1656, mode: os.FileMode(0644), modTime: time.Unix(1686319261, 0)} + info := bindataFileInfo{name: "1685880973_add_profile_links_settings_table.up.sql", size: 1656, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x13, 0x23, 0x7b, 0x1e, 0x82, 0x61, 0xcc, 0x76, 0xd6, 0xc7, 0x42, 0x6e, 0x69, 0x21, 0x1b, 0xfd, 0x7d, 0xda, 0xd7, 0xb7, 0xc7, 0xd3, 0x22, 0x63, 0xfe, 0xc6, 0xd3, 0xdf, 0xc8, 0x5f, 0x50, 0xcc}} return a, nil } @@ -1485,7 +1486,7 @@ func _1686041510_add_idx_transfers_blkno_loadedUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1686041510_add_idx_transfers_blkno_loaded.up.sql", size: 71, mode: os.FileMode(0644), modTime: time.Unix(1686319261, 0)} + info := bindataFileInfo{name: "1686041510_add_idx_transfers_blkno_loaded.up.sql", size: 71, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe2, 0x5d, 0x7e, 0x43, 0x14, 0x3c, 0x50, 0x44, 0x25, 0xd0, 0xe1, 0x75, 0xba, 0x61, 0x7b, 0x68, 0x2e, 0x43, 0x74, 0x1d, 0x10, 0x61, 0x8e, 0x45, 0xe6, 0x25, 0x78, 0x81, 0x68, 0x6, 0x24, 0x5b}} return a, nil } @@ -1505,7 +1506,7 @@ func _1686048341_transfers_receipt_json_blob_outUpSqlDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1686048341_transfers_receipt_json_blob_out.up.sql.down.sql", size: 104, mode: os.FileMode(0644), modTime: time.Unix(1686621769, 0)} + info := bindataFileInfo{name: "1686048341_transfers_receipt_json_blob_out.up.sql.down.sql", size: 104, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9f, 0x6c, 0xd9, 0x76, 0x83, 0x64, 0xf0, 0xf2, 0x74, 0x97, 0xca, 0xd7, 0xaa, 0x4, 0x74, 0x7c, 0x34, 0x56, 0x88, 0x10, 0xa9, 0x4d, 0x1d, 0x8e, 0x85, 0xc3, 0x66, 0x1, 0x2b, 0x30, 0x90, 0xf4}} return a, nil } @@ -1525,7 +1526,7 @@ func _1686048341_transfers_receipt_json_blob_outUpSqlUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1686048341_transfers_receipt_json_blob_out.up.sql.up.sql", size: 1500, mode: os.FileMode(0644), modTime: time.Unix(1686621769, 0)} + info := bindataFileInfo{name: "1686048341_transfers_receipt_json_blob_out.up.sql.up.sql", size: 1500, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x49, 0xcd, 0xe3, 0xa6, 0x8c, 0x53, 0x51, 0xe6, 0x3c, 0x64, 0xcb, 0x3, 0x3, 0xb, 0x4d, 0x52, 0xa5, 0x1c, 0xcc, 0xe1, 0x23, 0x94, 0x14, 0x79, 0xd7, 0x56, 0x58, 0xef, 0xcc, 0x1a, 0x6, 0xa4}} return a, nil } @@ -1545,7 +1546,7 @@ func _1686825075_cleanup_token_addressUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1686825075_cleanup_token_address.up.sql", size: 273, mode: os.FileMode(0644), modTime: time.Unix(1687351618, 0)} + info := bindataFileInfo{name: "1686825075_cleanup_token_address.up.sql", size: 273, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x14, 0x72, 0x10, 0xec, 0x97, 0xc9, 0x3a, 0xdb, 0x39, 0x33, 0xc9, 0x6, 0x92, 0xbe, 0xe4, 0xc2, 0x5c, 0xb6, 0xaa, 0xe5, 0x25, 0x21, 0x4d, 0x74, 0x18, 0x94, 0xc, 0x33, 0x2f, 0xa4, 0x9, 0x99}} return a, nil } @@ -1565,7 +1566,7 @@ func _1687193315_transfers_extract_from_to_addressDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1687193315_transfers_extract_from_to_address.down.sql", size: 104, mode: os.FileMode(0644), modTime: time.Unix(1687946577, 0)} + info := bindataFileInfo{name: "1687193315_transfers_extract_from_to_address.down.sql", size: 104, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9f, 0x6c, 0xd9, 0x76, 0x83, 0x64, 0xf0, 0xf2, 0x74, 0x97, 0xca, 0xd7, 0xaa, 0x4, 0x74, 0x7c, 0x34, 0x56, 0x88, 0x10, 0xa9, 0x4d, 0x1d, 0x8e, 0x85, 0xc3, 0x66, 0x1, 0x2b, 0x30, 0x90, 0xf4}} return a, nil } @@ -1585,7 +1586,7 @@ func _1687193315_transfers_extract_from_to_addressUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1687193315_transfers_extract_from_to_address.up.sql", size: 499, mode: os.FileMode(0644), modTime: time.Unix(1687946577, 0)} + info := bindataFileInfo{name: "1687193315_transfers_extract_from_to_address.up.sql", size: 499, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4c, 0xef, 0xf4, 0x66, 0xac, 0x3a, 0xa6, 0xe3, 0x26, 0x43, 0x53, 0xe, 0xd8, 0xfe, 0xf2, 0xaa, 0x20, 0x8, 0x4e, 0x52, 0x49, 0x37, 0xbf, 0x46, 0xbf, 0x53, 0xa7, 0xcf, 0x27, 0x23, 0xab, 0x99}} return a, nil } @@ -1605,7 +1606,7 @@ func _1687249080_add_position_accountsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1687249080_add_position_accounts.up..sql", size: 2053, mode: os.FileMode(0644), modTime: time.Unix(1688137680, 0)} + info := bindataFileInfo{name: "1687249080_add_position_accounts.up..sql", size: 2053, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf3, 0x47, 0x9f, 0xb4, 0xe3, 0xc, 0x35, 0x15, 0x74, 0xc3, 0x72, 0x57, 0x9f, 0x3b, 0xc9, 0xd5, 0x9b, 0x31, 0xef, 0xd6, 0x21, 0xc4, 0x27, 0x8e, 0x37, 0xd5, 0x5, 0xdb, 0x3d, 0xcf, 0x37, 0xbb}} return a, nil } @@ -1625,7 +1626,7 @@ func _1687269871_add_device_nameUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1687269871_add_device_name.up.sql", size: 108, mode: os.FileMode(0644), modTime: time.Unix(1688137680, 0)} + info := bindataFileInfo{name: "1687269871_add_device_name.up.sql", size: 108, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xed, 0x61, 0xf2, 0xf9, 0x78, 0x57, 0xc3, 0x57, 0xdb, 0x37, 0xe, 0x7, 0x15, 0xde, 0x5a, 0x2a, 0xb5, 0x86, 0xb8, 0x5, 0x48, 0x68, 0x2a, 0xb, 0x7c, 0xd, 0x60, 0xba, 0x67, 0x30, 0x2d, 0xa3}} return a, nil } @@ -1645,7 +1646,7 @@ func _1687506642_include_watch_only_account_settingUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1687506642_include_watch_only_account_setting.up.sql", size: 81, mode: os.FileMode(0644), modTime: time.Unix(1688137680, 0)} + info := bindataFileInfo{name: "1687506642_include_watch_only_account_setting.up.sql", size: 81, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xaa, 0xa0, 0x61, 0xf8, 0xb9, 0x15, 0x22, 0x9a, 0xca, 0x9b, 0x89, 0x96, 0x90, 0x47, 0x56, 0xf3, 0x21, 0xf6, 0xbd, 0xd1, 0xa1, 0x8f, 0xa8, 0x34, 0xc3, 0x54, 0x86, 0x69, 0x14, 0x96, 0xdb, 0xbb}} return a, nil } @@ -1665,7 +1666,7 @@ func _1688022264_add_include_watch_only_account_to_settings_sync_clockUpSql() (* return nil, err } - info := bindataFileInfo{name: "1688022264_add_include_watch_only_account_to_settings_sync_clock.up.sql", size: 98, mode: os.FileMode(0644), modTime: time.Unix(1688137680, 0)} + info := bindataFileInfo{name: "1688022264_add_include_watch_only_account_to_settings_sync_clock.up.sql", size: 98, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xab, 0xa2, 0x31, 0xcc, 0x3d, 0x59, 0x1b, 0x26, 0x5b, 0x78, 0xd, 0x6a, 0x75, 0x2a, 0xe0, 0x2, 0x21, 0x28, 0x8c, 0x92, 0x24, 0x98, 0x86, 0xdd, 0x2, 0x53, 0xe8, 0xf6, 0xc2, 0x7d, 0x57, 0x13}} return a, nil } @@ -1685,7 +1686,7 @@ func _1688054680_add_columns_to_multitransactionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1688054680_add_columns_to_multitransaction.up.sql", size: 342, mode: os.FileMode(0644), modTime: time.Unix(1689677237, 0)} + info := bindataFileInfo{name: "1688054680_add_columns_to_multitransaction.up.sql", size: 342, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb5, 0xbb, 0x88, 0xde, 0x98, 0x9e, 0xa8, 0xc0, 0xf7, 0x2b, 0xc4, 0x33, 0x77, 0xf5, 0x58, 0x46, 0x52, 0xc6, 0xc2, 0x27, 0x1d, 0x8, 0xc9, 0x83, 0xb6, 0x16, 0x31, 0x99, 0x15, 0xcb, 0xb1, 0x40}} return a, nil } @@ -1705,7 +1706,7 @@ func _1688636552_keycards_table_columns_updateUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1688636552_keycards_table_columns_update.up.sql", size: 1051, mode: os.FileMode(0644), modTime: time.Unix(1689677237, 0)} + info := bindataFileInfo{name: "1688636552_keycards_table_columns_update.up.sql", size: 1051, mode: os.FileMode(0644), modTime: time.Unix(1689340430, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2f, 0x82, 0x37, 0x82, 0xae, 0x44, 0x7f, 0x4d, 0xb5, 0x50, 0x1b, 0x5f, 0x2b, 0xaa, 0xb1, 0x3, 0x97, 0xba, 0x8b, 0xea, 0x30, 0x5, 0xa4, 0x1a, 0x2c, 0x7, 0x63, 0x89, 0x43, 0x12, 0xb6, 0xb7}} return a, nil } @@ -1725,7 +1726,7 @@ func _1689248269_add_related_chain_id_networksUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1689248269_add_related_chain_id_networks.up.sql", size: 66, mode: os.FileMode(0644), modTime: time.Unix(1689677237, 0)} + info := bindataFileInfo{name: "1689248269_add_related_chain_id_networks.up.sql", size: 66, mode: os.FileMode(0644), modTime: time.Unix(1689662849, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x76, 0xad, 0xde, 0xb5, 0xc7, 0x60, 0x1a, 0x99, 0x7d, 0x51, 0x74, 0x43, 0x60, 0x17, 0x54, 0x82, 0xb6, 0xc6, 0x96, 0x1c, 0x43, 0x74, 0x6, 0x15, 0xd6, 0xa4, 0x2a, 0xd2, 0x1c, 0xeb, 0xdc, 0xb4}} return a, nil } @@ -1745,7 +1746,7 @@ func _1689340211_index_filter_columnsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1689340211_index_filter_columns.up.sql", size: 633, mode: os.FileMode(0644), modTime: time.Unix(1689842988, 0)} + info := bindataFileInfo{name: "1689340211_index_filter_columns.up.sql", size: 633, mode: os.FileMode(0644), modTime: time.Unix(1689832764, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x83, 0xc8, 0x1, 0x8b, 0x85, 0x2b, 0xa7, 0x46, 0xfe, 0xe9, 0x9c, 0xaf, 0xec, 0x10, 0xe5, 0xec, 0x23, 0xd3, 0xf, 0xee, 0xad, 0xfb, 0xf1, 0xc7, 0xc, 0xbc, 0x14, 0xac, 0xf8, 0x3b, 0x5a, 0x9e}} return a, nil } @@ -1765,11 +1766,31 @@ func _1689498471_make_wallet_accounts_positions_non_negativeUpSql() (*asset, err return nil, err } - info := bindataFileInfo{name: "1689498471_make_wallet_accounts_positions_non_negative.up.sql", size: 1617, mode: os.FileMode(0644), modTime: time.Unix(1690254800, 0)} + info := bindataFileInfo{name: "1689498471_make_wallet_accounts_positions_non_negative.up.sql", size: 1617, mode: os.FileMode(0644), modTime: time.Unix(1690272108, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfe, 0x8d, 0xfc, 0x64, 0x78, 0x7a, 0x55, 0x38, 0xc9, 0x1e, 0x71, 0x25, 0xe2, 0x81, 0xc8, 0x3b, 0x1d, 0xf, 0xe7, 0x1f, 0x67, 0xbf, 0x6, 0xf1, 0x6a, 0x56, 0xf, 0x30, 0xb1, 0xc5, 0xca, 0x19}} return a, nil } +var __1689856991_add_soft_remove_column_for_keypairs_and_accountsUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x8e\x3d\x6e\x02\x31\x14\x84\x7b\x9f\x62\x3a\xe0\x0c\x88\xe2\x81\xdf\x2a\x85\x17\x47\x6b\xaf\x92\xce\xb2\xbc\x16\x58\x2c\x36\xc2\xce\x0f\xb7\x8f\xb4\x8a\xd2\x24\x4d\xda\xd1\xcc\x37\x1f\x29\xcb\x03\x2c\xed\x15\xe3\x12\x1f\x37\x9f\xee\x15\x24\x25\x0e\x5a\x8d\xfd\x11\xf7\x78\x2d\xef\x71\xc2\x5e\x6b\xc5\x74\x84\xe4\x8e\x46\x65\xd1\x91\x32\xbc\x15\x7f\xcd\x9d\x0f\xa1\xbc\xe5\xf6\x1f\x8e\x18\x9f\x25\x59\x16\x40\x8d\xad\xa5\x7c\xaa\xc2\xb0\x15\xc0\x87\x9f\xe7\xd8\x7e\x90\xee\x56\x6a\x6a\xa9\x64\x17\xce\x3e\x9f\xa2\x0b\x73\x09\x17\xec\xb0\x36\xac\xf8\x60\xd1\xd3\xeb\x7a\xc9\x36\x20\x83\xab\xff\xfc\x6e\x74\x83\xee\x7f\x1b\x6e\xc4\xcb\x13\x0f\xcb\xed\x23\xb7\x73\x6c\x29\xb8\x34\x61\x87\x55\x9a\x56\xdb\xaf\x00\x00\x00\xff\xff\x4e\x4f\x7c\x3c\x1c\x01\x00\x00") + +func _1689856991_add_soft_remove_column_for_keypairs_and_accountsUpSqlBytes() ([]byte, error) { + return bindataRead( + __1689856991_add_soft_remove_column_for_keypairs_and_accountsUpSql, + "1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql", + ) +} + +func _1689856991_add_soft_remove_column_for_keypairs_and_accountsUpSql() (*asset, error) { + bytes, err := _1689856991_add_soft_remove_column_for_keypairs_and_accountsUpSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql", size: 284, mode: os.FileMode(0644), modTime: time.Unix(1690272108, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd4, 0xfb, 0x7b, 0x9a, 0xee, 0xa4, 0x1f, 0x54, 0x81, 0x9c, 0x66, 0xd1, 0xde, 0x2d, 0xee, 0x8f, 0xb0, 0xc, 0x8, 0xb7, 0x1f, 0x5f, 0x28, 0x42, 0x75, 0x3, 0x19, 0xfb, 0xb5, 0x53, 0xa2, 0xcc}} + return a, nil +} + var _docGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2c\xc9\xb1\x0d\xc4\x20\x0c\x05\xd0\x9e\x29\xfe\x02\xd8\xfd\x6d\xe3\x4b\xac\x2f\x44\x82\x09\x78\x7f\xa5\x49\xfd\xa6\x1d\xdd\xe8\xd8\xcf\x55\x8a\x2a\xe3\x47\x1f\xbe\x2c\x1d\x8c\xfa\x6f\xe3\xb4\x34\xd4\xd9\x89\xbb\x71\x59\xb6\x18\x1b\x35\x20\xa2\x9f\x0a\x03\xa2\xe5\x0d\x00\x00\xff\xff\x60\xcd\x06\xbe\x4a\x00\x00\x00") func docGoBytes() ([]byte, error) { @@ -1785,7 +1806,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1645429416, 0)} + info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1687723683, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xde, 0x7c, 0x28, 0xcd, 0x47, 0xf2, 0xfa, 0x7c, 0x51, 0x2d, 0xd8, 0x38, 0xb, 0xb0, 0x34, 0x9d, 0x4c, 0x62, 0xa, 0x9e, 0x28, 0xc3, 0x31, 0x23, 0xd9, 0xbb, 0x89, 0x9f, 0xa0, 0x89, 0x1f, 0xe8}} return a, nil } @@ -2043,6 +2064,8 @@ var _bindata = map[string]func() (*asset, error){ "1689498471_make_wallet_accounts_positions_non_negative.up.sql": _1689498471_make_wallet_accounts_positions_non_negativeUpSql, + "1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql": _1689856991_add_soft_remove_column_for_keypairs_and_accountsUpSql, + "doc.go": docGo, } @@ -2168,6 +2191,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "1689248269_add_related_chain_id_networks.up.sql": &bintree{_1689248269_add_related_chain_id_networksUpSql, map[string]*bintree{}}, "1689340211_index_filter_columns.up.sql": &bintree{_1689340211_index_filter_columnsUpSql, map[string]*bintree{}}, "1689498471_make_wallet_accounts_positions_non_negative.up.sql": &bintree{_1689498471_make_wallet_accounts_positions_non_negativeUpSql, map[string]*bintree{}}, + "1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql": &bintree{_1689856991_add_soft_remove_column_for_keypairs_and_accountsUpSql, map[string]*bintree{}}, "doc.go": &bintree{docGo, map[string]*bintree{}}, }} diff --git a/appdatabase/migrations/sql/1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql b/appdatabase/migrations/sql/1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql new file mode 100644 index 000000000..c47103870 --- /dev/null +++ b/appdatabase/migrations/sql/1689856991_add_soft_remove_column_for_keypairs_and_accounts.up.sql @@ -0,0 +1,9 @@ +ALTER TABLE keypairs ADD COLUMN removed BOOLEAN DEFAULT FALSE; +ALTER TABLE keypairs_accounts ADD COLUMN removed BOOLEAN DEFAULT FALSE; + +UPDATE + settings +SET + wallet_accounts_position_change_clock = (SELECT MAX(clock) AS max_clock FROM keypairs_accounts) +WHERE + synthetic_id = 'id'; \ No newline at end of file diff --git a/multiaccounts/accounts/database.go b/multiaccounts/accounts/database.go index bd61dd850..a22c2b48b 100644 --- a/multiaccounts/accounts/database.go +++ b/multiaccounts/accounts/database.go @@ -18,18 +18,22 @@ import ( ) const ( - statusChatPath = "m/43'/60'/1581'/0'/0" - statusWalletRootPath = "m/44'/60'/0'/0/" - zeroAddress = "0x0000000000000000000000000000000000000000" - SyncedFromBackup = "backup" // means a account is coming from backed up data - SyncedFromLocalPairing = "local-pairing" // means a account is coming from another device when user is reocovering Status account + statusChatPath = "m/43'/60'/1581'/0'/0" + statusWalletRootPath = "m/44'/60'/0'/0/" + zeroAddress = "0x0000000000000000000000000000000000000000" + SyncedFromBackup = "backup" // means a account is coming from backed up data + SyncedFromLocalPairing = "local-pairing" // means a account is coming from another device when user is reocovering Status account + ThirtyDaysInMilliseconds = 30 * 24 * 60 * 60 * 1000 ) var ( errDbPassedParameterIsNil = errors.New("accounts: passed parameter is nil") errDbTransactionIsNil = errors.New("accounts: database transaction is nil") ErrDbKeypairNotFound = errors.New("accounts: keypair is not found") + ErrCannotRemoveProfileKeypair = errors.New("accounts: cannot remove profile keypair") ErrDbAccountNotFound = errors.New("accounts: account is not found") + ErrCannotRemoveProfileAccount = errors.New("accounts: cannot remove profile account") + ErrCannotRemoveDefaultWalletAccount = errors.New("accounts: cannot remove default wallet account") ErrAccountWrongPosition = errors.New("accounts: trying to set wrong position to account") ErrNotTheSameNumberOdAccountsToApplyReordering = errors.New("accounts: there is different number of accounts between received sync message and db accounts") ErrNotTheSameAccountsToApplyReordering = errors.New("accounts: there are differences between accounts in received sync message and db accounts") @@ -295,6 +299,7 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error) kpLastUsedDerivationIndex sql.NullInt64 kpSyncedFrom sql.NullString kpClock sql.NullInt64 + kpRemoved sql.NullBool ) var ( @@ -311,6 +316,7 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error) accClock sql.NullInt64 accCreatedAt sql.NullTime accPosition sql.NullInt64 + accRemoved sql.NullBool ) for rows.Next() { @@ -318,9 +324,9 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error) acc := &Account{} pubkey := []byte{} err := rows.Scan( - &kpKeyUID, &kpName, &kpType, &kpDerivedFrom, &kpLastUsedDerivationIndex, &kpSyncedFrom, &kpClock, + &kpKeyUID, &kpName, &kpType, &kpDerivedFrom, &kpLastUsedDerivationIndex, &kpSyncedFrom, &kpClock, &kpRemoved, &accAddress, &accKeyUID, &pubkey, &accPath, &accName, &accColorID, &accEmoji, - &accWallet, &accChat, &accHidden, &accOperable, &accClock, &accCreatedAt, &accPosition) + &accWallet, &accChat, &accHidden, &accOperable, &accClock, &accCreatedAt, &accPosition, &accRemoved) if err != nil { return nil, nil, err } @@ -347,6 +353,9 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error) if kpClock.Valid { kp.Clock = uint64(kpClock.Int64) } + if kpRemoved.Valid { + kp.Removed = kpRemoved.Bool + } // check keypair accounts fields if accAddress.Valid { acc.Address = types.BytesToAddress([]byte(accAddress.String)) @@ -391,6 +400,9 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error) acc.PublicKey = make(types.HexBytes, lth) copy(acc.PublicKey, pubkey) } + if accRemoved.Valid { + acc.Removed = accRemoved.Bool + } acc.Type = GetAccountTypeForKeypairType(kp.Type) if kp.KeyUID != "" { @@ -415,8 +427,11 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error) return keypairs, allAccounts, nil } -// If `keyUID` is passed only keypairs which match the passed `keyUID` will be returned, if `keyUID` is empty, all keypairs will be returned. -func (db *Database) getKeypairs(tx *sql.Tx, keyUID string) ([]*Keypair, error) { +// If `includeRemoved` is false and `keyUID` is not empty, then keypairs which are not flagged as removed and match the `keyUID` will be returned. +// If `includeRemoved` is true and `keyUID` is not empty, then keypairs which match the `keyUID` will be returned (regardless how they are flagged). +// If `includeRemoved` is false and `keyUID` is empty, then all keypairs which are not flagged as removed will be returned. +// If `includeRemoved` is true and `keyUID` is empty, then all keypairs will be returned (regardless how they are flagged). +func (db *Database) getKeypairs(tx *sql.Tx, keyUID string, includeRemoved bool) ([]*Keypair, error) { var ( rows *sql.Rows err error @@ -424,6 +439,9 @@ func (db *Database) getKeypairs(tx *sql.Tx, keyUID string) ([]*Keypair, error) { ) if tx == nil { tx, err = db.db.Begin() + if err != nil { + return nil, err + } defer func() { if err == nil { err = tx.Commit() @@ -431,15 +449,17 @@ func (db *Database) getKeypairs(tx *sql.Tx, keyUID string) ([]*Keypair, error) { } _ = tx.Rollback() }() - - if err != nil { - return nil, err - } } if keyUID != "" { where = "WHERE k.key_uid = ?" + if !includeRemoved { + where += " AND k.removed = FALSE" + } + } else if !includeRemoved { + where = "WHERE k.removed = FALSE" } + query := fmt.Sprintf( // nolint: gosec ` SELECT @@ -457,11 +477,18 @@ func (db *Database) getKeypairs(tx *sql.Tx, keyUID string) ([]*Keypair, error) { ka.operable, ka.clock, ka.created_at, - ka.position + ka.position, + ka.removed FROM keypairs k LEFT JOIN - keypairs_accounts ka + ( + SELECT * + FROM + keypairs_accounts + WHERE + removed = FALSE + ) AS ka ON k.key_uid = ka.key_uid %s @@ -474,7 +501,7 @@ func (db *Database) getKeypairs(tx *sql.Tx, keyUID string) ([]*Keypair, error) { } defer stmt.Close() - if where != "" { + if keyUID != "" { rows, err = stmt.Query(keyUID) } else { rows, err = stmt.Query() @@ -503,7 +530,7 @@ func (db *Database) getKeypairs(tx *sql.Tx, keyUID string) ([]*Keypair, error) { } func (db *Database) getKeypairByKeyUID(tx *sql.Tx, keyUID string) (*Keypair, error) { - keypairs, err := db.getKeypairs(tx, keyUID) + keypairs, err := db.getKeypairs(tx, keyUID, false) if err != nil && err != sql.ErrNoRows { return nil, err } @@ -515,15 +542,24 @@ func (db *Database) getKeypairByKeyUID(tx *sql.Tx, keyUID string) (*Keypair, err return keypairs[0], nil } -// If `address` is passed only accounts which match the passed `address` will be returned, if `address` is empty, all accounts will be returned. -func (db *Database) getAccounts(tx *sql.Tx, address types.Address) ([]*Account, error) { +// If `includeRemoved` is false and `address` is not zero address, then accounts which are not flagged as removed and match the `address` will be returned. +// If `includeRemoved` is true and `address` is not zero address, then accounts which match the `address` will be returned (regardless how they are flagged). +// If `includeRemoved` is false and `address` is zero address, then all accounts which are not flagged as removed will be returned. +// If `includeRemoved` is true and `address` is zero address, then all accounts will be returned (regardless how they are flagged). +func (db *Database) getAccounts(tx *sql.Tx, address types.Address, includeRemoved bool) ([]*Account, error) { var ( rows *sql.Rows err error where string ) - if address.String() != zeroAddress { + filterByAddress := address.String() != zeroAddress + if filterByAddress { where = "WHERE ka.address = ?" + if !includeRemoved { + where += " AND ka.removed = FALSE" + } + } else if !includeRemoved { + where = "WHERE ka.removed = FALSE" } query := fmt.Sprintf( // nolint: gosec @@ -543,7 +579,8 @@ func (db *Database) getAccounts(tx *sql.Tx, address types.Address) ([]*Account, ka.operable, ka.clock, ka.created_at, - ka.position + ka.position, + ka.removed FROM keypairs_accounts ka LEFT JOIN @@ -555,7 +592,7 @@ func (db *Database) getAccounts(tx *sql.Tx, address types.Address) ([]*Account, ka.position`, where) if tx == nil { - if where != "" { + if filterByAddress { rows, err = db.db.Query(query, address) } else { rows, err = db.db.Query(query) @@ -570,7 +607,7 @@ func (db *Database) getAccounts(tx *sql.Tx, address types.Address) ([]*Account, } defer stmt.Close() - if where != "" { + if filterByAddress { rows, err = stmt.Query(address) } else { rows, err = stmt.Query() @@ -590,7 +627,7 @@ func (db *Database) getAccounts(tx *sql.Tx, address types.Address) ([]*Account, } func (db *Database) getAccountByAddress(tx *sql.Tx, address types.Address) (*Account, error) { - accounts, err := db.getAccounts(tx, address) + accounts, err := db.getAccounts(tx, address, false) if err != nil && err != sql.ErrNoRows { return nil, err } @@ -602,57 +639,100 @@ func (db *Database) getAccountByAddress(tx *sql.Tx, address types.Address) (*Acc return accounts[0], nil } -func (db *Database) deleteKeypair(tx *sql.Tx, keyUID string) error { - keypairs, err := db.getKeypairs(tx, keyUID) - if err != nil && err != sql.ErrNoRows { +func (db *Database) markAccountRemoved(tx *sql.Tx, address types.Address, clock uint64) error { + if tx == nil { + return errDbTransactionIsNil + } + + _, err := db.getAccountByAddress(tx, address) + if err != nil { return err } - if len(keypairs) == 0 { - return ErrDbKeypairNotFound + query, err := tx.Prepare(` + UPDATE + keypairs_accounts + SET + removed = TRUE, + clock = ? + WHERE + address = ? + `) + if err != nil { + return err + } + defer query.Close() + + _, err = query.Exec(clock, address) + return err +} + +// Marking keypair as removed, will delete related keycards. +func (db *Database) markKeypairRemoved(tx *sql.Tx, keyUID string, clock uint64) error { + if tx == nil { + return errDbTransactionIsNil + } + + keypair, err := db.getKeypairByKeyUID(tx, keyUID) + if err != nil { + return err + } + + for _, acc := range keypair.Accounts { + if acc.Removed { + continue + } + err = db.markAccountRemoved(tx, acc.Address, clock) + if err != nil { + return err + } } query := ` - DELETE - FROM + UPDATE keypairs + SET + removed = TRUE, + clock = ? WHERE key_uid = ? ` - if tx == nil { - _, err := db.db.Exec(query, keyUID) - return err - } - stmt, err := tx.Prepare(query) if err != nil { return err } defer stmt.Close() - _, err = stmt.Exec(keyUID) + _, err = stmt.Exec(clock, keyUID) + if err != nil { + return err + } + + err = db.deleteAllKeycardsWithKeyUID(tx, keyUID) return err } -func (db *Database) GetKeypairs() ([]*Keypair, error) { - return db.getKeypairs(nil, "") +func (db *Database) GetKeypairs(includeRemoved bool) ([]*Keypair, error) { + return db.getKeypairs(nil, "", includeRemoved) } +// Returns keypair if it is not marked as removed and its accounts which are not marked as removed. func (db *Database) GetKeypairByKeyUID(keyUID string) (*Keypair, error) { return db.getKeypairByKeyUID(nil, keyUID) } -func (db *Database) GetAccounts() ([]*Account, error) { - return db.getAccounts(nil, types.Address{}) +func (db *Database) GetAccounts(includeRemoved bool) ([]*Account, error) { + return db.getAccounts(nil, types.Address{}, includeRemoved) } +// Returns account if it is not marked as removed. func (db *Database) GetAccountByAddress(address types.Address) (*Account, error) { return db.getAccountByAddress(nil, address) } -func (db *Database) GetWatchOnlyAccounts() (res []*Account, err error) { - accounts, err := db.getAccounts(nil, types.Address{}) +func (db *Database) GetWatchOnlyAccounts(includeRemoved bool) (res []*Account, err error) { + accounts, err := db.getAccounts(nil, types.Address{}, includeRemoved) if err != nil { return nil, err } @@ -678,12 +758,11 @@ func (db *Database) IsAnyAccountPartiallyOrFullyOperableForKeyUID(keyUID string) return false, nil } -func (db *Database) DeleteKeypair(keyUID string) error { - return db.deleteKeypair(nil, keyUID) -} - -func (db *Database) DeleteAccount(address types.Address, clock uint64) error { +func (db *Database) RemoveKeypair(keyUID string, clock uint64) error { tx, err := db.db.Begin() + if err != nil { + return err + } defer func() { if err == nil { err = tx.Commit() @@ -692,10 +771,23 @@ func (db *Database) DeleteAccount(address types.Address, clock uint64) error { _ = tx.Rollback() }() + return db.markKeypairRemoved(tx, keyUID, clock) +} + +func (db *Database) RemoveAccount(address types.Address, clock uint64) error { + tx, err := db.db.Begin() if err != nil { return err } + defer func() { + if err == nil { + err = tx.Commit() + return + } + _ = tx.Rollback() + }() + acc, err := db.getAccountByAddress(tx, address) if err != nil { return err @@ -706,23 +798,20 @@ func (db *Database) DeleteAccount(address types.Address, clock uint64) error { return err } - if kp != nil && len(kp.Accounts) == 1 && kp.Accounts[0].Address == address { - return db.deleteKeypair(tx, acc.KeyUID) + if kp != nil { + lastAccOfKepairToBeRemoved := true + for _, kpAcc := range kp.Accounts { + if !kpAcc.Removed && kpAcc.Address != address { + lastAccOfKepairToBeRemoved = false + } + } + + if lastAccOfKepairToBeRemoved { + return db.markKeypairRemoved(tx, acc.KeyUID, clock) + } } - delete, err := tx.Prepare(` - DELETE - FROM - keypairs_accounts - WHERE - address = ? - `) - if err != nil { - return err - } - defer delete.Close() - - _, err = delete.Exec(address) + err = db.markAccountRemoved(tx, address, clock) if err != nil { return err } @@ -821,12 +910,13 @@ func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account, update operable = ?, clock = ?, position = ?, - updated_at = datetime('now') + updated_at = datetime('now'), + removed = ? WHERE address = ?; `, acc.Address, keyUID, acc.PublicKey, acc.Path, acc.Wallet, acc.Chat, - acc.Name, acc.ColorID, acc.Emoji, acc.Hidden, acc.Operable, acc.Clock, acc.Position, acc.Address) + acc.Name, acc.ColorID, acc.Emoji, acc.Hidden, acc.Operable, acc.Clock, acc.Position, acc.Removed, acc.Address) if err != nil { return err @@ -846,7 +936,7 @@ func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account, update } } - if strings.HasPrefix(acc.Path, statusWalletRootPath) { + if !acc.Removed && strings.HasPrefix(acc.Path, statusWalletRootPath) { accIndex, err := strconv.ParseUint(acc.Path[len(statusWalletRootPath):], 0, 64) if err != nil { return err @@ -954,11 +1044,12 @@ func (db *Database) SaveOrUpdateKeypair(keypair *Keypair) error { name = ?, last_used_derivation_index = ?, synced_from = ?, - clock = ? + clock = ?, + removed = ? WHERE key_uid = ?; `, keypair.KeyUID, keypair.Type, keypair.DerivedFrom, - keypair.Name, keypair.LastUsedDerivationIndex, keypair.SyncedFrom, keypair.Clock, keypair.KeyUID) + keypair.Name, keypair.LastUsedDerivationIndex, keypair.SyncedFrom, keypair.Clock, keypair.Removed, keypair.KeyUID) if err != nil { return err } @@ -1020,7 +1111,7 @@ func (db *Database) GetWalletAddress() (rst types.Address, err error) { } func (db *Database) GetWalletAddresses() (rst []types.Address, err error) { - rows, err := db.db.Query("SELECT address FROM keypairs_accounts WHERE chat = 0 ORDER BY created_at") + rows, err := db.db.Query("SELECT address FROM keypairs_accounts WHERE chat = 0 AND removed = FALSE ORDER BY created_at") if err != nil { return nil, err } @@ -1048,7 +1139,7 @@ func (db *Database) GetChatAddress() (rst types.Address, err error) { } func (db *Database) GetAddresses() (rst []types.Address, err error) { - rows, err := db.db.Query("SELECT address FROM keypairs_accounts ORDER BY created_at") + rows, err := db.db.Query("SELECT address FROM keypairs_accounts WHERE removed = FALSE ORDER BY created_at") if err != nil { return nil, err } @@ -1071,7 +1162,7 @@ func (db *Database) GetAddresses() (rst []types.Address, err error) { } func (db *Database) keypairExists(tx *sql.Tx, keyUID string) (exists bool, err error) { - query := `SELECT EXISTS (SELECT 1 FROM keypairs WHERE key_uid = ?)` + query := `SELECT EXISTS (SELECT 1 FROM keypairs WHERE key_uid = ? AND removed = FALSE)` if tx == nil { err = db.db.QueryRow(query, keyUID).Scan(&exists) @@ -1089,13 +1180,13 @@ func (db *Database) KeypairExists(keyUID string) (exists bool, err error) { // AddressExists returns true if given address is stored in database. func (db *Database) AddressExists(address types.Address) (exists bool, err error) { - err = db.db.QueryRow("SELECT EXISTS (SELECT 1 FROM keypairs_accounts WHERE address = ?)", address).Scan(&exists) + err = db.db.QueryRow("SELECT EXISTS (SELECT 1 FROM keypairs_accounts WHERE address = ? AND removed = FALSE)", address).Scan(&exists) return exists, err } // GetPath returns true if account with given address was recently key and doesn't have a key yet func (db *Database) GetPath(address types.Address) (path string, err error) { - err = db.db.QueryRow("SELECT path FROM keypairs_accounts WHERE address = ?", address).Scan(&path) + err = db.db.QueryRow("SELECT path FROM keypairs_accounts WHERE address = ? AND removed = FALSE", address).Scan(&path) return path, err } @@ -1106,6 +1197,9 @@ func (db *Database) GetNodeConfig() (*params.NodeConfig, error) { // This function should not update the clock, cause it marks accounts locally. func (db *Database) SetAccountOperability(address types.Address, operable AccountOperable) (err error) { tx, err := db.db.Begin() + if err != nil { + return err + } defer func() { if err == nil { err = tx.Commit() @@ -1114,10 +1208,6 @@ func (db *Database) SetAccountOperability(address types.Address, operable Accoun _ = tx.Rollback() }() - if err != nil { - return err - } - _, err = db.getAccountByAddress(tx, address) if err != nil { return err @@ -1129,7 +1219,7 @@ func (db *Database) SetAccountOperability(address types.Address, operable Accoun func (db *Database) GetPositionForNextNewAccount() (int64, error) { var pos sql.NullInt64 - err := db.db.QueryRow("SELECT MAX(position) FROM keypairs_accounts").Scan(&pos) + err := db.db.QueryRow("SELECT MAX(position) FROM keypairs_accounts WHERE removed = FALSE").Scan(&pos) if err != nil { return 0, err } @@ -1160,6 +1250,9 @@ func (db *Database) GetClockOfLastAccountsPositionChange() (result uint64, err e // Updates positions of accounts respecting current order. func (db *Database) ResolveAccountsPositions(clock uint64) (err error) { tx, err := db.db.Begin() + if err != nil { + return err + } defer func() { if err == nil { err = tx.Commit() @@ -1169,7 +1262,7 @@ func (db *Database) ResolveAccountsPositions(clock uint64) (err error) { }() // returns all accounts ordered by position - dbAccounts, err := db.getAccounts(tx, types.Address{}) + dbAccounts, err := db.getAccounts(tx, types.Address{}, false) if err != nil { return err } @@ -1199,6 +1292,9 @@ func (db *Database) SetWalletAccountsPositions(accounts []*Account, clock uint64 } } tx, err := db.db.Begin() + if err != nil { + return err + } defer func() { if err == nil { err = tx.Commit() @@ -1207,7 +1303,7 @@ func (db *Database) SetWalletAccountsPositions(accounts []*Account, clock uint64 _ = tx.Rollback() }() - dbAccounts, err := db.getAccounts(tx, types.Address{}) + dbAccounts, err := db.getAccounts(tx, types.Address{}, false) if err != nil { return err } @@ -1249,6 +1345,9 @@ func (db *Database) MoveWalletAccount(fromPosition int64, toPosition int64, cloc return ErrMovingAccountToWrongPosition } tx, err := db.db.Begin() + if err != nil { + return err + } defer func() { if err == nil { err = tx.Commit() @@ -1261,7 +1360,7 @@ func (db *Database) MoveWalletAccount(fromPosition int64, toPosition int64, cloc newMaxPosition int64 newMinPosition int64 ) - err = tx.QueryRow("SELECT MAX(position), MIN(position) FROM keypairs_accounts").Scan(&newMaxPosition, &newMinPosition) + err = tx.QueryRow("SELECT MAX(position), MIN(position) FROM keypairs_accounts WHERE removed = FALSE").Scan(&newMaxPosition, &newMinPosition) if err != nil { return err } @@ -1269,32 +1368,32 @@ func (db *Database) MoveWalletAccount(fromPosition int64, toPosition int64, cloc newMinPosition-- if toPosition > fromPosition { - _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ?", newMaxPosition, fromPosition) + _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ? AND removed = FALSE", newMaxPosition, fromPosition) if err != nil { return err } for i := fromPosition + 1; i <= toPosition; i++ { - _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ?", i-1, i) + _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ? AND removed = FALSE", i-1, i) if err != nil { return err } } - _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ?", toPosition, newMaxPosition) + _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ? AND removed = FALSE", toPosition, newMaxPosition) if err != nil { return err } } else { - _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ?", newMinPosition, fromPosition) + _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ? AND removed = FALSE", newMinPosition, fromPosition) if err != nil { return err } for i := fromPosition - 1; i >= toPosition; i-- { - _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ?", i+1, i) + _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ? AND removed = FALSE", i+1, i) if err != nil { return err } } - _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ?", toPosition, newMinPosition) + _, err = tx.Exec("UPDATE keypairs_accounts SET position = ? WHERE position = ? AND removed = FALSE", toPosition, newMinPosition) if err != nil { return err } @@ -1302,3 +1401,71 @@ func (db *Database) MoveWalletAccount(fromPosition int64, toPosition int64, cloc return db.setClockOfLastAccountsPositionChange(tx, clock) } + +func (db *Database) CheckAndDeleteExpiredKeypairsAndAccounts(time uint64) error { + tx, err := db.db.Begin() + if err != nil { + return err + } + defer func() { + if err == nil { + err = tx.Commit() + return + } + _ = tx.Rollback() + }() + + // Check keypairs first + dbKeypairs, err := db.getKeypairs(tx, "", true) + if err != nil { + return err + } + + for _, dbKp := range dbKeypairs { + if dbKp.Type == KeypairTypeProfile || + !dbKp.Removed || + time-dbKp.Clock < ThirtyDaysInMilliseconds { + continue + } + query := ` + DELETE + FROM + keypairs + WHERE + key_uid = ? + ` + _, err := tx.Exec(query, dbKp.KeyUID) + if err != nil { + return err + } + } + + // Check accounts (keypair related and watch only as well) + dbAccounts, err := db.getAccounts(tx, types.Address{}, true) + if err != nil { + return err + } + + for _, dbAcc := range dbAccounts { + if dbAcc.Chat || + dbAcc.Wallet || + !dbAcc.Removed || + time-dbAcc.Clock < ThirtyDaysInMilliseconds { + continue + } + + query := ` + DELETE + FROM + keypairs_accounts + WHERE + address = ? + ` + _, err := tx.Exec(query, dbAcc.Address) + if err != nil { + return err + } + } + + return nil +} diff --git a/multiaccounts/accounts/database_test.go b/multiaccounts/accounts/database_test.go index e80d36c88..59516c14e 100644 --- a/multiaccounts/accounts/database_test.go +++ b/multiaccounts/accounts/database_test.go @@ -66,7 +66,7 @@ func TestMoveWalletAccount(t *testing.T) { {Address: types.Address{0x06}, Type: AccountTypeWatch, Position: 5}, } require.NoError(t, db.SaveOrUpdateAccounts(accounts, false)) - dbAccounts, err := db.GetAccounts() + dbAccounts, err := db.GetAccounts(false) require.NoError(t, err) require.Len(t, dbAccounts, len(accounts)) for i := 0; i < len(accounts); i++ { @@ -95,7 +95,7 @@ func TestMoveWalletAccount(t *testing.T) { {Address: types.Address{0x06}, Type: AccountTypeWatch, Position: 5}, } - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) for i := 0; i < len(accounts); i++ { require.True(t, SameAccounts(accounts[i], dbAccounts[i])) @@ -121,7 +121,7 @@ func TestMoveWalletAccount(t *testing.T) { {Address: types.Address{0x02}, Type: AccountTypeWatch, Position: 5}, } - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) for i := 0; i < len(accounts); i++ { require.True(t, SameAccounts(accounts[i], dbAccounts[i])) @@ -184,7 +184,7 @@ func TestWatchOnlyAccounts(t *testing.T) { defer stop() // check the db - dbAccounts, err := db.GetAccounts() + dbAccounts, err := db.GetAccounts(false) require.NoError(t, err) require.Equal(t, 0, len(dbAccounts)) @@ -197,7 +197,7 @@ func TestWatchOnlyAccounts(t *testing.T) { require.Error(t, err) // check the db after that trying to save keypair with watch only accounts - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, 0, len(dbAccounts)) @@ -207,7 +207,7 @@ func TestWatchOnlyAccounts(t *testing.T) { _, err = db.GetKeypairByKeyUID(woAccounts[0].KeyUID) require.Error(t, err) require.True(t, err == ErrDbKeypairNotFound) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(woAccounts), len(dbAccounts)) require.Equal(t, woAccounts[0].Address, dbAccounts[0].Address) @@ -215,7 +215,7 @@ func TestWatchOnlyAccounts(t *testing.T) { // try to save the same watch only account again err = db.SaveOrUpdateAccounts(woAccounts[:1], false) require.NoError(t, err) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(woAccounts), len(dbAccounts)) dbAcc, err := db.GetAccountByAddress(woAccounts[:1][0].Address) @@ -232,7 +232,7 @@ func TestWatchOnlyAccounts(t *testing.T) { } err = db.SaveOrUpdateAccounts([]*Account{wo4}, false) require.NoError(t, err) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(woAccounts)+1, len(dbAccounts)) dbAcc, err = db.GetAccountByAddress(wo4.Address) @@ -245,7 +245,7 @@ func TestWatchOnlyAccounts(t *testing.T) { wo4.Emoji = wo4.Emoji + "updated" err = db.SaveOrUpdateAccounts([]*Account{wo4}, false) require.NoError(t, err) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(woAccounts)+1, len(dbAccounts)) dbAcc, err = db.GetAccountByAddress(wo4.Address) @@ -253,14 +253,14 @@ func TestWatchOnlyAccounts(t *testing.T) { require.Equal(t, wo4.Address, dbAcc.Address) // try to delete keypair for watch only account - err = db.DeleteKeypair(wo4.KeyUID) + err = db.RemoveKeypair(wo4.KeyUID, 0) require.Error(t, err) require.True(t, err == ErrDbKeypairNotFound) // try to delete watch only account - err = db.DeleteAccount(wo4.Address, 0) + err = db.RemoveAccount(wo4.Address, 0) require.NoError(t, err) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(woAccounts), len(dbAccounts)) _, err = db.GetAccountByAddress(wo4.Address) @@ -275,14 +275,14 @@ func TestUpdateKeypairName(t *testing.T) { kp := GetProfileKeypairForTest(true, false, false) // check the db - dbAccounts, err := db.GetAccounts() + dbAccounts, err := db.GetAccounts(false) require.NoError(t, err) require.Equal(t, 0, len(dbAccounts)) // save keypair err = db.SaveOrUpdateKeypair(kp) require.NoError(t, err) - dbKeypairs, err := db.GetKeypairs() + dbKeypairs, err := db.GetKeypairs(false) require.NoError(t, err) require.Equal(t, 1, len(dbKeypairs)) require.True(t, SameKeypairs(kp, dbKeypairs[0])) @@ -313,10 +313,10 @@ func TestKeypairs(t *testing.T) { defer stop() // check the db - dbKeypairs, err := db.GetKeypairs() + dbKeypairs, err := db.GetKeypairs(false) require.NoError(t, err) require.Equal(t, 0, len(dbKeypairs)) - dbAccounts, err := db.GetAccounts() + dbAccounts, err := db.GetAccounts(false) require.NoError(t, err) require.Equal(t, 0, len(dbAccounts)) @@ -328,7 +328,7 @@ func TestKeypairs(t *testing.T) { // save keypair err = db.SaveOrUpdateKeypair(kp) require.NoError(t, err) - dbKeypairs, err = db.GetKeypairs() + dbKeypairs, err = db.GetKeypairs(false) require.NoError(t, err) require.Equal(t, 1, len(dbKeypairs)) dbKp, err := db.GetKeypairByKeyUID(kp.KeyUID) @@ -336,12 +336,12 @@ func TestKeypairs(t *testing.T) { require.Equal(t, len(kp.Accounts), len(dbKp.Accounts)) kp.LastUsedDerivationIndex = expectedLastUsedDerivationIndex require.Equal(t, kp.KeyUID, dbKp.KeyUID) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(kp.Accounts), len(dbAccounts)) // delete keypair - err = db.DeleteKeypair(kp.KeyUID) + err = db.RemoveKeypair(kp.KeyUID, 0) require.NoError(t, err) _, err = db.GetKeypairByKeyUID(kp.KeyUID) require.Error(t, err) @@ -350,7 +350,7 @@ func TestKeypairs(t *testing.T) { // save keypair again to test the flow below err = db.SaveOrUpdateKeypair(kp) require.NoError(t, err) - dbKeypairs, err = db.GetKeypairs() + dbKeypairs, err = db.GetKeypairs(false) require.NoError(t, err) require.Equal(t, 1, len(dbKeypairs)) @@ -364,7 +364,7 @@ func TestKeypairs(t *testing.T) { require.NoError(t, err) require.Equal(t, len(kp.Accounts), len(dbKp.Accounts)) require.Equal(t, kp.KeyUID, dbKp.KeyUID) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(kp.Accounts), len(dbAccounts)) @@ -378,7 +378,7 @@ func TestKeypairs(t *testing.T) { dbKp, err = db.GetKeypairByKeyUID(kp.KeyUID) require.NoError(t, err) require.Equal(t, len(kp.Accounts), len(dbKp.Accounts)) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(kp.Accounts), len(dbAccounts)) dbAcc, err := db.GetAccountByAddress(accToUpdate.Address) @@ -390,7 +390,7 @@ func TestKeypairs(t *testing.T) { kpToUpdate.Name = kpToUpdate.Name + "updated" err = db.SaveOrUpdateKeypair(kp) require.NoError(t, err) - dbKeypairs, err = db.GetKeypairs() + dbKeypairs, err = db.GetKeypairs(false) require.NoError(t, err) require.Equal(t, 1, len(dbKeypairs)) dbKp, err = db.GetKeypairByKeyUID(kp.KeyUID) @@ -411,7 +411,7 @@ func TestKeypairs(t *testing.T) { require.NoError(t, err) require.Equal(t, len(kp.Accounts)+1, len(dbKp.Accounts)) require.Equal(t, kp.LastUsedDerivationIndex, dbKp.LastUsedDerivationIndex) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(kp.Accounts)+1, len(dbAccounts)) dbAcc, err = db.GetAccountByAddress(accToUpdate.Address) @@ -440,7 +440,7 @@ func TestKeypairs(t *testing.T) { require.NoError(t, err) require.Equal(t, len(kp.Accounts)+2, len(dbKp.Accounts)) require.Equal(t, expectedLastUsedDerivationIndex, dbKp.LastUsedDerivationIndex) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(kp.Accounts)+2, len(dbAccounts)) dbAcc, err = db.GetAccountByAddress(accToUpdate.Address) @@ -448,9 +448,9 @@ func TestKeypairs(t *testing.T) { require.Equal(t, accToAdd.Address, dbAcc.Address) // delete account - err = db.DeleteAccount(accToAdd.Address, 0) + err = db.RemoveAccount(accToAdd.Address, 0) require.NoError(t, err) - dbAccounts, err = db.GetAccounts() + dbAccounts, err = db.GetAccounts(false) require.NoError(t, err) require.Equal(t, len(kp.Accounts)+1, len(dbAccounts)) _, err = db.GetAccountByAddress(accToAdd.Address) @@ -458,7 +458,7 @@ func TestKeypairs(t *testing.T) { require.True(t, err == ErrDbAccountNotFound) for _, acc := range dbAccounts { - err = db.DeleteAccount(acc.Address, 0) + err = db.RemoveAccount(acc.Address, 0) require.NoError(t, err) } diff --git a/multiaccounts/accounts/keycard_database.go b/multiaccounts/accounts/keycard_database.go index f525396d4..4a0ab98c0 100644 --- a/multiaccounts/accounts/keycard_database.go +++ b/multiaccounts/accounts/keycard_database.go @@ -236,6 +236,27 @@ func (db *Database) deleteKeycard(tx *sql.Tx, kcUID string) (err error) { return err } +func (db *Database) deleteAllKeycardsWithKeyUID(tx *sql.Tx, keyUID string) (err error) { + if tx == nil { + return errKeycardDbTransactionIsNil + } + + delete, err := tx.Prepare(` + DELETE + FROM + keycards + WHERE + key_uid = ? + `) + if err != nil { + return err + } + defer delete.Close() + + _, err = delete.Exec(keyUID) + return err +} + func (db *Database) deleteKeycardAccounts(tx *sql.Tx, kcUID string, accountAddresses []types.Address) (err error) { if tx == nil { return errKeycardDbTransactionIsNil @@ -435,19 +456,7 @@ func (db *Database) DeleteAllKeycardsWithKeyUID(keyUID string, clock uint64) (er _ = tx.Rollback() }() - delete, err := tx.Prepare(` - DELETE - FROM - keycards - WHERE - key_uid = ? - `) - if err != nil { - return err - } - defer delete.Close() - - _, err = delete.Exec(keyUID) + err = db.deleteAllKeycardsWithKeyUID(tx, keyUID) if err != nil { return err } diff --git a/multiaccounts/accounts/keycard_database_test.go b/multiaccounts/accounts/keycard_database_test.go index 8ad1aa4df..7f85cb95d 100644 --- a/multiaccounts/accounts/keycard_database_test.go +++ b/multiaccounts/accounts/keycard_database_test.go @@ -28,7 +28,7 @@ func TestKeycards(t *testing.T) { require.NoError(t, err) err = db.SaveOrUpdateKeypair(kp2) require.NoError(t, err) - dbKeypairs, err := db.GetKeypairs() + dbKeypairs, err := db.GetKeypairs(false) require.NoError(t, err) require.Equal(t, 2, len(dbKeypairs)) @@ -168,7 +168,7 @@ func TestKeycardsRemovalWhenDeletingKeypair(t *testing.T) { // Pre-condition err := db.SaveOrUpdateKeypair(kp2) require.NoError(t, err) - dbKeypairs, err := db.GetKeypairs() + dbKeypairs, err := db.GetKeypairs(false) require.NoError(t, err) require.Equal(t, 1, len(dbKeypairs)) @@ -193,11 +193,11 @@ func TestKeycardsRemovalWhenDeletingKeypair(t *testing.T) { require.True(t, Contains(dbKeycards, keycard2Copy, SameKeycards)) // Remove keypair - err = db.DeleteKeypair(kp2.KeyUID) + err = db.RemoveKeypair(kp2.KeyUID, 0) require.NoError(t, err) // Check db state after deletion - dbKeypairs, err = db.GetKeypairs() + dbKeypairs, err = db.GetKeypairs(false) require.NoError(t, err) require.Equal(t, 0, len(dbKeypairs)) diff --git a/multiaccounts/accounts/testutils.go b/multiaccounts/accounts/testutils.go index 0549b53b6..3c9f7993b 100644 --- a/multiaccounts/accounts/testutils.go +++ b/multiaccounts/accounts/testutils.go @@ -13,7 +13,7 @@ func MockTestAccounts(tb testing.TB, db *sql.DB, accounts []*Account) { err = d.SaveOrUpdateAccounts(accounts, false) require.NoError(tb, err) - res, err := d.GetAccounts() + res, err := d.GetAccounts(false) require.NoError(tb, err) require.Equal(tb, accounts[0].Address, res[0].Address) } diff --git a/protocol/communities_messenger_token_permissions_test.go b/protocol/communities_messenger_token_permissions_test.go index 75e1281f7..14ce7dfca 100644 --- a/protocol/communities_messenger_token_permissions_test.go +++ b/protocol/communities_messenger_token_permissions_test.go @@ -151,7 +151,7 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) newMessenger(password string s.Require().NoError(err) } - walletAccounts, err := messenger.settings.GetAccounts() + walletAccounts, err := messenger.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Len(walletAccounts, len(walletAddresses)) for i := range walletAddresses { diff --git a/protocol/messenger.go b/protocol/messenger.go index 5a8d7511d..4595a9b2d 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -713,6 +713,11 @@ func (m *Messenger) ToBackground() { } func (m *Messenger) Start() (*MessengerResponse, error) { + now := time.Now().UnixMilli() + if err := m.settings.CheckAndDeleteExpiredKeypairsAndAccounts(uint64(now)); err != nil { + return nil, err + } + m.logger.Info("starting messenger", zap.String("identity", types.EncodeHex(crypto.FromECDSAPub(&m.identity.PublicKey)))) // Start push notification server if m.pushNotificationServer != nil { @@ -2559,7 +2564,8 @@ func (m *Messenger) SyncDevices(ctx context.Context, ensName, photoPath string, } } - keypairs, err := m.settings.GetKeypairs() + // we have to sync deleted keypairs as well + keypairs, err := m.settings.GetKeypairs(true) if err != nil { return err } @@ -2574,7 +2580,8 @@ func (m *Messenger) SyncDevices(ctx context.Context, ensName, photoPath string, } } - woAccounts, err := m.settings.GetWatchOnlyAccounts() + // we have to sync deleted watch only accounts as well + woAccounts, err := m.settings.GetWatchOnlyAccounts(true) if err != nil { return err } diff --git a/protocol/messenger_backup.go b/protocol/messenger_backup.go index 8caf5f114..abddb579d 100644 --- a/protocol/messenger_backup.go +++ b/protocol/messenger_backup.go @@ -421,7 +421,7 @@ func (m *Messenger) backupProfile(ctx context.Context, clock uint64) ([]*protobu } func (m *Messenger) backupKeypairs() ([]*protobuf.Backup, error) { - keypairs, err := m.settings.GetKeypairs() + keypairs, err := m.settings.GetKeypairs(false) if err != nil { return nil, err } @@ -446,7 +446,7 @@ func (m *Messenger) backupKeypairs() ([]*protobuf.Backup, error) { } func (m *Messenger) backupWatchOnlyAccounts() ([]*protobuf.Backup, error) { - accounts, err := m.settings.GetWatchOnlyAccounts() + accounts, err := m.settings.GetWatchOnlyAccounts(true) if err != nil { return nil, err } diff --git a/protocol/messenger_backup_test.go b/protocol/messenger_backup_test.go index 518962554..71a57ebb4 100644 --- a/protocol/messenger_backup_test.go +++ b/protocol/messenger_backup_test.go @@ -772,7 +772,7 @@ func (s *MessengerBackupSuite) TestBackupKeycards() { s.Require().NoError(err) err = bob1.settings.SaveOrUpdateKeypair(kp3) s.Require().NoError(err) - dbKeypairs, err := bob1.settings.GetKeypairs() + dbKeypairs, err := bob1.settings.GetKeypairs(false) s.Require().NoError(err) s.Require().Equal(3, len(dbKeypairs)) @@ -822,7 +822,7 @@ func (s *MessengerBackupSuite) TestBackupWatchOnlyAccounts() { woAccounts := accounts.GetWatchOnlyAccountsForTest() err := bob1.settings.SaveOrUpdateAccounts(woAccounts, false) s.Require().NoError(err) - dbWoAccounts1, err := bob1.settings.GetWatchOnlyAccounts() + dbWoAccounts1, err := bob1.settings.GetWatchOnlyAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbWoAccounts1)) s.Require().True(haveSameElements(woAccounts, dbWoAccounts1, accounts.SameAccounts)) @@ -848,7 +848,7 @@ func (s *MessengerBackupSuite) TestBackupWatchOnlyAccounts() { ) s.Require().NoError(err) - dbWoAccounts2, err := bob2.settings.GetWatchOnlyAccounts() + dbWoAccounts2, err := bob2.settings.GetWatchOnlyAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbWoAccounts2)) s.Require().True(haveSameElements(woAccounts, dbWoAccounts2, accounts.SameAccounts)) diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 1a60e153f..edc52821e 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -752,7 +752,7 @@ func (m *Messenger) SetMutePropertyOnChatsByCategory(request *requests.MuteCateg // getAccountsToShare is used to get the wallet accounts to share either when requesting to join a community or when editing // requestToJoinID can be empty when editing func (m *Messenger) getAccountsToShare(addressesToReveal []string, airdropAddress string, communityID types.HexBytes, password string, requestToJoinID []byte) (map[gethcommon.Address]*protobuf.RevealedAccount, []gethcommon.Address, error) { - walletAccounts, err := m.settings.GetAccounts() + walletAccounts, err := m.settings.GetAccounts(false) if err != nil { return nil, nil, err } @@ -819,7 +819,7 @@ func (m *Messenger) RequestToJoinCommunity(request *requests.RequestToJoinCommun } if request.Password != "" { - walletAccounts, err := m.settings.GetAccounts() + walletAccounts, err := m.settings.GetAccounts(false) if err != nil { return nil, err } @@ -975,7 +975,7 @@ func (m *Messenger) EditSharedAddressesForCommunity(request *requests.EditShared return nil, err } - walletAccounts, err := m.settings.GetAccounts() + walletAccounts, err := m.settings.GetAccounts(false) if err != nil { return nil, err } @@ -4122,7 +4122,7 @@ func (m *Messenger) CheckPermissionsToJoinCommunity(request *requests.CheckPermi return nil, err } - accounts, err := m.settings.GetAccounts() + accounts, err := m.settings.GetAccounts(false) if err != nil { return nil, err } @@ -4141,7 +4141,7 @@ func (m *Messenger) CheckCommunityChannelPermissions(request *requests.CheckComm return nil, err } - accounts, err := m.settings.GetAccounts() + accounts, err := m.settings.GetAccounts(false) if err != nil { return nil, err } @@ -4160,7 +4160,7 @@ func (m *Messenger) CheckAllCommunityChannelsPermissions(request *requests.Check return nil, err } - accounts, err := m.settings.GetAccounts() + accounts, err := m.settings.GetAccounts(false) if err != nil { return nil, err } diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index a9faa1c79..dd4161ad0 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -48,7 +48,6 @@ var ( ErrTryingToStoreOldWalletAccount = errors.New("trying to store an old wallet account") ErrTryingToStoreOldKeypair = errors.New("trying to store an old keypair") ErrSomeFieldsMissingForWalletAccount = errors.New("some fields are missing for wallet account") - ErrTryingToRemoveUnexistingWalletAccount = errors.New("trying to remove an unexisting wallet account") ErrUnknownKeypairForWalletAccount = errors.New("keypair is not known for the wallet account") ErrInvalidCommunityID = errors.New("invalid community id") ) @@ -3105,7 +3104,7 @@ func (m *Messenger) handleSyncWatchOnlyAccount(message *protobuf.SyncAccount) (* } if message.Removed { - err = m.settings.DeleteAccount(accAddress, message.Clock) + err = m.settings.RemoveAccount(accAddress, message.Clock) if err != nil { return nil, err } @@ -3113,10 +3112,6 @@ func (m *Messenger) handleSyncWatchOnlyAccount(message *protobuf.SyncAccount) (* dbAccount.Removed = true return dbAccount, err } - } else { - if message.Removed { - return nil, ErrTryingToRemoveUnexistingWalletAccount - } } acc := mapSyncAccountToAccount(message, accountOperability, accounts.AccountTypeWatch) @@ -3233,7 +3228,8 @@ func (m *Messenger) handleSyncKeypair(message *protobuf.SyncKeypair) (*accounts. } } - err = m.settings.DeleteKeypair(message.KeyUid) // deleting keypair will delete related keycards as well + // deleting keypair will delete related keycards as well + err = m.settings.RemoveKeypair(message.KeyUid, message.Clock) if err != nil && err != accounts.ErrDbKeypairNotFound { return nil, err } diff --git a/protocol/messenger_sync_keycard_change_test.go b/protocol/messenger_sync_keycard_change_test.go index 9b558d85b..b4c386d00 100644 --- a/protocol/messenger_sync_keycard_change_test.go +++ b/protocol/messenger_sync_keycard_change_test.go @@ -89,7 +89,7 @@ func (s *MessengerSyncKeycardChangeSuite) SetupTest() { s.Require().NoError(err) // err = s.main.settings.SaveOrUpdateKeypair(kp3) // s.Require().NoError(err) - dbKeypairs, err := s.main.settings.GetKeypairs() + dbKeypairs, err := s.main.settings.GetKeypairs(false) s.Require().NoError(err) s.Require().Equal(2, len(dbKeypairs)) @@ -103,7 +103,7 @@ func (s *MessengerSyncKeycardChangeSuite) SetupTest() { s.Require().NoError(err) // err = s.other.settings.SaveOrUpdateKeypair(kp3) // s.Require().NoError(err) - dbKeypairs, err = s.other.settings.GetKeypairs() + dbKeypairs, err = s.other.settings.GetKeypairs(false) s.Require().NoError(err) s.Require().Equal(2, len(dbKeypairs)) } diff --git a/protocol/messenger_sync_keycards_state_test.go b/protocol/messenger_sync_keycards_state_test.go index b98ac1461..98dc048f0 100644 --- a/protocol/messenger_sync_keycards_state_test.go +++ b/protocol/messenger_sync_keycards_state_test.go @@ -89,7 +89,7 @@ func (s *MessengerSyncKeycardsStateSuite) SetupTest() { s.Require().NoError(err) err = s.main.settings.SaveOrUpdateKeypair(kp3) s.Require().NoError(err) - dbKeypairs, err := s.main.settings.GetKeypairs() + dbKeypairs, err := s.main.settings.GetKeypairs(false) s.Require().NoError(err) s.Require().Equal(3, len(dbKeypairs)) @@ -103,7 +103,7 @@ func (s *MessengerSyncKeycardsStateSuite) SetupTest() { s.Require().NoError(err) err = s.other.settings.SaveOrUpdateKeypair(kp3) s.Require().NoError(err) - dbKeypairs, err = s.other.settings.GetKeypairs() + dbKeypairs, err = s.other.settings.GetKeypairs(false) s.Require().NoError(err) s.Require().Equal(3, len(dbKeypairs)) } diff --git a/protocol/messenger_sync_wallets_test.go b/protocol/messenger_sync_wallets_test.go index 17c608408..358afcf2f 100644 --- a/protocol/messenger_sync_wallets_test.go +++ b/protocol/messenger_sync_wallets_test.go @@ -146,12 +146,12 @@ func (s *MessengerSyncWalletSuite) TestSyncWallets() { woAccounts := accounts.GetWatchOnlyAccountsForTest() err = s.m.settings.SaveOrUpdateAccounts(woAccounts, false) s.Require().NoError(err) - dbWoAccounts1, err := s.m.settings.GetWatchOnlyAccounts() + dbWoAccounts1, err := s.m.settings.GetWatchOnlyAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbWoAccounts1)) s.Require().True(haveSameElements(woAccounts, dbWoAccounts1, accounts.SameAccounts)) - dbAccounts1, err := s.m.settings.GetAccounts() + dbAccounts1, err := s.m.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(len(profileKp.Accounts)+len(seedPhraseKp.Accounts)+len(privKeyKp.Accounts)+len(woAccounts), len(dbAccounts1)) @@ -206,12 +206,12 @@ func (s *MessengerSyncWalletSuite) TestSyncWallets() { s.Require().NoError(err) s.Require().True(accounts.SameKeypairsWithDifferentSyncedFrom(privKeyKp, dbPrivKeyKp2, true, "", accounts.AccountNonOperable)) - dbWoAccounts2, err := alicesOtherDevice.settings.GetWatchOnlyAccounts() + dbWoAccounts2, err := alicesOtherDevice.settings.GetWatchOnlyAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbWoAccounts2)) s.Require().True(haveSameElements(woAccounts, dbWoAccounts2, accounts.SameAccounts)) - dbAccounts2, err := alicesOtherDevice.settings.GetAccounts() + dbAccounts2, err := alicesOtherDevice.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(len(profileKp.Accounts)+len(seedPhraseKp.Accounts)+len(privKeyKp.Accounts)+len(woAccounts), len(dbAccounts2)) @@ -297,7 +297,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountsReorder() { err = s.m.settings.SaveOrUpdateAccounts(woAccounts, false) s.Require().NoError(err, "wo accounts alice.settings.SaveOrUpdateKeypair") - dbAccounts, err := s.m.settings.GetAccounts() + dbAccounts, err := s.m.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbAccounts)-1) @@ -310,7 +310,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountsReorder() { err = alicesOtherDevice.settings.SaveOrUpdateAccounts(woAccounts, false) s.Require().NoError(err, "wo accounts alice.settings.SaveOrUpdateKeypair") - dbAccounts, err = alicesOtherDevice.settings.GetAccounts() + dbAccounts, err = alicesOtherDevice.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbAccounts)-1) @@ -358,7 +358,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountsReorder() { {Address: types.Address{0x16}, Type: accounts.AccountTypeWatch, Position: 5}, } - dbAccounts, err = s.m.settings.GetAccounts() + dbAccounts, err = s.m.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbAccounts)-1) for i := 0; i < len(woAccounts); i++ { @@ -380,7 +380,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountsReorder() { s.Require().NoError(err) // check on alice's other device - dbAccounts, err = alicesOtherDevice.settings.GetAccounts() + dbAccounts, err = alicesOtherDevice.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbAccounts)-1) for i := 0; i < len(woAccounts); i++ { @@ -408,7 +408,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountsReorder() { {Address: types.Address{0x12}, Type: accounts.AccountTypeWatch, Position: 5}, } - dbAccounts, err = s.m.settings.GetAccounts() + dbAccounts, err = s.m.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbAccounts)-1) for i := 0; i < len(woAccounts); i++ { @@ -430,7 +430,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountsReorder() { s.Require().NoError(err) // check on alice's other device - dbAccounts, err = alicesOtherDevice.settings.GetAccounts() + dbAccounts, err = alicesOtherDevice.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(len(woAccounts), len(dbAccounts)-1) for i := 0; i < len(woAccounts); i++ { @@ -491,7 +491,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountOrderAfterDeletion() { err = s.m.settings.SaveOrUpdateAccounts(woAccounts, false) s.Require().NoError(err) // Check accounts - dbAccounts1, err := s.m.settings.GetAccounts() + dbAccounts1, err := s.m.settings.GetAccounts(false) s.Require().NoError(err) totalNumOfAccounts := len(profileKp.Accounts) + len(seedPhraseKp.Accounts) + len(privKeyKp.Accounts) + len(woAccounts) s.Require().Equal(totalNumOfAccounts, len(dbAccounts1)) @@ -553,7 +553,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountOrderAfterDeletion() { }) s.Require().NoError(err) - dbAccounts2, err := alicesOtherDevice.settings.GetAccounts() + dbAccounts2, err := alicesOtherDevice.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(totalNumOfAccounts, len(dbAccounts2)) @@ -579,11 +579,11 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountOrderAfterDeletion() { }) s.Require().NoError(err) - dbAccounts1, err = s.m.settings.GetAccounts() + dbAccounts1, err = s.m.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(totalNumOfAccounts, len(dbAccounts1)) - dbAccounts2, err = alicesOtherDevice.settings.GetAccounts() + dbAccounts2, err = alicesOtherDevice.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(totalNumOfAccounts, len(dbAccounts2)) @@ -609,11 +609,11 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountOrderAfterDeletion() { }) s.Require().NoError(err) - dbAccounts1, err = s.m.settings.GetAccounts() + dbAccounts1, err = s.m.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(totalNumOfAccounts, len(dbAccounts1)) - dbAccounts2, err = alicesOtherDevice.settings.GetAccounts() + dbAccounts2, err = alicesOtherDevice.settings.GetAccounts(false) s.Require().NoError(err) s.Require().Equal(totalNumOfAccounts, len(dbAccounts2)) diff --git a/protocol/messenger_wallet.go b/protocol/messenger_wallet.go index 262685a5a..a4b8bba60 100644 --- a/protocol/messenger_wallet.go +++ b/protocol/messenger_wallet.go @@ -27,7 +27,7 @@ func (m *Messenger) retrieveWalletBalances() error { if m.walletAPI == nil { m.logger.Warn("wallet api not enabled") } - accounts, err := m.settings.GetAccounts() + accounts, err := m.settings.GetAccounts(false) if err != nil { return err } @@ -192,12 +192,7 @@ func (m *Messenger) deleteKeystoreFileForAddress(address types.Address) error { lastAcccountOfKeypairWithTheSameKey := len(kp.Accounts) == 1 - knownKeycardsForKeyUID, err := m.settings.GetKeycardsWithSameKeyUID(acc.KeyUID) - if err != nil { - return err - } - - if len(knownKeycardsForKeyUID) == 0 { + if len(kp.Keycards) == 0 { err = m.accountsManager.DeleteAccount(address) var e *account.ErrCannotLocateKeyFile if err != nil && !errors.As(err, &e) { @@ -220,19 +215,27 @@ func (m *Messenger) deleteKeystoreFileForAddress(address types.Address) error { } func (m *Messenger) DeleteAccount(address types.Address) error { - err := m.deleteKeystoreFileForAddress(address) + acc, err := m.settings.GetAccountByAddress(address) if err != nil { return err } - acc, err := m.settings.GetAccountByAddress(address) + if acc.Chat { + return accounts.ErrCannotRemoveProfileAccount + } + + if acc.Wallet { + return accounts.ErrCannotRemoveDefaultWalletAccount + } + + err = m.deleteKeystoreFileForAddress(address) if err != nil { return err } clock, _ := m.getLastClockWithRelatedChat() - err = m.settings.DeleteAccount(address, clock) + err = m.settings.RemoveAccount(address, clock) if err != nil { return err } @@ -253,6 +256,46 @@ func (m *Messenger) DeleteAccount(address types.Address) error { return m.syncAccountsPositions(m.dispatchMessage) } +func (m *Messenger) DeleteKeypair(keyUID string) error { + kp, err := m.settings.GetKeypairByKeyUID(keyUID) + if err != nil { + return err + } + + if kp.Type == accounts.KeypairTypeProfile { + return accounts.ErrCannotRemoveProfileKeypair + } + + for _, acc := range kp.Accounts { + err = m.deleteKeystoreFileForAddress(acc.Address) + if err != nil { + return err + } + } + + clock, _ := m.getLastClockWithRelatedChat() + + err = m.settings.RemoveKeypair(keyUID, clock) + if err != nil { + return err + } + + err = m.resolveAndSyncKeypairOrJustWalletAccount(kp.KeyUID, types.Address{}, clock, m.dispatchMessage) + if err != nil { + return err + } + + // In case when user deletes entire keypair, we need to send sync message after a keypair gets deleted, + // and then (after that) update the positions of other accoutns. That's needed to handle properly + // accounts order on the paired devices. + err = m.settings.ResolveAccountsPositions(clock) + if err != nil { + return err + } + // Since some keypairs may be received out of expected order, we're aligning that by sending accounts position sync msg. + return m.syncAccountsPositions(m.dispatchMessage) +} + func (m *Messenger) prepareSyncAccountMessage(acc *accounts.Account) *protobuf.SyncAccount { return &protobuf.SyncAccount{ Clock: acc.Clock, @@ -332,7 +375,7 @@ func (m *Messenger) syncAccountsPositions(rawMessageHandler RawMessageHandler) e _, chat := m.getLastClockWithRelatedChat() - allDbAccounts, err := m.settings.GetAccounts() + allDbAccounts, err := m.settings.GetAccounts(false) if err != nil { return err } @@ -436,36 +479,45 @@ func (m *Messenger) resolveAndSyncKeypairOrJustWalletAccount(keyUID string, addr } if keyUID == "" { - dbAccount, err := m.settings.GetAccountByAddress(address) - if err != nil && err != accounts.ErrDbAccountNotFound { + var dbAccount *accounts.Account + allDbAccounts, err := m.settings.GetAccounts(true) // removed accounts included + if err != nil { return err } - if dbAccount == nil { - dbAccount = &accounts.Account{ - Address: address, - Clock: clock, - Removed: true, + + for _, acc := range allDbAccounts { + if acc.Address == address { + dbAccount = acc + break } } + + if dbAccount == nil { + return accounts.ErrDbAccountNotFound + } + err = m.syncWalletAccount(dbAccount, rawMessageHandler) if err != nil { return err } } else { - dbKeypair, err := m.settings.GetKeypairByKeyUID(keyUID) - if err != nil && err != accounts.ErrDbKeypairNotFound { + var dbKeypair *accounts.Keypair + allDbKeypairs, err := m.settings.GetKeypairs(true) // removed keypairs included + if err != nil { return err } - if dbKeypair == nil { - // In case entire keypair was removed (happens if user removes the last account for a keypair). - dbKeypair = &accounts.Keypair{ - KeyUID: keyUID, - Clock: clock, - Removed: true, + for _, kp := range allDbKeypairs { + if kp.KeyUID == keyUID { + dbKeypair = kp + break } } + if dbKeypair == nil { + return accounts.ErrDbKeypairNotFound + } + err = m.syncKeypair(dbKeypair, rawMessageHandler) if err != nil { return err diff --git a/services/accounts/accounts.go b/services/accounts/accounts.go index 8dadbc608..c6c832b46 100644 --- a/services/accounts/accounts.go +++ b/services/accounts/accounts.go @@ -81,15 +81,15 @@ func (api *API) MoveWalletAccount(ctx context.Context, fromPosition int64, toPos } func (api *API) GetAccounts(ctx context.Context) ([]*accounts.Account, error) { - return api.db.GetAccounts() + return api.db.GetAccounts(false) } func (api *API) GetWatchOnlyAccounts(ctx context.Context) ([]*accounts.Account, error) { - return api.db.GetWatchOnlyAccounts() + return api.db.GetWatchOnlyAccounts(false) } func (api *API) GetKeypairs(ctx context.Context) ([]*accounts.Keypair, error) { - return api.db.GetKeypairs() + return api.db.GetKeypairs(false) } func (api *API) GetAccountByAddress(ctx context.Context, address types.Address) (*accounts.Account, error) { @@ -114,6 +114,33 @@ func (api *API) DeleteAccount(ctx context.Context, address types.Address) error return nil } +func (api *API) DeleteKeypair(ctx context.Context, keyUID string) error { + keypair, err := api.db.GetKeypairByKeyUID(keyUID) + if err != nil { + return err + } + + err = (*api.messenger).DeleteKeypair(keyUID) + if err != nil { + return err + } + + var addresses []common.Address + for _, acc := range keypair.Accounts { + if acc.Chat { + continue + } + addresses = append(addresses, common.Address(acc.Address)) + } + + api.feed.Send(accountsevent.Event{ + Type: accountsevent.EventTypeRemoved, + Accounts: addresses, + }) + + return nil +} + func (api *API) AddKeypair(ctx context.Context, password string, keypair *accounts.Keypair) error { if len(keypair.KeyUID) == 0 { return errors.New("`KeyUID` field of a keypair must be set") diff --git a/services/ext/service.go b/services/ext/service.go index 6563cebe9..d538a8e72 100644 --- a/services/ext/service.go +++ b/services/ext/service.go @@ -322,7 +322,7 @@ func (s *Service) verifyTransactionLoop(tick time.Duration, cancel <-chan struct for { select { case <-ticker.C: - accounts, err := s.accountsDB.GetAccounts() + accounts, err := s.accountsDB.GetAccounts(false) if err != nil { log.Error("failed to retrieve accounts", "err", err) } diff --git a/services/stickers/api.go b/services/stickers/api.go index 47e88d68f..fcfca111b 100644 --- a/services/stickers/api.go +++ b/services/stickers/api.go @@ -105,7 +105,7 @@ func NewAPI(ctx context.Context, acc *accounts.Database, rpcClient *rpc.Client, func (api *API) Market(chainID uint64) ([]StickerPack, error) { // TODO: eventually this should be changed to include pagination - accs, err := api.accountsDB.GetAccounts() + accs, err := api.accountsDB.GetAccounts(false) if err != nil { return nil, err } diff --git a/services/stickers/pending.go b/services/stickers/pending.go index 7c60eeb0c..6e02e827e 100644 --- a/services/stickers/pending.go +++ b/services/stickers/pending.go @@ -80,7 +80,7 @@ func (api *API) ProcessPending(chainID uint64) (pendingChanged StickerPackCollec return nil, err } - accs, err := api.accountsDB.GetAccounts() + accs, err := api.accountsDB.GetAccounts(false) if err != nil { return nil, err } diff --git a/services/wallet/api.go b/services/wallet/api.go index 9c6db3d86..b3030d0cc 100644 --- a/services/wallet/api.go +++ b/services/wallet/api.go @@ -433,7 +433,7 @@ func (api *API) GetDerivedAddressesForMnemonic(ctx context.Context, mnemonic str // Generates addresses for the provided paths, response doesn't include `HasActivity` value (if you need it check `GetAddressDetails` function) func (api *API) getDerivedAddresses(id string, paths []string) ([]*DerivedAddress, error) { - addedAccounts, err := api.s.accountsDB.GetAccounts() + addedAccounts, err := api.s.accountsDB.GetAccounts(false) if err != nil { return nil, err }