Unlock error display (#373)

* Unlock error display

* Bumps
This commit is contained in:
Jaco Greeff 2020-06-24 10:54:23 +02:00 committed by GitHub
parent b7176010a5
commit e9fe113b29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 350 additions and 282 deletions

View File

@ -8,11 +8,11 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^1.18.0-beta.7",
"@polkadot/keyring": "^2.13.0-beta.3",
"@polkadot/types": "^1.18.0-beta.7",
"@polkadot/util": "^2.13.0-beta.3",
"@polkadot/util-crypto": "^2.13.0-beta.3",
"@polkadot/api": "^1.20.0-beta.3",
"@polkadot/keyring": "^2.14.1",
"@polkadot/types": "^1.20.0-beta.3",
"@polkadot/util": "^2.14.1",
"@polkadot/util-crypto": "^2.14.1",
"babel-core": "^7.0.0-bridge.0"
},
"scripts": {
@ -32,8 +32,8 @@
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@polkadot/dev": "^0.55.8",
"@polkadot/typegen": "^1.18.0-beta.7",
"@polkadot/dev": "^0.55.10",
"@polkadot/typegen": "^1.20.0-beta.3",
"@types/jest": "^25.2.3",
"copy-webpack-plugin": "^6.0.2",
"sinon-chrome": "^3.0.1",

View File

@ -6,9 +6,9 @@
"license": "Apache-2",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/api": "^1.18.0-beta.7",
"@polkadot/api": "^1.20.0-beta.3",
"@polkadot/extension-inject": "0.30.1",
"@polkadot/keyring": "^2.13.0-beta.3",
"@polkadot/ui-keyring": "^0.54.0-beta.6"
"@polkadot/keyring": "^2.14.1",
"@polkadot/ui-keyring": "^0.54.1"
}
}

View File

