Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
dashboard: Clean up ganache indexeddb on start
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffoo authored and eggplantzzz committed Jul 14, 2023
1 parent f5a6d77 commit b50c72e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/dashboard/src/contexts/DashContext/DashProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useReducer, useEffect, useRef, useMemo, useCallback } from "react";
import { useAccount, useNetwork } from "wagmi";
import { sha1 } from "object-hash";
import { deleteDB } from "idb/with-async-ittr";
import type { ReceivedMessageLifecycle } from "@truffle/dashboard-message-bus-client";
import {
isCliEventMessage,
Expand Down Expand Up @@ -234,10 +235,18 @@ function DashProvider({ children }: DashProviderProps): JSX.Element {
dispatch({ type: "set-analytics-config", data });
};

const cleanGanacheDb = async () => {
const ganacheDb = await indexedDB.databases();
for (const { name } of ganacheDb) {
if (name?.startsWith("/tmp/ganache_")) await deleteDB(name);
}
};

const init = async () => {
await initDecoder();
await initBusClient();
await initAnalytics();
await cleanGanacheDb();
};

init();
Expand Down

0 comments on commit b50c72e

Please sign in to comment.