split default derivation in to defaultCreation and mostCommon

This commit is contained in:
Matthew Fosse 2024-04-26 16:05:03 -07:00
parent 7b49b2ad87
commit 34f7ed4eae
3 changed files with 21 additions and 6 deletions

View file

@ -377,8 +377,6 @@ class WalletRestorePage extends BasePage {
) as DerivationInfo?;
} else if (derivationsWithHistory == 1) {
dInfo = derivations[derivationWithHistoryIndex];
} else if (derivationsWithHistory == 0 && derivations.isNotEmpty) {
dInfo = derivations.first;
}
if (dInfo == null) {
@ -390,7 +388,7 @@ class WalletRestorePage extends BasePage {
// get the default derivation for this wallet type:
if (this.derivationInfo == null) {
this.derivationInfo = walletRestoreViewModel.getDefaultDerivation();
this.derivationInfo = walletRestoreViewModel.getMostCommonDerivation();
}
walletRestoreViewModel.state = InitialExecutionState();

View file

@ -59,7 +59,7 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
derivationInfo = options["derivationInfo"] as DerivationInfo?;
passphrase = options["passphrase"] as String?;
}
derivationInfo ??= getDefaultDerivation();
derivationInfo ??= getDefaultCreationDerivation();
switch (restoreWallet.restoreMode) {
case WalletRestoreMode.keys:

View file

@ -71,7 +71,7 @@ abstract class WalletCreationVMBase with Store {
dirPath: dirPath,
address: '',
showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven,
derivationInfo: credentials.derivationInfo ?? getDefaultDerivation(),
derivationInfo: credentials.derivationInfo ?? getDefaultCreationDerivation(),
);
credentials.walletInfo = walletInfo;
@ -89,7 +89,7 @@ abstract class WalletCreationVMBase with Store {
}
}
DerivationInfo? getDefaultDerivation() {
DerivationInfo? getDefaultCreationDerivation() {
switch (this.type) {
case WalletType.nano:
return DerivationInfo(
@ -106,6 +106,23 @@ abstract class WalletCreationVMBase with Store {
}
}
DerivationInfo? getMostCommonDerivation() {
switch (this.type) {
case WalletType.nano:
return DerivationInfo(
derivationType: DerivationType.nano,
);
case WalletType.bitcoin:
case WalletType.litecoin:
return DerivationInfo(
derivationType: DerivationType.electrum,
derivationPath: "m/84'/0'/0'/0",
);
default:
return null;
}
}
WalletCredentials getCredentials(dynamic options) => throw UnimplementedError();
Future<WalletBase> process(WalletCredentials credentials) => throw UnimplementedError();