fix_:Missing "Backup Recovery Phrase" option in profile (#5305)

This commit is contained in:
frank 2024-06-07 07:34:08 +08:00 committed by GitHub
parent f6a5f1d740
commit 33ccf784c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 8 deletions

View File

@ -1073,7 +1073,7 @@ func TestConvertAccount(t *testing.T) {
found = keystoreContainsFileForAccount(keyStoreDir, chatAddress) found = keystoreContainsFileForAccount(keyStoreDir, chatAddress)
require.True(t, found) require.True(t, found)
defaultSettings, err := defaultSettings(genAccInfo, derivedAccounts, nil) defaultSettings, err := defaultSettings(genAccInfo, derivedAccounts)
require.NoError(t, err) require.NoError(t, err)
nodeConfig, err := defaultNodeConfig(defaultSettings.InstallationID, &requests.CreateAccount{ nodeConfig, err := defaultNodeConfig(defaultSettings.InstallationID, &requests.CreateAccount{
LogLevel: defaultSettings.LogLevel, LogLevel: defaultSettings.LogLevel,
@ -1418,7 +1418,9 @@ func TestCreateWallet(t *testing.T) {
walletRootAddress, err := db.GetWalletRootAddress() walletRootAddress, err := db.GetWalletRootAddress()
require.NoError(t, err) require.NoError(t, err)
mnemonic, err := db.Mnemonic()
require.NoError(t, err) require.NoError(t, err)
require.NotEmpty(t, mnemonic)
derivedAddress, err := walletAPI.GetDerivedAddresses(context.Background(), password, walletRootAddress.String(), paths) derivedAddress, err := walletAPI.GetDerivedAddresses(context.Background(), password, walletRootAddress.String(), paths)
require.NoError(t, err) require.NoError(t, err)
@ -1649,6 +1651,12 @@ func TestRestoreAccountAndLogin(t *testing.T) {
invalidRequest := &requests.RestoreAccount{} invalidRequest := &requests.RestoreAccount{}
_, err = backend.RestoreAccountAndLogin(invalidRequest) _, err = backend.RestoreAccountAndLogin(invalidRequest)
require.Error(t, err) require.Error(t, err)
db, err := accounts.NewDB(backend.appDB)
require.NoError(t, err)
mnemonic, err := db.Mnemonic()
require.NoError(t, err)
require.Empty(t, mnemonic)
} }
func TestCreateAccountPathsValidation(t *testing.T) { func TestCreateAccountPathsValidation(t *testing.T) {

View File

@ -45,11 +45,10 @@ var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWa
var DefaultFleet = params.FleetShardsTest var DefaultFleet = params.FleetShardsTest
func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) { func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo) (*settings.Settings, error) {
chatKeyString := derivedAddresses[pathDefaultChat].PublicKey chatKeyString := derivedAddresses[pathDefaultChat].PublicKey
s := &settings.Settings{} s := &settings.Settings{}
s.Mnemonic = &generatedAccountInfo.Mnemonic
s.BackupEnabled = true s.BackupEnabled = true
logLevel := "INFO" logLevel := "INFO"
s.LogLevel = &logLevel s.LogLevel = &logLevel
@ -70,7 +69,6 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
s.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address) s.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address)
s.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address) s.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address)
s.Mnemonic = mnemonic
signingPhrase, err := buildSigningPhrase() signingPhrase, err := buildSigningPhrase()
if err != nil { if err != nil {

View File

@ -1338,7 +1338,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
return nil, nil, nil, nil, err return nil, nil, nil, nil, err
} }
settings, err := b.prepareSettings(*info, derivedAddresses, request) settings, err := b.prepareSettings(*info, derivedAddresses, request, mnemonic)
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, nil, err
} }
@ -1445,8 +1445,8 @@ func (b *GethStatusBackend) generateAccount(info generator.GeneratedAccountInfo,
return &account, &info, nil return &account, &info, nil
} }
func (b *GethStatusBackend) prepareSettings(info generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, request *requests.CreateAccount) (*settings.Settings, error) { func (b *GethStatusBackend) prepareSettings(info generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, request *requests.CreateAccount, mnemonic string) (*settings.Settings, error) {
settings, err := defaultSettings(info, derivedAddresses, nil) settings, err := defaultSettings(info, derivedAddresses)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1458,7 +1458,7 @@ func (b *GethStatusBackend) prepareSettings(info generator.GeneratedAccountInfo,
settings.TestNetworksEnabled = request.TestNetworksEnabled settings.TestNetworksEnabled = request.TestNetworksEnabled
// If restoring an account, we don't set the mnemonic // If restoring an account, we don't set the mnemonic
if info.Mnemonic == "" { if mnemonic == "" {
settings.Mnemonic = &info.Mnemonic settings.Mnemonic = &info.Mnemonic
settings.OmitTransfersHistoryScan = true settings.OmitTransfersHistoryScan = true
// TODO(rasom): uncomment it as soon as address will be properly // TODO(rasom): uncomment it as soon as address will be properly