Adjust interfaces for cleaner esnext usage (#2833)

* Adjust interfaces for cleaner esnext usage

* Swap out esnext
This commit is contained in:
Jaco Greeff
2020-11-09 23:17:52 +01:00
committed by GitHub
parent 8993844739
commit e6dbbfae34
82 changed files with 242 additions and 348 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import { AnyNumber, Registry } from '@polkadot/types/types';
import { assert } from '@polkadot/util';
import U32 from '@polkadot/types/primitive/U32';
import { u32 as U32 } from '@polkadot/types/primitive';
export const MAGIC_NUMBER = 0x6174656d; // `meta`, reversed for Little Endian encoding
+1 -1
View File
@@ -4,7 +4,7 @@
import { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12 } from '@polkadot/types/interfaces/metadata';
import { Registry } from '@polkadot/types/types';
import Struct from '@polkadot/types/codec/Struct';
import { Struct } from '@polkadot/types/codec';
import { assert } from '@polkadot/util';
import { MagicNumber } from './MagicNumber';
@@ -3,8 +3,9 @@
import { Constants } from '../types';
import { Metadata, TypeRegistry } from '@polkadot/types';
import { TypeRegistry } from '@polkadot/types';
import { Metadata } from '../../Metadata';
import rpcMetadata from '../../static';
import rpcMetadataV10 from '../../v10/static';
import { constantsFromMeta } from './fromMetadata';
@@ -7,7 +7,7 @@ import { Constants, ConstantCodec, ModuleConstants } from '../types';
import { createTypeUnsafe } from '@polkadot/types/create';
import { hexToU8a, stringCamelCase } from '@polkadot/util';
import { Metadata } from '../..';
import { Metadata } from '../../Metadata';
/** @internal */
export function constantsFromMeta (registry: Registry, metadata: Metadata): Constants {
@@ -7,7 +7,7 @@ import { AnyJson, CallFunction, Registry, RegistryMetadataCall } from '@polkadot
import { assert, stringCamelCase } from '@polkadot/util';
/** @internal */
export default function createDescriptor (registry: Registry, section: string, callIndex: Uint8Array, callMetadata: RegistryMetadataCall): CallFunction {
export default function createUnchecked (registry: Registry, section: string, callIndex: Uint8Array, callMetadata: RegistryMetadataCall): CallFunction {
const expectedArgs = callMetadata.args;
const funcName = stringCamelCase(callMetadata.name);
@@ -1,8 +1,9 @@
// Copyright 2017-2020 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Metadata, TypeRegistry } from '@polkadot/types';
import { TypeRegistry } from '@polkadot/types';
import { Metadata } from '../../Metadata';
import json from '../../static';
import { extrinsicsFromMeta } from './fromMetadata';
@@ -3,8 +3,9 @@
import BN from 'bn.js';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import { Metadata, TypeRegistry } from '@polkadot/types';
import { TypeRegistry } from '@polkadot/types';
import { Metadata } from '../../Metadata';
import metadataStatic from '../../static';
import { extrinsicsFromMeta } from './fromMetadata';
+1 -1
View File
@@ -4,7 +4,7 @@
import { TypeRegistry } from '@polkadot/types/create';
import { u8aToHex } from '@polkadot/util';
import { Metadata } from '..';
import { Metadata } from '../Metadata';
import json from '../static';
import { constantsFromMeta, extrinsicsFromMeta, storageFromMeta } from './';
+1 -1
View File
@@ -6,7 +6,7 @@ import { DecoratedMeta } from './types';
import { assert } from '@polkadot/util';
import { Metadata } from '..';
import { Metadata } from '../Metadata';
import { constantsFromMeta } from './consts/fromMetadata';
import { extrinsicsFromMeta } from './extrinsics/fromMetadata';
import { storageFromMeta } from './storage/fromMetadata';
@@ -2,13 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
import { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
import { StorageEntry } from '@polkadot/types/primitive/types';
import { Codec, Registry } from '@polkadot/types/types';
import BN from 'bn.js';
import { Compact, Raw } from '@polkadot/types/codec';
import { Raw } from '@polkadot/types/codec';
import { createTypeUnsafe } from '@polkadot/types/create';
import StorageKey, { StorageEntry } from '@polkadot/types/primitive/StorageKey';
import { assert, compactStripLength, isNull, isUndefined, stringLowerFirst, u8aConcat } from '@polkadot/util';
import { StorageKey } from '@polkadot/types';
import { assert, compactAddLength, compactStripLength, isNull, isUndefined, stringLowerFirst, u8aConcat } from '@polkadot/util';
import { xxhashAsU8a } from '@polkadot/util-crypto';
import getHasher, { HasherFunction } from './getHasher';
@@ -75,7 +76,7 @@ function createKeyDoubleMap (registry: Registry, itemFn: CreateItemFn, args: [Cr
const val2 = createTypeUnsafe(registry, map.key2.toString(), [key2]).toU8a();
// as per createKey, always add the length prefix (underlying it is Bytes)
return Compact.addLengthPrefix(u8aConcat(
return compactAddLength(u8aConcat(
createPrefixedKey(itemFn),
hasher1(val1),
hasher2(val2)
@@ -97,7 +98,7 @@ function createKey (registry: Registry, itemFn: CreateItemFn, arg: CreateArgType
}
// StorageKey is a Bytes, so is length-prefixed
return Compact.addLengthPrefix(u8aConcat(
return compactAddLength(u8aConcat(
createPrefixedKey(itemFn),
param.length
? hasher(param)
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
import { StorageEntry } from '@polkadot/types/primitive/types';
import { Registry } from '@polkadot/types/types';
import { Storage } from '../types';
@@ -1,11 +1,10 @@
// Copyright 2017-2020 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
import { StorageEntryMetadataLatest } from '@polkadot/types/interfaces';
import { StorageEntry } from '@polkadot/types/primitive/types';
import { Registry } from '@polkadot/types/types';
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
import createFunction from './createFunction';
interface SubstrateMetadata {
+1 -1
View File
@@ -3,7 +3,7 @@
import { AugmentedConst, QueryableConsts, QueryableModuleConsts } from '@polkadot/api/types/consts';
import { Codec, ModulesWithCalls } from '@polkadot/types/types';
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
import { StorageEntry } from '@polkadot/types/primitive/types';
export interface ModuleStorage {
[key: string]: StorageEntry;
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { Codec } from '@polkadot/types/types';
import Vec from '@polkadot/types/codec/Vec';
import { Vec } from '@polkadot/types/codec';
export interface MetadataInterface<Modules extends Codec> extends Codec {
modules: Vec<Modules>;
+1 -1
View File
@@ -7,7 +7,7 @@ import { MetadataInterface } from '../types';
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
import getUniqTypes from './getUniqTypes';
import { Metadata } from '..';
import { Metadata } from '../Metadata';
/** @internal */
export function decodeLatestSubstrate<Modules extends Codec> (registry: Registry, version: number, rpcData: string, staticSubstrate: Record<string, unknown>): void {
@@ -4,7 +4,7 @@
import { TypeRegistry } from '@polkadot/types';
import staticData from '../static';
import { Metadata } from '..';
import { Metadata } from '../Metadata';
describe('toCallsOnly', (): void => {
const registry = new TypeRegistry();