aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyring-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/keyring-controller.js')
-rw-r--r--app/scripts/keyring-controller.js74
1 files changed, 37 insertions, 37 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 5d9dd51a4..b74d6cbfc 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -46,7 +46,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- getState() {
+ getState () {
const configManager = this.configManager
const address = configManager.getSelectedAccount()
const wallet = configManager.getWallet() // old style vault
@@ -72,18 +72,18 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- setStore(ethStore) {
+ setStore (ethStore) {
this.ethStore = ethStore
}
- createNewVaultAndKeychain(password, entropy, cb) {
+ createNewVaultAndKeychain (password, entropy, cb) {
this.createNewVault(password, entropy, (err) => {
if (err) return cb(err)
this.createFirstKeyTree(password, cb)
})
}
- createNewVaultAndRestore(password, seed, cb) {
+ createNewVaultAndRestore (password, seed, cb) {
if (typeof password !== 'string') {
return cb('Password must be text.')
}
@@ -114,7 +114,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- migrateAndGetKey(password) {
+ migrateAndGetKey (password) {
let key
const shouldMigrate = !!this.configManager.getWallet() && !this.configManager.getVault()
@@ -134,7 +134,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- createNewVault(password, entropy, cb) {
+ createNewVault (password, entropy, cb) {
const configManager = this.configManager
const salt = this.encryptor.generateSalt()
configManager.setSalt(salt)
@@ -151,7 +151,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- createFirstKeyTree(password, cb) {
+ createFirstKeyTree (password, cb) {
this.clearKeyrings()
this.addNewKeyring('HD Key Tree', {n: 1}, (err) => {
const firstKeyring = this.keyrings[0]
@@ -179,7 +179,7 @@ module.exports = class KeyringController extends EventEmitter {
this.configManager.setSeedWords(seedWords)
}
- submitPassword(password, cb) {
+ submitPassword (password, cb) {
this.migrateAndGetKey(password)
.then((key) => {
return this.unlockKeyrings(key)
@@ -196,7 +196,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- loadKey(password) {
+ loadKey (password) {
const salt = this.configManager.getSalt() || this.encryptor.generateSalt()
return this.encryptor.keyFromPassword(password + salt)
.then((key) => {
@@ -206,7 +206,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- addNewKeyring(type, opts, cb) {
+ addNewKeyring (type, opts, cb) {
const Keyring = this.getKeyringClassForType(type)
const keyring = new Keyring(opts)
const accounts = keyring.getAccounts()
@@ -222,7 +222,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- addNewAccount(keyRingNum = 0, cb) {
+ addNewAccount (keyRingNum = 0, cb) {
const ring = this.keyrings[keyRingNum]
const accounts = ring.addAccounts(1)
this.setupAccounts(accounts)
@@ -235,7 +235,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- setupAccounts(accounts) {
+ setupAccounts (accounts) {
var arr = accounts || this.getAccounts()
arr.forEach((account) => {
this.loadBalanceAndNickname(account)
@@ -244,13 +244,13 @@ module.exports = class KeyringController extends EventEmitter {
// Takes an account address and an iterator representing
// the current number of named accounts.
- loadBalanceAndNickname(account) {
+ loadBalanceAndNickname (account) {
const address = normalize(account)
this.ethStore.addAccount(address)
this.createNickname(address)
}
- createNickname(address) {
+ createNickname (address) {
const hexAddress = normalize(address)
var i = Object.keys(this.identities).length
const oldNickname = this.configManager.nicknameForWallet(address)
@@ -274,7 +274,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- persistAllKeyrings() {
+ persistAllKeyrings () {
const serialized = this.keyrings.map((k) => {
return {
type: k.type,
@@ -289,7 +289,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- unlockKeyrings(key) {
+ unlockKeyrings (key) {
const encryptedVault = this.configManager.getVault()
return this.encryptor.decryptWithKey(key, encryptedVault)
.then((vault) => {
@@ -298,7 +298,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- restoreKeyring(serialized) {
+ restoreKeyring (serialized) {
const { type, data } = serialized
const Keyring = this.getKeyringClassForType(type)
const keyring = new Keyring()
@@ -311,7 +311,7 @@ module.exports = class KeyringController extends EventEmitter {
return keyring
}
- getKeyringClassForType(type) {
+ getKeyringClassForType (type) {
const Keyring = this.keyringTypes.reduce((res, kr) => {
if (kr.type() === type) {
return kr
@@ -322,7 +322,7 @@ module.exports = class KeyringController extends EventEmitter {
return Keyring
}
- getAccounts() {
+ getAccounts () {
const keyrings = this.keyrings || []
return keyrings.map(kr => kr.getAccounts())
.reduce((res, arr) => {
@@ -330,13 +330,13 @@ module.exports = class KeyringController extends EventEmitter {
}, [])
}
- setSelectedAddress(address, cb) {
+ setSelectedAddress (address, cb) {
var addr = normalize(address)
this.configManager.setSelectedAccount(addr)
cb(null, addr)
}
- addUnconfirmedTransaction(txParams, onTxDoneCb, cb) {
+ addUnconfirmedTransaction (txParams, onTxDoneCb, cb) {
var self = this
const configManager = this.configManager
@@ -369,7 +369,7 @@ module.exports = class KeyringController extends EventEmitter {
], didComplete)
// perform static analyis on the target contract code
- function analyzeForDelegateCall(cb){
+ function analyzeForDelegateCall (cb) {
if (txParams.to) {
query.getCode(txParams.to, function (err, result) {
if (err) return cb(err)
@@ -388,8 +388,8 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- function estimateGas(cb){
- query.estimateGas(txParams, function(err, result){
+ function estimateGas (cb) {
+ query.estimateGas(txParams, function (err, result) {
if (err) return cb(err)
txData.estimatedGas = self.addGasBuffer(result)
cb()
@@ -406,7 +406,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- addUnconfirmedMessage(msgParams, cb) {
+ addUnconfirmedMessage (msgParams, cb) {
// create txData obj with parameters and meta data
var time = (new Date()).getTime()
var msgId = createId()
@@ -428,7 +428,7 @@ module.exports = class KeyringController extends EventEmitter {
return msgId
}
- approveTransaction(txId, cb) {
+ approveTransaction (txId, cb) {
const configManager = this.configManager
var approvalCb = this._unconfTxCbs[txId] || noop
@@ -441,7 +441,7 @@ module.exports = class KeyringController extends EventEmitter {
this.emit('update')
}
- cancelTransaction(txId, cb) {
+ cancelTransaction (txId, cb) {
const configManager = this.configManager
var approvalCb = this._unconfTxCbs[txId] || noop
@@ -456,7 +456,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- signTransaction(txParams, cb) {
+ signTransaction (txParams, cb) {
try {
const address = normalize(txParams.from)
const keyring = this.getKeyringForAccount(address)
@@ -492,7 +492,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- signMessage(msgParams, cb) {
+ signMessage (msgParams, cb) {
try {
const keyring = this.getKeyringForAccount(msgParams.from)
const address = normalize(msgParams.from)
@@ -503,7 +503,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- getKeyringForAccount(address) {
+ getKeyringForAccount (address) {
const hexed = normalize(address)
return this.keyrings.find((ring) => {
return ring.getAccounts()
@@ -512,19 +512,19 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- cancelMessage(msgId, cb) {
+ cancelMessage (msgId, cb) {
if (cb && typeof cb === 'function') {
cb()
}
}
- setLocked(cb) {
+ setLocked (cb) {
this.key = null
this.keyrings = []
cb()
}
- exportAccount(address, cb) {
+ exportAccount (address, cb) {
try {
const keyring = this.getKeyringForAccount(address)
const privateKey = keyring.exportAccount(normalize(address))
@@ -534,19 +534,19 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- addGasBuffer(gas) {
+ addGasBuffer (gas) {
const gasBuffer = new BN('100000', 10)
const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
const correct = bnGas.add(gasBuffer)
return ethUtil.addHexPrefix(correct.toString(16))
}
- clearSeedWordCache(cb) {
+ clearSeedWordCache (cb) {
this.configManager.setSeedWords(null)
cb(null, this.configManager.getSelectedAccount())
}
- clearKeyrings() {
+ clearKeyrings () {
let accounts
try {
accounts = Object.keys(this.ethStore._currentState.accounts)
@@ -564,7 +564,7 @@ module.exports = class KeyringController extends EventEmitter {
}
-function normalize(address) {
+function normalize (address) {
if (!address) return
return ethUtil.addHexPrefix(address.toLowerCase())
}