Skip to content

Commit

Permalink
Create send max button and fee types (#148)
Browse files Browse the repository at this point in the history
* Create send max button and fee types

* Fix some html

* add max button and fee to cold staking

* Add Max button

* Add icons to buttons & improve tables

* Add button icons

* Fix xds fees

* Show staking balance of hot accounts on staking UI

* Improve UI Home Dashboard

* Add network status to wallet page

* Update Calculation for Wallet Sync

* Revert xds min tx fee

* change text for connection direction

Co-authored-by: Hunter <thecryptohunter@protonmail.com>
  • Loading branch information
dangershony and thecrypt0hunter authored Jun 6, 2020
1 parent 81a7f68 commit 75fa06c
Show file tree
Hide file tree
Showing 15 changed files with 661 additions and 415 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@
<div class="card">
<div class="card-body">
<h4 class="card-title">Balances</h4>
<div class="table-responsive">
<div class="table-responsive small">
<table class="table table-border-bottom table-striped table-sm table-hover">
<thead class="thead">
<tr>
<th>Wallet</th>
<th>Account balance</th>
<th>Cold balance</th>
<th>Hot balance</th>
<th class="text-primary"><strong>WALLET</strong></th>
<th class="text-primary"><strong>MAIN BALANCE</strong></th>
<th class="text-primary"><strong>COLD BALANCE</strong></th>
<th class="text-primary"><strong>HOT BALANCE</strong></th>
<th class="text-primary text-center"><strong>DETAILS</strong></th>
</tr>
</thead>
<tbody>
Expand All @@ -85,25 +86,25 @@
var coldStakingWalletEnabled = ColdStakingManager.GetColdStakingAccount(this.WalletManager.GetWallet(walletName), true);
if (coldStakingWalletEnabled != null) {
<tr @onclick="() => { NavigateToColdStakeView(walletName); }" >
<td>@walletName</td>
<td class="align-middle">@walletName</td>
@foreach (var account in this.WalletManager.GetAccounts(walletName)) {

var accountBalance = this.WalletManager.GetBalances(walletName, account.Name).Single();

@if (@accountBalance.AmountUnconfirmed >0) {
<td>@accountBalance.AmountConfirmed (@accountBalance.AmountUnconfirmed )</td>
<td class="align-middle">@accountBalance.AmountConfirmed (@accountBalance.AmountUnconfirmed )</td>
} else {
<td>@accountBalance.AmountConfirmed</td>
<td class="align-middle">@accountBalance.AmountConfirmed</td>
}

var coldStakingAccount = ColdStakingManager.GetColdStakingAccount(this.WalletManager.GetWallet(walletName), true);

if (coldStakingAccount != null) {
var coldAccountBalance = ColdStakingManager.GetBalances(walletName, coldStakingAccount.Name).Single();
@if (@coldAccountBalance.AmountUnconfirmed >0) {
<td>@coldAccountBalance.AmountConfirmed (@coldAccountBalance.AmountUnconfirmed )</td>
<td class="align-middle">@coldAccountBalance.AmountConfirmed (@coldAccountBalance.AmountUnconfirmed )</td>
} else {
<td>@coldAccountBalance.AmountConfirmed</td>
<td class="align-middle">@coldAccountBalance.AmountConfirmed</td>
}
}

Expand All @@ -112,15 +113,18 @@
if (hotStakingAccount != null) {
var hotAccountBalance = ColdStakingManager.GetBalances(walletName, hotStakingAccount.Name).Single();
@if (@hotAccountBalance.AmountUnconfirmed >0) {
<td>@hotAccountBalance.AmountConfirmed (@hotAccountBalance.AmountUnconfirmed )</td>
<td class="align-middle">@hotAccountBalance.AmountConfirmed (@hotAccountBalance.AmountUnconfirmed )</td>
} else {
<td>@hotAccountBalance.AmountConfirmed</td>
<td class="align-middle">@hotAccountBalance.AmountConfirmed</td>
}
}
}
<td class="text-center">
<button class="btn btn-sm btn-primary"><span class="oi oi-zoom-in" aria-hidden="true"></span></button>
</td>
</tr>
}
}
}
</tbody>
</table>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@inject NodeDeployments NodeDeployments

