fix: disable ASCII decoding for binary data in chain state display (#12027)

This commit is contained in:
rajk93 2025-12-02 11:23:15 +05:30 committed by GitHub
parent 913555da19
commit df45a4ec47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -131,7 +131,7 @@ function getCachedComponent (registry: Registry, query: QueryTypes): CacheInstan
const defaultProps = { className: 'ui--output' };
const Component = renderHelper(
// 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
);

View File

@ -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
return isFunction((value as Codec).toHuman)
? (value as Codec).toHuman()
? (value as Codec).toHuman(isExtended, disableAscii)
: Array.isArray(value)
? value.map((v) => toHuman(v))
? value.map((v) => toHuman(v, isExtended, disableAscii))
: value.toString();
}
@ -50,7 +50,7 @@ export function toHumanJson (value: unknown): string {
.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)) {
const { cName, key, values } = div({}, '<unknown>');
@ -78,7 +78,7 @@ export default function valueToText (type: string, value: Codec | undefined | nu
: value.toString()
: (value instanceof Option) && value.isNone
? '<none>'
: toHumanJson(toHuman(value))
: toHumanJson(toHuman(value, isExtended, disableAscii))
);
const { cName, key, values } = div({}, renderedValue);