Compare commits

...
32 Commits
Author SHA1 Message Date
Github Actions f0b984f141 [CI Skip] release/stable 7.3.1
skip-checks: true
2021-08-28 06:17:10 +00:00
Jaco 56e518fc92 7.3.1 (#1098) 2021-08-28 08:08:14 +02:00
Tore19 87a1ca96e3 Add stafi genesis hash (#1096) 2021-08-28 07:55:10 +02:00
Github Actions 8ef9e206d6 [CI Skip] release/beta 7.2.2-8
skip-checks: true
2021-08-26 09:30:40 +00:00
Jaco 1cdda7ca06 Bump deps (#1097) 2021-08-26 11:22:25 +02:00
Github Actions fa930e9f09 [CI Skip] release/beta 7.2.2-7
skip-checks: true
2021-08-26 06:54:37 +00:00
Jaco f6cc776e87 schnorrkelAgreement (#1095)
* schnorrkelAgreement

* Hex on sr25519 functions

* cleanups
2021-08-26 08:47:25 +02:00
Github Actions 3c4bfeb3e8 [CI Skip] release/beta 7.2.2-6
skip-checks: true
2021-08-26 06:03:11 +00:00
Jaco 6e49aaf1db Bump wasm (w/ sr agreement) (#1094) 2021-08-26 07:54:29 +02:00
Github Actions 852c4c0398 [CI Skip] release/beta 7.2.2-5
skip-checks: true
2021-08-25 08:03:48 +00:00
Jaco 9b03461c7e Align prefixes with upstream (#1093) 2021-08-25 09:55:16 +02:00
Github Actions 4d11a90188 [CI Skip] release/beta 7.2.2-4
skip-checks: true
2021-08-24 07:19:28 +00:00
Jaco b7666e9de9 Bump deps (#1091) 2021-08-24 09:11:33 +02:00
Github Actions 0129752206 [CI Skip] release/beta 7.2.2-3
skip-checks: true
2021-08-24 06:37:29 +00:00
pan 11fa66441d add bifrost genesis hash (#1090) 2021-08-24 08:28:40 +02:00
Eliott Teissonniere 9ed08def61 add nodle ledger specs (#1089) 2021-08-24 08:28:01 +02:00
Github Actions f1ccfad087 [CI Skip] release/beta 7.2.2-2
skip-checks: true
2021-08-21 08:33:43 +00:00
Jaco 4f9198f1f3 Bumps (#1088)
* Bumps

* Upgrade @polkadot/ts
2021-08-21 10:25:08 +02:00
Github Actions 6bd6c8340f [CI Skip] release/beta 7.2.2-1
skip-checks: true
2021-08-17 07:44:23 +00:00
Jaco 4355df9e9b Bump deps (#1087) 2021-08-17 09:35:40 +02:00
Github Actions 272fe62031 [CI Skip] release/beta 7.2.2-0
skip-checks: true
2021-08-16 06:07:50 +00:00
Jaco 5ab88bcd35 Bump deps (#1086) 2021-08-16 07:58:42 +02:00
Github Actions 4a5659a579 [CI Skip] release/stable 7.2.1
skip-checks: true
2021-08-15 08:46:10 +00:00
Jaco c4a8aa2dd7 7.2.1 (#1085)
* 7.2.1

* Update CHANGELOG.md

* u8aEmpty
2021-08-15 10:38:48 +02:00
Github Actions 2ad042e44d [CI Skip] release/beta 7.1.3-4
skip-checks: true
2021-08-13 11:56:50 +00:00
Jaco Greeff 4615fcfbde bump berry 2021-08-13 14:48:47 +03:00
Github Actions f90d84500d [CI Skip] release/beta 7.1.3-3
skip-checks: true
2021-08-13 11:02:19 +00:00
Jaco e919446341 Bump dev (#1084)
* Bump dev

* Cleanup circular dep

* CHANGELOG

* typo
2021-08-13 12:54:03 +02:00
Github Actions 8f942dcabe [CI Skip] release/beta 7.1.3-2
skip-checks: true
2021-08-12 08:09:40 +00:00
Nantian 2e4de2093c fix bigint type (#1079) 2021-08-12 10:00:58 +02:00
Github Actions 0202a1f1d4 [CI Skip] release/beta 7.1.3-1
skip-checks: true
2021-08-12 05:24:15 +00:00
Jaco Greeff 1e256fedaa pre 2021-08-12 08:16:52 +03:00
64 changed files with 1262 additions and 1091 deletions
File diff suppressed because one or more lines are too long
+631
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -10,4 +10,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
yarnPath: .yarn/releases/yarn-3.0.0-rc.2.cjs
yarnPath: .yarn/releases/yarn-3.0.1.cjs
+28
View File
@@ -1,5 +1,33 @@
# CHANGELOG
## 7.3.1 Aug 28, 2021
Contributed:
- Added Bifrost genesisHash (Thanks to https://github.com/awesomepan)
- Added Stafi genesisHash (Thanks to https://github.com/Tore19)
- Add Ledger support for Nodle (Thanks to https://github.com/ETeissonniere)
Changes:
- Add support for `schnorrkelAgreement` (as exposed by new `wasm-crypto)
- Ensure `schnorrkel*` functions allows hex inputs
- `@polkadot/wasm-crypto` 4.2.1
- Sync with upstream Substrate ss58 registry
## 7.2.1 Aug 15, 2021
Contributed:
- Always use `bigint` type to indicate instance (Thanks to https://github.com/ntduan)
Changes:
- Added `u8aEmpty` helper check, all 0 or no length
- Cleanup additional circular dependencies detected by rollup
## 7.1.2 Aug 11, 2021
Changes:
+5 -4
View File
@@ -24,10 +24,11 @@
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@polkadot/dev": "^0.62.58",
"@polkadot/ts": "^0.4.4",
"@polkadot/dev": "^0.62.62",
"@polkadot/ts": "^0.4.6",
"@types/ed2curve": "^0.2.2",
"@types/jest": "^26.0.24"
"@types/jest": "^27.0.1"
},
"version": "7.1.2"
"version": "7.3.1",
"packageManager": "yarn@3.0.1"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/hw-ledger-transports",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"repository": "github:polkadot-js/common",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -15,9 +15,9 @@
"node": ">=14.0.0"
},
"dependencies": {
"@babel/runtime": "^7.14.8",
"@babel/runtime": "^7.15.3",
"@ledgerhq/hw-transport": "^6.3.0",
"@ledgerhq/hw-transport-webhid": "^6.3.0",
"@ledgerhq/hw-transport-webhid": "^6.4.1",
"@ledgerhq/hw-transport-webusb": "^6.3.0"
},
"optionalDependencies": {
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '7.3.1' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/hw-ledger",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"repository": "github:polkadot-js/common",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -16,9 +16,9 @@
"node": ">=14.0.0"
},
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/hw-ledger-transports": "7.1.2",
"@polkadot/util": "7.1.2",
"@zondax/ledger-substrate": "^0.17.3"
"@babel/runtime": "^7.15.3",
"@polkadot/hw-ledger-transports": "7.3.1",
"@polkadot/util": "7.3.1",
"@zondax/ledger-substrate": "^0.18.0"
}
}
+2 -1
View File
@@ -4,7 +4,7 @@
import type Transport from '@ledgerhq/hw-transport';
import type { SubstrateApp } from '@zondax/ledger-substrate';
import { newCentrifugeApp, newDockApp, newEdgewareApp, newEquilibriumApp, newKusamaApp, newPolkadotApp, newPolymeshApp, newStatemineApp } from '@zondax/ledger-substrate';
import { newCentrifugeApp, newDockApp, newEdgewareApp, newEquilibriumApp, newKusamaApp, newNodleApp, newPolkadotApp, newPolymeshApp, newStatemineApp } from '@zondax/ledger-substrate';
// These match up with the keys of the knownLedger object in the @polkadot/networks/defaults.ts
export const ledgerApps: Record<string, (transport: Transport) => SubstrateApp> = {
@@ -13,6 +13,7 @@ export const ledgerApps: Record<string, (transport: Transport) => SubstrateApp>
edgeware: newEdgewareApp,
equilibrium: newEquilibriumApp,
kusama: newKusamaApp,
'nodle-chain': newNodleApp,
polkadot: newPolkadotApp,
polymesh: newPolymeshApp,
statemine: newStatemineApp
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/hw-ledger', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/hw-ledger', version: '7.3.1' };
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/keyring",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "Keyring management",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -19,12 +19,12 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/util": "7.1.2",
"@polkadot/util-crypto": "7.1.2"
"@babel/runtime": "^7.15.3",
"@polkadot/util": "7.3.1",
"@polkadot/util-crypto": "7.3.1"
},
"peerDependencies": {
"@polkadot/util": "7.1.2",
"@polkadot/util-crypto": "7.1.2"
"@polkadot/util": "7.3.1",
"@polkadot/util-crypto": "7.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/keyring', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/keyring', version: '7.3.1' };
+6 -8
View File
@@ -168,11 +168,11 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
encodePkcs8: (passphrase?: string): Uint8Array => {
return recode(passphrase);
},
encryptMessage: (message: string | Uint8Array, recipientPublicKey: string | Uint8Array, _nonce?: Uint8Array): Uint8Array => {
encryptMessage: (message: string | Uint8Array, recipientPublicKey: string | Uint8Array, nonceIn?: Uint8Array): Uint8Array => {
assert(!isLocked(secretKey), 'Cannot encrypt with a locked key pair');
assert(!['ecdsa', 'ethereum'].includes(type), 'Secp256k1 not supported yet');
const { nonce, sealed } = naclSeal(u8aToU8a(message), convertSecretKeyToCurve25519(secretKey), convertPublicKeyToCurve25519(u8aToU8a(recipientPublicKey)), _nonce);
const { nonce, sealed } = naclSeal(u8aToU8a(message), convertSecretKeyToCurve25519(secretKey), convertPublicKeyToCurve25519(u8aToU8a(recipientPublicKey)), nonceIn);
return u8aConcat(nonce, sealed);
},
@@ -207,8 +207,8 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
unlock: (passphrase?: string): void => {
return decodePkcs8(passphrase);
},
verify: (message: string | Uint8Array, signature: Uint8Array, _signerPublic: string | Uint8Array): boolean => {
return signatureVerify(message, signature, TYPE_ADDRESS[type](u8aToU8a(_signerPublic))).isValid;
verify: (message: string | Uint8Array, signature: Uint8Array, signerPublic: string | Uint8Array): boolean => {
return signatureVerify(message, signature, TYPE_ADDRESS[type](u8aToU8a(signerPublic))).isValid;
},
vrfSign: (message: string | Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array => {
assert(!isLocked(secretKey), 'Cannot sign with a locked key pair');
@@ -221,14 +221,12 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
return u8aConcat(vrfHash(proof, context, extra), proof);
},
vrfVerify: (message: string | Uint8Array, vrfResult: Uint8Array, _signerPublic: Uint8Array | string, context?: string | Uint8Array, extra?: string | Uint8Array): boolean => {
const signerPublic = TYPE_ADDRESS[type](u8aToU8a(_signerPublic));
vrfVerify: (message: string | Uint8Array, vrfResult: Uint8Array, signerPublic: Uint8Array | string, context?: string | Uint8Array, extra?: string | Uint8Array): boolean => {
if (type === 'sr25519') {
return schnorrkelVrfVerify(message, vrfResult, publicKey, context, extra);
}
const result = signatureVerify(message, u8aConcat(TYPE_PREFIX[type], vrfResult.subarray(32)), signerPublic);
const result = signatureVerify(message, u8aConcat(TYPE_PREFIX[type], vrfResult.subarray(32)), TYPE_ADDRESS[type](u8aToU8a(signerPublic)));
return result.isValid && u8aEq(vrfResult.subarray(0, 32), vrfHash(vrfResult.subarray(32), context, extra));
}
+1 -1
View File
@@ -6,8 +6,8 @@ import type { KeyringInstance, KeyringOptions } from './types';
import { hexToU8a } from '@polkadot/util';
import { KeypairType } from '@polkadot/util-crypto/types';
import { Keyring } from './keyring';
import { createPair } from './pair';
import Keyring from '.';
interface PairDef {
name?: string;
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/networks",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A list of all available Substrate networks and their applicable prefixes",
"main": "index.js",
@@ -16,10 +16,10 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/networks#readme",
"dependencies": {
"@babel/runtime": "^7.14.8"
"@babel/runtime": "^7.15.3"
},
"devDependencies": {
"@polkadot/util": "7.1.2",
"@polkadot/x-fetch": "7.1.2"
"@polkadot/util": "7.3.1",
"@polkadot/x-fetch": "7.3.1"
}
}
+10
View File
@@ -8,6 +8,9 @@ import type { KnownGenesis, KnownIcon, KnownLedger, KnownTestnet } from './types
// last. This make lookups for the current a simple genesisHash[0]
// (See Kusama as an example)
export const knownGenesis: KnownGenesis = {
bifrost: [
'0x9f28c6a68e0fc9646eff64935684f6eeeece527e37bbe1f213d22caa1d9d6bed'
],
centrifuge: [
'0x67dddf2673b69e5f875f6f25277495834398eafd67f492e09f3f3345e003d1b5'
],
@@ -37,6 +40,9 @@ export const knownGenesis: KnownGenesis = {
'0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636', // Kusama CC2
'0x3fd7b9eb6a00376e5be61f01abb429ffb0b104be05eaff4d458da48fcd425baf' // Kusama CC1
],
'nodle-chain': [
'0xa3d114c2b8d0627c1aa9b134eafcf7d05ca561fdc19fb388bb9457f81809fb23'
],
plasm: [
'0x3e86364d4b4894021cb2a0390bcf2feb5517d5292f2de2bb9404227e908b0b8b'
],
@@ -46,6 +52,9 @@ export const knownGenesis: KnownGenesis = {
polymesh: [
'0x9deeb940c92ae02111c3bd5baca89970384f4c9849f02a1b2e53e66414d30f9f'
],
stafi: [
'0x290a4149f09ea0e402c74c1c7e96ae4239588577fe78932f94f5404c68243d80'
],
statemine: [
'0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a'
],
@@ -73,6 +82,7 @@ export const knownLedger: KnownLedger = {
edgeware: 0x0000020b,
equilibrium: 0x05f5e0fd,
kusama: 0x000001b2,
'nodle-chain': 0x000003eb,
polkadot: 0x00000162,
polymesh: 0x00000253,
statemine: 0x000001b2 // common-good on Kusama, shares derivation
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/networks', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/networks', version: '7.3.1' };
+14 -5
View File
@@ -129,13 +129,13 @@ export const knownSubstrate: KnownSubstrate[] = [
website: 'https://polymath.network/'
},
{
decimals: null,
displayName: 'SubstraTEE',
network: 'substratee',
decimals: [12],
displayName: 'Integritee',
network: 'integritee',
prefix: 13,
standardAccount: '*25519',
symbols: null,
website: 'https://www.substratee.com'
symbols: ['TEER'],
website: 'https://integritee.network'
},
{
decimals: [0],
@@ -551,6 +551,15 @@ export const knownSubstrate: KnownSubstrate[] = [
symbols: ['HKO'],
website: 'https://parallel.fi/'
},
{
decimals: null,
displayName: 'Integritee Incognito',
network: 'integritee-incognito',
prefix: 113,
standardAccount: '*25519',
symbols: null,
website: 'https://integritee.network'
},
{
decimals: [18],
displayName: 'Altair',
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util-crypto",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A collection of useful crypto utilities for @polkadot",
"main": "index.js",
@@ -21,15 +21,15 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/networks": "7.1.2",
"@polkadot/util": "7.1.2",
"@polkadot/wasm-crypto": "^4.1.2",
"@polkadot/x-randomvalues": "7.1.2",
"@babel/runtime": "^7.15.3",
"@polkadot/networks": "7.3.1",
"@polkadot/util": "7.3.1",
"@polkadot/wasm-crypto": "^4.2.1",
"@polkadot/x-randomvalues": "7.3.1",
"base-x": "^3.0.8",
"base64-js": "^1.5.1",
"blakejs": "^1.1.1",
"bn.js": "^4.11.9",
"bn.js": "^4.12.0",
"create-hash": "^1.2.0",
"ed2curve": "^0.3.0",
"elliptic": "^6.5.4",
@@ -47,6 +47,6 @@
"@types/xxhashjs": "^0.2.2"
},
"peerDependencies": {
"@polkadot/util": "7.1.2"
"@polkadot/util": "7.3.1"
}
}
@@ -14,6 +14,6 @@ import { createKeyDerived } from './keyDerived';
* @description
* Creates a Substrate derived address based on the input address/publicKey and the index supplied.
*/
export function encodeDerivedAddress (who: Uint8Array | string, index: BigInt | BN | number, ss58Format?: Prefix): string {
export function encodeDerivedAddress (who: Uint8Array | string, index: bigint | BN | number, ss58Format?: Prefix): string {
return encodeAddress(createKeyDerived(decodeAddress(who), index), ss58Format);
}
@@ -13,6 +13,6 @@ import { createKeyMulti } from './keyMulti';
* @description
* Creates a Substrate multisig address based on the input address and the required threshold.
*/
export function encodeMultiAddress (who: (Uint8Array | string)[], threshold: BigInt | BN | number, ss58Format?: Prefix): string {
export function encodeMultiAddress (who: (Uint8Array | string)[], threshold: bigint | BN | number, ss58Format?: Prefix): string {
return encodeAddress(createKeyMulti(who, threshold), ss58Format);
}
@@ -10,7 +10,7 @@ import { decodeAddress } from './decode';
const PREFIX = stringToU8a('modlpy/utilisuba');
export function createKeyDerived (who: Uint8Array | string, index: BigInt | BN | number): Uint8Array {
export function createKeyDerived (who: Uint8Array | string, index: bigint | BN | number): Uint8Array {
return blake2AsU8a(
u8aConcat(
PREFIX,
+1 -1
View File
@@ -10,7 +10,7 @@ import { decodeAddress } from './decode';
const PREFIX = stringToU8a('modlpy/utilisuba');
export function createKeyMulti (who: (Uint8Array | string)[], threshold: BigInt | BN | number): Uint8Array {
export function createKeyMulti (who: (Uint8Array | string)[], threshold: bigint | BN | number): Uint8Array {
return blake2AsU8a(
u8aConcat(
PREFIX,
@@ -47,7 +47,7 @@ export class DeriveJunction {
return !this.#isHard;
}
public hard (value: number | string | BigInt | BN | Uint8Array): DeriveJunction {
public hard (value: number | string | bigint | BN | Uint8Array): DeriveJunction {
return this.soft(value).harden();
}
@@ -57,7 +57,7 @@ export class DeriveJunction {
return this;
}
public soft (value: number | string | BigInt | BN | Uint8Array): DeriveJunction {
public soft (value: number | string | bigint | BN | Uint8Array): DeriveJunction {
if (isNumber(value) || isBn(value) || isBigInt(value)) {
return this.soft(bnToHex(value, BN_OPTIONS));
} else if (isHex(value)) {
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/util-crypto', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/util-crypto', version: '7.3.1' };
@@ -0,0 +1,32 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Keypair } from '../types';
import { u8aToHex } from '@polkadot/util';
import { waitReady } from '@polkadot/wasm-crypto';
import { schnorrkelAgreement, schnorrkelKeypairFromSeed } from '.';
describe('agreement', (): void => {
let pairA: Keypair;
let pairB: Keypair;
beforeEach(async (): Promise<void> => {
await waitReady();
pairA = schnorrkelKeypairFromSeed('0x98b3d305d5a5eace562387e47e59badd4d77e3f72cabfb10a60f8a197059f0a8');
pairB = schnorrkelKeypairFromSeed('0x9732eea001851ff862d949a1699c9971f3a26edbede2ad7922cbbe9a0701f366');
});
it('matches a known agreement (both ways)', (): void => {
const TEST = '0xb03a0b198c34c16f35cae933d88b16341b4cef3e84e851f20e664c6a30527f4e';
expect(
u8aToHex(schnorrkelAgreement(pairA.secretKey, pairB.publicKey))
).toEqual(TEST);
expect(
u8aToHex(schnorrkelAgreement(pairB.secretKey, pairA.publicKey))
).toEqual(TEST);
});
});
@@ -0,0 +1,19 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { assert, u8aToU8a } from '@polkadot/util';
import { sr25519Agree } from '@polkadot/wasm-crypto';
/**
* @name schnorrkelAgreement
* @description Key agreement between other's public key and self secret key
*/
export function schnorrkelAgreement (secretKey: Uint8Array | string, publicKey: Uint8Array | string): Uint8Array {
const secretKeyU8a = u8aToU8a(secretKey);
const publicKeyU8a = u8aToU8a(publicKey);
assert(publicKeyU8a.length === 32, () => `Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
assert(secretKeyU8a.length === 64, () => `Invalid secretKey, received ${secretKeyU8a.length} bytes, expected 64`);
return sr25519Agree(publicKeyU8a, secretKeyU8a);
}
@@ -3,13 +3,14 @@
import type { Keypair } from '../types';
import { u8aToU8a } from '@polkadot/util';
import { sr25519DeriveKeypairHard } from '@polkadot/wasm-crypto';
import { schnorrkelKeypairFromU8a } from './keypair/fromU8a';
import { schnorrkelKeypairToU8a } from './keypair/toU8a';
export function schnorrkelDeriveHard (keypair: Keypair, chainCode: Uint8Array): Keypair {
export function schnorrkelDeriveHard (keypair: Keypair, chainCode: Uint8Array | string): Keypair {
return schnorrkelKeypairFromU8a(
sr25519DeriveKeypairHard(schnorrkelKeypairToU8a(keypair), chainCode)
sr25519DeriveKeypairHard(schnorrkelKeypairToU8a(keypair), u8aToU8a(chainCode))
);
}
@@ -1,8 +1,13 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { assert, u8aToU8a } from '@polkadot/util';
import { sr25519DerivePublicSoft } from '@polkadot/wasm-crypto';
export function schnorrkelDerivePublic (publicKey: Uint8Array, chainCode: Uint8Array): Uint8Array {
return sr25519DerivePublicSoft(publicKey, chainCode);
export function schnorrkelDerivePublic (publicKey: Uint8Array | string, chainCode: Uint8Array | string): Uint8Array {
const publicKeyU8a = u8aToU8a(publicKey);
assert(publicKeyU8a.length === 32, () => `Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
return sr25519DerivePublicSoft(publicKeyU8a, u8aToU8a(chainCode));
}
@@ -3,13 +3,14 @@
import type { Keypair } from '../types';
import { u8aToU8a } from '@polkadot/util';
import { sr25519DeriveKeypairSoft } from '@polkadot/wasm-crypto';
import { schnorrkelKeypairFromU8a } from './keypair/fromU8a';
import { schnorrkelKeypairToU8a } from './keypair/toU8a';
export function schnorrkelDeriveSoft (keypair: Keypair, chainCode: Uint8Array): Keypair {
export function schnorrkelDeriveSoft (keypair: Keypair, chainCode: Uint8Array | string): Keypair {
return schnorrkelKeypairFromU8a(
sr25519DeriveKeypairSoft(schnorrkelKeypairToU8a(keypair), chainCode)
sr25519DeriveKeypairSoft(schnorrkelKeypairToU8a(keypair), u8aToU8a(chainCode))
);
}
@@ -1,6 +1,7 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { schnorrkelAgreement } from './agreement';
export { schnorrkelDeriveHard } from './deriveHard';
export { schnorrkelDerivePublic } from './derivePublic';
export { schnorrkelDeriveSoft } from './deriveSoft';
@@ -3,6 +3,7 @@
import type { Keypair } from '../../types';
import { assert, u8aToU8a } from '@polkadot/util';
import { sr25519KeypairFromSeed } from '@polkadot/wasm-crypto';
import { schnorrkelKeypairFromU8a } from './fromU8a';
@@ -11,8 +12,12 @@ import { schnorrkelKeypairFromU8a } from './fromU8a';
* @name schnorrkelKeypairFromSeed
* @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
*/
export function schnorrkelKeypairFromSeed (seed: Uint8Array): Keypair {
export function schnorrkelKeypairFromSeed (seed: Uint8Array | string): Keypair {
const seedU8a = u8aToU8a(seed);
assert(seedU8a.length === 32, () => `Expected a seed matching 32 bytes, found ${seedU8a.length}`);
return schnorrkelKeypairFromU8a(
sr25519KeypairFromSeed(seed)
sr25519KeypairFromSeed(seedU8a)
);
}
@@ -3,12 +3,19 @@
import type { Keypair } from '../../types';
import { assert, u8aToU8a } from '@polkadot/util';
const SEC_LEN = 64;
const PUB_LEN = 32;
const TOT_LEN = SEC_LEN + PUB_LEN;
export function schnorrkelKeypairFromU8a (full: Uint8Array | string): Keypair {
const fullU8a = u8aToU8a(full);
assert(fullU8a.length === TOT_LEN, () => `Expected keypair with ${TOT_LEN} bytes, found ${fullU8a.length}`);
export function schnorrkelKeypairFromU8a (full: Uint8Array): Keypair {
return {
publicKey: full.slice(SEC_LEN, SEC_LEN + PUB_LEN),
secretKey: full.slice(0, SEC_LEN)
publicKey: fullU8a.slice(SEC_LEN, TOT_LEN),
secretKey: fullU8a.slice(0, SEC_LEN)
};
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A collection of useful utilities for @polkadot",
"main": "index.js",
@@ -19,12 +19,12 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/x-textdecoder": "7.1.2",
"@polkadot/x-textencoder": "7.1.2",
"@babel/runtime": "^7.15.3",
"@polkadot/x-textdecoder": "7.3.1",
"@polkadot/x-textencoder": "7.3.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9",
"camelcase": "^5.3.1",
"bn.js": "^4.12.0",
"camelcase": "^6.2.0",
"ip-regex": "^4.3.0"
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
import { BN, bnSqrt } from '.';
const TESTS: [string | number | BN | BigInt, string | number][] = [
const TESTS: [string | number | BN | bigint, string | number][] = [
[0, 0],
[1, 1],
[4, 2],
+1 -1
View File
@@ -23,7 +23,7 @@ const SQRT_MAX_SAFE_INTEGER = new BN(94906265);
* bnSqrt(new BN(16)).toString(); // => '4'
* ```
*/
export function bnSqrt <ExtToBn extends ToBn> (value: ExtToBn | BN | BigInt | string | number | null): BN {
export function bnSqrt <ExtToBn extends ToBn> (value: ExtToBn | BN | bigint | string | number | null): BN {
const n = bnToBn(value);
assert(n.gte(BN_ZERO), 'square root of negative numbers is not supported');
+2 -2
View File
@@ -11,7 +11,7 @@ import { BN } from './bn';
/**
* @name bnToBn
* @summary Creates a BN value from a BN, BigInt, string (base 10 or hex) or number input.
* @summary Creates a BN value from a BN, bigint, string (base 10 or hex) or number input.
* @description
* `null` inputs returns a `0x0` result, BN values returns the value, numbers returns a BN representation.
* @example
@@ -25,7 +25,7 @@ import { BN } from './bn';
* bnToBn(new BN(0x1234)); // => BN(0x1234)
* ```
*/
export function bnToBn <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | string | number | null): BN {
export function bnToBn <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | string | number | null): BN {
if (!value) {
return new BN(0);
} else if (isHex(value)) {
+3 -3
View File
@@ -29,9 +29,9 @@ interface Options extends ToBnOptions {
* bnToHex(new BN(0x123456)); // => '0x123456'
* ```
*/
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, options?: Options): string;
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, bitLength?: number, isLe?: boolean): string;
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, arg1: number | Options = { bitLength: -1, isLe: false, isNegative: false }, arg2?: boolean): string {
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, options?: Options): string;
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, bitLength?: number, isLe?: boolean): string;
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, arg1: number | Options = { bitLength: -1, isLe: false, isNegative: false }, arg2?: boolean): string {
if (!value) {
return ZERO_STR;
}
+3 -3
View File
@@ -40,9 +40,9 @@ function createValue (valueBn: BN, byteLength: number, { isLe, isNegative }: Opt
* bnToU8a(new BN(0x1234)); // => [0x12, 0x34]
* ```
*/
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, options?: Options): Uint8Array;
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, bitLength?: number, isLe?: boolean): Uint8Array;
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, arg1: number | Options = { bitLength: -1, isLe: true, isNegative: false }, arg2?: boolean): Uint8Array {
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, options?: Options): Uint8Array;
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, bitLength?: number, isLe?: boolean): Uint8Array;
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, arg1: number | Options = { bitLength: -1, isLe: true, isNegative: false }, arg2?: boolean): Uint8Array {
const options: Options = {
bitLength: -1,
isLe: true,
+1 -1
View File
@@ -21,7 +21,7 @@ const MAX_U32 = new BN(2).pow(new BN(32 - 2)).subn(1);
* console.log(compactToU8a(511, 32)); // Uint8Array([0b11111101, 0b00000111])
* ```
*/
export function compactToU8a (_value: BN | BigInt | number): Uint8Array {
export function compactToU8a (_value: BN | bigint | number): Uint8Array {
const value = bnToBn(_value);
if (value.lte(MAX_U8)) {
+2 -2
View File
@@ -29,7 +29,7 @@ interface Options {
}
interface BalanceFormatter {
<ExtToBn extends ToBn> (input?: number | string | BN | BigInt | ExtToBn, options?: Options, decimals?: number): string;
<ExtToBn extends ToBn> (input?: number | string | BN | bigint | ExtToBn, options?: Options, decimals?: number): string;
calcSi (text: string, decimals?: number): SiDef;
findSi (type: string): SiDef;
getDefaults (): Defaults;
@@ -44,7 +44,7 @@ let defaultDecimals = DEFAULT_DECIMALS;
let defaultUnit = DEFAULT_UNIT;
// Formats a string/number with <prefix>.<postfix><type> notation
function _formatBalance <ExtToBn extends ToBn> (input?: number | string | BN | BigInt | ExtToBn, options: Options | boolean = true, optDecimals: number = defaultDecimals): string {
function _formatBalance <ExtToBn extends ToBn> (input?: number | string | BN | bigint | ExtToBn, options: Options | boolean = true, optDecimals: number = defaultDecimals): string {
let text = bnToBn(input).toString();
if (text.length === 0 || text === '0') {
+1 -1
View File
@@ -18,7 +18,7 @@ function formatValue (elapsed: number): string {
return `${elapsed / 3600 | 0}h`;
}
export function formatElapsed <ExtToBn extends ToBn> (now?: Date | null, value?: BigInt | BN | ExtToBn | Date | number | null): string {
export function formatElapsed <ExtToBn extends ToBn> (now?: Date | null, value?: bigint | BN | ExtToBn | Date | number | null): string {
const tsNow = (now && now.getTime()) || 0;
const tsValue = value instanceof Date
? value.getTime()
+1 -1
View File
@@ -7,6 +7,6 @@ import type { ToBn } from '../types';
import { bnToBn } from '../bn/toBn';
import { formatDecimal } from './formatDecimal';
export function formatNumber <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null): string {
export function formatNumber <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null): string {
return formatDecimal(bnToBn(value).toString());
}
+1 -1
View File
@@ -15,6 +15,6 @@
* console.log('isBigInt', isBigInt(123_456n)); // => true
* ```
*/
export function isBigInt (value: unknown): value is BigInt {
export function isBigInt (value: unknown): value is bigint {
return typeof value === 'bigint';
}
+1 -1
View File
@@ -3,7 +3,7 @@
import { isU8a } from '.';
describe('isUint8Array', (): void => {
describe('isU8a', (): void => {
it('returns false on undefined values', (): void => {
expect(
isU8a()
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/util', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/util', version: '7.3.1' };
+24
View File
@@ -0,0 +1,24 @@
// Copyright 2017-2021 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { u8aEmpty } from '.';
describe('u8aEmpty', (): void => {
it('returns true on zero length', (): void => {
expect(
u8aEmpty(new Uint8Array())
).toEqual(true);
});
it('returns true on all zero values', (): void => {
expect(
u8aEmpty(new Uint8Array([0, 0, 0, 0, 0, 0]))
).toEqual(true);
});
it('returns false when value is found', (): void => {
expect(
u8aEmpty(new Uint8Array([0, 0, 0, 0, 0, 1]))
).toEqual(false);
});
});
+12
View File
@@ -0,0 +1,12 @@
// Copyright 2017-2021 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
/**
* @name u8aEmpty
* @summary Tests for a `Uint8Array` for emptyness
* @description
* 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);
}
+1
View File
@@ -7,6 +7,7 @@
export { u8aCmp } from './cmp';
export { u8aConcat } from './concat';
export { u8aEmpty } from './empty';
export { u8aEq } from './eq';
export { u8aFixLength } from './fixLength';
export { u8aSorted } from './sorted';
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-bundle",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A bundler helper",
"main": "index.js",
@@ -16,8 +16,8 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-bundle#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/util": "7.1.2",
"@babel/runtime": "^7.15.3",
"@polkadot/util": "7.3.1",
"buffer-es6": "^4.9.3"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/x-bundle', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/x-bundle', version: '7.3.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-fetch",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A cross-environment fetch replacement",
"browser": "browser.js",
@@ -18,8 +18,8 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-fetch#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/x-global": "7.1.2",
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.3.1",
"@types/node-fetch": "^2.5.12",
"node-fetch": "^2.6.1"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/x-fetch', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/x-fetch', version: '7.3.1' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-global",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A cross-environment global replacement",
"main": "index.js",
@@ -16,6 +16,6 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-global#readme",
"dependencies": {
"@babel/runtime": "^7.14.8"
"@babel/runtime": "^7.15.3"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/x-global', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/x-global', version: '7.3.1' };
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-randomvalues",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A cross-environment window.crypto.getRandomValues replacement",
"browser": "browser.js",
@@ -18,10 +18,10 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-randomvalues#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/x-global": "7.1.2"
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.3.1"
},
"devDependencies": {
"@types/react-native": "^0.64.12"
"@types/react-native": "^0.64.13"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '7.3.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-textdecoder",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A TextDecoder replacement",
"browser": "browser.js",
@@ -18,7 +18,7 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textdecoder#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/x-global": "7.1.2"
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '7.3.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-textencoder",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A TextDecoder replacement",
"browser": "browser.js",
@@ -18,7 +18,7 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textencoder#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/x-global": "7.1.2"
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.3.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/x-textencoder', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/x-textencoder', version: '7.3.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-ws",
"version": "7.1.2",
"version": "7.3.1",
"type": "module",
"description": "A cross-environment WebSocket replacement",
"browser": "browser.js",
@@ -18,8 +18,8 @@
"bugs": "https://github.com/polkadot-js/common/issues",
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-ws#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/x-global": "7.1.2",
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.3.1",
"@types/websocket": "^1.0.4",
"websocket": "^1.0.34"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/x-ws', version: '7.1.2' };
export const packageInfo = { name: '@polkadot/x-ws', version: '7.3.1' };
+356 -380
View File
File diff suppressed because it is too large Load Diff