diff --git a/packages/ui-app/src/Call.tsx b/packages/ui-app/src/Call.tsx index 731a92e504..e888d608dc 100644 --- a/packages/ui-app/src/Call.tsx +++ b/packages/ui-app/src/Call.tsx @@ -2,12 +2,12 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { IExtrinsic, IMethod } from '@polkadot/types/types'; +import { Codec, IExtrinsic, IMethod } from '@polkadot/types/types'; import { BareProps, I18nProps } from './types'; import React from 'react'; import styled from 'styled-components'; -import { Method, getTypeDef } from '@polkadot/types'; +import { Method, getTypeDef, TypeDef } from '@polkadot/types'; import Params from '@polkadot/ui-params'; import Static from './Static'; @@ -15,10 +15,10 @@ import { classes } from './util'; import translate from './translate'; export type Props = I18nProps & BareProps & { - children?: React.ReactNode, - value: IExtrinsic | IMethod, - withHash?: boolean, - mortality?: string + children?: React.ReactNode; + value: IExtrinsic | IMethod; + withHash?: boolean; + mortality?: string; }; const Wrapper = styled.div` @@ -33,11 +33,11 @@ const Wrapper = styled.div` class Call extends React.PureComponent { public render (): React.ReactNode { const { children, className, style, mortality, value, withHash, t } = this.props; - const params = Method.filterOrigin(value.meta).map(({ name, type }) => ({ + const params = Method.filterOrigin(value.meta).map(({ name, type }): { name: string; type: TypeDef } => ({ name: name.toString(), type: getTypeDef(type) })); - const values = value.args.map((value) => ({ + const values = value.args.map((value): { isValid: boolean; value: Codec } => ({ isValid: true, value })); diff --git a/packages/ui-params/src/index.tsx b/packages/ui-params/src/index.tsx index a594b19676..f6956a05c1 100644 --- a/packages/ui-params/src/index.tsx +++ b/packages/ui-params/src/index.tsx @@ -30,10 +30,10 @@ interface Props extends I18nProps { } interface State { - handlers: RawParamOnChange[]; + handlers?: RawParamOnChange[]; onChangeParam: (at: number, next: RawParamOnChangeValue) => void; - params: Param[]; - values: RawParams; + params?: Param[]; + values?: RawParams; } class Params extends React.PureComponent { @@ -43,10 +43,7 @@ class Params extends React.PureComponent { super(props); this.state = { - handlers: [], - onChangeParam: this.onChangeParam, - params: [], - values: [] + onChangeParam: this.onChangeParam }; } @@ -84,7 +81,7 @@ class Params extends React.PureComponent { const { values } = this.state; if (!isDisabled && prevState.values !== values) { - onChange && onChange(values); + onChange && onChange(values || []); } } @@ -130,7 +127,7 @@ class Params extends React.PureComponent { this.setState( (prevState: State): State => ({ - values: prevState.values.map((prev, index): RawParam => + values: (prevState.values || []).map((prev, index): RawParam => index !== at ? prev : { @@ -147,7 +144,7 @@ class Params extends React.PureComponent { const { values } = this.state; const { onChange, isDisabled } = this.props; - if (isDisabled) { + if (isDisabled || !values) { return; }