Compare commits

...
22 Commits
Author SHA1 Message Date
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
Github Actions 56a3d19083 [CI Skip] release/stable 7.1.2
skip-checks: true
2021-08-11 15:21:50 +00:00
Jaco caf76a7511 Ensure packageInfo from networks doesn't clobber crypto (#1076)
* Ensure packageInfo from networks doesn't clobber crypto

* 7.1.2

* Update CHANGELOG.md

* Extract network sorting

* ... revert, CC still not happy, maybe another day...
2021-08-11 17:14:28 +02:00
Github Actions 834a1e6a52 [CI Skip] release/beta 7.1.2-0
skip-checks: true
2021-08-10 09:23:32 +00:00
Jaco 7a5b1207b0 Minor x-bundle style cleanups (#1074) 2021-08-10 11:15:10 +02:00
Github Actions 8221576d25 [CI Skip] release/stable 7.1.1
skip-checks: true
2021-08-02 08:41:20 +00:00
Jaco 1f9d36d4db 7.1.1 (#1073) 2021-08-02 10:32:37 +02:00
Github Actions b292f2ae1d [CI Skip] release/beta 7.0.4-0
skip-checks: true
2021-08-02 04:26:52 +00:00
Song ZhouandJaco 7eddfc25c9 Add in ability to encrypt/decrypt msg with keyring (#1070)
* feat: able to encrypt & decrypt message in keyring - ed25519 & sr25519 types

* chore: make eslint happy

* test: add in one more test on cross-usage of ed25519 & sr25519

* make lint happy without eslint-disable

* assert away secp256k1 for encrypt/decrypt

* Update packages/keyring/src/pair/index.ts

* Update packages/keyring/src/pair/index.ts

Co-authored-by: Jaco <jacogr@gmail.com>
2021-08-02 06:18:58 +02:00
Github Actions c6ff77b56f [CI Skip] release/stable 7.0.3
skip-checks: true
2021-07-26 05:42:45 +00:00
Jaco 4a1f5bfbf4 7.0.3 (#1069) 2021-07-26 07:34:06 +02:00
Github Actions e8f0072e44 [CI Skip] release/beta 7.0.3-0
skip-checks: true
2021-07-23 05:26:30 +00:00
Jaco 4620a6a649 ss58 sync (#1066) 2021-07-23 07:19:24 +02:00
66 changed files with 1439 additions and 1149 deletions
+3 -1
View File
@@ -15,4 +15,6 @@
6.0.4
6.0.5
7.0.2
7.0.2
7.0.3
7.1.2
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
+39
View File
@@ -1,5 +1,44 @@
# CHANGELOG
## 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:
- Ensure `@polkadot/util-crypto` doesn't re-export `packageInfo` from `@polkadot/networks`
- Minor TS style cleanups in `@polkadot/x-bundle`
## 7.1.1 Aug 2, 2021
Contributed:
- Add keyring encrypt/decrypt functionality (Thanks to https://github.com/RoyTimes)
Changes:
- Bump Ledger libraries to latest versions
## 7.0.3 Jul 26, 2021
Changes:
- Sync with upstream Substrate ss58 registry
- Bump Ledger libraries to latest versions
## 7.0.2 Jul 19, 2021
Changes:
+5 -3
View File
@@ -23,10 +23,12 @@
"test:one": "polkadot-dev-run-test --runInBand"
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@polkadot/dev": "^0.62.57",
"@babel/core": "^7.15.0",
"@polkadot/dev": "^0.62.59",
"@polkadot/ts": "^0.4.4",
"@types/ed2curve": "^0.2.2",
"@types/jest": "^26.0.24"
},
"version": "7.0.2"
"version": "7.2.1",
"packageManager": "yarn@3.0.1"
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/hw-ledger-transports",
"version": "7.0.2",
"version": "7.2.1",
"type": "module",
"repository": "github:polkadot-js/common",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -15,12 +15,12 @@
"node": ">=14.0.0"
},
"dependencies": {
"@babel/runtime": "^7.14.6",
"@ledgerhq/hw-transport": "^6.1.0",
"@ledgerhq/hw-transport-webhid": "^6.1.0",
"@ledgerhq/hw-transport-webusb": "^6.1.0"
"@babel/runtime": "^7.15.3",
"@ledgerhq/hw-transport": "^6.3.0",
"@ledgerhq/hw-transport-webhid": "^6.4.1",
"@ledgerhq/hw-transport-webusb": "^6.3.0"
},
"optionalDependencies": {
"@ledgerhq/hw-transport-node-hid-singleton": "^6.1.0"
"@ledgerhq/hw-transport-node-hid-singleton": "^6.3.0"
}
}
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '7.0.2' };
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '7.2.1' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/hw-ledger",
"version": "7.0.2",
"version": "7.2.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.6",
"@polkadot/hw-ledger-transports": "7.0.2",
"@polkadot/util": "^7.0.2",
"@zondax/ledger-substrate": "^0.16.2"
"@babel/runtime": "^7.15.3",
"@polkadot/hw-ledger-transports": "7.2.1",
"@polkadot/util": "7.2.1",
"@zondax/ledger-substrate": "^0.17.3"
}
}
+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.0.2' };
export const packageInfo = { name: '@polkadot/hw-ledger', version: '7.2.1' };
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/keyring",
"version": "7.0.2",
"version": "7.2.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.6",
"@polkadot/util": "7.0.2",
"@polkadot/util-crypto": "7.0.2"
"@babel/runtime": "^7.15.3",
"@polkadot/util": "7.2.1",
"@polkadot/util-crypto": "7.2.1"
},
"peerDependencies": {
"@polkadot/util": "7.0.2",
"@polkadot/util-crypto": "7.0.2"
"@polkadot/util": "7.2.1",
"@polkadot/util-crypto": "7.2.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.0.2' };
export const packageInfo = { name: '@polkadot/keyring', version: '7.2.1' };
+109 -1
View File
@@ -18,6 +18,10 @@ describe('pair', (): void => {
});
const SIGNATURE = new Uint8Array([80, 191, 198, 147, 225, 207, 75, 88, 126, 39, 129, 109, 191, 38, 72, 181, 75, 254, 81, 143, 244, 79, 237, 38, 236, 141, 28, 252, 134, 26, 169, 234, 79, 33, 153, 158, 151, 34, 175, 188, 235, 20, 35, 135, 83, 120, 139, 211, 233, 130, 1, 208, 201, 215, 73, 80, 56, 98, 185, 196, 11, 8, 193, 14]);
const ENCRYPTED = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 59, 53, 85, 227, 40, 107, 48, 234, 198, 238, 157, 238, 224, 235, 179, 75, 153, 241, 142, 254]);
// the last byte is changed from 254 -> 253
const ENCRYPTED_CHANGED = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 59, 53, 85, 227, 40, 107, 48, 234, 198, 238, 157, 238, 224, 235, 179, 75, 153, 241, 142, 253]);
it('has a publicKey', (): void => {
expect(
@@ -53,7 +57,7 @@ describe('pair', (): void => {
it('fails a correctly signed message (signer changed)', (): void => {
expect(
keyring.alice.verify(
new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]),
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
SIGNATURE,
keyring.bob.publicKey
)
@@ -94,6 +98,93 @@ describe('pair', (): void => {
).toBe(false);
});
it('allows encrypting', (): void => {
const message = new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]);
expect(
keyring.alice.encryptMessage(
message,
keyring.bob.publicKey,
new Uint8Array(24)
)
).toEqual(ENCRYPTED);
});
it('validates a correctly encrypted message', (): void => {
const message = new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]);
expect(
keyring.bob.decryptMessage(
ENCRYPTED,
keyring.alice.publicKey
)
).toEqual(message);
});
it('fails a correctly encrypted message (message changed)', (): void => {
expect(
keyring.bob.decryptMessage(
ENCRYPTED_CHANGED,
keyring.alice.publicKey
)
).toEqual(null);
});
it('fails a correctly encrypted message (sender changed)', (): void => {
expect(
keyring.bob.decryptMessage(
ENCRYPTED,
keyring.charlie.publicKey
)
).toEqual(null);
});
it('fails a correctly encrypted message (receiver changed)', (): void => {
expect(
keyring.charlie.decryptMessage(
ENCRYPTED,
keyring.alice.publicKey
)
).toEqual(null);
});
it('validates encryption between ed25519 & sr25519 key pairs', (): void => {
const PASS = 'testing';
const encodedA = keyring.alice.encodePkcs8(PASS);
const encodedB = keyring.bob.encodePkcs8(PASS);
const pairA = createPair({ toSS58, type: 'sr25519' }, { publicKey: keyring.alice.publicKey });
const pairB = createPair({ toSS58, type: 'sr25519' }, { publicKey: keyring.bob.publicKey });
pairA.decodePkcs8(PASS, encodedA);
pairB.decodePkcs8(PASS, encodedB);
const message = new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]);
// alice-sr25519 -> bob-ed25519
const encrypted1 = pairA.encryptMessage(message, keyring.bob.publicKey);
// alice-sr25519 -> bob-sr25519
const encrypted2 = pairA.encryptMessage(message, pairB.publicKey);
// alice-ed25519 -> bob-sr25519
const encrypted3 = keyring.alice.encryptMessage(message, pairB.publicKey);
// decrypt: Bob-ed25519 - use alice-ed25519 pubkey
expect(
keyring.bob.decryptMessage(encrypted3, keyring.alice.publicKey)
).toEqual(message);
// decrypt: Bob-ed25519 - use alice-sr25519 pubkey
expect(
keyring.bob.decryptMessage(encrypted1, pairA.publicKey)
).toEqual(message);
// decrypt: Bob-sr25519 - use alice-sr25519 pubkey
expect(
pairB.decryptMessage(encrypted2, pairA.publicKey)
).toEqual(message);
});
it('allows setting/getting of meta', (): void => {
keyring.bob.setMeta({ foo: 'bar', something: 'else' });
@@ -183,5 +274,22 @@ describe('pair', (): void => {
});
expect(json.address).toEqual(u8aToHex(PUBLICDERIVED));
});
it('denies access to encryptMessage/decryptMessage API', (): void => {
const PASS = 'testing';
const encoded = keyring.alice.encodePkcs8(PASS);
const pair = createPair({ toSS58, type: 'ethereum' }, { publicKey: keyring.alice.publicKey });
pair.decodePkcs8(PASS, encoded);
expect(
() => pair.encryptMessage(
new Uint8Array(4), // null message
keyring.bob.publicKey,
new Uint8Array(24)
)
).toThrow('Secp256k1 not supported yet');
});
});
});
+20 -1
View File
@@ -7,7 +7,7 @@ import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta, SignOptions } fro
import type { PairInfo } from './types';
import { assert, u8aConcat, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { blake2AsU8a, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, naclKeypairFromSeed as naclFromSeed, naclSign, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, schnorrkelVrfSign, schnorrkelVrfVerify, secp256k1Compress, secp256k1Expand, secp256k1KeypairFromSeed as secp256k1FromSeed, secp256k1Sign, signatureVerify } from '@polkadot/util-crypto';
import { blake2AsU8a, convertPublicKeyToCurve25519, convertSecretKeyToCurve25519, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, naclKeypairFromSeed as naclFromSeed, naclOpen, naclSeal, naclSign, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, schnorrkelVrfSign, schnorrkelVrfVerify, secp256k1Compress, secp256k1Expand, secp256k1KeypairFromSeed as secp256k1FromSeed, secp256k1Sign, signatureVerify } from '@polkadot/util-crypto';
import { decodePair } from './decode';
import { encodePair } from './encode';
@@ -145,6 +145,17 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
},
// eslint-disable-next-line sort-keys
decodePkcs8,
decryptMessage: (encryptedMessageWithNonce: string | Uint8Array, senderPublicKey: string | Uint8Array): Uint8Array | null => {
assert(!isLocked(secretKey), 'Cannot encrypt with a locked key pair');
assert(!['ecdsa', 'ethereum'].includes(type), 'Secp256k1 not supported yet');
return naclOpen(
u8aToU8a(encryptedMessageWithNonce.slice(24, encryptedMessageWithNonce.length)),
u8aToU8a(encryptedMessageWithNonce.slice(0, 24)),
convertPublicKeyToCurve25519(u8aToU8a(senderPublicKey)),
convertSecretKeyToCurve25519(secretKey)
);
},
derive: (suri: string, meta?: KeyringPair$Meta): KeyringPair => {
assert(type !== 'ethereum', 'Unable to derive on this keypair');
assert(!isLocked(secretKey), 'Cannot derive on a locked keypair');
@@ -157,6 +168,14 @@ 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 => {
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);
return u8aConcat(nonce, sealed);
},
lock: (): void => {
secretKey = new Uint8Array();
},
+6
View File
@@ -30,11 +30,17 @@ export function nobody (): KeyringPair {
decodePkcs8: (passphrase?: string, encoded?: Uint8Array): void =>
undefined,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
decryptMessage: (encryptedMessageWithNonce: string | Uint8Array, senderPublicKey: string | Uint8Array): Uint8Array | null =>
null,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
derive: (suri: string, meta?: KeyringPair$Meta): KeyringPair =>
pair,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
encodePkcs8: (passphrase?: string): Uint8Array =>
new Uint8Array(0),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
encryptMessage: (message: string | Uint8Array, recipientPublicKey: string | Uint8Array, _nonce?: Uint8Array): Uint8Array =>
new Uint8Array(),
isLocked: true,
lock: (): void => {
// no locking, it is always locked
+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;
+2
View File
@@ -37,6 +37,8 @@ export interface KeyringPair {
sign (message: string | Uint8Array, options?: SignOptions): Uint8Array;
toJson (passphrase?: string): KeyringPair$Json;
unlock (passphrase?: string): void;
encryptMessage (message: string | Uint8Array, recipientPublicKey: string | Uint8Array, nonce?: Uint8Array): Uint8Array;
decryptMessage (encryptedMessageWithNonce: string | Uint8Array, senderPublicKey: string | Uint8Array): Uint8Array | null;
verify (message: string | Uint8Array, signature: Uint8Array, signerPublic: string | Uint8Array): boolean;
vrfSign (message: string | Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array;
vrfVerify (message: string | Uint8Array, vrfResult: Uint8Array, signerPublic: Uint8Array | string, context?: string | Uint8Array, extra?: string | Uint8Array): boolean;
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/networks",
"version": "7.0.2",
"version": "7.2.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.6"
"@babel/runtime": "^7.15.3"
},
"devDependencies": {
"@polkadot/util": "7.0.2",
"@polkadot/x-fetch": "7.0.2"
"@polkadot/util": "7.2.1",
"@polkadot/x-fetch": "7.2.1"
}
}
+1 -42
View File
@@ -1,46 +1,5 @@
// Copyright 2017-2021 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Network, SubstrateNetwork } from './types';
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults';
import { knownSubstrate } from './substrate';
export * from './interfaces';
export { packageInfo } from './packageInfo';
// These are known prefixes that are not sorted
const UNSORTED = [0, 2, 42];
export const allNetworks = knownSubstrate.map((o): SubstrateNetwork => {
const network = o.network || '';
const n = o as SubstrateNetwork;
n.slip44 = knownLedger[network];
n.hasLedgerSupport = !!n.slip44;
n.genesisHash = knownGenesis[network] || [];
n.icon = knownIcon[network] || 'substrate';
n.isIgnored = !network || !!knownTestnet[network] || network.startsWith('reserved');
return n;
});
// The list of available/claimed prefixes
// - no testnets
// - we only include those where we have a standardAccount
// - when no icon has been specified, default to substrate
// - sort by name, however we keep 0, 2, 42 first in the list
export const availableNetworks = allNetworks
.filter((n): n is Network => !n.isIgnored && !!n.network)
.sort((a, b) =>
UNSORTED.includes(a.prefix) === UNSORTED.includes(b.prefix)
? 0
: UNSORTED.includes(a.prefix)
? -1
: UNSORTED.includes(b.prefix)
? 1
: a.displayName.localeCompare(b.displayName)
);
// A filtered list of those chains we have details about (genesisHashes)
export const selectableNetworks = availableNetworks.filter((n) => n.genesisHash.length || n.prefix === 42);
+43
View File
@@ -0,0 +1,43 @@
// Copyright 2017-2021 @polkadot/networks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Network, SubstrateNetwork } from './types';
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults';
import { knownSubstrate } from './substrate';
// These are known prefixes that are not sorted
const UNSORTED = [0, 2, 42];
export const allNetworks = knownSubstrate.map((o): SubstrateNetwork => {
const network = o.network || '';
const n = o as SubstrateNetwork;
n.slip44 = knownLedger[network];
n.hasLedgerSupport = !!n.slip44;
n.genesisHash = knownGenesis[network] || [];
n.icon = knownIcon[network] || 'substrate';
n.isIgnored = !network || !!knownTestnet[network] || network.startsWith('reserved');
return n;
});
// The list of available/claimed prefixes
// - no testnets
// - we only include those where we have a standardAccount
// - sort by name, however we keep 0, 2, 42 first in the list
export const availableNetworks = allNetworks
.filter((n): n is Network => !n.isIgnored && !!n.network)
.sort((a, b) =>
UNSORTED.includes(a.prefix) === UNSORTED.includes(b.prefix)
? 0
: UNSORTED.includes(a.prefix)
? -1
: UNSORTED.includes(b.prefix)
? 1
: a.displayName.localeCompare(b.displayName)
);
// A filtered list of those chains we have details about (genesisHashes)
export const selectableNetworks = availableNetworks.filter((n) => n.genesisHash.length || n.prefix === 42);
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/networks', version: '7.0.2' };
export const packageInfo = { name: '@polkadot/networks', version: '7.2.1' };
+9
View File
@@ -488,6 +488,15 @@ export const knownSubstrate: KnownSubstrate[] = [
symbols: ['XOR'],
website: 'https://sora.org'
},
{
decimals: [10],
displayName: 'Zeitgeist',
network: 'zeitgeist',
prefix: 73,
standardAccount: '*25519',
symbols: ['ZTG'],
website: 'https://zeitgeist.pm'
},
{
decimals: [12],
displayName: 'Manta network',
+7 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util-crypto",
"version": "7.0.2",
"version": "7.2.1",
"type": "module",
"description": "A collection of useful crypto utilities for @polkadot",
"main": "index.js",
@@ -21,16 +21,17 @@
"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.6",
"@polkadot/networks": "7.0.2",
"@polkadot/util": "7.0.2",
"@babel/runtime": "^7.15.3",
"@polkadot/networks": "7.2.1",
"@polkadot/util": "7.2.1",
"@polkadot/wasm-crypto": "^4.1.2",
"@polkadot/x-randomvalues": "7.0.2",
"@polkadot/x-randomvalues": "7.2.1",
"base-x": "^3.0.8",
"base64-js": "^1.5.1",
"blakejs": "^1.1.1",
"bn.js": "^4.11.9",
"create-hash": "^1.2.0",
"ed2curve": "^0.3.0",
"elliptic": "^6.5.4",
"hash.js": "^1.1.7",
"js-sha3": "^0.8.0",
@@ -46,6 +47,6 @@
"@types/xxhashjs": "^0.2.2"
},
"peerDependencies": {
"@polkadot/util": "7.0.2"
"@polkadot/util": "7.2.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)) {
@@ -0,0 +1,12 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import ed2curve from 'ed2curve';
export function convertSecretKeyToCurve25519 (secretKey: Uint8Array): Uint8Array {
return ed2curve.convertSecretKey(secretKey);
}
export function convertPublicKeyToCurve25519 (publicKey: Uint8Array): Uint8Array {
return ed2curve.convertPublicKey(publicKey) as Uint8Array;
}
+1
View File
@@ -15,3 +15,4 @@ export { naclVerify } from './verify';
export { naclBoxKeypairFromSecret } from './box/fromSecret';
export { naclOpen } from './open';
export { naclSeal } from './seal';
export { convertSecretKeyToCurve25519, convertPublicKeyToCurve25519 } from './convertKey';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from '@polkadot/networks';
export * from '@polkadot/networks/interfaces';
+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.0.2' };
export const packageInfo = { name: '@polkadot/util-crypto', version: '7.2.1' };
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util",
"version": "7.0.2",
"version": "7.2.1",
"type": "module",
"description": "A collection of useful utilities for @polkadot",
"main": "index.js",
@@ -19,9 +19,9 @@
"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.6",
"@polkadot/x-textdecoder": "7.0.2",
"@polkadot/x-textencoder": "7.0.2",
"@babel/runtime": "^7.15.3",
"@polkadot/x-textdecoder": "7.2.1",
"@polkadot/x-textencoder": "7.2.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9",
"camelcase": "^5.3.1",
+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.0.2' };
export const packageInfo = { name: '@polkadot/util', version: '7.2.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.0.2",
"version": "7.2.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.6",
"@polkadot/util": "^7.0.2",
"@babel/runtime": "^7.15.3",
"@polkadot/util": "7.2.1",
"buffer-es6": "^4.9.3"
}
}
+1 -3
View File
@@ -1,6 +1,4 @@
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
// SPDX-License-Identifier: Apache-2.0
const crypto = {};
export default crypto;
export default {};
+1 -3
View File
@@ -1,6 +1,4 @@
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
// SPDX-License-Identifier: Apache-2.0
const empty = {};
export default empty;
export default {};
+2 -8
View File
@@ -5,22 +5,16 @@
// The ISC License
// Copyright (c) Isaac Z. Schlueter
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
function inherits (ctor: any, superCtor: any): any {
export default function inherits (ctor: Record<string, unknown>, superCtor: Record<string, unknown>): void {
if (superCtor) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
ctor.super_ = superCtor;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
ctor.prototype = Object.create(superCtor.prototype, {
ctor.prototype = Object.create(superCtor.prototype as null, {
constructor: {
configurable: true,
enumerable: false,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
value: ctor,
writable: true
}
});
}
}
export default inherits;
+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.0.2' };
export const packageInfo = { name: '@polkadot/x-bundle', version: '7.2.1' };
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-fetch",
"version": "7.0.2",
"version": "7.2.1",
"type": "module",
"description": "A cross-environment fetch replacement",
"browser": "browser.js",
@@ -18,9 +18,9 @@
"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.6",
"@polkadot/x-global": "7.0.2",
"@types/node-fetch": "^2.5.11",
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.2.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.0.2' };
export const packageInfo = { name: '@polkadot/x-fetch', version: '7.2.1' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-global",
"version": "7.0.2",
"version": "7.2.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.6"
"@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.0.2' };
export const packageInfo = { name: '@polkadot/x-global', version: '7.2.1' };
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-randomvalues",
"version": "7.0.2",
"version": "7.2.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.6",
"@polkadot/x-global": "7.0.2"
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.2.1"
},
"devDependencies": {
"@types/react-native": "^0.64.11"
"@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.0.2' };
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '7.2.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-textdecoder",
"version": "7.0.2",
"version": "7.2.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.6",
"@polkadot/x-global": "7.0.2"
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.2.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.0.2' };
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '7.2.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-textencoder",
"version": "7.0.2",
"version": "7.2.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.6",
"@polkadot/x-global": "7.0.2"
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.2.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.0.2' };
export const packageInfo = { name: '@polkadot/x-textencoder', version: '7.2.1' };
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/x-ws",
"version": "7.0.2",
"version": "7.2.1",
"type": "module",
"description": "A cross-environment WebSocket replacement",
"browser": "browser.js",
@@ -18,9 +18,9 @@
"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.6",
"@polkadot/x-global": "7.0.2",
"@types/websocket": "^1.0.3",
"@babel/runtime": "^7.15.3",
"@polkadot/x-global": "7.2.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.0.2' };
export const packageInfo = { name: '@polkadot/x-ws', version: '7.2.1' };
+423 -403
View File
File diff suppressed because it is too large Load Diff