Adjust create imports (#2834)
* Adjust create imports * Restore create root exports * Adjust unsafe creation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { MagicNumber, MAGIC_NUMBER } from './MagicNumber';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import substrateData from './static';
|
||||
import { Metadata } from './Metadata';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { Constants } from '../types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import rpcMetadata from '../../static';
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { Constants, ConstantCodec, ModuleConstants } from '../types';
|
||||
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { hexToU8a, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
@@ -22,7 +21,7 @@ export function constantsFromMeta (registry: Registry, metadata: Metadata): Cons
|
||||
result[stringCamelCase(name)] = moduleMetadata.constants.reduce((newModule: ModuleConstants, meta): ModuleConstants => {
|
||||
// convert to the natural type as received
|
||||
const type = meta.type.toString();
|
||||
const codec: ConstantCodec = createTypeUnsafe(registry, type, [hexToU8a(meta.value.toHex())]);
|
||||
const codec = registry.createType(type as 'Raw', hexToU8a(meta.value.toHex())) as unknown as ConstantCodec;
|
||||
|
||||
codec.meta = meta;
|
||||
newModule[stringCamelCase(meta.name)] = codec;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import json from '../../static';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import metadataStatic from '../../static';
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Text, TypeRegistry } from '@polkadot/types';
|
||||
import { Text } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import createFunction from './createFunction';
|
||||
|
||||
@@ -7,8 +7,7 @@ import { Codec, Registry } from '@polkadot/types/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Raw } from '@polkadot/types/codec';
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { StorageKey } from '@polkadot/types';
|
||||
import { StorageKey } from '@polkadot/types/primitive';
|
||||
import { assert, compactAddLength, compactStripLength, isNull, isUndefined, stringLowerFirst, u8aConcat } from '@polkadot/util';
|
||||
import { xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -72,8 +71,8 @@ function createKeyDoubleMap (registry: Registry, itemFn: CreateItemFn, args: [Cr
|
||||
|
||||
const [key1, key2] = args;
|
||||
const map = type.asDoubleMap;
|
||||
const val1 = createTypeUnsafe(registry, map.key1.toString(), [key1]).toU8a();
|
||||
const val2 = createTypeUnsafe(registry, map.key2.toString(), [key2]).toU8a();
|
||||
const val1 = registry.createType(map.key1.toString() as 'Raw', key1).toU8a();
|
||||
const val2 = registry.createType(map.key2.toString() as 'Raw', key2).toU8a();
|
||||
|
||||
// as per createKey, always add the length prefix (underlying it is Bytes)
|
||||
return compactAddLength(u8aConcat(
|
||||
@@ -94,7 +93,7 @@ function createKey (registry: Registry, itemFn: CreateItemFn, arg: CreateArgType
|
||||
|
||||
assert(!isUndefined(arg) && !isNull(arg), `${name.toString()} is a Map and requires one argument`);
|
||||
|
||||
param = createTypeUnsafe(registry, map.key.toString(), [arg]).toU8a();
|
||||
param = registry.createType(map.key.toString() as 'Raw', arg).toU8a();
|
||||
}
|
||||
|
||||
// StorageKey is a Bytes, so is length-prefixed
|
||||
@@ -136,7 +135,7 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
|
||||
// meta fallback only applies to actual entry values, create one for head
|
||||
(iterFn as IterFn).meta = registry.createType('StorageEntryMetadataLatest', {
|
||||
documentation,
|
||||
fallback: registry.createType('Bytes', createTypeUnsafe(registry, outputType).toHex()),
|
||||
fallback: registry.createType('Bytes', registry.createType(outputType as 'Raw').toHex()),
|
||||
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
|
||||
name,
|
||||
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', type.isMap ? type.asMap.key : type.asDoubleMap.key1), 0)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../../';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
import { xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import getStorage from './storage';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import staticData from '../static';
|
||||
import { Metadata } from '../Metadata';
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
import { FunctionMetadataLatest, MetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||
import { AnyJson, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Option, Text, Vec, u8 } from '@polkadot/types';
|
||||
import { Option, Vec } from '@polkadot/types/codec';
|
||||
import { Text, u8 } from '@polkadot/types/primitive';
|
||||
|
||||
interface ModuleMetadataTrimmed {
|
||||
calls: Option<Vec<FunctionMetadataLatest>>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
|
||||
Reference in New Issue
Block a user