mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-11-01 06:39:48 +00:00
Move to @pezkuwi/dev 0.86 (eslint 10 toolchain)
- @pezkuwi/dev, dev-test, dev-ts ^0.86.3; disable directives renamed for the new rule names, or removed where the rule no longer reports - rethrown errors carry the original as `cause` (13 sites) - optional chains where a guard expression tested the same value - Init: the registry cache settles with the creator's own promise, dropping the entry in finally(), instead of re-wrapping it - Combinator: a typed call instead of `Function` - checkTypes.manual: synchronous checks run outside Promise.all - sortValues, createTypeUnsafe: initial values that were never read - typegen util: load docs.js for its side effect (it registers the `docs` Handlebars partial) now that its types are re-exported type-only - MockProvider keeps its Header assertion: the package's own build does not load api-augment, so createType returns a plain Codec there - Decorate keeps `delete queue[i]`: the hole marks a fired queue and later indexes must not shift
This commit is contained in:
1 parent
8c9af013b5
commit
60e0f73ffa
166 files changed
+2757
-3731
No files matched your search
@@ -226,7 +226,6 @@ describe('createType', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const cmpDef: any = registry.createType('TestComplex');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
||||
expect(cmpDef.balance.bitLength()).toEqual(128);
|
||||
|
||||
registry.clearCache();
|
||||
@@ -245,7 +244,6 @@ describe('createType', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const cmpu32: any = registry.createType('TestComplex');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
||||
expect(cmpu32.balance.bitLength()).toEqual(32);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import type { Codec, CodecClass } from '@pezkuwi/types-codec/types';
|
||||
|
||||
import { DoNotConstruct, Struct, Text, U32 } from '@pezkuwi/types-codec';
|
||||
@@ -30,7 +28,6 @@ describe('TypeRegistry', (): void => {
|
||||
const Type = registry.getOrUnknown('non-exist');
|
||||
|
||||
expect(Type).toBeDefined();
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
expect(isChildClass(DoNotConstruct, Type)).toBe(true);
|
||||
});
|
||||
|
||||
@@ -72,7 +69,6 @@ describe('TypeRegistry', (): void => {
|
||||
const first = new Recursive(registry, { next: last });
|
||||
|
||||
expect((first as any).next.isSome).toBe(true);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
expect((first as any).next.unwrap().next.isSome).toBe(false);
|
||||
});
|
||||
|
||||
@@ -153,9 +149,7 @@ describe('TypeRegistry', (): void => {
|
||||
});
|
||||
|
||||
expect(struct instanceof Struct).toBe(true);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
expect(struct.foo.toNumber()).toEqual(42);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
expect(struct.bar.toString()).toEqual('testing');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -472,10 +472,8 @@ export class TypeRegistry implements Registry {
|
||||
|
||||
public register (type: CodecClass | RegistryTypes): void;
|
||||
|
||||
// eslint-disable-next-line no-dupe-class-members
|
||||
public register (name: string, type: CodecClass): void;
|
||||
|
||||
// eslint-disable-next-line no-dupe-class-members
|
||||
public register (arg1: string | CodecClass | RegistryTypes, arg2?: CodecClass): void {
|
||||
// NOTE Constructors appear as functions here
|
||||
if (isFunction(arg1)) {
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import type { GenericEthereumAccountId as AccountId } from './AccountId.js';
|
||||
|
||||
import { Raw } from '@pezkuwi/types-codec';
|
||||
|
||||
@@ -12,7 +12,6 @@ import { decodeAddress } from '@pezkuwi/util-crypto';
|
||||
import { GenericAccountIndex } from '../generic/AccountIndex.js';
|
||||
import { GenericEthereumAccountId } from './AccountId.js';
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
type AnyAddress = bigint | BN | GenericEthereumLookupSource | GenericEthereumAccountId | GenericAccountIndex | number[] | Uint8Array | number | string;
|
||||
|
||||
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
|
||||
|
||||
@@ -50,7 +50,6 @@ const PreambleMask = {
|
||||
|
||||
const preambleUnMask: Record<string, Preamble> = {
|
||||
0: 'bare',
|
||||
// eslint-disable-next-line sort-keys
|
||||
64: 'general'
|
||||
};
|
||||
|
||||
@@ -342,7 +341,7 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
|
||||
*/
|
||||
public override get hash (): CodecHash {
|
||||
if (!this.#hashCache) {
|
||||
this.#hashCache = super.hash as CodecHash;
|
||||
this.#hashCache = super.hash;
|
||||
}
|
||||
|
||||
return this.#hashCache;
|
||||
|
||||
@@ -84,7 +84,7 @@ function decodeMortalU8a (registry: Registry, value: Uint8Array): MortalEraValue
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
|
||||
function decodeExtrinsicEra (value: IExtrinsicEra | MortalMethod | MortalEnumDef | ImmortalEnumDef | Uint8Array | string = new Uint8Array()): Uint8Array | Object | undefined {
|
||||
if (isU8a(value)) {
|
||||
return (!value.length || value[0] === 0)
|
||||
|
||||
@@ -18,7 +18,6 @@ registry.setMetadata(metadata);
|
||||
describe('SignerPayload', (): void => {
|
||||
const TEST = {
|
||||
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
|
||||
// eslint-disable-next-line sort-keys
|
||||
assetId: '0x0002043205ed01',
|
||||
blockHash: '0xde8f69eeb5e065e18c6950ff708d7e551f68dc9bf59a07c52367c0280f805ec7',
|
||||
blockNumber: '0x00231d30',
|
||||
@@ -62,7 +61,6 @@ describe('SignerPayload', (): void => {
|
||||
}).toPayload()
|
||||
).toEqual({
|
||||
address: '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE',
|
||||
// eslint-disable-next-line sort-keys
|
||||
assetId: '0x010002043205ed01',
|
||||
blockHash: '0xde8f69eeb5e065e18c6950ff708d7e551f68dc9bf59a07c52367c0280f805ec7',
|
||||
blockNumber: '0x00231d30',
|
||||
@@ -93,12 +91,10 @@ describe('SignerPayload', (): void => {
|
||||
|
||||
expect(
|
||||
test.toPayload().assetId
|
||||
// eslint-disable-next-line sort-keys
|
||||
).toEqual('0x010002043205ed01');
|
||||
|
||||
expect(
|
||||
new SignerPayload(registry, { assetId: 0 }).toPayload().assetId
|
||||
// eslint-disable-next-line sort-keys
|
||||
).toEqual('0x010000');
|
||||
});
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
|
||||
// the known defaults as managed explicitly and has different
|
||||
// formatting in cases, e.g. we mostly expose a hex format here
|
||||
address: this.address.toString(),
|
||||
assetId: this.assetId && this.assetId.isSome ? this.assetId.toHex() : null,
|
||||
assetId: this.assetId?.isSome ? this.assetId.toHex() : null,
|
||||
blockHash: this.blockHash.toHex(),
|
||||
blockNumber: this.blockNumber.toHex(),
|
||||
era: this.era.toHex(),
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import { Raw } from '@pezkuwi/types-codec';
|
||||
import jsonVec from '@pezkuwi/types-support/json/AccountIdVec.001.json' with { type: 'json' };
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ const MAX_4BYTE = new BN(1).shln(32);
|
||||
|
||||
/** @internal */
|
||||
function decodeAccountIndex (value: AnyNumber): BN | bigint | Uint8Array | number | string {
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
if (value instanceof GenericAccountIndex) {
|
||||
// `value.toBn()` on AccountIndex returns a pure BN (i.e. not an
|
||||
// AccountIndex), which has the initial `toString()` implementation.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import type { BlockValue } from './Block.js';
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import { isHex, isObject, isU8a, objectSpread, u8aToU8a } from '@pezkuwi/util';
|
||||
|
||||
interface DecodeMethodInput {
|
||||
args: unknown;
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
callIndex: GenericCallIndex | Uint8Array;
|
||||
}
|
||||
|
||||
@@ -40,7 +39,6 @@ function decodeCallViaObject (registry: Registry, value: DecodedMethod, _meta?:
|
||||
const { args, callIndex } = value;
|
||||
|
||||
// Get the correct lookupIndex
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
const lookupIndex = callIndex instanceof GenericCallIndex
|
||||
? callIndex.toU8a()
|
||||
: callIndex;
|
||||
@@ -141,7 +139,7 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
|
||||
// ignore
|
||||
}
|
||||
|
||||
throw new Error(`Call: failed decoding ${method}:: ${(error as Error).message}`);
|
||||
throw new Error(`Call: failed decoding ${method}:: ${(error as Error).message}`, { cause: error });
|
||||
}
|
||||
|
||||
this._meta = decoded.meta;
|
||||
|
||||
@@ -12,7 +12,6 @@ import { decodeAddress } from '@pezkuwi/util-crypto';
|
||||
import { GenericAccountId } from './AccountId.js';
|
||||
import { GenericAccountIndex } from './AccountIndex.js';
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
type AnyAddress = bigint | BN | GenericLookupSource | GenericAccountId | GenericAccountIndex | number[] | Uint8Array | number | string;
|
||||
|
||||
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
|
||||
|
||||
@@ -27,12 +27,10 @@ describe('GenericVote', (): void => {
|
||||
});
|
||||
|
||||
it('has isYay for positive', (): void => {
|
||||
// eslint-disable-next-line no-new-wrappers
|
||||
expect(new GenericVote(registry, true).isAye).toBe(true);
|
||||
});
|
||||
|
||||
it('has isNay for negative', (): void => {
|
||||
// eslint-disable-next-line no-new-wrappers
|
||||
expect(new GenericVote(registry, false).isNay).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ interface VoteType {
|
||||
conviction?: number | ArrayElementType<typeof AllConvictions>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
|
||||
type InputTypes = boolean | number | Boolean | Uint8Array | VoteType;
|
||||
|
||||
// For votes, the topmost bit indicated aye/nay, the lower bits indicate the conviction
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import type { ExtrinsicStatus } from './types.js';
|
||||
|
||||
import rpc from '@pezkuwi/types-support/json/ExtrinsicStatus.001.json' with { type: 'json' };
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ function inspectType (type: string): void {
|
||||
inspectType(sub.type);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(`${type}:: ${(error as Error).message}`);
|
||||
throw new Error(`${type}:: ${(error as Error).message}`, { cause: error });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import json3 from '@pezkuwi/types-support/json/GrandpaRoundstate.001.json' with { type: 'json' };
|
||||
|
||||
import { TypeRegistry } from '../../create/index.js';
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
export const AllHashers = {
|
||||
Blake2_128: null, // eslint-disable-line camelcase
|
||||
Blake2_256: null, // eslint-disable-line camelcase
|
||||
Blake2_128Concat: null, // eslint-disable-line camelcase
|
||||
Blake2_128: null,
|
||||
Blake2_256: null,
|
||||
Blake2_128Concat: null,
|
||||
Twox128: null,
|
||||
Twox256: null,
|
||||
Twox64Concat: null,
|
||||
|
||||
@@ -56,9 +56,9 @@ export const v10: DefinitionsTypes = {
|
||||
},
|
||||
StorageHasherV10: {
|
||||
_enum: {
|
||||
Blake2_128: null, // eslint-disable-line camelcase
|
||||
Blake2_256: null, // eslint-disable-line camelcase
|
||||
Blake2_128Concat: null, // eslint-disable-line camelcase
|
||||
Blake2_128: null,
|
||||
Blake2_256: null,
|
||||
Blake2_128Concat: null,
|
||||
Twox128: null,
|
||||
Twox256: null,
|
||||
Twox64Concat: null
|
||||
|
||||
@@ -73,8 +73,8 @@ export const v9: DefinitionsTypes = {
|
||||
},
|
||||
StorageHasherV9: {
|
||||
_enum: {
|
||||
Blake2_128: null, // eslint-disable-line camelcase
|
||||
Blake2_256: null, // eslint-disable-line camelcase
|
||||
Blake2_128: null,
|
||||
Blake2_256: null,
|
||||
Twox128: null,
|
||||
Twox256: null,
|
||||
Twox64Concat: null
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import json3 from '@pezkuwi/types-support/json/Header.003.json' with { type: 'json' };
|
||||
|
||||
import { TypeRegistry } from '../../create/index.js';
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import json1 from '@pezkuwi/types-support/json/Header.001.json' with { type: 'json' };
|
||||
import json2 from '@pezkuwi/types-support/json/Header.002.json' with { type: 'json' };
|
||||
import json3 from '@pezkuwi/types-support/json/Header.003.json' with { type: 'json' };
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import type { RuntimeVersion } from './types.js';
|
||||
|
||||
import rpc from '@pezkuwi/types-support/json/RuntimeVersion.002.json' with { type: 'json' };
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import { TypeRegistry } from '@pezkuwi/types/create';
|
||||
import json from '@pezkuwi/types-support/json/StorageChangeSet.001.json' with { type: 'json' };
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import json1 from '@pezkuwi/types-support/json/EventRecord.001.json' with { type: 'json' };
|
||||
import json3 from '@pezkuwi/types-support/json/EventRecord.003.json' with { type: 'json' };
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types/index.js';
|
||||
|
||||
|
||||
@@ -175,7 +175,8 @@ export class MetadataVersioned extends Struct {
|
||||
public override toJSON (): Record<string, AnyJson> {
|
||||
// HACK(y): ensure that we apply the aliases if we have not done so already, this is
|
||||
// needed to ensure we have the correct overrides (which is only applied in toLatest)
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- the getter is read for its side effect
|
||||
this.asLatest;
|
||||
|
||||
return super.toJSON();
|
||||
|
||||
@@ -733,7 +733,7 @@ export class PortableRegistry extends Struct implements ILookup {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(`PortableRegistry: ${lookupIndex}${namespace ? ` (${namespace})` : ''}: Error extracting ${stringify(type)}: ${(error as Error).message}`);
|
||||
throw new Error(`PortableRegistry: ${lookupIndex}${namespace ? ` (${namespace})` : ''}: Error extracting ${stringify(type)}: ${(error as Error).message}`, { cause: error });
|
||||
}
|
||||
|
||||
return objectSpread({
|
||||
|
||||
@@ -251,7 +251,7 @@ export function createFunction (registry: Registry, itemFn: CreateItemFn, option
|
||||
}
|
||||
|
||||
storageFn.keyPrefix = (...args: unknown[]): Uint8Array =>
|
||||
(storageFn.iterKey && storageFn.iterKey(...args)) ||
|
||||
(storageFn.iterKey?.(...args)) ||
|
||||
compactStripLength(storageFn())[1];
|
||||
|
||||
return storageFn;
|
||||
|
||||
@@ -14,11 +14,11 @@ export type HasherFunction = (data: HasherInput) => Uint8Array;
|
||||
const DEFAULT_FN = (data: HasherInput): Uint8Array => xxhashAsU8a(data, 128);
|
||||
|
||||
const HASHERS: Record<keyof typeof AllHashers, HasherFunction> = {
|
||||
Blake2_128: (data: HasherInput) => // eslint-disable-line camelcase
|
||||
Blake2_128: (data: HasherInput) =>
|
||||
blake2AsU8a(data, 128),
|
||||
Blake2_128Concat: (data: HasherInput) => // eslint-disable-line camelcase
|
||||
Blake2_128Concat: (data: HasherInput) =>
|
||||
u8aConcat(blake2AsU8a(data, 128), u8aToU8a(data)),
|
||||
Blake2_256: (data: HasherInput) => // eslint-disable-line camelcase
|
||||
Blake2_256: (data: HasherInput) =>
|
||||
blake2AsU8a(data, 256),
|
||||
Identity: (data: HasherInput) =>
|
||||
u8aToU8a(data),
|
||||
|
||||
@@ -30,7 +30,7 @@ export type ModuleEvents = Record<string, IsEvent<AnyTuple>>;
|
||||
|
||||
export type ModuleExtrinsics = Record<string, CallFunction>;
|
||||
|
||||
export type ModuleStorage = Record<string, StorageEntry>
|
||||
export type ModuleStorage = Record<string, StorageEntry>;
|
||||
|
||||
export type Constants = Record<string, ModuleConstants>;
|
||||
|
||||
@@ -38,7 +38,7 @@ export type Errors = Record<string, ModuleErrors>;
|
||||
|
||||
export type Events = Record<string, ModuleEvents>;
|
||||
|
||||
export type Extrinsics = Record<string, ModuleExtrinsics>
|
||||
export type Extrinsics = Record<string, ModuleExtrinsics>;
|
||||
|
||||
export type Storage = Record<string, ModuleStorage>;
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ export function defaultValues (registry: Registry, { data, fails = [] }: Check,
|
||||
const message = `${location}:: ${(error as Error).message}`;
|
||||
|
||||
if (withThrow && !fails.some((f) => location.includes(f))) {
|
||||
throw new Error(message);
|
||||
throw new Error(message, { cause: error });
|
||||
} else {
|
||||
console.warn(message);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ interface StorageKeyExtra {
|
||||
// hasher type -> [initialHashLength, canDecodeKey]
|
||||
const HASHER_MAP: Record<keyof typeof AllHashers, [number, boolean]> = {
|
||||
// opaque
|
||||
Blake2_128: [16, false], // eslint-disable-line camelcase
|
||||
Blake2_128Concat: [16, true], // eslint-disable-line camelcase
|
||||
Blake2_256: [32, false], // eslint-disable-line camelcase
|
||||
Blake2_128: [16, false],
|
||||
Blake2_128Concat: [16, true],
|
||||
Blake2_256: [32, false],
|
||||
Identity: [0, true],
|
||||
Twox128: [16, false],
|
||||
Twox256: [32, false],
|
||||
@@ -61,7 +61,7 @@ function decodeStorageKey (value?: string | Uint8Array | StorageKey | StorageEnt
|
||||
throw new Error('Expected function input for key construction');
|
||||
}
|
||||
|
||||
if (fn.meta && fn.meta.type.isMap) {
|
||||
if (fn.meta?.type.isMap) {
|
||||
const map = fn.meta.type.asMap;
|
||||
|
||||
if (!Array.isArray(args) || args.length !== map.hashers.length) {
|
||||
@@ -102,7 +102,7 @@ function decodeHashers <A extends AnyTuple> (registry: Registry, value: Uint8Arr
|
||||
|
||||
/** @internal */
|
||||
function decodeArgsFromMeta <A extends AnyTuple> (registry: Registry, value: Uint8Array, meta?: StorageEntryMetadataLatest): A {
|
||||
if (!meta || !meta.type.isMap) {
|
||||
if (!meta?.type.isMap) {
|
||||
return [] as unknown as A;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,17 +6,17 @@ import './augmentLookup.js';
|
||||
import './augmentRegistry.js';
|
||||
|
||||
// augmented exports
|
||||
export * from '@pezkuwi/types/types/registry';
|
||||
export type * from '@pezkuwi/types/types/registry';
|
||||
|
||||
// used inside augmented definitions
|
||||
export type { Observable } from 'rxjs';
|
||||
|
||||
// other exports
|
||||
export * from '../create/types.js';
|
||||
export * from './calls.js';
|
||||
export * from './codec.js';
|
||||
export * from './definitions.js';
|
||||
export * from './detect.js';
|
||||
export * from './events.js';
|
||||
export * from './extrinsic.js';
|
||||
export * from './interfaces.js';
|
||||
export type * from './calls.js';
|
||||
export type * from './codec.js';
|
||||
export type * from './definitions.js';
|
||||
export type * from './detect.js';
|
||||
export type * from './events.js';
|
||||
export type * from './extrinsic.js';
|
||||
export type * from './interfaces.js';
|
||||
@@ -19,21 +19,66 @@ export type { Registry, RegistryError, RegistryTypes } from '@pezkuwi/types-code
|
||||
|
||||
export interface InterfaceTypes {
|
||||
// base codec
|
||||
BitVec: BitVec, Bytes: Bytes, Json: Json, Null: Null, OptionBool: OptionBool, Raw: Raw, Text: Text, Type: Type,
|
||||
BitVec: BitVec,
|
||||
Bytes: Bytes,
|
||||
Json: Json,
|
||||
Null: Null,
|
||||
OptionBool: OptionBool,
|
||||
Raw: Raw,
|
||||
Text: Text,
|
||||
Type: Type,
|
||||
// base codec - upper variants
|
||||
Bool: Bool, F32: F32, F64: F64, I128: I128, I16: I16, I256: I256, I32: I32, I64: I64, I8: I8, ISize: ISize, U128: U128, U16: U16, U256: U256, U32: U32, U64: U64, U8: U8, USize: USize,
|
||||
Bool: Bool,
|
||||
F32: F32,
|
||||
F64: F64,
|
||||
I128: I128,
|
||||
I16: I16,
|
||||
I256: I256,
|
||||
I32: I32,
|
||||
I64: I64,
|
||||
I8: I8,
|
||||
ISize: ISize,
|
||||
U128: U128,
|
||||
U16: U16,
|
||||
U256: U256,
|
||||
U32: U32,
|
||||
U64: U64,
|
||||
U8: U8,
|
||||
USize: USize,
|
||||
// base codec - lower variants
|
||||
bool: bool, f32: f32, f64: f64, i128: i128, i16: i16, i256: i256, i32: i32, i64: i64, i8: i8, isize: isize, u128: u128, u16: u16, u256: u256, u32: u32, u64: u64, u8: u8, usize: usize,
|
||||
bool: bool,
|
||||
f32: f32,
|
||||
f64: f64,
|
||||
i128: i128,
|
||||
i16: i16,
|
||||
i256: i256,
|
||||
i32: i32,
|
||||
i64: i64,
|
||||
i8: i8,
|
||||
isize: isize,
|
||||
u128: u128,
|
||||
u16: u16,
|
||||
u256: u256,
|
||||
u32: u32,
|
||||
u64: u64,
|
||||
u8: u8,
|
||||
usize: usize,
|
||||
// extrinsic
|
||||
Extrinsic: GenericExtrinsic, ExtrinsicEra: GenericExtrinsicEra, ExtrinsicPayload: GenericExtrinsicPayload, SignerPayload: GenericSignerPayload,
|
||||
Extrinsic: GenericExtrinsic,
|
||||
ExtrinsicEra: GenericExtrinsicEra,
|
||||
ExtrinsicPayload: GenericExtrinsicPayload,
|
||||
SignerPayload: GenericSignerPayload,
|
||||
// generic
|
||||
Call: GenericCall,
|
||||
// primitive
|
||||
Data: Data, StorageKey: StorageKey,
|
||||
Data: Data,
|
||||
StorageKey: StorageKey,
|
||||
// metadata
|
||||
Metadata: Metadata, PortableRegistry: PortableRegistry,
|
||||
Metadata: Metadata,
|
||||
PortableRegistry: PortableRegistry,
|
||||
// interfaces
|
||||
HeaderPartial: HeaderPartial, RuntimeVersionPartial: RuntimeVersionPartial
|
||||
HeaderPartial: HeaderPartial,
|
||||
RuntimeVersionPartial: RuntimeVersionPartial
|
||||
}
|
||||
|
||||
export type CodecHasher = (data: Uint8Array) => Uint8Array;
|
||||
|
||||
Reference in new issue
Block a user