Skip to content

Commit

Permalink
[explorer] Use system state for current epoch (MystenLabs#10859)
Browse files Browse the repository at this point in the history
## Description

Updates explorer home metrics to use the system state for the epoch
instead of the metrics.

## Test Plan

Ran locally.
  • Loading branch information
Jordan-Mysten authored Apr 13, 2023
1 parent 4b99adc commit 3cbf585
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions apps/explorer/src/components/HomeMetrics/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { formatAmountParts, useRpcClient } from '@mysten/core';
import {
formatAmountParts,
useGetSystemState,
useRpcClient,
} from '@mysten/core';
import { useQuery } from '@tanstack/react-query';

import { MetricGroup } from './MetricGroup';
Expand Down Expand Up @@ -45,6 +49,8 @@ export function HomeMetrics() {
rpc.getReferenceGasPrice()
);

const { data: systemState } = useGetSystemState();

const { data: transactionCount } = useQuery(
['home', 'transaction-count'],
() => rpc.getTotalTransactionBlocks(),
Expand Down Expand Up @@ -90,10 +96,8 @@ export function HomeMetrics() {
{gasData ? gasData.toLocaleString() : null}
</StatsWrapper>
<StatsWrapper label="Epoch" tooltip="The current epoch">
{networkMetrics?.currentEpoch
? BigInt(
networkMetrics?.currentEpoch
).toLocaleString()
{systemState?.epoch
? BigInt(systemState?.epoch).toLocaleString()
: null}
</StatsWrapper>
<StatsWrapper
Expand Down Expand Up @@ -124,7 +128,7 @@ export function HomeMetrics() {
tooltip="Total transaction blocks counter"
amount={transactionCount}
/>
{/*
{/*
TODO: enable when indexer is healthy
<FormattedStatsAmount
label="Addresses"
Expand Down

0 comments on commit 3cbf585

Please sign in to comment.