Skip to content

Commit cdca40c

Browse files
feat: add quick select list options
1 parent 54ea8f5 commit cdca40c

File tree

12 files changed

+477
-289
lines changed

12 files changed

+477
-289
lines changed

src/api/atoms.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type {
2323
BlockEngineUpdate,
2424
VoteBalance,
2525
ScheduleStrategy,
26+
SlotRankings,
2627
} from "./types";
2728
import { rafAtom } from "../atomUtils";
2829

@@ -85,3 +86,5 @@ export const voteDistanceAtom = atom<VoteDistance | undefined>(undefined);
8586
export const skippedSlotsAtom = atom<SkippedSlots | undefined>(undefined);
8687

8788
export const blockEngineAtom = atom<BlockEngineUpdate | undefined>(undefined);
89+
90+
export const slotRankingsAtom = atom<SlotRankings | undefined>(undefined);

src/api/entities.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,33 @@ export const slotResponseSchema = z.object({
474474

475475
export const slotSkippedHistorySchema = z.number().array();
476476

477+
export const slotRankingsSchema = z.object({
478+
slots_largest_tips: z.number().array(),
479+
vals_largest_tips: z.coerce.bigint().array(),
480+
slots_smallest_tips: z.number().array(),
481+
vals_smallest_tips: z.coerce.bigint().array(),
482+
slots_largest_fees: z.number().array(),
483+
vals_largest_fees: z.coerce.bigint().array(),
484+
slots_smallest_fees: z.number().array(),
485+
vals_smallest_fees: z.coerce.bigint().array(),
486+
slots_largest_rewards: z.number().array(),
487+
vals_largest_rewards: z.coerce.bigint().array(),
488+
slots_smallest_rewards: z.number().array(),
489+
vals_smallest_rewards: z.coerce.bigint().array(),
490+
slots_largest_duration: z.number().array(),
491+
vals_largest_duration: z.coerce.bigint().array(),
492+
slots_smallest_duration: z.number().array(),
493+
vals_smallest_duration: z.coerce.bigint().array(),
494+
slots_largest_compute_units: z.number().array(),
495+
vals_largest_compute_units: z.coerce.bigint().array(),
496+
slots_smallest_compute_units: z.number().array(),
497+
vals_smallest_compute_units: z.coerce.bigint().array(),
498+
slots_largest_skipped: z.number().array(),
499+
vals_largest_skipped: z.coerce.bigint().array(),
500+
slots_smallest_skipped: z.number().array(),
501+
vals_smallest_skipped: z.coerce.bigint().array(),
502+
});
503+
477504
export const slotSchema = z.discriminatedUnion("key", [
478505
slotTopicSchema.extend({
479506
key: z.literal("skipped_history"),
@@ -487,6 +514,10 @@ export const slotSchema = z.discriminatedUnion("key", [
487514
key: z.literal("query"),
488515
value: slotResponseSchema.nullable(),
489516
}),
517+
slotTopicSchema.extend({
518+
key: z.literal("query_rankings"),
519+
value: slotRankingsSchema,
520+
}),
490521
]);
491522

492523
export const blockEngineStatusSchema = z.enum([

src/api/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import type {
4040
slotTransactionsSchema,
4141
voteBalanceSchema,
4242
scheduleStrategySchema,
43+
slotRankingsSchema,
4344
} from "./entities";
4445

4546
export type Client = z.infer<typeof clientSchema>;
@@ -131,3 +132,5 @@ export type SkippedSlots = z.infer<typeof slotSkippedHistorySchema>;
131132
export type BlockEngineUpdate = z.infer<typeof blockEngineUpdateSchema>;
132133

133134
export type BlockEngineStatus = z.infer<typeof blockEngineStatusSchema>;
135+
136+
export type SlotRankings = z.infer<typeof slotRankingsSchema>;

src/api/useSetAtomWsData.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
voteStateAtom,
2121
voteBalanceAtom,
2222
scheduleStrategyAtom,
23+
slotRankingsAtom,
2324
} from "./atoms";
2425
import {
2526
blockEngineSchema,
@@ -130,6 +131,7 @@ export function useSetAtomWsData() {
130131

131132
const setSkippedSlots = useSetAtom(skippedSlotsAtom);
132133
const setSlotResponse = useSetAtom(setSlotResponseAtom);
134+
const setSlotRankings = useSetAtom(slotRankingsAtom);
133135

134136
const [epoch, setEpoch] = useAtom(epochAtom);
135137

@@ -280,6 +282,10 @@ export function useSetAtomWsData() {
280282
}
281283
break;
282284
}
285+
case "query_rankings": {
286+
setSlotRankings(value);
287+
break;
288+
}
283289
}
284290
} else if (topic === "block_engine") {
285291
const { key, value } = blockEngineSchema.parse(msg);

src/atoms.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -288,28 +288,30 @@ export const firstProcessedSlotAtom = atom((get) => {
288288
return startupProgress.ledger_max_slot + 1;
289289
});
290290

291-
export const earliestProcessedSlotLeaderAtom = atom((get) => {
292-
const firstProcessedSlot = get(firstProcessedSlotAtom);
291+
export const firstProcessedLeaderIndexAtom = atom((get) => {
293292
const leaderSlots = get(leaderSlotsAtom);
293+
const firstProcessedSlot = get(firstProcessedSlotAtom);
294294

295-
if (firstProcessedSlot === undefined || !leaderSlots?.length) return;
296-
return leaderSlots.find((s) => s >= firstProcessedSlot);
295+
if (!leaderSlots || firstProcessedSlot === undefined) return;
296+
297+
const leaderIndex = leaderSlots.findIndex((s) => s >= firstProcessedSlot);
298+
return leaderIndex !== -1 ? leaderIndex : undefined;
297299
});
298300

299-
export const mostRecentSlotLeaderAtom = atom((get) => {
300-
const earliestProcessedSlotLeader = get(earliestProcessedSlotLeaderAtom);
301+
export const firstProcessedLeaderAtom = atom((get) => {
301302
const leaderSlots = get(leaderSlotsAtom);
302-
const currentLeaderSlot = get(currentLeaderSlotAtom);
303-
304-
if (
305-
earliestProcessedSlotLeader === undefined ||
306-
currentLeaderSlot === undefined ||
307-
!leaderSlots?.length
308-
)
309-
return;
310-
return leaderSlots.findLast(
311-
(s) => earliestProcessedSlotLeader <= s && s <= currentLeaderSlot,
312-
);
303+
const firstProcessedLeaderIndex = get(firstProcessedLeaderIndexAtom);
304+
return firstProcessedLeaderIndex
305+
? leaderSlots?.[firstProcessedLeaderIndex]
306+
: undefined;
307+
});
308+
309+
export const lastProcessedLeaderAtom = atom((get) => {
310+
const leaderSlots = get(leaderSlotsAtom);
311+
const nextLeaderSlotIndex = get(nextLeaderSlotIndexAtom);
312+
return nextLeaderSlotIndex
313+
? leaderSlots?.[nextLeaderSlotIndex - 1]
314+
: undefined;
313315
});
314316

315317
const _currentSlotAtom = atom<number | undefined>(undefined);

src/colors.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,15 @@ export const circularProgressPathColor = slotStatusBlue;
164164

165165
// slot details
166166
export const slotDetailsMySlotsColor = "#0080e6";
167-
export const slotDetailsQuickSearchTextPrimaryColor = "#cecece";
168-
export const slotDetailsQuickSearchTextSecondaryColor = "#646464";
169-
export const slotDetailsEarliestSlotColor = "#00A2C7";
170-
export const slotDetailsMostRecentSlotColor = "#1D863B";
171-
export const slotDetailsLastSkippedSlotColor = "#EB6262";
167+
export const slotDetailsSearchLabelColor = "#FFF";
168+
export const slotDetailsQuickSearchTextColor = "var(--gray-10)";
169+
export const slotDetailsEarliestSlotColor = "var(--teal-9)";
170+
export const slotDetailsRecentSlotColor = "var(--cyan-9)";
171+
export const slotDetailsSkippedSlotColor = "var(--red-8)";
172+
export const slotDetailsFeesSlotColor = "var(--sky-8)";
173+
export const slotDetailsTipsSlotColor = "var(--green-9)";
174+
export const slotDetailsRewardsSlotColor = "var(--indigo-10)";
175+
export const slotDetailsClickableSlotColor = "var(--blue-9)";
172176
export const slotDetailsBackgroundColor = "#15181e";
173177
export const slotDetailsColor = "#9aabc3";
174178
export const slotDetailsSkippedBackgroundColor = "#250f0f";

src/features/Navigation/EpochSlider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
epochAtom,
99
firstProcessedSlotAtom,
1010
leaderSlotsAtom,
11-
mostRecentSlotLeaderAtom,
11+
lastProcessedLeaderAtom,
1212
SlotNavFilter,
1313
slotNavFilterAtom,
1414
slotOverrideAtom,
@@ -228,7 +228,7 @@ function SliderEpochProgress({
228228
setSliderValue: React.Dispatch<React.SetStateAction<number[]>>;
229229
}) {
230230
const epoch = useAtomValue(epochAtom);
231-
const mostRecentSlotLeader = useAtomValue(mostRecentSlotLeaderAtom);
231+
const lastProcessedLeader = useAtomValue(lastProcessedLeaderAtom);
232232
const currentLeaderSlot = useAtomValue(currentLeaderSlotAtom);
233233
const slotOverride = useAtomValue(slotOverrideAtom);
234234
const navFilter = useAtomValue(slotNavFilterAtom);
@@ -270,7 +270,7 @@ function SliderEpochProgress({
270270
})
271271
: navFilter === SlotNavFilter.MySlots
272272
? slotToEpochPct({
273-
slot: mostRecentSlotLeader,
273+
slot: lastProcessedLeader,
274274
epochStartSlot: epoch?.start_slot,
275275
epochEndSlot: epoch?.end_slot,
276276
})
@@ -288,7 +288,7 @@ function SliderEpochProgress({
288288
setSliderValue,
289289
slotOverride,
290290
navFilter,
291-
mostRecentSlotLeader,
291+
lastProcessedLeader,
292292
]);
293293

294294
return (

0 commit comments

Comments
 (0)