|
|
@ -1,18 +1,18 @@ |
|
|
|
const async = require('async') |
|
|
|
const async = require('async') |
|
|
|
const EventEmitter = require('events').EventEmitter |
|
|
|
|
|
|
|
const encryptor = require('./lib/encryptor') |
|
|
|
|
|
|
|
const messageManager = require('./lib/message-manager') |
|
|
|
|
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
const ethBinToOps = require('eth-bin-to-ops') |
|
|
|
const ethBinToOps = require('eth-bin-to-ops') |
|
|
|
const EthQuery = require('eth-query') |
|
|
|
const EthQuery = require('eth-query') |
|
|
|
const BN = ethUtil.BN |
|
|
|
const bip39 = require('bip39') |
|
|
|
const Transaction = require('ethereumjs-tx') |
|
|
|
const Transaction = require('ethereumjs-tx') |
|
|
|
|
|
|
|
const EventEmitter = require('events').EventEmitter |
|
|
|
|
|
|
|
|
|
|
|
const createId = require('web3-provider-engine/util/random-id') |
|
|
|
const createId = require('web3-provider-engine/util/random-id') |
|
|
|
|
|
|
|
const normalize = require('./lib/sig-util').normalize |
|
|
|
|
|
|
|
const encryptor = require('./lib/encryptor') |
|
|
|
|
|
|
|
const messageManager = require('./lib/message-manager') |
|
|
|
const autoFaucet = require('./lib/auto-faucet') |
|
|
|
const autoFaucet = require('./lib/auto-faucet') |
|
|
|
const bip39 = require('bip39') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TEMPORARY UNTIL FULL DEPRECATION:
|
|
|
|
|
|
|
|
const IdStoreMigrator = require('./lib/idStore-migrator') |
|
|
|
const IdStoreMigrator = require('./lib/idStore-migrator') |
|
|
|
|
|
|
|
const BN = ethUtil.BN |
|
|
|
|
|
|
|
|
|
|
|
// Keyrings:
|
|
|
|
// Keyrings:
|
|
|
|
const SimpleKeyring = require('./keyrings/simple') |
|
|
|
const SimpleKeyring = require('./keyrings/simple') |
|
|
@ -26,7 +26,6 @@ module.exports = class KeyringController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
constructor (opts) { |
|
|
|
constructor (opts) { |
|
|
|
super() |
|
|
|
super() |
|
|
|
this.web3 = opts.web3 |
|
|
|
|
|
|
|
this.configManager = opts.configManager |
|
|
|
this.configManager = opts.configManager |
|
|
|
this.ethStore = opts.ethStore |
|
|
|
this.ethStore = opts.ethStore |
|
|
|
this.encryptor = encryptor |
|
|
|
this.encryptor = encryptor |
|
|
@ -98,7 +97,7 @@ module.exports = class KeyringController extends EventEmitter { |
|
|
|
if (err) return cb(err) |
|
|
|
if (err) return cb(err) |
|
|
|
this.addNewKeyring('HD Key Tree', { |
|
|
|
this.addNewKeyring('HD Key Tree', { |
|
|
|
mnemonic: seed, |
|
|
|
mnemonic: seed, |
|
|
|
n: 1, |
|
|
|
numberOfAccounts: 1, |
|
|
|
}, (err) => { |
|
|
|
}, (err) => { |
|
|
|
if (err) return cb(err) |
|
|
|
if (err) return cb(err) |
|
|
|
const firstKeyring = this.keyrings[0] |
|
|
|
const firstKeyring = this.keyrings[0] |
|
|
@ -143,9 +142,7 @@ module.exports = class KeyringController extends EventEmitter { |
|
|
|
.then(() => { |
|
|
|
.then(() => { |
|
|
|
return this.persistAllKeyrings() |
|
|
|
return this.persistAllKeyrings() |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
.then(cb) |
|
|
|
cb(null) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch((err) => { |
|
|
|
.catch((err) => { |
|
|
|
cb(err) |
|
|
|
cb(err) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -153,7 +150,7 @@ module.exports = class KeyringController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
createFirstKeyTree (password, cb) { |
|
|
|
createFirstKeyTree (password, cb) { |
|
|
|
this.clearKeyrings() |
|
|
|
this.clearKeyrings() |
|
|
|
this.addNewKeyring('HD Key Tree', {n: 1}, (err) => { |
|
|
|
this.addNewKeyring('HD Key Tree', {numberOfAccounts: 1}, (err) => { |
|
|
|
const firstKeyring = this.keyrings[0] |
|
|
|
const firstKeyring = this.keyrings[0] |
|
|
|
const accounts = firstKeyring.getAccounts() |
|
|
|
const accounts = firstKeyring.getAccounts() |
|
|
|
const firstAccount = accounts[0] |
|
|
|
const firstAccount = accounts[0] |
|
|
@ -564,9 +561,4 @@ module.exports = class KeyringController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function normalize (address) { |
|
|
|
|
|
|
|
if (!address) return |
|
|
|
|
|
|
|
return ethUtil.addHexPrefix(address.toLowerCase()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function noop () {} |
|
|
|
function noop () {} |
|
|
|