Check valid params fro RPC app (#321)

This commit is contained in:
Jaco Greeff 2018-09-19 14:42:51 +02:00 committed by GitHub
parent 2195ca131d
commit 15788c1051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,9 +92,10 @@ class Selection extends React.PureComponent<Props, State> {
this.setState(
(prevState: State): State => {
const { rpc = prevState.rpc, nonce = prevState.nonce, publicKey = prevState.publicKey, values = prevState.values } = newState;
const hasNeededKey = rpc.isSigned !== true || (!!publicKey && publicKey.length === 32);
const isValid = values.reduce((isValid, value) => {
return isValid && value.isValid === true;
}, rpc.isSigned !== true || (!!publicKey && publicKey.length === 32));
}, rpc.params.length === values.length && hasNeededKey);
return {
isValid,
@ -108,11 +109,17 @@ class Selection extends React.PureComponent<Props, State> {
}
onChangeAccount = (publicKey: Uint8Array | undefined | null, nonce: BN): void => {
this.nextState({ nonce, publicKey } as State);
this.nextState({
nonce,
publicKey
} as State);
}
onChangeMethod = (rpc: SectionItem<Interfaces>): void => {
this.nextState({ rpc } as State);
this.nextState({
rpc,
values: [] as Array<RawParam>
} as State);
}
onChangeValues = (values: Array<RawParam>): void => {