private async Task OnNext(WalletManager walletManager, HwiEnumerateEntry device) { try { var walletFilePath = WalletManager.WalletDirectories.GetWalletFilePaths(WalletName).walletFilePath; var km = await HardwareWalletOperationHelpers.GenerateWalletAsync(device, walletFilePath, WalletManager.Network, CancelCts.Token); km.SetIcon(Type); Navigate().To(new AddedWalletPageViewModel(walletManager, km)); } catch (Exception ex) { Logger.LogError(ex); await ShowErrorAsync(Title, ex.ToUserFriendlyString(), "Error occured during adding your wallet."); Navigate().Back(); } }
public DetectedHardwareWalletViewModel(WalletManager walletManager, string walletName, HwiEnumerateEntry device) { Title = "Hardware Wallet"; WalletManager = walletManager; WalletName = walletName; CancelCts = new CancellationTokenSource(); Type = device.Model switch { HardwareWalletModels.Coldcard or HardwareWalletModels.Coldcard_Simulator => WalletType.Coldcard, HardwareWalletModels.Ledger_Nano_S => WalletType.Ledger, HardwareWalletModels.Trezor_1 or HardwareWalletModels.Trezor_1_Simulator or HardwareWalletModels.Trezor_T or HardwareWalletModels.Trezor_T_Simulator => WalletType.Trezor, _ => WalletType.Hardware }; TypeName = device.Model.FriendlyName(); NextCommand = ReactiveCommand.CreateFromTask(async() => { try { var walletFilePath = WalletManager.WalletDirectories.GetWalletFilePaths(WalletName).walletFilePath; var km = await HardwareWalletOperationHelpers.GenerateWalletAsync(device, walletFilePath, WalletManager.Network, CancelCts.Token); km.SetIcon(Type); Navigate().To(new AddedWalletPageViewModel(walletManager, km)); } catch (Exception ex) { Logger.LogError(ex); await ShowErrorAsync(ex.ToUserFriendlyString(), "Error occured during adding your wallet."); Navigate().Back(); } }); NoCommand = ReactiveCommand.Create(() => Navigate().Back()); EnableAutoBusyOn(NextCommand); }