<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
<h1 class="h2"><strong>Delegate Staking From: @walletname</strong></h1>
<h1 class="h2"><strong>Delegate Staking from @walletname</strong></h1>
<div class="btn-toolbar mb-2 mb-md-0">
</div>
</div>
Expand All @@ -40,7 +40,7 @@ var mainAccountBalance = this.WalletManager.GetBalances(walletname, "account 0")
</div>
</div>
</div>
<div class="col-xl-6 col-sm-6 grid-margin stretch-card">
<div class="col-xl-6 col-sm-6 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h5>Cold Balance</h5>
Expand All @@ -57,7 +57,6 @@ var mainAccountBalance = this.WalletManager.GetBalances(walletname, "account 0")
</div>
</div>
</div>

<div class="row ">
<div class="col-12 grid-margin">
<div class="card">
Expand All @@ -69,35 +68,36 @@ var mainAccountBalance = this.WalletManager.GetBalances(walletname, "account 0")
<input @bind="HotWalletAddress" type="text" class="form-control" placeholder="Your third party delegated staking address" />
</div>

<div class="input-group mb-3">
<div class="input-group-prepend">
<span style="min-width: 15em" class="input-group-text">Amount:</span>
</div>
<input @bind="Amount" type="text" class="form-control" placeholder="amount" />
<div class="input-group-append">
<span style="min-width: 3em" class="input-group-text">@this.Network.CoinTicker.ToUpper()</span>
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span style="min-width: 15em" class="input-group-text">Amount (@this.Network.CoinTicker.ToUpper()):</span>
</div>
<input @bind="Amount" type="text" class="form-control" placeholder="amount" />
<div class="input-group-append">
<button class="btn btn-secondary" @onclick="MaxAmount">Max</button>
</div>
</div>

<div class="input-group mb-3">
<div class="input-group-prepend">
<span style="min-width: 15em" class="input-group-text">Fee:</span>
</div>
<input @bind="Fee" type="text" class="form-control" placeholder="fee" />
<div class="input-group-append">
<span style="min-width: 10em" class="input-group-text">Optional (<abbr title="The low fee may not be enough for every transaction">default to low</abbr>)</span>
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span style="min-width: 15em" class="input-group-text">Fee:</span>
</div>
<input @bind="Fee" type="text" class="form-control" placeholder="fee" />
<div class="input-group-append">
<span style="min-width: 6em" class="input-group-text"><abbr title="The low fee may not be enough for every transaction">Default to low</abbr></span>
</div>
</div>

<div class="input-group mb-3">
<div class="input-group-prepend">
<span style="min-width: 15em" class="input-group-text">Password:</span>
</div>
<input @bind="Password" type="password" class="form-control" placeholder="Please enter your password" />
</div>

<div class="btn-toolbar mb-2 mb-md-0">
<button class="btn btn-primary mr-1" @onclick="Setup">Delegate Staking Now</button>
<button class="btn btn-primary" @onclick="ChangePayToScript">PayToScript: @PayToScript</button>
<button class="btn btn-primary mr-1" @onclick="Setup">Delegate Staking Now</button>
<button class="btn btn-primary" @onclick="ChangePayToScript">PayToScript: @PayToScript</button>
</div>
<div class="input-group">
<div class="alert-warning">@Alert</div>
Expand Down Expand Up @@ -147,12 +147,25 @@ var mainAccountBalance = this.WalletManager.GetBalances(walletname, "account 0")
}
return Task.CompletedTask;
}
public void SendMax()
{
var mainAccountBalance = this.WalletManager.GetBalances(walletname, "account 0").Single();

this.Amount = mainAccountBalance.AmountConfirmed.ToUnit(MoneyUnit.BTC);

this.Amount = this.Amount - this.Fee;
}
private void ChangePayToScript()
{
this.PayToScript = !this.PayToScript;
}

public void MaxAmount()
{
var accountBalance = this.WalletManager.GetBalances(walletname, "account 0").Single();
this.Amount = accountBalance.AmountConfirmed.ToDecimal(MoneyUnit.BTC) - this.Fee;
}

private async Task Setup()
{
if (string.IsNullOrEmpty(this.Password)) { this.Alert = "Please enter a password"; return; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
@inject NavigationManager NavigationManager
@inject NodeDeployments NodeDeployments

@if (!NodeDeployments.GetFlags().ScriptFlags.HasFlag(ScriptVerify.CheckColdStakeVerify))
{
<h2>Cold staking is not activated</h2>
return;
}

<h2><strong>Enable cold staking on an existing wallet</strong></h2>

<div class="row ">
Expand Down
Loading

0 comments on commit 75fa06c

Please sign in to comment.