Align tsconfig to allow moduleResolution: nodenext (#5530)
* Align tsconfig to allow moduleResolution: nodenext * Small adjustments (revert nodenext req. changes) * Adjust for current compilation * Read metadata compare from file * Adjust * Fix assertions
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { AnyString, Codec, CodecClass, IU8a, LookupString } from '@polkadot/types-codec/types';
|
||||
import type { CreateOptions, TypeDef } from '@polkadot/types-create/types';
|
||||
import type { ExtDef } from '../extrinsic/signedExtensions/types';
|
||||
import type { ExtDef } from '../extrinsic/signedExtensions/types.js';
|
||||
import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, EventMetadataLatest, Hash, MetadataLatest, SiField, SiLookupTypeId, SiVariant, WeightV1, WeightV2 } from '../interfaces/types.js';
|
||||
import type { CallFunction, CodecHasher, Definitions, DetectCodec, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types/index.js';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { Address, BlockHash, Call, ExtrinsicEra, Hash } from '../interfaces';
|
||||
import type { Address, BlockHash, Call, ExtrinsicEra, Hash } from '../interfaces/index.js';
|
||||
import type { Codec, ICompact, INumber, IRuntimeVersion, ISignerPayload, SignerPayloadJSON, SignerPayloadRaw } from '../types/index.js';
|
||||
|
||||
import { Option, Struct, Text, Vec } from '@polkadot/types-codec';
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { ExtrinsicSignatureV4 } from '../../interfaces/extrinsics';
|
||||
import type { Address, Call } from '../../interfaces/runtime';
|
||||
import type { ExtrinsicSignatureV4 } from '../../interfaces/extrinsics/index.js';
|
||||
import type { Address, Call } from '../../interfaces/runtime/index.js';
|
||||
import type { ExtrinsicPayloadValue, IExtrinsicImpl, IKeyringPair, Registry, SignatureOptions } from '../../types/index.js';
|
||||
import type { ExtrinsicOptions } from '../types.js';
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { EcdsaSignature, Ed25519Signature, ExtrinsicEra, ExtrinsicSignature, Sr25519Signature } from '../../interfaces/extrinsics';
|
||||
import type { Address, Call } from '../../interfaces/runtime';
|
||||
import type { EcdsaSignature, Ed25519Signature, ExtrinsicEra, ExtrinsicSignature, Sr25519Signature } from '../../interfaces/extrinsics/index.js';
|
||||
import type { Address, Call } from '../../interfaces/runtime/index.js';
|
||||
import type { ExtrinsicPayloadValue, ICompact, IExtrinsicSignature, IKeyringPair, INumber, Registry, SignatureOptions } from '../../types/index.js';
|
||||
import type { ExtrinsicSignatureOptions } from '../types.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AnyU8a, Registry } from '@polkadot/types-codec/types';
|
||||
import type { AccountId, RawAuraPreDigest, RawBabePreDigestCompat } from '../interfaces';
|
||||
import type { AccountId, RawAuraPreDigest, RawBabePreDigestCompat } from '../interfaces/index.js';
|
||||
|
||||
import { Bytes, U8aFixed, u32 } from '@polkadot/types-codec';
|
||||
import { BN, bnToU8a, isNumber, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Option, Text, Type, Vec } from '@polkadot/types-codec';
|
||||
import type { AnyString, LookupString, Registry } from '@polkadot/types-codec/types';
|
||||
import type { ILookup, TypeDef } from '@polkadot/types-create/types';
|
||||
import type { PortableType } from '../../interfaces/metadata/index.js';
|
||||
import type { SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '../../interfaces/scaleInfo';
|
||||
import type { SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '../../interfaces/scaleInfo/index.js';
|
||||
|
||||
import { sanitize, Struct, u32 } from '@polkadot/types-codec';
|
||||
import { getTypeDef, TypeDefInfo, withTypeString } from '@polkadot/types-create';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { PortableType, Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefComposite, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefVariant, Si1Field, Si1TypeDef, SiTypeDef } from '../../interfaces';
|
||||
import type { PortableType, Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefComposite, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefVariant, Si1Field, Si1TypeDef, SiTypeDef } from '../../interfaces/index.js';
|
||||
import type { Registry } from '../../types/index.js';
|
||||
|
||||
import { assertUnreachable } from '@polkadot/util';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { BlockNumber } from '../../../interfaces';
|
||||
import type { BlockNumber } from '../../../interfaces/index.js';
|
||||
import type { Constants } from '../types.js';
|
||||
|
||||
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { MetadataLatest, PalletConstantMetadataLatest } from '../../../interfaces';
|
||||
import type { MetadataLatest, PalletConstantMetadataLatest } from '../../../interfaces/index.js';
|
||||
import type { ConstantCodec, Constants } from '../types.js';
|
||||
|
||||
import { hexToU8a, lazyMethod, lazyMethods, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
import type { Text, u8 } from '@polkadot/types-codec';
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, MetadataLatest, SiField, SiVariant } from '../../../interfaces';
|
||||
import type { PortableRegistry } from '../../../metadata';
|
||||
import type { DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, MetadataLatest, SiField, SiVariant } from '../../../interfaces/index.js';
|
||||
import type { PortableRegistry } from '../../../metadata/index.js';
|
||||
import type { Errors, IsError } from '../types.js';
|
||||
|
||||
import { isCodec, isU8a, lazyMethod, objectSpread, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AnyTuple, Registry } from '@polkadot/types-codec/types';
|
||||
import type { MetadataLatest, PalletMetadataLatest, SiVariant } from '../../../interfaces';
|
||||
import type { MetadataLatest, PalletMetadataLatest, SiVariant } from '../../../interfaces/index.js';
|
||||
import type { IEvent, IEventLike } from '../../../types/index.js';
|
||||
import type { Events, IsEvent } from '../types.js';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AnyJson, AnyTuple, Registry } from '@polkadot/types-codec/types';
|
||||
import type { Call, FunctionMetadataLatest } from '../../../interfaces';
|
||||
import type { Call, FunctionMetadataLatest } from '../../../interfaces/index.js';
|
||||
import type { CallFunction, IMethod } from '../../../types/index.js';
|
||||
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { MetadataLatest, PalletMetadataLatest, SiVariant } from '../../../interfaces';
|
||||
import type { PortableRegistry } from '../../../metadata';
|
||||
import type { MetadataLatest, PalletMetadataLatest, SiVariant } from '../../../interfaces/index.js';
|
||||
import type { PortableRegistry } from '../../../metadata/index.js';
|
||||
import type { CallFunction } from '../../../types/index.js';
|
||||
import type { Extrinsics } from '../types.js';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getTypeDef, TypeDefInfo } from '@polkadot/types-create';
|
||||
type Extracted = string | Extracted[];
|
||||
|
||||
function extractSubSingle (_: string, { sub }: TypeDef): Extracted[] {
|
||||
const { lookupName, type } = sub as TypeDef;
|
||||
const { lookupName, type } = sub as unknown as TypeDef;
|
||||
|
||||
return extractTypes([lookupName || type]);
|
||||
}
|
||||
|
||||
@@ -16,16 +16,22 @@ import { unwrapStorageSi, unwrapStorageType } from '../../primitive/StorageKey.j
|
||||
import { Metadata } from '../Metadata.js';
|
||||
import { getUniqTypes } from './getUniqTypes.js';
|
||||
|
||||
function getJsonName (version: number, type: string, sub: 'json' | 'types'): string {
|
||||
return path.join(process.cwd(), `packages/types-support/src/metadata/v${version}/${type}-${sub}.json`);
|
||||
}
|
||||
|
||||
function writeJson (json: unknown, version: number, type: string, sub: 'json' | 'types'): void {
|
||||
fs.writeFileSync(
|
||||
path.join(process.cwd(), `packages/types-support/src/metadata/v${version}/${type}-${sub}.json`),
|
||||
stringify(json, 2),
|
||||
{ flag: 'w' }
|
||||
);
|
||||
fs.writeFileSync(getJsonName(version, type, sub), stringify(json, 2), { flag: 'w' });
|
||||
}
|
||||
|
||||
function readJson <T = unknown> (version: number, type: string, sub: 'json' | 'types'): T {
|
||||
return JSON.parse(
|
||||
fs.readFileSync(getJsonName(version, type, sub), 'utf-8')
|
||||
) as unknown as T;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function decodeLatestMeta (registry: Registry, type: string, version: number, { compare, data, types }: Check): void {
|
||||
export function decodeLatestMeta (registry: Registry, type: string, version: number, { data }: Check): void {
|
||||
const metadata = new Metadata(registry, data);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
@@ -38,35 +44,39 @@ export function decodeLatestMeta (registry: Registry, type: string, version: num
|
||||
expect(metadata.version).toBe(version);
|
||||
|
||||
try {
|
||||
expect(json).toEqual(compare);
|
||||
expect(json).toEqual(readJson(version, type, 'json'));
|
||||
} catch (error) {
|
||||
if (process.env.GITHUB_REPOSITORY) {
|
||||
console.error(stringify(json));
|
||||
|
||||
throw error;
|
||||
} else {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
writeJson(json, version, type, 'json');
|
||||
}
|
||||
});
|
||||
|
||||
it('decodes latest types correctly', (): void => {
|
||||
if (types) {
|
||||
if (version >= 14) {
|
||||
it('decodes latest types correctly', (): void => {
|
||||
const json = metadata.asLatest.lookup.types.toJSON();
|
||||
|
||||
try {
|
||||
expect(json).toEqual(types);
|
||||
expect(json).toEqual(readJson(version, type, 'types'));
|
||||
} catch (error) {
|
||||
if (process.env.GITHUB_REPOSITORY) {
|
||||
console.error(stringify(metadata.toJSON()));
|
||||
|
||||
throw error;
|
||||
} else {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
writeJson(json, version, type, 'types');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
export interface Check {
|
||||
compare: Record<string, unknown>;
|
||||
data: HexString;
|
||||
fails?: string[];
|
||||
types?: unknown[];
|
||||
}
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import substrateData from '@polkadot/types-support/metadata/v10/substrate-hex';
|
||||
import substrateJson from '@polkadot/types-support/metadata/v10/substrate-json.json' assert { type: 'json' };
|
||||
|
||||
import { testMeta } from '../util/testUtil.js';
|
||||
|
||||
testMeta(10, {
|
||||
substrate: {
|
||||
compare: substrateJson as Record<string, unknown>,
|
||||
data: substrateData
|
||||
}
|
||||
}, false);
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import substrateData from '@polkadot/types-support/metadata/v11/substrate-hex';
|
||||
import substrateJson from '@polkadot/types-support/metadata/v11/substrate-json.json' assert { type: 'json' };
|
||||
|
||||
import { testMeta } from '../util/testUtil.js';
|
||||
|
||||
testMeta(11, {
|
||||
substrate: {
|
||||
compare: substrateJson as Record<string, unknown>,
|
||||
data: substrateData
|
||||
}
|
||||
}, false);
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import substrateData from '@polkadot/types-support/metadata/v12/substrate-hex';
|
||||
import substrateJson from '@polkadot/types-support/metadata/v12/substrate-json.json' assert { type: 'json' };
|
||||
|
||||
import { testMeta } from '../util/testUtil.js';
|
||||
|
||||
testMeta(12, {
|
||||
substrate: {
|
||||
compare: substrateJson as Record<string, unknown>,
|
||||
data: substrateData
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,17 +2,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import kusamaData from '@polkadot/types-support/metadata/v13/kusama-hex';
|
||||
import kusamaJson from '@polkadot/types-support/metadata/v13/kusama-json.json' assert { type: 'json' };
|
||||
import polkadotData from '@polkadot/types-support/metadata/v13/polkadot-hex';
|
||||
import polkadotJson from '@polkadot/types-support/metadata/v13/polkadot-json.json' assert { type: 'json' };
|
||||
import substrateData from '@polkadot/types-support/metadata/v13/substrate-hex';
|
||||
import substrateJson from '@polkadot/types-support/metadata/v13/substrate-json.json' assert { type: 'json' };
|
||||
|
||||
import { testMeta } from '../util/testUtil.js';
|
||||
|
||||
testMeta(13, {
|
||||
kusama: {
|
||||
compare: kusamaJson as Record<string, unknown>,
|
||||
data: kusamaData,
|
||||
fails: [
|
||||
// RawSolution has 24 entries
|
||||
@@ -20,11 +16,9 @@ testMeta(13, {
|
||||
]
|
||||
},
|
||||
polkadot: {
|
||||
compare: polkadotJson as Record<string, unknown>,
|
||||
data: polkadotData
|
||||
},
|
||||
substrate: {
|
||||
compare: substrateJson as Record<string, unknown>,
|
||||
data: substrateData
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,31 +2,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import kusamaData from '@polkadot/types-support/metadata/v14/kusama-hex';
|
||||
import kusamaJson from '@polkadot/types-support/metadata/v14/kusama-json.json' assert { type: 'json' };
|
||||
import kusamaTypes from '@polkadot/types-support/metadata/v14/kusama-types.json' assert { type: 'json' };
|
||||
import polkadotData from '@polkadot/types-support/metadata/v14/polkadot-hex';
|
||||
import polkadotJson from '@polkadot/types-support/metadata/v14/polkadot-json.json' assert { type: 'json' };
|
||||
import polkadotTypes from '@polkadot/types-support/metadata/v14/polkadot-types.json' assert { type: 'json' };
|
||||
import substrateData from '@polkadot/types-support/metadata/v14/substrate-hex';
|
||||
import substrateJson from '@polkadot/types-support/metadata/v14/substrate-json.json' assert { type: 'json' };
|
||||
import substrateTypes from '@polkadot/types-support/metadata/v14/substrate-types.json' assert { type: 'json' };
|
||||
|
||||
import { testMeta } from '../util/testUtil.js';
|
||||
|
||||
testMeta(14, {
|
||||
kusama: {
|
||||
compare: kusamaJson as Record<string, unknown>,
|
||||
data: kusamaData,
|
||||
types: kusamaTypes as unknown[]
|
||||
data: kusamaData
|
||||
},
|
||||
polkadot: {
|
||||
compare: polkadotJson as Record<string, unknown>,
|
||||
data: polkadotData,
|
||||
types: polkadotTypes as unknown[]
|
||||
data: polkadotData
|
||||
},
|
||||
substrate: {
|
||||
compare: substrateJson as Record<string, unknown>,
|
||||
data: substrateData,
|
||||
types: substrateTypes as unknown[]
|
||||
data: substrateData
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import substrateData from '@polkadot/types-support/metadata/v9/substrate-hex';
|
||||
import substrateJson from '@polkadot/types-support/metadata/v9/substrate-json.json' assert { type: 'json' };
|
||||
|
||||
import { testMeta } from '../util/testUtil.js';
|
||||
|
||||
testMeta(9, {
|
||||
substrate: {
|
||||
compare: substrateJson as Record<string, unknown>,
|
||||
data: substrateData
|
||||
}
|
||||
}, false);
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import rpcDataV11 from '@polkadot/types-support//metadata/v11/substrate-hex';
|
||||
import rpcDataV11 from '@polkadot/types-support/metadata/v11/substrate-hex';
|
||||
|
||||
import { TypeRegistry } from '../create/index.js';
|
||||
import { decorateStorage, Metadata } from '../metadata/index.js';
|
||||
|
||||
Reference in New Issue
Block a user