aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyrings
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-11-12 02:26:12 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-11-12 02:26:12 +0800
commit23263bec7d5100accd61f7648fd9355fc95e2bb7 (patch)
tree3c24f23655b5e1aad7102b603412d6fae70d5e43 /app/scripts/keyrings
parentc664b8f11e32eaa7f8f1b46d4be938f2ebb74d35 (diff)
downloadtangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.gz
tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.zst
tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.zip
Linting to the max.
Diffstat (limited to 'app/scripts/keyrings')
-rw-r--r--app/scripts/keyrings/hd.js27
-rw-r--r--app/scripts/keyrings/simple.js19
2 files changed, 21 insertions, 25 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())
}
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js
index 9e832f274..ee743bc03 100644
--- a/app/scripts/keyrings/simple.js
+++ b/app/scripts/keyrings/simple.js
@@ -6,22 +6,22 @@ const sigUtil = require('../lib/sig-util')
module.exports = class SimpleKeyring extends EventEmitter {
- static type() {
+ static type () {
return type
}
- constructor(opts) {
+ constructor (opts) {
super()
this.type = type
this.opts = opts || {}
this.wallets = []
}
- serialize() {
+ serialize () {
return this.wallets.map(w => w.getPrivateKey().toString('hex'))
}
- deserialize(wallets = []) {
+ deserialize (wallets = []) {
this.wallets = wallets.map((w) => {
var b = new Buffer(w, 'hex')
const wallet = Wallet.fromPrivateKey(b)
@@ -29,7 +29,7 @@ module.exports = class SimpleKeyring extends EventEmitter {
})
}
- addAccounts(n = 1) {
+ addAccounts (n = 1) {
var newWallets = []
for (var i = 0; i < n; i++) {
newWallets.push(Wallet.generate())
@@ -38,12 +38,12 @@ module.exports = class SimpleKeyring 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)
@@ -51,7 +51,7 @@ module.exports = class SimpleKeyring 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()
@@ -60,9 +60,8 @@ module.exports = class SimpleKeyring extends EventEmitter {
return rawMsgSig
}
- getWalletForAccount(account) {
+ getWalletForAccount (account) {
return this.wallets.find(w => w.getAddress().toString('hex') === account)
}
}
-