fix warnings and consistent standards.
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/ConnectHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/ConnectHardwareWalletViewModel.cs
@@ -26,7 +26,8 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
IsBusy = true;
}
- NextCommand = ReactiveCommand.Create(() =>
+ NextCommand = ReactiveCommand.Create(
+ () =>
{
Navigate().To(new DetectHardwareWalletViewModel(_detectionState));
});
@@ -40,7 +41,8 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
if (!inStack && _trySkipPage)
{
- RxApp.MainThreadScheduler.Schedule(async () =>
+ RxApp.MainThreadScheduler.Schedule(
+ async () =>
{
await _detectionState.EnumerateHardwareWalletsAsync(CancellationToken.None);

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/DetectHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/DetectHardwareWalletViewModel.cs
@@ -32,15 +32,13 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
this.WhenAnyValue(x => x.SelectedHardwareWallet)
.ObserveOn(RxApp.MainThreadScheduler)
.Select(x => x?.HardwareWalletInfo.Fingerprint is { } && x.HardwareWalletInfo.IsInitialized())
- .Subscribe(async x=>
- {
- await ConnectSelectedHardwareWalletAsync();
- });
+ .Subscribe(async _ => await ConnectSelectedHardwareWalletAsync());
this.WhenAnyValue(x => x.SelectedHardwareWallet)
.ObserveOn(RxApp.MainThreadScheduler)
.Where(x => x is { } && !x.HardwareWalletInfo.IsInitialized() && x.HardwareWalletInfo.Model != HardwareWalletModels.Coldcard)
- .Subscribe(async x =>
+ .Subscribe(
+ async x =>
{
if (DisposeCts is null)
{
@@ -77,11 +75,12 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
StartDetection();
- disposable.Add(Disposable.Create(() =>
+ Disposable.Create(
+ () =>
{
DisposeCts.Cancel();
DisposeCts.Dispose();
- }));
+ }).DisposeWith(disposable);
}
private Task? DetectionTask { get; set; }
@@ -158,30 +157,34 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(3));
- var detectedHardwareWallets = (await _detectionState.Client.EnumerateAsync(timeoutCts.Token).ConfigureAwait(false)).Select(x => new HardwareWalletViewModel(x)).ToArray();
+ var detectedHardwareWallets =
+ (await _detectionState.Client.EnumerateAsync(timeoutCts.Token).ConfigureAwait(false))
+ .Select(x => new HardwareWalletViewModel(x)).ToArray();
detectionCts.Token.ThrowIfCancellationRequested();
// The wallets that already exist in the software.
- var alreadyExistingWalletsToRemove = detectedHardwareWallets.Where(wallet => _detectionState.WalletManager.GetWallets().Any(x => x.KeyManager.MasterFingerprint == wallet.HardwareWalletInfo.Fingerprint));
+ var alreadyExistingWalletsToRemove = detectedHardwareWallets.Where(
+ wallet => _detectionState.WalletManager.GetWallets().Any(
+ x => x.KeyManager.MasterFingerprint == wallet.HardwareWalletInfo.Fingerprint));
+
// The wallets that are not detectable since the last enumeration.
var disconnectedWalletsToRemove = HardwareWallets.Except(detectedHardwareWallets);
var toRemove = alreadyExistingWalletsToRemove.Union(disconnectedWalletsToRemove).ToArray();
var toAdd = detectedHardwareWallets.Except(toRemove).Except(HardwareWallets);
- await Observable.Start(() =>
+ await Observable.Start(
+ () =>
{
// Remove disconnected hardware wallets from the list
HardwareWallets.RemoveMany(toRemove);
+
// Add newly detected hardware wallets
HardwareWallets.AddRange(toAdd);
- if (SelectedHardwareWallet is null)
- {
- SelectedHardwareWallet = HardwareWallets.FirstOrDefault();
- }
- }, RxApp.MainThreadScheduler);
-
+ SelectedHardwareWallet ??= HardwareWallets.FirstOrDefault();
+ },
+ RxApp.MainThreadScheduler);
}
catch (Exception ex)
{

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/DetectedHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/DetectedHardwareWalletViewModel.cs
@@ -6,7 +6,6 @@ using WalletWasabi.Fluent.ViewModels.Navigation;
namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
-
public class DetectedHardwareWalletViewModel : RoutableViewModel
{
public DetectedHardwareWalletViewModel(HardwareDetectionState detectionState)
@@ -35,11 +34,13 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
Type = type;
TypeName = detectionState.SelectedDevice.Model.FriendlyName();
- NextCommand = ReactiveCommand.CreateFromTask(async () =>
+ NextCommand = ReactiveCommand.CreateFromTask(
+ async () =>
{
IsBusy = true;
- var newWallet = await Task.Run(async () =>
+ var newWallet = await Task.Run(
+ async () =>
{
return await detectionState.GenerateWalletAsync();
});
@@ -51,7 +52,8 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
IsBusy = false;
});
- NoCommand = ReactiveCommand.Create(() =>
+ NoCommand = ReactiveCommand.Create(
+ () =>
{
Navigate().To(new ConnectHardwareWalletViewModel(detectionState.WalletName, detectionState.Network, detectionState.WalletManager, false));
});

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareDetectionState.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareDetectionState.cs
@@ -38,14 +38,18 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
var selectedDevice = SelectedDevice;
- if(selectedDevice is null)
+ if (selectedDevice?.Fingerprint is null)
{
throw new Exception("Cannot be null.");
}
var fingerPrint = (HDFingerprint) selectedDevice.Fingerprint;
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(3));
- var extPubKey = await Client.GetXpubAsync(selectedDevice.Model, selectedDevice.Path, KeyManager.DefaultAccountKeyPath, cts.Token).ConfigureAwait(false);
+ var extPubKey = await Client.GetXpubAsync(
+ selectedDevice.Model,
+ selectedDevice.Path,
+ KeyManager.DefaultAccountKeyPath,
+ cts.Token).ConfigureAwait(false);
var path = WalletManager.WalletDirectories.GetWalletFilePaths(WalletName).walletFilePath;
return KeyManager.CreateNewHardwareWalletWatchOnly(fingerPrint, extPubKey, path);
@@ -54,7 +58,8 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
public async Task EnumerateHardwareWalletsAsync(CancellationToken token)
{
Devices = (await Client.EnumerateAsync(token).ConfigureAwait(false))
- .Where(wallet => WalletManager.GetWallets()
+ .Where(
+ wallet => WalletManager.GetWallets()
.Any(x => x.KeyManager.MasterFingerprint == wallet.Fingerprint) == false);
}
}

MODIFY
WalletWasabi.Fluent/Views/AddWallet/DetectedHardwareWalletView.axaml
WalletWasabi.Fluent/Views/AddWallet/DetectedHardwareWalletView.axaml
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
- xmlns:h="using:WalletWasabi.Fluent.Helpers"
+ xmlns:vm="using:WalletWasabi.Fluent.ViewModels.AddWallet"
xmlns:conv="using:WalletWasabi.Fluent.Converters"
- xmlns:svg="clr-namespace:Svg.Skia.Avalonia;assembly=Svg.Skia.Avalonia"
mc:Ignorable="d"
d:DesignWidth="600" d:DesignHeight="500"
+ x:DataType="vm:DetectedHardwareWalletViewModel"
+ x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.Views.AddWallet.DetectedHardwareWalletView">
-
-
-
<c:ContentArea Title="Hardware Wallet"
IsBusy="{Binding IsBusy}"
EnableCancel="False"
<Button Content="Yes" Classes="action" HorizontalAlignment="Right" IsDefault="True" Command="{Binding NextCommand}" />
</Panel>
<StackPanel VerticalAlignment="Center" Spacing="40">
- <Image Height="180" Source="{Binding Path='Type' Converter={x:Static conv:WalletTypeImageConverter.Instance}}" />
+ <Image Height="180" Source="{Binding Path='Type', Converter={x:Static conv:WalletTypeImageConverter.Instance}}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="{Binding TypeName}" HorizontalAlignment="Center" />
<TextBlock Text=" was detected. Is this correct?" />

fix warnings and consistent standards.