Input Uknown types as hex (underlying) (#1551)

This commit is contained in:
Jaco Greeff 2019-08-28 13:11:00 +02:00 committed by GitHub
parent fb4856d1f9
commit cc2f442245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import { hexToU8a, isHex, u8aToHex } from '@polkadot/util';
import Bare from './Bare';
interface Props extends BaseProps {
asHex?: boolean;
children?: React.ReactNode;
length?: number;
size?: Size;
@ -59,7 +60,7 @@ export default class BaseBytes extends React.PureComponent<Props> {
}
private onChange = (hex: string): void => {
const { length = -1, onChange, validate = defaultValidate, withLength } = this.props;
const { asHex, length = -1, onChange, validate = defaultValidate, withLength } = this.props;
let value: Uint8Array;
let isValid = true;
@ -83,7 +84,9 @@ export default class BaseBytes extends React.PureComponent<Props> {
onChange && onChange({
isValid,
value
value: asHex
? u8aToHex(value)
: value
});
}
}

View File

@ -24,6 +24,7 @@ export default class Unknown extends React.PureComponent<Props> {
return (
<BaseBytes
asHex
className={className}
defaultValue={defaultValue}
isDisabled={isDisabled}