diff --git a/apps/block_scout_web/lib/block_scout_web/chain.ex b/apps/block_scout_web/lib/block_scout_web/chain.ex index c8279652bf..3aa660fbe4 100644 --- a/apps/block_scout_web/lib/block_scout_web/chain.ex +++ b/apps/block_scout_web/lib/block_scout_web/chain.ex @@ -33,6 +33,7 @@ defmodule BlockScoutWeb.Chain do defimpl Poison.Encoder, for: Decimal do def encode(value, _opts) do + # silence the xref warning decimal = Decimal [?\", decimal.to_string(value), ?\"] diff --git a/apps/block_scout_web/test/block_scout_web/chain_test.exs b/apps/block_scout_web/test/block_scout_web/chain_test.exs index 3d1a7312f4..7656ff2259 100644 --- a/apps/block_scout_web/test/block_scout_web/chain_test.exs +++ b/apps/block_scout_web/test/block_scout_web/chain_test.exs @@ -71,4 +71,12 @@ defmodule BlockScoutWeb.ChainTest do assert {:error, :not_found} = Chain.from_param(address_hash) end end + + describe "Posion.encode!" do + test "correctly encodes decimal values" do + val = Decimal.from_float(5.55) + + assert "\"5.55\"" == Poison.encode!(val) + end + end end