Skip to content

Commit

Permalink
Allow to fetch up to 100 test coins (#231)
Browse files Browse the repository at this point in the history
* Allow to fetch up to 100 test coins

* move notification the message to the right place
  • Loading branch information
dangershony authored Dec 21, 2024
1 parent 5cfd53c commit e0ceac3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Angor/Client/Pages/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,15 @@ else
invested = investorProject.InvestedInProject();
myProjectExplorerLink = _NetworkConfiguration.GetExplorerUrl().Url + $"/transaction/{investorProject.TransactionId}";
projectStats.Loading = false;
SetProjectLinksAndRefreshBalance();
return;
}

project = SessionStorage.GetProjectById(ProjectId);
if (project != null)
{
await SetProjectLinksAndRefreshBalance();
projectStats.Loading = false;
SetProjectLinksAndRefreshBalance();
StateHasChanged();
return;
}
Expand Down
21 changes: 18 additions & 3 deletions src/Angor/Client/Pages/Wallet.razor
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ else
</div>

</div>
@if (network.NetworkType != NetworkType.Mainnet && (accountBalanceInfo.TotalUnconfirmedBalance <= 0) & (accountBalanceInfo.TotalBalance <= 0))
@if (CanGetTestCoins())
{
<div class="d-flex flex-wrap align-items-center">
<button class="btn btn-border ms-2" data-cy="get-test-coins" @onclick="GetTestCoins" disabled="@testCoinsSpinner">
Expand Down Expand Up @@ -1201,9 +1201,9 @@ else

private async Task GetTestCoins()
{
if (Money.Satoshis(accountBalanceInfo.TotalBalance + accountBalanceInfo.TotalUnconfirmedBalance).ToUnit(MoneyUnit.BTC) > 10)
if (!CanGetTestCoins())
{
notificationComponent.ShowNotificationMessage("you already have coins!");
notificationComponent.ShowNotificationMessage("you already have too much test coins!");
return;
}

Expand Down Expand Up @@ -1231,6 +1231,21 @@ else
}
}

private bool CanGetTestCoins()
{
if (network.NetworkType == NetworkType.Mainnet)
{
return false;
}

if (Money.Satoshis(accountBalanceInfo.TotalBalance + accountBalanceInfo.TotalUnconfirmedBalance).ToUnit(MoneyUnit.BTC) > 100)
{
return false;
}

return true;
}

void SetActiveTab(int tab)
{
activeTab = tab;
Expand Down

0 comments on commit e0ceac3

Please sign in to comment.