Fix ledger signing (#1473)
* Fix sign message not returning * Remove unused bufferToHex * trigger mycryptobuild
This commit is contained in:
parent
f9e59fdd73
commit
05a751b1f3
|
@ -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,27 +46,15 @@ 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');
|
||||||
|
try {
|
||||||
return new Promise((resolve, reject) => {
|
const signed = await this.ethApp.signPersonalMessage_async(this.getPath(), msgHex);
|
||||||
this.ethApp.signPersonalMessage_async(
|
const combined = addHexPrefix(signed.r + signed.s + signed.v.toString(16));
|
||||||
this.getPath(),
|
return combined;
|
||||||
msgHex,
|
} catch (error) {
|
||||||
async (signed: any, error: any) => {
|
throw (this.ethApp as any).getError(error);
|
||||||
if (error) {
|
}
|
||||||
return reject((this.ethApp as any).getError(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const combined = signed.r + signed.s + signed.v;
|
|
||||||
resolve(bufferToHex(combined));
|
|
||||||
} catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public displayAddress = (
|
public displayAddress = (
|
||||||
|
|
Loading…
Reference in New Issue