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:
Jaco Greeff
2020-11-09 19:41:29 +01:00
committed by GitHub
parent e787c08bd9
commit 21d0622f84
116 changed files with 1245 additions and 1270 deletions
+3 -3
View File
@@ -30,15 +30,15 @@
"dependencies": {
"@babel/runtime": "^7.12.1",
"@polkadot/metadata": "2.6.2-0",
"@polkadot/util": "^4.0.1",
"@polkadot/util-crypto": "^4.0.1",
"@polkadot/util": "^4.0.2-5",
"@polkadot/util-crypto": "^4.0.2-5",
"@types/bn.js": "^4.11.6",
"bn.js": "^5.1.3",
"memoizee": "^0.4.14",
"rxjs": "^6.6.3"
},
"devDependencies": {
"@polkadot/keyring": "^4.0.1",
"@polkadot/keyring": "^4.0.2-5",
"@types/memoizee": "^0.4.4"
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ import BN from 'bn.js';
import { compactAddLength, compactFromU8a, compactStripLength, compactToU8a, isBigInt, isBn, isNumber, isString } from '@polkadot/util';
import { DEFAULT_BITLENGTH } from '@polkadot/util/compact/defaults';
import typeToConstructor from './utils/typeToConstructor';
import { typeToConstructor } from './utils';
import { UIntBitLength } from './AbstractInt';
export interface CompactEncodable extends Codec {
+1 -3
View File
@@ -7,9 +7,7 @@ import { AnyJson, Constructor, Codec, InterfaceTypes, Registry } from '../types'
import { isHex, hexToU8a, isObject, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
import Compact from './Compact';
import compareMap from './utils/compareMap';
import decodeU8a from './utils/decodeU8a';
import typeToConstructor from './utils/typeToConstructor';
import { compareMap, decodeU8a, typeToConstructor } from './utils';
const l = logger('Map');
+1 -1
View File
@@ -5,7 +5,7 @@ import { VoteThreshold } from '../interfaces/elections';
import { BlockNumber } from '../interfaces/runtime';
import { CodecTo } from '../types';
import Metadata from '@polkadot/metadata';
import { Metadata } from '@polkadot/metadata';
import rpcMetadata from '@polkadot/metadata/static';
import { TypeRegistry } from '../create';
+1 -1
View File
@@ -4,7 +4,7 @@
import { PropIndex } from '../interfaces/democracy';
import { Codec, CodecTo } from '../types';
import Metadata from '@polkadot/metadata';
import { Metadata } from '@polkadot/metadata';
import rpcMetadata from '@polkadot/metadata/static';
import { createTypeUnsafe, TypeRegistry } from '../create';
@@ -3,7 +3,7 @@
import { TypeRegistry } from '../../create';
import U32 from '../../primitive/U32';
import compareArray from './compareArray';
import { compareArray } from '.';
describe('compareArray', (): void => {
const registry = new TypeRegistry();
@@ -7,7 +7,7 @@ import { hasEq } from './util';
// NOTE These are used internally and when comparing objects, expects that
// when the second is an Codec[] that the first has to be as well
export default function compareArray (a: unknown[], b?: unknown): boolean {
export function compareArray (a: unknown[], b?: unknown): boolean {
if (Array.isArray(b)) {
return (a.length === b.length) && isUndefined(
a.find((value, index): boolean =>
@@ -4,7 +4,7 @@
import { Codec } from '../../types';
import { TypeRegistry } from '../../create';
import U32 from '../../primitive/U32';
import compareMap from './compareMap';
import { compareMap } from '.';
describe('compareMap', (): void => {
const registry = new TypeRegistry();
+1 -1
View File
@@ -26,7 +26,7 @@ function compareMapArray (a: Map<any, any>, b: [any, any][]): boolean {
// NOTE These are used internally and when comparing objects, expects that
// when the second is an Map<string, Codec> that the first has to be as well
export default function compareMap (a: Map<any, any>, b?: unknown): boolean {
export function compareMap (a: Map<any, any>, b?: unknown): boolean {
if (Array.isArray(b)) {
return compareMapArray(a, b);
} else if (b instanceof Map) {
+1 -1
View File
@@ -10,7 +10,7 @@ function compareSetArray (a: Set<unknown>, b: any[]): boolean {
// NOTE These are used internally and when comparing objects, expects that
// when the second is an Set<string, Codec> that the first has to be as well
export default function compareSet (a: Set<unknown>, b?: unknown): boolean {
export function compareSet (a: Set<unknown>, b?: unknown): boolean {
if (Array.isArray(b)) {
return compareSetArray(a, b);
} else if (b instanceof Set) {
+1 -1
View File
@@ -10,7 +10,7 @@ import { Codec, Constructor, Registry } from '../../types';
* @param u8a - The u8a to decode.
* @param types - The array of Constructor to decode the U8a against.
*/
export default function decodeU8a (registry: Registry, u8a: Uint8Array, _types: Constructor[] | { [index: string]: Constructor }): Codec[] {
export function decodeU8a (registry: Registry, u8a: Uint8Array, _types: Constructor[] | { [index: string]: Constructor }): Codec[] {
const types = Array.isArray(_types)
? _types
: Object.values(_types);
+6 -6
View File
@@ -1,11 +1,11 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { default as compareArray } from './compareArray';
export { default as compareMap } from './compareMap';
export { default as compareSet } from './compareSet';
export { default as decodeU8a } from './decodeU8a';
export { default as mapToTypeMap } from './mapToTypeMap';
export { default as typeToConstructor } from './typeToConstructor';
export { compareArray } from './compareArray';
export { compareMap } from './compareMap';
export { compareSet } from './compareSet';
export { decodeU8a } from './decodeU8a';
export { mapToTypeMap } from './mapToTypeMap';
export { typeToConstructor } from './typeToConstructor';
export * from './encodeTypes';
@@ -3,12 +3,12 @@
import { Constructor, InterfaceTypes, Registry } from '../../types';
import typeToConstructor from './typeToConstructor';
import { typeToConstructor } from './typeToConstructor';
/**
* @description takes an input map of the form `{ [string]: string | Constructor }` and returns a map of `{ [string]: Constructor }`
*/
export default function mapToTypeMap (registry: Registry, input: Record<string, keyof InterfaceTypes | Constructor>): Record<string, Constructor> {
export function mapToTypeMap (registry: Registry, input: Record<string, keyof InterfaceTypes | Constructor>): Record<string, Constructor> {
return Object
.entries(input)
.reduce((output: Record<string, Constructor>, [key, type]): Record<string, Constructor> => {
@@ -5,7 +5,7 @@ import { Codec, Constructor, InterfaceTypes, Registry } from '../../types';
import { isString } from '@polkadot/util';
export default function typeToConstructor <T = Codec> (registry: Registry, type: keyof InterfaceTypes | Constructor<T>): Constructor<T> {
export function typeToConstructor <T = Codec> (registry: Registry, type: keyof InterfaceTypes | Constructor<T>): Constructor<T> {
return (
isString(type)
? registry.createClass(type)
@@ -5,7 +5,7 @@
import { TypeRegistry } from '../create';
import Raw from '../codec/Raw';
import AccountId from './AccountId';
import { GenericEthereumAccountId as AccountId } from './AccountId';
describe('EthereumAccountId', (): void => {
const registry = new TypeRegistry();
+3 -3
View File
@@ -22,13 +22,13 @@ function decodeAccountId (value: AnyU8a | AnyString): AnyU8a {
}
/**
* @name EthereumAccountId
* @name GenericEthereumAccountId
* @description
* A wrapper around an Ethereum-compatible AccountId. Since we are dealing with
* underlying addresses (20 bytes in length), we extend from U8aFixed which is
* just a Uint8Array wrapper with a fixed length.
*/
export default class AccountId extends U8aFixed {
export class GenericEthereumAccountId extends U8aFixed {
constructor (registry: Registry, value: AnyU8a = new Uint8Array()) {
super(registry, decodeAccountId(value), 160);
}
@@ -62,7 +62,7 @@ export default class AccountId extends U8aFixed {
* @description Returns the string representation of the value
*/
public toString (): string {
return AccountId.encode(this);
return GenericEthereumAccountId.encode(this);
}
/**
@@ -3,8 +3,7 @@
import { TypeRegistry } from '../create';
import AccountIndex from '../generic/AccountIndex';
import AccountId from './AccountId';
import Address from './LookupSource';
import { GenericEthereumAccountId as AccountId, GenericEthereumLookupSource as Address } from '.';
describe('EthereumLookupSource', (): void => {
const registry = new TypeRegistry();
+10 -10
View File
@@ -9,15 +9,15 @@ import { decodeAddress } from '@polkadot/util-crypto';
import Base from '../codec/Base';
import AccountIndex from '../generic/AccountIndex';
import EthereumAccountId from './AccountId';
import { GenericEthereumAccountId } from './AccountId';
// eslint-disable-next-line no-use-before-define
type AnyAddress = BigInt | BN | LookupSource | EthereumAccountId | AccountIndex | number[] | Uint8Array | number | string;
type AnyAddress = BigInt | BN | GenericEthereumLookupSource | GenericEthereumAccountId | AccountIndex | number[] | Uint8Array | number | string;
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
/** @internal */
function decodeString (registry: Registry, value: string): EthereumAccountId | AccountIndex {
function decodeString (registry: Registry, value: string): GenericEthereumAccountId | AccountIndex {
const decoded = decodeAddress(value);
return decoded.length === 20
@@ -26,7 +26,7 @@ function decodeString (registry: Registry, value: string): EthereumAccountId | A
}
/** @internal */
function decodeU8a (registry: Registry, value: Uint8Array): EthereumAccountId | AccountIndex {
function decodeU8a (registry: Registry, value: Uint8Array): GenericEthereumAccountId | AccountIndex {
// This allows us to instantiate an address with a raw publicKey. Do this first before
// we checking the first byte, otherwise we may split an already-existent valid address
if (value.length === 20) {
@@ -41,23 +41,23 @@ function decodeU8a (registry: Registry, value: Uint8Array): EthereumAccountId |
}
/**
* @name LookupSource
* @name GenericEthereumLookupSource
* @description
* A wrapper around an EthereumAccountId and/or AccountIndex that is encoded with a prefix.
* Since we are dealing with underlying publicKeys (or shorter encoded addresses),
* we extend from Base with an AccountId/AccountIndex wrapper. Basically the Address
* is encoded as `[ <prefix-byte>, ...publicKey/...bytes ]` as per spec
*/
export default class LookupSource extends Base<EthereumAccountId | AccountIndex> {
export class GenericEthereumLookupSource extends Base<GenericEthereumAccountId | AccountIndex> {
constructor (registry: Registry, value: AnyAddress = new Uint8Array()) {
super(registry, LookupSource._decodeAddress(registry, value));
super(registry, GenericEthereumLookupSource._decodeAddress(registry, value));
}
/** @internal */
private static _decodeAddress (registry: Registry, value: AnyAddress): EthereumAccountId | AccountIndex {
return value instanceof LookupSource
private static _decodeAddress (registry: Registry, value: AnyAddress): GenericEthereumAccountId | AccountIndex {
return value instanceof GenericEthereumLookupSource
? value._raw
: value instanceof EthereumAccountId || value instanceof AccountIndex
: value instanceof GenericEthereumAccountId || value instanceof AccountIndex
? value
: isBn(value) || isNumber(value) || isBigInt(value)
? registry.createType('AccountIndex', value)
+2 -2
View File
@@ -1,5 +1,5 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { default as GenericEthereumAccountId } from './AccountId';
export { default as GenericEthereumLookupSource } from './LookupSource';
export { GenericEthereumAccountId } from './AccountId';
export { GenericEthereumLookupSource } from './LookupSource';
@@ -1,11 +1,11 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import Metadata from '@polkadot/metadata';
import { Metadata } from '@polkadot/metadata';
import rpcMetadata from '@polkadot/metadata/static';
import { TypeRegistry } from '../create';
import Extrinsic from './Extrinsic';
import { GenericExtrinsic as Extrinsic } from '.';
const registry = new TypeRegistry();
const metadata = new Metadata(registry, rpcMetadata);
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import Metadata from '@polkadot/metadata';
import { Metadata } from '@polkadot/metadata';
import rpcMetadata from '@polkadot/metadata/static';
import { TypeRegistry } from '../create';
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
import BN from 'bn.js';
import testingPairs from '@polkadot/keyring/testingPairs';
import Metadata, { extrinsicsFromMeta } from '@polkadot/metadata';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import { Metadata, extrinsicsFromMeta } from '@polkadot/metadata';
import rpcMetadata from '@polkadot/metadata/static';
import { TypeRegistry } from '../../create';
@@ -11,7 +11,7 @@ import Extrinsic from './Extrinsic';
const registry = new TypeRegistry();
const metadata = new Metadata(registry, rpcMetadata);
const keyring = testingPairs({ type: 'ed25519' }, false);
const keyring = createTestPairs({ type: 'ed25519' }, false);
registry.setMetadata(metadata);
+1 -1
View File
@@ -4,7 +4,7 @@
/* eslint-disable sort-keys */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import Metadata from '@polkadot/metadata';
import { Metadata } from '@polkadot/metadata';
import metadataStatic from '@polkadot/metadata/static';
import { TypeRegistry } from '../create';
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import Metadata from '@polkadot/metadata';
import { Metadata } from '@polkadot/metadata';
import metadataStatic from '@polkadot/metadata/static';
import { TypeRegistry } from '../create';
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import Metadata from '@polkadot/metadata';
import { Metadata } from '@polkadot/metadata';
import metadataStatic from '@polkadot/metadata/static';
import { createTypeUnsafe, TypeRegistry } from './create';
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { default as Metadata } from '@polkadot/metadata';
export { Metadata } from '@polkadot/metadata';
export * from './extrinsic';
export * from './generic';
@@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import Metadata from '@polkadot/metadata';
import { Metadata } from '@polkadot/metadata';
import rpcMetadata from '@polkadot/metadata/static';
import { TypeRegistry } from '../../create';
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import Metadata, { storageFromMeta } from '@polkadot/metadata';
import { Metadata, storageFromMeta } from '@polkadot/metadata';
import rpcDataV11 from '@polkadot/metadata/v11/static';
import { TypeRegistry } from '../create';