diff --git a/packages/app-accounts/src/Address.js b/packages/app-accounts/src/Address.js index b873864230..9b8368052c 100644 --- a/packages/app-accounts/src/Address.js +++ b/packages/app-accounts/src/Address.js @@ -13,9 +13,10 @@ import IdentityIcon from '@polkadot/ui-react/IdentityIcon'; import Balance from '@polkadot/ui-react-rx/Balance'; import Nonce from '@polkadot/ui-react-rx/Nonce'; import addressDecode from '@polkadot/util-keyring/address/decode'; +import addressEncode from '@polkadot/util-keyring/address/encode'; type Props = BareProps & { - value: string | null; + value: string; } type State = { @@ -31,13 +32,10 @@ const DEFAULT_SHORT = `${DEFAULT_ADDR.slice(0, 7)}…${DEFAULT_ADDR.slice(-7)}`; export default class Address extends React.PureComponent { state: State = ({}: $Shape); - static getDerivedStateFromProps ({ value }: Props, { publicKey, shortValue }: State): State { - // flowlint-next-line sketchy-null-string:off - const address = value || DEFAULT_ADDR; - + static getDerivedStateFromProps ({ value }: Props, { address, publicKey, shortValue }: State): State { try { - // $FlowFixMe yes, we expect a throw when invalid publicKey = addressDecode(value); + address = addressEncode(publicKey); shortValue = `${address.slice(0, 7)}…${address.slice(-7)}`; } catch (error) { publicKey = null; diff --git a/packages/app-accounts/src/Creator.js b/packages/app-accounts/src/Creator.js index fa07d427ed..10a9f77ee3 100644 --- a/packages/app-accounts/src/Creator.js +++ b/packages/app-accounts/src/Creator.js @@ -76,7 +76,7 @@ class Creator extends React.PureComponent { value={ isSeedValid ? address - : null + : '' } /> {this.renderInput()} @@ -171,7 +171,7 @@ class Creator extends React.PureComponent { nextState (newState: $Shape): void { this.setState( - (prevState: State, props: Props): $Shape => { + (prevState: State, props: Props): State => { const { name = prevState.name, password = prevState.password, seed = prevState.seed } = newState; let address = prevState.address; const isNameValid = !!name; diff --git a/packages/app-addresses/src/Creator.js b/packages/app-addresses/src/Creator.js index aa7cd1fd32..ed8fdce6f0 100644 --- a/packages/app-addresses/src/Creator.js +++ b/packages/app-addresses/src/Creator.js @@ -127,13 +127,14 @@ class Creator extends React.PureComponent { nextState (newState: $Shape): void { this.setState( - (prevState: State, props: Props): $Shape => { + (prevState: State, props: Props): State => { const { address = prevState.address, name = prevState.name } = newState; let isAddressValid = true; + let newAddress = address; try { - addressEncode( + newAddress = addressEncode( addressDecode(address) ); } catch (error) { @@ -143,7 +144,7 @@ class Creator extends React.PureComponent { const isNameValid = !!name; return { - address, + address: newAddress, isAddressValid, isNameValid, isValid: isAddressValid && isNameValid, diff --git a/packages/app-addresses/src/Editor.js b/packages/app-addresses/src/Editor.js index 2cbea7b2b9..24197302a7 100644 --- a/packages/app-addresses/src/Editor.js +++ b/packages/app-addresses/src/Editor.js @@ -25,8 +25,7 @@ type State = { currentAddress: KeyringAddress | null, defaultPublicKey?: Uint8Array, editedName: string, - isEdited: boolean, - info: KeyringAddress | null + isEdited: boolean } class Editor extends React.PureComponent { @@ -157,7 +156,7 @@ class Editor extends React.PureComponent { nextState (newState?: $Shape = {}): void { this.setState( - (prevState: State): $Shape => { + (prevState: State): State => { let { currentAddress = prevState.currentAddress, editedName = prevState.editedName } = newState; const previous = prevState.currentAddress || { address: () => null }; let isEdited = false; diff --git a/packages/app-extrinsics/src/Extrinsic.js b/packages/app-extrinsics/src/Extrinsic.js index 667b3db3cf..ac571a6f80 100644 --- a/packages/app-extrinsics/src/Extrinsic.js +++ b/packages/app-extrinsics/src/Extrinsic.js @@ -32,15 +32,16 @@ type State = { values: Array }; -export default class ExtrinsicDisplay extends React.PureComponent { +export default class Extrinsic extends React.PureComponent { state: State; constructor (props: Props) { super(props); - this.state = ({ - extrinsic: props.defaultValue - }: $Shape); + this.state = { + extrinsic: props.defaultValue, + values: [] + }; } render (): React$Node { diff --git a/packages/app-storage/src/Query.js b/packages/app-storage/src/Query.js index bac9f2b4bd..f764a9f0db 100644 --- a/packages/app-storage/src/Query.js +++ b/packages/app-storage/src/Query.js @@ -38,6 +38,7 @@ class Query extends React.PureComponent { if (!cache[id]) { const values = params.map(({ value }) => value); + // $FlowFixMe we SHOULD be transforming these before passing cache[id] = withStorageDiv(key, { params: values })( (value) => valueToText(key.type, value), diff --git a/packages/app-storage/src/types.js b/packages/app-storage/src/types.js index 8fd09d1b57..71e4ef7e58 100644 --- a/packages/app-storage/src/types.js +++ b/packages/app-storage/src/types.js @@ -4,10 +4,10 @@ // @flow import type { Storage$Key } from '@polkadot/storage/types'; +import type { RawParams } from '@polkadot/ui-app/Params/types'; export type StorageQuery = { id: number, key: Storage$Key, - // flowlint-next-line unclear-type:off - params: Array + params: RawParams } diff --git a/packages/app-toolbox/src/Unlock.js b/packages/app-toolbox/src/Unlock.js index a6e0f9107f..90daa80fa7 100644 --- a/packages/app-toolbox/src/Unlock.js +++ b/packages/app-toolbox/src/Unlock.js @@ -41,7 +41,7 @@ class Unlock extends React.PureComponent { unlockError: null }; - static getDerivedStateFromProps ({ pair }: Props, prevState: State): $Shape { + static getDerivedStateFromProps ({ pair }: Props, prevState: State): State { const address = pair ? pair.address() : ''; diff --git a/packages/app-toolbox/src/Verify.js b/packages/app-toolbox/src/Verify.js index f0600803a3..0c1a646a74 100644 --- a/packages/app-toolbox/src/Verify.js +++ b/packages/app-toolbox/src/Verify.js @@ -151,7 +151,7 @@ class Verify extends React.PureComponent { nextState (newState: $Shape): void { this.setState( - (prevState: State): $Shape => { + (prevState: State): State => { const { isHexData = prevState.isHexData, isValidAddress = prevState.isValidAddress, isValidSignature = prevState.isValidSignature, currentPublicKey = prevState.currentPublicKey, data = prevState.data, signature = prevState.signature } = newState; let isValid = isValidAddress && isValidSignature; diff --git a/packages/ui-app/src/Input.js b/packages/ui-app/src/Input.js index 4209cd33ad..a451f4d0b6 100644 --- a/packages/ui-app/src/Input.js +++ b/packages/ui-app/src/Input.js @@ -25,8 +25,7 @@ type Props = BareProps & { label?: React$Node, max?: mixed, min?: mixed, - // flowlint-next-line unclear-type:off - onChange: (value: any) => void, + onChange: (value: string) => void, placeholder?: string, type?: Input$Type, value?: mixed, diff --git a/packages/ui-app/src/InputAddress/addressToAddress.js b/packages/ui-app/src/InputAddress/addressToAddress.js index 28e205deae..9dbf86e510 100644 --- a/packages/ui-app/src/InputAddress/addressToAddress.js +++ b/packages/ui-app/src/InputAddress/addressToAddress.js @@ -6,7 +6,7 @@ import addressDecode from '@polkadot/util-keyring/address/decode'; import addressEncode from '@polkadot/util-keyring/address/encode'; -export default function addressToAddress (value?: string | Uint8Array | null): ?string { +export default function addressToAddress (value?: string | Uint8Array): ?string { // flowlint-next-line sketchy-null-string:off if (value) { try { diff --git a/packages/ui-app/src/InputAddress/index.js b/packages/ui-app/src/InputAddress/index.js index d9dbc63d54..4a43b52ca7 100644 --- a/packages/ui-app/src/InputAddress/index.js +++ b/packages/ui-app/src/InputAddress/index.js @@ -19,7 +19,7 @@ import classes from '../util/classes'; import addressToAddress from './addressToAddress'; type Props = BareProps & { - defaultValue?: string | Uint8Array | null, + defaultValue?: string | Uint8Array, hideAddress?: boolean; isError?: boolean, isInput?: boolean, diff --git a/packages/ui-app/src/Params/Param/Amount.js b/packages/ui-app/src/Params/Param/Amount.js index 0ee9194882..c0be7c5606 100644 --- a/packages/ui-app/src/Params/Param/Amount.js +++ b/packages/ui-app/src/Params/Param/Amount.js @@ -37,7 +37,7 @@ export default class Amount extends React.PureComponent { ); } - onChange = (value: number): void => { + onChange = (value: string): void => { const { onChange } = this.props; onChange({ diff --git a/packages/ui-app/src/Params/Param/File.js b/packages/ui-app/src/Params/Param/File.js index 19676a553f..f302a60a09 100644 --- a/packages/ui-app/src/Params/Param/File.js +++ b/packages/ui-app/src/Params/Param/File.js @@ -28,6 +28,12 @@ type State = { } }; +type LoadEvent = { + target: { // eslint-disable-line react/no-unused-prop-types + result: ArrayBuffer + } +}; + class BytesFile extends React.PureComponent { state: State = {}; @@ -72,9 +78,8 @@ class BytesFile extends React.PureComponent { reader.onabort = () => {}; reader.onerror = () => {}; - reader.onload = () => { - // flowlint-next-line unclear-type:off - const data = new Uint8Array((((reader.result): any): ArrayBuffer)); + reader.onload = ({ target: { result } }: LoadEvent) => { + const data = new Uint8Array(result); onChange(data); diff --git a/packages/ui-app/src/Params/Param/Hash.js b/packages/ui-app/src/Params/Param/Hash.js index 7832cb4cf1..d58ed9708d 100644 --- a/packages/ui-app/src/Params/Param/Hash.js +++ b/packages/ui-app/src/Params/Param/Hash.js @@ -9,9 +9,10 @@ import React from 'react'; import BaseBytes from './BaseBytes'; -export default function Hash ({ defaultValue, isDisabled, isError, label, name, onChange, withLabel }: Props): React$Node { +export default function Hash ({ className, defaultValue, isDisabled, isError, label, name, onChange, style, withLabel }: Props): React$Node { return ( ); diff --git a/packages/ui-app/src/Params/Param/index.js b/packages/ui-app/src/Params/Param/index.js index 25d22e713b..56cf740ec3 100644 --- a/packages/ui-app/src/Params/Param/index.js +++ b/packages/ui-app/src/Params/Param/index.js @@ -15,7 +15,6 @@ import translate from '../../translate'; import findComponent from './findComponent'; type Props = I18nProps & BaseProps & { - index: number, overrides?: ComponentMap }; @@ -43,15 +42,15 @@ class ParamComponent extends React.PureComponent { return null; } - const { className, defaultValue, index, name, onChange, style } = this.props; + const { className, defaultValue, name, onChange, style } = this.props; const type = typeToString(defaultValue.type); return ( { {paramNames.map((paramName, index) => ( ))} diff --git a/packages/ui-signer/src/Unlock.js b/packages/ui-signer/src/Unlock.js index bdc64b1446..67d0d724c4 100644 --- a/packages/ui-signer/src/Unlock.js +++ b/packages/ui-signer/src/Unlock.js @@ -31,7 +31,7 @@ type State = { class Unlock extends React.PureComponent { state: State = ({}: $Shape); - static getDerivedStateFromProps ({ error, password, value }: Props): $Shape { + static getDerivedStateFromProps ({ error, password, value }: Props): State { const pair = keyring.getPair(value); const isLocked = !pair.hasSecretKey();