Adjust inspect inner/outer (#4553)
This commit is contained in:
@@ -84,7 +84,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
||||
inspect (): Inspect {
|
||||
return {
|
||||
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 {
|
||||
return {
|
||||
inner: [],
|
||||
value: this.toU8a()
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,7 @@ describe('Compact', (): void => {
|
||||
expect(
|
||||
new (Compact.with(U32))(registry, 0xffff).inspect()
|
||||
).toEqual({
|
||||
inner: [],
|
||||
value: new Uint8Array([254, 255, 3, 0])
|
||||
outer: [new Uint8Array([254, 255, 3, 0])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -105,8 +105,7 @@ export class Compact<T extends INumber> implements ICompact<T> {
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
return {
|
||||
inner: [],
|
||||
value: this.toU8a()
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -298,8 +298,7 @@ describe('Enum', (): void => {
|
||||
'0x0134120000'
|
||||
).inspect()
|
||||
).toEqual({
|
||||
inner: [{ inner: [], value: new Uint8Array([0x34, 0x12, 0x00, 0x00]) }],
|
||||
value: new Uint8Array([0x01])
|
||||
outer: [new Uint8Array([0x01]), new Uint8Array([0x34, 0x12, 0x00, 0x00])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -324,11 +324,15 @@ export class Enum implements IEnum {
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
if (this.isBasic) {
|
||||
return { outer: [new Uint8Array([this.index])] };
|
||||
}
|
||||
|
||||
const { inner, outer = [] } = this.#raw.inspect();
|
||||
|
||||
return {
|
||||
inner: this.isBasic
|
||||
? []
|
||||
: [this.#raw.inspect()],
|
||||
value: new Uint8Array([this.index])
|
||||
inner,
|
||||
outer: [new Uint8Array([this.index]), ...outer]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,7 @@ describe('Int', (): void => {
|
||||
expect(
|
||||
new Int(registry, '0x12', 16).inspect()
|
||||
).toEqual({
|
||||
inner: [],
|
||||
value: new Uint8Array([0x12, 0x00])
|
||||
outer: [new Uint8Array([0x12, 0x00])]
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -55,10 +55,7 @@ export class Null implements Codec {
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
return {
|
||||
inner: [],
|
||||
value: new Uint8Array()
|
||||
};
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,11 +158,7 @@ describe('Option', (): void => {
|
||||
expect(
|
||||
new Option(registry, U32, '1234').inspect()
|
||||
).toEqual({
|
||||
inner: [{
|
||||
inner: [],
|
||||
value: new Uint8Array([210, 4, 0, 0])
|
||||
}],
|
||||
value: new Uint8Array([0x01])
|
||||
outer: [new Uint8Array([0x01]), new Uint8Array([210, 4, 0, 0])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -141,15 +141,15 @@ export class Option<T extends Codec> implements IOption<T> {
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
if (this.isNone) {
|
||||
return { outer: [new Uint8Array([0])] };
|
||||
}
|
||||
|
||||
const { inner, outer = [] } = this.#raw.inspect();
|
||||
|
||||
return {
|
||||
inner: this.isSome
|
||||
? [this.#raw.inspect()]
|
||||
: [],
|
||||
value: new Uint8Array(
|
||||
this.isSome
|
||||
? [1]
|
||||
: [0]
|
||||
)
|
||||
inner,
|
||||
outer: [new Uint8Array([1]), ...outer]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -126,10 +126,9 @@ describe('Tuple', (): void => {
|
||||
tuple.inspect()
|
||||
).toEqual({
|
||||
inner: [
|
||||
{ inner: [{ inner: [], value: stringToU8a('bazzing') }], value: new Uint8Array([7 << 2]) },
|
||||
{ inner: [], value: new Uint8Array([69, 0, 0, 0]) }
|
||||
],
|
||||
value: new Uint8Array()
|
||||
{ outer: [new Uint8Array([7 << 2]), stringToU8a('bazzing')] },
|
||||
{ outer: [new Uint8Array([69, 0, 0, 0])] }
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -105,8 +105,7 @@ export class Tuple extends AbstractArray<Codec> implements ITuple<Codec[]> {
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
return {
|
||||
inner: this.inspectInner(),
|
||||
value: new Uint8Array()
|
||||
inner: this.inspectInner()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -127,8 +127,7 @@ describe('UInt', (): void => {
|
||||
expect(
|
||||
new UInt(registry, '0x12', 16).inspect()
|
||||
).toEqual({
|
||||
inner: [],
|
||||
value: new Uint8Array([0x12, 0x00])
|
||||
outer: [new Uint8Array([0x12, 0x00])]
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -184,10 +184,9 @@ describe('Vec', (): void => {
|
||||
|
||||
expect(vec.inspect()).toEqual({
|
||||
inner: addrs.map((a) => ({
|
||||
inner: [],
|
||||
value: decodeAddress(a)
|
||||
outer: [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 => {
|
||||
expect(test.inspect()).toEqual({
|
||||
inner: [
|
||||
{ inner: [{ inner: [], value: stringToU8a('1') }], value: new Uint8Array([1 << 2]) },
|
||||
{ inner: [{ inner: [], value: stringToU8a('2') }], value: new Uint8Array([1 << 2]) },
|
||||
{ inner: [{ inner: [], value: stringToU8a('3') }], value: new Uint8Array([1 << 2]) },
|
||||
{ inner: [{ inner: [], value: new Uint8Array() }], value: new Uint8Array([0]) },
|
||||
{ inner: [{ inner: [], value: stringToU8a('56') }], value: new Uint8Array([2 << 2]) }
|
||||
],
|
||||
value: new Uint8Array()
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('1')] },
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('2')] },
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('3')] },
|
||||
{ outer: [new Uint8Array([0])] },
|
||||
{ outer: [new Uint8Array([2 << 2]), stringToU8a('56')] }
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,8 +75,7 @@ export class VecFixed<T extends Codec> extends AbstractArray<T> {
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
return {
|
||||
inner: this.inspectInner(),
|
||||
value: new Uint8Array()
|
||||
inner: this.inspectInner()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -198,32 +198,14 @@ describe('BTreeMap', (): void => {
|
||||
])).inspect()
|
||||
).toEqual({
|
||||
inner: [
|
||||
{
|
||||
inner: [{ inner: [], value: stringToU8a('1') }],
|
||||
value: new Uint8Array([1 << 2])
|
||||
},
|
||||
{
|
||||
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])
|
||||
},
|
||||
{
|
||||
inner: [{ inner: [], value: stringToU8a('3') }],
|
||||
value: new Uint8Array([1 << 2])
|
||||
},
|
||||
{
|
||||
inner: [{ inner: [], value: stringToU8a('baz') }],
|
||||
value: new Uint8Array([3 << 2])
|
||||
}
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('1')] },
|
||||
{ outer: [new Uint8Array([3 << 2]), stringToU8a('foo')] },
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('2')] },
|
||||
{ outer: [new Uint8Array([3 << 2]), stringToU8a('bar')] },
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('3')] },
|
||||
{ outer: [new Uint8Array([3 << 2]), stringToU8a('baz')] }
|
||||
],
|
||||
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()
|
||||
).toEqual({
|
||||
inner: [
|
||||
{ inner: [], value: new Uint8Array([1, 0, 0, 0]) },
|
||||
{ inner: [], value: new Uint8Array([2, 0, 0, 0]) },
|
||||
{ inner: [], value: new Uint8Array([3, 0, 0, 0]) },
|
||||
{ inner: [], value: new Uint8Array([4, 0, 0, 0]) }
|
||||
{ outer: [new Uint8Array([1, 0, 0, 0])] },
|
||||
{ outer: [new Uint8Array([2, 0, 0, 0])] },
|
||||
{ outer: [new Uint8Array([3, 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 {
|
||||
inner,
|
||||
value: compactToU8a(this.size)
|
||||
outer: [compactToU8a(this.size)]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,7 @@ describe('BitVec', (): void => {
|
||||
expect(
|
||||
new BitVec(registry, '0x0837').inspect()
|
||||
).toEqual({
|
||||
inner: [
|
||||
{ inner: [], value: new Uint8Array([0x08, 0x37]) }
|
||||
],
|
||||
value: new Uint8Array([0])
|
||||
outer: [new Uint8Array([0]), new Uint8Array([0x08, 0x37])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -62,8 +62,7 @@ export class BitVec extends Raw {
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
return {
|
||||
inner: [{ inner: [], value: super.toU8a() }],
|
||||
value: compactToU8a(this.#decodedLength)
|
||||
outer: [compactToU8a(this.#decodedLength), super.toU8a()]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,7 @@ describe('Bytes', (): void => {
|
||||
expect(
|
||||
new Bytes(registry, '0x12345678').inspect()
|
||||
).toEqual({
|
||||
inner: [{ inner: [], value: new Uint8Array([0x12, 0x34, 0x56, 0x78]) }],
|
||||
value: new Uint8Array([4 << 2])
|
||||
outer: [new Uint8Array([4 << 2]), new Uint8Array([0x12, 0x34, 0x56, 0x78])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,9 +64,12 @@ export class Bytes extends Raw {
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
const clength = compactToU8a(this.length);
|
||||
|
||||
return {
|
||||
inner: [{ inner: [], value: super.toU8a() }],
|
||||
value: compactToU8a(this.length)
|
||||
outer: this.length
|
||||
? [clength, super.toU8a()]
|
||||
: [clength]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -23,24 +23,12 @@ describe('HashMap', (): void => {
|
||||
])).inspect()
|
||||
).toEqual({
|
||||
inner: [
|
||||
{
|
||||
inner: [{ inner: [], value: stringToU8a('1') }],
|
||||
value: new Uint8Array([1 << 2])
|
||||
},
|
||||
{
|
||||
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])
|
||||
}
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('1')] },
|
||||
{ outer: [new Uint8Array([3 << 2]), stringToU8a('foo')] },
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('2')] },
|
||||
{ outer: [new Uint8Array([3 << 2]), stringToU8a('bar')] }
|
||||
],
|
||||
value: new Uint8Array([2 << 2])
|
||||
outer: [new Uint8Array([2 << 2])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -83,24 +83,12 @@ describe('CodecMap', (): void => {
|
||||
])).inspect()
|
||||
).toEqual({
|
||||
inner: [
|
||||
{
|
||||
inner: [{ inner: [], value: stringToU8a('1') }],
|
||||
value: new Uint8Array([1 << 2])
|
||||
},
|
||||
{
|
||||
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])
|
||||
}
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('1')] },
|
||||
{ outer: [new Uint8Array([3 << 2]), stringToU8a('foo')] },
|
||||
{ outer: [new Uint8Array([1 << 2]), stringToU8a('2')] },
|
||||
{ outer: [new Uint8Array([3 << 2]), stringToU8a('bar')] }
|
||||
],
|
||||
value: new Uint8Array([2 << 2])
|
||||
outer: [new Uint8Array([2 << 2])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -165,7 +165,7 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
|
||||
|
||||
return {
|
||||
inner,
|
||||
value: compactToU8a(this.size)
|
||||
outer: [compactToU8a(this.size)]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +32,9 @@ describe('Range', (): void => {
|
||||
it('has a sane inspect', (): void => {
|
||||
expect(range.inspect()).toEqual({
|
||||
inner: [
|
||||
{ inner: [], value: new Uint8Array([1, 0, 0, 0]) },
|
||||
{ inner: [], value: new Uint8Array([2, 0, 0, 0]) }
|
||||
],
|
||||
value: new Uint8Array()
|
||||
{ outer: [new Uint8Array([1, 0, 0, 0])] },
|
||||
{ outer: [new Uint8Array([2, 0, 0, 0])] }
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,8 +64,7 @@ describe('U8aFixed', (): void => {
|
||||
|
||||
it('has a sane inspect', (): void => {
|
||||
expect(u8a.inspect()).toEqual({
|
||||
inner: [],
|
||||
value: new Uint8Array([1, 2, 3, 4])
|
||||
outer: [new Uint8Array([1, 2, 3, 4])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,8 +54,7 @@ describe('WrapperKeepOpaque', (): void => {
|
||||
expect(
|
||||
new ClazzUSize(registry, u8au32).inspect()
|
||||
).toEqual({
|
||||
inner: [{ inner: [], value: new Uint8Array([0x87, 0xd6, 0x12, 0x00]) }],
|
||||
value: new Uint8Array([4 << 2])
|
||||
outer: [new Uint8Array([4 << 2]), new Uint8Array([0x87, 0xd6, 0x12, 0x00])]
|
||||
});
|
||||
});
|
||||
|
||||
@@ -63,8 +62,8 @@ describe('WrapperKeepOpaque', (): void => {
|
||||
expect(
|
||||
new ClazzU32(registry, u8au32).inspect()
|
||||
).toEqual({
|
||||
inner: [{ inner: [], value: new Uint8Array([0x87, 0xd6, 0x12, 0x00]) }],
|
||||
value: new Uint8Array([4 << 2])
|
||||
inner: [{ outer: [new Uint8Array([0x87, 0xd6, 0x12, 0x00])] }],
|
||||
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
|
||||
*/
|
||||
override inspect (): Inspect {
|
||||
return {
|
||||
inner: this.#decoded
|
||||
? [this.#decoded.inspect()]
|
||||
: [{ inner: [], value: this.toU8a(true) }],
|
||||
value: compactToU8a(this.length)
|
||||
};
|
||||
return this.#decoded
|
||||
? {
|
||||
inner: [this.#decoded.inspect()],
|
||||
outer: [compactToU8a(this.length)]
|
||||
}
|
||||
: {
|
||||
outer: [compactToU8a(this.length), this.toU8a(true)]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,8 +49,8 @@ describe('WrapperOpaque', (): void => {
|
||||
expect(
|
||||
new WrapperOpaque(registry, 'u32', '0x12345678').inspect()
|
||||
).toEqual({
|
||||
inner: [{ inner: [], value: new Uint8Array([0x78, 0x56, 0x34, 0x12]) }],
|
||||
value: new Uint8Array([4 << 2])
|
||||
inner: [{ outer: [new Uint8Array([0x78, 0x56, 0x34, 0x12])] }],
|
||||
outer: [new Uint8Array([4 << 2])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,8 +65,7 @@ describe('Bool', (): void => {
|
||||
|
||||
it('has a sane inspect', (): void => {
|
||||
expect(new Bool(registry, true).inspect()).toEqual({
|
||||
inner: [],
|
||||
value: new Uint8Array([1])
|
||||
outer: [new Uint8Array([1])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -86,8 +86,7 @@ export class bool extends Boolean implements Codec {
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
return {
|
||||
inner: [],
|
||||
value: this.toU8a()
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,7 @@ describe('Date', (): void => {
|
||||
|
||||
it('has a sane inspect', (): void => {
|
||||
expect(new CodecDate(registry, 3).inspect()).toEqual({
|
||||
inner: [],
|
||||
value: new Uint8Array([3, 0, 0, 0, 0, 0, 0, 0])
|
||||
outer: [new Uint8Array([3, 0, 0, 0, 0, 0, 0, 0])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -83,8 +83,7 @@ export class CodecDate extends Date implements INumber {
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
return {
|
||||
inner: [],
|
||||
value: this.toU8a()
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -94,8 +94,7 @@ describe('Raw', (): void => {
|
||||
expect(
|
||||
new Raw(registry, [1, 2, 3, 4, 5]).inspect()
|
||||
).toEqual({
|
||||
inner: [],
|
||||
value: new Uint8Array([1, 2, 3, 4, 5])
|
||||
outer: [new Uint8Array([1, 2, 3, 4, 5])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -96,8 +96,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
return {
|
||||
inner: [],
|
||||
value: this.toU8a()
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +98,7 @@ describe('Set', (): void => {
|
||||
|
||||
it('has a sane inspect', (): void => {
|
||||
expect(set.inspect()).toEqual({
|
||||
inner: [],
|
||||
value: new Uint8Array([SET_ROLES.full | SET_ROLES.authority])
|
||||
outer: [new Uint8Array([SET_ROLES.full | SET_ROLES.authority])]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -189,8 +189,7 @@ export class CodecSet extends Set<string> implements ISet<string> {
|
||||
*/
|
||||
inspect (): Inspect {
|
||||
return {
|
||||
inner: [],
|
||||
value: this.toU8a()
|
||||
outer: [this.toU8a()]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -342,27 +342,22 @@ describe('Struct', (): void => {
|
||||
).toEqual({
|
||||
inner: [
|
||||
{
|
||||
inner: [{ inner: [], value: new Uint8Array([0x42, 0x69]) }],
|
||||
name: 'foo',
|
||||
value: new Uint8Array([2 << 2])
|
||||
outer: [new Uint8Array([2 << 2]), new Uint8Array([0x42, 0x69])]
|
||||
},
|
||||
{
|
||||
inner: [{ inner: [], value: new Uint8Array([0x99]) }],
|
||||
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',
|
||||
value: new Uint8Array([1])
|
||||
outer: [new Uint8Array([1]), new Uint8Array([1, 0, 0, 0])]
|
||||
},
|
||||
{
|
||||
inner: [],
|
||||
name: 'baz',
|
||||
value: new Uint8Array([1])
|
||||
outer: [new Uint8Array([1])]
|
||||
}
|
||||
],
|
||||
value: new Uint8Array()
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -227,8 +227,7 @@ export class Struct<
|
||||
}
|
||||
|
||||
return {
|
||||
inner,
|
||||
value: new Uint8Array()
|
||||
inner
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ describe('Text', (): void => {
|
||||
expect(
|
||||
new Text(registry, 'abcde').inspect()
|
||||
).toEqual({
|
||||
inner: [{ inner: [], value: stringToU8a('abcde') }],
|
||||
value: new Uint8Array([5 << 2])
|
||||
outer: [new Uint8Array([5 << 2]), stringToU8a('abcde')]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -117,8 +117,9 @@ export class Text extends String implements Codec {
|
||||
const value = stringToU8a(super.toString());
|
||||
|
||||
return {
|
||||
inner: [{ inner: [], value }],
|
||||
value: compactToU8a(value.length)
|
||||
outer: value.length
|
||||
? [compactToU8a(value.length), value]
|
||||
: [compactToU8a(value.length)]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import type { Registry } from './registry';
|
||||
export type BareOpts = boolean | Record<string, boolean>;
|
||||
|
||||
export interface Inspect {
|
||||
inner: Inspect[];
|
||||
inner?: Inspect[];
|
||||
name?: string;
|
||||
value?: Uint8Array;
|
||||
outer?: Uint8Array[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user