Skip to content

Commit dc033e1

Browse files
committed
feat: conditionally render aggregated components if environment is mainnet
1 parent 2e8796f commit dc033e1

File tree

4 files changed

+125
-88
lines changed

4 files changed

+125
-88
lines changed

explorer/lib/explorer_web/components/contracts.ex

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,54 @@ defmodule ContractsComponent do
88
def mount(socket) do
99
addresses = Helpers.get_aligned_contracts_addresses()
1010

11+
proof_aggregator_service =
12+
case Helpers.is_mainnet() do
13+
true ->
14+
[]
15+
16+
false ->
17+
[
18+
%{
19+
contract_name: "AlignedProofAggregationService",
20+
address: addresses["alignedProofAggregationService"]
21+
}
22+
]
23+
end
24+
1125
{:ok,
1226
assign(socket,
13-
contracts: [
14-
%{
15-
contract_name: "AlignedProofAggregationService",
16-
address: addresses["alignedProofAggregationService"]
17-
},
18-
%{
19-
contract_name: "AlignedServiceManager",
20-
address: addresses["alignedLayerServiceManager"]
21-
},
22-
%{
23-
contract_name: "BatcherPaymentService",
24-
address: addresses["batcherPaymentService"]
25-
},
26-
%{
27-
contract_name: "BlsApkRegistry",
28-
address: addresses["blsApkRegistry"]
29-
},
30-
%{
31-
contract_name: "IndexRegistry",
32-
address: addresses["indexRegistry"]
33-
},
34-
%{
35-
contract_name: "OperatorStateRetriever",
36-
address: addresses["operatorStateRetriever"]
37-
},
38-
%{
39-
contract_name: "RegistryCoordinator",
40-
address: addresses["registryCoordinator"]
41-
},
42-
%{
43-
contract_name: "StakeRegistry",
44-
address: addresses["stakeRegistry"]
45-
}
46-
]
27+
contracts:
28+
proof_aggregator_service ++
29+
[
30+
%{
31+
contract_name: "AlignedServiceManager",
32+
address: addresses["alignedLayerServiceManager"]
33+
},
34+
%{
35+
contract_name: "BatcherPaymentService",
36+
address: addresses["batcherPaymentService"]
37+
},
38+
%{
39+
contract_name: "BlsApkRegistry",
40+
address: addresses["blsApkRegistry"]
41+
},
42+
%{
43+
contract_name: "IndexRegistry",
44+
address: addresses["indexRegistry"]
45+
},
46+
%{
47+
contract_name: "OperatorStateRetriever",
48+
address: addresses["operatorStateRetriever"]
49+
},
50+
%{
51+
contract_name: "RegistryCoordinator",
52+
address: addresses["registryCoordinator"]
53+
},
54+
%{
55+
contract_name: "StakeRegistry",
56+
address: addresses["stakeRegistry"]
57+
}
58+
]
4759
)}
4860
end
4961

