Skip to content

Commit

Permalink
Merge pull request #2010 from gobitfly/BIDS-1801/WithdrawalsOnDashboard
Browse files Browse the repository at this point in the history
Bids 1801/withdrawals on dashboard
  • Loading branch information
recy21 authored Mar 28, 2023
2 parents 7969098 + a5adcd8 commit b017770
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
20 changes: 11 additions & 9 deletions handlers/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,16 @@ func getNextWithdrawalRow(queryValidators []uint64) ([][]interface{}, error) {
continue
}
for _, v := range validatorsDb {
if v.Index == balanceIndex {
if (balance[0].Balance > 0 && v.WithdrawableEpoch <= epoch) ||
(balance[0].EffectiveBalance == utils.Config.Chain.Config.MaxEffectiveBalance && balance[0].Balance > utils.Config.Chain.Config.MaxEffectiveBalance) {
// this validator is withdrawable, check if it is the next one
if nextValidator == nil || v.Index > *stats.LatestValidatorWithdrawalIndex {
nextValidator = v
nextValidator.Balance = balance[0].Balance
}
if v.Index != balanceIndex {
continue
}

if (balance[0].Balance > 0 && v.WithdrawableEpoch <= epoch) ||
(balance[0].EffectiveBalance == utils.Config.Chain.Config.MaxEffectiveBalance && balance[0].Balance > utils.Config.Chain.Config.MaxEffectiveBalance) {
// this validator is withdrawable, check if it is the next one
if nextValidator == nil || v.Index > *stats.LatestValidatorWithdrawalIndex {
nextValidator = v
nextValidator.Balance = balance[0].Balance
}
}
}
Expand Down Expand Up @@ -286,7 +288,7 @@ func getNextWithdrawalRow(queryValidators []uint64) ([][]interface{}, error) {
template.HTML(fmt.Sprintf(`<span class="text-muted">~ %s</span>`, utils.FormatBlockSlot(utils.TimeToSlot(uint64(timeToWithdrawal.Unix()))))),
template.HTML(fmt.Sprintf(`<span class="">~ %s</span>`, utils.FormatTimeFromNow(timeToWithdrawal))),
withdrawalCredentialsTemplate,
template.HTML(fmt.Sprintf(`<span class="text-muted">~ %s</span>`, utils.FormatAmount(new(big.Int).Mul(new(big.Int).SetUint64(nextValidator.Balance-utils.Config.Chain.Config.MaxEffectiveBalance), big.NewInt(1e9)), "ETH", 6))),
template.HTML(fmt.Sprintf(`<span class="text-muted"><span data-toggle="tooltip" title="If the withdrawal were to be processed at this very moment, this amount would be withdrawn"><i class="far ml-1 fa-question-circle" style="margin-left: 0px !important;"></i></span> %s</span>`, utils.FormatAmount(new(big.Int).Mul(new(big.Int).SetUint64(nextValidator.Balance-utils.Config.Chain.Config.MaxEffectiveBalance), big.NewInt(1e9)), "ETH", 6))),
})

return nextData, nil
Expand Down
2 changes: 1 addition & 1 deletion handlers/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func Validator(w http.ResponseWriter, r *http.Request) {
template.HTML(fmt.Sprintf(`<span class="text-muted">~ %s</span>`, utils.FormatBlockSlot(utils.TimeToSlot(uint64(timeToWithdrawal.Unix()))))),
template.HTML(fmt.Sprintf(`<span class="">~ %s</span>`, utils.FormatTimeFromNow(timeToWithdrawal))),
withdrawalCredentialsTemplate,
template.HTML(fmt.Sprintf(`<span class="text-muted"><span data-toggle="tooltip" title="If the withdrawal were to be processed at this very moment, this amount would be withdrawn"><i class="far ml-1 fa-question-circle" style="margin-left: 0px !important;"></i></span> %s</span>`, utils.FormatAmount(new(big.Int).Mul(new(big.Int).SetUint64(validatorPageData.CurrentBalance-utils.Config.Chain.Config.MaxEffectiveBalance), big.NewInt(1e9)), "ETH", 6))), // RECy
template.HTML(fmt.Sprintf(`<span class="text-muted"><span data-toggle="tooltip" title="If the withdrawal were to be processed at this very moment, this amount would be withdrawn"><i class="far ml-1 fa-question-circle" style="margin-left: 0px !important;"></i></span> %s</span>`, utils.FormatAmount(new(big.Int).Mul(new(big.Int).SetUint64(validatorPageData.CurrentBalance-utils.Config.Chain.Config.MaxEffectiveBalance), big.NewInt(1e9)), "ETH", 6))),
})

validatorPageData.NextWithdrawalRow = tableData
Expand Down
5 changes: 4 additions & 1 deletion templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@
</li>
{{ if .CappellaHasHappened }}
<li class="nav-item dashboard-table-nav" style="flex:1;">
<a class="nav-link" id="withdrawal-tab" data-toggle="tab" href="#withdrawals" role="tab" aria-controls="withdrawals" aria-selected="false"><i class="tab-icon mr-md-1 fas fa-money-bill"></i> <span class="tab-text">Withdrawals</span></a>
<a class="nav-link" id="withdrawal-tab" data-toggle="tab" href="#withdrawals" role="tab" aria-controls="withdrawals" aria-selected="false" style="text-align:center;white-space:nowrap;">
<i class="tab-icon mr-md-1 fas fa-money-bill"></i>
<span class="tab-text">Withdrawals</span>
</a>
</li>
{{ end }}
</ul>
Expand Down

0 comments on commit b017770

Please sign in to comment.