Compare commits

..
4 Commits
Author SHA1 Message Date
Github Actions 72456bb2bd [CI Skip] release/stable 2.15.1
skip-checks: true
2020-06-22 09:33:14 +00:00
Jaco Greeff 87f3fd2827 2.15 (#621) 2020-06-22 11:29:33 +02:00
Github Actions 7254aab68d [CI Skip] release/beta 2.15.0-beta.0
skip-checks: true
2020-06-19 15:39:36 +00:00
Jaco Greeff 95d7160ad0 Test for 0 prefix (#620)
* Test for 0 prefix

* Add test for keyring encodeAddress (& fix)

* Test other branch of ?: check
2020-06-19 17:35:48 +02:00
10 changed files with 499 additions and 584 deletions
+4
View File
@@ -1,5 +1,9 @@
# CHANGELOG
## 2.15.1 Jun 22, 2020
- Adjust keyring to no override 0-prefix (Polkadot live) settings with keychain default
## 2.14.1 Jun 16, 2020
- Add `extractTime` utility conversion (Thanks to https://github.com/kwingram25)
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "2.14.1"
"version": "2.15.1"
}
+3 -3
View File
@@ -21,10 +21,10 @@
"test:one": "polkadot-dev-run-test"
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@polkadot/dev": "^0.55.10",
"@babel/core": "^7.10.3",
"@polkadot/dev": "^0.55.11",
"@polkadot/ts": "^0.3.26",
"@types/jest": "^26.0.0"
},
"version": "2.14.1"
"version": "2.15.1"
}
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/keyring",
"version": "2.14.1",
"version": "2.15.1",
"description": "Keyring management",
"main": "index.js",
"publishConfig": {
@@ -27,8 +27,8 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/util": "2.14.1",
"@polkadot/util-crypto": "2.14.1"
"@babel/runtime": "^7.10.3",
"@polkadot/util": "2.15.1",
"@polkadot/util-crypto": "2.15.1"
}
}
+20
View File
@@ -212,4 +212,24 @@ describe('keypair', (): void => {
expect(pair.verify(MESSAGE, signature)).toBe(true);
});
});
describe('util', (): void => {
let keyring: Keyring;
beforeEach((): void => {
keyring = new Keyring({ ss58Format: 42 });
});
it('can re-encode an address to Polkadot live', (): void => {
expect(
keyring.encodeAddress('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', 0)
).toEqual('15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5');
});
it('can re-encode an address to keyring default', (): void => {
expect(
keyring.encodeAddress('15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5')
).toEqual('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
});
});
});
+2 -2
View File
@@ -5,7 +5,7 @@
import { KeypairType, Keypair } from '@polkadot/util-crypto/types';
import { KeyringInstance, KeyringPair, KeyringPair$Json, KeyringPair$Meta, KeyringOptions } from './types';
import { assert, hexToU8a, isHex, stringToU8a } from '@polkadot/util';
import { assert, hexToU8a, isHex, isUndefined, stringToU8a } from '@polkadot/util';
import { decodeAddress, encodeAddress, keyExtractSuri, keyFromPath, naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, secp256k1KeypairFromSeed as secp256k1FromSeed, mnemonicToMiniSecret } from '@polkadot/util-crypto';
import { DEV_PHRASE } from './defaults';
@@ -192,7 +192,7 @@ export default class Keyring implements KeyringInstance {
* @description Encodes the input into an ss58 representation
*/
public encodeAddress = (address: Uint8Array | string, ss58Format?: number): string => {
return encodeAddress(address, ss58Format || this.#ss58);
return encodeAddress(address, isUndefined(ss58Format) ? this.#ss58 : ss58Format);
}
/**
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util-crypto",
"version": "2.14.1",
"version": "2.15.1",
"description": "A collection of useful crypto utilities for @polkadot",
"main": "index.js",
"keywords": [
@@ -25,15 +25,15 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/util": "2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/util": "2.15.1",
"@polkadot/wasm-crypto": "^1.2.1",
"base-x": "^3.0.8",
"bip39": "^3.0.2",
"blakejs": "^1.1.0",
"bn.js": "^5.1.2",
"bs58": "^4.0.1",
"elliptic": "^6.5.2",
"elliptic": "^6.5.3",
"js-sha3": "^0.8.0",
"pbkdf2": "^3.1.1",
"tweetnacl": "^1.0.3",
@@ -21,6 +21,12 @@ describe('encode', (): void => {
).toEqual('7sL6eNJj5ZGV5cn3hhV2deRUsivXfBfMH76wCALCqWj1EKzv');
});
it('can re-encode an address to Polkadot live', (): void => {
expect(
encode('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', 0)
).toEqual('15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5');
});
it('fails when non-valid publicKey provided', (): void => {
expect(
(): string => encode(
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util",
"version": "2.14.1",
"version": "2.15.1",
"description": "A collection of useful utilities for @polkadot",
"main": "index.js",
"keywords": [
@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@babel/runtime": "^7.10.3",
"@types/bn.js": "^4.11.6",
"bn.js": "^5.1.2",
"camelcase": "^5.3.1",
+453 -568
View File
File diff suppressed because it is too large Load Diff