explorer/lib/explorer_web/components/nav.ex

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,19 @@ defmodule NavComponent do
5959
>
6060
Batches
6161
</.link>
62-
<.link
63-
class={
64-
active_view_class(assigns.socket.view, [
65-
ExplorerWeb.AggProofs.Index,
66-
ExplorerWeb.AggProof.Index
67-
])
68-
}
69-
navigate={~p"/aggregated_proofs"}
70-
>
71-
Aggregation
72-
</.link>
62+
<%= if !ExplorerWeb.Helpers.is_mainnet() do %>
63+
<.link
64+
class={
65+
active_view_class(@socket.view, [
66+
ExplorerWeb.AggProofs.Index,
67+
ExplorerWeb.AggProof.Index
68+
])
69+
}
70+
navigate={~p"/aggregated_proofs"}
71+
>
72+
Aggregation
73+
</.link>
74+
<% end %>
7375
<.nav_links_dropdown
7476
title="Restaking"
7577
class={
@@ -154,20 +156,22 @@ defmodule NavComponent do
154156
>
155157
Batches
156158
</.link>
157-
<.link
158-
class={
159-
classes([
160-
active_view_class(assigns.socket.view, [
161-
ExplorerWeb.AggregatedProofs.Index,
162-
ExplorerWeb.AggregatedProof.Index
163-
]),
164-
"text-foreground/80 hover:text-foreground font-semibold"
165-
])
166-
}
167-
navigate={~p"/aggregated_proofs"}
168-
>
169-
Aggregation
170-
</.link>
159+
<%= if !ExplorerWeb.Helpers.is_mainnet() do %>
160+
<.link
161+
class={
162+
classes([
163+
active_view_class(assigns.socket.view, [
164+
ExplorerWeb.AggregatedProofs.Index,
165+
ExplorerWeb.AggregatedProof.Index
166+
]),
167+
"text-foreground/80 hover:text-foreground font-semibold"
168+
])
169+
}
170+
navigate={~p"/aggregated_proofs"}
171+
>
172+
Aggregation
173+
</.link>
174+
<% end %>
171175
<.link
172176
class="hover:text-foreground"
173177
target="_blank"

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

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ defmodule ExplorerWeb.Home.Index do
3939

4040
operator_latest_release = ReleasesHelper.get_latest_release()
4141

42+
# Only show aggregated proof stat for testnet
43+
aggregated_proof_stat =
44+
if !ExplorerWeb.Helpers.is_mainnet() do
45+
[
46+
%{
47+
title: "Aggregated proofs",
48+
value: aggregated_proofs,
49+
tooltip_text: nil,
50+
link: "/aggregated_proofs"
51+
}
52+
]
53+
else
54+
[]
55+
end
56+
4257
[
4358
%{
4459
title: "Proofs verified",
@@ -59,36 +74,33 @@ defmodule ExplorerWeb.Home.Index do
5974
_ -> nil
6075
end,
6176
link: nil
62-
},
63-
%{
64-
title: "Aggregated proofs",
65-
value: aggregated_proofs,
66-
tooltip_text: nil,
67-
link: "/aggregated_proofs"
68-
},
69-
%{
70-
title: "AVG proof cost",
71-
value: "#{avg_fee_per_proof_usd} USD",
72-
tooltip_text: "~= #{avg_fee_per_proof_eth} ETH",
73-
link: nil
74-
},
75-
%{
76-
title: "Operators",
77-
value: operators_registered,
78-
tooltip_text: "Current version #{operator_latest_release}",
79-
link: "/operators"
80-
},
81-
%{
82-
title: "Total restaked",
83-
value: "#{restaked_amount_usd_shorthand} USD",
84-
# Using HTML.raw to break paragraph line with <br>
85-
tooltip_text:
86-
Phoenix.HTML.raw(
87-
"= #{Helpers.format_number(restaked_amount_usd)} USD<br>~= #{restaked_amount_eth} ETH"
88-
),
89-
link: "/restaked"
9077
}
91-
]
78+
] ++
79+
aggregated_proof_stat ++
80+
[
81+
%{
82+
title: "AVG proof cost",
83+
value: "#{avg_fee_per_proof_usd} USD",
84+
tooltip_text: "~= #{avg_fee_per_proof_eth} ETH",
85+
link: nil
86+
},
87+
%{
88+
title: "Operators",
89+
value: operators_registered,
90+
tooltip_text: "Current version #{operator_latest_release}",
91+
link: "/operators"
92+
},
93+
%{
94+
title: "Total restaked",
95+
value: "#{restaked_amount_usd_shorthand} USD",
96+
# Using HTML.raw to break paragraph line with <br>
97+
tooltip_text:
98+
Phoenix.HTML.raw(
99+
"= #{Helpers.format_number(restaked_amount_usd)} USD<br>~= #{restaked_amount_eth} ETH"
100+
),
101+
link: "/restaked"
102+
}
103+
]
92104
end
93105

94106
def get_cost_per_proof_chart_data(amount) do

explorer/lib/explorer_web/live/utils.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ defmodule ExplorerWeb.Helpers do
102102
Integer.to_string(value) |> String.pad_leading(2, "0")
103103
end
104104

105+
def is_mainnet() do
106+
prefix = System.get_env("ENVIRONMENT")
107+
108+
case prefix do
109+
"mainnet" -> true
110+
_ -> false
111+
end
112+
end
113+
105114
@doc """
106115
Get the EigenLayer Explorer URL based on the environment.
107116
- `holesky` -> https://holesky.eigenlayer.xyz

0 commit comments

Comments
 (0)