Skip to content

Commit da7ddae

Browse files
authored
Merge pull request #15448 from ethereum/hotfix-layer-2
hotfix layer 2
2 parents 1dec3e8 + 1ebc0d0 commit da7ddae

File tree

4 files changed

+58
-19
lines changed

4 files changed

+58
-19
lines changed

app/[locale]/layer-2/_components/layer-2.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,12 @@ const Layer2Hub = ({
124124
<div className="max-w-[224px]">
125125
<p className="text-5xl">
126126
$
127-
{growThePieData.dailyTxCosts["ethereum"].toLocaleString(
128-
locale as Lang,
129-
{ minimumFractionDigits: 2, maximumFractionDigits: 2 }
130-
)}
127+
{(
128+
growThePieData.dailyTxCosts["ethereum"] || 0
129+
).toLocaleString(locale as Lang, {
130+
minimumFractionDigits: 2,
131+
maximumFractionDigits: 2,
132+
})}
131133
</p>
132134
<p className="text-body-medium">
133135
{t("page-layer-2-blockchain-transaction-cost")}

src/components/Layer2NetworksTable/NetworksSubComponent.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { MdInfoOutline } from "react-icons/md"
22

3+
import { ExtendedRollup } from "@/lib/types"
4+
35
import NetworkUsageChart from "@/components/Layer2NetworksTable/NetworkUsageChart"
46
import Tooltip from "@/components/Tooltip"
57

@@ -21,7 +23,11 @@ const formatNumber = (num: number): string => {
2123
return num.toString()
2224
}
2325

24-
const NetworkSubComponent = ({ network }) => {
26+
type NetworkSubComponentProps = {
27+
network: ExtendedRollup
28+
}
29+
30+
const NetworkSubComponent = ({ network }: NetworkSubComponentProps) => {
2531
const { t } = useTranslation("page-layer-2-networks")
2632

2733
return (
@@ -60,6 +66,7 @@ const NetworkSubComponent = ({ network }) => {
6066
</p>
6167
<p>
6268
{(() => {
69+
if (!network.launchDate) return "-"
6370
const launch = new Date(network.launchDate)
6471
const today = new Date()
6572
const yearDiff = today.getFullYear() - launch.getFullYear()
@@ -141,7 +148,11 @@ const NetworkSubComponent = ({ network }) => {
141148
</Tooltip>
142149
</p>
143150
</div>
144-
<p>{formatNumber(network.activeAddresses)}</p>
151+
<p>
152+
{network.activeAddresses
153+
? formatNumber(network.activeAddresses)
154+
: "-"}
155+
</p>
145156
</div>
146157
<div className="flex-1">
147158
<div>

src/components/Layer2NetworksTable/hooks/useNetworkColumns.tsx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const useNetworkColumns: ColumnDef<ExtendedRollup>[] = [
4949
},
5050
cell: ({ table, row }) => {
5151
const meta = table.options.meta as TableMeta
52+
5253
return (
5354
<TableCell
5455
className={cn(
@@ -78,11 +79,20 @@ export const useNetworkColumns: ColumnDef<ExtendedRollup>[] = [
7879
<Translation id="page-layer-2-networks:page-layer-2-networks-avg-transaction-fee" />
7980
</p>
8081
<p>
81-
$
82-
{row.original.txCosts.toLocaleString(meta.locale as Lang, {
83-
minimumFractionDigits: 2,
84-
maximumFractionDigits: 3,
85-
})}
82+
{row.original.txCosts ? (
83+
<>
84+
$
85+
{(row.original.txCosts || 0).toLocaleString(
86+
meta.locale as Lang,
87+
{
88+
minimumFractionDigits: 2,
89+
maximumFractionDigits: 3,
90+
}
91+
)}
92+
</>
93+
) : (
94+
<p>-</p>
95+
)}
8696
</p>
8797
</div>
8898
<div>
@@ -160,11 +170,17 @@ export const useNetworkColumns: ColumnDef<ExtendedRollup>[] = [
160170
row.original.canExpand === false && "border-b-4"
161171
)}
162172
>
163-
$
164-
{row.original.txCosts.toLocaleString(meta.locale as Lang, {
165-
minimumFractionDigits: 2,
166-
maximumFractionDigits: 3,
167-
})}
173+
{row.original.txCosts ? (
174+
<p>
175+
$
176+
{row.original.txCosts.toLocaleString(meta.locale as Lang, {
177+
minimumFractionDigits: 2,
178+
maximumFractionDigits: 3,
179+
})}
180+
</p>
181+
) : (
182+
<p>-</p>
183+
)}
168184
</TableCell>
169185
)
170186
},

src/lib/types.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,8 @@ export type StatsBoxState = ValueOrError<string>
559559
export type GrowThePieMetricKey = "txCount" | "txCostsMedianUsd"
560560

561561
export type GrowThePieData = Record<GrowThePieMetricKey, MetricReturnData> & {
562-
dailyTxCosts: Record<string, number>
563-
activeAddresses: Record<string, number>
562+
dailyTxCosts: Record<string, number | undefined>
563+
activeAddresses: Record<string, number | undefined>
564564
}
565565

566566
export type MetricName =
@@ -642,9 +642,19 @@ export type NonEVMChainName = "Starknet"
642642

643643
export type ExtendedRollup = Rollup & {
644644
networkMaturity: MaturityLevel
645-
txCosts: number
645+
txCosts: number | undefined
646646
tvl: number
647647
walletsSupported: string[]
648+
activeAddresses: number | undefined
649+
launchDate: string | null
650+
walletsSupportedCount: number
651+
blockspaceData: {
652+
nft: number
653+
defi: number
654+
social: number
655+
token_transfers: number
656+
unlabeled: number
657+
} | null
648658
}
649659

650660
// Wallets

0 commit comments

Comments
 (0)