Skip to content

Commit 0f5a9f2

Browse files
committed
change timestamps + lamports fields to string
1 parent 02ba515 commit 0f5a9f2

File tree

13 files changed

+395
-128
lines changed

13 files changed

+395
-128
lines changed

src/api/entities.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const commitHashSchema = z.string();
4444

4545
export const identityKeySchema = z.string();
4646

47-
export const uptimeNanosSchema = z.number();
47+
export const uptimeNanosSchema = z.coerce.bigint();
4848

4949
export const tileTypeSchema = z.enum([
5050
"sock",
@@ -71,9 +71,9 @@ export const tileSchema = z.object({
7171
kind_id: z.number(),
7272
});
7373

74-
export const identityBalanceSchema = z.number();
74+
export const identityBalanceSchema = z.coerce.bigint();
7575

76-
export const voteBalanceSchema = z.number();
76+
export const voteBalanceSchema = z.coerce.bigint();
7777

7878
export const rootSlotSchema = z.number();
7979

@@ -234,12 +234,12 @@ export const slotPublishSchema = z.object({
234234
transactions: z.number().nullable(),
235235
vote_transactions: z.number().nullable(),
236236
failed_transactions: z.number().nullable(),
237-
priority_fee: z.number().nullable(),
238-
transaction_fee: z.number().nullable(),
239-
tips: z.number().nullable(),
237+
priority_fee: z.coerce.bigint().nullable(),
238+
transaction_fee: z.coerce.bigint().nullable(),
239+
tips: z.coerce.bigint().nullable(),
240240
compute_units: z.number().nullable(),
241241
duration_nanos: z.number().nullable(),
242-
completed_time_nanos: z.number().nullable(),
242+
completed_time_nanos: z.coerce.bigint().nullable(),
243243
});
244244

245245
export const tpsHistorySchema = z.array(
@@ -360,11 +360,13 @@ export const summarySchema = z.discriminatedUnion("key", [
360360

361361
export const epochNewSchema = z.object({
362362
epoch: z.number(),
363+
start_time_nanos: z.string().nullable(),
364+
end_time_nanos: z.string().nullable(),
363365
start_slot: z.number(),
364366
end_slot: z.number(),
365-
excluded_stake_lamports: z.number(),
367+
excluded_stake_lamports: z.coerce.bigint(),
366368
staked_pubkeys: z.string().array(),
367-
staked_lamports: z.number().array(),
369+
staked_lamports: z.coerce.bigint().array(),
368370
leader_slots: z.number().array(),
369371
});
370372

@@ -385,7 +387,7 @@ const peerUpdateGossipSchema = z.object({
385387

386388
const peerUpdateVoteAccountSchema = z.object({
387389
vote_account: z.string(),
388-
activated_stake: z.number(),
390+
activated_stake: z.coerce.bigint(),
389391
last_vote: z.nullable(z.number()),
390392
root_slot: z.nullable(z.number()),
391393
epoch_credits: z.number(),
@@ -425,7 +427,7 @@ export const peersSchema = z.discriminatedUnion("key", [
425427
]);
426428

427429
const tsTileTimersSchema = z.object({
428-
timestamp_nanos: z.number(),
430+
timestamp_nanos: z.string(),
429431
tile_timers: z.number().array(),
430432
});
431433

src/api/useSetAtomWsData.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function useSetAtomWsData() {
7474

7575
const [uptime, setUptime] = useAtom(uptimeAtom);
7676
const uptimeMins =
77-
uptime !== undefined ? uptime.uptimeNanos / minuteNanos : undefined;
77+
uptime !== undefined ? Number(uptime.uptimeNanos) / minuteNanos : undefined;
7878

7979
const setEstimatedSlotDuration = useSetAtom(estimatedSlotDurationAtom);
8080
const setDbEstimatedSlotDuration = useThrottledCallback(

src/atoms.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,17 @@ export const peerStatsAtom = atom((get) => {
381381
(stake, p) =>
382382
p.vote.reduce(
383383
(acc, v) => (v.delinquent ? acc : acc + v.activated_stake),
384-
0,
384+
0n,
385385
) + stake,
386-
0,
386+
0n,
387387
);
388388
const delinquentStake = activePeers.reduce(
389389
(stake, p) =>
390390
p.vote.reduce(
391391
(acc, v) => (v.delinquent ? acc + v.activated_stake : acc),
392-
0,
392+
0n,
393393
) + stake,
394-
0,
394+
0n,
395395
);
396396

397397
return {
@@ -420,8 +420,13 @@ export const myStakePctAtom = atom((get) => {
420420
const stake = get(myStakeAmountAtom);
421421

422422
if (stake === undefined || !peerStats) return;
423+
if (!(peerStats.activeStake + peerStats.delinquentStake)) return;
423424

424-
return (stake / (peerStats.activeStake + peerStats.delinquentStake)) * 100;
425+
return (
426+
(Number(stake) /
427+
Number(peerStats.activeStake + peerStats.delinquentStake)) *
428+
100
429+
);
425430
});
426431

427432
export const allLeaderNamesAtom = atom((get) => {

src/features/Gossip/Grid.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ColDef,
1010
GetRowIdParams,
1111
ModuleRegistry,
12+
ValueFormatterParams,
1213
} from "@ag-grid-community/core";
1314
import { ClientSideRowModelModule } from "@ag-grid-community/client-side-row-model";
1415
import { CsvExportModule } from "@ag-grid-community/csv-export";
@@ -38,7 +39,7 @@ interface PeerRow {
3839
pubkey: string;
3940
name?: string | null;
4041
description?: string | null;
41-
stake?: number | null;
42+
stake?: bigint | null;
4243
delinquent?: boolean | null;
4344
lastVote?: number | null;
4445
rootSlot?: number | null;
@@ -48,14 +49,21 @@ const colDefs: ColDef<PeerRow>[] = [
4849
{
4950
field: "pubkey",
5051
initialWidth: 300,
51-
cellStyle: (params) => {
52+
cellStyle: (params: ValueFormatterParams<PeerRow, string>) => {
5253
return { color: params.data?.delinquent ? "#6D6F71" : "#B2BCC9" };
5354
},
5455
filter: true,
5556
},
5657
{ field: "name", initialWidth: 300, filter: true },
5758
{ field: "description", initialWidth: 500, filter: true },
58-
{ field: "stake", initialSort: "desc", initialWidth: 180, filter: true },
59+
{
60+
field: "stake",
61+
initialSort: "desc",
62+
initialWidth: 180,
63+
filter: true,
64+
valueFormatter: (params: ValueFormatterParams<PeerRow, bigint>) =>
65+
params.value?.toString() ?? "",
66+
},
5967
{ field: "delinquent", initialWidth: 110, filter: true },
6068
{ field: "lastVote", initialWidth: 110, filter: true },
6169
{ field: "rootSlot", initialWidth: 110, filter: true },

src/features/Header/DropDownNavLinks.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function DropDownNavLinks({ children }: PropsWithChildren) {
2929
</Button>
3030
)}
3131
</DropdownMenu.Trigger>
32-
<DropdownMenu.Portal container={containerEl} >
32+
<DropdownMenu.Portal container={containerEl}>
3333
<DropdownMenu.Content className={styles.content} sideOffset={5}>
3434
<DropdownMenu.Item className={styles.item}>
3535
<NavLink to="/" label="Overview" />

src/features/Header/IdentityKey.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function Commission() {
182182
const { peer } = useIdentityPeer();
183183

184184
const maxCommission = peer?.vote.reduce<{
185-
maxStake: number;
185+
maxStake: bigint;
186186
commission?: number;
187187
}>(
188188
(acc, vote) => {
@@ -191,7 +191,7 @@ function Commission() {
191191
}
192192
return acc;
193193
},
194-
{ maxStake: 0, commission: undefined },
194+
{ maxStake: 0n, commission: undefined },
195195
);
196196

197197
return (
@@ -212,7 +212,9 @@ function Uptime() {
212212
const getValue = () => {
213213
if (!uptime) return "-";
214214

215-
const uptimeDuration = Duration.fromMillis(uptime.uptimeNanos / 1_000_000);
215+
const uptimeDuration = Duration.fromMillis(
216+
Number(uptime.uptimeNanos) / 1_000_000,
217+
);
216218
const diffDuration = slowDateTimeNow.diff(uptime.ts);
217219

218220
const text = getTimeTillText(uptimeDuration.plus(diffDuration).rescale(), {

src/features/LeaderSchedule/Slots/CardValidatorSummary.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,17 @@ export function CardValidatorSummaryMobile({
116116

117117
function getStakeMsg(
118118
peer?: Peer,
119-
activeStake?: number,
120-
delinquentStake?: number,
119+
activeStake?: bigint,
120+
delinquentStake?: bigint,
121121
) {
122122
if (!peer) return;
123123

124124
const stake = getStake(peer);
125125
const pct =
126126
activeStake !== undefined || delinquentStake !== undefined
127-
? (stake / ((activeStake ?? 0) + (delinquentStake ?? 0))) * 100
127+
? (Number(stake) /
128+
Number((activeStake ?? 0n) + (delinquentStake ?? 0n))) *
129+
100
128130
: undefined;
129131

130132
return `${getFmtStake(stake)} ${
@@ -201,7 +203,7 @@ function TimeAgo({ slot, showTime }: CardValidatorSummaryProps) {
201203
if (!query.publish?.completed_time_nanos) return;
202204

203205
return DateTime.fromMillis(
204-
Math.trunc(query.publish?.completed_time_nanos / 1_000_000),
206+
Math.trunc(Number(query.publish?.completed_time_nanos) / 1_000_000),
205207
);
206208
}, [query.publish]);
207209

src/features/LeaderSchedule/Slots/SlotCardGrid.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function getRowValues(publish: SlotPublish): RowValues {
184184
const totalTxns = fixValue(publish.transactions ?? 0);
185185
const nonVoteTxns = totalTxns - voteTxns;
186186
const totalFees = formatNumberLamports(
187-
(publish.transaction_fee ?? 0) + (publish.priority_fee ?? 0),
187+
(publish.transaction_fee ?? 0n) + (publish.priority_fee ?? 0n),
188188
3,
189189
{
190190
decimals: 3,
@@ -194,20 +194,22 @@ function getRowValues(publish: SlotPublish): RowValues {
194194

195195
const transactionFeeFull =
196196
publish.transaction_fee != null
197-
? (publish.transaction_fee / lamportsPerSol).toString()
197+
? (Number(publish.transaction_fee) / lamportsPerSol).toString()
198198
: "0";
199199

200200
const priorityFeeFull =
201201
publish.priority_fee != null
202-
? (publish.priority_fee / lamportsPerSol).toString()
202+
? (Number(publish.priority_fee) / lamportsPerSol).toString()
203203
: "0";
204204

205-
const tips = formatNumberLamports(publish.tips ?? 0, 3, {
205+
const tips = formatNumberLamports(publish.tips ?? 0n, 3, {
206206
decimals: 3,
207207
trailingZeroes: true,
208208
});
209209
const tipsFull =
210-
publish.tips != null ? (publish.tips / lamportsPerSol).toString() : "0";
210+
publish.tips != null
211+
? (Number(publish.tips) / lamportsPerSol).toString()
212+
: "0";
211213

212214
const durationText =
213215
publish.duration_nanos !== null

0 commit comments

Comments
 (0)