Optimize Compact decoding in Uint8Array streams (#4808)

* Optimize Compact decoding in Uint8Array streams

* Adjust test

* Adjust
This commit is contained in:
Jaco
2022-05-09 13:19:05 +03:00
committed by GitHub
parent 2edcef6ff5
commit fd568c0341
5 changed files with 13 additions and 12 deletions
@@ -16,7 +16,7 @@ export function createUnchecked (registry: Registry, section: string, callIndex:
const expectedArgs = callMetadata.fields;
const funcName = stringCamelCase(callMetadata.name);
const extrinsicFn = (...args: any[]): Call => {
const extrinsicFn = (...args: unknown[]): Call => {
assert(expectedArgs.length === args.length, () => `Extrinsic ${section}.${funcName} expects ${expectedArgs.length} arguments, got ${args.length}.`);
return registry.createTypeUnsafe('Call', [{ args, callIndex }, callMetadata]);
@@ -64,7 +64,7 @@ describe('decorateExtrinsics', (): void => {
it('should return properly-encoded transactions', (): void => {
expect(
registry.createType('Extrinsic', extrinsics.timestamp.set([10101])).toU8a()
registry.createType('Extrinsic', extrinsics.timestamp.set(32)).toU8a()
).toEqual(
new Uint8Array([
// length (encoded)
@@ -74,7 +74,7 @@ describe('decorateExtrinsics', (): void => {
// index
3, 0,
// values, Compact<Moment>
116
32 << 2
])
);
});
@@ -31,7 +31,7 @@ describe('Decorated', () => {
const tx = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
expect(
registry.createType('Extrinsic', tx.timestamp.set([10101])).toU8a()
registry.createType('Extrinsic', tx.timestamp.set(63)).toU8a()
).toEqual(
new Uint8Array([
// length (encoded)
@@ -41,7 +41,7 @@ describe('Decorated', () => {
// index
3, 0,
// values, Compact<Moment>
116
63 << 2
])
);
});