Merge branch 'master' into vb-fix-dark-theme-flickering

pull/2562/head
Victor Baranov 5 years ago committed by GitHub
commit 64c1f66df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 6
      apps/explorer/lib/explorer/chain/supply/rsk.ex
  3. 12
      apps/explorer/test/explorer/chain/supply/rsk_test.exs

@ -20,6 +20,7 @@
### Fixes ### Fixes
- [#2562](https://github.com/poanetwork/blockscout/pull/2562) - Fix dark theme flickering - [#2562](https://github.com/poanetwork/blockscout/pull/2562) - Fix dark theme flickering
- [#2559](https://github.com/poanetwork/blockscout/pull/2559) - fix rsk total supply for empty exchange rate
- [#2553](https://github.com/poanetwork/blockscout/pull/2553) - Dark theme import to the end of sass - [#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 - [#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 - [#2549](https://github.com/poanetwork/blockscout/pull/2549) - Fix wrong colour of tooltip

@ -17,12 +17,14 @@ defmodule Explorer.Chain.Supply.RSK do
@cache_name :rsk_balance @cache_name :rsk_balance
@balance_key :balance @balance_key :balance
def market_cap(exchange_rate) do def market_cap(%{usd_value: usd_value}) when not is_nil(usd_value) do
btc = circulating() btc = circulating()
Decimal.mult(btc, exchange_rate.usd_value) Decimal.mult(btc, usd_value)
end end
def market_cap(_), do: Decimal.new(0)
@doc "Equivalent to getting the circulating value " @doc "Equivalent to getting the circulating value "
def supply_for_days(days) do def supply_for_days(days) do
now = Timex.now() now = Timex.now()

@ -24,7 +24,17 @@ defmodule Explorer.Chain.Supply.RSKTest do
exchange_rate = %{Token.null() | usd_value: Decimal.new(1_000_000)} exchange_rate = %{Token.null() | usd_value: Decimal.new(1_000_000)}
assert Decimal.equal?(RSK.market_cap(exchange_rate), Decimal.new(100.0000)) assert Decimal.equal?(RSK.market_cap(exchange_rate), Decimal.from_float(100.0000))
end
test "returns zero when exchange_rate is empty" do
assert RSK.market_cap(nil) == Decimal.new(0)
end
test "returns zero when usd_value is nil" do
exchange_rate = %{Token.null() | usd_value: nil}
assert RSK.market_cap(exchange_rate) == Decimal.new(0)
end end
end end

Loading…
Cancel
Save