From 303758f1088ac86310c534389e2aea8596c09ed1 Mon Sep 17 00:00:00 2001 From: George-CL Date: Fri, 30 Apr 2021 16:15:25 +0100 Subject: [PATCH 1/4] Bump version to 0.3.9 --- package.json | 2 +- public/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 65e57ae5..595a93bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "casperlabs-signer", - "version": "0.3.8", + "version": "0.3.9", "private": true, "dependencies": { "@fortawesome/fontawesome-free": "^5.13.0", diff --git a/public/manifest.json b/public/manifest.json index 425e91f1..131b2ee1 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -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.", From 46f7346143f59a4dbb30e87c0b2660978ae4aab2 Mon Sep 17 00:00:00 2001 From: George-CL Date: Fri, 30 Apr 2021 16:44:25 +0100 Subject: [PATCH 2/4] Rough fix for key representation --- .../components/AccountManagementPage.tsx | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/popup/components/AccountManagementPage.tsx b/src/popup/components/AccountManagementPage.tsx index cc7e1a1b..71423cbe 100644 --- a/src/popup/components/AccountManagementPage.tsx +++ b/src/popup/components/AccountManagementPage.tsx @@ -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 } from 'casper-client-sdk'; // interface Item { // id: string; @@ -56,6 +57,8 @@ interface Props { } export const AccountManagementPage = observer((props: Props) => { + const history = useHistory(); + const [openDialog, setOpenDialog] = React.useState(false); const [openKeyDialog, setOpenKeyDialog] = React.useState(false); const [ @@ -63,12 +66,15 @@ export const AccountManagementPage = observer((props: Props) => { setSelectedAccount ] = React.useState(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(''); + + // Whilst the prefix is currently hard-coded to 01 (ed25519) this + // will soon be dynamic to support secp256k1 keys. + const publicKey = '01' + encodeBase16(decodeBase64(publicKey64)); + const accountHash = encodeBase16( + Keys.Ed25519.accountHash(decodeBase64(publicKey64)) + ); const handleClickOpen = (account: SignKeyPairWithAlias) => { setOpenDialog(true); @@ -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); }; @@ -266,14 +270,14 @@ export const AccountManagementPage = observer((props: Props) => { { - copy(address); + copy(publicKey); setCopyStatus(true); }} > @@ -281,14 +285,14 @@ export const AccountManagementPage = observer((props: Props) => { { - copy(publicKey64); + copy(accountHash); setCopyStatus(true); }} > From be8d36ef597ebf91a3b7cd4fc16e1ebc0c27db95 Mon Sep 17 00:00:00 2001 From: George-CL Date: Fri, 30 Apr 2021 17:06:47 +0100 Subject: [PATCH 3/4] Convert to PublicKey object for better tooling --- src/popup/components/AccountManagementPage.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/popup/components/AccountManagementPage.tsx b/src/popup/components/AccountManagementPage.tsx index 71423cbe..ff16e222 100644 --- a/src/popup/components/AccountManagementPage.tsx +++ b/src/popup/components/AccountManagementPage.tsx @@ -34,7 +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 } from 'casper-client-sdk'; +import { decodeBase64, encodeBase16, Keys, PublicKey } from 'casper-client-sdk'; // interface Item { // id: string; @@ -69,12 +69,12 @@ export const AccountManagementPage = observer((props: Props) => { const [copyStatus, setCopyStatus] = React.useState(false); const [publicKey64, setPublicKey64] = React.useState(''); - // Whilst the prefix is currently hard-coded to 01 (ed25519) this - // will soon be dynamic to support secp256k1 keys. - const publicKey = '01' + encodeBase16(decodeBase64(publicKey64)); - const accountHash = encodeBase16( - Keys.Ed25519.accountHash(decodeBase64(publicKey64)) + // 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); @@ -270,14 +270,14 @@ export const AccountManagementPage = observer((props: Props) => { { - copy(publicKey); + copy(publicKey.toAccountHex()); setCopyStatus(true); }} > From 16b35c787adaa5a8d60ef4f93371624e29f1b590 Mon Sep 17 00:00:00 2001 From: George-CL Date: Mon, 3 May 2021 00:45:08 +0100 Subject: [PATCH 4/4] Fixes update render --- src/popup/components/AccountManagementPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/popup/components/AccountManagementPage.tsx b/src/popup/components/AccountManagementPage.tsx index ff16e222..11eb531b 100644 --- a/src/popup/components/AccountManagementPage.tsx +++ b/src/popup/components/AccountManagementPage.tsx @@ -107,6 +107,7 @@ export const AccountManagementPage = observer((props: Props) => { const handleUpdateName = () => { if (selectedAccount) { props.authContainer.renameUserAccount(selectedAccount.name, name); + props.authContainer.switchToAccount(name); handleClose(); } };