Fix zero total supply bug

pull/4429/head
nikitosing 3 years ago
parent 3d88333174
commit 768afccee8
  1. 1
      CHANGELOG.md
  2. 2
      apps/block_scout_web/lib/block_scout_web/views/tokens/holder_view.ex
  3. 7
      apps/block_scout_web/test/block_scout_web/views/tokens/holder_view_test.exs

@ -7,6 +7,7 @@
- [#4353](https://github.com/blockscout/blockscout/pull/4353) - Added live-reload on the token holders page
### Fixes
- [#4429](https://github.com/blockscout/blockscout/pull/4429) - Fix 500 response on `/tokens/{addressHash}/token-holders?type=JSON` when total supply is zero
- [#4419](https://github.com/blockscout/blockscout/pull/4419) - Order contracts in the search by inserted_at in descending order
- [#4418](https://github.com/blockscout/blockscout/pull/4418) - Fix empty search results for the full-word search criteria
- [#4406](https://github.com/blockscout/blockscout/pull/4406) - Fix internal server error on the validator's txs page

@ -33,6 +33,8 @@ defmodule BlockScoutWeb.Tokens.HolderView do
"20.0000%"
"""
def total_supply_percentage(_, 0), do: "N/A%"
def total_supply_percentage(value, total_supply) do
result =
value

@ -40,6 +40,13 @@ defmodule BlockScoutWeb.Tokens.HolderViewTest do
assert HolderView.total_supply_percentage(value, total_supply) == "0.0005%"
end
test "zero total_supply" do
%Token{total_supply: total_supply} = build(:token, total_supply: 0)
%TokenBalance{value: value} = build(:token_balance, value: 0)
assert HolderView.total_supply_percentage(value, total_supply) == "N/A%"
end
end
describe "format_token_balance_value/1" do

Loading…
Cancel
Save