Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a5659a579 | ||
|
|
c4a8aa2dd7 | ||
|
|
2ad042e44d | ||
|
|
4615fcfbde | ||
|
|
f90d84500d | ||
|
|
e919446341 | ||
|
|
8f942dcabe | ||
|
|
2e4de2093c | ||
|
|
0202a1f1d4 | ||
|
|
1e256fedaa | ||
|
|
56a3d19083 | ||
|
|
caf76a7511 | ||
|
|
834a1e6a52 | ||
|
|
7a5b1207b0 | ||
|
|
8221576d25 | ||
|
|
1f9d36d4db | ||
|
|
b292f2ae1d | ||
|
|
7eddfc25c9 | ||
|
|
c6ff77b56f | ||
|
|
4a1f5bfbf4 | ||
|
|
e8f0072e44 | ||
|
|
4620a6a649 | ||
|
|
a5fd5e2c85 | ||
|
|
b58c77d774 | ||
|
|
5e8ec185cb | ||
|
|
bbdf5659df | ||
|
|
f8cc8d07e1 | ||
|
|
e3eb76762c | ||
|
|
114e75a4b4 | ||
|
|
5ca641c758 | ||
|
|
ded2528836 | ||
|
|
70fa61916d | ||
|
|
c9a2d3b6d7 | ||
|
|
4927120403 | ||
|
|
36f53f6b82 | ||
|
|
24548e84e1 | ||
|
|
337deab526 | ||
|
|
4a9f0326e7 | ||
|
|
81811510f4 | ||
|
|
f09867d90f | ||
|
|
709e1ab3c1 | ||
|
|
ae2d7518b2 | ||
|
|
5337f1dca9 | ||
|
|
cc9b8630ff | ||
|
|
e6e266a4c0 | ||
|
|
3b96d87f7f | ||
|
|
c1949a21be | ||
|
|
7f0a6b0ce9 | ||
|
|
6b644025b0 | ||
|
|
6ea1ee555b | ||
|
|
d582b2e180 | ||
|
|
c2d04155f9 | ||
|
|
5a4dc97498 | ||
|
|
f1aeda10ee | ||
|
|
70a3aebce3 | ||
|
|
31dd2ced0e | ||
|
|
98ad1199f3 | ||
|
|
30225ceb40 | ||
|
|
194b8ced5b | ||
|
|
81ed8cfc6c | ||
|
|
51598b00c0 | ||
|
|
1684bd3161 | ||
|
|
a53e1b8aa4 | ||
|
|
89f2925d89 | ||
|
|
c29a226279 |
@@ -14,3 +14,7 @@
|
||||
6.0.3
|
||||
6.0.4
|
||||
6.0.5
|
||||
|
||||
7.0.2
|
||||
7.0.3
|
||||
7.1.2
|
||||
Vendored
-591
File diff suppressed because one or more lines are too long
+631
File diff suppressed because one or more lines are too long
+1
-1
@@ -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
|
||||
|
||||
@@ -1,5 +1,69 @@
|
||||
# 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:
|
||||
|
||||
- Added `isCompact` utility for check on compact-like types
|
||||
- Sync with upstream Substrate ss58 registry
|
||||
|
||||
|
||||
## 7.0.1 Jul 11, 2021
|
||||
|
||||
- **Breaking change** The `@polkadot/x-rxjs` package has been removed. In `rxjs` 7.2.0 the compatibility issues at the base layer has been solved.
|
||||
- **Breaking change** The named exports in `@polkadot/networks` has been changed
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Ledger config for Centrifuge (Thanks to https://github.com/mikiquantum)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `@polkadot/networks` to fully-descriptive exports
|
||||
- Remove `@polkadot/x-rxjs`, direct import from `rxjs >= 7.2.0` required
|
||||
- Allow building as a completely stand-alone browser bundle (experimental)
|
||||
- Sync with upstream Substrate ss58 registry
|
||||
|
||||
|
||||
## 6.11.1 Jul 5, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
+8
-5
@@ -12,6 +12,7 @@
|
||||
"scripts": {
|
||||
"build": "polkadot-dev-build-ts",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"build:rollup": "polkadot-exec-rollup --config",
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"networks:crosscheck": "polkadot-dev-run-test packages/networks/src/crosscheck",
|
||||
@@ -22,10 +23,12 @@
|
||||
"test:one": "polkadot-dev-run-test --runInBand"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.6",
|
||||
"@polkadot/dev": "^0.62.44",
|
||||
"@polkadot/ts": "^0.4.2",
|
||||
"@types/jest": "^26.0.23"
|
||||
"@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": "6.11.1"
|
||||
"version": "7.2.1",
|
||||
"packageManager": "yarn@3.0.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/hw-ledger-transports",
|
||||
"version": "6.11.1",
|
||||
"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.0.2",
|
||||
"@ledgerhq/hw-transport-webhid": "^6.0.2",
|
||||
"@ledgerhq/hw-transport-webusb": "^6.0.2"
|
||||
"@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.0.2"
|
||||
"@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: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '7.2.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/hw-ledger",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ResponseBase, SubstrateApp } from '@zondax/ledger-substrate';
|
||||
import type { AccountOptions, LedgerAddress, LedgerSignature, LedgerTypes, LedgerVersion } from './types';
|
||||
|
||||
import { transports } from '@polkadot/hw-ledger-transports';
|
||||
import { assert, u8aToBuffer } from '@polkadot/util';
|
||||
|
||||
import { LEDGER_DEFAULT_ACCOUNT, LEDGER_DEFAULT_CHANGE, LEDGER_DEFAULT_INDEX, LEDGER_SUCCESS_CODE } from './constants';
|
||||
import { ledgerApps } from './defaults';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
type Chain = keyof typeof ledgerApps;
|
||||
|
||||
// A very basic wrapper for a ledger app -
|
||||
// - it connects automatically, creating an app as required
|
||||
// - Promises return errors (instead of wrapper errors)
|
||||
export class Ledger {
|
||||
#app: SubstrateApp | null = null;
|
||||
|
||||
#chain: Chain;
|
||||
|
||||
#transport: LedgerTypes;
|
||||
|
||||
constructor (transport: LedgerTypes, chain: Chain) {
|
||||
// u2f is deprecated
|
||||
assert(['hid', 'webusb'].includes(transport), () => `Unsupported transport ${transport}`);
|
||||
assert(Object.keys(ledgerApps).includes(chain), () => `Unsupported chain ${chain}`);
|
||||
|
||||
this.#chain = chain;
|
||||
this.#transport = transport;
|
||||
}
|
||||
|
||||
public async getAddress (confirm = false, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerAddress> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerAddress> => {
|
||||
const { address, pubKey } = await this.#wrapError(app.getAddress(account + accountOffset, change, addressIndex + addressOffset, confirm));
|
||||
|
||||
return {
|
||||
address,
|
||||
publicKey: `0x${pubKey}`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async getVersion (): Promise<LedgerVersion> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerVersion> => {
|
||||
const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await this.#wrapError(app.getVersion());
|
||||
|
||||
return {
|
||||
isLocked,
|
||||
isTestMode,
|
||||
version: [major, minor, patch]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async sign (message: Uint8Array, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerSignature> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerSignature> => {
|
||||
const buffer = u8aToBuffer(message);
|
||||
const { signature } = await this.#wrapError(app.sign(account + accountOffset, change, addressIndex + addressOffset, buffer));
|
||||
|
||||
return {
|
||||
signature: `0x${signature.toString('hex')}`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
#getApp = async (): Promise<SubstrateApp> => {
|
||||
if (!this.#app) {
|
||||
const def = transports.find(({ type }) => type === this.#transport);
|
||||
|
||||
assert(def, () => `Unable to find a transport for ${this.#transport}`);
|
||||
|
||||
const transport = await def.create();
|
||||
|
||||
this.#app = ledgerApps[this.#chain](transport);
|
||||
}
|
||||
|
||||
return this.#app;
|
||||
};
|
||||
|
||||
#withApp = async <T> (fn: (app: SubstrateApp) => Promise<T>): Promise<T> => {
|
||||
try {
|
||||
const app = await this.#getApp();
|
||||
|
||||
return await fn(app);
|
||||
} catch (error) {
|
||||
this.#app = null;
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
#wrapError = async <T extends ResponseBase> (promise: Promise<T>): Promise<T> => {
|
||||
const result = await promise;
|
||||
|
||||
assert(result.return_code === LEDGER_SUCCESS_CODE, () => result.error_message);
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
@@ -4,10 +4,11 @@
|
||||
import type Transport from '@ledgerhq/hw-transport';
|
||||
import type { SubstrateApp } from '@zondax/ledger-substrate';
|
||||
|
||||
import { newDockApp, newEdgewareApp, newEquilibriumApp, newKusamaApp, newPolkadotApp, newPolymeshApp, newStatemineApp } from '@zondax/ledger-substrate';
|
||||
import { newCentrifugeApp, newDockApp, newEdgewareApp, newEquilibriumApp, newKusamaApp, 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> = {
|
||||
centrifuge: newCentrifugeApp,
|
||||
'dock-mainnet': newDockApp,
|
||||
edgeware: newEdgewareApp,
|
||||
equilibrium: newEquilibriumApp,
|
||||
|
||||
@@ -3,103 +3,4 @@
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import type { ResponseBase, SubstrateApp } from '@zondax/ledger-substrate';
|
||||
import type { AccountOptions, LedgerAddress, LedgerSignature, LedgerTypes, LedgerVersion } from './types';
|
||||
|
||||
import { transports } from '@polkadot/hw-ledger-transports';
|
||||
import { assert, u8aToBuffer } from '@polkadot/util';
|
||||
|
||||
import { LEDGER_DEFAULT_ACCOUNT, LEDGER_DEFAULT_CHANGE, LEDGER_DEFAULT_INDEX, LEDGER_SUCCESS_CODE } from './constants';
|
||||
import { ledgerApps } from './defaults';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
type Chain = keyof typeof ledgerApps;
|
||||
|
||||
// A very basic wrapper for a ledger app -
|
||||
// - it connects automatically, creating an app as required
|
||||
// - Promises return errors (instead of wrapper errors)
|
||||
export class Ledger {
|
||||
#app: SubstrateApp | null = null;
|
||||
|
||||
#chain: Chain;
|
||||
|
||||
#transport: LedgerTypes;
|
||||
|
||||
constructor (transport: LedgerTypes, chain: Chain) {
|
||||
// u2f is deprecated
|
||||
assert(['hid', 'webusb'].includes(transport), () => `Unsupported transport ${transport}`);
|
||||
assert(Object.keys(ledgerApps).includes(chain), () => `Unsupported chain ${chain}`);
|
||||
|
||||
this.#chain = chain;
|
||||
this.#transport = transport;
|
||||
}
|
||||
|
||||
public async getAddress (confirm = false, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerAddress> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerAddress> => {
|
||||
const { address, pubKey } = await this.#wrapError(app.getAddress(account + accountOffset, change, addressIndex + addressOffset, confirm));
|
||||
|
||||
return {
|
||||
address,
|
||||
publicKey: `0x${pubKey}`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async getVersion (): Promise<LedgerVersion> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerVersion> => {
|
||||
const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await this.#wrapError(app.getVersion());
|
||||
|
||||
return {
|
||||
isLocked,
|
||||
isTestMode,
|
||||
version: [major, minor, patch]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async sign (message: Uint8Array, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerSignature> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerSignature> => {
|
||||
const buffer = u8aToBuffer(message);
|
||||
const { signature } = await this.#wrapError(app.sign(account + accountOffset, change, addressIndex + addressOffset, buffer));
|
||||
|
||||
return {
|
||||
signature: `0x${signature.toString('hex')}`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
#getApp = async (): Promise<SubstrateApp> => {
|
||||
if (!this.#app) {
|
||||
const def = transports.find(({ type }) => type === this.#transport);
|
||||
|
||||
assert(def, () => `Unable to find a transport for ${this.#transport}`);
|
||||
|
||||
const transport = await def.create();
|
||||
|
||||
this.#app = ledgerApps[this.#chain](transport);
|
||||
}
|
||||
|
||||
return this.#app;
|
||||
};
|
||||
|
||||
#withApp = async <T> (fn: (app: SubstrateApp) => Promise<T>): Promise<T> => {
|
||||
try {
|
||||
const app = await this.#getApp();
|
||||
|
||||
return await fn(app);
|
||||
} catch (error) {
|
||||
this.#app = null;
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
#wrapError = async <T extends ResponseBase> (promise: Promise<T>): Promise<T> => {
|
||||
const result = await promise;
|
||||
|
||||
assert(result.return_code === LEDGER_SUCCESS_CODE, () => result.error_message);
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
export * from './bundle';
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', version: '7.2.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/keyring",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1",
|
||||
"@polkadot/util-crypto": "6.11.1"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@polkadot/util-crypto": "7.2.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "6.11.1",
|
||||
"@polkadot/util-crypto": "6.11.1"
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@polkadot/util-crypto": "7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Keyring } from './keyring';
|
||||
|
||||
export { decodeAddress, encodeAddress, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
export * from './defaults';
|
||||
export { createPair } from './pair';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { createTestKeyring } from './testing';
|
||||
export { createTestPairs } from './testingPairs';
|
||||
|
||||
export { Keyring };
|
||||
@@ -3,12 +3,8 @@
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import { Keyring } from './keyring';
|
||||
import { Keyring } from './bundle';
|
||||
|
||||
export { decodeAddress, encodeAddress, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
export * from './bundle';
|
||||
|
||||
export default Keyring;
|
||||
|
||||
export { Keyring };
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/keyring', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/keyring', version: '7.2.1' };
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/networks",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1",
|
||||
"@polkadot/x-fetch": "6.11.1"
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@polkadot/x-fetch": "7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import fs from 'fs';
|
||||
import { stringify } from '@polkadot/util';
|
||||
import { fetch } from '@polkadot/x-fetch';
|
||||
|
||||
import { all } from './';
|
||||
import { allNetworks } from './';
|
||||
|
||||
const OUTPUT = './.github/ss58-check.md';
|
||||
const SUBSTRATE_REGISTRY = 'https://raw.githubusercontent.com/paritytech/substrate/master/ss58-registry.json';
|
||||
@@ -32,19 +32,19 @@ describe('check latest Substrate ss58 registry', (): void => {
|
||||
});
|
||||
|
||||
it('has the same number as the original', (): void => {
|
||||
assertAndLog(all.length === original.registry.length, `Number of entries mismatched:: Expected ${original.registry.length} found ${all.length}`);
|
||||
assertAndLog(allNetworks.length === original.registry.length, `Number of entries mismatched:: Expected ${original.registry.length} found ${allNetworks.length}`);
|
||||
});
|
||||
|
||||
it('has no missing any entries', (): void => {
|
||||
const missing = original.registry
|
||||
.filter(({ prefix }) => !all.some((n) => n.prefix === prefix))
|
||||
.filter(({ prefix }) => !allNetworks.some((n) => n.prefix === prefix))
|
||||
.map(({ displayName, prefix }) => `${displayName} (${prefix})`);
|
||||
|
||||
assertAndLog(!missing.length, `Missing entries found: ${stringify(missing, 2)}`);
|
||||
});
|
||||
|
||||
it('has no extra entries', (): void => {
|
||||
const missing = all
|
||||
const missing = allNetworks
|
||||
.filter(({ prefix }) => !original.registry.some((n) => n.prefix === prefix))
|
||||
.map(({ displayName, prefix }) => `${displayName} (${prefix})`);
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('check latest Substrate ss58 registry', (): void => {
|
||||
const fields = Object.keys(original.schema) as (keyof KnownSubstrate)[];
|
||||
const errors = original.registry
|
||||
.map((n): [string, string[]] => {
|
||||
const other = all.find(({ prefix }) => prefix === n.prefix);
|
||||
const other = allNetworks.find(({ prefix }) => prefix === n.prefix);
|
||||
|
||||
return [
|
||||
`${n.displayName} (${n.prefix})`,
|
||||
|
||||
@@ -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 = {
|
||||
centrifuge: [
|
||||
'0x67dddf2673b69e5f875f6f25277495834398eafd67f492e09f3f3345e003d1b5'
|
||||
],
|
||||
'dock-mainnet': [
|
||||
'0xf73467c6544aa68df2ee546b135f955c46b90fa627e9b5d7935f41061bb8a5a9'
|
||||
],
|
||||
@@ -53,6 +56,7 @@ export const knownGenesis: KnownGenesis = {
|
||||
|
||||
// these are icon overrides
|
||||
export const knownIcon: KnownIcon = {
|
||||
centrifuge: 'polkadot',
|
||||
kusama: 'polkadot',
|
||||
polkadot: 'polkadot',
|
||||
statemine: 'polkadot',
|
||||
@@ -64,6 +68,7 @@ export const knownIcon: KnownIcon = {
|
||||
// and maps to the known slip44 (minus the `0x8` hard derivation flag)
|
||||
// NOTE: Any network here needs to have a genesisHash attached in the config above
|
||||
export const knownLedger: KnownLedger = {
|
||||
centrifuge: 0x000002eb,
|
||||
'dock-mainnet': 0x00000252,
|
||||
edgeware: 0x0000020b,
|
||||
equilibrium: 0x05f5e0fd,
|
||||
|
||||
@@ -4,25 +4,25 @@
|
||||
import type { SubstrateNetwork } from './types';
|
||||
|
||||
import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults';
|
||||
import filtered, { all, available } from '.';
|
||||
import { allNetworks, availableNetworks, selectableNetworks } from '.';
|
||||
|
||||
describe('filtered', (): void => {
|
||||
describe('selectableNetworks', (): void => {
|
||||
it('has the correct starting order', (): void => {
|
||||
expect(filtered.slice(0, 3).map(({ prefix }) => prefix)).toEqual([0, 2, 42]);
|
||||
expect(selectableNetworks.slice(0, 3).map(({ prefix }) => prefix)).toEqual([0, 2, 42]);
|
||||
});
|
||||
|
||||
it('has no ignored networks', (): void => {
|
||||
expect(available.some(({ isIgnored }) => isIgnored)).toEqual(false);
|
||||
expect(availableNetworks.some(({ isIgnored }) => isIgnored)).toEqual(false);
|
||||
});
|
||||
|
||||
it('has no reserved networks', (): void => {
|
||||
expect(available.some(({ prefix }) => prefix === 47)).toEqual(false);
|
||||
expect(availableNetworks.some(({ prefix }) => prefix === 47)).toEqual(false);
|
||||
});
|
||||
|
||||
it('has all genesis information', (): void => {
|
||||
it('has allNetworks genesis information', (): void => {
|
||||
expect(
|
||||
Object.entries(knownGenesis).filter(([network, genesisHash]) =>
|
||||
available.some((a) =>
|
||||
availableNetworks.some((a) =>
|
||||
a.network === network &&
|
||||
genesisHash.some((g, index) => a.genesisHash[index] !== g)
|
||||
)
|
||||
@@ -30,10 +30,10 @@ describe('filtered', (): void => {
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has all ledger details', (): void => {
|
||||
it('has allNetworks ledger details', (): void => {
|
||||
expect(
|
||||
Object.entries(knownLedger).filter(([network, slip44]) =>
|
||||
available.some((a) =>
|
||||
availableNetworks.some((a) =>
|
||||
a.network === network && (
|
||||
a.slip44 !== slip44 ||
|
||||
!a.hasLedgerSupport ||
|
||||
@@ -47,16 +47,16 @@ describe('filtered', (): void => {
|
||||
it('has no testnets exposed', (): void => {
|
||||
expect(
|
||||
Object.keys(knownTestnet).filter((network) =>
|
||||
available.some((a) =>
|
||||
availableNetworks.some((a) =>
|
||||
a.network === network
|
||||
)
|
||||
)
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has all icons, except for overrides', (): void => {
|
||||
it('has allNetworks icons, except for overrides', (): void => {
|
||||
expect(
|
||||
available.filter(({ icon, network }) =>
|
||||
availableNetworks.filter(({ icon, network }) =>
|
||||
icon !== 'substrate' &&
|
||||
knownIcon[network] !== icon
|
||||
)
|
||||
@@ -67,7 +67,7 @@ describe('filtered', (): void => {
|
||||
const dupes: SubstrateNetwork[] = [];
|
||||
const uniques: SubstrateNetwork[] = [];
|
||||
|
||||
all.forEach((a): void => {
|
||||
allNetworks.forEach((a): void => {
|
||||
if (uniques.some((u) => u.prefix === a.prefix)) {
|
||||
dupes.push(a);
|
||||
} else {
|
||||
|
||||
@@ -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 all = 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 available = all
|
||||
.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 default available.filter((n) => n.genesisHash.length || n.prefix === 42);
|
||||
|
||||
@@ -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);
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/networks', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/networks', version: '7.2.1' };
|
||||
|
||||
@@ -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',
|
||||
@@ -533,6 +542,15 @@ export const knownSubstrate: KnownSubstrate[] = [
|
||||
symbols: ['TRAC'],
|
||||
website: 'https://origintrail.io'
|
||||
},
|
||||
{
|
||||
decimals: [12],
|
||||
displayName: 'Heiko',
|
||||
network: 'heiko',
|
||||
prefix: 110,
|
||||
standardAccount: '*25519',
|
||||
symbols: ['HKO'],
|
||||
website: 'https://parallel.fi/'
|
||||
},
|
||||
{
|
||||
decimals: [18],
|
||||
displayName: 'Altair',
|
||||
@@ -542,6 +560,15 @@ export const knownSubstrate: KnownSubstrate[] = [
|
||||
symbols: ['AIR'],
|
||||
website: 'https://centrifuge.io/'
|
||||
},
|
||||
{
|
||||
decimals: [12],
|
||||
displayName: 'Parallel',
|
||||
network: 'parallel',
|
||||
prefix: 172,
|
||||
standardAccount: '*25519',
|
||||
symbols: ['PARA'],
|
||||
website: 'https://parallel.fi/'
|
||||
},
|
||||
{
|
||||
decimals: [18],
|
||||
displayName: 'Social Network',
|
||||
@@ -556,7 +583,7 @@ export const knownSubstrate: KnownSubstrate[] = [
|
||||
displayName: 'Moonbeam',
|
||||
network: 'moonbeam',
|
||||
prefix: 1284,
|
||||
standardAccount: '*25519',
|
||||
standardAccount: 'secp256k1',
|
||||
symbols: ['GLMR'],
|
||||
website: 'https://moonbeam.network'
|
||||
},
|
||||
@@ -565,7 +592,7 @@ export const knownSubstrate: KnownSubstrate[] = [
|
||||
displayName: 'Moonriver',
|
||||
network: 'moonriver',
|
||||
prefix: 1285,
|
||||
standardAccount: '*25519',
|
||||
standardAccount: 'secp256k1',
|
||||
symbols: ['MOVR'],
|
||||
website: 'https://moonbeam.network'
|
||||
},
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/util-crypto",
|
||||
"version": "6.11.1",
|
||||
"version": "7.2.1",
|
||||
"type": "module",
|
||||
"description": "A collection of useful crypto utilities for @polkadot",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
"./cryptoInit.js",
|
||||
"./cryptoInit.cjs",
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
@@ -19,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": "6.11.1",
|
||||
"@polkadot/util": "6.11.1",
|
||||
"@polkadot/wasm-crypto": "^4.0.2",
|
||||
"@polkadot/x-randomvalues": "6.11.1",
|
||||
"@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.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",
|
||||
@@ -39,11 +42,11 @@
|
||||
"devDependencies": {
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"@types/create-hash": "^1.2.2",
|
||||
"@types/elliptic": "^6.4.12",
|
||||
"@types/elliptic": "^6.4.13",
|
||||
"@types/scryptsy": "^2.0.0",
|
||||
"@types/xxhashjs": "^0.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "6.11.1"
|
||||
"@polkadot/util": "7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { available } from '@polkadot/networks';
|
||||
import { availableNetworks } from '../networks';
|
||||
|
||||
export const defaults = {
|
||||
allowedDecodedLengths: [1, 2, 4, 8, 32, 33],
|
||||
// publicKey has prefix + 2 checksum bytes, short only prefix + 1 checksum byte
|
||||
allowedEncodedLengths: [3, 4, 6, 10, 35, 36, 37, 38],
|
||||
allowedPrefix: available.map(({ prefix }) => prefix),
|
||||
allowedPrefix: availableNetworks.map(({ prefix }) => prefix),
|
||||
prefix: 42
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './cryptoInit';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
// all internal exports
|
||||
export * from './address';
|
||||
export * from './base32';
|
||||
export * from './base58';
|
||||
export * from './base64';
|
||||
export * from './blake2';
|
||||
export * from './crypto';
|
||||
export * from './ethereum';
|
||||
export * from './hd';
|
||||
export * from './hmac';
|
||||
export * from './json';
|
||||
export * from './keccak';
|
||||
export * from './key';
|
||||
export * from './mnemonic';
|
||||
export * from './networks';
|
||||
export * from './nacl';
|
||||
export * from './pbkdf2';
|
||||
export * from './random';
|
||||
export * from './schnorrkel';
|
||||
export * from './scrypt';
|
||||
export * from './secp256k1';
|
||||
export * from './sha512';
|
||||
export * from './signature';
|
||||
export * from './xxhash';
|
||||
@@ -1,31 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './cryptoInit';
|
||||
import './detectPackage';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
// all internal exports
|
||||
export * from './address';
|
||||
export * from './base32';
|
||||
export * from './base58';
|
||||
export * from './base64';
|
||||
export * from './blake2';
|
||||
export * from './crypto';
|
||||
export * from './ethereum';
|
||||
export * from './hd';
|
||||
export * from './hmac';
|
||||
export * from './json';
|
||||
export * from './keccak';
|
||||
export * from './key';
|
||||
export * from './mnemonic';
|
||||
export * from './nacl';
|
||||
export * from './pbkdf2';
|
||||
export * from './random';
|
||||
export * from './schnorrkel';
|
||||
export * from './scrypt';
|
||||
export * from './secp256k1';
|
||||
export * from './sha512';
|
||||
export * from './signature';
|
||||
export * from './xxhash';
|
||||
export * from './bundle';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from '@polkadot/networks/interfaces';
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/util-crypto', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/util-crypto', version: '7.2.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/util",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1",
|
||||
"@polkadot/x-textencoder": "6.11.1",
|
||||
"@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",
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* @summary Utility methods for this package are split into groups
|
||||
*/
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export * from './array';
|
||||
export * from './assert';
|
||||
export * from './bn';
|
||||
export * from './buffer';
|
||||
export * from './compact';
|
||||
export * from './extractTime';
|
||||
export * from './format';
|
||||
export * from './hex';
|
||||
export * from './is';
|
||||
export * from './logger';
|
||||
export * from './memoize';
|
||||
export * from './number';
|
||||
export * from './promisify';
|
||||
export * from './string';
|
||||
export * from './stringify';
|
||||
export * from './u8a';
|
||||
export * from './versionDetect';
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -3,25 +3,4 @@
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
/**
|
||||
* @summary Utility methods for this package are split into groups
|
||||
*/
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export * from './array';
|
||||
export * from './assert';
|
||||
export * from './bn';
|
||||
export * from './buffer';
|
||||
export * from './compact';
|
||||
export * from './extractTime';
|
||||
export * from './format';
|
||||
export * from './hex';
|
||||
export * from './is';
|
||||
export * from './logger';
|
||||
export * from './memoize';
|
||||
export * from './number';
|
||||
export * from './promisify';
|
||||
export * from './string';
|
||||
export * from './stringify';
|
||||
export * from './u8a';
|
||||
export * from './versionDetect';
|
||||
export * from './bundle';
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@
|
||||
* ```
|
||||
*/
|
||||
export function isBuffer (value: unknown): value is Buffer {
|
||||
return Buffer.isBuffer(value);
|
||||
return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BN } from '../bn/bn';
|
||||
|
||||
import { isFunction } from './function';
|
||||
|
||||
interface Compact<T> {
|
||||
toBigInt (): bigint;
|
||||
toBn (): BN;
|
||||
toNumber (): number;
|
||||
unwrap (): T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name isCompact
|
||||
* @summary Tests for SCALE-Compact-like object instance.
|
||||
*/
|
||||
export function isCompact <T> (value: unknown): value is Compact<T> {
|
||||
return isFunction((value as Compact<T>).toBigInt) && isFunction((value as Compact<T>).toBn) && isFunction((value as Compact<T>).toNumber) && isFunction((value as Compact<T>).unwrap);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ export { isBn } from './bn';
|
||||
export { isBuffer } from './buffer';
|
||||
export { isBoolean } from './boolean';
|
||||
export { isChildClass } from './childClass';
|
||||
export { isCompact } from './compact';
|
||||
export { isError } from './error';
|
||||
export { isFunction } from './function';
|
||||
export { isHex } from './hex';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { isU8a } from '.';
|
||||
|
||||
describe('isUint8Array', (): void => {
|
||||
describe('isU8a', (): void => {
|
||||
it('returns false on undefined values', (): void => {
|
||||
expect(
|
||||
isU8a()
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/util', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/util', version: '7.2.1' };
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# @polkadot/x-bundle
|
||||
|
||||
A rollup-only package to allow for bundling of builtin dependencies
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@polkadot/x-rxjs",
|
||||
"version": "6.11.1",
|
||||
"name": "@polkadot/x-bundle",
|
||||
"version": "7.2.1",
|
||||
"type": "module",
|
||||
"description": "A pass-through interface for RxJs (allowing node + mjs usage)",
|
||||
"description": "A bundler helper",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
@@ -14,9 +14,10 @@
|
||||
"license": "Apache-2.0",
|
||||
"repository": "github:polkadot-js/common",
|
||||
"bugs": "https://github.com/polkadot-js/common/issues",
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-rxjs#readme",
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-bundle#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"rxjs": "^6.6.7"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "7.2.1",
|
||||
"buffer-es6": "^4.9.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const { BN } = require('@polkadot/util');
|
||||
|
||||
module.exports = BN;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
declare module 'buffer-es6';
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Buffer } from 'buffer-es6';
|
||||
|
||||
export default Buffer;
|
||||
export { Buffer };
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default {};
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default {};
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
console.error('@polkadot/x-bundle is not meant to be used directly');
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Adapted from https://github.com/isaacs/inherits/blob/dbade4c47c548aa7259017eca8874d61c8aaad2b/inherits_browser.js
|
||||
// The ISC License
|
||||
// Copyright (c) Isaac Z. Schlueter
|
||||
|
||||
export default function inherits (ctor: Record<string, unknown>, superCtor: Record<string, unknown>): void {
|
||||
if (superCtor) {
|
||||
ctor.super_ = superCtor;
|
||||
ctor.prototype = Object.create(superCtor.prototype as null, {
|
||||
constructor: {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: ctor,
|
||||
writable: true
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/x-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-bundle', version: '7.2.1' };
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-fetch",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1",
|
||||
"@types/node-fetch": "^2.5.10",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"node-fetch": "^2.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-fetch', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-fetch', version: '7.2.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-global",
|
||||
"version": "6.11.1",
|
||||
"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,4 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/x-fetch authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/x-global authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-global', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-global', version: '7.2.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-randomvalues",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-native": "^0.64.10"
|
||||
"@types/react-native": "^0.64.13"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '7.2.1' };
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,5 +0,0 @@
|
||||
# @polkadot/x-rxjs
|
||||
|
||||
This is a small wrapper around rjx to make it friendly to both Node.js (from .mjs as well as .cjs) as well as bundlers using both esm and cjs modules.
|
||||
|
||||
This need wil disappear, once rxjs supports export maps.
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from 'rxjs';
|
||||
@@ -1,69 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// This is not great, but while having esm files, rxjs doesn't quite play nicely with
|
||||
// Node.js esm files. (Hopefully this improves in 7.0, although no exports map as of yet)
|
||||
|
||||
const rxjs = require('rxjs');
|
||||
|
||||
exports.Observable = rxjs.Observable;
|
||||
exports.ConnectableObservable = rxjs.ConnectableObservable;
|
||||
exports.GroupedObservable = rxjs.GroupedObservable;
|
||||
exports.observable = rxjs.observable;
|
||||
exports.Subject = rxjs.Subject;
|
||||
exports.BehaviorSubject = rxjs.BehaviorSubject;
|
||||
exports.ReplaySubject = rxjs.ReplaySubject;
|
||||
exports.AsyncSubject = rxjs.AsyncSubject;
|
||||
exports.asap = rxjs.asap;
|
||||
exports.asapScheduler = rxjs.asapScheduler;
|
||||
exports.async = rxjs.async;
|
||||
exports.asyncScheduler = rxjs.asyncScheduler;
|
||||
exports.queue = rxjs.queue;
|
||||
exports.queueScheduler = rxjs.queueScheduler;
|
||||
exports.animationFrame = rxjs.animationFrame;
|
||||
exports.animationFrameScheduler = rxjs.animationFrameScheduler;
|
||||
exports.VirtualTimeScheduler = rxjs.VirtualTimeScheduler;
|
||||
exports.VirtualAction = rxjs.VirtualAction;
|
||||
exports.Scheduler = rxjs.Scheduler;
|
||||
exports.Subscription = rxjs.Subscription;
|
||||
exports.Subscriber = rxjs.Subscriber;
|
||||
exports.Notification = rxjs.Notification;
|
||||
exports.NotificationKind = rxjs.NotificationKind;
|
||||
exports.pipe = rxjs.pipe;
|
||||
exports.noop = rxjs.noop;
|
||||
exports.identity = rxjs.identity;
|
||||
exports.isObservable = rxjs.isObservable;
|
||||
exports.ArgumentOutOfRangeError = rxjs.ArgumentOutOfRangeError;
|
||||
exports.EmptyError = rxjs.EmptyError;
|
||||
exports.ObjectUnsubscribedError = rxjs.ObjectUnsubscribedError;
|
||||
exports.UnsubscriptionError = rxjs.UnsubscriptionError;
|
||||
exports.TimeoutError = rxjs.TimeoutError;
|
||||
exports.bindCallback = rxjs.bindCallback;
|
||||
exports.bindNodeCallback = rxjs.bindNodeCallback;
|
||||
exports.combineLatest = rxjs.combineLatest;
|
||||
exports.concat = rxjs.concat;
|
||||
exports.defer = rxjs.defer;
|
||||
exports.empty = rxjs.empty;
|
||||
exports.forkJoin = rxjs.forkJoin;
|
||||
exports.from = rxjs.from;
|
||||
exports.fromEvent = rxjs.fromEvent;
|
||||
exports.fromEventPattern = rxjs.fromEventPattern;
|
||||
exports.generate = rxjs.generate;
|
||||
exports.iif = rxjs.iif;
|
||||
exports.interval = rxjs.interval;
|
||||
exports.merge = rxjs.merge;
|
||||
exports.never = rxjs.never;
|
||||
exports.of = rxjs.of;
|
||||
exports.onErrorResumeNext = rxjs.onErrorResumeNext;
|
||||
exports.pairs = rxjs.pairs;
|
||||
exports.partition = rxjs.partition;
|
||||
exports.race = rxjs.race;
|
||||
exports.range = rxjs.range;
|
||||
exports.throwError = rxjs.throwError;
|
||||
exports.timer = rxjs.timer;
|
||||
exports.using = rxjs.using;
|
||||
exports.zip = rxjs.zip;
|
||||
exports.scheduled = rxjs.scheduled;
|
||||
exports.EMPTY = rxjs.EMPTY;
|
||||
exports.NEVER = rxjs.NEVER;
|
||||
exports.config = rxjs.config;
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from 'rxjs/operators';
|
||||
@@ -1,112 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// This is not great, but while having esm files, rxjs doesn't quite play nicely with
|
||||
// Node.js esm files. (Hopefully this improves in 7.0, although no exports map as of yet)
|
||||
|
||||
const operators = require('rxjs/operators');
|
||||
|
||||
exports.audit = operators.audit;
|
||||
exports.auditTime = operators.auditTime;
|
||||
exports.buffer = operators.buffer;
|
||||
exports.bufferCount = operators.bufferCount;
|
||||
exports.bufferTime = operators.bufferTime;
|
||||
exports.bufferToggle = operators.bufferToggle;
|
||||
exports.bufferWhen = operators.bufferWhen;
|
||||
exports.catchError = operators.catchError;
|
||||
exports.combineAll = operators.combineAll;
|
||||
exports.combineLatest = operators.combineLatest;
|
||||
exports.concat = operators.concat;
|
||||
exports.concatAll = operators.concatAll;
|
||||
exports.concatMap = operators.concatMap;
|
||||
exports.concatMapTo = operators.concatMapTo;
|
||||
exports.count = operators.count;
|
||||
exports.debounce = operators.debounce;
|
||||
exports.debounceTime = operators.debounceTime;
|
||||
exports.defaultIfEmpty = operators.defaultIfEmpty;
|
||||
exports.delay = operators.delay;
|
||||
exports.delayWhen = operators.delayWhen;
|
||||
exports.dematerialize = operators.dematerialize;
|
||||
exports.distinct = operators.distinct;
|
||||
exports.distinctUntilChanged = operators.distinctUntilChanged;
|
||||
exports.distinctUntilKeyChanged = operators.distinctUntilKeyChanged;
|
||||
exports.elementAt = operators.elementAt;
|
||||
exports.endWith = operators.endWith;
|
||||
exports.every = operators.every;
|
||||
exports.exhaust = operators.exhaust;
|
||||
exports.exhaustMap = operators.exhaustMap;
|
||||
exports.expand = operators.expand;
|
||||
exports.filter = operators.filter;
|
||||
exports.finalize = operators.finalize;
|
||||
exports.find = operators.find;
|
||||
exports.findIndex = operators.findIndex;
|
||||
exports.first = operators.first;
|
||||
exports.groupBy = operators.groupBy;
|
||||
exports.ignoreElements = operators.ignoreElements;
|
||||
exports.isEmpty = operators.isEmpty;
|
||||
exports.last = operators.last;
|
||||
exports.map = operators.map;
|
||||
exports.mapTo = operators.mapTo;
|
||||
exports.materialize = operators.materialize;
|
||||
exports.max = operators.max;
|
||||
exports.merge = operators.merge;
|
||||
exports.mergeAll = operators.mergeAll;
|
||||
exports.mergeMap = operators.mergeMap;
|
||||
exports.flatMap = operators.flatMap;
|
||||
exports.mergeMapTo = operators.mergeMapTo;
|
||||
exports.mergeScan = operators.mergeScan;
|
||||
exports.min = operators.min;
|
||||
exports.multicast = operators.multicast;
|
||||
exports.observeOn = operators.observeOn;
|
||||
exports.onErrorResumeNext = operators.onErrorResumeNext;
|
||||
exports.pairwise = operators.pairwise;
|
||||
exports.partition = operators.partition;
|
||||
exports.pluck = operators.pluck;
|
||||
exports.publish = operators.publish;
|
||||
exports.publishBehavior = operators.publishBehavior;
|
||||
exports.publishLast = operators.publishLast;
|
||||
exports.publishReplay = operators.publishReplay;
|
||||
exports.race = operators.race;
|
||||
exports.reduce = operators.reduce;
|
||||
exports.repeat = operators.repeat;
|
||||
exports.repeatWhen = operators.repeatWhen;
|
||||
exports.retry = operators.retry;
|
||||
exports.retryWhen = operators.retryWhen;
|
||||
exports.refCount = operators.refCount;
|
||||
exports.sample = operators.sample;
|
||||
exports.sampleTime = operators.sampleTime;
|
||||
exports.scan = operators.scan;
|
||||
exports.sequenceEqual = operators.sequenceEqual;
|
||||
exports.share = operators.share;
|
||||
exports.shareReplay = operators.shareReplay;
|
||||
exports.single = operators.single;
|
||||
exports.skip = operators.skip;
|
||||
exports.skipLast = operators.skipLast;
|
||||
exports.skipUntil = operators.skipUntil;
|
||||
exports.skipWhile = operators.skipWhile;
|
||||
exports.startWith = operators.startWith;
|
||||
exports.subscribeOn = operators.subscribeOn;
|
||||
exports.switchAll = operators.switchAll;
|
||||
exports.switchMap = operators.switchMap;
|
||||
exports.switchMapTo = operators.switchMapTo;
|
||||
exports.take = operators.take;
|
||||
exports.takeLast = operators.takeLast;
|
||||
exports.takeUntil = operators.takeUntil;
|
||||
exports.takeWhile = operators.takeWhile;
|
||||
exports.tap = operators.tap;
|
||||
exports.throttle = operators.throttle;
|
||||
exports.throttleTime = operators.throttleTime;
|
||||
exports.throwIfEmpty = operators.throwIfEmpty;
|
||||
exports.timeInterval = operators.timeInterval;
|
||||
exports.timeout = operators.timeout;
|
||||
exports.timeoutWith = operators.timeoutWith;
|
||||
exports.timestamp = operators.timestamp;
|
||||
exports.toArray = operators.toArray;
|
||||
exports.window = operators.window;
|
||||
exports.windowCount = operators.windowCount;
|
||||
exports.windowTime = operators.windowTime;
|
||||
exports.windowToggle = operators.windowToggle;
|
||||
exports.windowWhen = operators.windowWhen;
|
||||
exports.withLatestFrom = operators.withLatestFrom;
|
||||
exports.zip = operators.zip;
|
||||
exports.zipAll = operators.zipAll;
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './cjs/index.js';
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './cjs/operators.js';
|
||||
@@ -1,6 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/x-rxjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-rxjs', version: '6.11.1' };
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-textdecoder",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '7.2.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-textencoder",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-textencoder', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-textencoder', version: '7.2.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-ws",
|
||||
"version": "6.11.1",
|
||||
"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": "6.11.1",
|
||||
"@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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-ws', version: '6.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-ws', version: '7.2.1' };
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import { createBundle } from '@polkadot/dev/config/rollup';
|
||||
|
||||
const pkgs = [
|
||||
'@polkadot/hw-ledger',
|
||||
'@polkadot/keyring',
|
||||
'@polkadot/util',
|
||||
'@polkadot/util-crypto'
|
||||
];
|
||||
|
||||
const external = [
|
||||
...pkgs
|
||||
];
|
||||
|
||||
const entries = ['hw-ledger-transports', 'networks', 'x-fetch', 'x-global', 'x-randomvalues', 'x-textdecoder', 'x-textencoder', 'x-ws'].reduce((all, p) => ({
|
||||
...all,
|
||||
[`@polkadot/${p}`]: path.resolve(process.cwd(), `packages/${p}/build`)
|
||||
}), {});
|
||||
|
||||
const overrides = {
|
||||
'@polkadot/hw-ledger': {
|
||||
// these are all in the un-shakable and unused hdDerivation stuff from the Zondax libs, ignore
|
||||
entries: {
|
||||
'bip32-ed25519': path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
|
||||
bip39: path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
|
||||
blakejs: path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
|
||||
bs58: path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
|
||||
events: path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
|
||||
'hash.js': path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js')
|
||||
}
|
||||
},
|
||||
'@polkadot/util-crypto': {
|
||||
entries: {
|
||||
'@polkadot/wasm-crypto': path.resolve(process.cwd(), 'node_modules/@polkadot/wasm-crypto/bundle.js'),
|
||||
'bn.js': path.resolve(process.cwd(), 'packages/x-bundle/build/bn.cjs'),
|
||||
buffer: path.resolve(process.cwd(), 'packages/x-bundle/build/buffer.js'),
|
||||
crypto: path.resolve(process.cwd(), 'packages/x-bundle/build/crypto.js')
|
||||
},
|
||||
inject: {
|
||||
Buffer: path.resolve(process.cwd(), 'packages/x-bundle/build/buffer.js'),
|
||||
crypto: path.resolve(process.cwd(), 'packages/x-bundle/build/crypto.js'),
|
||||
inherits: path.resolve(process.cwd(), 'packages/x-bundle/build/inherits.js')
|
||||
},
|
||||
polyfill: false
|
||||
}
|
||||
};
|
||||
|
||||
export default pkgs.map((pkg) => {
|
||||
const override = (overrides[pkg] || {});
|
||||
|
||||
return createBundle({
|
||||
external,
|
||||
pkg,
|
||||
...override,
|
||||
entries: {
|
||||
...entries,
|
||||
...(override.entries || {})
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Bundler tests</title>
|
||||
<style>
|
||||
pre {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
pre.header {
|
||||
background: #ddd;
|
||||
margin-top: 1.5rem;
|
||||
padding: 0.25rem 0.75rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
function log (label, result) {
|
||||
const pre = document.createElement('pre');
|
||||
|
||||
if (typeof result !== 'undefined') {
|
||||
pre.innerHTML = `${label.padStart(24)} = ${result}`;
|
||||
} else {
|
||||
pre.innerHTML = label;
|
||||
pre.className = 'header';
|
||||
}
|
||||
|
||||
document.body.appendChild(pre);
|
||||
}
|
||||
</script>
|
||||
<script src="packages/util/build/bundle-polkadot-util.js"></script>
|
||||
<script>
|
||||
log('polkadotUtil');
|
||||
|
||||
const { bnToBn, u8aToHex } = polkadotUtil;
|
||||
|
||||
log('u8aToHex', u8aToHex(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])));
|
||||
log('bnToBn', bnToBn(123).addn(1).toString());
|
||||
</script>
|
||||
<script src="packages/util-crypto/build/bundle-polkadot-util-crypto.js"></script>
|
||||
<script>
|
||||
log('polkadotUtilCrypto');
|
||||
|
||||
const { blake2AsHex, selectableNetworks } = polkadotUtilCrypto;
|
||||
|
||||
log('blake2AsHex', blake2AsHex(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])));
|
||||
log('blake2AsHex (js)', blake2AsHex(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]), 256, null, true));
|
||||
log('selectableNetworks', selectableNetworks.map(({ displayName }) => displayName).join('; '));
|
||||
</script>
|
||||
<script src="packages/keyring/build/bundle-polkadot-keyring.js"></script>
|
||||
<script>
|
||||
log('polkadotKeyring');
|
||||
|
||||
const { Keyring } = polkadotKeyring;
|
||||
|
||||
const keyring = new Keyring();
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
log('alice.address', alice.address);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+1
-2
@@ -19,11 +19,10 @@
|
||||
"@polkadot/util-crypto/*": [ "packages/util-crypto/src/*" ],
|
||||
"@polkadot/util": [ "packages/util/src" ],
|
||||
"@polkadot/util/*": [ "packages/util/src/*" ],
|
||||
"@polkadot/x-bundle/*": [ "packages/x-bundle/src/*" ],
|
||||
"@polkadot/x-fetch": [ "packages/x-fetch/src/browser" ],
|
||||
"@polkadot/x-global": [ "packages/x-global/src" ],
|
||||
"@polkadot/x-randomvalues": [ "packages/x-randomvalues/src/browser" ],
|
||||
"@polkadot/x-rxjs": ["packages/x-rxjs/src"],
|
||||
"@polkadot/x-rxjs/*": ["packages/x-rxjs/src/*"],
|
||||
"@polkadot/x-textdecoder": [ "packages/x-textdecoder/src/browser" ],
|
||||
"@polkadot/x-textencoder": [ "packages/x-textencoder/src/browser" ],
|
||||
"@polkadot/x-ws": [ "packages/x-ws/src/browser" ]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user