7.7.1 (#1152)
* 7.7.1
* Extract stringify replacer
* formatting
* linting
* isUnSorted{A, B}
* Adjust
* Complexity?
* Cleanups
* Update packages/util-crypto/src/address/derive.ts
* formatBalance
* Revert formatBalance
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
# CHANGELOG
|
||||
|
||||
## master
|
||||
## 7.7.1 Oct 31, 2021
|
||||
|
||||
Contributed:
|
||||
|
||||
@@ -10,8 +10,8 @@ Changes:
|
||||
|
||||
- Add `arrayZip` to combine a key + value array into entries-like
|
||||
- Assert `chainCode` inputs to `derive*`, protecting against misuse
|
||||
- Adjust base library usage of `for` vs `reduce/map`
|
||||
- Adjust testnet detection in `@polkadot/networks`
|
||||
- Adjust base library usage of `for` vs `reduce/map`
|
||||
- Bump Ledger libraries to latest versions
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@
|
||||
"url": "https://github.com/polkadot-js/common.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
@@ -30,7 +30,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.15.8",
|
||||
"@polkadot/dev": "^0.63.10",
|
||||
"@polkadot/dev": "^0.63.18",
|
||||
"@polkadot/ts": "^0.4.12",
|
||||
"@types/ed2curve": "^0.2.2",
|
||||
"@types/jest": "^27.0.2"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/hw-ledger-transports": "7.6.2-8",
|
||||
"@polkadot/util": "7.6.2-8",
|
||||
"@polkadot/hw-ledger-transports": "7.7.0",
|
||||
"@polkadot/util": "7.7.0",
|
||||
"@zondax/ledger-substrate": "^0.18.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,15 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/util": "7.6.2-8",
|
||||
"@polkadot/util-crypto": "7.6.2-8"
|
||||
"@polkadot/util": "7.7.0",
|
||||
"@polkadot/util-crypto": "7.7.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "7.6.2-8",
|
||||
"@polkadot/util-crypto": "7.6.2-8"
|
||||
"@polkadot/util": "7.7.0",
|
||||
"@polkadot/util-crypto": "7.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ const keypairFromSeed = {
|
||||
sr25519: (seed: Uint8Array): Keypair => schnorrkelFromSeed(seed)
|
||||
};
|
||||
|
||||
function pairToPublic ({ publicKey }: KeyringPair): Uint8Array {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* # @polkadot/keyring
|
||||
*
|
||||
@@ -262,7 +266,7 @@ export class Keyring implements KeyringInstance {
|
||||
* @description Returns an array list of all the public keys associated with each of the keyring pair values that are stored in the keyring pair dictionary.
|
||||
*/
|
||||
public getPublicKeys (): Uint8Array[] {
|
||||
return this.#pairs.all().map(({ publicKey }) => publicKey);
|
||||
return this.#pairs.all().map(pairToPublic);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { EncryptedJsonEncoding, Keypair, KeypairType } from '@polkadot/util
|
||||
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta, SignOptions } from '../types';
|
||||
import type { PairInfo } from './types';
|
||||
|
||||
import { assert, u8aConcat, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { assert, u8aConcat, u8aEmpty, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a, convertPublicKeyToCurve25519, convertSecretKeyToCurve25519, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, naclKeypairFromSeed as naclFromSeed, naclOpen, naclSeal, naclSign, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, schnorrkelVrfSign, schnorrkelVrfVerify, secp256k1Compress, secp256k1Expand, secp256k1KeypairFromSeed as secp256k1FromSeed, secp256k1Sign, signatureVerify } from '@polkadot/util-crypto';
|
||||
|
||||
import { decodePair } from './decode';
|
||||
@@ -48,9 +48,8 @@ const TYPE_ADDRESS = {
|
||||
sr25519: (p: Uint8Array) => p
|
||||
};
|
||||
|
||||
// Not 100% correct, since it can be a Uint8Array, but an invalid one - just say "undefined" is anything non-valid
|
||||
function isLocked (secretKey?: Uint8Array): secretKey is undefined {
|
||||
return !secretKey || secretKey.length === 0 || secretKey.every((b) => b === 0);
|
||||
return !secretKey || u8aEmpty(secretKey);
|
||||
}
|
||||
|
||||
function vrfHash (proof: Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array {
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "7.6.2-8",
|
||||
"@polkadot/x-fetch": "7.6.2-8"
|
||||
"@polkadot/util": "7.7.0",
|
||||
"@polkadot/x-fetch": "7.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Network, SubstrateNetwork } from './types';
|
||||
import type { KnownSubstrate, Network, SubstrateNetwork } from './types';
|
||||
|
||||
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults';
|
||||
import { knownSubstrate } from './substrate';
|
||||
@@ -10,37 +10,55 @@ import { knownSubstrate } from './substrate';
|
||||
const UNSORTED = [0, 2, 42];
|
||||
const TESTNETS = ['testnet'];
|
||||
|
||||
export const allNetworks = knownSubstrate.map((o): SubstrateNetwork => {
|
||||
function toExpanded (o: KnownSubstrate): SubstrateNetwork {
|
||||
const network = o.network || '';
|
||||
const nameParts = network.replace(/_/g, '-').split('-');
|
||||
const n = o as SubstrateNetwork;
|
||||
|
||||
// ledger additions
|
||||
n.slip44 = knownLedger[network];
|
||||
n.hasLedgerSupport = !!n.slip44;
|
||||
|
||||
// general items
|
||||
n.genesisHash = knownGenesis[network] || [];
|
||||
n.icon = knownIcon[network] || 'substrate';
|
||||
|
||||
// filtering
|
||||
n.isTestnet = !!knownTestnet[network] || TESTNETS.includes(nameParts[nameParts.length - 1]);
|
||||
n.isIgnored = n.isTestnet || (!(o.standardAccount && o.decimals && o.symbols) && o.prefix !== 42);
|
||||
|
||||
return n;
|
||||
});
|
||||
}
|
||||
|
||||
function filterSelectable ({ genesisHash, prefix }: Network): boolean {
|
||||
return !!genesisHash.length || prefix === 42;
|
||||
}
|
||||
|
||||
function filterAvailable (n: SubstrateNetwork): n is Network {
|
||||
return !n.isIgnored && !!n.network;
|
||||
}
|
||||
|
||||
function sortNetworks (a: Network, b: Network): number {
|
||||
const isUnSortedA = UNSORTED.includes(a.prefix);
|
||||
const isUnSortedB = UNSORTED.includes(b.prefix);
|
||||
|
||||
return isUnSortedA === isUnSortedB
|
||||
? 0
|
||||
: isUnSortedA
|
||||
? -1
|
||||
: isUnSortedB
|
||||
? 1
|
||||
: a.displayName.localeCompare(b.displayName);
|
||||
}
|
||||
|
||||
// This is all the Substrate networks with our additional information
|
||||
export const allNetworks = knownSubstrate.map(toExpanded);
|
||||
|
||||
// The list of available/claimed prefixes
|
||||
// - no testnets
|
||||
// - we only include those where we have a standardAccount
|
||||
// - sort by name, however we keep 0, 2, 42 first in the list
|
||||
export const availableNetworks = allNetworks
|
||||
.filter((n): n is Network => !n.isIgnored && !!n.network)
|
||||
.sort((a, b) =>
|
||||
UNSORTED.includes(a.prefix) === UNSORTED.includes(b.prefix)
|
||||
? 0
|
||||
: UNSORTED.includes(a.prefix)
|
||||
? -1
|
||||
: UNSORTED.includes(b.prefix)
|
||||
? 1
|
||||
: a.displayName.localeCompare(b.displayName)
|
||||
);
|
||||
export const availableNetworks = allNetworks.filter(filterAvailable).sort(sortNetworks);
|
||||
|
||||
// A filtered list of those chains we have details about (genesisHashes)
|
||||
export const selectableNetworks = availableNetworks.filter((n) => n.genesisHash.length || n.prefix === 42);
|
||||
export const selectableNetworks = availableNetworks.filter(filterSelectable);
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/networks": "7.6.2-8",
|
||||
"@polkadot/util": "7.6.2-8",
|
||||
"@polkadot/networks": "7.7.0",
|
||||
"@polkadot/util": "7.7.0",
|
||||
"@polkadot/wasm-crypto": "^4.2.1",
|
||||
"@polkadot/x-randomvalues": "7.6.2-8",
|
||||
"@polkadot/x-randomvalues": "7.7.0",
|
||||
"base-x": "^3.0.9",
|
||||
"base64-js": "^1.5.1",
|
||||
"blakejs": "^1.1.1",
|
||||
@@ -51,6 +51,6 @@
|
||||
"@types/xxhashjs": "^0.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "7.6.2-8"
|
||||
"@polkadot/util": "7.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Network } from '@polkadot/networks/types';
|
||||
|
||||
import { availableNetworks } from '../networks';
|
||||
|
||||
function networkToPrefix ({ prefix }: Network): number {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
export const defaults = {
|
||||
allowedDecodedLengths: [1, 2, 4, 8, 32, 33],
|
||||
// publicKey has prefix + 2 checksum bytes, short only prefix + 1 checksum byte
|
||||
allowedEncodedLengths: [3, 4, 6, 10, 35, 36, 37, 38],
|
||||
allowedPrefix: availableNetworks.map(({ prefix }) => prefix),
|
||||
allowedPrefix: availableNetworks.map(networkToPrefix),
|
||||
prefix: 42
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { DeriveJunction } from '../key/DeriveJunction';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
@@ -11,6 +12,10 @@ import { schnorrkelDerivePublic } from '../schnorrkel';
|
||||
import { decodeAddress } from './decode';
|
||||
import { encodeAddress } from './encode';
|
||||
|
||||
function filterHard ({ isHard }: DeriveJunction): boolean {
|
||||
return isHard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name deriveAddress
|
||||
* @summary Creates a sr25519 derived address from the supplied and path.
|
||||
@@ -20,7 +25,7 @@ import { encodeAddress } from './encode';
|
||||
export function deriveAddress (who: HexString | Uint8Array | string, suri: string, ss58Format?: Prefix): string {
|
||||
const { path } = keyExtractPath(suri);
|
||||
|
||||
assert(path.length && !path.some((p) => p.isHard), 'Expected suri to contain a combination of non-hard paths');
|
||||
assert(path.length && !path.every(filterHard), 'Expected suri to contain a combination of non-hard paths');
|
||||
|
||||
let publicKey = decodeAddress(who);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { HexString } from '@polkadot/util/types';
|
||||
import { bnToU8a, compactToU8a, stringToU8a, u8aConcat, u8aSorted } from '@polkadot/util';
|
||||
|
||||
import { blake2AsU8a } from '../blake2/asU8a';
|
||||
import { decodeAddress } from './decode';
|
||||
import { addressToU8a } from './util';
|
||||
|
||||
const PREFIX = stringToU8a('modlpy/utilisuba');
|
||||
|
||||
@@ -16,7 +16,7 @@ export function createKeyMulti (who: (HexString | Uint8Array | string)[], thresh
|
||||
u8aConcat(
|
||||
PREFIX,
|
||||
compactToU8a(who.length),
|
||||
...u8aSorted(who.map((who) => decodeAddress(who))),
|
||||
...u8aSorted(who.map(addressToU8a)),
|
||||
bnToU8a(threshold, { bitLength: 16, isLe: true })
|
||||
)
|
||||
);
|
||||
|
||||
@@ -6,11 +6,13 @@ import type { Prefix } from './types';
|
||||
|
||||
import { u8aSorted } from '@polkadot/util';
|
||||
|
||||
import { decodeAddress } from './decode';
|
||||
import { encodeAddress } from './encode';
|
||||
import { addressToU8a } from './util';
|
||||
|
||||
export function sortAddresses (addresses: (HexString | Uint8Array | string)[], ss58Format?: Prefix): string[] {
|
||||
const u8aToAddress = (u8a: Uint8Array) => encodeAddress(u8a, ss58Format);
|
||||
|
||||
return u8aSorted(
|
||||
addresses.map((who) => decodeAddress(who))
|
||||
).map((u8a) => encodeAddress(u8a, ss58Format));
|
||||
addresses.map(addressToU8a)
|
||||
).map(u8aToAddress);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { decodeAddress } from './decode';
|
||||
|
||||
export function addressToU8a (who: string | Uint8Array): Uint8Array {
|
||||
return decodeAddress(who);
|
||||
}
|
||||
@@ -9,13 +9,11 @@ import { BASE32_ALPHABET, BITS_PER_CHAR } from './bs32';
|
||||
import { base32Validate } from './validate';
|
||||
|
||||
// Build the character lookup table:
|
||||
const LOOKUP = BASE32_ALPHABET
|
||||
.split('')
|
||||
.reduce((lookup: Record<string, number>, char: string, index: number): Record<string, number> => {
|
||||
lookup[char] = index;
|
||||
const LOOKUP = BASE32_ALPHABET.split('').reduce<Record<string, number>>((lookup, a, i) => {
|
||||
lookup[a] = i;
|
||||
|
||||
return lookup;
|
||||
}, {});
|
||||
return lookup;
|
||||
}, {});
|
||||
|
||||
/** @internal */
|
||||
function decode (output: Uint8Array, input: string, offset: number): [Uint8Array, number, number] {
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/x-textdecoder": "7.6.2-8",
|
||||
"@polkadot/x-textencoder": "7.6.2-8",
|
||||
"@polkadot/x-textdecoder": "7.7.0",
|
||||
"@polkadot/x-textencoder": "7.7.0",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.12.0",
|
||||
"camelcase": "^6.2.0",
|
||||
|
||||
@@ -9,6 +9,19 @@ import { isString } from './string';
|
||||
|
||||
const FORMAT = [9, 10, 13];
|
||||
|
||||
/** @internal */
|
||||
function getCharCode0 (s: string): number {
|
||||
return s.charCodeAt(0);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function isAsciiByte (b: number): boolean {
|
||||
return (b < 127) && (
|
||||
(b >= 32) ||
|
||||
FORMAT.includes(b)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name isAscii
|
||||
* @summary Tests if the input is printable ASCII
|
||||
@@ -18,10 +31,13 @@ const FORMAT = [9, 10, 13];
|
||||
export function isAscii (value?: U8aLike | null): boolean {
|
||||
const isStringIn = isString(value);
|
||||
|
||||
return value
|
||||
? (isStringIn && !isHex(value)
|
||||
? value.toString().split('').map((s) => s.charCodeAt(0))
|
||||
: u8aToU8a(value)
|
||||
).every((b) => (b < 127) && ((b >= 32) || FORMAT.includes(b)))
|
||||
: isStringIn;
|
||||
if (value) {
|
||||
return (
|
||||
isStringIn && !isHex(value)
|
||||
? value.toString().split('').map(getCharCode0)
|
||||
: u8aToU8a(value)
|
||||
).every(isAsciiByte);
|
||||
}
|
||||
|
||||
return isStringIn;
|
||||
}
|
||||
|
||||
@@ -17,5 +17,10 @@ interface Compact<T> {
|
||||
* @summary Tests for SCALE-Compact-like object instance.
|
||||
*/
|
||||
export function isCompact <T> (value: unknown): value is Compact<T> {
|
||||
return isFunction((value as Compact<T>).toBigInt) && isFunction((value as Compact<T>).toBn) && isFunction((value as Compact<T>).toNumber) && isFunction((value as Compact<T>).unwrap);
|
||||
return (
|
||||
isFunction((value as Compact<T>).toBigInt) &&
|
||||
isFunction((value as Compact<T>).toBn) &&
|
||||
isFunction((value as Compact<T>).toNumber) &&
|
||||
isFunction((value as Compact<T>).unwrap)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,5 +24,8 @@ interface Observable {
|
||||
* ```
|
||||
*/
|
||||
export function isObservable (value: unknown): value is Observable {
|
||||
return isObject(value) && isFunction((value as Observable).next);
|
||||
return (
|
||||
isObject(value) &&
|
||||
isFunction((value as Observable).next)
|
||||
);
|
||||
}
|
||||
|
||||
+54
-27
@@ -48,6 +48,20 @@ export function loggerFormat (value: unknown): unknown {
|
||||
return formatOther(value);
|
||||
}
|
||||
|
||||
function formatWithLength (maxLength: number): (v: unknown) => unknown {
|
||||
return (v: unknown): unknown => {
|
||||
if (maxLength <= 0) {
|
||||
return v;
|
||||
}
|
||||
|
||||
const r = `${v as string}`;
|
||||
|
||||
return r.length < maxLength
|
||||
? v
|
||||
: `${r.substr(0, maxLength)} ...`;
|
||||
};
|
||||
}
|
||||
|
||||
function apply (log: LogType, type: string, values: Logger$Data, maxSize = -1): void {
|
||||
if (values.length === 1 && isFunction(values[0])) {
|
||||
const fnResult = values[0]() as unknown;
|
||||
@@ -60,17 +74,7 @@ function apply (log: LogType, type: string, values: Logger$Data, maxSize = -1):
|
||||
type,
|
||||
...values
|
||||
.map(loggerFormat)
|
||||
.map((v) => {
|
||||
if (maxSize <= 0) {
|
||||
return v;
|
||||
}
|
||||
|
||||
const r = `${v as string}`;
|
||||
|
||||
return r.length < maxSize
|
||||
? v
|
||||
: `${r.substr(0, maxSize)} ...`;
|
||||
})
|
||||
.map(formatWithLength(maxSize))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,27 +82,50 @@ function noop (): void {
|
||||
// noop
|
||||
}
|
||||
|
||||
function isDebugOn (e: string, type: string): boolean {
|
||||
return !!e && (
|
||||
e === '*' ||
|
||||
type === e ||
|
||||
(
|
||||
e.endsWith('*') &&
|
||||
type.startsWith(e.slice(0, -1))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function isDebugOff (e: string, type: string): boolean {
|
||||
return !!e && (
|
||||
e.startsWith('-') &&
|
||||
(
|
||||
type === e.slice(1) ||
|
||||
(
|
||||
e.endsWith('*') &&
|
||||
type.startsWith(e.slice(1, -1))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function getDebugFlag (env: string[], type: string): boolean {
|
||||
let flag = false;
|
||||
|
||||
for (const e of env) {
|
||||
if (isDebugOn(e, type)) {
|
||||
flag = true;
|
||||
} else if (isDebugOff(e, type)) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
function parseEnv (type: string): [boolean, number] {
|
||||
const env = (typeof process === 'object' ? process : {}).env || {};
|
||||
const maxSize = parseInt(env.DEBUG_MAX || '-1', 10);
|
||||
|
||||
let isDebugOn = false;
|
||||
|
||||
(env.DEBUG || '')
|
||||
.toLowerCase()
|
||||
.split(',')
|
||||
.forEach((e) => {
|
||||
if (!!e && (e === '*' || type === e || (e.endsWith('*') && type.startsWith(e.slice(0, -1))))) {
|
||||
isDebugOn = true;
|
||||
}
|
||||
|
||||
if (!!e && e.startsWith('-') && (type === e.slice(1) || (e.endsWith('*') && type.startsWith(e.slice(1, -1))))) {
|
||||
isDebugOn = false;
|
||||
}
|
||||
});
|
||||
|
||||
return [
|
||||
isDebugOn,
|
||||
getDebugFlag((env.DEBUG || '').toLowerCase().split(','), type),
|
||||
isNaN(maxSize)
|
||||
? -1
|
||||
: maxSize
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
import { isBigInt } from './is/bigInt';
|
||||
|
||||
export function stringify (args: unknown, space?: string | number): string {
|
||||
return JSON.stringify(
|
||||
args,
|
||||
(_, value: unknown) =>
|
||||
isBigInt(value)
|
||||
? value.toString()
|
||||
: value,
|
||||
space
|
||||
);
|
||||
/** @internal */
|
||||
function replacer (_: unknown, v: unknown): unknown {
|
||||
return isBigInt(v)
|
||||
? v.toString()
|
||||
: v;
|
||||
}
|
||||
|
||||
export function stringify (args: unknown, space?: string | number): string {
|
||||
return JSON.stringify(args, replacer, space);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
function isByteZero (v: number): boolean {
|
||||
return !v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name u8aEmpty
|
||||
* @summary Tests for a `Uint8Array` for emptyness
|
||||
@@ -8,5 +12,5 @@
|
||||
* Checks to see if the input `Uint8Array` has zero length or contains all 0 values.
|
||||
*/
|
||||
export function u8aEmpty (value: Uint8Array): boolean {
|
||||
return value.length === 0 || value.every((v) => !v);
|
||||
return value.length === 0 || value.every(isByteZero);
|
||||
}
|
||||
|
||||
@@ -56,24 +56,24 @@ function getVersionLength (all: { version: string }[]): number {
|
||||
/** @internal */
|
||||
function flattenInfos (all: PackageJson[]): string {
|
||||
const verLength = getVersionLength(all);
|
||||
const stringify = ({ name, version }: PackageJson) =>
|
||||
`\t${version.padEnd(verLength)}\t${name}`;
|
||||
|
||||
return all
|
||||
.map(({ name, version }) => `\t${version.padEnd(verLength)}\t${name}`)
|
||||
.join('\n');
|
||||
return all.map(stringify).join('\n');
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function flattenVersions (entry: VersionPath[]): string {
|
||||
const all = entry.map((version: VersionPath | string): VersionPath =>
|
||||
const toPath = (version: VersionPath | string): VersionPath =>
|
||||
isString(version)
|
||||
? { version }
|
||||
: version
|
||||
);
|
||||
: version;
|
||||
const all = entry.map(toPath);
|
||||
const verLength = getVersionLength(all);
|
||||
const stringify = ({ path, version }: VersionPath) =>
|
||||
`\t${version.padEnd(verLength)}\t${(!path || path.length < 5) ? '<unknown>' : path}`;
|
||||
|
||||
return all
|
||||
.map(({ path, version }) => `\t${version.padEnd(verLength)}\t${(!path || path.length < 5) ? '<unknown>' : path}`)
|
||||
.join('\n');
|
||||
return all.map(stringify).join('\n');
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/util": "7.6.2-8",
|
||||
"@polkadot/util": "7.7.0",
|
||||
"buffer-es6": "^4.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/x-global": "7.6.2-8",
|
||||
"@polkadot/x-global": "7.7.0",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"node-fetch": "^2.6.5"
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4"
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/x-global": "7.6.2-8"
|
||||
"@polkadot/x-global": "7.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-native": "^0.66.1"
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/x-global": "7.6.2-8"
|
||||
"@polkadot/x-global": "7.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/x-global": "7.6.2-8"
|
||||
"@polkadot/x-global": "7.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.6.2-8",
|
||||
"version": "7.7.0",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/x-global": "7.6.2-8",
|
||||
"@polkadot/x-global": "7.7.0",
|
||||
"@types/websocket": "^1.0.4",
|
||||
"websocket": "^1.0.34"
|
||||
}
|
||||
|
||||
@@ -1918,9 +1918,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/dev@npm:^0.63.10":
|
||||
version: 0.63.10
|
||||
resolution: "@polkadot/dev@npm:0.63.10"
|
||||
"@polkadot/dev@npm:^0.63.18":
|
||||
version: 0.63.18
|
||||
resolution: "@polkadot/dev@npm:0.63.18"
|
||||
dependencies:
|
||||
"@babel/cli": ^7.15.7
|
||||
"@babel/core": ^7.15.8
|
||||
@@ -1946,10 +1946,10 @@ __metadata:
|
||||
"@rollup/plugin-inject": ^4.0.3
|
||||
"@rollup/plugin-json": ^4.1.0
|
||||
"@rollup/plugin-node-resolve": ^13.0.6
|
||||
"@rushstack/eslint-patch": ^1.0.8
|
||||
"@rushstack/eslint-patch": ^1.0.9
|
||||
"@typescript-eslint/eslint-plugin": 5.2.0
|
||||
"@typescript-eslint/parser": 5.2.0
|
||||
"@vue/component-compiler-utils": ^3.2.2
|
||||
"@vue/component-compiler-utils": ^3.3.0
|
||||
babel-jest: ^27.3.1
|
||||
babel-plugin-module-extension-resolver: ^1.0.0-rc.2
|
||||
babel-plugin-module-resolver: ^4.1.0
|
||||
@@ -2008,11 +2008,11 @@ __metadata:
|
||||
polkadot-exec-rollup: scripts/polkadot-exec-rollup.cjs
|
||||
polkadot-exec-tsc: scripts/polkadot-exec-tsc.cjs
|
||||
polkadot-exec-webpack: scripts/polkadot-exec-webpack.cjs
|
||||
checksum: a47ef588d69c35d67fb96ffc8a386de1d5c722dd9817068cc063e0d634c4e9f356e937d572eb46bfdcbd28a4e9822c9469cb6cab8ec2eda024e0053b7d31e63a
|
||||
checksum: 76c73b040bb02e9b1d7b050718e1e9b8bad4a20850b33e9597d0ccc07981e79c18f19ff3d1b4ab2827b86fe7fede8ee11f83b3ecf3518de7e294164de4b1c130
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/hw-ledger-transports@7.6.2-8, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports":
|
||||
"@polkadot/hw-ledger-transports@7.7.0, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports"
|
||||
dependencies:
|
||||
@@ -2032,8 +2032,8 @@ __metadata:
|
||||
resolution: "@polkadot/hw-ledger@workspace:packages/hw-ledger"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/hw-ledger-transports": 7.6.2-8
|
||||
"@polkadot/util": 7.6.2-8
|
||||
"@polkadot/hw-ledger-transports": 7.7.0
|
||||
"@polkadot/util": 7.7.0
|
||||
"@zondax/ledger-substrate": ^0.18.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -2043,21 +2043,21 @@ __metadata:
|
||||
resolution: "@polkadot/keyring@workspace:packages/keyring"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/util": 7.6.2-8
|
||||
"@polkadot/util-crypto": 7.6.2-8
|
||||
"@polkadot/util": 7.7.0
|
||||
"@polkadot/util-crypto": 7.7.0
|
||||
peerDependencies:
|
||||
"@polkadot/util": 7.6.2-8
|
||||
"@polkadot/util-crypto": 7.6.2-8
|
||||
"@polkadot/util": 7.7.0
|
||||
"@polkadot/util-crypto": 7.7.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/networks@7.6.2-8, @polkadot/networks@workspace:packages/networks":
|
||||
"@polkadot/networks@7.7.0, @polkadot/networks@workspace:packages/networks":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/networks@workspace:packages/networks"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/util": 7.6.2-8
|
||||
"@polkadot/x-fetch": 7.6.2-8
|
||||
"@polkadot/util": 7.7.0
|
||||
"@polkadot/x-fetch": 7.7.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -2070,15 +2070,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/util-crypto@7.6.2-8, @polkadot/util-crypto@workspace:packages/util-crypto":
|
||||
"@polkadot/util-crypto@7.7.0, @polkadot/util-crypto@workspace:packages/util-crypto":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/util-crypto@workspace:packages/util-crypto"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/networks": 7.6.2-8
|
||||
"@polkadot/util": 7.6.2-8
|
||||
"@polkadot/networks": 7.7.0
|
||||
"@polkadot/util": 7.7.0
|
||||
"@polkadot/wasm-crypto": ^4.2.1
|
||||
"@polkadot/x-randomvalues": 7.6.2-8
|
||||
"@polkadot/x-randomvalues": 7.7.0
|
||||
"@types/bn.js": ^4.11.6
|
||||
"@types/create-hash": ^1.2.2
|
||||
"@types/elliptic": ^6.4.13
|
||||
@@ -2097,17 +2097,17 @@ __metadata:
|
||||
tweetnacl: ^1.0.3
|
||||
xxhashjs: ^0.2.2
|
||||
peerDependencies:
|
||||
"@polkadot/util": 7.6.2-8
|
||||
"@polkadot/util": 7.7.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/util@7.6.2-8, @polkadot/util@workspace:packages/util":
|
||||
"@polkadot/util@7.7.0, @polkadot/util@workspace:packages/util":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/util@workspace:packages/util"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/x-textdecoder": 7.6.2-8
|
||||
"@polkadot/x-textencoder": 7.6.2-8
|
||||
"@polkadot/x-textdecoder": 7.7.0
|
||||
"@polkadot/x-textencoder": 7.7.0
|
||||
"@types/bn.js": ^4.11.6
|
||||
bn.js: ^4.12.0
|
||||
camelcase: ^6.2.0
|
||||
@@ -2152,23 +2152,23 @@ __metadata:
|
||||
resolution: "@polkadot/x-bundle@workspace:packages/x-bundle"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/util": 7.6.2-8
|
||||
"@polkadot/util": 7.7.0
|
||||
buffer-es6: ^4.9.3
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-fetch@7.6.2-8, @polkadot/x-fetch@workspace:packages/x-fetch":
|
||||
"@polkadot/x-fetch@7.7.0, @polkadot/x-fetch@workspace:packages/x-fetch":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-fetch@workspace:packages/x-fetch"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/x-global": 7.6.2-8
|
||||
"@polkadot/x-global": 7.7.0
|
||||
"@types/node-fetch": ^2.5.12
|
||||
node-fetch: ^2.6.5
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-global@7.6.2-8, @polkadot/x-global@workspace:packages/x-global":
|
||||
"@polkadot/x-global@7.7.0, @polkadot/x-global@workspace:packages/x-global":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-global@workspace:packages/x-global"
|
||||
dependencies:
|
||||
@@ -2176,31 +2176,31 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-randomvalues@7.6.2-8, @polkadot/x-randomvalues@workspace:packages/x-randomvalues":
|
||||
"@polkadot/x-randomvalues@7.7.0, @polkadot/x-randomvalues@workspace:packages/x-randomvalues":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-randomvalues@workspace:packages/x-randomvalues"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/x-global": 7.6.2-8
|
||||
"@polkadot/x-global": 7.7.0
|
||||
"@types/react-native": ^0.66.1
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-textdecoder@7.6.2-8, @polkadot/x-textdecoder@workspace:packages/x-textdecoder":
|
||||
"@polkadot/x-textdecoder@7.7.0, @polkadot/x-textdecoder@workspace:packages/x-textdecoder":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-textdecoder@workspace:packages/x-textdecoder"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/x-global": 7.6.2-8
|
||||
"@polkadot/x-global": 7.7.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/x-textencoder@7.6.2-8, @polkadot/x-textencoder@workspace:packages/x-textencoder":
|
||||
"@polkadot/x-textencoder@7.7.0, @polkadot/x-textencoder@workspace:packages/x-textencoder":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/x-textencoder@workspace:packages/x-textencoder"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/x-global": 7.6.2-8
|
||||
"@polkadot/x-global": 7.7.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -2209,7 +2209,7 @@ __metadata:
|
||||
resolution: "@polkadot/x-ws@workspace:packages/x-ws"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.15.4
|
||||
"@polkadot/x-global": 7.6.2-8
|
||||
"@polkadot/x-global": 7.7.0
|
||||
"@types/websocket": ^1.0.4
|
||||
websocket: ^1.0.34
|
||||
languageName: unknown
|
||||
@@ -2296,10 +2296,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@rushstack/eslint-patch@npm:^1.0.8":
|
||||
version: 1.0.8
|
||||
resolution: "@rushstack/eslint-patch@npm:1.0.8"
|
||||
checksum: e1c4e2d8317db712a4f24510eacb98c13fd18632eaffae0096a359ab02021ce44c35f614d489741e57f4b0f2d8b11b4b95cdc00aa57753d840d0ba512a5c609e
|
||||
"@rushstack/eslint-patch@npm:^1.0.9":
|
||||
version: 1.0.9
|
||||
resolution: "@rushstack/eslint-patch@npm:1.0.9"
|
||||
checksum: 01425d38261013955990e4e923bc57dd1ff258a09740a5cbf5645b6a61cd3c85255edd11801277c07022fabbdfdb39d1d324f6acb1bc0b1795d2a0a187b9569f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -2802,9 +2802,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@vue/component-compiler-utils@npm:^3.2.2":
|
||||
version: 3.2.2
|
||||
resolution: "@vue/component-compiler-utils@npm:3.2.2"
|
||||
"@vue/component-compiler-utils@npm:^3.3.0":
|
||||
version: 3.3.0
|
||||
resolution: "@vue/component-compiler-utils@npm:3.3.0"
|
||||
dependencies:
|
||||
consolidate: ^0.15.1
|
||||
hash-sum: ^1.0.2
|
||||
@@ -2812,13 +2812,13 @@ __metadata:
|
||||
merge-source-map: ^1.1.0
|
||||
postcss: ^7.0.36
|
||||
postcss-selector-parser: ^6.0.2
|
||||
prettier: ^1.18.2
|
||||
prettier: ^1.18.2 || ^2.0.0
|
||||
source-map: ~0.6.1
|
||||
vue-template-es2015-compiler: ^1.9.0
|
||||
dependenciesMeta:
|
||||
prettier:
|
||||
optional: true
|
||||
checksum: ae2d08b4c1907c1bdb2c35e0d67e58afd3afa053bbc5f9cdb6de8915b051124d034cd6b14808aca5c93776289dd832e5514847e4fb925571857aa237262d753a
|
||||
checksum: 70fee2289a4f54ec1be4d46136ee9b9893e31bf5622cead5be06c3dfb83449c3dbe6f8c03404625ccf302d0628ff9e2ea1debfae609d1bfe1d065d8f57c5dba8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -8642,16 +8642,7 @@ fsevents@~2.1.2:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prettier@npm:^1.18.2":
|
||||
version: 1.19.1
|
||||
resolution: "prettier@npm:1.19.1"
|
||||
bin:
|
||||
prettier: ./bin-prettier.js
|
||||
checksum: bc78219e0f8173a808f4c6c8e0a137dd8ebd4fbe013e63fe1a37a82b48612f17b8ae8e18a992adf802ee2cf7428f14f084e7c2846ca5759cf4013c6e54810e1f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prettier@npm:^2.4.1":
|
||||
"prettier@npm:^1.18.2 || ^2.0.0, prettier@npm:^2.4.1":
|
||||
version: 2.4.1
|
||||
resolution: "prettier@npm:2.4.1"
|
||||
bin:
|
||||
@@ -9192,7 +9183,7 @@ resolve@^2.0.0-next.3:
|
||||
resolution: "root-workspace-0b6124@workspace:."
|
||||
dependencies:
|
||||
"@babel/core": ^7.15.8
|
||||
"@polkadot/dev": ^0.63.10
|
||||
"@polkadot/dev": ^0.63.18
|
||||
"@polkadot/ts": ^0.4.12
|
||||
"@types/ed2curve": ^0.2.2
|
||||
"@types/jest": ^27.0.2
|
||||
|
||||
Reference in New Issue
Block a user