2.4 (#539)
This commit is contained in:
+4
-3
@@ -1,8 +1,9 @@
|
||||
# 2.4.0-beta.x
|
||||
# 2.4.1 Feb 18, 2020
|
||||
|
||||
- Ensure that `formatBalance` does not apply unit overrides apply when no SI is applicable
|
||||
- Adjust `formatBalance` to take expanded `withUnit: string | boolean` option where string is an actual unit, e.g. `KSM`
|
||||
- The `.setSS58Format` on keyring will now just operate on the keyring, not globally. The global `setSS58Format` in `@polkadot/util-crypto` is deprecated.
|
||||
- Adjust `formatBalance(<balance>, <options>)` to take expanded `withUnit: string | boolean` option where string is an actual unit, e.g. `KSM`
|
||||
- The `decimals` option to `formatBalance` should now be passed as part of the `options` (previous last-param deprecated)
|
||||
- The `.setSS58Format` on keyring will now just operate on pairs created on the keyring, not globally. The global `setSS58Format` in `@polkadot/util-crypto` will be deprecated.
|
||||
- The deprecated `addressPrefix` option to keyring has been belatedly removed (Use `ss58Format` rather)
|
||||
|
||||
# 2.3.1 Feb 15, 2020
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "2.4.0-beta.2"
|
||||
"version": "2.4.0"
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.4",
|
||||
"@polkadot/dev": "^0.40.17",
|
||||
"@polkadot/dev": "^0.40.18",
|
||||
"@polkadot/ts": "^0.2.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/keyring",
|
||||
"version": "2.4.0-beta.2",
|
||||
"version": "2.4.0",
|
||||
"description": "Keyring management",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -28,7 +28,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/util": "^2.4.0-beta.2",
|
||||
"@polkadot/util-crypto": "^2.4.0-beta.2"
|
||||
"@polkadot/util": "^2.4.0",
|
||||
"@polkadot/util-crypto": "^2.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ export const PAIRS: PairDef[] = [
|
||||
export default function testKeyring (options: KeyringOptions = {}, isDerived = true): KeyringInstance {
|
||||
const keyring = new Keyring(options);
|
||||
|
||||
PAIRS.forEach(({ name, publicKey, secretKey, seed, type }): void => {
|
||||
PAIRS.forEach(({ name, publicKey, secretKey, seed, type = 'sr25519' }): void => {
|
||||
const meta = {
|
||||
isTesting: true,
|
||||
name: name || seed.replace('//', '_').toLowerCase()
|
||||
@@ -82,7 +82,7 @@ export default function testKeyring (options: KeyringOptions = {}, isDerived = t
|
||||
const pair = !isDerived && !name
|
||||
? keyring.addFromUri(seed, meta, options.type)
|
||||
: keyring.addPair(
|
||||
createPair({ toSS58: keyring.encodeAddress, type: type || 'sr25519' }, { publicKey, secretKey }, meta)
|
||||
createPair({ toSS58: keyring.encodeAddress, type }, { publicKey, secretKey }, meta)
|
||||
);
|
||||
|
||||
pair.lock = (): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/util-crypto",
|
||||
"version": "2.4.0-beta.2",
|
||||
"version": "2.4.0",
|
||||
"description": "A collection of useful crypto utilities for @polkadot",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,7 +26,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/util": "^2.4.0-beta.2",
|
||||
"@polkadot/util": "^2.4.0",
|
||||
"@polkadot/wasm-crypto": "^1.0.1",
|
||||
"base-x": "^3.0.7",
|
||||
"bip39": "^3.0.2",
|
||||
@@ -40,6 +40,7 @@
|
||||
"xxhashjs": "^0.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"@types/bs58": "^4.0.0",
|
||||
"@types/elliptic": "^6.4.12",
|
||||
"@types/pbkdf2": "^3.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/util",
|
||||
"version": "2.4.0-beta.2",
|
||||
"version": "2.4.0",
|
||||
"description": "A collection of useful utilities for @polkadot",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,12 +26,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^5.1.1",
|
||||
"camelcase": "^5.3.1",
|
||||
"chalk": "^3.0.0",
|
||||
"ip-regex": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bn.js": "^4.11.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,20 @@ describe('formatBalance', (): void => {
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=15)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { withSi: true, decimals: 15 })
|
||||
).toEqual('123.456µ Unit');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=15, old style)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { withSi: true }, 15)
|
||||
).toEqual('123.456µ Unit');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=36)', (): void => {
|
||||
it('formats 123,456,789,000 (decimals=36, option)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { withSi: true }, 36)
|
||||
formatBalance(TESTVAL, { withSi: true, decimals: 36 })
|
||||
).toEqual('0.123y Unit');
|
||||
});
|
||||
|
||||
@@ -34,13 +40,13 @@ describe('formatBalance', (): void => {
|
||||
something: 'else'
|
||||
};
|
||||
expect(
|
||||
formatBalance(compact, { withSi: true }, 15)
|
||||
formatBalance(compact, { withSi: true, decimals: 15 })
|
||||
).toEqual('123.456µ Unit');
|
||||
});
|
||||
|
||||
it('formats 123,456,789,000 (decimals=12)', (): void => {
|
||||
expect(
|
||||
formatBalance(TESTVAL, { withSi: true }, 12)
|
||||
formatBalance(TESTVAL, { withSi: true, decimals: 12 })
|
||||
).toEqual('123.456m Unit');
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ interface Defaults {
|
||||
}
|
||||
|
||||
interface Options {
|
||||
decimals?: number;
|
||||
forceUnit?: string;
|
||||
withSi?: boolean;
|
||||
withSiFull?: boolean;
|
||||
@@ -40,7 +41,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 | ExtToBn, options: Options | boolean = true, decimals: number = defaultDecimals): string {
|
||||
function _formatBalance <ExtToBn extends ToBn> (input?: number | string | BN | ExtToBn, options: Options | boolean = true, optDecimals: number = defaultDecimals): string {
|
||||
let text = bnToBn(input).toString();
|
||||
|
||||
if (text.length === 0 || text === '0') {
|
||||
@@ -56,7 +57,7 @@ function _formatBalance <ExtToBn extends ToBn> (input?: number | string | BN | E
|
||||
}
|
||||
|
||||
// extract options - the boolean case is for backwards-compat
|
||||
const { forceUnit = undefined, withSi = true, withSiFull = false, withUnit = true } = isBoolean(options)
|
||||
const { decimals = optDecimals, forceUnit = undefined, withSi = true, withSiFull = false, withUnit = true } = isBoolean(options)
|
||||
? { withSi: options }
|
||||
: options;
|
||||
|
||||
|
||||
@@ -2016,10 +2016,10 @@
|
||||
dependencies:
|
||||
"@types/node" ">= 8"
|
||||
|
||||
"@polkadot/dev@^0.40.17":
|
||||
version "0.40.17"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.40.17.tgz#493f4a7263797e416b12e6b735b39d428f6c0ef1"
|
||||
integrity sha512-tAfUlcdOzixa6c4/5fxaXjO4cEmXpGZzx3EAIyqsQw+74FBFVR1BKEeGoGuWetTQfIWKqAMOKsFjF5O6VS+VfA==
|
||||
"@polkadot/dev@^0.40.18":
|
||||
version "0.40.18"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.40.18.tgz#6ca40304bcc7c75b26c0190d60cb5b892a512dc5"
|
||||
integrity sha512-SEkmrdZPYcnFzXnfpIjnvNfrwdBS3uAenEt8ZYBMkay59+XgFnPKi7xKV92x5iGYEiAXfcKFYjCAN0Nk2rXV5Q==
|
||||
dependencies:
|
||||
"@babel/cli" "^7.8.4"
|
||||
"@babel/core" "^7.8.4"
|
||||
|
||||
Reference in New Issue
Block a user