|
@@ -1,9 +1,8 @@
|
|
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
|
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// This software may be modified and distributed under the terms
|
|
// of the ISC license. See the LICENSE file for details.
|
|
// of the ISC license. See the LICENSE file for details.
|
|
-// @flow
|
|
|
|
|
|
|
|
-import type { I18nProps } from '@polkadot/ui-app/types';
|
|
|
|
|
|
+import { I18nProps } from '@polkadot/ui-app/types';
|
|
|
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
|
|
|
@@ -11,7 +10,7 @@ import Button from '@polkadot/ui-app/Button';
|
|
import Input from '@polkadot/ui-app/Input';
|
|
import Input from '@polkadot/ui-app/Input';
|
|
import Password from '@polkadot/ui-app/Password';
|
|
import Password from '@polkadot/ui-app/Password';
|
|
import classes from '@polkadot/ui-app/util/classes';
|
|
import classes from '@polkadot/ui-app/util/classes';
|
|
-import keyring from '@polkadot/ui-keyring';
|
|
|
|
|
|
+import keyring from '@polkadot/ui-keyring/index';
|
|
import isHex from '@polkadot/util/is/hex';
|
|
import isHex from '@polkadot/util/is/hex';
|
|
import hexToU8a from '@polkadot/util/hex/toU8a';
|
|
import hexToU8a from '@polkadot/util/hex/toU8a';
|
|
import u8aFromString from '@polkadot/util/u8a/fromString';
|
|
import u8aFromString from '@polkadot/util/u8a/fromString';
|
|
@@ -41,7 +40,7 @@ type State = {
|
|
function formatSeed (seed: string): Uint8Array {
|
|
function formatSeed (seed: string): Uint8Array {
|
|
return isHex(seed)
|
|
return isHex(seed)
|
|
? hexToU8a(seed)
|
|
? hexToU8a(seed)
|
|
- : u8aFromString(seed.padEnd(32, ' '));
|
|
|
|
|
|
+ : u8aFromString((seed as string).padEnd(32, ' '));
|
|
}
|
|
}
|
|
|
|
|
|
function addressFromSeed (seed: string): string {
|
|
function addressFromSeed (seed: string): string {
|
|
@@ -61,7 +60,7 @@ class Creator extends React.PureComponent<Props, State> {
|
|
this.state = this.emptyState();
|
|
this.state = this.emptyState();
|
|
}
|
|
}
|
|
|
|
|
|
- render (): React$Node {
|
|
|
|
|
|
+ render () {
|
|
const { className, style } = this.props;
|
|
const { className, style } = this.props;
|
|
const { address, isSeedValid } = this.state;
|
|
const { address, isSeedValid } = this.state;
|
|
|
|
|
|
@@ -86,7 +85,7 @@ class Creator extends React.PureComponent<Props, State> {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- renderButtons (): React$Node {
|
|
|
|
|
|
+ renderButtons () {
|
|
const { t } = this.props;
|
|
const { t } = this.props;
|
|
const { isValid } = this.state;
|
|
const { isValid } = this.state;
|
|
|
|
|
|
@@ -110,7 +109,7 @@ class Creator extends React.PureComponent<Props, State> {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- renderInput (): React$Node {
|
|
|
|
|
|
+ renderInput () {
|
|
const { t } = this.props;
|
|
const { t } = this.props;
|
|
const { isNameValid, isPassValid, isSeedValid, name, password, seed } = this.state;
|
|
const { isNameValid, isPassValid, isSeedValid, name, password, seed } = this.state;
|
|
|
|
|
|
@@ -169,7 +168,7 @@ class Creator extends React.PureComponent<Props, State> {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
- nextState (newState: $Shape<State>): void {
|
|
|
|
|
|
+ nextState (newState: State): void {
|
|
this.setState(
|
|
this.setState(
|
|
(prevState: State, props: Props): State => {
|
|
(prevState: State, props: Props): State => {
|
|
const { name = prevState.name, password = prevState.password, seed = prevState.seed } = newState;
|
|
const { name = prevState.name, password = prevState.password, seed = prevState.seed } = newState;
|
|
@@ -177,7 +176,7 @@ class Creator extends React.PureComponent<Props, State> {
|
|
const isNameValid = !!name;
|
|
const isNameValid = !!name;
|
|
const isSeedValid = isHex(seed)
|
|
const isSeedValid = isHex(seed)
|
|
? seed.length === 66
|
|
? seed.length === 66
|
|
- : seed.length <= 32;
|
|
|
|
|
|
+ : (seed as string).length <= 32;
|
|
const isPassValid = password.length > 0 && password.length <= 32;
|
|
const isPassValid = password.length > 0 && password.length <= 32;
|
|
|
|
|
|
if (isSeedValid && seed !== prevState.seed) {
|
|
if (isSeedValid && seed !== prevState.seed) {
|
|
@@ -199,15 +198,15 @@ class Creator extends React.PureComponent<Props, State> {
|
|
}
|
|
}
|
|
|
|
|
|
onChangeSeed = (seed: string): void => {
|
|
onChangeSeed = (seed: string): void => {
|
|
- this.nextState({ seed });
|
|
|
|
|
|
+ this.nextState({ seed } as State);
|
|
}
|
|
}
|
|
|
|
|
|
onChangeName = (name: string): void => {
|
|
onChangeName = (name: string): void => {
|
|
- this.nextState({ name });
|
|
|
|
|
|
+ this.nextState({ name } as State);
|
|
}
|
|
}
|
|
|
|
|
|
onChangePass = (password: string): void => {
|
|
onChangePass = (password: string): void => {
|
|
- this.nextState({ password });
|
|
|
|
|
|
+ this.nextState({ password } as State);
|
|
}
|
|
}
|
|
|
|
|
|
onCommit = (): void => {
|
|
onCommit = (): void => {
|