simplfy things
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
@@ -48,7 +48,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
async () =>
{
var (accountKeyPathIn, minGapLimitIn) = await AdvancedOptionsInteraction
- .Handle((AccountKeyPath!, (int) MinGapLimit!)).ToTask();
+ .Handle((AccountKeyPath!, MinGapLimit)).ToTask();
if (accountKeyPathIn is { })
{
@@ -57,20 +57,14 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
if (minGapLimitIn is { })
{
- MinGapLimit = minGapLimitIn;
+ MinGapLimit = (int)minGapLimitIn;
}
});
- FinishCommandCanExecute = this.WhenAnyValue(
- x => x.CurrentMnemonics,
- x => x.AccountKeyPath,
- x => x.MinGapLimit,
- (_, __, ___) =>
- AccountKeyPath is { } &&
- MinGapLimit is { } &&
- CurrentMnemonics is { } &&
- (CurrentMnemonics?.IsValidChecksum ?? false) &&
- !Validations.Any);
+ FinishCommandCanExecute =
+ this.WhenAnyValue(x => x.CurrentMnemonics)
+ .Select(currentMnemonics =>
+ currentMnemonics is { } && currentMnemonics.IsValidChecksum && !Validations.Any);
NextCommand = ReactiveCommand.CreateFromTask(
async () =>
@@ -88,11 +82,11 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
password,
walletFilePath,
AccountKeyPath!,
- (int) MinGapLimit!);
+ MinGapLimit);
keyManager.SetNetwork(network);
walletManager.AddWallet(keyManager);
- navigationState.DialogScreen?.Invoke().Router.NavigationStack.Clear();
+ navigationState.DialogScreen.Invoke().Router.NavigationStack.Clear();
}
catch (Exception ex)
{
@@ -121,9 +115,9 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
public ICommand NextCommand { get; }
- private KeyPath? AccountKeyPath { get; set; } = KeyPath.Parse("m/84'/0'/0'");
+ private KeyPath AccountKeyPath { get; set; } = KeyPath.Parse("m/84'/0'/0'");
- private int? MinGapLimit { get; set; } = 63;
+ private int MinGapLimit { get; set; } = 63;
private Interaction<(KeyPath, int), (KeyPath?, int?)> AdvancedOptionsInteraction { get; }

MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/AdvancedRecoveryOptionsViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/AdvancedRecoveryOptionsViewModel.cs
@@ -10,8 +10,8 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
{
public class AdvancedRecoveryOptionsViewModel : DialogViewModelBase<(KeyPath? accountKeyPath, int? minGapLimit)>
{
- private string? _accountKeyPath;
- private string? _minGapLimit;
+ private string _accountKeyPath;
+ private string _minGapLimit;
public AdvancedRecoveryOptionsViewModel((KeyPath keyPath, int minGapLimit) interactionInput)
{
@@ -31,23 +31,23 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
})
.ObserveOn(RxApp.MainThreadScheduler);
- AccountKeyPath = interactionInput.keyPath.ToString();
- MinGapLimit = interactionInput.minGapLimit.ToString();
+ _accountKeyPath = interactionInput.keyPath.ToString();
+ _minGapLimit = interactionInput.minGapLimit.ToString();
ContinueCommand = ReactiveCommand.Create(
- () => Close((GetAccountKeyPath(), GetMinGapLimit())),
+ () => Close((KeyPath.Parse(AccountKeyPath), int.Parse(MinGapLimit))),
continueCommandCanExecute);
CancelCommand = ReactiveCommand.Create(() => Close());
}
- public string? AccountKeyPath
+ public string AccountKeyPath
{
get => _accountKeyPath;
set => this.RaiseAndSetIfChanged(ref _accountKeyPath, value);
}
- public string? MinGapLimit
+ public string MinGapLimit
{
get => _minGapLimit;
set => this.RaiseAndSetIfChanged(ref _minGapLimit, value);
@@ -57,43 +57,8 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
public ICommand CancelCommand { get; }
- private int? GetMinGapLimit()
- {
- if (int.TryParse(MinGapLimit, out var minGapLimit) && minGapLimit > KeyManager.AbsoluteMinGapLimit &&
- minGapLimit < KeyManager.MaxGapLimit)
- {
- return minGapLimit;
- }
-
- return null;
- }
-
- private KeyPath? GetAccountKeyPath()
- {
- if (AccountKeyPath is null || !KeyPath.TryParse(AccountKeyPath, out var keyPath) ||
- keyPath is null)
- {
- return null;
- }
-
- var accountKeyPath = keyPath.GetAccountKeyPath();
-
- if (keyPath.Length != accountKeyPath.Length ||
- accountKeyPath.Length != KeyManager.DefaultAccountKeyPath.Length)
- {
- return null;
- }
-
- return keyPath;
- }
-
private void ValidateMinGapLimit(IValidationErrors errors)
{
- if (string.IsNullOrWhiteSpace(MinGapLimit))
- {
- return;
- }
-
if (!int.TryParse(MinGapLimit, out var minGapLimit) || minGapLimit < KeyManager.AbsoluteMinGapLimit ||
minGapLimit > KeyManager.MaxGapLimit)
{
@@ -105,11 +70,6 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
private void ValidateAccountKeyPath(IValidationErrors errors)
{
- if (string.IsNullOrWhiteSpace(AccountKeyPath))
- {
- return;
- }
-
if (KeyPath.TryParse(AccountKeyPath, out var keyPath) && keyPath is { })
{
var accountKeyPath = keyPath.GetAccountKeyPath();

simplfy things