Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83975e9235 | ||
|
|
3adf475ef4 | ||
|
|
ccc6edebbb | ||
|
|
0d7ed7420d | ||
|
|
dbf1837b97 | ||
|
|
9ae738ac51 | ||
|
|
a4000efc43 | ||
|
|
7871a17942 | ||
|
|
5aad1d09b2 | ||
|
|
4eb5d7dfd3 | ||
|
|
0a841e8f4a | ||
|
|
53ffd0c9f0 | ||
|
|
5d3a9f2e2e | ||
|
|
9d6f38edb3 | ||
|
|
9e5e032e1d | ||
|
|
31426858c6 | ||
|
|
46b4ca0c91 | ||
|
|
f4cb68c567 | ||
|
|
ab4b234510 | ||
|
|
d5151c4f01 | ||
|
|
6df4689aa3 | ||
|
|
9727a6a9a5 | ||
|
|
7f00182fd9 | ||
|
|
261b0add27 | ||
|
|
5d6e753384 | ||
|
|
15c2e79e6e | ||
|
|
f763a66219 | ||
|
|
1061df6e4a | ||
|
|
4c121e6f50 | ||
|
|
74b3a04c4a | ||
|
|
e4488463ba | ||
|
|
c6fd67b5d5 | ||
|
|
e5dc596867 | ||
|
|
a28f8dad37 | ||
|
|
7855658bfd | ||
|
|
de14a85817 | ||
|
|
de2206bb27 | ||
|
|
451a7aecde | ||
|
|
5170194105 | ||
|
|
b2286ac06a | ||
|
|
57cc6d6d46 | ||
|
|
6e1b5901b3 | ||
|
|
203db7467f | ||
|
|
aa7d4838c7 | ||
|
|
b778f606c5 | ||
|
|
45146efce8 | ||
|
|
9229f9f295 | ||
|
|
2e1c29a5a8 | ||
|
|
79f925b589 | ||
|
|
572c2789cc | ||
|
|
913f9636ba | ||
|
|
83e5592305 | ||
|
|
b7e579f6b8 | ||
|
|
c211b811a6 | ||
|
|
4c02b25a2d | ||
|
|
28b2435019 | ||
|
|
a0e5d60a0a | ||
|
|
311eceec0d | ||
|
|
cf24dcdf22 | ||
|
|
ead3eceef4 | ||
|
|
59df9aefc4 | ||
|
|
cb97cc1786 | ||
|
|
cf18ecf193 | ||
|
|
6e6b13f29a | ||
|
|
f75a16159d | ||
|
|
b8fe6be9cc | ||
|
|
9993325679 | ||
|
|
ce8fe9f49d | ||
|
|
408a6706b1 | ||
|
|
79c7fa3b75 | ||
|
|
e9713b6c93 | ||
|
|
706a3e0cc2 | ||
|
|
b1a40516c1 | ||
|
|
7cf449074d | ||
|
|
2ce7a79263 | ||
|
|
cfa5660d54 | ||
|
|
1256f2a54a | ||
|
|
2695afa68e | ||
|
|
af71673c7b | ||
|
|
7f489e1a99 | ||
|
|
10fb33877c |
+3
-2
@@ -1,2 +1,3 @@
|
||||
5
|
||||
2.6.22.12.2
|
||||
6
|
||||
2.6.2
|
||||
2.12.2
|
||||
|
||||
+46
-7
File diff suppressed because one or more lines are too long
+46
-21
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
-55
File diff suppressed because one or more lines are too long
+55
File diff suppressed because one or more lines are too long
+1
-3
@@ -9,7 +9,5 @@ plugins:
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
||||
spec: "@yarnpkg/plugin-workspace-tools"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.3.3.cjs
|
||||
yarnPath: .yarn/releases/yarn-2.4.0.cjs
|
||||
|
||||
@@ -1,5 +1,42 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 5.2.1 Dec 27, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `arrayFlatten` to merge a series of arrays into a single
|
||||
- Add `arrayChunk` to chunk an array into multiples of defined size
|
||||
- Add `bitLength` param (allowed 256, 512) to `keccakAs{Hex, U8a}`
|
||||
- Align `@polkadot/networks` with Substrate master
|
||||
|
||||
|
||||
## 5.1.1 Dec 19, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- `detectPackage` now can take a path-retrieval callback as second argument
|
||||
- Adjust `blake2js` imports to consistently cater for esm & cjs usage
|
||||
- Explicitly mark `detectPackage` usage as having side-effects
|
||||
- Align `@polkadot/networks` with Substrate master
|
||||
- `@polkadot/wasm-crypto` 3.1.1
|
||||
|
||||
|
||||
## 5.0.1 Dec 13, 2020
|
||||
|
||||
**Important** While this package contains no external interface changes, it now compiles and ships both cjs and esm modules. This means that modern bundlers will have more information for tree-shaking available. Additionally when using Node with `.mjs` extensions, the esm version imports will be used on recent Node versions. Adding an export map, as here, may have some impacts so a major semver bump is advised. There may be (small) dragons hiding in the dark corners...
|
||||
|
||||
Changes:
|
||||
|
||||
- Build and expose both cjs and esm via exports map
|
||||
- Use `import type { ... }` form for all type imports
|
||||
- Align with Substrate master network list
|
||||
- Debug logs now don't depend on `NODE_ENV`, but rather `DEBUG=<type,type,...>` (`*` logs all)
|
||||
- Limit debug console output via `DEBUG_MAX=<number>` value, trimming when passed
|
||||
- Add `memoize` util, allowing for function memoization (as used in the API)
|
||||
- Align `@polkadot/networks` with Substrate master
|
||||
- `@polkadot/wasm-crypto` 3.0.1
|
||||
|
||||
|
||||
## 4.2.1 Nov 23, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.0.5"
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "polkadot-dev-build-ts",
|
||||
@@ -20,10 +20,10 @@
|
||||
"test:one": "polkadot-dev-run-test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.3",
|
||||
"@polkadot/dev": "^0.60.3",
|
||||
"@polkadot/ts": "^0.3.55",
|
||||
"@types/jest": "^26.0.15"
|
||||
"@babel/core": "^7.12.10",
|
||||
"@polkadot/dev": "^0.61.16",
|
||||
"@polkadot/ts": "^0.3.58",
|
||||
"@types/jest": "^26.0.19"
|
||||
},
|
||||
"version": "4.2.1"
|
||||
"version": "5.2.1"
|
||||
}
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
{
|
||||
"name": "@polkadot/keyring",
|
||||
"version": "4.2.1",
|
||||
"version": "5.2.1",
|
||||
"description": "Keyring management",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"Keyring",
|
||||
"ed25519"
|
||||
"module": "index.mjs",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
],
|
||||
"repository": "github:polkadot-js/common",
|
||||
"bugs": "https://github.com/polkadot-js/common/issues",
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/util": "4.2.1",
|
||||
"@polkadot/util-crypto": "4.2.1"
|
||||
"@polkadot/util": "5.2.1",
|
||||
"@polkadot/util-crypto": "5.2.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "4.2.1",
|
||||
"@polkadot/util-crypto": "4.2.1"
|
||||
"@polkadot/util": "5.2.1",
|
||||
"@polkadot/util-crypto": "5.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
||||
//
|
||||
// new URL(import.meta.url).pathname)
|
||||
//
|
||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
||||
// there is a complete dead end with usage thereof
|
||||
//
|
||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
||||
//
|
||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
||||
//
|
||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
detectPackage(require('./package.json'), typeof __dirname !== 'undefined' && __dirname);
|
||||
import packageInfo from './package-info.json';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
||||
|
||||
export { packageInfo };
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { hexToU8a, stringToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady, setSS58Format, encodeAddress } from '@polkadot/util-crypto';
|
||||
import { cryptoWaitReady, encodeAddress, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
import Keyring from '.';
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeypairType, Keypair } from '@polkadot/util-crypto/types';
|
||||
import { KeyringInstance, KeyringPair, KeyringPair$Json, KeyringPair$JsonEncodingTypes, KeyringPair$Meta, KeyringOptions } from './types';
|
||||
import type { Keypair, KeypairType } from '@polkadot/util-crypto/types';
|
||||
import type { KeyringInstance, KeyringOptions, KeyringPair, KeyringPair$Json, KeyringPair$JsonEncodingTypes, KeyringPair$Meta } from './types';
|
||||
|
||||
import { assert, hexToU8a, isHex, isUndefined, stringToU8a } from '@polkadot/util';
|
||||
import { base64Decode, decodeAddress, encodeAddress, keyExtractSuri, keyFromPath, naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, secp256k1KeypairFromSeed as secp256k1FromSeed, mnemonicToLegacySeed, mnemonicToMiniSecret } from '@polkadot/util-crypto';
|
||||
import { base64Decode, decodeAddress, encodeAddress, keyExtractSuri, keyFromPath, mnemonicToLegacySeed, mnemonicToMiniSecret, naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, secp256k1KeypairFromSeed as secp256k1FromSeed } from '@polkadot/util-crypto';
|
||||
|
||||
import { DEV_PHRASE } from './defaults';
|
||||
import { createPair } from './pair';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringPair$JsonEncodingTypes } from '../types';
|
||||
import { PairInfo } from './types';
|
||||
import type { KeyringPair$JsonEncodingTypes } from '../types';
|
||||
import type { PairInfo } from './types';
|
||||
|
||||
import { assert, stringToU8a, u8aFixLength } from '@polkadot/util';
|
||||
import { naclDecrypt, scryptEncode, scryptFromU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { ENCODING, NONCE_LENGTH, PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SEC_LENGTH, SEED_LENGTH, SCRYPT_LENGTH } from './defaults';
|
||||
import { ENCODING, NONCE_LENGTH, PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SCRYPT_LENGTH, SEC_LENGTH, SEED_LENGTH } from './defaults';
|
||||
|
||||
const SEED_OFFSET = PKCS8_HEADER.length;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringPair$JsonEncodingTypes } from '../types';
|
||||
import type { KeyringPair$JsonEncodingTypes } from '../types';
|
||||
|
||||
const ENCODING: KeyringPair$JsonEncodingTypes[] = ['scrypt', 'xsalsa20-poly1305'];
|
||||
const NONCE_LENGTH = 24;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createTestPairs } from '../testingPairs';
|
||||
import { PKCS8_DIVIDER, PKCS8_HEADER, NONCE_LENGTH, PUB_LENGTH, SCRYPT_LENGTH, SEC_LENGTH } from './defaults';
|
||||
import { NONCE_LENGTH, PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SCRYPT_LENGTH, SEC_LENGTH } from './defaults';
|
||||
|
||||
const PKCS8_LENGTH = PKCS8_DIVIDER.length + PKCS8_HEADER.length + PUB_LENGTH + SEC_LENGTH;
|
||||
const ENCODED_LENGTH = 16 + PKCS8_LENGTH + NONCE_LENGTH + SCRYPT_LENGTH;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { PairInfo } from './types';
|
||||
import type { PairInfo } from './types';
|
||||
|
||||
import { u8aConcat, assert } from '@polkadot/util';
|
||||
import { assert, u8aConcat } from '@polkadot/util';
|
||||
import { naclEncrypt, scryptEncode, scryptToU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { PKCS8_DIVIDER, PKCS8_HEADER } from './defaults';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { cryptoWaitReady, encodeAddress as toSS58, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady, encodeAddress as toSS58, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
import { PAIRS } from '../testing';
|
||||
import { createTestPairs } from '../testingPairs';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair, KeypairType } from '@polkadot/util-crypto/types';
|
||||
import { KeyringPair, KeyringPair$Json, KeyringPair$JsonEncodingTypes, KeyringPair$Meta, SignOptions } from '../types';
|
||||
import { PairInfo } from './types';
|
||||
import type { Keypair, KeypairType } from '@polkadot/util-crypto/types';
|
||||
import type { KeyringPair, KeyringPair$Json, KeyringPair$JsonEncodingTypes, KeyringPair$Meta, SignOptions } from '../types';
|
||||
import type { PairInfo } from './types';
|
||||
|
||||
import { assert, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, naclKeypairFromSeed as naclFromSeed, naclSign, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, secp256k1Expand, secp256k1KeypairFromSeed as secp256k1FromSeed, secp256k1Sign, secp256k1Compress, signatureVerify } from '@polkadot/util-crypto';
|
||||
import { blake2AsU8a, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, naclKeypairFromSeed as naclFromSeed, naclSign, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, secp256k1Compress, secp256k1Expand, secp256k1KeypairFromSeed as secp256k1FromSeed, secp256k1Sign, signatureVerify } from '@polkadot/util-crypto';
|
||||
|
||||
import { decodePair } from './decode';
|
||||
import { encodePair } from './encode';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '../types';
|
||||
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '../types';
|
||||
|
||||
import { encodeAddress } from '@polkadot/util-crypto';
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeypairType } from '@polkadot/util-crypto/types';
|
||||
import { KeyringPair$Json, KeyringPair$JsonEncodingTypes, KeyringPair$Meta } from '../types';
|
||||
import type { KeypairType } from '@polkadot/util-crypto/types';
|
||||
import type { KeyringPair$Json, KeyringPair$JsonEncodingTypes, KeyringPair$Meta } from '../types';
|
||||
|
||||
import { base64Encode } from '@polkadot/util-crypto';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringPairs, KeyringPair } from './types';
|
||||
import type { KeyringPair, KeyringPairs } from './types';
|
||||
|
||||
import { assert, isHex, isU8a, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringInstance, KeyringOptions } from './types';
|
||||
import type { KeyringInstance, KeyringOptions } from './types';
|
||||
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringPair, KeyringOptions } from './types';
|
||||
import type { KeyringOptions, KeyringPair } from './types';
|
||||
|
||||
import { createTestKeyring } from './testing';
|
||||
import { nobody } from './pair/nobody';
|
||||
import { createTestKeyring } from './testing';
|
||||
|
||||
export interface TestKeyringMap {
|
||||
[index: string]: KeyringPair;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from '@polkadot/util-crypto/address/types';
|
||||
import { KeypairType } from '@polkadot/util-crypto/types';
|
||||
import type { Prefix } from '@polkadot/util-crypto/address/types';
|
||||
import type { KeypairType } from '@polkadot/util-crypto/types';
|
||||
|
||||
export interface KeyringOptions {
|
||||
ss58Format?: Prefix;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
{
|
||||
"name": "@polkadot/networks",
|
||||
"version": "4.2.1",
|
||||
"version": "5.2.1",
|
||||
"description": "A list of all available Substrate networks and their applicable prefixes",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
"sideEffects": false,
|
||||
"repository": "github:polkadot-js/common",
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"ss58"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -19,7 +16,7 @@
|
||||
"@babel/runtime": "^7.12.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "4.2.1",
|
||||
"@polkadot/x-fetch": "4.2.1"
|
||||
"@polkadot/util": "5.2.1",
|
||||
"@polkadot/x-fetch": "5.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/networks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Ss58Registry } from './types';
|
||||
import type { Ss58Registry } from './types';
|
||||
|
||||
import fs from 'fs';
|
||||
import fetch from '@polkadot/x-fetch';
|
||||
|
||||
import { fetch } from '@polkadot/x-fetch';
|
||||
|
||||
import { all } from './';
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
// Once the above is published as a package, the duplication here can be removed
|
||||
|
||||
import { Network, NetworkFromSubstrate } from './types';
|
||||
import type { Network, NetworkFromSubstrate } from './types';
|
||||
|
||||
// These are known prefixes that are not sorted
|
||||
const UNSORTED = [0, 2, 42];
|
||||
@@ -270,13 +270,13 @@ const all: NetworkFromSubstrate[] = [
|
||||
website: null
|
||||
},
|
||||
{
|
||||
decimals: null,
|
||||
decimals: [12],
|
||||
displayName: 'Phala Network',
|
||||
network: 'phala',
|
||||
prefix: 30,
|
||||
standardAccount: '*25519',
|
||||
symbols: null,
|
||||
website: null
|
||||
symbols: ['PHA'],
|
||||
website: 'https://phala.network'
|
||||
},
|
||||
{
|
||||
decimals: null,
|
||||
@@ -296,6 +296,15 @@ const all: NetworkFromSubstrate[] = [
|
||||
symbols: null,
|
||||
website: null
|
||||
},
|
||||
{
|
||||
decimals: [15],
|
||||
displayName: 'Valiu Liquidity Network',
|
||||
network: 'vln',
|
||||
prefix: 35,
|
||||
standardAccount: '*25519',
|
||||
symbols: ['USDv'],
|
||||
website: 'https://valiu.com/'
|
||||
},
|
||||
{
|
||||
decimals: [18],
|
||||
displayName: 'Centrifuge Chain',
|
||||
@@ -314,6 +323,15 @@ const all: NetworkFromSubstrate[] = [
|
||||
symbols: ['NODL'],
|
||||
website: 'https://nodle.io/'
|
||||
},
|
||||
{
|
||||
decimals: [18],
|
||||
displayName: 'KILT Chain',
|
||||
network: 'kilt',
|
||||
prefix: 38,
|
||||
standardAccount: '*25519',
|
||||
symbols: ['KILT'],
|
||||
website: 'https://kilt.io/'
|
||||
},
|
||||
{
|
||||
decimals: [18],
|
||||
displayName: 'MathChain mainnet',
|
||||
@@ -332,6 +350,15 @@ const all: NetworkFromSubstrate[] = [
|
||||
symbols: ['MATH'],
|
||||
website: 'https://mathwallet.org'
|
||||
},
|
||||
{
|
||||
decimals: null,
|
||||
displayName: 'Polimec Chain',
|
||||
network: 'poli',
|
||||
prefix: 41,
|
||||
standardAccount: '*25519',
|
||||
symbols: null,
|
||||
website: 'https://polimec.io/'
|
||||
},
|
||||
{
|
||||
decimals: null,
|
||||
displayName: 'Substrate',
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/util-crypto",
|
||||
"version": "4.2.1",
|
||||
"version": "5.2.1",
|
||||
"description": "A collection of useful crypto utilities for @polkadot",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"Polkadot"
|
||||
"module": "index.mjs",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
@@ -16,10 +17,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/networks": "4.2.1",
|
||||
"@polkadot/util": "4.2.1",
|
||||
"@polkadot/wasm-crypto": "^2.0.1",
|
||||
"@polkadot/x-randomvalues": "4.2.1",
|
||||
"@polkadot/networks": "5.2.1",
|
||||
"@polkadot/util": "5.2.1",
|
||||
"@polkadot/wasm-crypto": "^3.1.1",
|
||||
"@polkadot/x-randomvalues": "5.2.1",
|
||||
"base-x": "^3.0.8",
|
||||
"blakejs": "^1.1.0",
|
||||
"bn.js": "^4.11.9",
|
||||
@@ -39,6 +40,6 @@
|
||||
"@types/xxhashjs": "^0.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "4.2.1"
|
||||
"@polkadot/util": "5.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
import { base58Decode } from '../base58/decode';
|
||||
import { checkAddressChecksum } from './checksum';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { stringToU8a, u8aToHex, hexToU8a } from '@polkadot/util';
|
||||
import { hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { TestKeyringMap, createTestPairs } from '../../../keyring/src/testingPairs';
|
||||
import { createTestPairs, TestKeyringMap } from '../../../keyring/src/testingPairs';
|
||||
import { decodeAddress } from '.';
|
||||
|
||||
describe('decodeAddress', (): void => {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L6
|
||||
|
||||
import { assert, isHex, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { base58Decode } from '../base58/decode';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { DeriveJunction } from '../key/DeriveJunction';
|
||||
import { keyExtractPath } from '../key';
|
||||
import { DeriveJunction } from '../key/DeriveJunction';
|
||||
import { schnorrkelDerivePublic } from '../schnorrkel';
|
||||
import { decodeAddress } from './decode';
|
||||
import { encodeAddress } from './encode';
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L34
|
||||
|
||||
import { assert, u8aConcat } from '@polkadot/util';
|
||||
|
||||
import { base58Encode } from '../base58/encode';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import type BN from 'bn.js';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
import { decodeAddress } from './decode';
|
||||
import { encodeAddress } from './encode';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import type BN from 'bn.js';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
import { encodeAddress } from './encode';
|
||||
import { createKeyMulti } from './keyMulti';
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
|
||||
import { addressEq } from '.';
|
||||
|
||||
describe('addressEq', (): void => {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
import type { HashType } from '../secp256k1/types';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
import { u8aConcat } from '@polkadot/util';
|
||||
|
||||
import { secp256k1Hasher } from '../secp256k1/hasher';
|
||||
import { HashType } from '../secp256k1/types';
|
||||
import { encodeAddress } from './encode';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import BN from 'bn.js';
|
||||
import type BN from 'bn.js';
|
||||
|
||||
import { bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
|
||||
import { blake2AsU8a } from '../blake2/asU8a';
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import BN from 'bn.js';
|
||||
import type BN from 'bn.js';
|
||||
|
||||
import { bnToU8a, compactToU8a, stringToU8a, u8aConcat, u8aSorted } from '@polkadot/util';
|
||||
|
||||
import { blake2AsU8a } from '../blake2/asU8a';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
import { defaults } from './defaults';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from './types';
|
||||
import type { Prefix } from './types';
|
||||
|
||||
import { u8aSorted } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import blakejs from 'blakejs';
|
||||
import js from 'blakejs';
|
||||
|
||||
import { u8aToU8a } from '@polkadot/util';
|
||||
import { blake2b, isReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
@@ -24,5 +25,5 @@ export function blake2AsU8a (data: Uint8Array | string, bitLength = 256, key: Ui
|
||||
|
||||
return isReady() && !onlyJs
|
||||
? blake2b(u8aToU8a(data), u8aToU8a(key), byteLength)
|
||||
: blakejs.blake2b(u8aToU8a(data), key, byteLength);
|
||||
: js.blake2b(u8aToU8a(data), key, byteLength);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,3 @@ export function cryptoWaitReady (): Promise<boolean> {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// start init process immediately
|
||||
cryptoWaitReady().catch((): void => {
|
||||
// shouldn't happen, logged above
|
||||
});
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
||||
//
|
||||
// new URL(import.meta.url).pathname)
|
||||
//
|
||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
||||
// there is a complete dead end with usage thereof
|
||||
//
|
||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
||||
//
|
||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
||||
//
|
||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import packageInfo from './package-info.json';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
||||
|
||||
export { packageInfo };
|
||||
@@ -2,8 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './cryptoInit';
|
||||
|
||||
export * from './crypto';
|
||||
import './detectPackage';
|
||||
|
||||
// all internal exports
|
||||
export * from './address';
|
||||
@@ -11,6 +10,7 @@ export * from './base32';
|
||||
export * from './base58';
|
||||
export * from './base64';
|
||||
export * from './blake2';
|
||||
export * from './crypto';
|
||||
export * from './ethereum';
|
||||
export * from './keccak';
|
||||
export * from './key';
|
||||
|
||||
@@ -5,17 +5,24 @@ import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { keccakAsHex } from '.';
|
||||
|
||||
const value = 'test value';
|
||||
const result = '2d07364b5c231c56ce63d49430e085ea3033c750688ba532b24029124c26ca5e';
|
||||
const BITS: (256 | 512)[] = [256, 512];
|
||||
|
||||
const value = 'test';
|
||||
const result = {
|
||||
256: '9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658',
|
||||
512: '1e2e9fc2002b002d75198b7503210c05a1baac4560916a3c6d93bcce3a50d7f00fd395bf1647b9abb8d1afcc9c76c289b0c9383ba386a956da4b38934417789e'
|
||||
};
|
||||
|
||||
describe('keccakAsHex', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await waitReady();
|
||||
});
|
||||
|
||||
it('returns a prefixed hex representation', (): void => {
|
||||
expect(
|
||||
keccakAsHex(value)
|
||||
).toEqual(`0x${result}`);
|
||||
BITS.forEach((bitLength): void => {
|
||||
it('returns a prefixed hex representation', (): void => {
|
||||
expect(
|
||||
keccakAsHex(value, bitLength)
|
||||
).toEqual(`0x${result[bitLength]}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,8 +19,8 @@ import { keccakAsU8a } from './asU8a';
|
||||
* keccakAsHex('123'); // => 0x...
|
||||
* ```
|
||||
*/
|
||||
export function keccakAsHex (value: Buffer | Uint8Array | string): string {
|
||||
export function keccakAsHex (value: Buffer | Uint8Array | string, bitLength?: 256 | 512): string {
|
||||
return u8aToHex(
|
||||
keccakAsU8a(value)
|
||||
keccakAsU8a(value, bitLength)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,37 +6,50 @@ import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { keccakAsU8a } from '.';
|
||||
|
||||
const BITS: (256 | 512)[] = [256, 512];
|
||||
|
||||
describe('keccakAsU8a', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await waitReady();
|
||||
});
|
||||
|
||||
const input = 'test value';
|
||||
const output = hexToU8a(
|
||||
'0x2d07364b5c231c56ce63d49430e085ea3033c750688ba532b24029124c26ca5e'
|
||||
);
|
||||
const output = {
|
||||
256: hexToU8a(
|
||||
'0x2d07364b5c231c56ce63d49430e085ea3033c750688ba532b24029124c26ca5e'
|
||||
),
|
||||
512: hexToU8a(
|
||||
'0xc1b50cc57f85ccd968a9d7c7a809dcebd140a548c8e0b67f3afcdd6fc14cca2b1d04187aef24ba0081b74f2ec362431e425760febe94a5607790854cafe5b197'
|
||||
)
|
||||
};
|
||||
|
||||
[false, true].forEach((onlyJs): void => {
|
||||
it(`returns an hex representation (string, onlyJs=${onlyJs.toString()})`, (): void => {
|
||||
expect(
|
||||
keccakAsU8a(input, onlyJs)
|
||||
).toEqual(output);
|
||||
BITS.forEach((bitLength): void => {
|
||||
[false, true].forEach((onlyJs): void => {
|
||||
it(`returns an hex representation (string, bitLength=${bitLength}, onlyJs=${onlyJs.toString()})`, (): void => {
|
||||
expect(
|
||||
keccakAsU8a(input, bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
[false, true].forEach((onlyJs): void => {
|
||||
it(`returns an hex representation (Buffer, onlyJs=${onlyJs.toString()})`, (): void => {
|
||||
expect(
|
||||
keccakAsU8a(Buffer.from(input), onlyJs)
|
||||
).toEqual(output);
|
||||
BITS.forEach((bitLength): void => {
|
||||
[false, true].forEach((onlyJs): void => {
|
||||
it(`returns an hex representation (Buffer, bitLength=${bitLength}, onlyJs=${onlyJs.toString()})`, (): void => {
|
||||
expect(
|
||||
keccakAsU8a(Buffer.from(input), bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
[false, true].forEach((onlyJs): void => {
|
||||
it(`returns an hex representation (Uint8Array, onlyJs=${onlyJs.toString()})`, (): void => {
|
||||
expect(
|
||||
keccakAsU8a(stringToU8a(input), onlyJs)
|
||||
).toEqual(output);
|
||||
BITS.forEach((bitLength): void => {
|
||||
[false, true].forEach((onlyJs): void => {
|
||||
it(`returns an hex representation (Uint8Array, bitLength=${bitLength}, onlyJs=${onlyJs.toString()})`, (): void => {
|
||||
expect(
|
||||
keccakAsU8a(stringToU8a(input), bitLength, onlyJs)
|
||||
).toEqual(output[bitLength]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { keccak256 as keccak256Js } from 'js-sha3';
|
||||
import js from 'js-sha3';
|
||||
|
||||
import { u8aToU8a } from '@polkadot/util';
|
||||
import { isReady, keccak256 } from '@polkadot/wasm-crypto';
|
||||
|
||||
@@ -19,10 +20,12 @@ import { isReady, keccak256 } from '@polkadot/wasm-crypto';
|
||||
* keccakAsU8a('123'); // => Uint8Array
|
||||
* ```
|
||||
*/
|
||||
export function keccakAsU8a (value: Buffer | Uint8Array | string, onlyJs = false): Uint8Array {
|
||||
return isReady() && !onlyJs
|
||||
export function keccakAsU8a (value: Buffer | Uint8Array | string, bitLength: 256 | 512 = 256, onlyJs = false): Uint8Array {
|
||||
const is256 = bitLength === 256;
|
||||
|
||||
return isReady() && is256 && !onlyJs
|
||||
? keccak256(u8aToU8a(value))
|
||||
: new Uint8Array(
|
||||
keccak256Js.update(u8aToU8a(value)).arrayBuffer()
|
||||
(is256 ? js.keccak256 : js.keccak512).update(u8aToU8a(value)).arrayBuffer()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* @summary Create Keccak256 values as hex & Uint8Array output
|
||||
* @summary Create Keccak256/512 values as hex & Uint8Array output
|
||||
*/
|
||||
|
||||
export { keccakAsHex } from './asHex';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { keyExtractPath, ExtractResult } from './extractPath';
|
||||
import { ExtractResult, keyExtractPath } from './extractPath';
|
||||
|
||||
describe('keyExtractPath', (): void => {
|
||||
it('extracts properly from soft', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { keyExtractSuri, ExtractResult } from './extractSuri';
|
||||
import { ExtractResult, keyExtractSuri } from './extractSuri';
|
||||
|
||||
describe('keyExtractSuri', (): void => {
|
||||
it('does not extract from invalid suri', (): void => {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeypairType, Keypair } from '../types';
|
||||
import type { Keypair, KeypairType } from '../types';
|
||||
|
||||
import { DeriveJunction } from './DeriveJunction';
|
||||
import { keyHdkdEcdsa } from './hdkdEcdsa';
|
||||
import { keyHdkdEd25519 } from './hdkdEd25519';
|
||||
import { keyHdkdSr25519 } from './hdkdSr25519';
|
||||
import { keyHdkdEcdsa } from './hdkdEcdsa';
|
||||
|
||||
const generators = {
|
||||
ecdsa: keyHdkdEcdsa,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../types';
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../types';
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../types';
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { schnorrkelDeriveHard } from '../schnorrkel/deriveHard';
|
||||
import { schnorrkelDeriveSoft } from '../schnorrkel/deriveSoft';
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
// - Remove setting of wordlost passing of wordlist in functions
|
||||
// - Remove mnemonicToSeed (we only use the sync variant)
|
||||
|
||||
import { sha256 } from 'hash.js';
|
||||
import hash from 'hash.js';
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { pbkdf2Encode } from '../pbkdf2';
|
||||
@@ -39,9 +40,9 @@ function bytesToBinary (bytes: number[]): string {
|
||||
function deriveChecksumBits (entropyBuffer: Uint8Array): string {
|
||||
const ENT = entropyBuffer.length * 8;
|
||||
const CS = ENT / 32;
|
||||
const hash = sha256().update(entropyBuffer).digest();
|
||||
const result = hash.sha256().update(entropyBuffer).digest();
|
||||
|
||||
return bytesToBinary(Array.from(hash)).slice(0, CS);
|
||||
return bytesToBinary(Array.from(result)).slice(0, CS);
|
||||
}
|
||||
|
||||
function salt (password?: string): string {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { cryptoWaitReady } from '..';
|
||||
import { mnemonicGenerate, WordCount } from './generate';
|
||||
import { mnemonicValidate } from './validate';
|
||||
import { cryptoWaitReady } from '..';
|
||||
|
||||
describe('mnemonicGenerate', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { mnemonicToEntropy } from './toEntropy';
|
||||
import tests from '../schnorrkel/keypair/testing';
|
||||
import { cryptoWaitReady } from '..';
|
||||
import { mnemonicToEntropy } from './toEntropy';
|
||||
|
||||
describe('mnemonicToEntropy', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { mnemonicToMiniSecret } from './toMiniSecret';
|
||||
import tests from '../schnorrkel/keypair/testing';
|
||||
import { cryptoWaitReady } from '..';
|
||||
import { mnemonicToMiniSecret } from './toMiniSecret';
|
||||
|
||||
const MNEMONIC = 'seed sock milk update focus rotate barely fade car face mechanic mercy';
|
||||
const SEED = '0x4d1ab2a57929edfd018aaa974e62ed557e3f54b4104acabedf73c8f5a1dbb029';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { mnemonicValidate } from './validate';
|
||||
import { cryptoWaitReady } from '..';
|
||||
import { mnemonicValidate } from './validate';
|
||||
|
||||
describe('mnemonicValidate', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import * as nacl from 'tweetnacl';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { naclKeypairFromRandom } from '..';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import * as nacl from 'tweetnacl';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import * as nacl from 'tweetnacl';
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import * as nacl from 'tweetnacl';
|
||||
import { isReady, ed25519KeypairFromSeed } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { ed25519KeypairFromSeed, isReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
/**
|
||||
* @name naclKeypairFromSeed
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { keyFromPath } from '../key/fromPath';
|
||||
import { keyExtractPath } from '../key';
|
||||
import { keyFromPath } from '../key/fromPath';
|
||||
import { naclBoxKeypairFromSecret, naclKeypairFromString, naclOpen, naclSeal } from '.';
|
||||
|
||||
describe('naclOpen', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { naclSeal, naclKeypairFromString, naclBoxKeypairFromSecret } from '.';
|
||||
import { naclBoxKeypairFromSecret, naclKeypairFromString, naclSeal } from '.';
|
||||
|
||||
describe('naclSeal', (): void => {
|
||||
it('seals a message', (): void => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { naclSign, naclKeypairFromSeed } from '.';
|
||||
import { naclKeypairFromSeed, naclSign } from '.';
|
||||
|
||||
describe('naclSign', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../types';
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import * as nacl from 'tweetnacl';
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
import { isReady, ed25519Sign } from '@polkadot/wasm-crypto';
|
||||
import { ed25519Sign, isReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
/**
|
||||
* @name naclSign
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { naclVerify, naclKeypairFromSeed } from '.';
|
||||
import { naclKeypairFromSeed, naclVerify } from '.';
|
||||
|
||||
describe('naclVerify', (): void => {
|
||||
let publicKey: Uint8Array;
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import * as nacl from 'tweetnacl';
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
import { isReady, ed25519Verify } from '@polkadot/wasm-crypto';
|
||||
import { ed25519Verify, isReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
/**
|
||||
* @name naclSign
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export function isReady (): boolean {
|
||||
// always false, when true it will try and use non-existent functions
|
||||
return false;
|
||||
}
|
||||
|
||||
export function waitReady (): Promise<boolean> {
|
||||
// always immediate true, our process is done
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
// Adapted from https://gist.github.com/calvinmetcalf/91e8e84dc63c75f2aa53
|
||||
|
||||
import { hmac, sha512 } from 'hash.js';
|
||||
import hash from 'hash.js';
|
||||
|
||||
import { u8aConcat } from '@polkadot/util';
|
||||
|
||||
export function pbkdf2Sync (password: Uint8Array, salt: Uint8Array, rounds: number, len = 64): Uint8Array {
|
||||
@@ -17,14 +18,14 @@ export function pbkdf2Sync (password: Uint8Array, salt: Uint8Array, rounds: numb
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
let prev = hmac(sha512, password).update(block).digest();
|
||||
let prev = hash.hmac(hash.sha512, password).update(block).digest();
|
||||
const md = prev;
|
||||
let i = 0;
|
||||
|
||||
while (++i < rounds) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
prev = hmac(sha512, password).update(prev).digest();
|
||||
prev = hash.hmac(hash.sha512, password).update(prev).digest();
|
||||
|
||||
let j = -1;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { hexToBn } from '@polkadot/util';
|
||||
|
||||
import { randomAsHex } from './asHex';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import getRandomValues from '@polkadot/x-randomvalues';
|
||||
import { getRandomValues } from '@polkadot/x-randomvalues';
|
||||
|
||||
/**
|
||||
* @name randomAsU8a
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../types';
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { sr25519DeriveKeypairHard } from '@polkadot/wasm-crypto';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../types';
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { sr25519DeriveKeypairSoft } from '@polkadot/wasm-crypto';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { sr25519KeypairFromSeed } from '@polkadot/wasm-crypto';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
const SEC_LEN = 64;
|
||||
const PUB_LEN = 32;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { u8aConcat } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../types';
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
import { sr25519Sign } from '@polkadot/wasm-crypto';
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Params } from './types';
|
||||
import type { Params } from './types';
|
||||
|
||||
import scryptsy from 'scryptsy';
|
||||
|
||||
import { bufferToU8a, u8aToBuffer, u8aToU8a } from '@polkadot/util';
|
||||
import { isReady, scrypt } from '@polkadot/wasm-crypto';
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Params } from './types';
|
||||
import type { Params } from './types';
|
||||
|
||||
import { u8aToBn, assert } from '@polkadot/util';
|
||||
import { assert, u8aToBn } from '@polkadot/util';
|
||||
|
||||
import { DEFAULT_PARAMS } from './defaults';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Params } from './types';
|
||||
import type { Params } from './types';
|
||||
|
||||
import { bnToU8a, u8aConcat } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { HashType } from './types';
|
||||
import type { HashType } from './types';
|
||||
|
||||
import { blake2AsU8a } from '../blake2';
|
||||
import { keccakAsU8a } from '../keccak';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { u8aToHex, hexToU8a } from '@polkadot/util';
|
||||
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { mnemonicToMiniSecret } from '../../mnemonic';
|
||||
import { secp256k1KeypairFromSeed } from '..';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../../types';
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { assert, bnToU8a } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ec as EC } from 'elliptic';
|
||||
import elliptic from 'elliptic';
|
||||
|
||||
const EC = elliptic.ec;
|
||||
|
||||
export const secp256k1 = new EC('secp256k1');
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keypair } from '../types';
|
||||
import { HashType } from './types';
|
||||
import type { Keypair } from '../types';
|
||||
import type { HashType } from './types';
|
||||
|
||||
import { assert, bnToU8a, u8aConcat } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { HashType } from './types';
|
||||
import type { HashType } from './types';
|
||||
|
||||
import { assert, u8aEq, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import * as nacl from 'tweetnacl';
|
||||
|
||||
import { isReady, sha512 } from '@polkadot/wasm-crypto';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeypairType, VerifyResult } from '../types';
|
||||
import type { KeypairType, VerifyResult } from '../types';
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import hasher from 'xxhashjs/lib/xxhash64';
|
||||
import xx from 'xxhashjs';
|
||||
|
||||
import { isBuffer, isString, u8aToBuffer } from '@polkadot/util';
|
||||
|
||||
export default function xxhash64AsValue (data: Buffer | Uint8Array | string, seed: number): number {
|
||||
if (isBuffer(data) || isString(data)) {
|
||||
return hasher(data, seed);
|
||||
return xx.h64(data, seed);
|
||||
}
|
||||
|
||||
return hasher(
|
||||
return xx.h64(
|
||||
u8aToBuffer(data),
|
||||
seed
|
||||
);
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
declare module 'xxhashjs/lib/xxhash64' {
|
||||
declare module 'xxhashjs' {
|
||||
export interface HashInterface {
|
||||
(data: string | Buffer, seed: number): number;
|
||||
}
|
||||
|
||||
const h64: HashInterface;
|
||||
|
||||
export = h64;
|
||||
export = { h64 };
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
{
|
||||
"name": "@polkadot/util",
|
||||
"version": "4.2.1",
|
||||
"version": "5.2.1",
|
||||
"description": "A collection of useful utilities for @polkadot",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"Polkadot"
|
||||
],
|
||||
"module": "index.mjs",
|
||||
"sideEffects": false,
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -15,8 +14,8 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/x-textdecoder": "4.2.1",
|
||||
"@polkadot/x-textencoder": "4.2.1",
|
||||
"@polkadot/x-textdecoder": "5.2.1",
|
||||
"@polkadot/x-textencoder": "5.2.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9",
|
||||
"camelcase": "^5.3.1",
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { arrayChunk } from '.';
|
||||
|
||||
describe('arrayChunk', (): void => {
|
||||
it('chunks arrays', (): void => {
|
||||
expect(
|
||||
arrayChunk([1, 2, 3, 4, 5, 6, 7], 3)
|
||||
).toEqual([[1, 2, 3], [4, 5, 6], [7]]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* @name arrayChunk
|
||||
* @summary Split T[] into T[][] based on the defind size
|
||||
* @description
|
||||
* Returns a set ao arrays based on the chunksize
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { arrayChunk } from '@polkadot/util';
|
||||
*
|
||||
* arrayChunk([1, 2, 3, 4, 5]); // [[1, 2], [3, 4], [5]]
|
||||
* ```
|
||||
*/
|
||||
export function arrayChunk <T> (array: T[], chunkSize: number): T[][] {
|
||||
const outputSize = Math.ceil(array.length / chunkSize);
|
||||
const output = Array<T[]>(outputSize);
|
||||
|
||||
for (let index = 0; index < outputSize; index++) {
|
||||
const offset = index * chunkSize;
|
||||
|
||||
output[index] = array.slice(offset, offset + chunkSize);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user