From 55fe4557136fde34d6d27af6c5685e2ba6db746e Mon Sep 17 00:00:00 2001 From: Jaco Date: Mon, 20 Dec 2021 16:58:16 +0100 Subject: [PATCH] Small import cleanups (#4368) --- package.json | 2 +- packages/api/src/base/Init.ts | 6 +++--- packages/types/src/checkTypes.manual.ts | 5 ++--- .../metadata/PortableRegistry/PortableRegistry.ts | 3 +-- packages/types/src/metadata/decorate/errors/index.ts | 3 +-- packages/types/src/metadata/decorate/index.spec.ts | 2 +- packages/types/src/metadata/decorate/util.ts | 2 +- packages/types/src/metadata/util/toCallsOnly.ts | 4 +--- packages/types/src/types/events.ts | 3 +-- packages/types/src/types/registry.ts | 12 +++++++++--- yarn.lock | 10 +++++----- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 391de7df21..7d510dd64e 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@babel/core": "^7.16.5", "@babel/register": "^7.16.5", "@babel/runtime": "^7.16.5", - "@polkadot/dev": "^0.64.8", + "@polkadot/dev": "^0.64.11", "@polkadot/ts": "^0.4.20", "@polkadot/typegen": "workspace:packages/typegen", "@types/jest": "^27.0.3", diff --git a/packages/api/src/base/Init.ts b/packages/api/src/base/Init.ts index 68cdeee14b..98b05b0874 100644 --- a/packages/api/src/base/Init.ts +++ b/packages/api/src/base/Init.ts @@ -4,7 +4,7 @@ import type { Observable, Subscription } from 'rxjs'; import type { Text } from '@polkadot/types'; import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types'; -import type { ChainProperties, Hash, HeaderPartial, RuntimeVersion, RuntimeVersionPartial } from '@polkadot/types/interfaces'; +import type { ChainProperties, Hash, RuntimeVersion, RuntimeVersionPartial } from '@polkadot/types/interfaces'; import type { Registry } from '@polkadot/types/types'; import type { BN } from '@polkadot/util'; import type { HexString } from '@polkadot/util/types'; @@ -151,7 +151,7 @@ export abstract class Init extends Decorate { this._genesisHash.eq(blockHash) ? { number: BN_ZERO, parentHash: this._genesisHash } : await firstValueFrom(this._rpcCore.chain.getHeader.raw(blockHash)) - ) as unknown as HeaderPartial; + ); assert(!header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash'); @@ -161,7 +161,7 @@ export abstract class Init extends Decorate { (firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion))) ? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion } : await firstValueFrom(this._rpcCore.state.getRuntimeVersion.raw(header.parentHash)) - ) as unknown as RuntimeVersionPartial; + ); const existingViaVersion = this._getBlockRegistryViaVersion(blockHash, version); diff --git a/packages/types/src/checkTypes.manual.ts b/packages/types/src/checkTypes.manual.ts index f27b245e56..d7e41bb018 100644 --- a/packages/types/src/checkTypes.manual.ts +++ b/packages/types/src/checkTypes.manual.ts @@ -3,10 +3,9 @@ import '@polkadot/types-augment'; -import type { Compact, Option } from './codec'; +import type { Bytes, Compact, Option, u32 } from '@polkadot/types-codec'; +import type { IOption, ITuple } from '@polkadot/types-codec/types'; import type { AccountId, BlockAttestations, SessionKeys7 } from './interfaces'; -import type { Bytes, u32 } from './primitive'; -import type { IOption, ITuple } from './types'; import { assert } from '@polkadot/util'; diff --git a/packages/types/src/metadata/PortableRegistry/PortableRegistry.ts b/packages/types/src/metadata/PortableRegistry/PortableRegistry.ts index a60b8a0352..e917931b82 100644 --- a/packages/types/src/metadata/PortableRegistry/PortableRegistry.ts +++ b/packages/types/src/metadata/PortableRegistry/PortableRegistry.ts @@ -1,12 +1,11 @@ // Copyright 2017-2021 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { Vec } from '@polkadot/types-codec'; +import type { Text, Type, Vec } from '@polkadot/types-codec'; import type { CodecRegistry } from '@polkadot/types-codec/types'; import type { ILookup, TypeDef } from '@polkadot/types-create/types'; import type { PortableType } from '../../interfaces/metadata'; import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '../../interfaces/scaleInfo'; -import type { Text, Type } from '../../primitive'; import { sanitize, Struct, u32 } from '@polkadot/types-codec'; import { getTypeDef, TypeDefInfo, withTypeString } from '@polkadot/types-create'; diff --git a/packages/types/src/metadata/decorate/errors/index.ts b/packages/types/src/metadata/decorate/errors/index.ts index e8e3220d1d..4ed0433c10 100644 --- a/packages/types/src/metadata/decorate/errors/index.ts +++ b/packages/types/src/metadata/decorate/errors/index.ts @@ -1,11 +1,10 @@ // Copyright 2017-2021 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { Text } from '@polkadot/types-codec'; +import type { Text, u8 } from '@polkadot/types-codec'; import type { CodecRegistry } from '@polkadot/types-codec/types'; import type { DispatchErrorModule, MetadataLatest, SiField, SiVariant } from '../../../interfaces'; import type { PortableRegistry } from '../../../metadata'; -import type { u8 } from '../../../primitive'; import type { Errors, IsError } from '../types'; import { lazyMethod, objectSpread, stringCamelCase } from '@polkadot/util'; diff --git a/packages/types/src/metadata/decorate/index.spec.ts b/packages/types/src/metadata/decorate/index.spec.ts index 2f263ebfe1..52c8375122 100644 --- a/packages/types/src/metadata/decorate/index.spec.ts +++ b/packages/types/src/metadata/decorate/index.spec.ts @@ -1,11 +1,11 @@ // Copyright 2017-2021 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 +import { u32 } from '@polkadot/types-codec'; import json from '@polkadot/types-support/metadata/static-substrate'; import { u8aToHex } from '@polkadot/util'; import { TypeRegistry } from '../../create'; -import { u32 } from '../../primitive'; import { Metadata } from '../Metadata'; import { decorateConstants, decorateExtrinsics, decorateStorage } from './'; diff --git a/packages/types/src/metadata/decorate/util.ts b/packages/types/src/metadata/decorate/util.ts index dd2dc64244..c137ddf6bd 100644 --- a/packages/types/src/metadata/decorate/util.ts +++ b/packages/types/src/metadata/decorate/util.ts @@ -1,7 +1,7 @@ // Copyright 2017-2021 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { Text } from '../../primitive'; +import type { Text } from '@polkadot/types-codec'; import { stringCamelCase, stringLowerFirst } from '@polkadot/util'; diff --git a/packages/types/src/metadata/util/toCallsOnly.ts b/packages/types/src/metadata/util/toCallsOnly.ts index 425de36a68..bd6edc23ba 100644 --- a/packages/types/src/metadata/util/toCallsOnly.ts +++ b/packages/types/src/metadata/util/toCallsOnly.ts @@ -4,9 +4,7 @@ import type { AnyJson, CodecRegistry } from '@polkadot/types-codec/types'; import type { MetadataLatest, PalletCallMetadataLatest } from '../../interfaces/metadata'; -import { Option, Text } from '@polkadot/types-codec'; - -import { u8 } from '../../primitive'; +import { Option, Text, u8 } from '@polkadot/types-codec'; interface ModuleMetadataTrimmed { calls: Option; diff --git a/packages/types/src/types/events.ts b/packages/types/src/types/events.ts index 47afc71f4b..8bfb06e500 100644 --- a/packages/types/src/types/events.ts +++ b/packages/types/src/types/events.ts @@ -1,11 +1,10 @@ // Copyright 2017-2021 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { Codec, ITuple } from '@polkadot/types-codec/types'; import type { EventMetadataLatest } from '../interfaces/metadata'; import type { Hash } from '../interfaces/runtime'; import type { EventId, Phase } from '../interfaces/system'; -import type { Codec } from './codec'; -import type { ITuple } from './interfaces'; export interface IEventRecord { readonly phase: Phase; diff --git a/packages/types/src/types/registry.ts b/packages/types/src/types/registry.ts index e2024cddd8..c52b59ade8 100644 --- a/packages/types/src/types/registry.ts +++ b/packages/types/src/types/registry.ts @@ -3,18 +3,20 @@ import type { Observable } from 'rxjs'; import type { BitVec, Bool, bool, Bytes, I8, i8, I16, i16, I32, i32, I64, i64, I128, i128, I256, i256, Json, Null, Raw, Text, Type, U8, u8, U16, u16, U32, u32, U64, u64, U128, u128, U256, u256, USize, usize } from '@polkadot/types-codec'; -import type { RegistryError as RegistryErrorBase, RegistryTypes } from '@polkadot/types-codec/types'; +import type { Codec, CodecClass, RegistryError as RegistryErrorBase, RegistryTypes } from '@polkadot/types-codec/types'; import type { CreateRegistry, TypeDef } from '@polkadot/types-create/types'; import type { BN } from '@polkadot/util'; import type { GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericSignerPayload } from '../extrinsic'; import type { ExtDef } from '../extrinsic/signedExtensions/types'; +import type { GenericCall } from '../generic'; import type { MetadataLatest } from '../interfaces/metadata'; +import type { HeaderPartial } from '../interfaces/runtime'; import type { SiField, SiLookupTypeId } from '../interfaces/scaleInfo'; +import type { RuntimeVersionPartial } from '../interfaces/state'; import type { ChainProperties } from '../interfaces/system'; import type { Metadata, PortableRegistry } from '../metadata'; import type { Data, StorageKey } from '../primitive'; import type { CallFunction } from './calls'; -import type { Codec, CodecClass } from './codec'; import type { DefinitionRpc, DefinitionRpcSub } from './definitions'; import type { DetectCodec } from './detect'; @@ -25,10 +27,14 @@ export interface InterfaceTypes { BitVec: BitVec, Bool: Bool, Bytes: Bytes, I128: I128, I16: I16, I256: I256, I32: I32, I64: I64, I8: I8, Json: Json, Null: Null, Raw: Raw, Text: Text, Type: Type, U128: U128, U16: U16, U256: U256, U32: U32, U64: U64, U8: U8, USize: USize, bool: bool, i128: i128, i16: i16, i256: i256, i32: i32, i64: i64, i8: i8, u128: u128, u16: u16, u256: u256, u32: u32, u64: u64, u8: u8, usize: usize, // extrinsic Extrinsic: GenericExtrinsic, ExtrinsicEra: GenericExtrinsicEra, ExtrinsicPayload: GenericExtrinsicPayload, SignerPayload: GenericSignerPayload, + // generic + Call: GenericCall, // primitive Data: Data, StorageKey: StorageKey, // metadata - Metadata: Metadata, PortableRegistry: PortableRegistry + Metadata: Metadata, PortableRegistry: PortableRegistry, + // interfaces + HeaderPartial: HeaderPartial, RuntimeVersionPartial: RuntimeVersionPartial } export type CodecHasher = (data: Uint8Array) => Uint8Array; diff --git a/yarn.lock b/yarn.lock index a2d875dee9..890ceba238 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1949,9 +1949,9 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/dev@npm:^0.64.8": - version: 0.64.8 - resolution: "@polkadot/dev@npm:0.64.8" +"@polkadot/dev@npm:^0.64.11": + version: 0.64.11 + resolution: "@polkadot/dev@npm:0.64.11" dependencies: "@babel/cli": ^7.16.0 "@babel/core": ^7.16.5 @@ -2036,7 +2036,7 @@ __metadata: polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs - checksum: c8ab862c3184cbbd4d26b27c53b91178245bfcb39ccdf8a5386e25b4ead71beee546fc5d79c28d21bfe252b65d3cb58cdf7465522a9b5e45560fe9bf48cbef7e + checksum: 97cecfd0df01cffa2bb1767305e20eaa4a94a4005ae3c3571e525a47fcbe4776534910a77ff836c71237d1ece7970f550086955e86c6f3499cdad381f36fc8a6 languageName: node linkType: hard @@ -8983,7 +8983,7 @@ resolve@^2.0.0-next.3: "@babel/core": ^7.16.5 "@babel/register": ^7.16.5 "@babel/runtime": ^7.16.5 - "@polkadot/dev": ^0.64.8 + "@polkadot/dev": ^0.64.11 "@polkadot/ts": ^0.4.20 "@polkadot/typegen": "workspace:packages/typegen" "@types/jest": ^27.0.3