From 5b2b17b0c72d6ec81759459f08024e4a57cbc8b3 Mon Sep 17 00:00:00 2001 From: rodrigopavezi Date: Thu, 14 Sep 2023 21:10:09 -0300 Subject: [PATCH] fix disconnect import wallet --- src/renderer/CustomConnector.tsx | 6 +++++- src/renderer/context/runnerContext.tsx | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/renderer/CustomConnector.tsx b/src/renderer/CustomConnector.tsx index 311d5bb..972cf29 100644 --- a/src/renderer/CustomConnector.tsx +++ b/src/renderer/CustomConnector.tsx @@ -44,6 +44,10 @@ export default class CustomConnector extends Connector { localStorage.setItem('privateKey', privateKey); } + async deletePrivateKey() { + localStorage.removeItem('privateKey'); + } + async connect({ chainId }: { chainId?: number } = {}): Promise< Required > { @@ -96,7 +100,7 @@ export default class CustomConnector extends Connector { async disconnect() { // Clear the private key and provider - this.setPrivateKey(undefined); + this.deletePrivateKey(); this.#provider = undefined; } } diff --git a/src/renderer/context/runnerContext.tsx b/src/renderer/context/runnerContext.tsx index d1d4b51..1f327aa 100644 --- a/src/renderer/context/runnerContext.tsx +++ b/src/renderer/context/runnerContext.tsx @@ -20,7 +20,7 @@ export const RunnerContext = createContext( export function RunnerContextProvider({ children, }: RunnerContextProviderProps) { - const { connector, connectors } = useConnect(); + const { connectors } = useConnect(); const [runningTasks, setRunningTasks] = useState([]); const [logs, setLogs] = useState>(new Map()); @@ -36,6 +36,7 @@ export function RunnerContextProvider({ const runTask = async (task: TaskType, file: File) => { setLogs(new Map(logs.set(task.address, []))); + // @ts-ignore let privateKey = await connectors[1].getPrivateKey(); @@ -45,6 +46,7 @@ export function RunnerContextProvider({ method: 'eth_private_key', }); } + window.electron.ipcRenderer.sendMessage('ipc', [ 'join', task.address,