Skip to content

Commit b23698b

Browse files
authored
hotfix(explorer): panic on batches last page (#1731)
1 parent cd0c331 commit b23698b

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

explorer/lib/explorer_web/components/batches_table.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ defmodule ExplorerWeb.BatchesTable do
3838
<%= "N/A" %>
3939
<% end %>
4040
<.tooltip>
41-
~= <%= EthConverter.wei_to_eth(batch.fee_per_proof, 6) %> ETH
41+
<%= case EthConverter.wei_to_eth(batch.fee_per_proof, 6) do %>
42+
<% nil -> %>
43+
<%= "N/A" %>
44+
<% eth -> %>
45+
<%= "~= #{eth} ETH" %>
46+
<% end %>
4247
</.tooltip>
4348
</:col>
4449

explorer/lib/explorer_web/live/eth_converter.ex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ defmodule EthConverter do
3131
|> wei_to_eth(decimal_places)
3232
end
3333

34-
def wei_to_usd(wei, decimal_places \\ 0) do
34+
def wei_to_usd(wei, decimal_places \\ 0)
35+
36+
def wei_to_usd(nil, _), do: {:error, "nil value"}
37+
38+
def wei_to_usd(wei, decimal_places) do
3539
with eth_amount <- wei_to_eth(wei, 18),
3640
{:ok, eth_price} <- get_eth_price_usd() do
3741
usd_value =
@@ -43,8 +47,11 @@ defmodule EthConverter do
4347
end
4448
end
4549

50+
def wei_to_usd_sf(wei, significant_figures \\ 3)
51+
def wei_to_usd_sf(nil, _), do: {:error, "nil value"}
52+
4653
# rounds to significant figures, instead of decimal places
47-
def wei_to_usd_sf(wei, significant_figures \\ 3) do
54+
def wei_to_usd_sf(wei, significant_figures) do
4855
with eth_amount <- wei_to_eth(wei, 18),
4956
{:ok, eth_price} <- get_eth_price_usd() do
5057
usd_value =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</h3>
4040
<p><%= @current_batch.amount_of_proofs %></p>
4141
</div>
42-
<div :if={@current_batch.fee_per_proof != 0} class="flex flex-col sm:flex-row">
42+
<div :if={!is_nil(@current_batch.fee_per_proof)} class="flex flex-col sm:flex-row">
4343
<h3>
4444
Fee per Proof:
4545
</h3>

0 commit comments

Comments
 (0)