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
+8 -1
View File
@@ -1,5 +1,12 @@
# CHANGELOG # CHANGELOG
## master
Changes:
- `{BTree|Hash}Map.toHuman()` now display `Raw` keys as ascii (if detected)
## 8.13.1 Jul 16, 2022 ## 8.13.1 Jul 16, 2022
Changes: Changes:
@@ -332,7 +339,7 @@ Changes:
- Only explicitly support LSB on `BitVec` types - Only explicitly support LSB on `BitVec` types
- Change `toHuman()` on `BitVec` to output default LSB - Change `toHuman()` on `BitVec` to output default LSB
- Add `bytes{Sent, Recv}` to provider stats - Add `bytes{Sent, Recv}` to provider stats
- Clear connection timout on provider `disconnect()` - Clear connection timeout on provider `disconnect()`
- Add support for `dev_getBlockStats` RPC - Add support for `dev_getBlockStats` RPC
+6 -1
View File
@@ -8,6 +8,7 @@ import { compactFromU8aLim, compactToU8a, isHex, isObject, isU8a, logger, string
import { AbstractArray } from '../abstract/Array'; import { AbstractArray } from '../abstract/Array';
import { Enum } from '../base/Enum'; import { Enum } from '../base/Enum';
import { Raw } from '../native/Raw';
import { Struct } from '../native/Struct'; import { Struct } from '../native/Struct';
import { compareMap, decodeU8a, sortMap, typeToConstructor } from '../utils'; 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> = {}; const json: Record<string, AnyJson> = {};
for (const [k, v] of this.entries()) { 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; return json;