Adjust inspect inner/outer (#4553)

This commit is contained in:
Jaco
2022-02-09 12:11:53 +02:00
committed by GitHub
parent 7af315f278
commit 61daa0f2c8
48 changed files with 131 additions and 194 deletions
@@ -84,7 +84,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
inspect (): Inspect { inspect (): Inspect {
return { return {
inner: this.inspectInner(), inner: this.inspectInner(),
value: compactToU8a(this.length) outer: [compactToU8a(this.length)]
}; };
} }
@@ -127,8 +127,7 @@ export abstract class AbstractInt extends BN implements INumber {
*/ */
inspect (): Inspect { inspect (): Inspect {
return { return {
inner: [], outer: [this.toU8a()]
value: this.toU8a()
}; };
} }
@@ -84,8 +84,7 @@ describe('Compact', (): void => {
expect( expect(
new (Compact.with(U32))(registry, 0xffff).inspect() new (Compact.with(U32))(registry, 0xffff).inspect()
).toEqual({ ).toEqual({
inner: [], outer: [new Uint8Array([254, 255, 3, 0])]
value: new Uint8Array([254, 255, 3, 0])
}); });
}); });
}); });
+1 -2
View File
@@ -105,8 +105,7 @@ export class Compact<T extends INumber> implements ICompact<T> {
*/ */
inspect (): Inspect { inspect (): Inspect {
return { return {
inner: [], outer: [this.toU8a()]
value: this.toU8a()
}; };
} }
+1 -2
View File
@@ -298,8 +298,7 @@ describe('Enum', (): void => {
'0x0134120000' '0x0134120000'
).inspect() ).inspect()
).toEqual({ ).toEqual({
inner: [{ inner: [], value: new Uint8Array([0x34, 0x12, 0x00, 0x00]) }], outer: [new Uint8Array([0x01]), new Uint8Array([0x34, 0x12, 0x00, 0x00])]
value: new Uint8Array([0x01])
}); });
}); });
}); });
+8 -4
View File
@@ -324,11 +324,15 @@ export class Enum implements IEnum {
* @description Returns a breakdown of the hex encoding for this Codec * @description Returns a breakdown of the hex encoding for this Codec
*/ */
inspect (): Inspect { inspect (): Inspect {
if (this.isBasic) {
return { outer: [new Uint8Array([this.index])] };
}
const { inner, outer = [] } = this.#raw.inspect();
return { return {
inner: this.isBasic inner,
? [] outer: [new Uint8Array([this.index]), ...outer]
: [this.#raw.inspect()],
value: new Uint8Array([this.index])
}; };
} }
+1 -2
View File
@@ -56,8 +56,7 @@ describe('Int', (): void => {
expect( expect(
new Int(registry, '0x12', 16).inspect() new Int(registry, '0x12', 16).inspect()
).toEqual({ ).toEqual({
inner: [], outer: [new Uint8Array([0x12, 0x00])]
value: new Uint8Array([0x12, 0x00])
}); });
}); });
+1 -4
View File
@@ -55,10 +55,7 @@ export class Null implements Codec {
* @description Returns a breakdown of the hex encoding for this Codec * @description Returns a breakdown of the hex encoding for this Codec
*/ */
inspect (): Inspect { inspect (): Inspect {
return { return {};
inner: [],
value: new Uint8Array()
};
} }
/** /**
+1 -5
View File
@@ -158,11 +158,7 @@ describe('Option', (): void => {
expect( expect(
new Option(registry, U32, '1234').inspect() new Option(registry, U32, '1234').inspect()
).toEqual({ ).toEqual({
inner: [{ outer: [new Uint8Array([0x01]), new Uint8Array([210, 4, 0, 0])]
inner: [],
value: new Uint8Array([210, 4, 0, 0])
}],
value: new Uint8Array([0x01])
}); });
}); });
}); });
+8 -8
View File
@@ -141,15 +141,15 @@ export class Option<T extends Codec> implements IOption<T> {
* @description Returns a breakdown of the hex encoding for this Codec * @description Returns a breakdown of the hex encoding for this Codec
*/ */
inspect (): Inspect { inspect (): Inspect {
if (this.isNone) {
return { outer: [new Uint8Array([0])] };
}
const { inner, outer = [] } = this.#raw.inspect();
return { return {
inner: this.isSome inner,
? [this.#raw.inspect()] outer: [new Uint8Array([1]), ...outer]
: [],
value: new Uint8Array(
this.isSome
? [1]
: [0]
)
}; };
} }
+3 -4
View File
@@ -126,10 +126,9 @@ describe('Tuple', (): void => {
tuple.inspect() tuple.inspect()
).toEqual({ ).toEqual({
inner: [ inner: [
{ inner: [{ inner: [], value: stringToU8a('bazzing') }], value: new Uint8Array([7 << 2]) }, { outer: [new Uint8Array([7 << 2]), stringToU8a('bazzing')] },
{ inner: [], value: new Uint8Array([69, 0, 0, 0]) } { outer: [new Uint8Array([69, 0, 0, 0])] }
], ]
value: new Uint8Array()
}); });
}); });
}); });
+1 -2
View File
@@ -105,8 +105,7 @@ export class Tuple extends AbstractArray<Codec> implements ITuple<Codec[]> {
*/ */
override inspect (): Inspect { override inspect (): Inspect {
return { return {
inner: this.inspectInner(), inner: this.inspectInner()
value: new Uint8Array()
}; };
} }
+1 -2
View File
@@ -127,8 +127,7 @@ describe('UInt', (): void => {
expect( expect(
new UInt(registry, '0x12', 16).inspect() new UInt(registry, '0x12', 16).inspect()
).toEqual({ ).toEqual({
inner: [], outer: [new Uint8Array([0x12, 0x00])]
value: new Uint8Array([0x12, 0x00])
}); });
}); });
+2 -3
View File
@@ -184,10 +184,9 @@ describe('Vec', (): void => {
expect(vec.inspect()).toEqual({ expect(vec.inspect()).toEqual({
inner: addrs.map((a) => ({ inner: addrs.map((a) => ({
inner: [], outer: [decodeAddress(a)]
value: decodeAddress(a)
})), })),
value: new Uint8Array([3 << 2]) outer: [new Uint8Array([3 << 2])]
}); });
}); });
}); });
@@ -64,13 +64,12 @@ describe('VecFixed', (): void => {
it('has a sane inspect', (): void => { it('has a sane inspect', (): void => {
expect(test.inspect()).toEqual({ expect(test.inspect()).toEqual({
inner: [ inner: [
{ inner: [{ inner: [], value: stringToU8a('1') }], value: new Uint8Array([1 << 2]) }, { outer: [new Uint8Array([1 << 2]), stringToU8a('1')] },
{ inner: [{ inner: [], value: stringToU8a('2') }], value: new Uint8Array([1 << 2]) }, { outer: [new Uint8Array([1 << 2]), stringToU8a('2')] },
{ inner: [{ inner: [], value: stringToU8a('3') }], value: new Uint8Array([1 << 2]) }, { outer: [new Uint8Array([1 << 2]), stringToU8a('3')] },
{ inner: [{ inner: [], value: new Uint8Array() }], value: new Uint8Array([0]) }, { outer: [new Uint8Array([0])] },
{ inner: [{ inner: [], value: stringToU8a('56') }], value: new Uint8Array([2 << 2]) } { outer: [new Uint8Array([2 << 2]), stringToU8a('56')] }
], ]
value: new Uint8Array()
}); });
}); });
}); });
+1 -2
View File
@@ -75,8 +75,7 @@ export class VecFixed<T extends Codec> extends AbstractArray<T> {
*/ */
override inspect (): Inspect { override inspect (): Inspect {
return { return {
inner: this.inspectInner(), inner: this.inspectInner()
value: new Uint8Array()
}; };
} }
@@ -198,32 +198,14 @@ describe('BTreeMap', (): void => {
])).inspect() ])).inspect()
).toEqual({ ).toEqual({
inner: [ inner: [
{ { outer: [new Uint8Array([1 << 2]), stringToU8a('1')] },
inner: [{ inner: [], value: stringToU8a('1') }], { outer: [new Uint8Array([3 << 2]), stringToU8a('foo')] },
value: new Uint8Array([1 << 2]) { outer: [new Uint8Array([1 << 2]), stringToU8a('2')] },
}, { outer: [new Uint8Array([3 << 2]), stringToU8a('bar')] },
{ { outer: [new Uint8Array([1 << 2]), stringToU8a('3')] },
inner: [{ inner: [], value: stringToU8a('foo') }], { outer: [new Uint8Array([3 << 2]), stringToU8a('baz')] }
value: new Uint8Array([3 << 2])
},
{
inner: [{ inner: [], value: stringToU8a('2') }],
value: new Uint8Array([1 << 2])
},
{
inner: [{ inner: [], value: stringToU8a('bar') }],
value: new Uint8Array([3 << 2])
},
{
inner: [{ inner: [], value: stringToU8a('3') }],
value: new Uint8Array([1 << 2])
},
{
inner: [{ inner: [], value: stringToU8a('baz') }],
value: new Uint8Array([3 << 2])
}
], ],
value: new Uint8Array([3 << 2]) outer: [new Uint8Array([3 << 2])]
}); });
}); });
}); });
@@ -186,12 +186,12 @@ describe('BTreeSet', (): void => {
new (BTreeSet.with(U32))(registry, [1, 2, 3, 4]).inspect() new (BTreeSet.with(U32))(registry, [1, 2, 3, 4]).inspect()
).toEqual({ ).toEqual({
inner: [ inner: [
{ inner: [], value: new Uint8Array([1, 0, 0, 0]) }, { outer: [new Uint8Array([1, 0, 0, 0])] },
{ inner: [], value: new Uint8Array([2, 0, 0, 0]) }, { outer: [new Uint8Array([2, 0, 0, 0])] },
{ inner: [], value: new Uint8Array([3, 0, 0, 0]) }, { outer: [new Uint8Array([3, 0, 0, 0])] },
{ inner: [], value: new Uint8Array([4, 0, 0, 0]) } { outer: [new Uint8Array([4, 0, 0, 0])] }
], ],
value: new Uint8Array([4 << 2]) outer: [new Uint8Array([4 << 2])]
}); });
}); });
}); });
@@ -150,7 +150,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements ISet<V>
return { return {
inner, inner,
value: compactToU8a(this.size) outer: [compactToU8a(this.size)]
}; };
} }
@@ -33,10 +33,7 @@ describe('BitVec', (): void => {
expect( expect(
new BitVec(registry, '0x0837').inspect() new BitVec(registry, '0x0837').inspect()
).toEqual({ ).toEqual({
inner: [ outer: [new Uint8Array([0]), new Uint8Array([0x08, 0x37])]
{ inner: [], value: new Uint8Array([0x08, 0x37]) }
],
value: new Uint8Array([0])
}); });
}); });
}); });
+1 -2
View File
@@ -62,8 +62,7 @@ export class BitVec extends Raw {
*/ */
override inspect (): Inspect { override inspect (): Inspect {
return { return {
inner: [{ inner: [], value: super.toU8a() }], outer: [compactToU8a(this.#decodedLength), super.toU8a()]
value: compactToU8a(this.#decodedLength)
}; };
} }
@@ -67,8 +67,7 @@ describe('Bytes', (): void => {
expect( expect(
new Bytes(registry, '0x12345678').inspect() new Bytes(registry, '0x12345678').inspect()
).toEqual({ ).toEqual({
inner: [{ inner: [], value: new Uint8Array([0x12, 0x34, 0x56, 0x78]) }], outer: [new Uint8Array([4 << 2]), new Uint8Array([0x12, 0x34, 0x56, 0x78])]
value: new Uint8Array([4 << 2])
}); });
}); });
}); });
+5 -2
View File
@@ -64,9 +64,12 @@ export class Bytes extends Raw {
* @description Returns a breakdown of the hex encoding for this Codec * @description Returns a breakdown of the hex encoding for this Codec
*/ */
override inspect (): Inspect { override inspect (): Inspect {
const clength = compactToU8a(this.length);
return { return {
inner: [{ inner: [], value: super.toU8a() }], outer: this.length
value: compactToU8a(this.length) ? [clength, super.toU8a()]
: [clength]
}; };
} }
@@ -23,24 +23,12 @@ describe('HashMap', (): void => {
])).inspect() ])).inspect()
).toEqual({ ).toEqual({
inner: [ inner: [
{ { outer: [new Uint8Array([1 << 2]), stringToU8a('1')] },
inner: [{ inner: [], value: stringToU8a('1') }], { outer: [new Uint8Array([3 << 2]), stringToU8a('foo')] },
value: new Uint8Array([1 << 2]) { outer: [new Uint8Array([1 << 2]), stringToU8a('2')] },
}, { outer: [new Uint8Array([3 << 2]), stringToU8a('bar')] }
{
inner: [{ inner: [], value: stringToU8a('foo') }],
value: new Uint8Array([3 << 2])
},
{
inner: [{ inner: [], value: stringToU8a('2') }],
value: new Uint8Array([1 << 2])
},
{
inner: [{ inner: [], value: stringToU8a('bar') }],
value: new Uint8Array([3 << 2])
}
], ],
value: new Uint8Array([2 << 2]) outer: [new Uint8Array([2 << 2])]
}); });
}); });
}); });
+5 -17
View File
@@ -83,24 +83,12 @@ describe('CodecMap', (): void => {
])).inspect() ])).inspect()
).toEqual({ ).toEqual({
inner: [ inner: [
{ { outer: [new Uint8Array([1 << 2]), stringToU8a('1')] },
inner: [{ inner: [], value: stringToU8a('1') }], { outer: [new Uint8Array([3 << 2]), stringToU8a('foo')] },
value: new Uint8Array([1 << 2]) { outer: [new Uint8Array([1 << 2]), stringToU8a('2')] },
}, { outer: [new Uint8Array([3 << 2]), stringToU8a('bar')] }
{
inner: [{ inner: [], value: stringToU8a('foo') }],
value: new Uint8Array([3 << 2])
},
{
inner: [{ inner: [], value: stringToU8a('2') }],
value: new Uint8Array([1 << 2])
},
{
inner: [{ inner: [], value: stringToU8a('bar') }],
value: new Uint8Array([3 << 2])
}
], ],
value: new Uint8Array([2 << 2]) outer: [new Uint8Array([2 << 2])]
}); });
}); });
}); });
+1 -1
View File
@@ -165,7 +165,7 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
return { return {
inner, inner,
value: compactToU8a(this.size) outer: [compactToU8a(this.size)]
}; };
} }
@@ -32,10 +32,9 @@ describe('Range', (): void => {
it('has a sane inspect', (): void => { it('has a sane inspect', (): void => {
expect(range.inspect()).toEqual({ expect(range.inspect()).toEqual({
inner: [ inner: [
{ inner: [], value: new Uint8Array([1, 0, 0, 0]) }, { outer: [new Uint8Array([1, 0, 0, 0])] },
{ inner: [], value: new Uint8Array([2, 0, 0, 0]) } { outer: [new Uint8Array([2, 0, 0, 0])] }
], ]
value: new Uint8Array()
}); });
}); });
}); });
@@ -64,8 +64,7 @@ describe('U8aFixed', (): void => {
it('has a sane inspect', (): void => { it('has a sane inspect', (): void => {
expect(u8a.inspect()).toEqual({ expect(u8a.inspect()).toEqual({
inner: [], outer: [new Uint8Array([1, 2, 3, 4])]
value: new Uint8Array([1, 2, 3, 4])
}); });
}); });
}); });
@@ -54,8 +54,7 @@ describe('WrapperKeepOpaque', (): void => {
expect( expect(
new ClazzUSize(registry, u8au32).inspect() new ClazzUSize(registry, u8au32).inspect()
).toEqual({ ).toEqual({
inner: [{ inner: [], value: new Uint8Array([0x87, 0xd6, 0x12, 0x00]) }], outer: [new Uint8Array([4 << 2]), new Uint8Array([0x87, 0xd6, 0x12, 0x00])]
value: new Uint8Array([4 << 2])
}); });
}); });
@@ -63,8 +62,8 @@ describe('WrapperKeepOpaque', (): void => {
expect( expect(
new ClazzU32(registry, u8au32).inspect() new ClazzU32(registry, u8au32).inspect()
).toEqual({ ).toEqual({
inner: [{ inner: [], value: new Uint8Array([0x87, 0xd6, 0x12, 0x00]) }], inner: [{ outer: [new Uint8Array([0x87, 0xd6, 0x12, 0x00])] }],
value: new Uint8Array([4 << 2]) outer: [new Uint8Array([4 << 2])]
}); });
}); });
}); });
@@ -67,12 +67,14 @@ export class WrapperKeepOpaque<T extends Codec> extends Bytes {
* @description Returns a breakdown of the hex encoding for this Codec * @description Returns a breakdown of the hex encoding for this Codec
*/ */
override inspect (): Inspect { override inspect (): Inspect {
return { return this.#decoded
inner: this.#decoded ? {
? [this.#decoded.inspect()] inner: [this.#decoded.inspect()],
: [{ inner: [], value: this.toU8a(true) }], outer: [compactToU8a(this.length)]
value: compactToU8a(this.length) }
}; : {
outer: [compactToU8a(this.length), this.toU8a(true)]
};
} }
/** /**
@@ -49,8 +49,8 @@ describe('WrapperOpaque', (): void => {
expect( expect(
new WrapperOpaque(registry, 'u32', '0x12345678').inspect() new WrapperOpaque(registry, 'u32', '0x12345678').inspect()
).toEqual({ ).toEqual({
inner: [{ inner: [], value: new Uint8Array([0x78, 0x56, 0x34, 0x12]) }], inner: [{ outer: [new Uint8Array([0x78, 0x56, 0x34, 0x12])] }],
value: new Uint8Array([4 << 2]) outer: [new Uint8Array([4 << 2])]
}); });
}); });
}); });
+1 -2
View File
@@ -65,8 +65,7 @@ describe('Bool', (): void => {
it('has a sane inspect', (): void => { it('has a sane inspect', (): void => {
expect(new Bool(registry, true).inspect()).toEqual({ expect(new Bool(registry, true).inspect()).toEqual({
inner: [], outer: [new Uint8Array([1])]
value: new Uint8Array([1])
}); });
}); });
}); });
+1 -2
View File
@@ -86,8 +86,7 @@ export class bool extends Boolean implements Codec {
*/ */
inspect (): Inspect { inspect (): Inspect {
return { return {
inner: [], outer: [this.toU8a()]
value: this.toU8a()
}; };
} }
+1 -2
View File
@@ -76,8 +76,7 @@ describe('Date', (): void => {
it('has a sane inspect', (): void => { it('has a sane inspect', (): void => {
expect(new CodecDate(registry, 3).inspect()).toEqual({ expect(new CodecDate(registry, 3).inspect()).toEqual({
inner: [], outer: [new Uint8Array([3, 0, 0, 0, 0, 0, 0, 0])]
value: new Uint8Array([3, 0, 0, 0, 0, 0, 0, 0])
}); });
}); });
}); });
+1 -2
View File
@@ -83,8 +83,7 @@ export class CodecDate extends Date implements INumber {
*/ */
inspect (): Inspect { inspect (): Inspect {
return { return {
inner: [], outer: [this.toU8a()]
value: this.toU8a()
}; };
} }
+1 -2
View File
@@ -94,8 +94,7 @@ describe('Raw', (): void => {
expect( expect(
new Raw(registry, [1, 2, 3, 4, 5]).inspect() new Raw(registry, [1, 2, 3, 4, 5]).inspect()
).toEqual({ ).toEqual({
inner: [], outer: [new Uint8Array([1, 2, 3, 4, 5])]
value: new Uint8Array([1, 2, 3, 4, 5])
}); });
}); });
}); });
+1 -2
View File
@@ -96,8 +96,7 @@ export class Raw extends Uint8Array implements IU8a {
*/ */
inspect (): Inspect { inspect (): Inspect {
return { return {
inner: [], outer: [this.toU8a()]
value: this.toU8a()
}; };
} }
+1 -2
View File
@@ -98,8 +98,7 @@ describe('Set', (): void => {
it('has a sane inspect', (): void => { it('has a sane inspect', (): void => {
expect(set.inspect()).toEqual({ expect(set.inspect()).toEqual({
inner: [], outer: [new Uint8Array([SET_ROLES.full | SET_ROLES.authority])]
value: new Uint8Array([SET_ROLES.full | SET_ROLES.authority])
}); });
}); });
}); });
+1 -2
View File
@@ -189,8 +189,7 @@ export class CodecSet extends Set<string> implements ISet<string> {
*/ */
inspect (): Inspect { inspect (): Inspect {
return { return {
inner: [], outer: [this.toU8a()]
value: this.toU8a()
}; };
} }
+5 -10
View File
@@ -342,27 +342,22 @@ describe('Struct', (): void => {
).toEqual({ ).toEqual({
inner: [ inner: [
{ {
inner: [{ inner: [], value: new Uint8Array([0x42, 0x69]) }],
name: 'foo', name: 'foo',
value: new Uint8Array([2 << 2]) outer: [new Uint8Array([2 << 2]), new Uint8Array([0x42, 0x69])]
}, },
{ {
inner: [{ inner: [], value: new Uint8Array([0x99]) }],
name: 'method', name: 'method',
value: new Uint8Array([1 << 2]) outer: [new Uint8Array([1 << 2]), new Uint8Array([0x99])]
}, },
{ {
inner: [{ inner: [], value: new Uint8Array([1, 0, 0, 0]) }],
name: 'bar', name: 'bar',
value: new Uint8Array([1]) outer: [new Uint8Array([1]), new Uint8Array([1, 0, 0, 0])]
}, },
{ {
inner: [],
name: 'baz', name: 'baz',
value: new Uint8Array([1]) outer: [new Uint8Array([1])]
} }
], ]
value: new Uint8Array()
}); });
}); });
}); });
+1 -2
View File
@@ -227,8 +227,7 @@ export class Struct<
} }
return { return {
inner, inner
value: new Uint8Array()
}; };
} }
+1 -2
View File
@@ -70,8 +70,7 @@ describe('Text', (): void => {
expect( expect(
new Text(registry, 'abcde').inspect() new Text(registry, 'abcde').inspect()
).toEqual({ ).toEqual({
inner: [{ inner: [], value: stringToU8a('abcde') }], outer: [new Uint8Array([5 << 2]), stringToU8a('abcde')]
value: new Uint8Array([5 << 2])
}); });
}); });
}); });
+3 -2
View File
@@ -117,8 +117,9 @@ export class Text extends String implements Codec {
const value = stringToU8a(super.toString()); const value = stringToU8a(super.toString());
return { return {
inner: [{ inner: [], value }], outer: value.length
value: compactToU8a(value.length) ? [compactToU8a(value.length), value]
: [compactToU8a(value.length)]
}; };
} }
+2 -2
View File
@@ -9,9 +9,9 @@ import type { Registry } from './registry';
export type BareOpts = boolean | Record<string, boolean>; export type BareOpts = boolean | Record<string, boolean>;
export interface Inspect { export interface Inspect {
inner: Inspect[]; inner?: Inspect[];
name?: string; name?: string;
value?: Uint8Array; outer?: Uint8Array[];
} }
/** /**
+2 -5
View File
@@ -270,11 +270,8 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
const encoded = u8aConcat(...this.toU8aInner()); const encoded = u8aConcat(...this.toU8aInner());
return { return {
inner: [{ inner: this.inner.inspect().inner,
inner: this.inner.inspect().inner, outer: [compactToU8a(encoded.length), new Uint8Array([this.version])]
value: new Uint8Array([this.version])
}],
value: compactToU8a(encoded.length)
}; };
} }
+8 -6
View File
@@ -97,12 +97,14 @@ export class GenericLookupSource extends Base<GenericAccountId | GenericAccountI
const value = this.inner.toU8a().subarray(0, this._rawLength); const value = this.inner.toU8a().subarray(0, this._rawLength);
return { return {
inner: [{ inner: [], value }], outer: [
value: new Uint8Array( new Uint8Array(
this.inner instanceof GenericAccountIndex this.inner instanceof GenericAccountIndex
? GenericAccountIndex.writeLength(value) ? GenericAccountIndex.writeLength(value)
: ACCOUNT_ID_PREFIX : ACCOUNT_ID_PREFIX
) ),
value
]
}; };
} }
+13 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2022 @polkadot/types authors & contributors // Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Registry } from '@polkadot/types-codec/types'; import type { Inspect, Registry } from '@polkadot/types-codec/types';
import { Enum } from '@polkadot/types-codec'; import { Enum } from '@polkadot/types-codec';
import { isBn, isNumber, isString, isU8a } from '@polkadot/util'; import { isBn, isNumber, isString, isU8a } from '@polkadot/util';
@@ -52,6 +52,18 @@ export class GenericMultiAddress extends Enum {
}, decodeMultiAny(registry, value)); }, decodeMultiAny(registry, value));
} }
/**
* @description Returns a breakdown of the hex encoding for this Codec
*/
override inspect (): Inspect {
const { inner, outer = [] } = this.inner.inspect();
return {
inner: inner,
outer: [new Uint8Array([this.index]), ...outer]
};
}
/** /**
* @description Returns the string representation of the value * @description Returns the string representation of the value
*/ */
@@ -96,8 +96,7 @@ export function createKeyInspect (registry: Registry, itemFn: CreateItemFn, args
return { return {
inner: prefix inner: prefix
.concat(...extra) .concat(...extra)
.map((value, i) => ({ inner: [], name: names[i], value })), .map((v, i) => ({ name: names[i], outer: [v] }))
value: new Uint8Array()
}; };
} }