From 618429c9f1602f240a7c0dca9676abb021c1d507 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 6 Aug 2018 14:38:08 +0200 Subject: [PATCH] Add lock() on pair, hasSecretKey -> isLocked (#187) --- lerna.json | 2 +- packages/trie-db/package.json | 10 +++++----- packages/trie-hash/package.json | 8 ++++---- packages/type-extrinsics/package.json | 8 ++++---- packages/type-jsonrpc/package.json | 4 ++-- packages/type-params/package.json | 8 ++++---- packages/type-primitives/package.json | 6 +++--- packages/type-storage/package.json | 12 ++++++------ packages/util-crypto/package.json | 4 ++-- packages/util-keyring/package.json | 6 +++--- packages/util-keyring/src/pair/index.ts | 5 ++++- packages/util-keyring/src/pair/nobody.ts | 5 ++++- packages/util-keyring/src/testing.ts | 6 +++++- packages/util-keyring/src/types.d.ts | 3 ++- packages/util-rlp/package.json | 4 ++-- packages/util/package.json | 2 +- 16 files changed, 52 insertions(+), 41 deletions(-) diff --git a/lerna.json b/lerna.json index f5d992fa3..9338d0e14 100644 --- a/lerna.json +++ b/lerna.json @@ -10,5 +10,5 @@ "packages": [ "packages/*" ], - "version": "0.26.36" + "version": "0.27.0" } diff --git a/packages/trie-db/package.json b/packages/trie-db/package.json index 1ac6e4453..b12ada047 100644 --- a/packages/trie-db/package.json +++ b/packages/trie-db/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/trie-db", - "version": "0.26.36", + "version": "0.27.0", "description": "This is an implementation of the modified merkle patricia tree as speficed in Ethereum's yellow paper, adpated for Polkadot.", "main": "index.js", "scripts": {}, @@ -27,10 +27,10 @@ "license": "MPL-2.0", "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/trie-hash": "^0.26.36", - "@polkadot/util": "^0.26.36", - "@polkadot/util-crypto": "^0.26.36", - "@polkadot/util-rlp": "^0.26.36", + "@polkadot/trie-hash": "^0.27.0", + "@polkadot/util": "^0.27.0", + "@polkadot/util-crypto": "^0.27.0", + "@polkadot/util-rlp": "^0.27.0", "@types/async": "^2.0.49", "@types/semaphore": "^1.1.0", "async": "^1.4.2", diff --git a/packages/trie-hash/package.json b/packages/trie-hash/package.json index dcb54596b..67723d2b4 100644 --- a/packages/trie-hash/package.json +++ b/packages/trie-hash/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/trie-hash", - "version": "0.26.36", + "version": "0.27.0", "description": "Creation of triehash values", "main": "index.js", "keywords": [ @@ -34,8 +34,8 @@ }, "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/util": "^0.26.36", - "@polkadot/util-crypto": "^0.26.36", - "@polkadot/util-rlp": "^0.26.36" + "@polkadot/util": "^0.27.0", + "@polkadot/util-crypto": "^0.27.0", + "@polkadot/util-rlp": "^0.27.0" } } diff --git a/packages/type-extrinsics/package.json b/packages/type-extrinsics/package.json index 655fce6cb..564b72776 100644 --- a/packages/type-extrinsics/package.json +++ b/packages/type-extrinsics/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/extrinsics", - "version": "0.26.36", + "version": "0.27.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -16,8 +16,8 @@ }, "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/params": "^0.26.36", - "@polkadot/primitives": "^0.26.36", - "@polkadot/util": "^0.26.36" + "@polkadot/params": "^0.27.0", + "@polkadot/primitives": "^0.27.0", + "@polkadot/util": "^0.27.0" } } diff --git a/packages/type-jsonrpc/package.json b/packages/type-jsonrpc/package.json index 81a481a32..559e9de0f 100644 --- a/packages/type-jsonrpc/package.json +++ b/packages/type-jsonrpc/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/jsonrpc", - "version": "0.26.36", + "version": "0.27.0", "description": "Method definitions for the Polkadot RPC layer", "main": "index.js", "engines": { @@ -34,7 +34,7 @@ "test": "echo \"Tests only available from root wrapper\"" }, "dependencies": { - "@polkadot/params": "^0.26.36", + "@polkadot/params": "^0.27.0", "babel-runtime": "^6.26.0" } } diff --git a/packages/type-params/package.json b/packages/type-params/package.json index 28f20fc5a..00de2f1f2 100644 --- a/packages/type-params/package.json +++ b/packages/type-params/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/params", - "version": "0.26.36", + "version": "0.27.0", "description": "Type defintions for parameters as passed in calls", "main": "index.js", "engines": { @@ -34,8 +34,8 @@ }, "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/extrinsics": "^0.26.36", - "@polkadot/primitives": "^0.26.36", - "@polkadot/util": "^0.26.36" + "@polkadot/extrinsics": "^0.27.0", + "@polkadot/primitives": "^0.27.0", + "@polkadot/util": "^0.27.0" } } diff --git a/packages/type-primitives/package.json b/packages/type-primitives/package.json index b90f53a30..89bd99050 100644 --- a/packages/type-primitives/package.json +++ b/packages/type-primitives/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/primitives", - "version": "0.26.36", + "version": "0.27.0", "description": "Type defintions for the Polkadot network", "main": "index.js", "engines": { @@ -34,8 +34,8 @@ }, "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/trie-hash": "^0.26.36", - "@polkadot/util": "^0.26.36" + "@polkadot/trie-hash": "^0.27.0", + "@polkadot/util": "^0.27.0" }, "devDependencies": { "bn.js": "^4.11.8" diff --git a/packages/type-storage/package.json b/packages/type-storage/package.json index 5d277121b..c93c27740 100644 --- a/packages/type-storage/package.json +++ b/packages/type-storage/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/storage", - "version": "0.26.36", + "version": "0.27.0", "description": "Generic wrapper wrapper around state storage", "main": "index.js", "engines": { @@ -35,10 +35,10 @@ }, "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/params": "^0.26.36", - "@polkadot/primitives": "^0.26.36", - "@polkadot/util": "^0.26.36", - "@polkadot/util-crypto": "^0.26.36", - "@polkadot/util-keyring": "^0.26.36" + "@polkadot/params": "^0.27.0", + "@polkadot/primitives": "^0.27.0", + "@polkadot/util": "^0.27.0", + "@polkadot/util-crypto": "^0.27.0", + "@polkadot/util-keyring": "^0.27.0" } } diff --git a/packages/util-crypto/package.json b/packages/util-crypto/package.json index 80ae91053..f98a02a00 100644 --- a/packages/util-crypto/package.json +++ b/packages/util-crypto/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-crypto", - "version": "0.26.36", + "version": "0.27.0", "description": "A collection of useful crypto utilities for @polkadot", "main": "index.js", "keywords": [ @@ -34,7 +34,7 @@ }, "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/util": "^0.26.36", + "@polkadot/util": "^0.27.0", "blakejs": "^1.1.0", "js-sha3": "^0.7.0", "tweetnacl": "^1.0.0", diff --git a/packages/util-keyring/package.json b/packages/util-keyring/package.json index 964c21127..c2b937df5 100644 --- a/packages/util-keyring/package.json +++ b/packages/util-keyring/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-keyring", - "version": "0.26.36", + "version": "0.27.0", "description": "Keyring management", "main": "index.js", "engines": { @@ -36,8 +36,8 @@ }, "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/util": "^0.26.36", - "@polkadot/util-crypto": "^0.26.36", + "@polkadot/util": "^0.27.0", + "@polkadot/util-crypto": "^0.27.0", "@types/bs58": "^3.0.30", "bs58": "^4.0.1" } diff --git a/packages/util-keyring/src/pair/index.ts b/packages/util-keyring/src/pair/index.ts index 14b463e8c..8e0067938 100644 --- a/packages/util-keyring/src/pair/index.ts +++ b/packages/util-keyring/src/pair/index.ts @@ -36,8 +36,11 @@ export default function pair ({ publicKey, secretKey }: KeypairType, meta: Keyri encode(secretKey, passphrase), getMeta: (): KeyringPair$Meta => getMeta(state), - hasSecretKey: (): boolean => + isLocked: (): boolean => !!(secretKey && secretKey.length !== 0), + lock: (): void => { + secretKey = new Uint8Array(0); + }, publicKey: (): Uint8Array => publicKey, setMeta: (meta: KeyringPair$Meta): void => diff --git a/packages/util-keyring/src/pair/nobody.ts b/packages/util-keyring/src/pair/nobody.ts index b33f027df..d6face3b8 100644 --- a/packages/util-keyring/src/pair/nobody.ts +++ b/packages/util-keyring/src/pair/nobody.ts @@ -32,8 +32,11 @@ export default function everybody (): KeyringPair { new Uint8Array(0), getMeta: (): KeyringPair$Meta => meta, - hasSecretKey: (): boolean => + isLocked: (): boolean => true, + lock: (): void => { + // no locking, it is always locked + }, publicKey: (): Uint8Array => publicKey, setMeta: (meta: KeyringPair$Meta): void => diff --git a/packages/util-keyring/src/testing.ts b/packages/util-keyring/src/testing.ts index 609e1a01b..ef51d00c6 100644 --- a/packages/util-keyring/src/testing.ts +++ b/packages/util-keyring/src/testing.ts @@ -38,10 +38,14 @@ export default function testKeyring (): KeyringInstance { Object .keys(SEEDS) .forEach((name) => { - keyring.addFromSeed(SEEDS[name], { + const pair = keyring.addFromSeed(SEEDS[name], { isTesting: true, name }); + + pair.lock = () => { + // we don't have lock/unlock functionality here + }; }); return keyring; diff --git a/packages/util-keyring/src/types.d.ts b/packages/util-keyring/src/types.d.ts index 06c7a9eb7..20e2004b6 100644 --- a/packages/util-keyring/src/types.d.ts +++ b/packages/util-keyring/src/types.d.ts @@ -22,7 +22,8 @@ export type KeyringPair = { decodePkcs8: (passphrase?: string, encoded?: Uint8Array) => void, encodePkcs8: (passphrase?: string) => Uint8Array, getMeta: () => KeyringPair$Meta, - hasSecretKey: () => boolean, + isLocked: () => boolean, + lock: () => void, publicKey: () => Uint8Array, setMeta: (meta: KeyringPair$Meta) => void, sign (message: Uint8Array): Uint8Array, diff --git a/packages/util-rlp/package.json b/packages/util-rlp/package.json index 54f4838c4..955b48f66 100644 --- a/packages/util-rlp/package.json +++ b/packages/util-rlp/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-rlp", - "version": "0.26.36", + "version": "0.27.0", "description": "RLP encoding and decoding", "main": "index.js", "keywords": [ @@ -36,7 +36,7 @@ }, "dependencies": { "@babel/runtime": "^7.0.0-beta.51", - "@polkadot/util": "^0.26.36" + "@polkadot/util": "^0.27.0" }, "devDependencies": { "ethereumjs-testing": "^1.0.4" diff --git a/packages/util/package.json b/packages/util/package.json index dfb4859bb..9f441e3b1 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util", - "version": "0.26.36", + "version": "0.27.0", "description": "A collection of useful utilities for @polkadot", "main": "index.js", "keywords": [