|
|
@ -32,9 +32,6 @@ class LedgerKeyring extends EventEmitter { |
|
|
|
this.iframe.src = ORIGIN |
|
|
|
this.iframe.src = ORIGIN |
|
|
|
console.log('Injecting ledger iframe') |
|
|
|
console.log('Injecting ledger iframe') |
|
|
|
document.head.appendChild(this.iframe) |
|
|
|
document.head.appendChild(this.iframe) |
|
|
|
|
|
|
|
|
|
|
|
console.log('[LEDGER]: LEDGER FROM-IFRAME LISTENER READY') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sendMessage (msg, cb) { |
|
|
|
sendMessage (msg, cb) { |
|
|
@ -181,8 +178,6 @@ class LedgerKeyring extends EventEmitter { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
this.unlock() |
|
|
|
this.unlock() |
|
|
|
.then(_ => { |
|
|
|
.then(_ => { |
|
|
|
console.log('[LEDGER]: sending message ', 'ledger-sign-transaction') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.sendMessage({ |
|
|
|
this.sendMessage({ |
|
|
|
action: 'ledger-sign-transaction', |
|
|
|
action: 'ledger-sign-transaction', |
|
|
|
params: { |
|
|
|
params: { |
|
|
@ -196,12 +191,11 @@ class LedgerKeyring extends EventEmitter { |
|
|
|
gasLimit: this._normalize(tx.gasLimit), |
|
|
|
gasLimit: this._normalize(tx.gasLimit), |
|
|
|
gasPrice: this._normalize(tx.gasPrice), |
|
|
|
gasPrice: this._normalize(tx.gasPrice), |
|
|
|
}, |
|
|
|
}, |
|
|
|
path: this._pathFromAddress(address) |
|
|
|
path: this._pathFromAddress(address), |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
({action, success, payload}) => { |
|
|
|
({action, success, payload}) => { |
|
|
|
if (success) { |
|
|
|
if (success) { |
|
|
|
console.log('[LEDGER]: got tx signed!', payload.txData) |
|
|
|
|
|
|
|
const signedTx = new Transaction(payload.txData) |
|
|
|
const signedTx = new Transaction(payload.txData) |
|
|
|
// Validate that the signature matches the right address
|
|
|
|
// Validate that the signature matches the right address
|
|
|
|
const addressSignedWith = ethUtil.toChecksumAddress(`0x${signedTx.from.toString('hex')}`) |
|
|
|
const addressSignedWith = ethUtil.toChecksumAddress(`0x${signedTx.from.toString('hex')}`) |
|
|
@ -209,9 +203,6 @@ class LedgerKeyring extends EventEmitter { |
|
|
|
if (addressSignedWith !== correctAddress) { |
|
|
|
if (addressSignedWith !== correctAddress) { |
|
|
|
reject('signature doesnt match the right address') |
|
|
|
reject('signature doesnt match the right address') |
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('[LEDGER]: all good!', signedTx.toJSON()) |
|
|
|
|
|
|
|
console.log('[LEDGER]: signedTX', `0x${signedTx.serialize().toString('hex')}`) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resolve(signedTx) |
|
|
|
resolve(signedTx) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
reject(payload) |
|
|
|
reject(payload) |
|
|
@ -230,7 +221,6 @@ class LedgerKeyring extends EventEmitter { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
this.unlock() |
|
|
|
this.unlock() |
|
|
|
.then(_ => { |
|
|
|
.then(_ => { |
|
|
|
console.log('[LEDGER]: sending message ', 'ledger-sign-personal-message') |
|
|
|
|
|
|
|
this.sendMessage({ |
|
|
|
this.sendMessage({ |
|
|
|
action: 'ledger-sign-personal-message', |
|
|
|
action: 'ledger-sign-personal-message', |
|
|
|
params: { |
|
|
|
params: { |
|
|
|