Fix/Clear active public key from local storage after disconnect

This commit is contained in:
Matthew Russell 2022-03-25 00:43:49 -07:00 committed by GitHub
parent ed8db76af7
commit 0af568dada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -21,7 +21,10 @@ export function useEagerConnect() {
// Developer hasn't provided this connector
if (!connector) {
throw new Error(`Connector ${cfgObj?.connector} not configured`);
console.warn(
`Can't eager connect, connector: ${cfgObj.connector} not found`
);
return;
}
connect(Connectors[cfgObj.connector]);

View File

@ -4,6 +4,7 @@ import { VegaKey } from '@vegaprotocol/vegawallet-service-api-client';
import { RestConnector } from './connectors';
import { useVegaWallet } from './hooks';
import { VegaWalletProvider } from './provider';
import { WALLET_KEY } from './storage-keys';
const restConnector = new RestConnector();
@ -93,4 +94,5 @@ test('Can connect, disconnect and retrieve keypairs', async () => {
});
expect(screen.getByTestId('current-keypair')).toBeEmptyDOMElement();
expect(screen.queryByTestId('keypairs-list')).not.toBeInTheDocument();
expect(localStorage.getItem(WALLET_KEY)).toBe(null);
});

View File

@ -67,6 +67,7 @@ export const VegaWalletProvider = ({ children }: VegaWalletProviderProps) => {
await connector.current?.disconnect();
setKeypairs(null);
connector.current = null;
LocalStorage.removeItem(WALLET_KEY);
return true;
} catch (err) {
console.error(err);