Adjust internal generic imports (#2838)
This commit is contained in:
@@ -8,10 +8,10 @@ import { Struct } from '@polkadot/types/codec';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { MagicNumber } from './MagicNumber';
|
||||
import v9ToV10 from './v9/toV10';
|
||||
import v10ToV11 from './v10/toV11';
|
||||
import v11ToV12 from './v11/toV12';
|
||||
import v12ToLatest from './v12/toLatest';
|
||||
import { toV10 as v9ToV10 } from './v9/toV10';
|
||||
import { toV11 as v10ToV11 } from './v10/toV11';
|
||||
import { toV12 as v11ToV12 } from './v11/toV12';
|
||||
import { toLatest as v12ToLatest } from './v12/toLatest';
|
||||
import { getUniqTypes, toCallsOnly } from './util';
|
||||
|
||||
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getTypeDef } from '@polkadot/types/create';
|
||||
type Extracted = string | Extracted[];
|
||||
|
||||
/** @internal */
|
||||
export default function extractTypes (types: string[]): Extracted[] {
|
||||
export function extractTypes (types: string[]): Extracted[] {
|
||||
return types.map((type): Extracted => {
|
||||
const decoded = getTypeDef(type);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
type Types = string | Types[];
|
||||
|
||||
/** @internal */
|
||||
export default function flattenUniq (list: Types[]): string[] {
|
||||
export function flattenUniq (list: Types[]): string[] {
|
||||
const flat = list.reduce((result: string[], entry): string[] => {
|
||||
return result.concat(
|
||||
Array.isArray(entry)
|
||||
|
||||
@@ -6,8 +6,8 @@ import { Codec, Registry } from '@polkadot/types/types';
|
||||
import { Option, Vec } from '@polkadot/types/codec';
|
||||
import { Text, Type } from '@polkadot/types/primitive';
|
||||
|
||||
import flattenUniq from './flattenUniq';
|
||||
import validateTypes from './validateTypes';
|
||||
import { flattenUniq } from './flattenUniq';
|
||||
import { validateTypes } from './validateTypes';
|
||||
|
||||
type Arg = { type: Type } & Codec;
|
||||
|
||||
@@ -167,7 +167,7 @@ function getStorageNames ({ modules }: ExtractionMetadata): string[][][] {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export default function getUniqTypes (registry: Registry, meta: ExtractionMetadata, throwError: boolean): string[] {
|
||||
export function getUniqTypes (registry: Registry, meta: ExtractionMetadata, throwError: boolean): string[] {
|
||||
const types = flattenUniq([
|
||||
getCallNames(meta),
|
||||
getConstantNames(meta),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as flattenUniq } from './flattenUniq';
|
||||
export { default as getUniqTypes } from './getUniqTypes';
|
||||
export { default as toCallsOnly } from './toCallsOnly';
|
||||
export { default as validateTypes } from './validateTypes';
|
||||
export { flattenUniq } from './flattenUniq';
|
||||
export { getUniqTypes } from './getUniqTypes';
|
||||
export { toCallsOnly } from './toCallsOnly';
|
||||
export { validateTypes } from './validateTypes';
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MetadataInterface } from '../types';
|
||||
|
||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
|
||||
import getUniqTypes from './getUniqTypes';
|
||||
import { getUniqTypes } from './getUniqTypes';
|
||||
import { Metadata } from '../Metadata';
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -40,7 +40,7 @@ function mapCalls (registry: Registry, _calls: Option<Vec<FunctionMetadataLatest
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export default function toCallsOnly (registry: Registry, { extrinsic, modules }: MetadataLatest): AnyJson {
|
||||
export function toCallsOnly (registry: Registry, { extrinsic, modules }: MetadataLatest): AnyJson {
|
||||
return registry.createType('MetadataLatest', {
|
||||
extrinsic,
|
||||
modules: modules.map(({ calls, index, name }): ModuleMetadataTrimmed => ({
|
||||
|
||||
@@ -5,13 +5,13 @@ import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { logger } from '@polkadot/util';
|
||||
|
||||
import extractTypes from './extractTypes';
|
||||
import flattenUniq from './flattenUniq';
|
||||
import { extractTypes } from './extractTypes';
|
||||
import { flattenUniq } from './flattenUniq';
|
||||
|
||||
const l = logger('metadata');
|
||||
|
||||
/** @internal */
|
||||
export default function validateTypes (registry: Registry, types: string[], throwError: boolean): void {
|
||||
export function validateTypes (registry: Registry, types: string[], throwError: boolean): void {
|
||||
const missing = flattenUniq(extractTypes(types)).filter((type) => !registry.hasType(type));
|
||||
|
||||
if (missing.length !== 0) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@ import { MetadataV10, MetadataV11 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
/** @internal */
|
||||
export default function toV11 (registry: Registry, { modules }: MetadataV10): MetadataV11 {
|
||||
export function toV11 (registry: Registry, { modules }: MetadataV10): MetadataV11 {
|
||||
return registry.createType('MetadataV11', {
|
||||
// This is new in V11, pass V0 here - something non-existing, telling the API to use
|
||||
// the fallback for this information (on-chain detection)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@ import { Registry } from '@polkadot/types/types';
|
||||
/**
|
||||
* @internal
|
||||
**/
|
||||
export default function toV12 (registry: Registry, { extrinsic, modules }: MetadataV11): MetadataV12 {
|
||||
export function toV12 (registry: Registry, { extrinsic, modules }: MetadataV11): MetadataV12 {
|
||||
return registry.createType('MetadataLatest', {
|
||||
extrinsic,
|
||||
modules: modules.map((mod): ModuleMetadataV12 =>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -137,7 +137,7 @@ function createModule (registry: Registry, mod: ModuleMetadataV12, { calls, even
|
||||
* most-recent metadata, since it allows us a chance to actually apply call and storage specific type aliasses
|
||||
* @internal
|
||||
**/
|
||||
export default function toLatest (registry: Registry, { extrinsic, modules }: MetadataV12): MetadataLatest {
|
||||
export function toLatest (registry: Registry, { extrinsic, modules }: MetadataV12): MetadataLatest {
|
||||
registerOriginCaller(registry, modules);
|
||||
|
||||
return registry.createType('MetadataLatest', {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -56,7 +56,7 @@ function convertModule (registry: Registry, mod: ModuleMetadataV9): ModuleMetada
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export default function toV10 (registry: Registry, { modules }: MetadataV9): MetadataV10 {
|
||||
export function toV10 (registry: Registry, { modules }: MetadataV9): MetadataV10 {
|
||||
return registry.createType('MetadataV10', {
|
||||
modules: modules.map((mod): ModuleMetadataV10 => convertModule(registry, mod))
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user