Validation count, only shows validations if has them. Validated -> Blocks Validated, gettext(Validated)pull/738/head
parent
40af46e47b
commit
cbb88f18fe
@ -0,0 +1,43 @@ |
||||
|
||||
defmodule BlockScoutWeb.AddressValidationController do |
||||
@moduledoc """ |
||||
Display all the blocks that this address validates. |
||||
""" |
||||
use BlockScoutWeb, :controller |
||||
|
||||
import BlockScoutWeb.AddressController, only: [transaction_count: 1, validation_count: 1] |
||||
import BlockScoutWeb.Chain, only: |
||||
[paging_options: 1, next_page_params: 3, split_list_by_page: 1] |
||||
|
||||
alias Explorer.{Chain, Market} |
||||
alias Explorer.ExchangeRates.Token |
||||
|
||||
def index(conn, %{"address_id" => address_hash_string} = params) do |
||||
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), |
||||
{:ok, address} <- Chain.hash_to_address(address_hash) do |
||||
|
||||
full_options = Keyword.merge( |
||||
[necessity_by_association: %{miner: :required, transactions: :optional}], |
||||
paging_options(params) |
||||
) |
||||
|
||||
blocks_plus_one = Chain.get_blocks_validated_by_address(full_options, address) |
||||
{blocks, next_page} = split_list_by_page(blocks_plus_one) |
||||
|
||||
render(conn, "index.html", |
||||
address: address, |
||||
blocks: blocks, |
||||
transaction_count: transaction_count(address), |
||||
validation_count: validation_count(address), |
||||
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), |
||||
next_page_params: next_page_params(next_page, blocks, params) |
||||
) |
||||
else |
||||
:error -> |
||||
unprocessable_entity(conn) |
||||
|
||||
{:error, :not_found} -> |
||||
not_found(conn) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,155 @@ |
||||
<section class="container"> |
||||
<%= render BlockScoutWeb.AddressView, "overview.html", assigns %> |
||||
|
||||
<section> |
||||
<div class="card"> |
||||
<div class="card-header"> |
||||
<!-- DESKTOP TAB NAV --> |
||||
<ul class="nav nav-tabs card-header-tabs d-none d-md-inline-flex"> |
||||
<li class="nav-item"> |
||||
<%= link( |
||||
gettext("Transactions"), |
||||
class: "nav-link", |
||||
to: address_transaction_path(@conn, :index, @address.hash) |
||||
) %> |
||||
</li> |
||||
<li class="nav-item"> |
||||
<%= link( |
||||
gettext("Tokens"), |
||||
class: "nav-link", |
||||
to: address_token_path(@conn, :index, @address.hash) |
||||
) %> |
||||
</li> |
||||
<li class="nav-item"> <%= link( |
||||
gettext("Internal Transactions"), |
||||
class: "nav-link", |
||||
"data-test": "internal_transactions_tab_link", |
||||
to: address_internal_transaction_path(@conn, :index, @address.hash) |
||||
) %> |
||||
</li> |
||||
<%= if @validation_count > 0 do %> |
||||
<li class="nav-item"> |
||||
<%= link( |
||||
"Blocks #{gettext("Validated")}", |
||||
class: "nav-link active", |
||||
"data-test": "validations_tab_link", |
||||
to: address_validation_path(@conn, :index, @address.hash) |
||||
) %> |
||||
</li> |
||||
<% end %> |
||||
<%= if contract?(@address) do %> |
||||
<li class="nav-item"> |
||||
<%= link( |
||||
to: address_contract_path(@conn, :index, @address.hash), |
||||
class: "nav-link") do %> |
||||
<%= gettext("Code") %> |
||||
<%= if smart_contract_verified?(@address) do %> |
||||
<i class="far fa-check-circle"></i> |
||||
<% end %> |
||||
<% end %> |
||||
</li> |
||||
<% end %> |
||||
<%= if smart_contract_with_read_only_functions?(@address) do %> |
||||
<li class="nav-item"> |
||||
<%= link( |
||||
gettext("Read Contract"), |
||||
to: address_read_contract_path(@conn, :index, @address.hash), |
||||
class: "nav-link")%> |
||||
</li> |
||||
<% end %> |
||||
<%= if smart_contract_with_read_only_functions?(@address) do %> |
||||
<li class="nav-item"> |
||||
<%= link( |
||||
gettext("Read Contract"), |
||||
to: address_read_contract_path(@conn, :index, @address.hash), |
||||
class: "nav-link")%> |
||||
</li> |
||||
<% end %> |
||||
</ul> |
||||
<!-- MOBILE DROPDOWN NAV --> |
||||
<ul class="nav nav-tabs card-header-tabs d-md-none"> |
||||
<li class="nav-item dropdown flex-fill text-center"> |
||||
<a class="nav-link active dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><%= gettext "Tokens" %></a> |
||||
<div class="dropdown-menu"> |
||||
<%= link( |
||||
gettext("Transactions"), |
||||
class: "dropdown-item", |
||||
to: address_transaction_path(@conn, :index, @address.hash) |
||||
) %> |
||||
<%= link( |
||||
gettext("Tokens"), |
||||
class: "dropdown-item", |
||||
to: address_token_path(@conn, :index, @address.hash) |
||||
) %> |
||||
<%= link( |
||||
gettext("Internal Transactions"), |
||||
class: "dropdown-item", |
||||
"data-test": "internal_transactions_tab_link", |
||||
to: address_internal_transaction_path(@conn, :index, @address.hash) |
||||
) %> |
||||
<%= if @validation_count > 0 do %> |
||||
<%= link( |
||||
"Blocks #{gettext("Validated")}", |
||||
class: "nav-link active", |
||||
"data-test": "validations_tab_link", |
||||
to: address_validation_path(@conn, :index, @address.hash) |
||||
) %> |
||||
<% end %> |
||||
<%= if contract?(@address) do %> |
||||
<%= link( |
||||
to: address_contract_path(@conn, :index, @address.hash), |
||||
class: "dropdown-item") do %> |
||||
<%= gettext("Code") %> |
||||
<%= if smart_contract_verified?(@address) do %> |
||||
<i class="far fa-check-circle"></i> |
||||
<% end %> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
|
||||
<div class="card-body"> |
||||
<div data-selector="channel-batching-message" style="display:none;"> |
||||
<div data-selector="reload-button" class="alert alert-info"> |
||||
<a href="#" class="alert-link"><span data-selector="channel-batching-count"></span> <%= gettext "More validations have come in." %></a> |
||||
</div> |
||||
</div> |
||||
|
||||
<div data-selector="channel-disconnected-message" style="display:none;"> |
||||
<div data-selector="reload-button" class="alert alert-danger"> |
||||
<a href="#" class="alert-link"><%= gettext "Connection Lost, click to load newer validations" %></a> |
||||
</div> |
||||
</div> |
||||
|
||||
<h2 class="card-title"><%="Blocks #{gettext("Validated")}"%></h2> |
||||
<%= if Enum.count(@blocks) > 0 do %> |
||||
<span data-selector="validations-list"> |
||||
<%= for block <- @blocks do %> |
||||
<%= render BlockScoutWeb.BlockView, "_tile.html", block: block %> |
||||
<% end %> |
||||
</span> |
||||
<% else %> |
||||
<div class="tile tile-muted text-center"> |
||||
<span data-selector="empty-validations-list"><%= gettext "There are no validations for this address." %></span> |
||||
</div> |
||||
<% end %> |
||||
<div> |
||||
<%= if @next_page_params do %> |
||||
<%= link( |
||||
gettext("Older"), |
||||
class: "button button-secondary button-sm float-right mt-3", |
||||
to: address_validation_path( |
||||
@conn, |
||||
:index, |
||||
@address, |
||||
@next_page_params |
||||
) |
||||
) %> |
||||
<% end %> |
||||
</div> |
||||
</div> <!-- Card Body --> |
||||
</div> <!-- Card --> |
||||
<section> |
||||
</section> |
@ -0,0 +1,6 @@ |
||||
defmodule BlockScoutWeb.AddressValidationView do |
||||
use BlockScoutWeb, :view |
||||
|
||||
import BlockScoutWeb.AddressView, |
||||
only: [contract?: 1, smart_contract_verified?: 1, smart_contract_with_read_only_functions?: 1] |
||||
end |
Loading…
Reference in new issue