@ -7,8 +7,8 @@
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/extension-inject": "0.30.1",
"@polkadot/util": "^2.13.0-beta.3",
"@polkadot/util-crypto": "^2.13.0-beta.3"
"@polkadot/util": "^2.14.1",
"@polkadot/util-crypto": "^2.14.1"
},
"peerDependencies": {
"@polkadot/api": "*"

View File

@ -8,11 +8,11 @@
"@babel/runtime": "^7.10.2",
"@polkadot/extension-base": "0.30.1",
"@polkadot/extension-inject": "0.30.1",
"@polkadot/keyring": "^2.13.0-beta.3",
"@polkadot/react-identicon": "^0.54.0-beta.6",
"@polkadot/react-qr": "^0.54.0-beta.6",
"@polkadot/util": "^2.13.0-beta.3",
"@polkadot/util-crypto": "^2.13.0-beta.3",
"@polkadot/keyring": "^2.14.1",
"@polkadot/react-identicon": "^0.54.1",
"@polkadot/react-qr": "^0.54.1",
"@polkadot/util": "^2.14.1",
"@polkadot/util-crypto": "^2.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-dropzone": "^11.0.1",

View File

@ -33,7 +33,7 @@ function AddAccount ({ className }: Props): React.ReactElement<Props> {
<AddAccountImage onClick={_onClick}/>
</div>
<div className='no-accounts'>
<p>You currently don&apos;t have any accounts. Either create a new account or if you have an existing account you wish to use, import it with the seed phrase.</p>
<p>You currently don&apos;t have any accounts. Create your first account to get started.</p>
</div>
</div>
</>

View File

@ -11,13 +11,13 @@ import { Header, Name } from '../partials';
export default function ImportQr (): React.ReactElement {
const onAction = useContext(ActionContext);
const [account, setAccount] = useState<null | { address: string; genesisHash: string }>(null);
const [account, setAccount] = useState<null | { content: string; genesisHash: string }>(null);
const [name, setName] = useState<string | null>(null);
// FIXME Duplicated between here and Create.tsx
const _onCreate = (): void => {
if (account && name) {
createAccountExternal(name, account.address, account.genesisHash)
createAccountExternal(name, account.content, account.genesisHash)
.then((): void => onAction('/'))
.catch((error: Error) => console.error(error));
}

View File

@ -41,6 +41,7 @@ function isRawPayload (payload: SignerPayloadJSON | SignerPayloadRaw): payload i
export default function Request ({ account: { isExternal }, buttonText, isFirst, request, signId, url }: Props): React.ReactElement<Props> | null {
const onAction = useContext(ActionContext);
const [{ hexBytes, payload }, setData] = useState<Data>({ hexBytes: null, payload: null });
const [error, setError] = useState<string | null>(null);
useEffect((): void => {
const payload = request.payload;
@ -67,11 +68,17 @@ export default function Request ({ account: { isExternal }, buttonText, isFirst,
const _onSign = (password: string): Promise<void> =>
approveSignPassword(signId, password)
.then((): void => onAction())
.catch((error: Error) => console.error(error));
.catch((error: Error): void => {
setError(error.message);
console.error(error);
});
const _onSignature = ({ signature }: { signature: string }): Promise<void> =>
approveSignSignature(signId, signature)
.then((): void => onAction())
.catch((error: Error) => console.error(error));
.catch((error: Error): void => {
setError(error.message);
console.error(error);
});
if (payload !== null) {
const json = request.payload as SignerPayloadJSON;
@ -104,6 +111,7 @@ export default function Request ({ account: { isExternal }, buttonText, isFirst,
{isFirst && !isExternal && (
<Unlock
buttonText={buttonText}
error={error}
onSign={_onSign}
/>
)}

View File

@ -2,24 +2,29 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import React, { useCallback, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { Button, InputWithLabel } from '../../components';
interface Props {
className?: string;
error?: string | null;
onSign: (password: string) => Promise<void>;
buttonText?: string;
}
export default function Unlock ({ buttonText = 'Sign the transaction', className, onSign }: Props): React.ReactElement<Props> {
const [error, setError] = useState('');
export default function Unlock ({ buttonText = 'Sign the transaction', className, error, onSign }: Props): React.ReactElement<Props> {
const [ownError, setError] = useState<string | null>();
const [password, setPassword] = useState('');
useEffect((): void => {
setError(error || null);
}, [error]);
const _onChangePassword = useCallback(
(password: string): void => {
setPassword(password);
setError('');
setError(null);
},
[]
);
@ -32,7 +37,7 @@ export default function Unlock ({ buttonText = 'Sign the transaction', className
return (
<div className={className}>
<InputWithLabel
isError={!password || !!error}
isError={!password || !!ownError}
isFocused
label='Password for this account'
onChange={_onChangePassword}

View File

@ -38,14 +38,14 @@ export default function Welcome (): React.ReactElement<Props> {
);
}
const Note = styled.p`
const Note = styled.p(({ theme }: Props) => `
color: ${theme.subTextColor};
margin-bottom: 6px;
margin-top: 0;
color: ${({ theme }: Props): string => theme.subTextColor};
`;
`);
const TextBox = styled(Box)`
const TextBox = styled(Box)(({ theme }: Props) => `
border: 1px solid ${theme.inputBorderColor};
color: ${theme.subTextColor};
margin: 0.75rem 24px;
border: 1px solid ${({ theme }: Props): string => theme.inputBorderColor};
color: ${({ theme }: Props): string => theme.subTextColor};
`;
`);

View File

@ -11,7 +11,7 @@
"@polkadot/extension-ui": "0.30.1"
},
"devDependencies": {
"@polkadot/dev": "^0.55.8",
"@polkadot/dev": "^0.55.10",
"babel-loader": "^8.1.0",
"extract-loader": "^5.1.0",
"file-loader": "^6.0.0",

549
yarn.lock

File diff suppressed because it is too large Load Diff