Revert "Export accounts (#30)"

This reverts commit cf933d1c06.
This commit is contained in:
Nathaniel Parke 2020-11-10 09:16:02 +08:00 committed by GitHub
parent cf933d1c06
commit cb0b061616
4 changed files with 14 additions and 81 deletions

View File

@ -16,7 +16,7 @@ export default function AddAccountDialog({ open, onAdd, onClose }) {
const [isImport, setIsImport] = useState(false);
const [importedPrivateKey, setPrivateKey] = useState('');
const importedAccount = decodeAccount(importedPrivateKey);
const importedAccount = isImport ? decodeAccount(importedPrivateKey) : undefined;
const isAddEnabled = isImport ? name && importedAccount !== undefined : name;
return (

View File

@ -30,7 +30,6 @@ import IconButton from '@material-ui/core/IconButton';
import InfoIcon from '@material-ui/icons/InfoOutlined';
import Tooltip from '@material-ui/core/Tooltip';
import AddTokenDialog from './AddTokenDialog';
import ExportAccountDialog from './ExportAccountDialog';
import SendDialog from './SendDialog';
import DepositDialog from './DepositDialog';
import {
@ -158,7 +157,6 @@ function BalanceListItemDetails({ publicKey, balanceInfo }) {
const [sendDialogOpen, setSendDialogOpen] = useState(false);
const [depositDialogOpen, setDepositDialogOpen] = useState(false);
const [tokenInfoDialogOpen, setTokenInfoDialogOpen] = useState(false);
const [exportAccDialogOpen, setExportAccDialogOpen] = useState(false);
const [
closeTokenAccountDialogOpen,
setCloseTokenAccountDialogOpen,
@ -170,16 +168,8 @@ function BalanceListItemDetails({ publicKey, balanceInfo }) {
let { mint, tokenName, tokenSymbol, owner, amount } = balanceInfo;
// Only show the export UI for the native SOL coin.
const exportNeedsDisplay =
mint === null && tokenName === 'SOL' && tokenSymbol === 'SOL';
return (
<>
<ExportAccountDialog
onClose={() => setExportAccDialogOpen(false)}
open={exportAccDialogOpen}
/>
<div className={classes.itemDetails}>
<div className={classes.buttonContainer}>
{!publicKey.equals(owner) && showTokenInfoDialog ? (
@ -234,31 +224,18 @@ function BalanceListItemDetails({ publicKey, balanceInfo }) {
Token Address: {mint.toBase58()}
</Typography>
) : null}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Typography variant="body2">
<Link
href={
`https://explorer.solana.com/account/${publicKey.toBase58()}` +
urlSuffix
}
target="_blank"
rel="noopener"
>
View on Solana Explorer
</Link>
</Typography>
</div>
{exportNeedsDisplay && (
<div>
<Typography variant="body2">
<Link href={'#'} onClick={(e) => setExportAccDialogOpen(true)}>
Export
</Link>
</Typography>
</div>
)}
</div>
<Typography variant="body2">
<Link
href={
`https://explorer.solana.com/account/${publicKey.toBase58()}` +
urlSuffix
}
target="_blank"
rel="noopener"
>
View on Solana Explorer
</Link>
</Typography>
</div>
<SendDialog
open={sendDialogOpen}

View File

@ -1,44 +0,0 @@
import React, { useState } from 'react';
import Button from '@material-ui/core/Button';
import DialogActions from '@material-ui/core/DialogActions';
import DialogTitle from '@material-ui/core/DialogTitle';
import DialogContent from '@material-ui/core/DialogContent';
import TextField from '@material-ui/core/TextField';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import Switch from '@material-ui/core/Switch';
import * as bs58 from 'bs58';
import DialogForm from './DialogForm';
import { useWallet } from '../utils/wallet';
export default function ExportAccountDialog({ open, onClose }) {
const wallet = useWallet();
const [isHidden, setIsHidden] = useState(true);
return (
<DialogForm open={open} onClose={onClose} fullWidth>
<DialogTitle>Export account</DialogTitle>
<DialogContent>
<TextField
label="Private key"
fullWidth
type={isHidden && 'password'}
variant="outlined"
margin="normal"
value={bs58.encode(wallet.account.secretKey)}
/>
<FormControlLabel
control={
<Switch
checked={!isHidden}
onChange={() => setIsHidden(!isHidden)}
/>
}
label="Reveal"
/>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>Close</Button>
</DialogActions>
</DialogForm>
);
}

View File

@ -311,7 +311,7 @@ export function useWalletSelector() {
function addAccount({ name, importedAccount }) {
if (importedAccount === undefined) {
name && localStorage.setItem(`name${walletCount + 1}`, name);
name && localStorage.setItem(`name${walletCount}`, name);
setWalletCount(walletCount + 1);
} else {
const nonce = nacl.randomBytes(nacl.secretbox.nonceLength);