fix: disable ASCII decoding for binary data in chain state display (#12027)
This commit is contained in:
parent
913555da19
commit
df45a4ec47
@ -131,7 +131,7 @@ function getCachedComponent (registry: Registry, query: QueryTypes): CacheInstan
|
|||||||
const defaultProps = { className: 'ui--output' };
|
const defaultProps = { className: 'ui--output' };
|
||||||
const Component = renderHelper(
|
const Component = renderHelper(
|
||||||
// By default we render a simple div node component with the query results in it
|
// By default we render a simple div node component with the query results in it
|
||||||
(value: unknown) => <pre>{valueToText(type, value as null)}</pre>,
|
(value: unknown) => <pre>{valueToText(type, value as null, undefined, true)}</pre>,
|
||||||
defaultProps
|
defaultProps
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -33,12 +33,12 @@ function formatKeys (keys: [ValidatorId, Keys][]): string {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toHuman (value: Codec | Codec[]): unknown {
|
function toHuman (value: Codec | Codec[], isExtended?: boolean, disableAscii?: boolean): unknown {
|
||||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||||
return isFunction((value as Codec).toHuman)
|
return isFunction((value as Codec).toHuman)
|
||||||
? (value as Codec).toHuman()
|
? (value as Codec).toHuman(isExtended, disableAscii)
|
||||||
: Array.isArray(value)
|
: Array.isArray(value)
|
||||||
? value.map((v) => toHuman(v))
|
? value.map((v) => toHuman(v, isExtended, disableAscii))
|
||||||
: value.toString();
|
: value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ export function toHumanJson (value: unknown): string {
|
|||||||
.replace(/\],\[/g, '],\n[');
|
.replace(/\],\[/g, '],\n[');
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function valueToText (type: string, value: Codec | undefined | null): React.ReactNode {
|
export default function valueToText (type: string, value: Codec | undefined | null, isExtended?: boolean, disableAscii?: boolean): React.ReactNode {
|
||||||
if (isNull(value) || isUndefined(value)) {
|
if (isNull(value) || isUndefined(value)) {
|
||||||
const { cName, key, values } = div({}, '<unknown>');
|
const { cName, key, values } = div({}, '<unknown>');
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ export default function valueToText (type: string, value: Codec | undefined | nu
|
|||||||
: value.toString()
|
: value.toString()
|
||||||
: (value instanceof Option) && value.isNone
|
: (value instanceof Option) && value.isNone
|
||||||
? '<none>'
|
? '<none>'
|
||||||
: toHumanJson(toHuman(value))
|
: toHumanJson(toHuman(value, isExtended, disableAscii))
|
||||||
);
|
);
|
||||||
|
|
||||||
const { cName, key, values } = div({}, renderedValue);
|
const { cName, key, values } = div({}, renderedValue);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user