Merge pull request #2550 from poanetwork/ab-fix-exchange-rates

correctly encode decimal values for frontend
pull/2562/head
Victor Baranov 5 years ago committed by GitHub
commit d44f42b032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 9
      apps/block_scout_web/lib/block_scout_web/chain.ex
  3. 8
      apps/block_scout_web/test/block_scout_web/chain_test.exs

@ -11,6 +11,7 @@
### Fixes
- [#2553](https://github.com/poanetwork/blockscout/pull/2553) - Dark theme import to the end of sass
- [#2550](https://github.com/poanetwork/blockscout/pull/2550) - correctly encode decimal values for frontend
- [#2549](https://github.com/poanetwork/blockscout/pull/2549) - Fix wrong colour of tooltip
- [#2548](https://github.com/poanetwork/blockscout/pull/2548) - CSS preload support in Firefox
- [#2547](https://github.com/poanetwork/blockscout/pull/2547) - do not show eth value if it's zero on the transaction overview page

@ -31,6 +31,15 @@ defmodule BlockScoutWeb.Chain do
alias Explorer.PagingOptions
defimpl Poison.Encoder, for: Decimal do
def encode(value, _opts) do
# silence the xref warning
decimal = Decimal
[?\", decimal.to_string(value), ?\"]
end
end
@page_size 50
@default_paging_options %PagingOptions{page_size: @page_size + 1}
@address_hash_len 40

@ -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

Loading…
Cancel
Save