This commit is contained in:
maciejhirsz 2017-04-04 11:49:36 +02:00
parent 50e0221dd1
commit 94bfe116aa
6 changed files with 10 additions and 10 deletions

View File

@ -39,7 +39,8 @@ export default class Accounts {
create (secret, password) { create (secret, password) {
const privateKey = Buffer.from(secret.slice(2), 'hex'); const privateKey = Buffer.from(secret.slice(2), 'hex');
return Account.fromPrivateKey(this.persist, privateKey, password) return Account
.fromPrivateKey(this.persist, privateKey, password)
.then((account) => { .then((account) => {
const { address } = account; const { address } = account;
@ -87,7 +88,8 @@ export default class Accounts {
return false; return false;
} }
return account.isValidPassword(password) return account
.isValidPassword(password)
.then((isValid) => { .then((isValid) => {
if (!isValid) { if (!isValid) {
return false; return false;

View File

@ -22,7 +22,8 @@ export function createKeyObject (key, password) {
} }
export function decryptPrivateKey (keyObject, password) { export function decryptPrivateKey (keyObject, password) {
return workerPool.getWorker() return workerPool
.getWorker()
.action('decryptPrivateKey', { keyObject, password }) .action('decryptPrivateKey', { keyObject, password })
.then((privateKey) => { .then((privateKey) => {
if (privateKey) { if (privateKey) {

View File

@ -16,6 +16,7 @@
import secp256k1 from 'secp256k1/js'; import secp256k1 from 'secp256k1/js';
import { keccak_256 as keccak256 } from 'js-sha3'; import { keccak_256 as keccak256 } from 'js-sha3';
import { bytesToHex } from '~/api/util/format';
const isWorker = typeof self !== 'undefined'; 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 }) { self.onmessage = function ({ data }) {
const result = route(data); const result = route(data);

View File

@ -60,7 +60,8 @@ export default class LocalAccountsMiddleware extends Middleware {
register('parity_changePassword', ([address, oldPassword, newPassword]) => { register('parity_changePassword', ([address, oldPassword, newPassword]) => {
const account = accounts.get(address); const account = accounts.get(address);
return account.decryptPrivateKey(oldPassword) return account
.decryptPrivateKey(oldPassword)
.then((privateKey) => { .then((privateKey) => {
if (!privateKey) { if (!privateKey) {
return false; return false;

View File

@ -17,7 +17,7 @@
import { range } from 'lodash'; import { range } from 'lodash';
export function bytesToHex (bytes) { 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) { export function cleanupValue (value, type) {

View File

@ -60,7 +60,6 @@ describe('modals/CreateAccount/NewAccount', () => {
it('resets the accounts', () => { it('resets the accounts', () => {
expect(instance.state.accounts).to.be.null; expect(instance.state.accounts).to.be.null;
// expect(Object.keys(instance.state.accounts).length).to.equal(7);
}); });
it('resets the initial selected value', () => { it('resets the initial selected value', () => {