Skip to content

Commit d415404

Browse files
authored
hotfix: handle nil prices per proofs (#687)
1 parent 1318774 commit d415404

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

explorer/lib/explorer/periodically.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ defmodule Explorer.Periodically do
7272
|> case do
7373
{:ok, _} ->
7474
PubSub.broadcast(Explorer.PubSub, "update_views", %{
75-
merkle_root: batch.merkle_root,
7675
eth_usd:
7776
case EthConverter.get_eth_price_usd() do
7877
{:ok, eth_usd_price} -> eth_usd_price

explorer/lib/explorer_web/live/eth_converter.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ defmodule EthConverter do
66

77
def wei_to_eth(wei, decimal_places \\ 18)
88

9+
def wei_to_eth(wei, _decimal_places) when is_nil(wei) do
10+
:nil
11+
end
12+
913
def wei_to_eth(wei, decimal_places) when is_integer(wei) do
1014
wei
1115
|> Decimal.new()

explorer/lib/explorer_web/live/pages/batch/index.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ defmodule ExplorerWeb.Batch.Index do
5555
end
5656

5757
@impl true
58-
def handle_info(%{merkle_root: merkle_root, eth_usd: eth_usd_price} = _params, socket) do
58+
def handle_info(%{eth_usd: eth_usd_price} = _params, socket) do
5959
eth_price =
6060
case socket.assigns.current_batch do
6161
:empty -> nil
6262
batch -> EthConverter.wei_to_eth(batch.cost_per_proof)
6363
end
6464

65-
new_batch = Batches.get_batch(%{merkle_root: merkle_root})
65+
new_batch = Batches.get_batch(%{merkle_root: socket.assigns.merkle_root})
6666

6767
case eth_usd_price do
6868
:empty ->

explorer/lib/explorer_web/live/pages/batch/index.html.heex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Cost per Proof:
1616
<p>
1717
<%= @current_batch.cost_per_proof |> EthConverter.wei_to_eth() %> ETH
18-
<%= if @eth_usd_price != :empty do %>
18+
<%= if @eth_usd_price != :empty and @eth_usd_price != "0.00000" do %>
1919
(<%= @eth_usd_price %> USD)
2020
<% end %>
2121
</p>

0 commit comments

Comments
 (0)