Skip to content

Commit

Permalink
🐛 fix(ValidationHelper.cs): format minimum and maximum amount to 8 de…
Browse files Browse the repository at this point in the history
…cimal places (#212)

🐛 fix(ChannelRequests.razor, Channels.razor, Wallets.razor, Withdrawals.razor): format BTC amounts to 8 decimal places
  • Loading branch information
markettes authored Jun 26, 2023
1 parent da38979 commit d442601
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Helpers/ValidationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ public static void ValidateWithdrawalAmount(ValidatorEventArgs obj, Boolean isAm
if (amount < minimum && !isAmountDisabled)
{
obj.Status = ValidationStatus.Error;
obj.ErrorText = $"Error, the minimum amount to withdraw is at least {minimum} BTC";
obj.ErrorText = $"Error, the minimum amount to withdraw is at least {minimum:f8} BTC";
}

if (amount > maximum && !isAmountDisabled)
{
obj.Status = ValidationStatus.Error;
obj.ErrorText = $"Error, the maximum amount to withdraw is {maximum} BTC";
obj.ErrorText = $"Error, the maximum amount to withdraw is {maximum:f8} BTC";
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Pages/ChannelRequests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<DataGridColumn TItem="ChannelOperationRequest" Field="@nameof(ChannelOperationRequest.Amount)" Caption="Capacity" Sortable="false" Displayable="true" PopupFieldColumnSize="ColumnSize.Is12" Editable="true">
<DisplayTemplate>
@{
@($"{context.Amount} BTC")
@($"{context.Amount:f8} BTC")
@($" ({Math.Round(PriceConversionHelper.BtcToUsdConversion(context.Amount, _btcPrice), 2)} USD)")
}
</DisplayTemplate>
Expand Down Expand Up @@ -265,7 +265,7 @@
<DataGridColumn TItem="ChannelOperationRequest" Field="@nameof(ChannelOperationRequest.Amount)" Caption="Capacity" Sortable="false" Displayable="true">
<DisplayTemplate>
@{
@($"{context.Amount} BTC")
@($"{context.Amount:f8} BTC")
@($" ({Math.Round(PriceConversionHelper.BtcToUsdConversion(context.Amount, _btcPrice), 2)} USD)")
}
</DisplayTemplate>
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Channels.razor
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<DisplayTemplate>
@{
var btcAmount = new Money(context.SatsAmount, MoneyUnit.Satoshi).ToUnit(MoneyUnit.BTC);
@($"{btcAmount} BTC")
@($"{btcAmount:f8} BTC")
@($" ({Math.Round(PriceConversionHelper.BtcToUsdConversion(btcAmount, _btcPrice), 2)} USD)")
}
</DisplayTemplate>
Expand Down Expand Up @@ -185,7 +185,7 @@
<DataGridColumn TItem="ChannelOperationRequest" Field="@nameof(ChannelOperationRequest.Amount)" Caption="Value" Sortable="false" Displayable="true">
<DisplayTemplate>
@{
@($"{context.Amount} BTC")
@($"{context.Amount:f8} BTC")
@($" ({Math.Round(PriceConversionHelper.BtcToUsdConversion(context.Amount, _btcPrice), 2)} USD)")
}
</DisplayTemplate>
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Wallets.razor
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@
if (balance != null)
{
_textModalTitle = $"Wallet: {wallet.Name} On-chain Balance";
_textModalContent = $"Confirmed: {((Money) balance.Confirmed).ToUnit(MoneyUnit.BTC)} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(((Money) balance.Confirmed).ToUnit(MoneyUnit.BTC), _btcPrice), 2)} USD) - " +
$"Unconfirmed: {((Money) balance.Unconfirmed).ToUnit(MoneyUnit.BTC)} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(((Money) balance.Unconfirmed).ToUnit(MoneyUnit.BTC), _btcPrice), 2)} USD)";
_textModalContent = $"Confirmed: {((Money) balance.Confirmed).ToUnit(MoneyUnit.BTC):f8} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(((Money) balance.Confirmed).ToUnit(MoneyUnit.BTC), _btcPrice), 2)} USD) - " +
$"Unconfirmed: {((Money) balance.Unconfirmed).ToUnit(MoneyUnit.BTC):f8} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(((Money) balance.Unconfirmed).ToUnit(MoneyUnit.BTC), _btcPrice), 2)} USD)";
_textModalCopy = false;

await _textModalRef.Show();
Expand Down
8 changes: 4 additions & 4 deletions src/Pages/Withdrawals.razor
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@
<EditTemplate>
@if (_selectedRequestWalletBalance != null)
{
<p>@($"{_selectedRequestWalletBalance} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion((decimal)_selectedRequestWalletBalance, _btcPrice), 2)} USD)")</p>
<p>@($"{_selectedRequestWalletBalance:f8} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion((decimal)_selectedRequestWalletBalance, _btcPrice), 2)} USD)")</p>
}
</EditTemplate>
</DataGridColumn>

<DataGridColumn TItem="WalletWithdrawalRequest" PopupFieldColumnSize="ColumnSize.Is12" Editable="true" Displayable="true" Field="@nameof(WalletWithdrawalRequest.Amount)" Caption="Amount (BTC)" Sortable="false" >
<DisplayTemplate>
@{
@($"{context.Amount} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(context.Amount, _btcPrice), 2)} USD)")
@($"{context.Amount:f8} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(context.Amount, _btcPrice), 2)} USD)")
}
</DisplayTemplate>
<EditTemplate>
Expand Down Expand Up @@ -297,7 +297,7 @@
<DataGridColumn TItem="WalletWithdrawalRequest" Editable="true" Field="@nameof(WalletWithdrawalRequest.Amount)" Caption="Amount (BTC)" Sortable="false" Displayable="true">
<DisplayTemplate>
@{
@($"{context.Amount} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(context.Amount, _btcPrice), 2)} USD)")
@($"{context.Amount:f8} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(context.Amount, _btcPrice), 2)} USD)")
}
</DisplayTemplate>

Expand Down Expand Up @@ -534,7 +534,7 @@
if (arg.Item.Amount > balance.Item1)
{
ToastService.ShowError(
$"The confirmed balance({balance.Item1} BTC) for the selected wallet is less than the amount requested to withdraw ({arg.Item.Amount})");
$"The confirmed balance({balance.Item1:f8} BTC) for the selected wallet is less than the amount requested to withdraw ({arg.Item.Amount:f8} BTC)");
await GetData();
return true;
}
Expand Down

0 comments on commit d442601

Please sign in to comment.