diff --git a/js/src/api/local/accounts/accounts.js b/js/src/api/local/accounts/accounts.js index 1bce1329a..e7e5cc397 100644 --- a/js/src/api/local/accounts/accounts.js +++ b/js/src/api/local/accounts/accounts.js @@ -39,7 +39,8 @@ export default class Accounts { create (secret, password) { const privateKey = Buffer.from(secret.slice(2), 'hex'); - return Account.fromPrivateKey(this.persist, privateKey, password) + return Account + .fromPrivateKey(this.persist, privateKey, password) .then((account) => { const { address } = account; @@ -87,7 +88,8 @@ export default class Accounts { return false; } - return account.isValidPassword(password) + return account + .isValidPassword(password) .then((isValid) => { if (!isValid) { return false; diff --git a/js/src/api/local/ethkey/index.js b/js/src/api/local/ethkey/index.js index 4539c8c50..a6967da25 100644 --- a/js/src/api/local/ethkey/index.js +++ b/js/src/api/local/ethkey/index.js @@ -22,7 +22,8 @@ export function createKeyObject (key, password) { } export function decryptPrivateKey (keyObject, password) { - return workerPool.getWorker() + return workerPool + .getWorker() .action('decryptPrivateKey', { keyObject, password }) .then((privateKey) => { if (privateKey) { diff --git a/js/src/api/local/ethkey/worker.js b/js/src/api/local/ethkey/worker.js index 3a0c34f7d..00f4a0bed 100644 --- a/js/src/api/local/ethkey/worker.js +++ b/js/src/api/local/ethkey/worker.js @@ -16,6 +16,7 @@ import secp256k1 from 'secp256k1/js'; import { keccak_256 as keccak256 } from 'js-sha3'; +import { bytesToHex } from '~/api/util/format'; const isWorker = typeof self !== 'undefined'; @@ -107,10 +108,6 @@ const actions = { } }; -function bytesToHex (bytes) { - return '0x' + Array.from(bytes).map(n => ('0' + n.toString(16)).slice(-2)).join(''); -} - self.onmessage = function ({ data }) { const result = route(data); diff --git a/js/src/api/local/middleware.js b/js/src/api/local/middleware.js index ece3fa17d..36a8cd2cf 100644 --- a/js/src/api/local/middleware.js +++ b/js/src/api/local/middleware.js @@ -60,7 +60,8 @@ export default class LocalAccountsMiddleware extends Middleware { register('parity_changePassword', ([address, oldPassword, newPassword]) => { const account = accounts.get(address); - return account.decryptPrivateKey(oldPassword) + return account + .decryptPrivateKey(oldPassword) .then((privateKey) => { if (!privateKey) { return false; diff --git a/js/src/api/util/format.js b/js/src/api/util/format.js index c7594b692..61fc9d32c 100644 --- a/js/src/api/util/format.js +++ b/js/src/api/util/format.js @@ -17,7 +17,7 @@ import { range } from 'lodash'; export function bytesToHex (bytes) { - return '0x' + bytes.map((b) => ('0' + b.toString(16)).slice(-2)).join(''); + return '0x' + Buffer.from(bytes).toString('hex'); } export function cleanupValue (value, type) { diff --git a/js/src/modals/CreateAccount/NewAccount/newAccount.spec.js b/js/src/modals/CreateAccount/NewAccount/newAccount.spec.js index d6d38779f..935fe5b80 100644 --- a/js/src/modals/CreateAccount/NewAccount/newAccount.spec.js +++ b/js/src/modals/CreateAccount/NewAccount/newAccount.spec.js @@ -60,7 +60,6 @@ describe('modals/CreateAccount/NewAccount', () => { it('resets the accounts', () => { expect(instance.state.accounts).to.be.null; - // expect(Object.keys(instance.state.accounts).length).to.equal(7); }); it('resets the initial selected value', () => {