Bump common (#2832)
* Bump common * Update for new common non-default exports * Don't export createSubmittable * Adjust exports * default export adjustments * Some additional non-default exports
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import MagicNumber, { MAGIC_NUMBER } from './MagicNumber';
|
||||
import { MagicNumber, MAGIC_NUMBER } from './MagicNumber';
|
||||
|
||||
describe('MagicNumber', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
@@ -9,7 +9,7 @@ import U32 from '@polkadot/types/primitive/U32';
|
||||
|
||||
export const MAGIC_NUMBER = 0x6174656d; // `meta`, reversed for Little Endian encoding
|
||||
|
||||
export default class MagicNumber extends U32 {
|
||||
export class MagicNumber extends U32 {
|
||||
constructor (registry: Registry, value?: AnyNumber) {
|
||||
super(registry, value);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import substrateData from './static';
|
||||
import Metadata from './Metadata';
|
||||
import { Metadata } from './Metadata';
|
||||
|
||||
describe('Metadata', (): void => {
|
||||
it('allows creation from hex with JSON equivalence', (): void => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { isString, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import MetadataVersioned from './MetadataVersioned';
|
||||
import { MetadataVersioned } from './MetadataVersioned';
|
||||
|
||||
// magic u32 preceding the version id
|
||||
const VERSION_IDX = 4;
|
||||
@@ -49,7 +49,7 @@ function decodeMetadata (registry: Registry, _value?: Uint8Array | string): Meta
|
||||
* @description
|
||||
* The versioned runtime metadata as a decoded structure
|
||||
*/
|
||||
export default class Metadata extends MetadataVersioned {
|
||||
export class Metadata extends MetadataVersioned {
|
||||
constructor (registry: Registry, value?: Uint8Array | string) {
|
||||
super(registry, decodeMetadata(registry, value));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Registry } from '@polkadot/types/types';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import MagicNumber from './MagicNumber';
|
||||
import { MagicNumber } from './MagicNumber';
|
||||
import v9ToV10 from './v9/toV10';
|
||||
import v10ToV11 from './v10/toV11';
|
||||
import v11ToV12 from './v11/toV12';
|
||||
@@ -23,7 +23,7 @@ type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12';
|
||||
* @description
|
||||
* The versioned runtime metadata as a decoded structure
|
||||
*/
|
||||
export default class MetadataVersioned extends Struct {
|
||||
export class MetadataVersioned extends Struct {
|
||||
readonly #converted = new Map<number, MetaMapped>();
|
||||
|
||||
constructor (registry: Registry, value?: unknown) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Metadata, TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import rpcMetadata from '../../static';
|
||||
import rpcMetadataV10 from '../../v10/static';
|
||||
import fromMetadata from './fromMetadata';
|
||||
import { constantsFromMeta } from './fromMetadata';
|
||||
|
||||
function init (meta: string): [Constants, TypeRegistry] {
|
||||
const registry = new TypeRegistry();
|
||||
@@ -15,7 +15,7 @@ function init (meta: string): [Constants, TypeRegistry] {
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
return [fromMetadata(registry, metadata), registry];
|
||||
return [constantsFromMeta(registry, metadata), registry];
|
||||
}
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
|
||||
@@ -7,10 +7,10 @@ import { Constants, ConstantCodec, ModuleConstants } from '../types';
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { hexToU8a, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import Metadata from '../..';
|
||||
import { Metadata } from '../..';
|
||||
|
||||
/** @internal */
|
||||
export default function fromMetadata (registry: Registry, metadata: Metadata): Constants {
|
||||
export function constantsFromMeta (registry: Registry, metadata: Metadata): Constants {
|
||||
return metadata.asLatest.modules.reduce((result: Constants, moduleMetadata): Constants => {
|
||||
if (moduleMetadata.constants.isEmpty) {
|
||||
return result;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { Metadata, TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import json from '../../static';
|
||||
import fromMetadata from './fromMetadata';
|
||||
import { extrinsicsFromMeta } from './fromMetadata';
|
||||
|
||||
// Use the pre-generated metadata
|
||||
const registry = new TypeRegistry();
|
||||
@@ -12,7 +12,7 @@ const metadata = new Metadata(registry, json);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const newExtrinsics = fromMetadata(registry, metadata);
|
||||
const newExtrinsics = extrinsicsFromMeta(registry, metadata);
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
it('should throw if an incorrect number of args is supplied', (): void => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import extrinsics from './';
|
||||
import createUnchecked from './createUnchecked';
|
||||
|
||||
/** @internal */
|
||||
export default function fromMetadata (registry: Registry, metadata: RegistryMetadata): ModulesWithCalls {
|
||||
export function extrinsicsFromMeta (registry: Registry, metadata: RegistryMetadata): ModulesWithCalls {
|
||||
const modules = metadata.asLatest.modules;
|
||||
const isIndexed = modules.some(({ index }) => !index.eqn(255));
|
||||
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import BN from 'bn.js';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import { Metadata, TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import metadataStatic from '../../static';
|
||||
import fromMetadata from './fromMetadata';
|
||||
import { extrinsicsFromMeta } from './fromMetadata';
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' }, false);
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const extrinsics = fromMetadata(registry, metadata);
|
||||
const extrinsics = extrinsicsFromMeta(registry, metadata);
|
||||
|
||||
describe('extrinsics', (): void => {
|
||||
it('encodes an actual transfer (actual data)', (): void => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Metadata from '..';
|
||||
import { Metadata } from '..';
|
||||
import json from '../static';
|
||||
import { constantsFromMeta, extrinsicsFromMeta, storageFromMeta } from './';
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ import { DecoratedMeta } from './types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Metadata from '..';
|
||||
import constantsFromMeta from './consts/fromMetadata';
|
||||
import extrinsicsFromMeta from './extrinsics/fromMetadata';
|
||||
import storageFromMeta from './storage/fromMetadata';
|
||||
import { Metadata } from '..';
|
||||
import { constantsFromMeta } from './consts/fromMetadata';
|
||||
import { extrinsicsFromMeta } from './extrinsics/fromMetadata';
|
||||
import { storageFromMeta } from './storage/fromMetadata';
|
||||
|
||||
/**
|
||||
* Expands the metadata by decoration int consts, query and tx sections
|
||||
*/
|
||||
export default function expandMetadata (registry: Registry, value: Metadata): DecoratedMeta {
|
||||
export function expandMetadata (registry: Registry, value: Metadata): DecoratedMeta {
|
||||
assert(value instanceof Metadata, 'You need to pass a valid Metadata instance to Decorated');
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Metadata from '../../';
|
||||
import { Metadata } from '../../';
|
||||
import rpcMetadata from '../../static';
|
||||
import { storageFromMeta } from '../';
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' });
|
||||
const keyring = createTestPairs({ type: 'ed25519' });
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
describe('latest', (): void => {
|
||||
|
||||
@@ -6,12 +6,12 @@ import { ModuleStorage, Storage } from '../types';
|
||||
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import Metadata from '../../Metadata';
|
||||
import { Metadata } from '../../Metadata';
|
||||
import createFunction from './createFunction';
|
||||
import getStorage from './storage';
|
||||
|
||||
/** @internal */
|
||||
export default function fromMetadata (registry: Registry, metadata: Metadata): Storage {
|
||||
export function storageFromMeta (registry: Registry, metadata: Metadata): Storage {
|
||||
return metadata.asLatest.modules.reduce((result: Storage, moduleMetadata): Storage => {
|
||||
if (moduleMetadata.storage.isNone) {
|
||||
return result;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import expandMetadata, { constantsFromMeta, extrinsicsFromMeta, storageFromMeta } from './decorate';
|
||||
import Metadata from './Metadata';
|
||||
|
||||
export default Metadata;
|
||||
|
||||
export { constantsFromMeta, expandMetadata, extrinsicsFromMeta, storageFromMeta };
|
||||
export { Metadata } from './Metadata';
|
||||
export { constantsFromMeta, expandMetadata, extrinsicsFromMeta, storageFromMeta } from './decorate';
|
||||
|
||||
@@ -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 '..';
|
||||
|
||||
/** @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 '..';
|
||||
|
||||
describe('toCallsOnly', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
Reference in New Issue
Block a user