diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_by_day_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_by_day_controller.ex index 6af67c4861..b440fc7d9f 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_by_day_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_by_day_controller.ex @@ -9,7 +9,12 @@ defmodule BlockScoutWeb.AddressCoinBalanceByDayController do def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"}) do with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string) do - balances_by_day = Chain.address_to_balances_by_day(address_hash) + balances_by_day = + address_hash + |> Chain.address_to_balances_by_day() + |> Enum.map(fn %{value: value} = map -> + Map.put(map, :value, Decimal.to_float(value)) + end) json(conn, balances_by_day) end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_coin_balance_by_day_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_coin_balance_by_day_controller_test.exs index e835ba71ce..1496bb24e9 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_coin_balance_by_day_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_coin_balance_by_day_controller_test.exs @@ -14,7 +14,10 @@ defmodule BlockScoutWeb.AddressCoinBalanceByDayControllerTest do response = json_response(conn, 200) - assert length(response) == 2 + assert [ + %{"date" => _, "value" => 2.0e-15}, + %{"date" => _, "value" => 1.0e-15} + ] = response end end end