Use alias BlockScoutWeb.Cldr.Number

pull/7040/head
Viktor Baranov 2 years ago
parent 6e9edfd7b7
commit 8793e23d69
  1. 1
      CHANGELOG.md
  2. 8
      apps/block_scout_web/lib/block_scout_web/views/cldr_helper/number.ex
  3. 6
      apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex

@ -12,6 +12,7 @@
### Chore ### Chore
- [#7040](https://github.com/blockscout/blockscout/pull/7040) - Use alias BlockScoutWeb.Cldr.Number
- [#7034](https://github.com/blockscout/blockscout/pull/7034) - Resolve "Unexpected var, use let or const instead" - [#7034](https://github.com/blockscout/blockscout/pull/7034) - Resolve "Unexpected var, use let or const instead"
- [#7014](https://github.com/blockscout/blockscout/pull/7014), [#7036](https://github.com/blockscout/blockscout/pull/7036) - Fix spell in namings, add spell checking in CI - [#7014](https://github.com/blockscout/blockscout/pull/7014), [#7036](https://github.com/blockscout/blockscout/pull/7036) - Fix spell in namings, add spell checking in CI
- [#7012](https://github.com/blockscout/blockscout/pull/7012) - Refactor socket.js - [#7012](https://github.com/blockscout/blockscout/pull/7012) - Refactor socket.js

@ -3,11 +3,13 @@ defmodule BlockScoutWeb.CldrHelper.Number do
Work-arounds for `Cldr.Number` bugs Work-arounds for `Cldr.Number` bugs
""" """
alias BlockScoutWeb.Cldr.Number
def to_string(decimal, options) do def to_string(decimal, options) do
# We do this to trick Dialyzer to not complain about non-local returns caused by bug in Cldr.Number.to_string spec # We do this to trick Dialyzer to not complain about non-local returns caused by bug in Cldr.Number.to_string spec
case :erlang.phash2(1, 1) do case :erlang.phash2(1, 1) do
0 -> 0 ->
BlockScoutWeb.Cldr.Number.to_string(decimal, options) Number.to_string(decimal, options)
1 -> 1 ->
# does not occur # does not occur
@ -19,7 +21,7 @@ defmodule BlockScoutWeb.CldrHelper.Number do
# We do this to trick Dialyzer to not complain about non-local returns caused by bug in Cldr.Number.to_string! spec # We do this to trick Dialyzer to not complain about non-local returns caused by bug in Cldr.Number.to_string! spec
case :erlang.phash2(1, 1) do case :erlang.phash2(1, 1) do
0 -> 0 ->
BlockScoutWeb.Cldr.Number.to_string!(decimal) Number.to_string!(decimal)
1 -> 1 ->
# does not occur # does not occur
@ -31,7 +33,7 @@ defmodule BlockScoutWeb.CldrHelper.Number do
# We do this to trick Dialyzer to not complain about non-local returns caused by bug in Cldr.Number.to_string! spec # We do this to trick Dialyzer to not complain about non-local returns caused by bug in Cldr.Number.to_string! spec
case :erlang.phash2(1, 1) do case :erlang.phash2(1, 1) do
0 -> 0 ->
BlockScoutWeb.Cldr.Number.to_string!(decimal, options) Number.to_string!(decimal, options)
1 -> 1 ->
# does not occur # does not occur

@ -278,7 +278,7 @@ defmodule BlockScoutWeb.TransactionView do
case block do case block do
%Block{consensus: true} -> %Block{consensus: true} ->
{:ok, confirmations} = Chain.confirmations(block, named_arguments) {:ok, confirmations} = Chain.confirmations(block, named_arguments)
BlockScoutWeb.Cldr.Number.to_string!(confirmations, format: "#,###") Number.to_string!(confirmations, format: "#,###")
_ -> _ ->
0 0
@ -326,7 +326,7 @@ defmodule BlockScoutWeb.TransactionView do
data data
|> Map.get(field_name) |> Map.get(field_name)
|> Decimal.new() |> Decimal.new()
|> BlockScoutWeb.CldrHelper.Number.to_string!(format: "#,##0.##################") |> Number.to_string!(format: "#,##0.##################")
end end
def transaction_action_string_to_address(address) do def transaction_action_string_to_address(address) do
@ -377,7 +377,7 @@ defmodule BlockScoutWeb.TransactionView do
end end
def gas(%type{gas: gas}) when is_transaction_type(type) do def gas(%type{gas: gas}) when is_transaction_type(type) do
BlockScoutWeb.Cldr.Number.to_string!(gas) Number.to_string!(gas)
end end
def skip_decoding?(transaction) do def skip_decoding?(transaction) do

Loading…
Cancel
Save