Skip to content

Commit

Permalink
fix: batch size tooltip data
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosNicolau committed Dec 24, 2024
1 parent 9c494af commit a30f444
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 3 additions & 4 deletions explorer/assets/vendor/charts/batch_size.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const batchSizeCustomOptions = (options, data) => {
name: "batch-size",
title: "Batch size",
items: [
{ title: "Cost", id: "cost" },
{ title: "Fee per proof", id: "cost" },
{ title: "Age", id: "age" },
{ title: "Merkle root", id: "merkle_root" },
{ title: "Block number", id: "block_number" },
Expand All @@ -41,16 +41,15 @@ export const batchSizeCustomOptions = (options, data) => {
onTooltipUpdate: (tooltipModel) => {
const dataset = tooltipModel.dataPoints[0].dataset;
const idx = tooltipModel.dataPoints[0].dataIndex;

const cost = `${dataset.data[idx].y} USD`;
const amount_of_proofs = dataset.data[idx].y;
const age = dataset.age[idx];
const merkleRootHash = dataset.merkle_root[idx];
const merkle_root = `${merkleRootHash.slice(
0,
6
)}...${merkleRootHash.slice(merkleRootHash.length - 4)}`;
const block_number = dataset.data[idx].x;
const amount_of_proofs = dataset.amount_of_proofs[idx];
const cost = `${dataset.fee_per_proof[idx]} USD`;

return {
cost,
Expand Down
2 changes: 1 addition & 1 deletion explorer/assets/vendor/charts/cost_per_proof.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const costPerProofCustomOptions = (options, data) => {
name: "cost-per-proof",
title: "Cost per proof",
items: [
{ title: "Cost", id: "cost" },
{ title: "Fee per proof", id: "cost" },
{ title: "Age", id: "age" },
{ title: "Merkle root", id: "merkle_root" },
{ title: "Block number", id: "block_number" },
Expand Down
11 changes: 10 additions & 1 deletion explorer/lib/explorer_web/live/pages/home/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,16 @@ defmodule ExplorerWeb.Home.Index do
extra_data =
%{
merkle_root: Enum.map(batches, fn b -> b.merkle_root end),
amount_of_proofs: Enum.map(batches, fn b -> b.amount_of_proofs end),
fee_per_proof:
Enum.map(batches, fn b ->
case EthConverter.wei_to_usd(b.fee_per_proof, 2) do
{:ok, value} ->
value

{:error, _} ->
nil
end
end),
age: Enum.map(batches, fn b -> Helpers.parse_timeago(b.submission_timestamp) end)
}

Expand Down

0 comments on commit a30f444

Please sign in to comment.