Move primitive/Extrinsic -> extrinsic (#1905)
* Move primitive/Extrinsic -> extrinsic * mv primitive/Generic -> generic * Update registry with BitVec * ove BitVec back to primitive * Remove unused import * Rebuild interfaces
This commit is contained in:
@@ -8,8 +8,8 @@ import fs from 'fs';
|
||||
import interfaces from '@polkadot/jsonrpc';
|
||||
import Decorated from '@polkadot/metadata/Decorated';
|
||||
import rpcdata from '@polkadot/metadata/Metadata/static';
|
||||
import Call from '@polkadot/types/generic/Call';
|
||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import Call from '@polkadot/types/primitive/Generic/Call';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { Vec } from '@polkadot/types/codec';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
|
||||
@@ -14,9 +14,9 @@ import Enum from '@polkadot/types/codec/Enum';
|
||||
import Option from '@polkadot/types/codec/Option';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import GenericAccountId from '@polkadot/types/primitive/Generic/AccountId';
|
||||
import GenericAddress from '@polkadot/types/primitive/Generic/Address';
|
||||
import Vote, { convictionNames as _voteConvictions } from '@polkadot/types/primitive/Generic/Vote';
|
||||
import GenericAccountId from '@polkadot/types/generic/AccountId';
|
||||
import GenericAddress from '@polkadot/types/generic/Address';
|
||||
import Vote, { convictionNames as _voteConvictions } from '@polkadot/types/generic/Vote';
|
||||
import Null from '@polkadot/types/primitive/Null';
|
||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
||||
|
||||
|
||||
@@ -28,6 +28,14 @@ export function createImportCode (header: string, imports: TypeImports, checks:
|
||||
.keys(imports.codecTypes)
|
||||
.filter((name): boolean => name !== 'Tuple')
|
||||
},
|
||||
{
|
||||
file: '@polkadot/types/extrinsic',
|
||||
types: Object.keys(imports.extrinsicTypes)
|
||||
},
|
||||
{
|
||||
file: '@polkadot/types/generic',
|
||||
types: Object.keys(imports.genericTypes)
|
||||
},
|
||||
{
|
||||
file: '@polkadot/types/primitive',
|
||||
types: Object
|
||||
|
||||
@@ -6,6 +6,8 @@ import { TypeDefInfo } from '@polkadot/types/create/types';
|
||||
|
||||
import * as codecClasses from '@polkadot/types/codec';
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
import * as extrinsicClasses from '@polkadot/types/extrinsic';
|
||||
import * as genericClasses from '@polkadot/types/generic';
|
||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
||||
|
||||
// these map all the codec and primitive types for import, see the TypeImports below. If
|
||||
@@ -18,8 +20,10 @@ type TypeExistMap = Record<string, TypeExist>;
|
||||
|
||||
export interface TypeImports {
|
||||
codecTypes: TypeExist; // `import {} from '@polkadot/types/codec`
|
||||
localTypes: TypeExistMap; // `import {} from '../something'`
|
||||
extrinsicTypes: TypeExist; // `import {} from '@polkadot/types/extrinsic`
|
||||
genericTypes: TypeExist; // `import {} from '@polkadot/types/generic`
|
||||
ignoredTypes: string[]; // No need to import these types
|
||||
localTypes: TypeExistMap; // `import {} from '../something'`
|
||||
primitiveTypes: TypeExist; // `import {} from '@polkadot/types/primitive`
|
||||
typesTypes: TypeExist; // `import {} from '@polkadot/types/types`
|
||||
definitions: object; // all definitions
|
||||
@@ -31,7 +35,7 @@ export interface TypeImports {
|
||||
// imports in the output file, dep-duped and sorted
|
||||
/** @internal */
|
||||
export function setImports (allDefs: object, imports: TypeImports, types: string[]): void {
|
||||
const { codecTypes, localTypes, ignoredTypes, primitiveTypes, typesTypes } = imports;
|
||||
const { codecTypes, extrinsicTypes, genericTypes, ignoredTypes, localTypes, primitiveTypes, typesTypes } = imports;
|
||||
|
||||
types.forEach((type): void => {
|
||||
if (ignoredTypes.includes(type)) {
|
||||
@@ -40,6 +44,10 @@ export function setImports (allDefs: object, imports: TypeImports, types: string
|
||||
typesTypes[type] = true;
|
||||
} else if ((codecClasses as any)[type]) {
|
||||
codecTypes[type] = true;
|
||||
} else if ((extrinsicClasses as any)[type]) {
|
||||
extrinsicTypes[type] = true;
|
||||
} else if ((genericClasses as any)[type]) {
|
||||
genericTypes[type] = true;
|
||||
} else if ((primitiveClasses as any)[type] || type === 'Metadata') {
|
||||
primitiveTypes[type] = true;
|
||||
} else if (type.includes('<') || type.includes('(') || type.includes('[')) {
|
||||
@@ -97,12 +105,14 @@ export function createImports (importDefinitions: Record<string, object>, { type
|
||||
|
||||
return {
|
||||
codecTypes: {},
|
||||
extrinsicTypes: {},
|
||||
genericTypes: {},
|
||||
ignoredTypes: Object.keys(types),
|
||||
localTypes: Object.keys(definitions).reduce((local: Record<string, TypeExist>, mod): Record<string, TypeExist> => {
|
||||
local[mod] = {};
|
||||
|
||||
return local;
|
||||
}, {}),
|
||||
ignoredTypes: Object.keys(types),
|
||||
primitiveTypes: {},
|
||||
typesTypes: {},
|
||||
definitions,
|
||||
|
||||
Reference in New Issue
Block a user