diff --git a/app/screens/node/Node.tsx b/app/screens/node/Node.tsx index b4a4b54d0..167b83f78 100644 --- a/app/screens/node/Node.tsx +++ b/app/screens/node/Node.tsx @@ -372,7 +372,7 @@ const Node = ({ history, location }: Props) => { const renderTable = (data: RowData[]) => data.map(([label, value], idx) => { return ( - + {label} {value} diff --git a/app/screens/node/NodeEventActivityRow.tsx b/app/screens/node/NodeEventActivityRow.tsx index 2f412b50f..158f155ac 100644 --- a/app/screens/node/NodeEventActivityRow.tsx +++ b/app/screens/node/NodeEventActivityRow.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { NodeEvent } from '../../../shared/types'; import ErrorMessage from '../../basicComponents/ErrorMessage'; -import { getEventType } from '../../../shared/utils'; +import { getEventType, longToNumber } from '../../../shared/utils'; import { CustomTimeAgo } from '../../basicComponents'; import { getNodeEventStage } from './nodeEventUtils'; @@ -88,6 +88,18 @@ export default (event: NodeEvent) => { return `Published proposal on layer ${event.proposal?.layer}`; case 'beacon': return `Node computed randomness beacon for epoch ${event.beacon?.epoch}`; + case 'bestProofSelected': { + const ticks = longToNumber( + typeof event.bestProofSelected?.ticks === 'string' + ? parseInt(event.bestProofSelected?.ticks, 10) + : event.bestProofSelected?.ticks ?? 0 + ); + return `The best PoET proof is selected for round ${ + event.bestProofSelected?.roundId ?? '' + }: ${ticks} ticks`; + } + case 'registeredInPoet': + return `Registered in PoET. Round ID: ${event.registeredInPoet?.roundId}`; default: return event.help ?? 'Node is preparing...'; } diff --git a/shared/utils.ts b/shared/utils.ts index 5825c521b..a6564b783 100644 --- a/shared/utils.ts +++ b/shared/utils.ts @@ -1,4 +1,5 @@ import os from 'os'; +import Long from 'long'; import { hash } from '@spacemesh/sm-codec'; import { Timestamp } from '@grpc/grpc-js/build/src/generated/google/protobuf/Timestamp'; import { Event } from '../api/generated/spacemesh/v1/Event'; @@ -91,8 +92,16 @@ export const toHexString = ( export const deriveHRP = (addr: string) => addr.match(/^(\w+)1/)?.[1] || null; +/* eslint-disable no-nested-ternary */ export const longToNumber = (val: Long | number) => - typeof val === 'number' ? val : val.toNumber(); + typeof val === 'number' + ? val + : val instanceof Long + ? val.toNumber() + : Object.hasOwn(val, 'low') && Object.hasOwn(val, 'high') + ? Long.fromValue(val).toNumber() + : NaN; +/* eslint-enable no-nested-ternary */ export const convertBytesToMiB = (maxFileSize: number) => maxFileSize / 1024 / 1024;