diff --git a/CHANGELOG.md b/CHANGELOG.md index a046a1a134..68beb6bd3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - [#1688](https://github.com/poanetwork/blockscout/pull/1688) - do not fail if failure reason is atom - [#1692](https://github.com/poanetwork/blockscout/pull/1692) - exclude decompiled smart contract from encoding - [#1684](https://github.com/poanetwork/blockscout/pull/1684) - Discard child block with parent_hash not matching hash of imported block + - [#1697](https://github.com/poanetwork/blockscout/pull/1697) - fix failing in rpc if balance is empty ### Chore diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex index f614f3cb88..5dd7146279 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex @@ -9,7 +9,7 @@ defmodule BlockScoutWeb.API.RPC.AddressView do end def render("balance.json", %{addresses: [address]}) do - RPCView.render("show.json", data: "#{address.fetched_coin_balance.value}") + RPCView.render("show.json", data: balance(address)) end def render("balance.json", assigns) do @@ -21,7 +21,7 @@ defmodule BlockScoutWeb.API.RPC.AddressView do Enum.map(addresses, fn address -> %{ "account" => "#{address.hash}", - "balance" => "#{address.fetched_coin_balance.value}" + "balance" => balance(address) } end) @@ -157,4 +157,8 @@ defmodule BlockScoutWeb.API.RPC.AddressView do "symbol" => token.symbol } end + + defp balance(address) do + address.fetched_coin_balance && address.fetched_coin_balance.value && "#{address.fetched_coin_balance.value}" + end end