|
|
@ -10,6 +10,7 @@ const ConfigManager = require('./lib/config-manager') |
|
|
|
module.exports = class MetamaskController { |
|
|
|
module.exports = class MetamaskController { |
|
|
|
|
|
|
|
|
|
|
|
constructor (opts) { |
|
|
|
constructor (opts) { |
|
|
|
|
|
|
|
this.opts = opts |
|
|
|
this.configManager = new ConfigManager(opts) |
|
|
|
this.configManager = new ConfigManager(opts) |
|
|
|
this.idStore = new IdentityStore({ |
|
|
|
this.idStore = new IdentityStore({ |
|
|
|
configManager: this.configManager, |
|
|
|
configManager: this.configManager, |
|
|
@ -108,16 +109,16 @@ module.exports = class MetamaskController { |
|
|
|
var providerOpts = { |
|
|
|
var providerOpts = { |
|
|
|
rpcUrl: this.configManager.getCurrentRpcAddress(), |
|
|
|
rpcUrl: this.configManager.getCurrentRpcAddress(), |
|
|
|
// account mgmt
|
|
|
|
// account mgmt
|
|
|
|
getAccounts: function (cb) { |
|
|
|
getAccounts: (cb) => { |
|
|
|
var selectedAddress = idStore.getSelectedAddress() |
|
|
|
var selectedAddress = idStore.getSelectedAddress() |
|
|
|
var result = selectedAddress ? [selectedAddress] : [] |
|
|
|
var result = selectedAddress ? [selectedAddress] : [] |
|
|
|
cb(null, result) |
|
|
|
cb(null, result) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// tx signing
|
|
|
|
// tx signing
|
|
|
|
approveTransaction: this.newUnsignedTransaction, |
|
|
|
approveTransaction: this.newUnsignedTransaction.bind(this), |
|
|
|
signTransaction: idStore.signTransaction.bind(idStore), |
|
|
|
signTransaction: idStore.signTransaction.bind(idStore), |
|
|
|
// msg signing
|
|
|
|
// msg signing
|
|
|
|
approveMessage: this.newUnsignedMessage, |
|
|
|
approveMessage: this.newUnsignedMessage.bind(this), |
|
|
|
signMessage: idStore.signMessage.bind(idStore), |
|
|
|
signMessage: idStore.signMessage.bind(idStore), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|