Move type-only imports (w/ verbatimModuleSyntax) (#5574)

This commit is contained in:
Jaco
2023-04-02 09:53:37 +03:00
committed by GitHub
parent 9a92089810
commit 186cfc93b5
24 changed files with 55 additions and 47 deletions
+1 -1
View File
@@ -40,7 +40,7 @@
"test:one": "polkadot-dev-run-test --env node"
},
"devDependencies": {
"@polkadot/dev": "^0.72.29",
"@polkadot/dev": "^0.72.32",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/node": "^18.15.11"
},
+1 -2
View File
@@ -3,8 +3,7 @@
import type { Observable } from 'rxjs';
import type { AnyFunction, AnyJson, Callback, DefinitionRpc } from '@polkadot/types/types';
import { ApiTypes, PromiseResult, Push, RxResult, UnsubscribePromise } from './base.js';
import type { ApiTypes, PromiseResult, Push, RxResult, UnsubscribePromise } from './base.js';
export type { AugmentedRpc } from '@polkadot/rpc-core/types';
@@ -5,9 +5,11 @@
import '@polkadot/api-augment';
import type { TestKeyringMap } from '@polkadot/keyring/testingPairs';
import { ApiPromise } from '@polkadot/api';
import { BlueprintPromise, ContractPromise } from '@polkadot/api-contract';
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import abiIncrementer from './test/contracts/ink/v0/incrementer.json' assert { type: 'json' };
+2 -2
View File
@@ -7,14 +7,14 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import type { ExactDerive } from './index.js';
import { from, Observable } from 'rxjs';
import { ApiRx } from '@polkadot/api';
import { MockProvider } from '@polkadot/rpc-provider/mock';
import { TypeRegistry } from '@polkadot/types/create';
import { ExactDerive } from './index.js';
const testFunction = (api: ApiRx): any => {
return <S extends keyof ExactDerive, M extends keyof (typeof api.derive[S])>(section: S, method: M, inputs: any[]): void => {
describe(`derive.${section}.${method as string}`, (): void => {
@@ -1,10 +1,11 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Bounty, BountyIndex } from '@polkadot/types/interfaces';
import type { Codec, Constructor, InterfaceTypes, Registry } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { Option, StorageKey } from '@polkadot/types';
import { Bounty, BountyIndex } from '@polkadot/types/interfaces';
import { Codec, Constructor, InterfaceTypes, Registry } from '@polkadot/types/types';
export class BountyFactory {
readonly #api: ApiPromise;
+2 -2
View File
@@ -1,8 +1,8 @@
// Copyright 2017-2023 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Bytes } from '@polkadot/types';
import { Registry } from '@polkadot/types/types';
import type { Bytes } from '@polkadot/types';
import type { Registry } from '@polkadot/types/types';
export class BytesFactory {
#registry: Registry;
@@ -3,9 +3,8 @@
import type { ApiPromise } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api-base/types';
import { Proposal, ProposalIndex } from '@polkadot/types/interfaces';
import { Registry } from '@polkadot/types/types';
import type { Proposal, ProposalIndex } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';
export class ProposalFactory {
readonly #api: ApiPromise;
+2 -1
View File
@@ -12,6 +12,7 @@ import type { AnyFunction, AnyJson, AnyTuple, CallFunction, Codec, DefinitionCal
import type { HexString } from '@polkadot/util/types';
import type { SubmittableExtrinsic } from '../submittable/types.js';
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, AugmentedQuery, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecorateMethod, GenericStorageEntryFunction, PaginationOptions, QueryableConsts, QueryableStorage, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics } from '../types/index.js';
import type { AllDerives } from '../util/decorate.js';
import type { VersionedRegistry } from './types.js';
import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray } from 'rxjs';
@@ -26,7 +27,7 @@ import { blake2AsHex } from '@polkadot/util-crypto';
import { createSubmittable } from '../submittable/index.js';
import { augmentObject } from '../util/augmentObject.js';
import { AllDerives, decorateDeriveSections } from '../util/decorate.js';
import { decorateDeriveSections } from '../util/decorate.js';
import { extractStorageArgs } from '../util/validate.js';
import { Events } from './Events.js';
import { findCall, findError } from './find.js';
+2 -1
View File
@@ -6,13 +6,14 @@
import '@polkadot/api-augment';
import type { HeaderExtended } from '@polkadot/api-derive/types';
import type { TestKeyringMap } from '@polkadot/keyring/testingPairs';
import type { StorageKey } from '@polkadot/types';
import type { AccountId, Balance, DispatchErrorModule, Event, Header, Index } from '@polkadot/types/interfaces';
import type { FrameSystemAccountInfo } from '@polkadot/types/lookup';
import type { AnyTuple, IExtrinsic, IMethod } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import { createTypeUnsafe, TypeRegistry } from '@polkadot/types/create';
import { SubmittableResult } from './index.js';
+2 -1
View File
@@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiOptions, UnsubscribePromise } from '../types/index.js';
import type { CombinatorCallback, CombinatorFunction } from './Combinator.js';
import { objectSpread } from '@polkadot/util';
import { ApiBase } from '../base/index.js';
import { Combinator, CombinatorCallback, CombinatorFunction } from './Combinator.js';
import { Combinator } from './Combinator.js';
import { promiseTracker, toPromiseMethod } from './decorateMethod.js';
/**
+2 -2
View File
@@ -1,9 +1,9 @@
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { isFunction } from '@polkadot/util';
import type { RpcErrorInterface } from '../types.js';
import { RpcErrorInterface } from '../types.js';
import { isFunction } from '@polkadot/util';
const UNKNOWN = -99999;
+1 -1
View File
@@ -4,9 +4,9 @@
/// <reference types="@polkadot/dev-test/globals.d.ts" />
import type { Request } from '../mock/mockWs.js';
import type { Global, Mock } from '../mock/types.js';
import { mockWs } from '../mock/mockWs.js';
import { Global, Mock } from '../mock/types.js';
import { WsProvider } from './index.js';
declare const global: Global;
+1 -1
View File
@@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Definitions, DefinitionsTypes } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import fs from 'node:fs';
@@ -8,7 +9,6 @@ import path from 'node:path';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { Definitions, DefinitionsTypes } from '@polkadot/types/types';
import { formatNumber, isHex } from '@polkadot/util';
import { generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultQuery, generateDefaultRpc, generateDefaultRuntime, generateDefaultTx } from './generate/index.js';
+1 -1
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/types/metadata/Metadata';
import type { Definitions } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { ExtraTypes } from './types.js';
import Handlebars from 'handlebars';
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import { Definitions } from '@polkadot/types/types';
import lookupDefinitions from '@polkadot/types-augment/lookup/definitions';
import { stringCamelCase } from '@polkadot/util';
+1 -1
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/types/metadata/Metadata';
import type { Definitions } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { ExtraTypes } from './types.js';
import Handlebars from 'handlebars';
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import { Definitions } from '@polkadot/types/types';
import lookupDefinitions from '@polkadot/types-augment/lookup/definitions';
import { stringCamelCase } from '@polkadot/util';
@@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ModuleTypes } from '../util/imports.js';
import Handlebars from 'handlebars';
import { Json, Raw } from '@polkadot/types/codec';
@@ -8,7 +10,6 @@ import { TypeRegistry } from '@polkadot/types/create';
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import * as defaultPrimitives from '@polkadot/types/primitive';
import { ModuleTypes } from '../util/imports.js';
import { createImports, readTemplate, setImports, writeFile } from '../util/index.js';
const primitiveClasses = {
+1 -1
View File
@@ -3,6 +3,7 @@
import type { PortableType, SiLookupTypeId, SiPath, SiTypeParameter } from '@polkadot/types/interfaces';
import type { PortableRegistry } from '@polkadot/types/metadata';
import type { Registry } from '@polkadot/types/types';
import type { TypeDef } from '@polkadot/types-create/types';
import type { HexString } from '@polkadot/util/types';
@@ -10,7 +11,6 @@ import Handlebars from 'handlebars';
import path from 'path';
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import { Registry } from '@polkadot/types/types';
import staticKusama from '@polkadot/types-support/metadata/static-kusama';
import staticPolkadot from '@polkadot/types-support/metadata/static-polkadot';
import staticSubstrate from '@polkadot/types-support/metadata/static-substrate';
+3 -2
View File
@@ -5,6 +5,8 @@ import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces';
import type { Metadata, PortableRegistry } from '@polkadot/types/metadata';
import type { Definitions, Registry } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { ModuleTypes } from '../util/imports.js';
import type { TypeImports } from '../util/index.js';
import type { ExtraTypes } from './types.js';
import Handlebars from 'handlebars';
@@ -14,8 +16,7 @@ import { unwrapStorageSi } from '@polkadot/types/primitive/StorageKey';
import lookupDefinitions from '@polkadot/types-augment/lookup/definitions';
import { stringCamelCase } from '@polkadot/util';
import { ModuleTypes } from '../util/imports.js';
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, TypeImports, writeFile } from '../util/index.js';
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util/index.js';
const generateForMetaTemplate = Handlebars.compile(readTemplate('query'));
+2 -1
View File
@@ -4,6 +4,7 @@
import type { Registry } from '@polkadot/types/types';
import type { TypeDef } from '@polkadot/types-create/types';
import type { ModuleTypes } from '../util/imports.js';
import type { TypeImports } from '../util/index.js';
import Handlebars from 'handlebars';
import path from 'path';
@@ -13,7 +14,7 @@ import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import { getTypeDef, TypeDefInfo } from '@polkadot/types-create';
import { assert, isString, stringify, stringPascalCase } from '@polkadot/util';
import { createImports, exportInterface, formatType, readTemplate, setImports, TypeImports, writeFile } from '../util/index.js';
import { createImports, exportInterface, formatType, readTemplate, setImports, writeFile } from '../util/index.js';
interface Imports extends TypeImports {
interfaces: [string, string][];
+2 -1
View File
@@ -3,6 +3,7 @@
import type { Constructor, Registry } from '@polkadot/types/types';
import type { TypeDef } from '@polkadot/types-create/types';
import type { ModuleTypes, TypeImports } from './imports.js';
import { GenericAccountId, GenericCall, GenericLookupSource, GenericVote } from '@polkadot/types/generic';
import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions';
@@ -11,7 +12,7 @@ import { getTypeDef, TypeDefInfo } from '@polkadot/types-create';
import { isChildClass, stringify } from '@polkadot/util';
import { formatType } from './formatting.js';
import { ModuleTypes, setImports, TypeImports } from './imports.js';
import { setImports } from './imports.js';
function arrayToStrType (arr: string[]): string {
return `${arr.map((c) => `'${c}'`).join(' | ')}`;
+2 -1
View File
@@ -4,6 +4,7 @@
import type { AnyString, Registry } from '@polkadot/types/types';
import type { LookupString } from '@polkadot/types-codec/types';
import type { TypeDef } from '@polkadot/types-create/types';
import type { ModuleTypes, TypeImports } from './imports.js';
import Handlebars from 'handlebars';
@@ -12,7 +13,7 @@ import { getTypeDef, paramsNotation, TypeDefInfo } from '@polkadot/types-create'
import { isString, stringify } from '@polkadot/util';
import { readTemplate } from './file.js';
import { ModuleTypes, setImports, TypeImports } from './imports.js';
import { setImports } from './imports.js';
interface ImportDef {
file: string;
@@ -4,12 +4,11 @@
/// <reference types="@polkadot/dev-test/globals.d.ts" />
import type { CodecClass, CodecTo } from '@polkadot/types-codec/types';
import type { ITuple } from '../types/interfaces.js';
import { TypeRegistry } from '@polkadot/types';
import { BTreeSet, Enum, I32, Struct, Text, Tuple, U32 } from '@polkadot/types-codec';
import { ITuple } from '../types/interfaces.js';
const registry = new TypeRegistry();
class U32TextTuple extends (Tuple.with([U32, Text]) as unknown as CodecClass<ITuple<[U32, Text]>>) {}
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AnyString } from '../types/index.js';
import type { AnyString } from '../types/index.js';
type Mapper = (value: string) => string;
+15 -15
View File
@@ -452,34 +452,34 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/dev-test@npm:^0.72.29":
version: 0.72.29
resolution: "@polkadot/dev-test@npm:0.72.29"
"@polkadot/dev-test@npm:^0.72.32":
version: 0.72.32
resolution: "@polkadot/dev-test@npm:0.72.32"
dependencies:
jsdom: ^21.1.1
tslib: ^2.5.0
checksum: f82b2be6539dc359b9d6574f9694266ebd6b63cd686630a9049b9bf88d86d13f96b8763b514a074007bfa5cfec27d3fc58db4e002c022237ad54416752d76d17
checksum: 81f6649827db6f43efdf6ea7f7b13b83e9ca9be9058c588cde62e695836e26c135dba26804c4832288c2690ed174a24dfd11d574c49053dfedd5bb30e913a801
languageName: node
linkType: hard
"@polkadot/dev-ts@npm:^0.72.29":
version: 0.72.29
resolution: "@polkadot/dev-ts@npm:0.72.29"
"@polkadot/dev-ts@npm:^0.72.32":
version: 0.72.32
resolution: "@polkadot/dev-ts@npm:0.72.32"
dependencies:
json5: ^2.2.3
tslib: ^2.5.0
typescript: ^5.0.3
checksum: 97af0e678ed25d5538d435f8e091564f462411d79b024e3ccc45eba55f3c05e4e476cc402039d6bb9dc2542a585b082833f484e71bc49a9ce3d2ead07971c5d1
checksum: 4d9783e83cde12ba1677273cbb89e56223d0b6d4b75452f14dd0ab612f264e40a888d79b081044f447815f7aaf584ccd5f299dce0291e9a0443135a9b070b546
languageName: node
linkType: hard
"@polkadot/dev@npm:^0.72.29":
version: 0.72.29
resolution: "@polkadot/dev@npm:0.72.29"
"@polkadot/dev@npm:^0.72.32":
version: 0.72.32
resolution: "@polkadot/dev@npm:0.72.32"
dependencies:
"@eslint/js": ^8.37.0
"@polkadot/dev-test": ^0.72.29
"@polkadot/dev-ts": ^0.72.29
"@polkadot/dev-test": ^0.72.32
"@polkadot/dev-ts": ^0.72.32
"@rollup/plugin-alias": ^4.0.3
"@rollup/plugin-commonjs": ^24.0.1
"@rollup/plugin-dynamic-import-vars": ^2.0.3
@@ -540,7 +540,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: d7b62ff4405b35626f07b9b9a4401b3a45db5cb3cc5f2bbccba583c1ffbb24e8327e757cf98894fc47f9176fbc95d859e1ea286d1e9fd6805994f739f98698ab
checksum: f4ab710a54a211bf5b99e88eaae73945312952213c0d405590348fd14576887d401a44546659773b0801ae77204973808f5b0eb8cf39cad1a910520a1b8b506f
languageName: node
linkType: hard
@@ -7368,7 +7368,7 @@ fsevents@~2.3.2:
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@polkadot/dev": ^0.72.29
"@polkadot/dev": ^0.72.32
"@polkadot/typegen": "workspace:packages/typegen"
"@types/node": ^18.15.11
languageName: unknown