Skip to content

Commit

Permalink
fix disconnect import wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopavezi committed Sep 15, 2023
1 parent 79460a2 commit 5b2b17b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/renderer/CustomConnector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export default class CustomConnector extends Connector<any, any> {
localStorage.setItem('privateKey', privateKey);
}

async deletePrivateKey() {
localStorage.removeItem('privateKey');
}

async connect({ chainId }: { chainId?: number } = {}): Promise<
Required<ConnectorData>
> {
Expand Down Expand Up @@ -96,7 +100,7 @@ export default class CustomConnector extends Connector<any, any> {

async disconnect() {
// Clear the private key and provider
this.setPrivateKey(undefined);
this.deletePrivateKey();
this.#provider = undefined;
}
}
4 changes: 3 additions & 1 deletion src/renderer/context/runnerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const RunnerContext = createContext<IRunnerContext>(
export function RunnerContextProvider({
children,
}: RunnerContextProviderProps) {
const { connector, connectors } = useConnect();
const { connectors } = useConnect();

const [runningTasks, setRunningTasks] = useState<string[]>([]);
const [logs, setLogs] = useState<Map<string, string[]>>(new Map());
Expand All @@ -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();

Expand All @@ -45,6 +46,7 @@ export function RunnerContextProvider({
method: 'eth_private_key',
});
}

window.electron.ipcRenderer.sendMessage('ipc', [
'join',
task.address,
Expand Down

0 comments on commit 5b2b17b

Please sign in to comment.