@binance-chain/bsc-ledger-bridge-keyring
Advanced tools
Comparing version 0.2.12 to 0.2.13
31
index.js
@@ -162,3 +162,3 @@ const { EventEmitter } = require('events') | ||
// tx is an instance of the ethereumjs-transaction class. | ||
signTransaction (address, tx, accountIndex = 0) { | ||
signTransaction (address, tx) { | ||
return new Promise((resolve, reject) => { | ||
@@ -172,3 +172,13 @@ this.unlock().then((_) => { | ||
if (this._isBIP44()) { | ||
hdPath = this._getPathForIndex(accountIndex) | ||
const checksummedAddress = ethUtil.toChecksumAddress(address) | ||
if (!Object.keys(this.accountIndexes).includes(checksummedAddress)) { | ||
reject( | ||
new Error( | ||
`Ledger: Index for address '${checksummedAddress}' not found`, | ||
), | ||
) | ||
} | ||
hdPath = this._getPathForIndex( | ||
this.accountIndexes[checksummedAddress], | ||
) | ||
} else { | ||
@@ -215,3 +225,3 @@ hdPath = this._toLedgerPath(this._pathFromAddress(address)) | ||
// For personal_sign, we need to prefix the message: | ||
signPersonalMessage (withAccount, message, accountIndex = 0) { | ||
signPersonalMessage (withAccount, message) { | ||
return new Promise((resolve, reject) => { | ||
@@ -221,3 +231,13 @@ this.unlock().then((_) => { | ||
if (this._isBIP44()) { | ||
hdPath = this._getPathForIndex(accountIndex) | ||
const checksummedAddress = ethUtil.toChecksumAddress(withAccount) | ||
if (!Object.keys(this.accountIndexes).includes(checksummedAddress)) { | ||
reject( | ||
new Error( | ||
`Ledger: Index for address '${checksummedAddress}' not found`, | ||
), | ||
) | ||
} | ||
hdPath = this._getPathForIndex( | ||
this.accountIndexes[checksummedAddress], | ||
) | ||
} else { | ||
@@ -331,2 +351,5 @@ hdPath = this._toLedgerPath(this._pathFromAddress(withAccount)) | ||
accounts = await this._getAccountsBIP44(from, to) | ||
accounts.forEach((address, index) => { | ||
this.accountIndexes[ethUtil.toChecksumAddress(address)] = from + index | ||
}) | ||
} else { | ||
@@ -333,0 +356,0 @@ accounts = this._getAccountsLegacy(from, to) |
{ | ||
"name": "@binance-chain/bsc-ledger-bridge-keyring", | ||
"version": "0.2.12", | ||
"version": "0.2.13", | ||
"description": "A MetaMask compatible keyring, for ledger hardware wallets", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
15038
431