Close the no-accounts import (JSON/seed) hole (#388)

* Close the no-accounts import (JSON/seed) hole

* Use accounts (not hierarchy)
This commit is contained in:
Jaco Greeff
2020-07-11 11:25:27 +02:00
committed by GitHub
parent 6bd893096e
commit f4fc547c7e
8 changed files with 286 additions and 204 deletions
+3 -3
View File
@@ -6,9 +6,9 @@
"license": "Apache-2",
"dependencies": {
"@babel/runtime": "^7.10.4",
"@polkadot/api": "^1.23.0-beta.3",
"@polkadot/api": "^1.24.0-beta.2",
"@polkadot/extension-inject": "0.32.0-beta.5",
"@polkadot/keyring": "^2.16.1",
"@polkadot/ui-keyring": "^0.55.0-beta.5"
"@polkadot/keyring": "^2.18.0-beta.3",
"@polkadot/ui-keyring": "^0.56.0-beta.0"
}
}
+2 -2
View File
@@ -7,8 +7,8 @@
"dependencies": {
"@babel/runtime": "^7.10.4",
"@polkadot/extension-inject": "0.32.0-beta.5",
"@polkadot/util": "^2.16.1",
"@polkadot/util-crypto": "^2.16.1"
"@polkadot/util": "^2.18.0-beta.3",
"@polkadot/util-crypto": "^2.18.0-beta.3"
},
"peerDependencies": {
"@polkadot/api": "*"
+5 -5
View File
@@ -8,11 +8,11 @@
"@babel/runtime": "^7.10.4",
"@polkadot/extension-base": "0.32.0-beta.5",
"@polkadot/extension-inject": "0.32.0-beta.5",
"@polkadot/keyring": "^2.16.1",
"@polkadot/react-identicon": "^0.55.0-beta.5",
"@polkadot/react-qr": "^0.55.0-beta.5",
"@polkadot/util": "^2.16.1",
"@polkadot/util-crypto": "^2.16.1",
"@polkadot/keyring": "^2.18.0-beta.3",
"@polkadot/react-identicon": "^0.56.0-beta.0",
"@polkadot/react-qr": "^0.56.0-beta.0",
"@polkadot/util": "^2.18.0-beta.3",
"@polkadot/util-crypto": "^2.18.0-beta.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-dropzone": "^11.0.1",
@@ -2,10 +2,10 @@
// 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, useContext, useState } from 'react';
import React, { useCallback, useContext, useEffect, useState } from 'react';
import styled from 'styled-components';
import { ActionContext, Address, ButtonArea, NextStepButton, TextAreaWithLabel, ValidatedInput, VerticalSpace } from '../components';
import { AccountContext, ActionContext, Address, ButtonArea, NextStepButton, TextAreaWithLabel, ValidatedInput, VerticalSpace } from '../components';
import { createAccountSuri, validateSeed } from '../messaging';
import { Header, Name, Password } from '../partials';
import { allOf, isNotShorterThan, Result } from '../util/validators';
@@ -26,11 +26,16 @@ const isSeedValid = allOf(
);
export default function Import (): React.ReactElement {
const { accounts } = useContext(AccountContext);
const onAction = useContext(ActionContext);
const [account, setAccount] = useState<null | { address: string; suri: string }>(null);
const [name, setName] = useState<string | null>(null);
const [password, setPassword] = useState<string | null>(null);
useEffect((): void => {
!accounts.length && onAction();
}, [accounts, onAction]);
const _onChangeSeed = useCallback(
async (suri: string | null): Promise<void> => {
if (suri) {
@@ -3,8 +3,8 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { KeyringPair$Json } from '@polkadot/keyring/types';
import React, { useCallback, useContext, useState } from 'react';
import { ActionContext, InputWithLabel, InputFileWithLabel, Button, Address } from '../components';
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { AccountContext, ActionContext, InputWithLabel, InputFileWithLabel, Button, Address } from '../components';
import { u8aToString } from '@polkadot/util';
import styled from 'styled-components';
import { jsonRestore, jsonVerifyPassword, jsonVerifyFile } from '../messaging';
@@ -41,10 +41,15 @@ async function parseFile (file: Uint8Array): Promise<FileState> {
}
export default function Upload (): React.ReactElement {
const { accounts } = useContext(AccountContext);
const onAction = useContext(ActionContext);
const [{ address, isFileValid, json }, setJson] = useState<FileState>({ address: null, isFileValid: false, json: null });
const [{ isPassValid, password }, setPass] = useState<PassState>({ isPassValid: false, password: '' });
useEffect((): void => {
!accounts.length && onAction();
}, [accounts, onAction]);
const _onChangePass = useCallback(
(password: string): void => {
jsonVerifyPassword(password)
+1 -1
View File
@@ -11,7 +11,7 @@
"@polkadot/extension-ui": "0.32.0-beta.5"
},
"devDependencies": {
"@polkadot/dev": "^0.55.19",
"@polkadot/dev": "^0.55.21",
"babel-loader": "^8.1.0",
"extract-loader": "^5.1.0",
"file-loader": "^6.0.0",