From 06d41d00eb78fb26fc8e5d0b0d20ded9b1da24e3 Mon Sep 17 00:00:00 2001 From: Nikita Pozdniakov Date: Tue, 8 Aug 2023 08:52:08 +0300 Subject: [PATCH] Handle negative holders count --- .../lib/block_scout_web/views/api/v2/token_view.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/v2/token_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/v2/token_view.ex index fe60782eb1..7f983ed84b 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/v2/token_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/v2/token_view.ex @@ -13,7 +13,7 @@ defmodule BlockScoutWeb.API.V2.TokenView do "name" => token.name, "decimals" => token.decimals, "type" => token.type, - "holders" => token.holder_count && to_string(token.holder_count), + "holders" => prepare_holders_count(token.holder_count), "exchange_rate" => exchange_rate(token), "total_supply" => token.total_supply, "icon_url" => token.icon_url, @@ -80,4 +80,8 @@ defmodule BlockScoutWeb.API.V2.TokenView do "is_unique" => is_unique } end + + defp prepare_holders_count(nil), do: nil + defp prepare_holders_count(count) when count < 0, do: prepare_holders_count(0) + defp prepare_holders_count(count), do: to_string(count) end