diff --git a/packages/page-rpc/src/Rpc/Selection.tsx b/packages/page-rpc/src/Rpc/Selection.tsx index 1151aee56a..c106a85f28 100644 --- a/packages/page-rpc/src/Rpc/Selection.tsx +++ b/packages/page-rpc/src/Rpc/Selection.tsx @@ -37,29 +37,28 @@ function Selection ({ queueRpc }: Props): React.ReactElement { }); const _nextState = useCallback( - (newState: Partial): void => - setState((prevState: State): State => { - const { accountId = prevState.accountId, rpc = prevState.rpc, values = prevState.values } = newState; - const reqCount = rpc.params.reduce((count, { isOptional }): number => count + (isOptional ? 0 : 1), 0); - const isValid = values.reduce((isValid, value) => isValid && value.isValid === true, reqCount <= values.length); + (newState: Partial) => setState((prevState: State): State => { + const { accountId = prevState.accountId, rpc = prevState.rpc, values = prevState.values } = newState; + const reqCount = rpc.params.reduce((count, { isOptional }) => count + (isOptional ? 0 : 1), 0); + const isValid = values.reduce((isValid, value) => isValid && value.isValid === true, reqCount <= values.length); - return { - accountId, - isValid, - rpc, - values - }; - }), + return { + accountId, + isValid, + rpc, + values + }; + }), [] ); const _onChangeMethod = useCallback( - (rpc: DefinitionRpcExt): void => _nextState({ rpc, values: [] }), + (rpc: DefinitionRpcExt) => _nextState({ rpc, values: [] }), [_nextState] ); const _onChangeValues = useCallback( - (values: RawParam[]): void => _nextState({ values }), + (values: RawParam[]) => _nextState({ values }), [_nextState] ); @@ -68,7 +67,7 @@ function Selection ({ queueRpc }: Props): React.ReactElement { accountId, rpc, values: values - .filter(({ value }): boolean => !isNull(value)) + .filter(({ value }) => !isNull(value)) .map(({ value }): any => value) }), [accountId, queueRpc, rpc, values] diff --git a/packages/react-components/src/InputRpc/SelectMethod.tsx b/packages/react-components/src/InputRpc/SelectMethod.tsx index 19a5b2adb7..34dcfc6160 100644 --- a/packages/react-components/src/InputRpc/SelectMethod.tsx +++ b/packages/react-components/src/InputRpc/SelectMethod.tsx @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import type { DefinitionRpcExt } from '@polkadot/types/types'; -import type { DropdownOptions } from '../util/types'; +import type { DropdownOption } from '../util/types'; import React, { useCallback } from 'react'; @@ -14,13 +14,13 @@ interface Props { className?: string; isError?: boolean; onChange: (value: DefinitionRpcExt) => void; - options: DropdownOptions; + options: DropdownOption[]; value: DefinitionRpcExt; } function SelectMethod ({ className = '', isError, onChange, options, value }: Props): React.ReactElement | null { const _transform = useCallback( - () => rpcs[value.section][value.method], + (method: string) => rpcs[value.section][method], [value] );