diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-11-12 02:26:12 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-11-12 02:26:12 +0800 |
commit | 23263bec7d5100accd61f7648fd9355fc95e2bb7 (patch) | |
tree | 3c24f23655b5e1aad7102b603412d6fae70d5e43 /app/scripts/keyrings/hd.js | |
parent | c664b8f11e32eaa7f8f1b46d4be938f2ebb74d35 (diff) | |
download | tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.gz tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.bz2 tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.lz tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.xz tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.zst tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.zip |
Linting to the max.
Diffstat (limited to 'app/scripts/keyrings/hd.js')
-rw-r--r-- | app/scripts/keyrings/hd.js | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js index 4bfc56c15..6df78555d 100644 --- a/app/scripts/keyrings/hd.js +++ b/app/scripts/keyrings/hd.js @@ -9,17 +9,17 @@ const hdPathString = `m/44'/60'/0'/0` module.exports = class HdKeyring extends EventEmitter { - static type() { + static type () { return type } - constructor(opts = {}) { + constructor (opts = {}) { super() this.type = type this.deserialize(opts) } - deserialize(opts = {}) { + deserialize (opts = {}) { this.opts = opts || {} this.wallets = [] this.mnemonic = null @@ -34,26 +34,26 @@ module.exports = class HdKeyring extends EventEmitter { } } - initFromMnemonic(mnemonic) { + initFromMnemonic (mnemonic) { this.mnemonic = mnemonic const seed = bip39.mnemonicToSeed(mnemonic) this.hdWallet = hdkey.fromMasterSeed(seed) this.root = this.hdWallet.derivePath(hdPathString) } - serialize() { + serialize () { return { mnemonic: this.mnemonic, n: this.wallets.length, } } - exportAccount(address) { + exportAccount (address) { const wallet = this.getWalletForAccount(address) return wallet.getPrivateKey().toString('hex') } - addAccounts(n = 1) { + addAccounts (n = 1) { if (!this.root) { this.initFromMnemonic(bip39.generateMnemonic()) } @@ -69,12 +69,12 @@ module.exports = class HdKeyring extends EventEmitter { return newWallets.map(w => w.getAddress().toString('hex')) } - getAccounts() { + getAccounts () { return this.wallets.map(w => w.getAddress().toString('hex')) } // tx is an instance of the ethereumjs-transaction class. - signTransaction(address, tx) { + signTransaction (address, tx) { const wallet = this.getWalletForAccount(address) var privKey = wallet.getPrivateKey() tx.sign(privKey) @@ -82,7 +82,7 @@ module.exports = class HdKeyring extends EventEmitter { } // For eth_sign, we need to sign transactions: - signMessage(withAccount, data) { + signMessage (withAccount, data) { const wallet = this.getWalletForAccount(withAccount) const message = ethUtil.removeHexPrefix(data) var privKey = wallet.getPrivateKey() @@ -91,17 +91,14 @@ module.exports = class HdKeyring extends EventEmitter { return rawMsgSig } - getWalletForAccount(account) { + getWalletForAccount (account) { return this.wallets.find((w) => { const address = w.getAddress().toString('hex') return ((address === account) || (normalize(address) === account)) }) } - - - } -function normalize(address) { +function normalize (address) { return ethUtil.addHexPrefix(address.toLowerCase()) } |