diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex new file mode 100644 index 0000000000..5bf5a0d897 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex @@ -0,0 +1,45 @@ +
+
+ +
+ + + <%= @index %> + +
+ +
+
+
+ <%= @address |> BlockScoutWeb.AddressView.address_partial_selector(nil, nil) |> BlockScoutWeb.RenderHelpers.render_partial() %> + + + + <%= transaction_count(@address) %> + <%= gettext "Transactions sent" %> + <% if validator?(@address) do %> + + <%= validation_count(@address) %> + <%= gettext "Validations" %> + <% end %> + +
+ + +
+ + <%= balance(@address) %> +
+ + + + + (<%= balance_percentage(@address) %>) +
+
+
+
+
+
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index b7dc6c7405..13db6de433 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -10,47 +10,11 @@ <%= for {address, index} <- Enum.with_index(@addresses, 1) do %> -
-
- -
- - <%= index %> -
- -
-
-
- <%= address |> BlockScoutWeb.AddressView.address_partial_selector(nil, nil) |> BlockScoutWeb.RenderHelpers.render_partial() %> - - - <%= transaction_count(address) %> - <%= gettext "Transactions sent" %> - -
- - -
- - <%= balance(address) %> -
- - - - - (<%= balance_percentage(address) %>) -
-
-
-
-
-
+ <%= render "_tile.html", + address: address, index: index, exchange_rate: @exchange_rate, + validation_count: validation_count(address) %> <% end %>
- - diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_view.ex index 2d241b01a2..afe2d8eb80 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_view.ex @@ -116,6 +116,8 @@ defmodule BlockScoutWeb.AddressView do def validator?(val) when val > 0, do: true + def validator?(%Address{} = address), do: Chain.address_to_validation_count(address) + def validator?(_), do: false def hash(%Address{hash: hash}) do @@ -163,6 +165,10 @@ defmodule BlockScoutWeb.AddressView do Chain.total_transactions_sent_by_address(address) end + def validation_count(%Address{} = address) do + Chain.address_to_validation_count(address) + end + def trimmed_hash(%Hash{} = hash) do string_hash = to_string(hash) "#{String.slice(string_hash, 0..5)}–#{String.slice(string_hash, -6..-1)}"