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
+2 -5
View File
@@ -270,11 +270,8 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
const encoded = u8aConcat(...this.toU8aInner());
return {
inner: [{
inner: this.inner.inspect().inner,
value: new Uint8Array([this.version])
}],
value: compactToU8a(encoded.length)
inner: this.inner.inspect().inner,
outer: [compactToU8a(encoded.length), new Uint8Array([this.version])]
};
}
+8 -6
View File
@@ -97,12 +97,14 @@ export class GenericLookupSource extends Base<GenericAccountId | GenericAccountI
const value = this.inner.toU8a().subarray(0, this._rawLength);
return {
inner: [{ inner: [], value }],
value: new Uint8Array(
this.inner instanceof GenericAccountIndex
? GenericAccountIndex.writeLength(value)
: ACCOUNT_ID_PREFIX
)
outer: [
new Uint8Array(
this.inner instanceof GenericAccountIndex
? GenericAccountIndex.writeLength(value)
: ACCOUNT_ID_PREFIX
),
value
]
};
}
+13 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// 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 { isBn, isNumber, isString, isU8a } from '@polkadot/util';
@@ -52,6 +52,18 @@ export class GenericMultiAddress extends Enum {
}, 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
*/
@@ -96,8 +96,7 @@ export function createKeyInspect (registry: Registry, itemFn: CreateItemFn, args
return {
inner: prefix
.concat(...extra)
.map((value, i) => ({ inner: [], name: names[i], value })),
value: new Uint8Array()
.map((v, i) => ({ name: names[i], outer: [v] }))
};
}