Fix ledger signing (#1473)

* Fix sign message not returning

* Remove unused bufferToHex

* trigger mycryptobuild
This commit is contained in:
HenryNguyen5 2018-04-09 13:15:57 -04:00 committed by Daniel Ternyak
parent f9e59fdd73
commit 05a751b1f3
1 changed files with 9 additions and 21 deletions

View File

@ -1,6 +1,6 @@
import ledger from 'ledgerco'; import ledger from 'ledgerco';
import EthTx, { TxObj } from 'ethereumjs-tx'; import EthTx, { TxObj } from 'ethereumjs-tx';
import { addHexPrefix, bufferToHex, toBuffer } from 'ethereumjs-util'; import { addHexPrefix, toBuffer } from 'ethereumjs-util';
import { DeterministicWallet } from './deterministic'; import { DeterministicWallet } from './deterministic';
import { getTransactionFields } from 'libs/transaction'; import { getTransactionFields } from 'libs/transaction';
import { IFullWallet } from '../IWallet'; import { IFullWallet } from '../IWallet';
@ -46,28 +46,16 @@ export class LedgerWallet extends DeterministicWallet implements IFullWallet {
// modeled after // modeled after
// https://github.com/kvhnuke/etherwallet/blob/3f7ff809e5d02d7ea47db559adaca1c930025e24/app/scripts/controllers/signMsgCtrl.js#L53 // https://github.com/kvhnuke/etherwallet/blob/3f7ff809e5d02d7ea47db559adaca1c930025e24/app/scripts/controllers/signMsgCtrl.js#L53
public signMessage(msg: string): Promise<string> { public async signMessage(msg: string): Promise<string> {
const msgHex = Buffer.from(msg).toString('hex'); const msgHex = Buffer.from(msg).toString('hex');
return new Promise((resolve, reject) => {
this.ethApp.signPersonalMessage_async(
this.getPath(),
msgHex,
async (signed: any, error: any) => {
if (error) {
return reject((this.ethApp as any).getError(error));
}
try { try {
const combined = signed.r + signed.s + signed.v; const signed = await this.ethApp.signPersonalMessage_async(this.getPath(), msgHex);
resolve(bufferToHex(combined)); const combined = addHexPrefix(signed.r + signed.s + signed.v.toString(16));
} catch (err) { return combined;
reject(err); } catch (error) {
throw (this.ethApp as any).getError(error);
} }
} }
);
});
}
public displayAddress = ( public displayAddress = (
dPath?: string, dPath?: string,