* Logout ability

* Logout for private key imports

Co-authored-by: armaniferrante <armaniferrante@gmail.com>
This commit is contained in:
philippe-ftx 2020-11-11 11:33:14 +01:00 committed by GitHub
parent 086f6e2763
commit acfe5a7faa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -9,9 +9,11 @@ import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from '@material-ui/core/MenuItem';
import { clusterApiUrl } from '@solana/web3.js'; import { clusterApiUrl } from '@solana/web3.js';
import { useWalletSelector } from '../utils/wallet'; import { useWalletSelector } from '../utils/wallet';
import { forgetWallet } from '../utils/wallet-seed';
import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemIcon from '@material-ui/core/ListItemIcon';
import CheckIcon from '@material-ui/icons/Check'; import CheckIcon from '@material-ui/icons/Check';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import ExitToApp from '@material-ui/icons/ExitToApp';
import AccountIcon from '@material-ui/icons/AccountCircle'; import AccountIcon from '@material-ui/icons/AccountCircle';
import Divider from '@material-ui/core/Divider'; import Divider from '@material-ui/core/Divider';
import Hidden from '@material-ui/core/Hidden'; import Hidden from '@material-ui/core/Hidden';
@ -210,6 +212,12 @@ function WalletSelector() {
</ListItemIcon> </ListItemIcon>
Add Account Add Account
</MenuItem> </MenuItem>
<MenuItem onClick={forgetWallet}>
<ListItemIcon className={classes.menuItemIcon}>
<ExitToApp fontSize="small" />
</ListItemIcon>
Logout
</MenuItem>
</Menu> </Menu>
</> </>
); );

View File

@ -130,3 +130,14 @@ function deriveImportsEncryptionKey(seed) {
return bip32.fromSeed(Buffer.from(seed, 'hex')).derivePath("m/10016'/0") return bip32.fromSeed(Buffer.from(seed, 'hex')).derivePath("m/10016'/0")
.privateKey; .privateKey;
} }
export function forgetWallet() {
localStorage.removeItem('walletIndex');
localStorage.removeItem('walletCount');
localStorage.removeItem('walletPrivateKeyImports');
localStorage.removeItem('locked');
localStorage.removeItem('unlocked');
sessionStorage.removeItem('unlocked');
unlockedMnemonicAndSeed = { mnemonic: null, seed: null, importsEncryptionKey: null };
walletSeedChanged.emit('change', unlockedMnemonicAndSeed);
}