Formatted percentage of Market Cap to be 4 decimal places.

pull/744/head
Stamates 6 years ago
parent 3061c6b069
commit 5e6a7ec45e
  1. 2
      apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex
  2. 2
      apps/block_scout_web/lib/block_scout_web/router.ex
  3. 4
      apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex
  4. 2
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  5. 5
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex
  6. 2
      apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex
  7. 2
      apps/block_scout_web/test/block_scout_web/views/address_view_test.exs

@ -9,7 +9,7 @@ defmodule BlockScoutWeb.AddressController do
def index(conn, params) do
address_count_module = Application.get_env(:block_scout_web, :fake_adapter) || Chain
full_options = paging_options(params)
addresses_plus_one = Chain.list_top_addresses(full_options)

@ -61,7 +61,7 @@ defmodule BlockScoutWeb.Router do
resources("/token_transfers", TransactionTokenTransferController, only: [:index], as: :token_transfer)
end
resources("/top_addresses", AddressController, only: [:index])
resources("/accounts", AddressController, only: [:index])
resources "/address", AddressController, only: [:show] do
resources("/transactions", AddressTransactionController, only: [:index], as: :transaction)

@ -5,7 +5,7 @@
<p>
<%= gettext "Showing 50 addresses of" %>
<%= Cldr.Number.to_string!(@address_estimated_count, format: "#,###") %>
<%= gettext "total addresses" %>
<%= gettext "total addresses with a balance" %>
</p>
<span data-selector="top-addresses-list">
@ -40,7 +40,7 @@
data-usd-exchange-rate="<%= @exchange_rate.usd_value %>">
</span>
<!-- percentage of coins from total supply -->
<span class="ml-0 ml-md-2">(<%= balance_percentage(address) %> Market Cap)</span>
<span class="ml-0 ml-md-2">(<%= balance_percentage(address) %>)</span>
</div>
</div>
</div>

@ -20,7 +20,7 @@
</li>
<li class="nav-item">
<%= link to: address_path(@conn, :index), class: "nav-link topnav-nav-link" do %>
<%= gettext("Addresses") %>
<%= gettext("Accounts") %>
<% end %>
</li>
<li class="nav-item">

@ -94,8 +94,9 @@ defmodule BlockScoutWeb.AddressView do
|> Wei.to(:ether)
|> Decimal.div(Decimal.new(Chain.total_supply()))
|> Decimal.mult(100)
|> Decimal.to_string()
|> Kernel.<>("%")
|> Decimal.round(4)
|> Decimal.to_string(:normal)
|> Kernel.<>("% #{gettext("Market Cap")}")
end
def balance_block_number(%Address{fetched_coin_balance_block_number: nil}), do: ""

@ -101,6 +101,6 @@ defmodule BlockScoutWeb.AddressPage do
end
def visit_page(session) do
visit(session, "/top_addresses")
visit(session, "/accounts")
end
end

@ -127,7 +127,7 @@ defmodule BlockScoutWeb.AddressViewTest do
test "balance_percentage/1" do
address = insert(:address, fetched_coin_balance: 2_524_608_000_000_000_000_000_000)
assert "1.00%" = AddressView.balance_percentage(address)
assert "1.0000% Market Cap" = AddressView.balance_percentage(address)
end
describe "contract?/1" do

Loading…
Cancel
Save