|
@@ -1,10 +1,9 @@
|
|
|
// Copyright 2017-2018 @polkadot/app-toolbox authors & contributors
|
|
|
// This software may be modified and distributed under the terms
|
|
|
// of the ISC license. See the LICENSE file for details.
|
|
|
-// @flow
|
|
|
|
|
|
-import type { I18nProps as Props } from '@polkadot/ui-app/types';
|
|
|
-import type { KeyringPair } from '@polkadot/util-keyring/types';
|
|
|
+import { I18nProps as Props } from '@polkadot/ui-app/types';
|
|
|
+import { KeyringPair } from '@polkadot/util-keyring/types';
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
@@ -14,7 +13,7 @@ import InputAddress from '@polkadot/ui-app/InputAddress';
|
|
|
import Output from '@polkadot/ui-app/Output';
|
|
|
import Static from '@polkadot/ui-app/Static';
|
|
|
import classes from '@polkadot/ui-app/util/classes';
|
|
|
-import keyring from '@polkadot/ui-keyring';
|
|
|
+import keyring from '@polkadot/ui-keyring/index';
|
|
|
import hexToU8a from '@polkadot/util/hex/toU8a';
|
|
|
import isHex from '@polkadot/util/is/hex';
|
|
|
import u8aFromString from '@polkadot/util/u8a/fromString';
|
|
@@ -57,7 +56,7 @@ class Sign extends React.PureComponent<Props, State> {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- render (): React$Node {
|
|
|
+ render () {
|
|
|
const { className, style } = this.props;
|
|
|
|
|
|
return (
|
|
@@ -74,7 +73,7 @@ class Sign extends React.PureComponent<Props, State> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- renderAccount (): React$Node {
|
|
|
+ renderAccount () {
|
|
|
const { t } = this.props;
|
|
|
const { defaultValue } = this.state;
|
|
|
|
|
@@ -94,7 +93,7 @@ class Sign extends React.PureComponent<Props, State> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- renderButtons (): React$Node {
|
|
|
+ renderButtons () {
|
|
|
const { t } = this.props;
|
|
|
const { isLocked } = this.state;
|
|
|
|
|
@@ -115,7 +114,7 @@ class Sign extends React.PureComponent<Props, State> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- renderInput (): React$Node {
|
|
|
+ renderInput () {
|
|
|
const { t } = this.props;
|
|
|
const { data, isHexData } = this.state;
|
|
|
|
|
@@ -148,7 +147,7 @@ class Sign extends React.PureComponent<Props, State> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- renderSignature (): React$Node {
|
|
|
+ renderSignature () {
|
|
|
const { t } = this.props;
|
|
|
const { signature } = this.state;
|
|
|
|
|
@@ -167,7 +166,7 @@ class Sign extends React.PureComponent<Props, State> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- renderUnlock (): React$Node {
|
|
|
+ renderUnlock () {
|
|
|
const { currentPair, isUnlockVisible } = this.state;
|
|
|
|
|
|
if (!isUnlockVisible) {
|
|
@@ -182,9 +181,9 @@ class Sign extends React.PureComponent<Props, State> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- nextState = (newState: $Shape<State>): void => {
|
|
|
+ nextState = (newState: State): void => {
|
|
|
this.setState(
|
|
|
- (prevState: State): $Shape<State> => {
|
|
|
+ (prevState: State): State => {
|
|
|
const { currentPair = prevState.currentPair, data = prevState.data, isHexData = prevState.isHexData, isUnlockVisible = prevState.isUnlockVisible } = newState;
|
|
|
const isLocked = !currentPair || !currentPair.hasSecretKey();
|
|
|
let signature = '';
|
|
@@ -216,19 +215,19 @@ class Sign extends React.PureComponent<Props, State> {
|
|
|
|
|
|
this.nextState({
|
|
|
isUnlockVisible: !isUnlockVisible
|
|
|
- });
|
|
|
+ } as State);
|
|
|
}
|
|
|
|
|
|
onChangeAccount = (publicKey: Uint8Array): void => {
|
|
|
const currentPair = keyring.getPair(publicKey);
|
|
|
|
|
|
- this.nextState({ currentPair });
|
|
|
+ this.nextState({ currentPair } as State);
|
|
|
}
|
|
|
|
|
|
onChangeData = (data: string): void => {
|
|
|
const isHexData = isHex(data);
|
|
|
|
|
|
- this.nextState({ data, isHexData });
|
|
|
+ this.nextState({ data, isHexData } as State);
|
|
|
}
|
|
|
|
|
|
onUnlock = (): void => {
|