Skip to content

Commit

Permalink
Merge pull request #51 from casper-ecosystem/hotfix/Correct-Represent…
Browse files Browse the repository at this point in the history
…ation-Of-Keys

Hotfix/correct representation of keys
  • Loading branch information
George-cl authored May 3, 2021
2 parents 46eb995 + 16b35c7 commit d5fc914
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "casperlabs-signer",
"version": "0.3.8",
"version": "0.3.9",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-free": "^5.13.0",
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 2,
"version": "0.3.8",
"version": "0.3.9",
"name": "CasperLabs Signer",
"author": "https://casperlabs.io",
"description": "CasperLabs Signer tool for signing transactions on the blockchain.",
Expand Down
27 changes: 16 additions & 11 deletions src/popup/components/AccountManagementPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Dialog from '@material-ui/core/Dialog';
import { confirm } from './Confirmation';
import copy from 'copy-to-clipboard';
import Pages from './Pages';
import { decodeBase64, encodeBase16, Keys, PublicKey } from 'casper-client-sdk';

// interface Item {
// id: string;
Expand All @@ -56,19 +57,24 @@ interface Props {
}

export const AccountManagementPage = observer((props: Props) => {
const history = useHistory();

const [openDialog, setOpenDialog] = React.useState(false);
const [openKeyDialog, setOpenKeyDialog] = React.useState(false);
const [
selectedAccount,
setSelectedAccount
] = React.useState<SignKeyPairWithAlias | null>(null);
const [name, setName] = React.useState('');
const [publicKey64, setPublicKey64] = React.useState('');
const [publicKeyHex, setPublicKeyHex] = React.useState('');
/* Note: 01 prefix denotes algorithm used in key generation */
const address = '01' + publicKeyHex;
const [copyStatus, setCopyStatus] = React.useState(false);
const history = useHistory();
const [publicKey64, setPublicKey64] = React.useState('');

// Currently only supports ED25519 keys will soon be extended to support SECP256k1 keys.
const publicKey = PublicKey.from(
decodeBase64(publicKey64),
Keys.SignatureAlgorithm.Ed25519
);
const accountHash = encodeBase16(publicKey.toAccountHash());

const handleClickOpen = (account: SignKeyPairWithAlias) => {
setOpenDialog(true);
Expand All @@ -80,10 +86,8 @@ export const AccountManagementPage = observer((props: Props) => {
let publicKey64 = await props.authContainer.getSelectedAccountKey(
accountName
);
let publicKeyHex = await props.authContainer.getPublicKeyHex(accountName);
setName(accountName);
setPublicKey64(publicKey64);
setPublicKeyHex(publicKeyHex);
setOpenKeyDialog(true);
};

Expand All @@ -103,6 +107,7 @@ export const AccountManagementPage = observer((props: Props) => {
const handleUpdateName = () => {
if (selectedAccount) {
props.authContainer.renameUserAccount(selectedAccount.name, name);
props.authContainer.switchToAccount(name);
handleClose();
}
};
Expand Down Expand Up @@ -266,29 +271,29 @@ export const AccountManagementPage = observer((props: Props) => {
<IconButton
edge={'start'}
onClick={() => {
copy(address);
copy(publicKey.toAccountHex());
setCopyStatus(true);
}}
>
<FilterNoneIcon />
</IconButton>
<ListItemText
primary={'Address: ' + address}
primary={'Public Key: ' + publicKey.toAccountHex()}
style={{ overflowWrap: 'break-word' }}
/>
</ListItem>
<ListItem>
<IconButton
edge={'start'}
onClick={() => {
copy(publicKey64);
copy(accountHash);
setCopyStatus(true);
}}
>
<FilterNoneIcon />
</IconButton>
<ListItemText
primary={'Public Key: ' + publicKey64}
primary={'Account Hash: ' + accountHash}
style={{ overflowWrap: 'break-word' }}
/>
</ListItem>
Expand Down

0 comments on commit d5fc914

Please sign in to comment.