@@ -20,7 +20,7 @@ export const EMPTY_POINT = new Point({
2020 address: '',
2121});
2222
23−export interface RollerStore {
23+export interface RollerState {
2424 loading: boolean;
2525 nextQuotaTime: number;
2626 pendingTransactions: PendingTransaction[];
@@ -31,6 +31,9 @@ export interface RollerStore {
3131 modalText?: string;
3232 recentlyCompleted: number;
3333 ethBalance: BN;
34+}
35+
36+export interface RollerActions {
3437 setLoading: (loading: boolean) => void;
3538 setModalText: (modalText: string) => void;
3639 setNextQuotaTime: (nextQuotaTime: number) => void;
@@ -41,9 +44,10 @@ export interface RollerStore {
4144 storePendingL1Txn: (txn: PendingL1Txn) => void;
4245 deletePendingL1Txn: (txn: PendingL1Txn) => void;
4346 setEthBalance: (ethBalance: BN) => void;
47+ resetStore: () => void;
4448}
4549
46−export const useRollerStore = create<RollerStore>(set => ({
50+const initialRollerState: RollerState = {
4751 loading: false,
4852 nextQuotaTime: new Date().getTime() + 24 * HOUR,
4953 pendingTransactions: [],
@@ -53,6 +57,10 @@ export const useRollerStore = create<RollerStore>(set => ({
5357 pendingL1ByPoint: {},
5458 recentlyCompleted: 0,
5559 ethBalance: toBN(0),
60+};
61+
62+export const useRollerStore = create<RollerState & RollerActions>(set => ({
63+ ...initialRollerState,
5664 setLoading: (loading: boolean) => set(() => ({ loading })),
5765 setNextQuotaTime: (nextQuotaTime: number) => set(() => ({ nextQuotaTime })),
5866 setPendingTransactions: (pendingTransactions: PendingTransaction[]) =>
@@ -92,4 +100,7 @@ export const useRollerStore = create<RollerStore>(set => ({
92100 return { pendingL1ByPoint: newPending };
93101 }),
94102 setEthBalance: (ethBalance: BN) => set(() => ({ ethBalance })),
103+ resetStore: () => {
104+ set(initialRollerState);
105+ },
95106}));