fix(portal/reporting): normalize Blockscout avg_block_time ms->s
Blockscout /api/v2/stats returns average_block_time in milliseconds;
ReportingPage displays it as `${value.toFixed(1)}s` which rendered
~4424s instead of the real ~4.4s. Normalize in the service layer so
every caller gets seconds regardless of upstream format.
Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
This commit is contained in:
@@ -25,7 +25,15 @@ export interface ExplorerStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getExplorerStats(): Promise<ExplorerStats> {
|
export async function getExplorerStats(): Promise<ExplorerStats> {
|
||||||
return httpJson<ExplorerStats>(api('/stats'));
|
const raw = await httpJson<ExplorerStats>(api('/stats'));
|
||||||
|
// Blockscout returns `average_block_time` in milliseconds; normalize to seconds
|
||||||
|
// so callers can display `${value.toFixed(1)}s` directly. Chain-138 block time
|
||||||
|
// is ~4s, so a raw value > 60 is a reliable signal that it is still in ms.
|
||||||
|
const average_block_time =
|
||||||
|
typeof raw.average_block_time === 'number' && raw.average_block_time > 60
|
||||||
|
? raw.average_block_time / 1000
|
||||||
|
: raw.average_block_time;
|
||||||
|
return { ...raw, average_block_time };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExplorerBlock {
|
export interface ExplorerBlock {
|
||||||
|
|||||||
Reference in New Issue
Block a user