Skip to content

Commit

Permalink
Add support for array format in account import and export (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
moshthepitt authored Jan 29, 2021
1 parent efcc69a commit f0386ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/components/AddAccountDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormGroup from '@material-ui/core/FormGroup';
import Switch from '@material-ui/core/Switch';
import { Account } from '@solana/web3.js';
import * as bs58 from 'bs58';
import DialogForm from './DialogForm';

export default function AddAccountDialog({ open, onAdd, onClose }) {
Expand Down Expand Up @@ -83,9 +82,14 @@ export default function AddAccountDialog({ open, onAdd, onClose }) {
);
}

/**
* Returns an account object when given the private key
*
* @param {string} privateKey - the private key in array format
*/
function decodeAccount(privateKey) {
try {
const a = new Account(bs58.decode(privateKey));
const a = new Account(JSON.parse(privateKey));
return a;
} catch (_) {
return undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/components/ExportAccountDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ 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);
const keyOutput = `[${Array.from(wallet.provider.account.secretKey)}]`;

return (
<DialogForm open={open} onClose={onClose} fullWidth>
Expand All @@ -24,7 +24,7 @@ export default function ExportAccountDialog({ open, onClose }) {
type={isHidden && 'password'}
variant="outlined"
margin="normal"
value={bs58.encode(wallet.provider.account.secretKey)}
value={keyOutput}
/>
<FormControlLabel
control={
Expand Down

4 comments on commit f0386ce

@barthy46
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you serious ? you change something and now i cant transfer coins from the sollet.io. and just on time for +10% on bitcoins nice work man

@armaniferrante
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barthy46 I'm sorry for your problems but they are unrelated to this change. No change to sollet has been deployed for 21 days https://github.com/project-serum/spl-token-wallet/deployments.

@barthy46
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @armaniferrante so maybe you can explain to me why today i cant transfert USDC from sollet.io to Binance (error name = Non-base58 character) or SOL (error name = failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1) ? yesterday the system have no issues.

@pnzfox
Copy link

@pnzfox pnzfox commented on f0386ce Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you serious ? now i cant import my private key !!!

Please sign in to comment.