1import create from 'zustand';
2import { L2Point, PendingTransaction } from '@urbit/roller-api/build';
4import { HOUR } from 'lib/utils/roller';
5import { Invite } from 'types/Invite';
7export const isL2 = (dom?: string) => dom === 'l2' || dom === 'spawn';
9export interface RollerStore {
10 nextBatchTime: number;
12 pendingTransactions: PendingTransaction[];
13 currentPoint: L2Point | null;
16 recentlyCompleted: number;
17 setNextBatchTime: (nextBatchTime: number) => void;
18 setNextRoll: (nextRoll: string) => void;
19 setPendingTransactions: (pendingTransactions: PendingTransaction[]) => void;
20 setCurrentPoint: (currentPoint: L2Point) => void;
21 setInvites: (invites: Invite[]) => void;
24export const useRollerStore = create<RollerStore>(set => ({
25 nextBatchTime: new Date().getTime() + HOUR,
26 nextRoll: '0h 00m 00s',
27 pendingTransactions: [],
32 setNextBatchTime: (nextBatchTime: number) => set(() => ({ nextBatchTime })),
33 setNextRoll: (nextRoll: string) => set(() => ({ nextRoll })),
34 setPendingTransactions: (pendingTransactions: PendingTransaction[]) =>
36 const oldPending = state.pendingTransactions.length;
37 if (oldPending > 0 && pendingTransactions.length === 0) {
41 recentlyCompleted: oldPending,
44 return { ...state, pendingTransactions };
46 setCurrentPoint: (currentPoint: L2Point) =>
49 currentL2: isL2(currentPoint?.dominion),
51 setInvites: (invites: Invite[]) => set(() => ({ invites })),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list