async void DeleteCurrentSprd() { try { Logging.Logger.LogInformation("Clicked button: DeleteCurrentSprd"); if (!CanExecuteDeleteSprd) { var warnMessage = string.Format( "Your wallet has no commitments in the SPRD database therefore cannot delete it. {0}If the problem persists contact [email protected]", Environment.NewLine); Logging.Logger.LogWarning(warnMessage); var msgBox = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow("SPRD: Missing data", warnMessage, ButtonEnum.Ok, Icon.Error); var msgBoxResult = msgBox.ShowDialog(_desktopMainWindow); return; } var sprdInfo = new SprdPoolInfo() { commited_ada = SprdSelection.Wallet.CurrentSprdPool.commited_ada, commiter_email = SprdSelection.Wallet.CurrentSprdPool.commiter_email, pool_id = SprdSelection.Wallet.CurrentSprdPool.pool_id, wallet_id = SprdSelection.Wallet.CurrentSprdPool.wallet_id, _id = SprdSelection.Wallet.CurrentSprdPool._id }; var response = await _sprdServer.DeletePoolInfoAsync(sprdInfo); var msgBoxSuccess = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow("SPRD: Sucessfully deleted spread", string.Format( "Deleted succesfully your SPRD for the pool {0}{1}We hope you will support another pool with your ADA!", sprdInfo.pool_id, Environment.NewLine), ButtonEnum.Ok, Icon.Info); var msgBoxResultSuccess = await msgBoxSuccess.ShowDialog(_desktopMainWindow); SprdSelection.Wallet.CurrentSprdPool = null; var toRemove = _lastComittedAdaPools.FirstOrDefault(p => p.timestamp == sprdInfo.timestamp && p.pool_id == SprdSelection.Pool.Name && p.commited_ada == sprdInfo.commited_ada); if (toRemove != null) { _lastComittedAdaPools.Remove(toRemove); OnPropertyChanged("LastComittedAdaPools"); } } catch (Exception e) { var msgBox = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow("SPRD: Unexpected error", string.Format( "While sending your deletion of SPRD to the server following error occurred: {0}{1}If the problem persists contact [email protected]", e.Message, Environment.NewLine), ButtonEnum.Ok, Icon.Error); var msgBoxResult = await msgBox.ShowDialog(_desktopMainWindow); Logging.Logger.LogCritical(e.Message); } }
async void SpreadAda() { try { Logging.Logger.LogInformation("Clicked button: SpreadAda"); if (!CanExecuteSprd) { var warnMessage = string.Format( "Data is missing:{0}Select a pool, wallet and insert a valid email address. Also, wait for a updated Stake Pool list and then try again.{1}If the problem persists contact [email protected]", Environment.NewLine, Environment.NewLine); Logging.Logger.LogWarning(warnMessage); var msgBox = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow("SPRD: Missing data", warnMessage, ButtonEnum.Ok, Icon.Error); var msgBoxResult = msgBox.ShowDialog(_desktopMainWindow); return; } var sprdInfo = new SprdPoolInfo() { commited_ada = SprdSelection.Wallet.BalanceAda, commiter_email = SprdSelection.NotifyEmail, pool_id = SprdSelection.Pool.Base.Id, wallet_id = SprdSelection.Wallet.Base.Id, timestamp = DateTime.Now, email_send = false }; var response = await _sprdServer.AddNewPoolInfoAsync(sprdInfo); var msgBoxSuccess = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow("SPRD: Sucessful spread", string.Format( "Thanks for supporting the pool {0}{1}You will get notified when enough other delegators SPRD there ADA to this pool in order to be ready to mint a block!", SprdSelection.Pool.Name, Environment.NewLine), ButtonEnum.Ok, Icon.Info); var msgBoxResultSuccess = await msgBoxSuccess.ShowDialog(_desktopMainWindow); sprdInfo.wallet_id = SprdSelection.Wallet.Name; sprdInfo.pool_id = SprdSelection.Pool.Name; SprdSelection.Wallet.CurrentSprdPool = sprdInfo; _lastComittedAdaPools.Add(sprdInfo); OnPropertyChanged("LastComittedAdaPools"); } catch (Exception e) { var msgBox = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow("SPRD: Unexpected error", string.Format( "While sending your SPRD to the server following error occurred: {0}{1}If the problem persists contact [email protected]", e.Message, Environment.NewLine), ButtonEnum.Ok, Icon.Error); var msgBoxResult = await msgBox.ShowDialog(_desktopMainWindow); Logging.Logger.LogCritical(e.Message); } }