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:
+8
-1
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user