Toolbox App RPC method bugfix & cleanup (#1171)

* WIP

* Removed unused code

* Add missing init values to ui-params

* Removed unused import

* Poke Travis

* Removed console.log

* Happy linting

* re-added the unused prevProps
This commit is contained in:
Stefanie Doll 2019-05-15 21:30:26 +02:00 committed by GitHub
parent 7ffe763317
commit a2d0eabf66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -52,7 +52,6 @@ class Selection extends React.PureComponent<Props, State> {
label={t('call the selected endpoint')}
onChange={this.onChangeMethod}
/>
{this.renderAccount()}
<Params
key={`${rpc.section}.${rpc.method}:params` /* force re-render on change */}
onChange={this.onChangeValues}
@ -70,20 +69,13 @@ class Selection extends React.PureComponent<Props, State> {
);
}
// FIXME Currently the UI doesn't support signing for rpc-submitted calls
private renderAccount () {
return null;
}
private nextState (newState: State): void {
this.setState(
(prevState: State): State => {
const { rpc = prevState.rpc, accountId = prevState.accountId, values = prevState.values } = newState;
const hasNeededKey = true;
const isValid = values.reduce((isValid, value) => {
return isValid && value.isValid === true;
}, rpc.params.length === values.length && hasNeededKey);
}, rpc.params.length === values.length);
return {
isValid,
rpc,

View File

@ -5,7 +5,7 @@
import { RawParam$Value } from './types';
import BN from 'bn.js';
import { Bytes, Hash, TypeDef, TypeDefInfo, UInt, createType } from '@polkadot/types';
import { Bytes, Hash, TypeDef, TypeDefInfo, U8a, UInt, createType } from '@polkadot/types';
export default function getInitValue (def: TypeDef): RawParam$Value | Array<RawParam$Value> {
if (def.info === TypeDefInfo.Vector) {
@ -46,6 +46,7 @@ export default function getInitValue (def: TypeDef): RawParam$Value | Array<RawP
return false;
case 'String':
case 'Text':
return '';
case 'Moment':
@ -77,8 +78,12 @@ export default function getInitValue (def: TypeDef): RawParam$Value | Array<RawP
case 'Proposal':
case 'Signature':
case 'SessionKey':
case 'StorageKey':
return void 0;
case 'Extrinsic':
return new U8a();
default: {
try {
const instance = createType(type);