diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b99c2ae51..08eddb8366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # CHANGELOG +## master + +Changes: + +- Adjust Struct decoding with better error messages on invalid input objects +- Add support for new `BoundedVec` type +- Adjusted Statemint `Proxy` type +- Updated Xcm types (with Plularity) +- Remove metadata generation dependency on well-known.json (dedupe) +- Adjust WebSocket reconnection delay from 1s to 2.5s +- Revert Beefy keys addition for Westend + + ## 4.6.2 Apr 19, 2021 Upgrade priority: Low. diff --git a/packages/api-contract/package.json b/packages/api-contract/package.json index 47f42db72f..06df9823bd 100644 --- a/packages/api-contract/package.json +++ b/packages/api-contract/package.json @@ -19,8 +19,8 @@ "@babel/runtime": "^7.13.17", "@polkadot/api": "4.6.3-7", "@polkadot/types": "4.6.3-7", - "@polkadot/util": "^6.2.1", - "@polkadot/x-rxjs": "^6.2.1", + "@polkadot/util": "^6.2.2-7", + "@polkadot/x-rxjs": "^6.2.2-7", "bn.js": "^4.11.9" } } diff --git a/packages/api-contract/src/Abi.ts b/packages/api-contract/src/Abi.ts index f2d29e2244..e2804deaf3 100644 --- a/packages/api-contract/src/Abi.ts +++ b/packages/api-contract/src/Abi.ts @@ -6,7 +6,7 @@ import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, Contr import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types'; import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types'; -import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util'; +import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util'; import { MetaRegistry } from './MetaRegistry'; @@ -21,7 +21,7 @@ function findMessage (list: T[], messageOrId: T | string ? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString())) : messageOrId; - return assertReturn(message, `Attempted to call an invalid contract interface, ${JSON.stringify(messageOrId)}`); + return assertReturn(message, `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`); } export class Abi { @@ -81,7 +81,7 @@ export class Abi { const index = data[0]; const event = this.#events[index]; - assert(event, `Unable to find event with index ${index}`); + assert(event, () => `Unable to find event with index ${index}`); return event.fromU8a(data.subarray(1)); } @@ -118,7 +118,7 @@ export class Abi { type: this.registry.getMetaTypeDef(arg.type) }; } catch (error) { - l.error(`Error expanding argument ${index} in ${JSON.stringify(spec)}`); + l.error(`Error expanding argument ${index} in ${stringify(spec)}`); throw error; } @@ -186,7 +186,7 @@ export class Abi { } #encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[], additional = EMPTY_U8A): Uint8Array => { - assert(data.length === args.length, `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`); + assert(data.length === args.length, () => `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`); return compactAddLength( u8aConcat( diff --git a/packages/api-contract/src/MetaRegistry.ts b/packages/api-contract/src/MetaRegistry.ts index 04f9cbd164..bfba0d2893 100644 --- a/packages/api-contract/src/MetaRegistry.ts +++ b/packages/api-contract/src/MetaRegistry.ts @@ -80,7 +80,7 @@ export class MetaRegistry extends TypeRegistry { #getMetaType = (id: SiLookupTypeId): SiType => { const type = this.#siTypes[getRegistryOffset(id)]; - assert(!isUndefined(type), `getMetaType:: Unable to find ${id.toNumber()} in type values`); + assert(!isUndefined(type), () => `getMetaType:: Unable to find ${id.toNumber()} in type values`); return this.createType('SiType', type); } @@ -184,7 +184,7 @@ export class MetaRegistry extends TypeRegistry { } #extractSequence = ({ type }: SiTypeDefSequence, id: SiLookupTypeId): Omit => { - assert(!!type, `ContractRegistry: Invalid sequence type found at id ${id.toString()}`); + assert(!!type, () => `ContractRegistry: Invalid sequence type found at id ${id.toString()}`); return { info: TypeDefInfo.Vec, diff --git a/packages/api-derive/package.json b/packages/api-derive/package.json index fdee1fa611..eac3fdd8e7 100644 --- a/packages/api-derive/package.json +++ b/packages/api-derive/package.json @@ -20,13 +20,13 @@ "@polkadot/api": "4.6.3-7", "@polkadot/rpc-core": "4.6.3-7", "@polkadot/types": "4.6.3-7", - "@polkadot/util": "^6.2.1", - "@polkadot/util-crypto": "^6.2.1", - "@polkadot/x-rxjs": "^6.2.1", + "@polkadot/util": "^6.2.2-7", + "@polkadot/util-crypto": "^6.2.2-7", + "@polkadot/x-rxjs": "^6.2.2-7", "bn.js": "^4.11.9" }, "devDependencies": { - "@polkadot/keyring": "^6.2.1", + "@polkadot/keyring": "^6.2.2-7", "@polkadot/rpc-provider": "4.6.3-7" } } diff --git a/packages/api/package.json b/packages/api/package.json index b993ae2e0a..eb921c6594 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -18,15 +18,15 @@ "dependencies": { "@babel/runtime": "^7.13.17", "@polkadot/api-derive": "4.6.3-7", - "@polkadot/keyring": "^6.2.1", + "@polkadot/keyring": "^6.2.2-7", "@polkadot/metadata": "4.6.3-7", "@polkadot/rpc-core": "4.6.3-7", "@polkadot/rpc-provider": "4.6.3-7", "@polkadot/types": "4.6.3-7", "@polkadot/types-known": "4.6.3-7", - "@polkadot/util": "^6.2.1", - "@polkadot/util-crypto": "^6.2.1", - "@polkadot/x-rxjs": "^6.2.1", + "@polkadot/util": "^6.2.2-7", + "@polkadot/util-crypto": "^6.2.2-7", + "@polkadot/x-rxjs": "^6.2.2-7", "bn.js": "^4.11.9", "eventemitter3": "^4.0.7" } diff --git a/packages/api/src/base/Init.ts b/packages/api/src/base/Init.ts index 226d5ef63b..be78f40ef9 100644 --- a/packages/api/src/base/Init.ts +++ b/packages/api/src/base/Init.ts @@ -13,7 +13,7 @@ import BN from 'bn.js'; import { Metadata } from '@polkadot/metadata'; import { TypeRegistry } from '@polkadot/types/create'; import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known'; -import { assert, BN_ZERO, logger, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util'; +import { assert, BN_ZERO, logger, stringify, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util'; import { cryptoWaitReady } from '@polkadot/util-crypto'; import { of } from '@polkadot/x-rxjs'; import { map, switchMap } from '@polkadot/x-rxjs/operators'; @@ -197,7 +197,7 @@ export abstract class Init extends Decorate { if (Object.keys(types).length) { (registry || this.registry).register(types as Record); - l.debug(`Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${JSON.stringify(types)}`); + l.debug(() => `Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${stringify(types)}`); } }) .catch(l.error); diff --git a/packages/api/src/base/capabilities.ts b/packages/api/src/base/capabilities.ts index 45ba4b1b7e..44578ecae1 100644 --- a/packages/api/src/base/capabilities.ts +++ b/packages/api/src/base/capabilities.ts @@ -75,7 +75,7 @@ function mapCapabilities ({ accountIdLength }: Constants, [leasePeriodsPerSlot, const numIds = tupleLength / accountIdLength; const numIdsRound = Math.floor(numIds); - assert(numIds >= 2 && numIds <= 11, `Detected ${numIds} in Keys, should be >= 2 and <= 11`); + assert(numIds >= 2 && numIds <= 11, () => `Detected ${numIds} in Keys, should be >= 2 and <= 11`); if (numIdsRound !== numIds) { // Beefy? @@ -84,7 +84,7 @@ function mapCapabilities ({ accountIdLength }: Constants, [leasePeriodsPerSlot, // @ts-ignore types.Keys = `SessionKeys${numIdsRound - 1}B`; } else { - assert(false, `Expected integer number of keys, found ${numIds.toFixed(2)}`); + assert(false, () => `Expected integer number of keys, found ${numIds.toFixed(2)}`); } } else { // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/packages/api/src/util/validate.ts b/packages/api/src/util/validate.ts index 2b42891c1e..f438109c78 100644 --- a/packages/api/src/util/validate.ts +++ b/packages/api/src/util/validate.ts @@ -13,7 +13,7 @@ function sig ({ method, section }: StorageEntry, ...args: Type[]): string { function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] { const { key1, key2 } = creator.meta.type.asDoubleMap; - assert(args.length === 2, `${sig(creator, key1, key2)} is a doublemap, requiring 2 arguments, ${args.length} found`); + assert(args.length === 2, () => `${sig(creator, key1, key2)} is a doublemap, requiring 2 arguments, ${args.length} found`); // pass as tuple return [creator, args as [any, any]]; @@ -22,7 +22,7 @@ function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [a function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] { const { key } = creator.meta.type.asMap; - assert(args.length === 1, `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`); + assert(args.length === 1, () => `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`); // expand return args.length @@ -41,7 +41,7 @@ export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [S return doMap(creator, args); } - assert(args.length === 0, `${sig(creator)} does not take any arguments, ${args.length} found`); + assert(args.length === 0, () => `${sig(creator)} does not take any arguments, ${args.length} found`); // no args return [creator]; diff --git a/packages/metadata/package.json b/packages/metadata/package.json index 6cea393433..28c5e01127 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -19,11 +19,11 @@ "@babel/runtime": "^7.13.17", "@polkadot/types": "4.6.3-7", "@polkadot/types-known": "4.6.3-7", - "@polkadot/util": "^6.2.1", - "@polkadot/util-crypto": "^6.2.1", + "@polkadot/util": "^6.2.2-7", + "@polkadot/util-crypto": "^6.2.2-7", "bn.js": "^4.11.9" }, "devDependencies": { - "@polkadot/keyring": "^6.2.1" + "@polkadot/keyring": "^6.2.2-7" } } diff --git a/packages/metadata/src/MagicNumber.ts b/packages/metadata/src/MagicNumber.ts index 5fa511d941..b9f4b09ae1 100644 --- a/packages/metadata/src/MagicNumber.ts +++ b/packages/metadata/src/MagicNumber.ts @@ -15,7 +15,7 @@ export class MagicNumber extends U32 { if (!this.isEmpty) { const magic = registry.createType('u32', MAGIC_NUMBER); - assert(this.eq(magic), `MagicNumber mismatch: expected ${magic.toHex()}, found ${this.toHex()}`); + assert(this.eq(magic), () => `MagicNumber mismatch: expected ${magic.toHex()}, found ${this.toHex()}`); } } } diff --git a/packages/metadata/src/MetadataVersioned.ts b/packages/metadata/src/MetadataVersioned.ts index db579e0b94..c8d9e2e293 100644 --- a/packages/metadata/src/MetadataVersioned.ts +++ b/packages/metadata/src/MetadataVersioned.ts @@ -34,7 +34,7 @@ export class MetadataVersioned extends Struct { } #assertVersion = (version: number): boolean => { - assert(this.version <= version, `Cannot convert metadata from v${this.version} to v${version}`); + assert(this.version <= version, () => `Cannot convert metadata from v${this.version} to v${version}`); return this.version === version; }; diff --git a/packages/metadata/src/decorate/extrinsics/createUnchecked.ts b/packages/metadata/src/decorate/extrinsics/createUnchecked.ts index b3302aecf9..6a2b36b334 100644 --- a/packages/metadata/src/decorate/extrinsics/createUnchecked.ts +++ b/packages/metadata/src/decorate/extrinsics/createUnchecked.ts @@ -16,7 +16,7 @@ export function createUnchecked (registry: Registry, section: string, callIndex: const funcName = stringCamelCase(callMetadata.name); const extrinsicFn = (...args: any[]): Call => { - assert(expectedArgs.length === args.length, `Extrinsic ${section}.${funcName} expects ${expectedArgs.length.valueOf()} arguments, got ${args.length}.`); + assert(expectedArgs.length === args.length, () => `Extrinsic ${section}.${funcName} expects ${expectedArgs.length.valueOf()} arguments, got ${args.length}.`); return registry.createType('Call', { args, diff --git a/packages/metadata/src/decorate/storage/createFunction.ts b/packages/metadata/src/decorate/storage/createFunction.ts index 3c5679a469..142fb5c8f2 100644 --- a/packages/metadata/src/decorate/storage/createFunction.ts +++ b/packages/metadata/src/decorate/storage/createFunction.ts @@ -65,7 +65,7 @@ function createKeyDoubleMap (registry: Registry, itemFn: CreateItemFn, args: [Cr const { meta: { name, type } } = itemFn; // since we are passing an almost-unknown through, trust, but verify - assert(Array.isArray(args) && !isUndefined(args[0]) && !isNull(args[0]) && !isUndefined(args[1]) && !isNull(args[1]), `${(name || 'unknown').toString()} is a DoubleMap and requires two arguments`); + assert(Array.isArray(args) && !isUndefined(args[0]) && !isNull(args[0]) && !isUndefined(args[1]) && !isNull(args[1]), () => `${(name || 'unknown').toString()} is a DoubleMap and requires two arguments`); // if this fails, we have bigger issues assert(!isUndefined(hasher2), '2 hashing functions should be defined for DoubleMaps'); @@ -92,7 +92,7 @@ function createKey (registry: Registry, itemFn: CreateItemFn, arg: CreateArgType if (type.isMap) { const map = type.asMap; - assert(!isUndefined(arg) && !isNull(arg), `${name.toString()} is a Map and requires one argument`); + assert(!isUndefined(arg) && !isNull(arg), () => `${name.toString()} is a Map and requires one argument`); param = registry.createType(map.key.toString() as 'Raw', arg).toU8a(); } diff --git a/packages/metadata/src/util/testUtil.ts b/packages/metadata/src/util/testUtil.ts index 99e89f0c29..768da9824d 100644 --- a/packages/metadata/src/util/testUtil.ts +++ b/packages/metadata/src/util/testUtil.ts @@ -5,7 +5,7 @@ import type { Codec, Registry } from '@polkadot/types/types'; import type { MetadataInterface } from '../types'; import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey'; -import { assert, hexToU8a, u8aToHex } from '@polkadot/util'; +import { assert, hexToU8a, stringify, u8aToHex } from '@polkadot/util'; import { Metadata } from '../Metadata'; import { getUniqTypes } from './getUniqTypes'; @@ -22,7 +22,7 @@ export function decodeLatestSubstrate (registry: Registry expect((metadata[`asV${version}` as keyof Metadata] as unknown as MetadataInterface).modules.length).not.toBe(0); expect(metadata.toJSON()).toEqual(staticSubstrate); } catch (error) { - console.error(JSON.stringify(metadata.toJSON())); + console.error(stringify(metadata.toJSON())); throw error; } @@ -65,7 +65,7 @@ export function defaultValues (registry: Registry, rpcData: string, withThrow = if (withFallbackCheck) { const [hexType, hexOrig] = [u8aToHex(type.toU8a()), u8aToHex(fallback.toU8a(true))]; - assert(hexType === hexOrig, `Fallback does not match (${((hexOrig.length - 2) / 2) - ((hexType.length - 2) / 2)} bytes missing): ${hexType} !== ${hexOrig}`); + assert(hexType === hexOrig, () => `Fallback does not match (${((hexOrig.length - 2) / 2) - ((hexType.length - 2) / 2)} bytes missing): ${hexType} !== ${hexOrig}`); } } catch (error) { const message = `${location}:: ${(error as Error).message}`; diff --git a/packages/rpc-core/package.json b/packages/rpc-core/package.json index 3edee78e89..078dddf5d7 100644 --- a/packages/rpc-core/package.json +++ b/packages/rpc-core/package.json @@ -20,10 +20,10 @@ "@polkadot/metadata": "4.6.3-7", "@polkadot/rpc-provider": "4.6.3-7", "@polkadot/types": "4.6.3-7", - "@polkadot/util": "^6.2.1", - "@polkadot/x-rxjs": "^6.2.1" + "@polkadot/util": "^6.2.2-7", + "@polkadot/x-rxjs": "^6.2.2-7" }, "devDependencies": { - "@polkadot/keyring": "^6.2.1" + "@polkadot/keyring": "^6.2.2-7" } } diff --git a/packages/rpc-core/src/index.ts b/packages/rpc-core/src/index.ts index f5045e6f2e..24fca4d091 100644 --- a/packages/rpc-core/src/index.ts +++ b/packages/rpc-core/src/index.ts @@ -343,7 +343,7 @@ export class RpcCore { ? '' : ` (${def.params.length - reqArgCount} optional)`; - assert(inputs.length >= reqArgCount && inputs.length <= def.params.length, `Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`); + assert(inputs.length >= reqArgCount && inputs.length <= def.params.length, () => `Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`); return inputs.map((input, index): Codec => createTypeUnsafe(registry, def.params[index].type, [input], { blockHash }) diff --git a/packages/rpc-core/src/util/drr.ts b/packages/rpc-core/src/util/drr.ts index d2e43d1e9e..551b0e41d7 100644 --- a/packages/rpc-core/src/util/drr.ts +++ b/packages/rpc-core/src/util/drr.ts @@ -3,7 +3,7 @@ import type { Observable } from '@polkadot/x-rxjs'; -import { logger } from '@polkadot/util'; +import { logger, stringify } from '@polkadot/util'; import { catchError, distinctUntilChanged, publishReplay, refCount, tap } from '@polkadot/x-rxjs/operators'; import { refCountDelay } from './refCountDelay'; @@ -19,7 +19,7 @@ interface Options { const l = logger('drr'); const CMP = (a: unknown, b: unknown): boolean => - JSON.stringify({ t: a }) === JSON.stringify({ t: b }); + stringify({ t: a }) === stringify({ t: b }); const ERR = (error: Error): Observable => { l.error(error); diff --git a/packages/rpc-provider/package.json b/packages/rpc-provider/package.json index 1a700c6cc1..adcdae4e63 100644 --- a/packages/rpc-provider/package.json +++ b/packages/rpc-provider/package.json @@ -18,16 +18,16 @@ "dependencies": { "@babel/runtime": "^7.13.17", "@polkadot/types": "4.6.3-7", - "@polkadot/util": "^6.2.1", - "@polkadot/util-crypto": "^6.2.1", - "@polkadot/x-fetch": "^6.2.1", - "@polkadot/x-global": "^6.2.1", - "@polkadot/x-ws": "^6.2.1", + "@polkadot/util": "^6.2.2-7", + "@polkadot/util-crypto": "^6.2.2-7", + "@polkadot/x-fetch": "^6.2.2-7", + "@polkadot/x-global": "^6.2.2-7", + "@polkadot/x-ws": "^6.2.2-7", "bn.js": "^4.11.9", "eventemitter3": "^4.0.7" }, "devDependencies": { - "@polkadot/keyring": "^6.2.1", + "@polkadot/keyring": "^6.2.2-7", "@polkadot/metadata": "4.6.3-7", "mock-socket": "^9.0.3", "nock": "^13.0.11" diff --git a/packages/rpc-provider/src/coder/index.ts b/packages/rpc-provider/src/coder/index.ts index 867d71f61d..60a5502f0f 100644 --- a/packages/rpc-provider/src/coder/index.ts +++ b/packages/rpc-provider/src/coder/index.ts @@ -3,7 +3,7 @@ import type { JsonRpcRequest, JsonRpcResponse, JsonRpcResponseBaseError } from '../types'; -import { assert, isNumber, isString, isUndefined } from '@polkadot/util'; +import { assert, isNumber, isString, isUndefined, stringify } from '@polkadot/util'; function formatErrorData (data?: string | number): string { if (isUndefined(data)) { @@ -12,7 +12,7 @@ function formatErrorData (data?: string | number): string { const formatted = `: ${isString(data) ? data.replace(/Error\("/g, '').replace(/\("/g, '(').replace(/"\)/g, ')').replace(/\(/g, ', ').replace(/\)/g, '') - : JSON.stringify(data)}`; + : stringify(data)}`; // We need some sort of cut-off here since these can be very large and // very nested, pick a number and trim the result display to it @@ -47,7 +47,7 @@ export class RpcCoder { } public encodeJson (method: string, params: any | any[]): string { - return JSON.stringify( + return stringify( this.encodeObject(method, params) ); } diff --git a/packages/rpc-provider/src/http/index.ts b/packages/rpc-provider/src/http/index.ts index eeec5d270b..76e9484710 100644 --- a/packages/rpc-provider/src/http/index.ts +++ b/packages/rpc-provider/src/http/index.ts @@ -44,7 +44,7 @@ export class HttpProvider implements ProviderInterface { * @param {string} endpoint The endpoint url starting with http:// */ constructor (endpoint: string = defaults.HTTP_URL, headers: Record = {}) { - assert(/^(https|http):\/\//.test(endpoint), `Endpoint should start with 'http://', received '${endpoint}'`); + assert(/^(https|http):\/\//.test(endpoint), () => `Endpoint should start with 'http://', received '${endpoint}'`); this.#coder = new RpcCoder(); this.#endpoint = endpoint; @@ -116,7 +116,7 @@ export class HttpProvider implements ProviderInterface { method: 'POST' }); - assert(response.ok, `[${response.status}]: ${response.statusText}`); + assert(response.ok, () => `[${response.status}]: ${response.statusText}`); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const result = await response.json(); diff --git a/packages/rpc-provider/src/mock/index.ts b/packages/rpc-provider/src/mock/index.ts index 8a81b072cc..79744acb63 100644 --- a/packages/rpc-provider/src/mock/index.ts +++ b/packages/rpc-provider/src/mock/index.ts @@ -60,7 +60,7 @@ export class MockProvider implements ProviderInterface { chain_getFinalizedHead: () => this.registry.createType('Header', rpcHeader.result).hash, // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access chain_getHeader: () => this.registry.createType('Header', rpcHeader.result).toJSON(), - rpc_methods: (): string[] => [], + rpc_methods: () => this.registry.createType('RpcMethods').toJSON(), state_getKeys: (): string[] => [], state_getKeysPaged: (): string[] => [], state_getMetadata: (): string => rpcMetadata, @@ -121,7 +121,7 @@ export class MockProvider implements ProviderInterface { // eslint-disable-next-line @typescript-eslint/require-await public async send (method: string, params: any[]): Promise { - assert(this.requests[method], `provider.send: Invalid method '${method}'`); + assert(this.requests[method], () => `provider.send: Invalid method '${method}'`); return this.requests[method](this.db, params); } @@ -130,7 +130,7 @@ export class MockProvider implements ProviderInterface { public async subscribe (type: string, method: string, ...params: unknown[]): Promise { l.debug((): any => ['subscribe', method, params]); - assert(this.subscriptions[method], `provider.subscribe: Invalid method '${method}'`); + assert(this.subscriptions[method], () => `provider.subscribe: Invalid method '${method}'`); const callback = params.pop() as MockStateSubscriptionCallback; const id = ++this.subscriptionId; @@ -151,7 +151,7 @@ export class MockProvider implements ProviderInterface { l.debug((): any => ['unsubscribe', id, sub]); - assert(sub, `Unable to find subscription for ${id}`); + assert(sub, () => `Unable to find subscription for ${id}`); delete this.subscriptionMap[id]; delete this.subscriptions[sub].callbacks[id]; diff --git a/packages/rpc-provider/src/ws/index.ts b/packages/rpc-provider/src/ws/index.ts index f5f0baabdb..4aaf987c17 100644 --- a/packages/rpc-provider/src/ws/index.ts +++ b/packages/rpc-provider/src/ws/index.ts @@ -109,7 +109,7 @@ export class WsProvider implements ProviderInterface { assert(endpoints.length !== 0, 'WsProvider requires at least one Endpoint'); endpoints.forEach((endpoint) => { - assert(/^(wss|ws):\/\//.test(endpoint), `Endpoint should start with 'ws://', received '${endpoint}'`); + assert(/^(wss|ws):\/\//.test(endpoint), () => `Endpoint should start with 'ws://', received '${endpoint}'`); }); this.#eventemitter = new EventEmitter(); diff --git a/packages/rpc-provider/test/mockWs.ts b/packages/rpc-provider/test/mockWs.ts index a44593aa55..63a04b36c3 100644 --- a/packages/rpc-provider/test/mockWs.ts +++ b/packages/rpc-provider/test/mockWs.ts @@ -3,6 +3,8 @@ import { Server, WebSocket } from 'mock-socket'; +import { stringify } from '@polkadot/util'; + interface Scope { body: { [index: string]: Record }; requests: number; @@ -79,7 +81,7 @@ export function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: stri scope.body[request.method] = body; requestCount++; - socket.send(JSON.stringify(response)); + socket.send(stringify(response)); }); }); diff --git a/packages/typegen/package.json b/packages/typegen/package.json index 8752076def..6626f4ff87 100644 --- a/packages/typegen/package.json +++ b/packages/typegen/package.json @@ -30,7 +30,7 @@ "@polkadot/metadata": "4.6.3-7", "@polkadot/rpc-provider": "4.6.3-7", "@polkadot/types": "4.6.3-7", - "@polkadot/util": "^6.2.1", + "@polkadot/util": "^6.2.2-7", "handlebars": "^4.7.7", "websocket": "^1.0.34", "yargs": "^16.2.0" diff --git a/packages/typegen/src/generate/tsDef.ts b/packages/typegen/src/generate/tsDef.ts index ce574eed2f..4463f8c6cc 100644 --- a/packages/typegen/src/generate/tsDef.ts +++ b/packages/typegen/src/generate/tsDef.ts @@ -10,7 +10,7 @@ import path from 'path'; import { getTypeDef } from '@polkadot/types/create'; import { TypeDefInfo } from '@polkadot/types/create/types'; import * as defaultDefinitions from '@polkadot/types/interfaces/definitions'; -import { assert, isString, stringCamelCase, stringUpperFirst } from '@polkadot/util'; +import { assert, isString, stringCamelCase, stringify, stringUpperFirst } from '@polkadot/util'; import { createImports, exportInterface, exportType, formatType, readTemplate, setImports, TypeImports, writeFile } from '../util'; @@ -192,7 +192,7 @@ function generateInterfaces (definitions: Record, { types } }; return Object.entries(types).map(([name, type]): [string, string] => { - const def = getTypeDef(isString(type) ? type : JSON.stringify(type), { name }); + const def = getTypeDef(isString(type) ? type : stringify(type), { name }); return [name, generators[def.info](definitions, def, imports)]; }); diff --git a/packages/typegen/src/util/derived.ts b/packages/typegen/src/util/derived.ts index ea5b470a57..e83188e78e 100644 --- a/packages/typegen/src/util/derived.ts +++ b/packages/typegen/src/util/derived.ts @@ -12,7 +12,7 @@ import { GenericAccountId, GenericLookupSource, GenericVote } from '@polkadot/ty import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions'; import { Null } from '@polkadot/types/primitive'; import * as primitiveClasses from '@polkadot/types/primitive'; -import { isChildClass } from '@polkadot/util'; +import { isChildClass, stringify } from '@polkadot/util'; import { isCompactEncodable } from './class'; import { formatType } from './formatting'; @@ -98,7 +98,7 @@ export function getSimilarTypes (registry: Registry, definitions: Record, type: stri } default: { - throw new Error(`Cannot format ${JSON.stringify(type)}`); + throw new Error(`Cannot format ${stringify(type)}`); } } } diff --git a/packages/types-known/package.json b/packages/types-known/package.json index fd3decea80..99aa79550f 100644 --- a/packages/types-known/package.json +++ b/packages/types-known/package.json @@ -17,9 +17,9 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme", "dependencies": { "@babel/runtime": "^7.13.17", - "@polkadot/networks": "^6.2.1", + "@polkadot/networks": "^6.2.2-7", "@polkadot/types": "4.6.3-7", - "@polkadot/util": "^6.2.1", + "@polkadot/util": "^6.2.2-7", "bn.js": "^4.11.9" }, "devDependencies": { diff --git a/packages/types-known/src/upgrades/index.ts b/packages/types-known/src/upgrades/index.ts index 3a1e05865c..2068f4e14d 100644 --- a/packages/types-known/src/upgrades/index.ts +++ b/packages/types-known/src/upgrades/index.ts @@ -7,7 +7,7 @@ import type { ChainUpgradesRaw } from './types'; import BN from 'bn.js'; import networks from '@polkadot/networks'; -import { assert, hexToU8a } from '@polkadot/util'; +import { assert, hexToU8a, stringify } from '@polkadot/util'; import kusama from './kusama'; import polkadot from './polkadot'; @@ -30,7 +30,7 @@ function checkOrder (network: string, versions: ChainUpgradesRaw): [number, numb : curr[0] <= prev[0] || curr[1] <= prev[1]; }); - assert(!ooo.length, `${network}: Mismatched upgrade ordering: ${JSON.stringify(ooo)}`); + assert(!ooo.length, () => `${network}: Mismatched upgrade ordering: ${stringify(ooo)}`); return versions; } @@ -39,7 +39,7 @@ function checkOrder (network: string, versions: ChainUpgradesRaw): [number, numb function mapRaw ([network, versions]: [string, ChainUpgradesRaw]): ChainUpgrades { const chain = networks.find((n) => n.network === network) || NET_EXTRA[network]; - assert(chain, `Unable to find info for chain ${network}`); + assert(chain, () => `Unable to find info for chain ${network}`); return { genesisHash: hexToU8a(chain.genesisHash[0]), diff --git a/packages/types/package.json b/packages/types/package.json index 5161bba987..f7b1e97bed 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -18,13 +18,13 @@ "dependencies": { "@babel/runtime": "^7.13.17", "@polkadot/metadata": "4.6.3-7", - "@polkadot/util": "^6.2.1", - "@polkadot/util-crypto": "^6.2.1", - "@polkadot/x-rxjs": "^6.2.1", + "@polkadot/util": "^6.2.2-7", + "@polkadot/util-crypto": "^6.2.2-7", + "@polkadot/x-rxjs": "^6.2.2-7", "@types/bn.js": "^4.11.6", "bn.js": "^4.11.9" }, "devDependencies": { - "@polkadot/keyring": "^6.2.1" + "@polkadot/keyring": "^6.2.2-7" } } diff --git a/packages/types/src/codec/AbstractInt.ts b/packages/types/src/codec/AbstractInt.ts index 5e4c8848b3..c2718fc70a 100644 --- a/packages/types/src/codec/AbstractInt.ts +++ b/packages/types/src/codec/AbstractInt.ts @@ -7,7 +7,7 @@ import type { UIntBitLength } from './types'; import BN from 'bn.js'; -import { assert, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, BN_ZERO, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isHex, isString, isU8a, u8aToBn } from '@polkadot/util'; +import { assert, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, BN_ZERO, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isHex, isString, isU8a, stringify, u8aToBn } from '@polkadot/util'; export const DEFAULT_UINT_BITS = 64; @@ -37,7 +37,7 @@ function decodeAbstracIntU8a (value: Uint8Array, bitLength: UIntBitLength, isNeg // NOTE When passing u8a in (typically from decoded data), it is always Little Endian return u8aToBn(value.subarray(0, bitLength / 8), { isLe: true, isNegative }).toString(); } catch (error) { - throw new Error(`AbstractInt: failed on ${JSON.stringify(value)}:: ${(error as Error).message}`); + throw new Error(`AbstractInt: failed on ${stringify(value)}:: ${(error as Error).message}`); } } @@ -83,8 +83,8 @@ export abstract class AbstractInt extends BN implements Codec { const isPositive = this.gte(BN_ZERO); const maxBits = bitLength - (isSigned && isPositive ? 1 : 0); - assert(isSigned || isPositive, `${this.toRawType()}: Negative number passed to unsigned type`); - assert(super.bitLength() <= maxBits, `${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${maxBits}`); + assert(isSigned || isPositive, () => `${this.toRawType()}: Negative number passed to unsigned type`); + assert(super.bitLength() <= maxBits, () => `${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${maxBits}`); } /** diff --git a/packages/types/src/codec/BTreeSet.ts b/packages/types/src/codec/BTreeSet.ts index b4016a87cc..60fb31f2f3 100644 --- a/packages/types/src/codec/BTreeSet.ts +++ b/packages/types/src/codec/BTreeSet.ts @@ -4,7 +4,7 @@ import type { CodecHash, Hash } from '../interfaces/runtime'; import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types'; -import { compactFromU8a, compactToU8a, isHex, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util'; +import { compactFromU8a, compactToU8a, isHex, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util'; import { compareSet, decodeU8a, typeToConstructor } from './utils'; @@ -176,7 +176,7 @@ export class BTreeSet extends Set implements Codec { * @description Returns the string representation of the value */ public toString (): string { - return JSON.stringify(this.toJSON()); + return stringify(this.toJSON()); } /** diff --git a/packages/types/src/codec/Compact.ts b/packages/types/src/codec/Compact.ts index 8c9b862174..9fd62902d7 100644 --- a/packages/types/src/codec/Compact.ts +++ b/packages/types/src/codec/Compact.ts @@ -3,7 +3,7 @@ import type { CodecHash, Hash } from '../interfaces'; import type { AnyJson, AnyNumber, Constructor, ICompact, InterfaceTypes, Registry } from '../types'; -import type { CompactEncodable, UIntBitLength } from './types'; +import type { CompactEncodable } from './types'; import BN from 'bn.js'; @@ -50,9 +50,7 @@ export class Compact implements ICompact { return new Type(registry, value); } - const [, _value] = compactFromU8a(value, new Type(registry, 0).bitLength() as UIntBitLength); - - return new Type(registry, _value); + return new Type(registry, compactFromU8a(value)[1]); } /** diff --git a/packages/types/src/codec/Enum.ts b/packages/types/src/codec/Enum.ts index 42bbec166a..a67870c714 100644 --- a/packages/types/src/codec/Enum.ts +++ b/packages/types/src/codec/Enum.ts @@ -4,7 +4,7 @@ import type { CodecHash, Hash } from '../interfaces'; import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types'; -import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, stringCamelCase, stringUpperFirst, u8aConcat, u8aToHex } from '@polkadot/util'; +import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, stringCamelCase, stringify, stringUpperFirst, u8aConcat, u8aToHex } from '@polkadot/util'; import { Null } from '../primitive/Null'; import { Struct } from './Struct'; @@ -88,7 +88,7 @@ function extractDef (registry: Registry, _def: Record e.index === index); - assert(!isUndefined(entry), `Unable to create Enum via index ${index}, in ${Object.keys(def).join(', ')}`); + assert(!isUndefined(entry), () => `Unable to create Enum via index ${index}, in ${Object.keys(def).join(', ')}`); return { index, @@ -105,7 +105,7 @@ function decodeFromJSON (registry: Registry, def: TypesDef, key: string, value?: const keyLower = key.toLowerCase(); const index = keys.indexOf(keyLower); - assert(index !== -1, `Cannot map Enum JSON, unable to find '${key}' in ${keys.join(', ')}`); + assert(index !== -1, () => `Cannot map Enum JSON, unable to find '${key}' in ${keys.join(', ')}`); try { return createFromValue(registry, def, Object.values(def)[index].index, value); @@ -213,7 +213,7 @@ export class Enum implements Codec { Object.defineProperty(this, askey, { enumerable: true, get: (): Codec => { - assert(this[iskey as keyof this], `Cannot convert '${this.type}' via ${askey}`); + assert(this[iskey as keyof this], () => `Cannot convert '${this.type}' via ${askey}`); return this.value; } @@ -384,7 +384,7 @@ export class Enum implements Codec { * @description Returns the base runtime type name for this instance */ public toRawType (): string { - return JSON.stringify({ _enum: this._toRawStruct() }); + return stringify({ _enum: this._toRawStruct() }); } /** @@ -393,7 +393,7 @@ export class Enum implements Codec { public toString (): string { return this.isNull ? this.type - : JSON.stringify(this.toJSON()); + : stringify(this.toJSON()); } /** diff --git a/packages/types/src/codec/Json.ts b/packages/types/src/codec/Json.ts index 05bbd2e7e2..20ba30f16c 100644 --- a/packages/types/src/codec/Json.ts +++ b/packages/types/src/codec/Json.ts @@ -4,7 +4,7 @@ import type { CodecHash, Hash } from '../interfaces/runtime'; import type { AnyJson, Codec, Registry } from '../types'; -import { isFunction, isUndefined } from '@polkadot/util'; +import { isFunction, isUndefined, stringify } from '@polkadot/util'; import { compareMap } from './utils'; @@ -112,7 +112,7 @@ export class Json extends Map implements Codec { * @description Returns the string representation of the value */ public toString (): string { - return JSON.stringify(this.toJSON()); + return stringify(this.toJSON()); } /** diff --git a/packages/types/src/codec/Map.ts b/packages/types/src/codec/Map.ts index 8569ba87a3..50cd76a427 100644 --- a/packages/types/src/codec/Map.ts +++ b/packages/types/src/codec/Map.ts @@ -4,7 +4,7 @@ import type { CodecHash, Hash } from '../interfaces/runtime'; import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types'; -import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util'; +import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util'; import { compareMap, decodeU8a, typeToConstructor } from './utils'; @@ -183,7 +183,7 @@ export class CodecMap extends * @description Returns the string representation of the value */ public toString (): string { - return JSON.stringify(this.toJSON()); + return stringify(this.toJSON()); } /** diff --git a/packages/types/src/codec/Set.ts b/packages/types/src/codec/Set.ts index 85e9d881bf..9f54bd9726 100644 --- a/packages/types/src/codec/Set.ts +++ b/packages/types/src/codec/Set.ts @@ -6,7 +6,7 @@ import type { Codec, Constructor, Registry } from '../types'; import BN from 'bn.js'; -import { assert, bnToBn, bnToU8a, isBn, isNumber, isString, isU8a, isUndefined, stringCamelCase, stringUpperFirst, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util'; +import { assert, bnToBn, bnToU8a, isBn, isNumber, isString, isU8a, isUndefined, stringCamelCase, stringify, stringUpperFirst, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util'; import { compareArray } from './utils'; @@ -21,7 +21,7 @@ function encodeSet (setValues: SetValues, value: string[]): BN { /** @internal */ function decodeSetArray (setValues: SetValues, value: string[]): string[] { return value.reduce((result, key): string[] => { - assert(!isUndefined(setValues[key]), `Set: Invalid key '${key}' passed to Set, allowed ${Object.keys(setValues).join(', ')}`); + assert(!isUndefined(setValues[key]), () => `Set: Invalid key '${key}' passed to Set, allowed ${Object.keys(setValues).join(', ')}`); result.push(key); @@ -42,14 +42,14 @@ function decodeSetNumber (setValues: SetValues, _value: BN | number): string[] { const computed = encodeSet(setValues, result); - assert(bn.eq(computed), `Set: Mismatch decoding '${bn.toString()}', computed as '${computed.toString()}' with ${result.join(', ')}`); + assert(bn.eq(computed), () => `Set: Mismatch decoding '${bn.toString()}', computed as '${computed.toString()}' with ${result.join(', ')}`); return result; } /** @internal */ function decodeSet (setValues: SetValues, value: string[] | Set | Uint8Array | BN | number | string = 0, bitLength: number): string[] { - assert(bitLength % 8 === 0, `Expected valid bitLength, power of 8, found ${bitLength}`); + assert(bitLength % 8 === 0, () => `Expected valid bitLength, power of 8, found ${bitLength}`); const byteLength = bitLength / 8; @@ -155,7 +155,7 @@ export class CodecSet extends Set implements Codec { // ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos // we have the isUndefined(this._setValues) in here as well, add is used internally // in the Set constructor (so it is undefined at this point, and should allow) - assert(isUndefined(this.#allowed) || !isUndefined(this.#allowed[key]), `Set: Invalid key '${key}' on add`); + assert(isUndefined(this.#allowed) || !isUndefined(this.#allowed[key]), () => `Set: Invalid key '${key}' on add`); super.add(key); @@ -210,7 +210,7 @@ export class CodecSet extends Set implements Codec { * @description Returns the base runtime type name for this instance */ public toRawType (): string { - return JSON.stringify({ _set: this.#allowed }); + return stringify({ _set: this.#allowed }); } /** diff --git a/packages/types/src/codec/Struct.spec.ts b/packages/types/src/codec/Struct.spec.ts index 9efdbaa6c2..7144a47217 100644 --- a/packages/types/src/codec/Struct.spec.ts +++ b/packages/types/src/codec/Struct.spec.ts @@ -119,6 +119,14 @@ describe('Struct', (): void => { ).toThrowError(/Cannot decode value/); }); + it('throws a sensical error on incorrect array values passed to structs', (): void => { + expect( + () => new Struct(registry, { + _: 'Vec' + }, [123, 456]) + ).toThrow(/array to object with known keys/); + }); + it('provides a clean toString()', (): void => { expect( new ( diff --git a/packages/types/src/codec/Struct.ts b/packages/types/src/codec/Struct.ts index 17c3bb0057..c9766f3fbb 100644 --- a/packages/types/src/codec/Struct.ts +++ b/packages/types/src/codec/Struct.ts @@ -4,7 +4,7 @@ import type { CodecHash, Hash } from '../interfaces/runtime'; import type { AnyJson, BareOpts, Codec, Constructor, ConstructorDef, InterfaceTypes, Registry } from '../types'; -import { hexToU8a, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util'; +import { assert, hexToU8a, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util'; import { compareMap, decodeU8a, mapToTypeMap } from './utils'; @@ -13,8 +13,11 @@ type TypesDef = Record> /** @internal */ function decodeStructFromObject (registry: Registry, Types: ConstructorDef, value: any, jsonMap: Map): T { let jsonObj: Record | undefined; + const inputKeys = Object.keys(Types); - return Object.keys(Types).reduce((raw, key, index): T => { + assert(!Array.isArray(value) || value.length === inputKeys.length, () => `Struct: Unable to map ${stringify(value)} array to object with known keys ${inputKeys.join(', ')}`); + + return inputKeys.reduce((raw, key, index): T => { // The key in the JSON can be snake_case (or other cases), but in our // Types, result or any other maps, it's camelCase // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access @@ -60,7 +63,7 @@ function decodeStructFromObject (registry: Registry, Types: ConstructorDef, ? assign : new Types[key](registry, assign); } else { - throw new Error(`Cannot decode value ${JSON.stringify(value)}`); + throw new Error(`Cannot decode value ${stringify(value)} (typeof ${typeof value}), expected an input object with known keys`); } } catch (error) { let type = Types[key].name; @@ -297,7 +300,7 @@ export class Struct< * @description Returns the base runtime type name for this instance */ public toRawType (): string { - return JSON.stringify( + return stringify( Struct.typesToMap(this.registry, this.#Types) ); } @@ -306,7 +309,7 @@ export class Struct< * @description Returns the string representation of the value */ public toString (): string { - return JSON.stringify(this.toJSON()); + return stringify(this.toJSON()); } /** diff --git a/packages/types/src/codec/Tuple.ts b/packages/types/src/codec/Tuple.ts index 1727a4644d..c8369787e8 100644 --- a/packages/types/src/codec/Tuple.ts +++ b/packages/types/src/codec/Tuple.ts @@ -3,7 +3,7 @@ import type { AnyNumber, AnyString, AnyU8a, Codec, Constructor, InterfaceTypes, Registry } from '../types'; -import { isHex, isU8a, u8aConcat, u8aToU8a } from '@polkadot/util'; +import { isHex, isU8a, stringify, u8aConcat, u8aToU8a } from '@polkadot/util'; import { AbstractArray } from './AbstractArray'; import { decodeU8a, mapToTypeMap, typeToConstructor } from './utils'; @@ -110,7 +110,7 @@ export class Tuple extends AbstractArray { */ public toString (): string { // Overwrite the default toString representation of Array. - return JSON.stringify(this.toJSON()); + return stringify(this.toJSON()); } /** diff --git a/packages/types/src/codec/Vec.ts b/packages/types/src/codec/Vec.ts index ff99c35d7f..8268bbe77b 100644 --- a/packages/types/src/codec/Vec.ts +++ b/packages/types/src/codec/Vec.ts @@ -50,7 +50,7 @@ export class Vec extends AbstractArray { const u8a = u8aToU8a(value); const [offset, length] = compactFromU8a(u8a); - assert(length.lten(MAX_LENGTH), `Vec length ${length.toString()} exceeds ${MAX_LENGTH}`); + assert(length.lten(MAX_LENGTH), () => `Vec length ${length.toString()} exceeds ${MAX_LENGTH}`); return decodeU8a(registry, u8a.subarray(offset), new Array(length.toNumber()).fill(Type)) as T[]; } diff --git a/packages/types/src/codec/VecFixed.ts b/packages/types/src/codec/VecFixed.ts index 68d4cc1098..8eeb35c16d 100644 --- a/packages/types/src/codec/VecFixed.ts +++ b/packages/types/src/codec/VecFixed.ts @@ -39,7 +39,7 @@ export class VecFixed extends AbstractArray { values.push(new Type(registry)); } - assert(values.length === allocLength, `Expected a length of exactly ${allocLength} entries`); + assert(values.length === allocLength, () => `Expected a length of exactly ${allocLength} entries`); return values; } diff --git a/packages/types/src/create/createClass.ts b/packages/types/src/create/createClass.ts index 782335b3cd..5cba177105 100644 --- a/packages/types/src/create/createClass.ts +++ b/packages/types/src/create/createClass.ts @@ -5,7 +5,7 @@ import type { U8aBitLength, UIntBitLength } from '../codec/types'; import type { Codec, Constructor, InterfaceTypes, Registry } from '../types'; import type { FromReg, TypeDef } from './types'; -import { assert, isNumber, isUndefined } from '@polkadot/util'; +import { assert, isNumber, isUndefined, stringify } from '@polkadot/util'; import { BTreeMap, BTreeSet, CodecSet, Compact, Enum, HashMap, Int, Option, Result, Struct, Tuple, U8aFixed, UInt, Vec, VecFixed } from '../codec'; import { DoNotConstruct } from '../primitive'; @@ -33,13 +33,13 @@ export function ClassOf (registry: Registry, nam } function getSubDefArray (value: TypeDef): TypeDef[] { - assert(value.sub && Array.isArray(value.sub), `Expected subtype as TypeDef[] in ${JSON.stringify(value)}`); + assert(value.sub && Array.isArray(value.sub), () => `Expected subtype as TypeDef[] in ${stringify(value)}`); return value.sub; } function getSubDef (value: TypeDef): TypeDef { - assert(value.sub && !Array.isArray(value.sub), `Expected subtype as TypeDef in ${JSON.stringify(value)}`); + assert(value.sub && !Array.isArray(value.sub), () => `Expected subtype as TypeDef in ${stringify(value)}`); return value.sub; } @@ -67,7 +67,7 @@ function getTypeClassArray (value: TypeDef): (keyof InterfaceTypes)[] { } function createInt ({ displayName, length }: TypeDef, Clazz: typeof Int | typeof UInt): Constructor { - assert(isNumber(length), `Expected bitLength information for ${displayName || Clazz.constructor.name}`); + assert(isNumber(length), () => `Expected bitLength information for ${displayName || Clazz.constructor.name}`); return Clazz.with(length as UIntBitLength, displayName); } @@ -185,7 +185,7 @@ export function getTypeClass (registry: Registry, value const getFn = infoMapping[value.info]; - assert(getFn, `Unable to construct class from ${JSON.stringify(value)}`); + assert(getFn, () => `Unable to construct class from ${stringify(value)}`); return getFn(registry, value) as Constructor; } diff --git a/packages/types/src/create/encodeTypes.ts b/packages/types/src/create/encodeTypes.ts index b663bd4167..69aff6ae68 100644 --- a/packages/types/src/create/encodeTypes.ts +++ b/packages/types/src/create/encodeTypes.ts @@ -3,7 +3,7 @@ import type { TypeDef } from './types'; -import { assert, isNumber, isUndefined } from '@polkadot/util'; +import { assert, isNumber, isUndefined, stringify } from '@polkadot/util'; import { TypeDefInfo } from './types'; @@ -34,7 +34,7 @@ function encodeWithParams (typeDef: TypeDef, outer: string): string { return paramsNotation(outer, sub, (param) => encodeTypeDef(param)); } - throw new Error(`Unable to encode ${JSON.stringify(typeDef)} with params`); + throw new Error(`Unable to encode ${stringify(typeDef)} with params`); } function encodeDoNotConstruct ({ displayName }: TypeDef): string { @@ -44,14 +44,14 @@ function encodeDoNotConstruct ({ displayName }: TypeDef): string { function encodeSubTypes (sub: TypeDef[], asEnum?: boolean): string { const names = sub.map(({ name }) => name); - assert(names.every((n) => !!n), `Subtypes does not have consistent names, ${names.join(', ')}`); + assert(names.every((n) => !!n), () => `Subtypes does not have consistent names, ${names.join(', ')}`); const inner = sub.reduce((result: Record, type): Record => ({ ...result, [type.name as string]: encodeTypeDef(type) }), {}); - return JSON.stringify( + return stringify( asEnum ? { _enum: inner } : inner @@ -66,7 +66,7 @@ function encodeEnum (typeDef: TypeDef): string { // c-like enums have all Null entries // TODO We need to take the disciminant into account and auto-add empty entries return sub.every(({ type }) => type === 'Null') - ? JSON.stringify({ _enum: sub.map(({ name }, index) => `${name || `Empty${index}`}`) }) + ? stringify({ _enum: sub.map(({ name }, index) => `${name || `Empty${index}`}`) }) : encodeSubTypes(sub, true); } @@ -121,13 +121,13 @@ const encoders: Record string> = { function encodeType (typeDef: TypeDef): string { const encoder = encoders[typeDef.info]; - assert(encoder, `Cannot encode type: ${JSON.stringify(typeDef)}`); + assert(encoder, () => `Cannot encode type: ${stringify(typeDef)}`); return encoder(typeDef); } export function encodeTypeDef (typeDef: TypeDef): string { - assert(!isUndefined(typeDef.info), `Invalid type definition with no instance info, ${JSON.stringify(typeDef)}`); + assert(!isUndefined(typeDef.info), () => `Invalid type definition with no instance info, ${stringify(typeDef)}`); // In the case of contracts we do have the unfortunate situation where the displayName would // refer to "Option" when it is an option. For these, string it out, only using when actually diff --git a/packages/types/src/create/getTypeDef.ts b/packages/types/src/create/getTypeDef.ts index 9bad115e8a..573d6cf249 100644 --- a/packages/types/src/create/getTypeDef.ts +++ b/packages/types/src/create/getTypeDef.ts @@ -110,7 +110,7 @@ function _decodeFixedVec (value: TypeDef, type: string, _: string, count: number const length = parseInt(strLength.trim(), 10); // as a first round, only u8 via u8aFixed, we can add more support - assert(length <= 256, `${type}: Only support for [Type; ], where length <= 256`); + assert(length <= 256, () => `${type}: Only support for [Type; ], where length <= 256`); value.displayName = displayName; value.length = length; @@ -137,7 +137,7 @@ function _decodeAnyInt (value: TypeDef, type: string, _: string, clazz: 'Int' | const length = parseInt(strLength.trim(), 10); // as a first round, only u8 via u8aFixed, we can add more support - assert(length <= 8192 && (length % 8) === 0, `${type}: Only support for ${clazz}, where length <= 8192 and a power of 8, found ${length}`); + assert(length <= 8192 && (length % 8) === 0, () => `${type}: Only support for ${clazz}, where length <= 8192 and a power of 8, found ${length}`); value.displayName = displayName; value.length = length; diff --git a/packages/types/src/create/registry.ts b/packages/types/src/create/registry.ts index 807a387e2c..a23666c0c7 100644 --- a/packages/types/src/create/registry.ts +++ b/packages/types/src/create/registry.ts @@ -10,7 +10,7 @@ import type { CallFunction, Codec, CodecHasher, Constructor, InterfaceTypes, Reg // we are attempting to avoid circular refs, hence the Metadata path import import { decorateConstants, decorateExtrinsics } from '@polkadot/metadata/decorate'; import { Metadata } from '@polkadot/metadata/Metadata'; -import { assert, assertReturn, BN_ZERO, formatBalance, isFunction, isString, isU8a, logger, stringCamelCase, u8aToHex } from '@polkadot/util'; +import { assert, assertReturn, BN_ZERO, formatBalance, isFunction, isString, isU8a, logger, stringCamelCase, stringify, u8aToHex } from '@polkadot/util'; import { blake2AsU8a } from '@polkadot/util-crypto'; import { Json } from '../codec/Json'; @@ -340,8 +340,8 @@ export class TypeRegistry implements Registry { if (isFunction(arg1)) { this.#classes.set(arg1.name, arg1); } else if (isString(arg1)) { - assert(isFunction(arg2), `Expected class definition passed to '${arg1}' registration`); - assert(arg1 !== arg2.toString(), `Unable to register circular ${arg1} === ${arg1}`); + assert(isFunction(arg2), () => `Expected class definition passed to '${arg1}' registration`); + assert(arg1 !== arg2.toString(), () => `Unable to register circular ${arg1} === ${arg1}`); this.#classes.set(arg1, arg2); } else { @@ -357,9 +357,9 @@ export class TypeRegistry implements Registry { } else { const def = isString(type) ? type - : JSON.stringify(type); + : stringify(type); - assert(name !== def, `Unable to register circular ${name} === ${def}`); + assert(name !== def, () => `Unable to register circular ${name} === ${def}`); // we already have this type, remove the classes registered for it if (this.#classes.has(name)) { diff --git a/packages/types/src/create/typeSplit.ts b/packages/types/src/create/typeSplit.ts index cf2fa4730c..fdf39161be 100644 --- a/packages/types/src/create/typeSplit.ts +++ b/packages/types/src/create/typeSplit.ts @@ -42,7 +42,7 @@ export function typeSplit (type: string): string[] { } } - assert(isNotNested(cDepth, fDepth, sDepth, tDepth), `Invalid definition (missing terminators) found in ${type}`); + assert(isNotNested(cDepth, fDepth, sDepth, tDepth), () => `Invalid definition (missing terminators) found in ${type}`); // the final leg of the journey result.push(type.substr(start, type.length - start).trim()); diff --git a/packages/types/src/extrinsic/Extrinsic.ts b/packages/types/src/extrinsic/Extrinsic.ts index cf1debba9e..c69e059e79 100644 --- a/packages/types/src/extrinsic/Extrinsic.ts +++ b/packages/types/src/extrinsic/Extrinsic.ts @@ -206,7 +206,7 @@ export class GenericExtrinsic extends ExtrinsicBa const [offset, length] = compactFromU8a(value); const total = offset + length.toNumber(); - assert(total <= value.length, `Extrinsic: length less than remainder, expected at least ${total}, found ${value.length}`); + assert(total <= value.length, () => `Extrinsic: length less than remainder, expected at least ${total}, found ${value.length}`); const data = value.subarray(offset, total); diff --git a/packages/types/src/extrinsic/ExtrinsicEra.ts b/packages/types/src/extrinsic/ExtrinsicEra.ts index e866501d0c..f9a621bec0 100644 --- a/packages/types/src/extrinsic/ExtrinsicEra.ts +++ b/packages/types/src/extrinsic/ExtrinsicEra.ts @@ -246,7 +246,7 @@ export class GenericExtrinsicEra extends Enum implements IExtrinsicEra { * @description Returns the item as a [[ImmortalEra]] */ public get asImmortalEra (): ImmortalEra { - assert(this.isImmortalEra, `Cannot convert '${this.type}' via asImmortalEra`); + assert(this.isImmortalEra, () => `Cannot convert '${this.type}' via asImmortalEra`); return this.value as ImmortalEra; } @@ -255,7 +255,7 @@ export class GenericExtrinsicEra extends Enum implements IExtrinsicEra { * @description Returns the item as a [[MortalEra]] */ public get asMortalEra (): MortalEra { - assert(this.isMortalEra, `Cannot convert '${this.type}' via asMortalEra`); + assert(this.isMortalEra, () => `Cannot convert '${this.type}' via asMortalEra`); return this.value as MortalEra; } diff --git a/packages/types/src/extrinsic/v4/ExtrinsicSignature.ts b/packages/types/src/extrinsic/v4/ExtrinsicSignature.ts index f71c42ba12..3899829ed4 100644 --- a/packages/types/src/extrinsic/v4/ExtrinsicSignature.ts +++ b/packages/types/src/extrinsic/v4/ExtrinsicSignature.ts @@ -6,7 +6,7 @@ import type { Address, Balance, Call, Index } from '../../interfaces/runtime'; import type { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types'; import type { ExtrinsicSignatureOptions } from '../types'; -import { assert, isU8a, u8aConcat, u8aToHex } from '@polkadot/util'; +import { assert, isU8a, stringify, u8aConcat, u8aToHex } from '@polkadot/util'; import { Compact } from '../../codec/Compact'; import { Enum } from '../../codec/Enum'; @@ -155,7 +155,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig * @description Generate a payload and applies the signature from a keypair */ public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature { - assert(account && account.addressRaw, `Expected a valid keypair for signing, found ${JSON.stringify(account)}`); + assert(account && account.addressRaw, () => `Expected a valid keypair for signing, found ${stringify(account)}`); const signer = toAddress(this.registry, account.addressRaw); const payload = this.createPayload(method, options); @@ -168,7 +168,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig * @description Generate a payload and applies a fake signature */ public signFake (method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature { - assert(address, `Expected a valid address for signing, found ${JSON.stringify(address)}`); + assert(address, () => `Expected a valid address for signing, found ${stringify(address)}`); const signer = toAddress(this.registry, address); const payload = this.createPayload(method, options); diff --git a/packages/types/src/generic/AccountId.ts b/packages/types/src/generic/AccountId.ts index 62ae122192..d9fc8da4d3 100644 --- a/packages/types/src/generic/AccountId.ts +++ b/packages/types/src/generic/AccountId.ts @@ -35,15 +35,11 @@ export class GenericAccountId extends U8aFixed { const decoded = decodeAccountId(value); // Part of stream containing >= 32 bytes or a all empty (defaults) - assert(decoded.length >= 32 || !decoded.some((b) => b), `Invalid AccountId provided, expected 32 bytes, found ${decoded.length}`); + assert(decoded.length >= 32 || !decoded.some((b) => b), () => `Invalid AccountId provided, expected 32 bytes, found ${decoded.length}`); super(registry, decoded, 256); } - public static encode (value: Uint8Array, ss58Format?: number): string { - return encodeAddress(value, ss58Format); - } - /** * @description Compares the value of the input to see if there is a match */ @@ -69,7 +65,7 @@ export class GenericAccountId extends U8aFixed { * @description Returns the string representation of the value */ public toString (): string { - return GenericAccountId.encode(this, this.registry.chainSS58); + return encodeAddress(this, this.registry.chainSS58); } /** diff --git a/packages/types/src/generic/Call.spec.ts b/packages/types/src/generic/Call.spec.ts index f2b66d294d..32c6dc38d0 100644 --- a/packages/types/src/generic/Call.spec.ts +++ b/packages/types/src/generic/Call.spec.ts @@ -16,7 +16,7 @@ describe('Call', (): void => { it('handles decoding correctly (bare)', (): void => { expect( new Call(registry, { - args: [], + args: ['0x0000000000000000000000000000000000000000000000000000000000000000', 0, 0], callIndex: [6, 1] // balances.setBalance }).toU8a() ).toEqual( diff --git a/packages/types/src/primitive/BitVec.ts b/packages/types/src/primitive/BitVec.ts index eaabee48ef..28976d14d1 100644 --- a/packages/types/src/primitive/BitVec.ts +++ b/packages/types/src/primitive/BitVec.ts @@ -17,7 +17,7 @@ function decodeBitVecU8a (value?: Uint8Array): Uint8Array { const [offset, length] = compactFromU8a(value); const total = offset + Math.ceil(length.toNumber() / 8); - assert(total <= value.length, `BitVec: required length less than remainder, expected at least ${total}, found ${value.length}`); + assert(total <= value.length, () => `BitVec: required length less than remainder, expected at least ${total}, found ${value.length}`); return value.subarray(offset, total); } diff --git a/packages/types/src/primitive/Bytes.ts b/packages/types/src/primitive/Bytes.ts index e46660b39b..0179f6b66f 100644 --- a/packages/types/src/primitive/Bytes.ts +++ b/packages/types/src/primitive/Bytes.ts @@ -20,8 +20,8 @@ function decodeBytesU8a (value: Uint8Array): Uint8Array { const [offset, length] = compactFromU8a(value); const total = offset + length.toNumber(); - assert(length.lten(MAX_LENGTH), `Bytes length ${length.toString()} exceeds ${MAX_LENGTH}`); - assert(total <= value.length, `Bytes: required length less than remainder, expected at least ${total}, found ${value.length}`); + assert(length.lten(MAX_LENGTH), () => `Bytes length ${length.toString()} exceeds ${MAX_LENGTH}`); + assert(total <= value.length, () => `Bytes: required length less than remainder, expected at least ${total}, found ${value.length}`); return value.subarray(offset, total); } diff --git a/packages/types/src/primitive/Text.ts b/packages/types/src/primitive/Text.ts index 9f0267b489..3810fd5c1c 100644 --- a/packages/types/src/primitive/Text.ts +++ b/packages/types/src/primitive/Text.ts @@ -28,8 +28,8 @@ function decodeText (value?: null | Text | string | AnyU8a | { toString: () => s const [offset, length] = compactFromU8a(value); const total = offset + length.toNumber(); - assert(length.lten(MAX_LENGTH), `Text length ${length.toString()} exceeds ${MAX_LENGTH}`); - assert(total <= value.length, `Text: required length less than remainder, expected at least ${total}, found ${value.length}`); + assert(length.lten(MAX_LENGTH), () => `Text length ${length.toString()} exceeds ${MAX_LENGTH}`); + assert(total <= value.length, () => `Text: required length less than remainder, expected at least ${total}, found ${value.length}`); return u8aToString(value.subarray(offset, total)); } diff --git a/yarn.lock b/yarn.lock index 112c409d38..2c05584b63 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1307,7 +1307,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.13.17, @babel/runtime@npm:^7.13.9, @babel/runtime@npm:^7.8.4": +"@babel/runtime@npm:^7.13.17, @babel/runtime@npm:^7.13.9, @babel/runtime@npm:^7.8.4": version: 7.13.17 resolution: "@babel/runtime@npm:7.13.17" dependencies: @@ -1790,8 +1790,8 @@ __metadata: "@babel/runtime": ^7.13.17 "@polkadot/api": 4.6.3-7 "@polkadot/types": 4.6.3-7 - "@polkadot/util": ^6.2.1 - "@polkadot/x-rxjs": ^6.2.1 + "@polkadot/util": ^6.2.2-7 + "@polkadot/x-rxjs": ^6.2.2-7 bn.js: ^4.11.9 languageName: unknown linkType: soft @@ -1802,13 +1802,13 @@ __metadata: dependencies: "@babel/runtime": ^7.13.17 "@polkadot/api": 4.6.3-7 - "@polkadot/keyring": ^6.2.1 + "@polkadot/keyring": ^6.2.2-7 "@polkadot/rpc-core": 4.6.3-7 "@polkadot/rpc-provider": 4.6.3-7 "@polkadot/types": 4.6.3-7 - "@polkadot/util": ^6.2.1 - "@polkadot/util-crypto": ^6.2.1 - "@polkadot/x-rxjs": ^6.2.1 + "@polkadot/util": ^6.2.2-7 + "@polkadot/util-crypto": ^6.2.2-7 + "@polkadot/x-rxjs": ^6.2.2-7 bn.js: ^4.11.9 languageName: unknown linkType: soft @@ -1819,15 +1819,15 @@ __metadata: dependencies: "@babel/runtime": ^7.13.17 "@polkadot/api-derive": 4.6.3-7 - "@polkadot/keyring": ^6.2.1 + "@polkadot/keyring": ^6.2.2-7 "@polkadot/metadata": 4.6.3-7 "@polkadot/rpc-core": 4.6.3-7 "@polkadot/rpc-provider": 4.6.3-7 "@polkadot/types": 4.6.3-7 "@polkadot/types-known": 4.6.3-7 - "@polkadot/util": ^6.2.1 - "@polkadot/util-crypto": ^6.2.1 - "@polkadot/x-rxjs": ^6.2.1 + "@polkadot/util": ^6.2.2-7 + "@polkadot/util-crypto": ^6.2.2-7 + "@polkadot/x-rxjs": ^6.2.2-7 bn.js: ^4.11.9 eventemitter3: ^4.0.7 languageName: unknown @@ -1919,17 +1919,17 @@ __metadata: languageName: node linkType: hard -"@polkadot/keyring@npm:^6.2.1": - version: 6.2.1 - resolution: "@polkadot/keyring@npm:6.2.1" +"@polkadot/keyring@npm:^6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/keyring@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - "@polkadot/util": 6.2.1 - "@polkadot/util-crypto": 6.2.1 + "@babel/runtime": ^7.13.17 + "@polkadot/util": 6.2.2-7 + "@polkadot/util-crypto": 6.2.2-7 peerDependencies: - "@polkadot/util": 6.2.1 - "@polkadot/util-crypto": 6.2.1 - checksum: 638019fb75d3571902a670ed30c1ff47bd1fb5eec5320a78f7900efac1d7f629e6fe92cd66be60658a2afd07dc21e0387fc3b30314b21dde425481e0a3781717 + "@polkadot/util": 6.2.2-7 + "@polkadot/util-crypto": 6.2.2-7 + checksum: fd71ae92ee212d2d1b7555f9b7bb5f86ce79399d2a1d643e513291075215c32e317c6773814e057f533c1bcd7ede9c9092dbcd62e8e6a1f8613f4cf84615f8b9 languageName: node linkType: hard @@ -1938,21 +1938,21 @@ __metadata: resolution: "@polkadot/metadata@workspace:packages/metadata" dependencies: "@babel/runtime": ^7.13.17 - "@polkadot/keyring": ^6.2.1 + "@polkadot/keyring": ^6.2.2-7 "@polkadot/types": 4.6.3-7 "@polkadot/types-known": 4.6.3-7 - "@polkadot/util": ^6.2.1 - "@polkadot/util-crypto": ^6.2.1 + "@polkadot/util": ^6.2.2-7 + "@polkadot/util-crypto": ^6.2.2-7 bn.js: ^4.11.9 languageName: unknown linkType: soft -"@polkadot/networks@npm:6.2.1, @polkadot/networks@npm:^6.2.1": - version: 6.2.1 - resolution: "@polkadot/networks@npm:6.2.1" +"@polkadot/networks@npm:6.2.2-7, @polkadot/networks@npm:^6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/networks@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - checksum: 680f9d18e92e7c6fee0480fa7fbc10f3232a488c47535053227ed20efbe575bc39ef3f122665561328aed3d66993fadb68629fc4e9880fdcb62e841354365d82 + "@babel/runtime": ^7.13.17 + checksum: 0d53e754a985fc00bef845335476b59ed6c5a38e51ec7b67995154549204aa40e53bc97b5335f6cf050144cc132a6b6e35fd0f86e965dee0e1b5a48dafe1cf21 languageName: node linkType: hard @@ -1961,12 +1961,12 @@ __metadata: resolution: "@polkadot/rpc-core@workspace:packages/rpc-core" dependencies: "@babel/runtime": ^7.13.17 - "@polkadot/keyring": ^6.2.1 + "@polkadot/keyring": ^6.2.2-7 "@polkadot/metadata": 4.6.3-7 "@polkadot/rpc-provider": 4.6.3-7 "@polkadot/types": 4.6.3-7 - "@polkadot/util": ^6.2.1 - "@polkadot/x-rxjs": ^6.2.1 + "@polkadot/util": ^6.2.2-7 + "@polkadot/x-rxjs": ^6.2.2-7 languageName: unknown linkType: soft @@ -1975,14 +1975,14 @@ __metadata: resolution: "@polkadot/rpc-provider@workspace:packages/rpc-provider" dependencies: "@babel/runtime": ^7.13.17 - "@polkadot/keyring": ^6.2.1 + "@polkadot/keyring": ^6.2.2-7 "@polkadot/metadata": 4.6.3-7 "@polkadot/types": 4.6.3-7 - "@polkadot/util": ^6.2.1 - "@polkadot/util-crypto": ^6.2.1 - "@polkadot/x-fetch": ^6.2.1 - "@polkadot/x-global": ^6.2.1 - "@polkadot/x-ws": ^6.2.1 + "@polkadot/util": ^6.2.2-7 + "@polkadot/util-crypto": ^6.2.2-7 + "@polkadot/x-fetch": ^6.2.2-7 + "@polkadot/x-global": ^6.2.2-7 + "@polkadot/x-ws": ^6.2.2-7 bn.js: ^4.11.9 eventemitter3: ^4.0.7 mock-socket: ^9.0.3 @@ -2010,7 +2010,7 @@ __metadata: "@polkadot/metadata": 4.6.3-7 "@polkadot/rpc-provider": 4.6.3-7 "@polkadot/types": 4.6.3-7 - "@polkadot/util": ^6.2.1 + "@polkadot/util": ^6.2.2-7 "@types/websocket": ^1.0.2 "@types/yargs": ^16.0.1 handlebars: ^4.7.7 @@ -2030,9 +2030,9 @@ __metadata: resolution: "@polkadot/types-known@workspace:packages/types-known" dependencies: "@babel/runtime": ^7.13.17 - "@polkadot/networks": ^6.2.1 + "@polkadot/networks": ^6.2.2-7 "@polkadot/types": 4.6.3-7 - "@polkadot/util": ^6.2.1 + "@polkadot/util": ^6.2.2-7 "@types/bn.js": ^4.11.6 bn.js: ^4.11.9 languageName: unknown @@ -2043,25 +2043,25 @@ __metadata: resolution: "@polkadot/types@workspace:packages/types" dependencies: "@babel/runtime": ^7.13.17 - "@polkadot/keyring": ^6.2.1 + "@polkadot/keyring": ^6.2.2-7 "@polkadot/metadata": 4.6.3-7 - "@polkadot/util": ^6.2.1 - "@polkadot/util-crypto": ^6.2.1 - "@polkadot/x-rxjs": ^6.2.1 + "@polkadot/util": ^6.2.2-7 + "@polkadot/util-crypto": ^6.2.2-7 + "@polkadot/x-rxjs": ^6.2.2-7 "@types/bn.js": ^4.11.6 bn.js: ^4.11.9 languageName: unknown linkType: soft -"@polkadot/util-crypto@npm:6.2.1, @polkadot/util-crypto@npm:^6.2.1": - version: 6.2.1 - resolution: "@polkadot/util-crypto@npm:6.2.1" +"@polkadot/util-crypto@npm:6.2.2-7, @polkadot/util-crypto@npm:^6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/util-crypto@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - "@polkadot/networks": 6.2.1 - "@polkadot/util": 6.2.1 + "@babel/runtime": ^7.13.17 + "@polkadot/networks": 6.2.2-7 + "@polkadot/util": 6.2.2-7 "@polkadot/wasm-crypto": ^4.0.2 - "@polkadot/x-randomvalues": 6.2.1 + "@polkadot/x-randomvalues": 6.2.2-7 base-x: ^3.0.8 base64-js: ^1.5.1 blakejs: ^1.1.0 @@ -2074,23 +2074,23 @@ __metadata: tweetnacl: ^1.0.3 xxhashjs: ^0.2.2 peerDependencies: - "@polkadot/util": 6.2.1 - checksum: 6b7a3e5c19081ca7255e85b66f0576a7945ec07fec9f96f0ff8738d030f48a6fece9782d915f77346d06cf040d0d1b60a94531cfb5927da2b641ca403b6652ec + "@polkadot/util": 6.2.2-7 + checksum: 7f6a63c0be70ba4508d97cdf268386bf83d0412cb26771495b4e4b92b0cb92c14c8002c7e7206dde95074c89193bd6e234e1642ce36350bd714a8d844e8f2a00 languageName: node linkType: hard -"@polkadot/util@npm:6.2.1, @polkadot/util@npm:^6.2.1": - version: 6.2.1 - resolution: "@polkadot/util@npm:6.2.1" +"@polkadot/util@npm:6.2.2-7, @polkadot/util@npm:^6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/util@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - "@polkadot/x-textdecoder": 6.2.1 - "@polkadot/x-textencoder": 6.2.1 + "@babel/runtime": ^7.13.17 + "@polkadot/x-textdecoder": 6.2.2-7 + "@polkadot/x-textencoder": 6.2.2-7 "@types/bn.js": ^4.11.6 bn.js: ^4.11.9 camelcase: ^5.3.1 ip-regex: ^4.3.0 - checksum: b4aeafe4eed161ac72a0f42deefe4fb91fcdd4f5aa497dc23f9480de976269e93708aeb18aa37e91b538a88ff60bac55a263b5d4808af4eb77a6bd7ad601c63a + checksum: aca94e6140c77765d7ed5a8b5f4b5ddb8fa4d093b6fb9f1646202d9723dcbd342d4e7bb959bbe8547f9df60fbb9d221516d570b1026f3b7fefd58aebbdb58a26 languageName: node linkType: hard @@ -2126,78 +2126,78 @@ __metadata: languageName: node linkType: hard -"@polkadot/x-fetch@npm:^6.2.1": - version: 6.2.1 - resolution: "@polkadot/x-fetch@npm:6.2.1" +"@polkadot/x-fetch@npm:^6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/x-fetch@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - "@polkadot/x-global": 6.2.1 + "@babel/runtime": ^7.13.17 + "@polkadot/x-global": 6.2.2-7 "@types/node-fetch": ^2.5.10 node-fetch: ^2.6.1 - checksum: 0ead9e1096a8904292914313adf14a1ad8113f48fc0df0c090cb43e984967d80ce35b09b8b760d37ac5aa57e41a926b48bcafc8360a4439ba46032df70a08453 + checksum: bb4a55223f03be048ec5a0042b31318e40c24da91279ce3e004f8b2ce06c7e0323ddca2f7fce15f90aca847163dc3ea8e8f440eabd8743ee9199ab28742a47fb languageName: node linkType: hard -"@polkadot/x-global@npm:6.2.1, @polkadot/x-global@npm:^6.2.1": - version: 6.2.1 - resolution: "@polkadot/x-global@npm:6.2.1" +"@polkadot/x-global@npm:6.2.2-7, @polkadot/x-global@npm:^6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/x-global@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 + "@babel/runtime": ^7.13.17 "@types/node-fetch": ^2.5.10 node-fetch: ^2.6.1 - checksum: ece93e020f9e8fb81c6315b078d7ca4e3a923a93dc90857757b2f14eed3b53243dd09c5cb56a43ca3c64cea6e71b8704788fea1f923f74a420e40fa9d520c9d5 + checksum: ed1bfdaab77730a0a45eb373a8e338a8526d6c3e56b19bb959c7a20096fd99bd21b49bd22683f208da0b72b8faa888236f45e6f3a8f1aac216b82b3e2d66c09d languageName: node linkType: hard -"@polkadot/x-randomvalues@npm:6.2.1": - version: 6.2.1 - resolution: "@polkadot/x-randomvalues@npm:6.2.1" +"@polkadot/x-randomvalues@npm:6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/x-randomvalues@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - "@polkadot/x-global": 6.2.1 - checksum: 65edcf6401eed14631bf605c035950837f6451d01f52bd65d299436900dae7271761d1018c05cd35fce4c0a7e52c9f134e0d13073e8afbe7eefa600dae035bf5 + "@babel/runtime": ^7.13.17 + "@polkadot/x-global": 6.2.2-7 + checksum: 7ebaf84105f5034921de0f1e4c24e858c5e7329282297b1b4edb2240cda263c239c6141e08760d8daea169c95ed8857d1582419f737399ef43e3cf377ef60f6f languageName: node linkType: hard -"@polkadot/x-rxjs@npm:^6.2.1": - version: 6.2.1 - resolution: "@polkadot/x-rxjs@npm:6.2.1" +"@polkadot/x-rxjs@npm:^6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/x-rxjs@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 + "@babel/runtime": ^7.13.17 rxjs: ^6.6.7 - checksum: 815672accbea5fe295f4de0bad50db5e223785ba1655bbbdf2af7b379eadb0479b4a7b1bef12757e8f58911144268f9dc47dc9c104cfd141e53f5d048ae96a66 + checksum: 64f4a0ae50a6c782420731513120d7aaa4859b4bbbd54eb4648964285a91c27cd5041a2484649c7464a5c642f2c56cdddd6ef5bd946d18f2c6ae4dfd43749f86 languageName: node linkType: hard -"@polkadot/x-textdecoder@npm:6.2.1": - version: 6.2.1 - resolution: "@polkadot/x-textdecoder@npm:6.2.1" +"@polkadot/x-textdecoder@npm:6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/x-textdecoder@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - "@polkadot/x-global": 6.2.1 - checksum: ff17e0db6d83509ede097dfcb17a662c198957edc4fb618dc024f4a46473392fbac187fa814a7819b61caa413d3a48a1d24aa794881c302d0a70cf77397b5ba8 + "@babel/runtime": ^7.13.17 + "@polkadot/x-global": 6.2.2-7 + checksum: c430069dbff27dcb0c7fa0bcbd9c837e3111c16973c4dca93dd854017979641bb8f153641a002238b91fd6ae93c47860522f047db4e8a324062092a7bafa8cfb languageName: node linkType: hard -"@polkadot/x-textencoder@npm:6.2.1": - version: 6.2.1 - resolution: "@polkadot/x-textencoder@npm:6.2.1" +"@polkadot/x-textencoder@npm:6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/x-textencoder@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - "@polkadot/x-global": 6.2.1 - checksum: 388e9c5d106199a889f2e87ebd9b447b147c699dfd98c0aad60761a697c16f0d840f7b458e5aaffaa23c73687844c6b19714eb35c0af1d20ab4d6ef21045bd2f + "@babel/runtime": ^7.13.17 + "@polkadot/x-global": 6.2.2-7 + checksum: 14895365115b61431b6f46936deaebdfe8760cbf0cb77195a6df23f303a8423b026c7817a25fce7e5066515127b5bac7d544485eba8359a66e5de30301e3ff53 languageName: node linkType: hard -"@polkadot/x-ws@npm:^6.2.1": - version: 6.2.1 - resolution: "@polkadot/x-ws@npm:6.2.1" +"@polkadot/x-ws@npm:^6.2.2-7": + version: 6.2.2-7 + resolution: "@polkadot/x-ws@npm:6.2.2-7" dependencies: - "@babel/runtime": ^7.13.10 - "@polkadot/x-global": 6.2.1 + "@babel/runtime": ^7.13.17 + "@polkadot/x-global": 6.2.2-7 "@types/websocket": ^1.0.2 websocket: ^1.0.34 - checksum: 4ccb3cbbcaf05dcb39d587091f1c7e9b425841c2ed4d75a84a0f99c0d263b7e4534f8f4224667a151ccf799eeddeb806affe6a8939dc4e51d805ce358ef22f4a + checksum: 5e086a4ebdc571dddca3e863ffba187b6d2a62473a987a92a9dc91b657879327ce44ed49fde7adaaa0bdf2d1145494f5e0edfdaf549277ffef1f4b04f2b39d41 languageName: node linkType: hard