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:
Jaco
2023-03-09 20:10:53 +02:00
committed by GitHub
parent 9ac9d72082
commit 611ff12a3d
56 changed files with 145 additions and 130 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/api-contract authors & contributors // Copyright 2017-2023 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base'; import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base/index.js';
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>; export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>; export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/api-contract authors & contributors // Copyright 2017-2023 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base'; import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base/index.js';
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>; export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>; export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
+1 -1
View File
@@ -3,7 +3,7 @@
import type { DeriveCustom } from '@polkadot/api-base/types'; import type { DeriveCustom } from '@polkadot/api-base/types';
import type { AnyFunction, AnyString } from '@polkadot/types/types'; import type { AnyFunction, AnyString } from '@polkadot/types/types';
import type { ExactDerive } from './derive'; import type { ExactDerive } from './derive.js';
import type { DeriveApi } from './types.js'; import type { DeriveApi } from './types.js';
import { lazyDeriveSection } from './util/index.js'; import { lazyDeriveSection } from './util/index.js';
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs'; import type { Observable } from 'rxjs';
import type { SignedBlockExtended } from '../type/types'; import type { SignedBlockExtended } from '../type/types.js';
import type { DeriveApi } from '../types.js'; import type { DeriveApi } from '../types.js';
import { switchMap } from 'rxjs'; import { switchMap } from 'rxjs';
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs'; import type { Observable } from 'rxjs';
import type { HeaderExtended } from '../type/types'; import type { HeaderExtended } from '../type/types.js';
import type { DeriveApi } from '../types.js'; import type { DeriveApi } from '../types.js';
import { combineLatest, map, of, switchMap } from 'rxjs'; import { combineLatest, map, of, switchMap } from 'rxjs';
+1 -1
View File
@@ -4,7 +4,7 @@
import type { AccountId, Balance, EraIndex, RewardPoint } from '@polkadot/types/interfaces'; import type { AccountId, Balance, EraIndex, RewardPoint } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs } from '@polkadot/types/lookup'; import type { PalletStakingExposure, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util'; import type { BN } from '@polkadot/util';
import type { DeriveSessionIndexes } from '../session/types'; import type { DeriveSessionIndexes } from '../session/types.js';
export type DeriveEraValPoints = Record<string, RewardPoint>; export type DeriveEraValPoints = Record<string, RewardPoint>;
+1 -1
View File
@@ -4,7 +4,7 @@
import type { Observable } from 'rxjs'; import type { Observable } from 'rxjs';
import type { ObsInnerType } from '@polkadot/api-base/types'; import type { ObsInnerType } from '@polkadot/api-base/types';
import type { EraIndex } from '@polkadot/types/interfaces'; import type { EraIndex } from '@polkadot/types/interfaces';
import type { ExactDerive } from '../derive'; import type { ExactDerive } from '../derive.js';
import type { DeriveApi } from '../types.js'; import type { DeriveApi } from '../types.js';
import { BehaviorSubject, combineLatest, map, of, switchMap, tap, toArray } from 'rxjs'; import { BehaviorSubject, combineLatest, map, of, switchMap, tap, toArray } from 'rxjs';
+1 -1
View File
@@ -6,7 +6,7 @@ import type { u32 } from '@polkadot/types';
import type { Balance, BlockNumber, BountyIndex, Hash, Proposal, ProposalIndex, SetIndex, Votes } from '@polkadot/types/interfaces'; import type { Balance, BlockNumber, BountyIndex, Hash, Proposal, ProposalIndex, SetIndex, Votes } from '@polkadot/types/interfaces';
import type { PalletBountiesBounty, PalletTreasuryProposal } from '@polkadot/types/lookup'; import type { PalletBountiesBounty, PalletTreasuryProposal } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util'; import type { BN } from '@polkadot/util';
import type { ExactDerive } from './derive'; import type { ExactDerive } from './derive.js';
export * from './accounts/types.js'; export * from './accounts/types.js';
export * from './balances/types.js'; export * from './balances/types.js';
+1 -1
View File
@@ -3,7 +3,7 @@
import type { ApiInterfaceEvents } from '../types/index.js'; import type { ApiInterfaceEvents } from '../types/index.js';
import EventEmitter from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
export class Events { export class Events {
#eventemitter = new EventEmitter(); #eventemitter = new EventEmitter();
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/api authors & contributors // Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { SubmittableExtrinsic as SubmittableExtrinsicBase } from '../submittable/types'; import type { SubmittableExtrinsic as SubmittableExtrinsicBase } from '../submittable/types.js';
import type { QueryableStorageEntry as QueryableStorageEntryBase, SubmittableExtrinsicFunction as SubmittableExtrinsicFunctionBase } from '../types/index.js'; import type { QueryableStorageEntry as QueryableStorageEntryBase, SubmittableExtrinsicFunction as SubmittableExtrinsicFunctionBase } from '../types/index.js';
export type QueryableStorageEntry = QueryableStorageEntryBase<'promise'>; export type QueryableStorageEntry = QueryableStorageEntryBase<'promise'>;
+1 -1
View File
@@ -1,9 +1,9 @@
// Copyright 2017-2023 @polkadot/api authors & contributors // Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Signer, SignerResult } from '@polkadot/api/types';
import type { KeyringPair } from '@polkadot/keyring/types'; import type { KeyringPair } from '@polkadot/keyring/types';
import type { Registry, SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types'; import type { Registry, SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
import type { Signer, SignerResult } from '../types/index.js';
import { hexToU8a, objectSpread, u8aToHex } from '@polkadot/util'; import { hexToU8a, objectSpread, u8aToHex } from '@polkadot/util';
@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import { isError } from '@polkadot/util/is/error'; import { isError } from '@polkadot/util';
import RpcError from './error.js'; import RpcError from './error.js';
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors // Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import { isFunction } from '@polkadot/util/is/function'; import { isFunction } from '@polkadot/util';
import { RpcErrorInterface } from '../types.js'; import { RpcErrorInterface } from '../types.js';
+1 -1
View File
@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import type { Mock } from '../mock/types'; import type { Mock } from '../mock/types.js';
import { mockHttp, TEST_HTTP_URL } from '../mock/mockHttp.js'; import { mockHttp, TEST_HTTP_URL } from '../mock/mockHttp.js';
import { HttpProvider } from './index.js'; import { HttpProvider } from './index.js';
+1 -1
View File
@@ -8,7 +8,7 @@ import type { Codec, Registry } from '@polkadot/types/types';
import type { ProviderInterface, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '../types.js'; import type { ProviderInterface, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '../types.js';
import type { MockStateDb, MockStateSubscriptionCallback, MockStateSubscriptions } from './types.js'; import type { MockStateDb, MockStateSubscriptionCallback, MockStateSubscriptions } from './types.js';
import EventEmitter from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import { createTestKeyring } from '@polkadot/keyring/testing'; import { createTestKeyring } from '@polkadot/keyring/testing';
import { decorateStorage, Metadata } from '@polkadot/types'; import { decorateStorage, Metadata } from '@polkadot/types';
@@ -20,7 +20,7 @@
// FIXME A number of tests here, that were passing, is not skipped since // FIXME A number of tests here, that were passing, is not skipped since
// Jest has "some" issues with `await import` - we don't transform these // Jest has "some" issues with `await import` - we don't transform these
import type Sc from '@substrate/connect'; import type * as Sc from '@substrate/connect';
import type { HealthChecker, SmoldotHealth } from './types.js'; import type { HealthChecker, SmoldotHealth } from './types.js';
import { ScProvider } from './index.js'; import { ScProvider } from './index.js';
@@ -1,10 +1,10 @@
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors // Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type ScType from '@substrate/connect'; import type * as ScType from '@substrate/connect';
import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '../types.js'; import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '../types.js';
import EventEmitter from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import { isError, isFunction, isObject, logger, objectSpread } from '@polkadot/util'; import { isError, isFunction, isObject, logger, objectSpread } from '@polkadot/util';
+1 -1
View File
@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import type { Mock } from '../mock/types'; import type { Mock } from '../mock/types.js';
import { mockWs } from '../mock/mockWs.js'; import { mockWs } from '../mock/mockWs.js';
import { WsProvider } from './index.js'; import { WsProvider } from './index.js';
+1 -1
View File
@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import type { Request } from '../mock/mockWs'; import type { Request } from '../mock/mockWs.js';
import type { Mock } from '../mock/types.js'; import type { Mock } from '../mock/types.js';
import { mockWs } from '../mock/mockWs.js'; import { mockWs } from '../mock/mockWs.js';
+1 -1
View File
@@ -5,7 +5,7 @@
import type { EndpointStats, JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted, ProviderStats } from '../types.js'; import type { EndpointStats, JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted, ProviderStats } from '../types.js';
import EventEmitter from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import { isChildClass, isNull, isUndefined, logger, objectSpread } from '@polkadot/util'; import { isChildClass, isNull, isUndefined, logger, objectSpread } from '@polkadot/util';
import { xglobal } from '@polkadot/x-global'; import { xglobal } from '@polkadot/x-global';
+1 -1
View File
@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import type { Request } from '../mock/mockWs'; import type { Request } from '../mock/mockWs.js';
import { mockWs } from '../mock/mockWs.js'; import { mockWs } from '../mock/mockWs.js';
import { Global, Mock } from '../mock/types.js'; import { Global, Mock } from '../mock/types.js';
@@ -3,8 +3,8 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import type { Request } from '../mock/mockWs'; import type { Request } from '../mock/mockWs.js';
import type { Global, Mock } from './../mock/types'; import type { Global, Mock } from './../mock/types.js';
import { mockWs } from '../mock/mockWs.js'; import { mockWs } from '../mock/mockWs.js';
import { WsProvider } from './index.js'; import { WsProvider } from './index.js';
@@ -3,8 +3,8 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import type { Request } from '../mock/mockWs'; import type { Request } from '../mock/mockWs.js';
import type { Global, Mock } from './../mock/types'; import type { Global, Mock } from './../mock/types.js';
import { mockWs } from '../mock/mockWs.js'; import { mockWs } from '../mock/mockWs.js';
import { WsProvider } from './index.js'; import { WsProvider } from './index.js';
+2 -2
View File
@@ -3,8 +3,8 @@
import type { HexString } from '@polkadot/util/types'; import type { HexString } from '@polkadot/util/types';
import fs from 'fs'; import fs from 'node:fs';
import path from 'path'; import path from 'node:path';
import yargs from 'yargs'; import yargs from 'yargs';
import { hideBin } from 'yargs/helpers'; import { hideBin } from 'yargs/helpers';
+2 -2
View File
@@ -3,8 +3,8 @@
import type { HexString } from '@polkadot/util/types'; import type { HexString } from '@polkadot/util/types';
import fs from 'fs'; import fs from 'node:fs';
import path from 'path'; import path from 'node:path';
import yargs from 'yargs'; import yargs from 'yargs';
import { hideBin } from 'yargs/helpers'; import { hideBin } from 'yargs/helpers';
+1 -1
View File
@@ -3,7 +3,7 @@
import type { Registry } from '@polkadot/types/types'; import type { Registry } from '@polkadot/types/types';
import type { TypeDef } from '@polkadot/types-create/types'; import type { TypeDef } from '@polkadot/types-create/types';
import type { ModuleTypes } from '../util/imports'; import type { ModuleTypes } from '../util/imports.js';
import Handlebars from 'handlebars'; import Handlebars from 'handlebars';
import path from 'path'; import path from 'path';
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { HexString } from '@polkadot/util/types'; import type { HexString } from '@polkadot/util/types';
import type { ExtraTypes } from '../generate/types'; import type { ExtraTypes } from '../generate/types.js';
import { Metadata, TypeRegistry } from '@polkadot/types'; import { Metadata, TypeRegistry } from '@polkadot/types';
@@ -3,7 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import { alias, flattenSingleTuple, removeColons, removeExtensions } from '@polkadot/types-codec/utils/sanitize'; import { alias, flattenSingleTuple, removeColons, removeExtensions } from './sanitize.js';
describe('sanitize', (): void => { describe('sanitize', (): void => {
describe('alias', (): void => { describe('alias', (): void => {
+1 -1
View File
@@ -3,7 +3,7 @@
import type { AnyString, Codec, CodecClass, IU8a, LookupString } from '@polkadot/types-codec/types'; import type { AnyString, Codec, CodecClass, IU8a, LookupString } from '@polkadot/types-codec/types';
import type { CreateOptions, TypeDef } from '@polkadot/types-create/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 { 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'; 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 { Registry } from '@polkadot/types-codec/types';
import type { HexString } from '@polkadot/util/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 type { Codec, ICompact, INumber, IRuntimeVersion, ISignerPayload, SignerPayloadJSON, SignerPayloadRaw } from '../types/index.js';
import { Option, Struct, Text, Vec } from '@polkadot/types-codec'; import { Option, Struct, Text, Vec } from '@polkadot/types-codec';
+2 -2
View File
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { HexString } from '@polkadot/util/types'; import type { HexString } from '@polkadot/util/types';
import type { ExtrinsicSignatureV4 } from '../../interfaces/extrinsics'; import type { ExtrinsicSignatureV4 } from '../../interfaces/extrinsics/index.js';
import type { Address, Call } from '../../interfaces/runtime'; import type { Address, Call } from '../../interfaces/runtime/index.js';
import type { ExtrinsicPayloadValue, IExtrinsicImpl, IKeyringPair, Registry, SignatureOptions } from '../../types/index.js'; import type { ExtrinsicPayloadValue, IExtrinsicImpl, IKeyringPair, Registry, SignatureOptions } from '../../types/index.js';
import type { ExtrinsicOptions } from '../types.js'; import type { ExtrinsicOptions } from '../types.js';
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { HexString } from '@polkadot/util/types'; import type { HexString } from '@polkadot/util/types';
import type { EcdsaSignature, Ed25519Signature, ExtrinsicEra, ExtrinsicSignature, Sr25519Signature } from '../../interfaces/extrinsics'; import type { EcdsaSignature, Ed25519Signature, ExtrinsicEra, ExtrinsicSignature, Sr25519Signature } from '../../interfaces/extrinsics/index.js';
import type { Address, Call } from '../../interfaces/runtime'; import type { Address, Call } from '../../interfaces/runtime/index.js';
import type { ExtrinsicPayloadValue, ICompact, IExtrinsicSignature, IKeyringPair, INumber, Registry, SignatureOptions } from '../../types/index.js'; import type { ExtrinsicPayloadValue, ICompact, IExtrinsicSignature, IKeyringPair, INumber, Registry, SignatureOptions } from '../../types/index.js';
import type { ExtrinsicSignatureOptions } from '../types.js'; import type { ExtrinsicSignatureOptions } from '../types.js';
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { AnyU8a, Registry } from '@polkadot/types-codec/types'; 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 { Bytes, U8aFixed, u32 } from '@polkadot/types-codec';
import { BN, bnToU8a, isNumber, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util'; 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 { AnyString, LookupString, Registry } from '@polkadot/types-codec/types';
import type { ILookup, TypeDef } from '@polkadot/types-create/types'; import type { ILookup, TypeDef } from '@polkadot/types-create/types';
import type { PortableType } from '../../interfaces/metadata/index.js'; 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 { sanitize, Struct, u32 } from '@polkadot/types-codec';
import { getTypeDef, TypeDefInfo, withTypeString } from '@polkadot/types-create'; import { getTypeDef, TypeDefInfo, withTypeString } from '@polkadot/types-create';
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/types authors & contributors // Copyright 2017-2023 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0 // 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 type { Registry } from '../../types/index.js';
import { assertUnreachable } from '@polkadot/util'; import { assertUnreachable } from '@polkadot/util';
@@ -4,7 +4,7 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <reference types="@polkadot/dev/node/test/node" />
import type { HexString } from '@polkadot/util/types'; 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 type { Constants } from '../types.js';
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate'; import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Registry } from '@polkadot/types-codec/types'; 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 type { ConstantCodec, Constants } from '../types.js';
import { hexToU8a, lazyMethod, lazyMethods, stringCamelCase } from '@polkadot/util'; import { hexToU8a, lazyMethod, lazyMethods, stringCamelCase } from '@polkadot/util';
@@ -3,8 +3,8 @@
import type { Text, u8 } from '@polkadot/types-codec'; import type { Text, u8 } from '@polkadot/types-codec';
import type { Registry } from '@polkadot/types-codec/types'; import type { Registry } from '@polkadot/types-codec/types';
import type { DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, MetadataLatest, SiField, SiVariant } from '../../../interfaces'; import type { DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, MetadataLatest, SiField, SiVariant } from '../../../interfaces/index.js';
import type { PortableRegistry } from '../../../metadata'; import type { PortableRegistry } from '../../../metadata/index.js';
import type { Errors, IsError } from '../types.js'; import type { Errors, IsError } from '../types.js';
import { isCodec, isU8a, lazyMethod, objectSpread, stringCamelCase } from '@polkadot/util'; import { isCodec, isU8a, lazyMethod, objectSpread, stringCamelCase } from '@polkadot/util';
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { AnyTuple, Registry } from '@polkadot/types-codec/types'; 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 { IEvent, IEventLike } from '../../../types/index.js';
import type { Events, IsEvent } from '../types.js'; import type { Events, IsEvent } from '../types.js';
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { AnyJson, AnyTuple, Registry } from '@polkadot/types-codec/types'; 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 type { CallFunction, IMethod } from '../../../types/index.js';
import { stringCamelCase } from '@polkadot/util'; import { stringCamelCase } from '@polkadot/util';
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Registry } from '@polkadot/types-codec/types'; import type { Registry } from '@polkadot/types-codec/types';
import type { MetadataLatest, PalletMetadataLatest, SiVariant } from '../../../interfaces'; import type { MetadataLatest, PalletMetadataLatest, SiVariant } from '../../../interfaces/index.js';
import type { PortableRegistry } from '../../../metadata'; import type { PortableRegistry } from '../../../metadata/index.js';
import type { CallFunction } from '../../../types/index.js'; import type { CallFunction } from '../../../types/index.js';
import type { Extrinsics } from '../types.js'; import type { Extrinsics } from '../types.js';
@@ -8,7 +8,7 @@ import { getTypeDef, TypeDefInfo } from '@polkadot/types-create';
type Extracted = string | Extracted[]; type Extracted = string | Extracted[];
function extractSubSingle (_: string, { sub }: TypeDef): 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]); return extractTypes([lookupName || type]);
} }
+22 -12
View File
@@ -16,16 +16,22 @@ import { unwrapStorageSi, unwrapStorageType } from '../../primitive/StorageKey.j
import { Metadata } from '../Metadata.js'; import { Metadata } from '../Metadata.js';
import { getUniqTypes } from './getUniqTypes.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 { function writeJson (json: unknown, version: number, type: string, sub: 'json' | 'types'): void {
fs.writeFileSync( fs.writeFileSync(getJsonName(version, type, sub), stringify(json, 2), { flag: 'w' });
path.join(process.cwd(), `packages/types-support/src/metadata/v${version}/${type}-${sub}.json`), }
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 */ /** @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); const metadata = new Metadata(registry, data);
registry.setMetadata(metadata); registry.setMetadata(metadata);
@@ -38,35 +44,39 @@ export function decodeLatestMeta (registry: Registry, type: string, version: num
expect(metadata.version).toBe(version); expect(metadata.version).toBe(version);
try { try {
expect(json).toEqual(compare); expect(json).toEqual(readJson(version, type, 'json'));
} catch (error) { } catch (error) {
if (process.env.GITHUB_REPOSITORY) { if (process.env.GITHUB_REPOSITORY) {
console.error(stringify(json)); console.error(stringify(json));
throw error; throw error;
} else {
console.error(error);
} }
writeJson(json, version, type, 'json'); writeJson(json, version, type, 'json');
} }
}); });
it('decodes latest types correctly', (): void => { if (version >= 14) {
if (types) { it('decodes latest types correctly', (): void => {
const json = metadata.asLatest.lookup.types.toJSON(); const json = metadata.asLatest.lookup.types.toJSON();
try { try {
expect(json).toEqual(types); expect(json).toEqual(readJson(version, type, 'types'));
} catch (error) { } catch (error) {
if (process.env.GITHUB_REPOSITORY) { if (process.env.GITHUB_REPOSITORY) {
console.error(stringify(metadata.toJSON())); console.error(stringify(metadata.toJSON()));
throw error; throw error;
} else {
console.error(error);
} }
writeJson(json, version, type, 'types'); writeJson(json, version, type, 'types');
} }
} });
}); }
} }
/** @internal */ /** @internal */
@@ -4,8 +4,6 @@
import type { HexString } from '@polkadot/util/types'; import type { HexString } from '@polkadot/util/types';
export interface Check { export interface Check {
compare: Record<string, unknown>;
data: HexString; data: HexString;
fails?: string[]; fails?: string[];
types?: unknown[];
} }
@@ -2,13 +2,11 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import substrateData from '@polkadot/types-support/metadata/v10/substrate-hex'; 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'; import { testMeta } from '../util/testUtil.js';
testMeta(10, { testMeta(10, {
substrate: { substrate: {
compare: substrateJson as Record<string, unknown>,
data: substrateData data: substrateData
} }
}, false); }, false);
@@ -2,13 +2,11 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import substrateData from '@polkadot/types-support/metadata/v11/substrate-hex'; 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'; import { testMeta } from '../util/testUtil.js';
testMeta(11, { testMeta(11, {
substrate: { substrate: {
compare: substrateJson as Record<string, unknown>,
data: substrateData data: substrateData
} }
}, false); }, false);
@@ -2,13 +2,11 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import substrateData from '@polkadot/types-support/metadata/v12/substrate-hex'; 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'; import { testMeta } from '../util/testUtil.js';
testMeta(12, { testMeta(12, {
substrate: { substrate: {
compare: substrateJson as Record<string, unknown>,
data: substrateData data: substrateData
} }
}); });
@@ -2,17 +2,13 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import kusamaData from '@polkadot/types-support/metadata/v13/kusama-hex'; 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 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 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'; import { testMeta } from '../util/testUtil.js';
testMeta(13, { testMeta(13, {
kusama: { kusama: {
compare: kusamaJson as Record<string, unknown>,
data: kusamaData, data: kusamaData,
fails: [ fails: [
// RawSolution has 24 entries // RawSolution has 24 entries
@@ -20,11 +16,9 @@ testMeta(13, {
] ]
}, },
polkadot: { polkadot: {
compare: polkadotJson as Record<string, unknown>,
data: polkadotData data: polkadotData
}, },
substrate: { substrate: {
compare: substrateJson as Record<string, unknown>,
data: substrateData data: substrateData
} }
}); });
@@ -2,31 +2,19 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import kusamaData from '@polkadot/types-support/metadata/v14/kusama-hex'; 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 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 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'; import { testMeta } from '../util/testUtil.js';
testMeta(14, { testMeta(14, {
kusama: { kusama: {
compare: kusamaJson as Record<string, unknown>, data: kusamaData
data: kusamaData,
types: kusamaTypes as unknown[]
}, },
polkadot: { polkadot: {
compare: polkadotJson as Record<string, unknown>, data: polkadotData
data: polkadotData,
types: polkadotTypes as unknown[]
}, },
substrate: { substrate: {
compare: substrateJson as Record<string, unknown>, data: substrateData
data: substrateData,
types: substrateTypes as unknown[]
} }
}); });
@@ -2,13 +2,11 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import substrateData from '@polkadot/types-support/metadata/v9/substrate-hex'; 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'; import { testMeta } from '../util/testUtil.js';
testMeta(9, { testMeta(9, {
substrate: { substrate: {
compare: substrateJson as Record<string, unknown>,
data: substrateData data: substrateData
} }
}, false); }, false);
@@ -3,9 +3,7 @@
/// <reference types="@polkadot/dev/node/test/node" /> /// <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 { TypeRegistry } from '../create/index.js';
import { decorateStorage, Metadata } from '../metadata/index.js'; import { decorateStorage, Metadata } from '../metadata/index.js';
+64 -29
View File
@@ -3,35 +3,70 @@
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"paths": { "paths": {
"@polkadot/api": ["api/src"], "@polkadot/api": ["api/src/index.ts"],
"@polkadot/api/*": ["api/src/*"], "@polkadot/api/base": ["api/src/base/index.ts"],
"@polkadot/api-augment": ["api-augment/src"], "@polkadot/api/packageInfo": ["api/src/packageInfo.ts"],
"@polkadot/api-augment/*": ["api-augment/src/*"], "@polkadot/api/submittable/*": ["api/src/submittable/*.ts"],
"@polkadot/api-base": ["api-base/src"], "@polkadot/api/types": ["api/src/types/index.ts"],
"@polkadot/api-base/*": ["api-base/src/*"], "@polkadot/api/types/*": ["api/src/types/*.ts"],
"@polkadot/api-contract": ["api-contract/src"], "@polkadot/api-augment": ["api-augment/src/index.ts"],
"@polkadot/api-contract/*": ["api-contract/src/*"], "@polkadot/api-augment/packageInfo": ["api-augment/src/packageInfo.ts"],
"@polkadot/api-derive": ["api-derive/src"], "@polkadot/api-base": ["api-base/src/index.ts"],
"@polkadot/api-derive/*": ["api-derive/src/*"], "@polkadot/api-base/packageInfo": ["api-base/src/packageInfo.ts"],
"@polkadot/rpc-augment": ["rpc-augment/src"], "@polkadot/api-base/types": ["api-base/src/types/index.ts"],
"@polkadot/rpc-augment/*": ["rpc-augment/src/*"], "@polkadot/api-base/types/*": ["api-base/src/types/*.ts"],
"@polkadot/rpc-core": ["rpc-core/src"], "@polkadot/api-contract": ["api-contract/src/index.ts"],
"@polkadot/rpc-core/*": ["rpc-core/src/*"], "@polkadot/api-contract/packageInfo": ["api-contract/src/packageInfo.ts"],
"@polkadot/rpc-provider": ["rpc-provider/src"], "@polkadot/api-derive": ["api-derive/src/index.ts"],
"@polkadot/rpc-provider/*": ["rpc-provider/src/*"], "@polkadot/api-derive/packageInfo": ["api-derive/src/packageInfo.ts"],
"@polkadot/typegen/*": ["typegen/src/*"], "@polkadot/api-derive/types": ["api-derive/src/types.ts"],
"@polkadot/types": ["types/src"], "@polkadot/rpc-augment": ["rpc-augment/src/index.ts"],
"@polkadot/types/*": ["types/src/*"], "@polkadot/rpc-augment/packageInfo": ["rpc-augment/src/packageInfo.ts"],
"@polkadot/types-augment": ["types-augment/src"], "@polkadot/rpc-core": ["rpc-core/src/index.ts"],
"@polkadot/types-augment/*": ["types-augment/src/*"], "@polkadot/rpc-core/packageInfo": ["rpc-core/src/packageInfo.ts"],
"@polkadot/types-codec": ["types-codec/src"], "@polkadot/rpc-core/types": ["rpc-core/src/types/index.ts"],
"@polkadot/types-codec/*": ["types-codec/src/*"], "@polkadot/rpc-core/types/*": ["rpc-core/src/types/*.ts"],
"@polkadot/types-create": ["types-create/src"], "@polkadot/rpc-provider": ["rpc-provider/src/index.ts"],
"@polkadot/types-create/*": ["types-create/src/*"], "@polkadot/rpc-provider/mock": ["rpc-provider/src/mock/index.ts"],
"@polkadot/types-known": ["types-known/src"], "@polkadot/rpc-provider/packageInfo": ["rpc-provider/src/packageInfo.ts"],
"@polkadot/types-known/*": ["types-known/src/*"], "@polkadot/rpc-provider/types": ["rpc-provider/src/types.ts"],
"@polkadot/types-support": ["types-support/src"], "@polkadot/typegen/*": ["typegen/src/*.ts"],
"@polkadot/types-support/*": ["types-support/src/*"] "@polkadot/types": ["types/src/index.ts"],
"@polkadot/types/codec": ["types/src/codec/index.ts"],
"@polkadot/types/create": ["types/src/create/index.ts"],
"@polkadot/types/extrinsic": ["types/src/extrinsic/index.ts"],
"@polkadot/types/extrinsic/*": ["types/src/extrinsic/*.ts"],
"@polkadot/types/generic": ["types/src/generic/index.ts"],
"@polkadot/types/interfaces": ["types/src/interfaces/index.ts"],
"@polkadot/types/interfaces/definitions": ["types/src/interfaces/definitions.ts"],
"@polkadot/types/interfaces/democracy/*": ["types/src/interfaces/democracy/*.ts"],
"@polkadot/types/interfaces/jsonrpc": ["types/src/interfaces/jsonrpc.ts"],
"@polkadot/types/interfaces/*": ["types/src/interfaces/*/index.ts"],
"@polkadot/types/lookup": ["types/src/lookup.ts"],
"@polkadot/types/metadata": ["types/src/metadata/index.ts"],
"@polkadot/types/metadata/*": ["types/src/metadata/*.ts"],
"@polkadot/types/packageInfo": ["types/src/packageInfo.ts"],
"@polkadot/types/primitive": ["types/src/primitive/index.ts"],
"@polkadot/types/primitive/*": ["types/src/primitive/*.ts"],
"@polkadot/types/types": ["types/src/types/index.ts"],
"@polkadot/types/types/*": ["types/src/types/*.ts"],
"@polkadot/types-augment": ["types-augment/src/index.ts"],
"@polkadot/types-augment/lookup/*": ["types-augment/src/lookup/*.ts"],
"@polkadot/types-augment/packageInfo": ["types-augment/src/packageInfo.ts"],
"@polkadot/types-codec": ["types-codec/src/index.ts"],
"@polkadot/types-codec/packageInfo": ["types-codec/src/packageInfo.ts"],
"@polkadot/types-codec/types": ["types-codec/src/types/index.ts"],
"@polkadot/types-codec/types/*": ["types-codec/src/types/*.ts"],
"@polkadot/types-create": ["types-create/src/index.ts"],
"@polkadot/types-create/packageInfo": ["types-create/src/packageInfo.ts"],
"@polkadot/types-create/types": ["types-create/src/types/index.ts"],
"@polkadot/types-create/types/*": ["types-create/src/types/*.ts"],
"@polkadot/types-known": ["types-known/src/index.ts"],
"@polkadot/types-known/packageInfo": ["types-known/src/packageInfo.ts"],
"@polkadot/types-support": ["types-support/src/index.ts"],
"@polkadot/types-support/json/*": ["types-support/src/json/*"],
"@polkadot/types-support/metadata/*": ["types-support/src/metadata/*"],
"@polkadot/types-support/packageInfo": ["types-support/src/packageInfo.ts"]
}, },
"skipLibCheck": true "skipLibCheck": true
} }