fix: removing exceptions for syncing/backing up accounts in case of mobile app

This commit is contained in:
Sale Djenic 2023-04-21 11:16:55 +02:00 committed by saledjenic
parent 5d7da45f07
commit e4f23752a9
2 changed files with 0 additions and 60 deletions

View File

@ -12,7 +12,6 @@ import (
"math/rand"
"os"
"reflect"
"runtime"
"strings"
"sync"
"time"
@ -78,8 +77,6 @@ const (
publicChat chatContext = "public-chat"
privateChat chatContext = "private-chat"
isMobileApp = runtime.GOOS == "android" || runtime.GOOS == "ios"
)
const messageResendMinDelay = 30
@ -2514,13 +2511,6 @@ func (m *Messenger) prepareSyncWalletAccountsMessage(accs []*accounts.Account, c
continue
}
// Once mobile app supports seed phrase and private key imported accounts we should remove the following `if` block
if isMobileApp {
if acc.Type != accounts.AccountTypeWatch &&
acc.Type != accounts.AccountTypeGenerated {
continue
}
}
var accountClock uint64
if acc.Clock == 0 {
accountClock = clock

View File

@ -2791,15 +2791,6 @@ func (m *Messenger) handleSyncWalletAccount(message *protobuf.SyncWalletAccount)
return nil, err
}
// Once mobile app supports seed phrase and private key imported accounts we should remove the following `if` block
if isMobileApp {
accType := accounts.AccountType(message.Type)
if accType != accounts.AccountTypeWatch &&
accType != accounts.AccountTypeGenerated {
return nil, ErrWalletAccountNotSupportedForMobileApp
}
}
if dbAccount != nil && message.Clock <= dbAccount.Clock {
return nil, ErrTryingToStoreOldWalletAccount
}
@ -2829,19 +2820,6 @@ func (m *Messenger) handleSyncWalletAccount(message *protobuf.SyncWalletAccount)
KeypairName: message.KeypairName,
LastUsedDerivationIndex: message.LastUsedDerivationIndex,
}
// Once mobile app supports seed phrase and private key imported accounts we should remove the following line, not entire if block
if !isMobileApp {
// For the desktop app we need to ignore accounts:
// - with empty `KeypairName` (except if an account is WatchOnly account) or
// - with empty `DerivedFrom` (except if an account is not private key imported account or watch only account)
// Otherwise keypair items will be broken.
if acc.Type != accounts.AccountTypeWatch {
if len(acc.KeypairName) == 0 || acc.Type != accounts.AccountTypeKey && len(acc.DerivedFrom) == 0 {
return nil, ErrSomeFieldsMissingForWalletAccount
}
}
}
}
err = m.settings.SaveAccounts([]*accounts.Account{acc})
@ -2869,36 +2847,8 @@ func (m *Messenger) HandleSyncWalletAccount(state *ReceivedMessageState, message
accs = append(accs, acc)
}
if len(accs) == 0 {
return nil
}
state.Response.Accounts = accs
if isMobileApp {
latestDerivedPath, err := m.settings.GetLatestDerivedPath()
if err != nil {
return err
}
newPath := latestDerivedPath + uint(len(accs))
err = m.settings.SaveSettingField(settings.LatestDerivedPath, newPath)
if err != nil {
return err
}
if state.Response.Settings == nil {
state.Response.Settings = []*settings.SyncSettingField{}
}
state.Response.Settings = append(
state.Response.Settings,
&settings.SyncSettingField{
SettingField: settings.LatestDerivedPath,
Value: newPath,
})
}
return nil
}