Adjust CodecMap toHuman key representation (Bytes, if isAscii) (#5079)

* Adjust CodecMap toHuman key representation (Bytes, if isAscii)

* Use Raw instead of Bytes

* old typo
This commit is contained in:
Jaco
2022-07-16 14:16:29 +03:00
committed by GitHub
parent 5e891f68ca
commit 9a2b67aa25
2 changed files with 14 additions and 2 deletions
+6 -1
View File
@@ -8,6 +8,7 @@ import { compactFromU8aLim, compactToU8a, isHex, isObject, isU8a, logger, string
import { AbstractArray } from '../abstract/Array';
import { Enum } from '../base/Enum';
import { Raw } from '../native/Raw';
import { Struct } from '../native/Struct';
import { compareMap, decodeU8a, sortMap, typeToConstructor } from '../utils';
@@ -182,7 +183,11 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
const json: Record<string, AnyJson> = {};
for (const [k, v] of this.entries()) {
json[k.toString()] = v.toHuman(isExtended);
json[
k instanceof Raw && k.isAscii
? k.toUtf8()
: k.toString()
] = v.toHuman(isExtended);
}
return json;