|
|
@ -42,8 +42,8 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
this.configManager.updateConversionRate() |
|
|
|
this.configManager.updateConversionRate() |
|
|
|
|
|
|
|
|
|
|
|
// preferences controller
|
|
|
|
// preferences controller
|
|
|
|
this.prefencesController = new PreferencesController({ |
|
|
|
this.preferencesController = new PreferencesController({ |
|
|
|
initState: initState.PrefencesController, |
|
|
|
initState: initState.PreferencesController, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// rpc provider
|
|
|
|
// rpc provider
|
|
|
@ -71,7 +71,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
txList: this.configManager.getTxList(), |
|
|
|
txList: this.configManager.getTxList(), |
|
|
|
txHistoryLimit: 40, |
|
|
|
txHistoryLimit: 40, |
|
|
|
setTxList: this.configManager.setTxList.bind(this.configManager), |
|
|
|
setTxList: this.configManager.setTxList.bind(this.configManager), |
|
|
|
getSelectedAccount: this.keyringController.getSelectedAccount.bind(this.keyringController), |
|
|
|
getSelectedAccount: this.preferencesController.getSelectedAccount.bind(this.preferencesController), |
|
|
|
getGasMultiplier: this.configManager.getGasMultiplier.bind(this.configManager), |
|
|
|
getGasMultiplier: this.configManager.getGasMultiplier.bind(this.configManager), |
|
|
|
getNetwork: this.getStateNetwork.bind(this), |
|
|
|
getNetwork: this.getStateNetwork.bind(this), |
|
|
|
signTransaction: this.keyringController.signTransaction.bind(this.keyringController), |
|
|
|
signTransaction: this.keyringController.signTransaction.bind(this.keyringController), |
|
|
@ -107,8 +107,8 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
this.keyringController.store.subscribe((state) => { |
|
|
|
this.keyringController.store.subscribe((state) => { |
|
|
|
this.store.updateState({ KeyringController: state }) |
|
|
|
this.store.updateState({ KeyringController: state }) |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.prefencesController.store.subscribe((state) => { |
|
|
|
this.preferencesController.store.subscribe((state) => { |
|
|
|
this.store.updateState({ PrefencesController: state }) |
|
|
|
this.store.updateState({ PreferencesController: state }) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -125,7 +125,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
rpcUrl: this.configManager.getCurrentRpcAddress(), |
|
|
|
rpcUrl: this.configManager.getCurrentRpcAddress(), |
|
|
|
// account mgmt
|
|
|
|
// account mgmt
|
|
|
|
getAccounts: (cb) => { |
|
|
|
getAccounts: (cb) => { |
|
|
|
let selectedAccount = this.keyringController.getSelectedAccount() |
|
|
|
let selectedAccount = this.preferencesController.getSelectedAccount() |
|
|
|
let result = selectedAccount ? [selectedAccount] : [] |
|
|
|
let result = selectedAccount ? [selectedAccount] : [] |
|
|
|
cb(null, result) |
|
|
|
cb(null, result) |
|
|
|
}, |
|
|
|
}, |
|
|
@ -191,6 +191,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
getApi () { |
|
|
|
getApi () { |
|
|
|
const keyringController = this.keyringController |
|
|
|
const keyringController = this.keyringController |
|
|
|
|
|
|
|
const preferencesController = this.preferencesController |
|
|
|
const txManager = this.txManager |
|
|
|
const txManager = this.txManager |
|
|
|
const noticeController = this.noticeController |
|
|
|
const noticeController = this.noticeController |
|
|
|
|
|
|
|
|
|
|
@ -221,12 +222,14 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
// vault management
|
|
|
|
// vault management
|
|
|
|
submitPassword: this.submitPassword.bind(this), |
|
|
|
submitPassword: this.submitPassword.bind(this), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PreferencesController
|
|
|
|
|
|
|
|
setSelectedAccount: nodeify(preferencesController.setSelectedAccount).bind(preferencesController), |
|
|
|
|
|
|
|
|
|
|
|
// KeyringController
|
|
|
|
// KeyringController
|
|
|
|
setLocked: nodeify(keyringController.setLocked).bind(keyringController), |
|
|
|
setLocked: nodeify(keyringController.setLocked).bind(keyringController), |
|
|
|
createNewVaultAndKeychain: nodeify(keyringController.createNewVaultAndKeychain).bind(keyringController), |
|
|
|
createNewVaultAndKeychain: nodeify(keyringController.createNewVaultAndKeychain).bind(keyringController), |
|
|
|
createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore).bind(keyringController), |
|
|
|
createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore).bind(keyringController), |
|
|
|
addNewKeyring: nodeify(keyringController.addNewKeyring).bind(keyringController), |
|
|
|
addNewKeyring: nodeify(keyringController.addNewKeyring).bind(keyringController), |
|
|
|
setSelectedAccount: nodeify(keyringController.setSelectedAccount).bind(keyringController), |
|
|
|
|
|
|
|
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController), |
|
|
|
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController), |
|
|
|
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController), |
|
|
|
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController), |
|
|
|
|
|
|
|
|
|
|
@ -339,7 +342,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
// ensuring they are only ever available in the background process.
|
|
|
|
// ensuring they are only ever available in the background process.
|
|
|
|
clearSeedWordCache (cb) { |
|
|
|
clearSeedWordCache (cb) { |
|
|
|
this.configManager.setSeedWords(null) |
|
|
|
this.configManager.setSeedWords(null) |
|
|
|
cb(null, this.keyringController.getSelectedAccount()) |
|
|
|
cb(null, this.preferencesController.getSelectedAccount()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
importAccountWithStrategy (strategy, args, cb) { |
|
|
|
importAccountWithStrategy (strategy, args, cb) { |
|
|
@ -348,7 +351,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ]) |
|
|
|
return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ]) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(keyring => keyring.getAccounts()) |
|
|
|
.then(keyring => keyring.getAccounts()) |
|
|
|
.then((accounts) => this.keyringController.setSelectedAccount(accounts[0])) |
|
|
|
.then((accounts) => this.preferencesController.setSelectedAccount(accounts[0])) |
|
|
|
.then(() => { cb(null, this.keyringController.fullUpdate()) }) |
|
|
|
.then(() => { cb(null, this.keyringController.fullUpdate()) }) |
|
|
|
.catch((reason) => { cb(reason) }) |
|
|
|
.catch((reason) => { cb(reason) }) |
|
|
|
} |
|
|
|
} |
|
|
|