Small app-RPC fixes (#60)

* Don't render invalid accountIndex

* Don't try to decode null/undefined
This commit is contained in:
Jaco Greeff 2018-05-28 10:01:09 +02:00 committed by GitHub
parent 9bc9bfd6fe
commit 07dd46442f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 13 deletions

View File

@ -40,7 +40,6 @@ class Account extends React.PureComponent<Props, State> {
render (): React$Node {
const { className, defaultValue, isError, style, t } = this.props;
const { publicKey } = this.state;
return (
<div
@ -59,22 +58,35 @@ class Account extends React.PureComponent<Props, State> {
type='account'
/>
</div>
<Labelled
className='small'
label={t('account.nonce', {
defaultValue: 'with an index of'
})}
>
<Nonce
className='ui disabled dropdown selection'
onChange={this.onChangeNonce}
params={publicKey}
/>
</Labelled>
{this.renderNonce()}
</div>
);
}
renderNonce (): React$Node {
const { t } = this.props;
const { publicKey } = this.state;
if (!publicKey) {
return null;
}
return (
<Labelled
className='small'
label={t('account.nonce', {
defaultValue: 'with an index of'
})}
>
<Nonce
className='ui disabled dropdown selection'
onChange={this.onChangeNonce}
params={publicKey}
/>
</Labelled>
);
}
onChangeAccount = (publicKey: Uint8Array): void => {
const { onChange } = this.props;

View File

@ -10,6 +10,10 @@ import isObject from '@polkadot/util/is/object';
import isU8a from '@polkadot/util/is/u8a';
function resultToText (result: mixed): mixed {
if (result === null || result === undefined) {
return 'null';
}
if (isU8a(result)) {
// $FlowFixMe type has been determined
return u8aToHex(result);