aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-10-19 08:07:25 +0800
committerDan Finlay <dan@danfinlay.com>2017-10-19 08:07:25 +0800
commitbbe2c9f48dd617e0696db50a3113df920dcaa974 (patch)
treecde9e7a2cb61dcfa254a7651aa12441e5c63c0fb /app/scripts/metamask-controller.js
parentd89394a7c9a5139ed5708ce7022fbbe2809e612a (diff)
parent6eb27389579586dc06ce840444bcdb207707e0b2 (diff)
downloadtangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.gz
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.bz2
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.lz
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.xz
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.tar.zst
tangerine-wallet-browser-bbe2c9f48dd617e0696db50a3113df920dcaa974.zip
Merge remote-tracking branch 'origin/master' into i2348-SelectAccountOnNewVault
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js68
1 files changed, 33 insertions, 35 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 11a26df64..dd34cec97 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -81,24 +81,9 @@ module.exports = class MetamaskController extends EventEmitter {
})
this.blacklistController.scheduleUpdates()
- // rpc provider and block tracker
- this.networkController.initializeProvider({
- scaffold: {
- eth_syncing: false,
- web3_clientVersion: `MetaMask/v${version}`,
- },
- // account mgmt
- getAccounts: nodeify(this.getAccounts, this),
- // tx signing
- processTransaction: nodeify(this.newTransaction, this),
- // old style msg signing
- processMessage: this.newUnsignedMessage.bind(this),
- // personal_sign msg signing
- processPersonalMessage: this.newUnsignedPersonalMessage.bind(this),
- processTypedMessage: this.newUnsignedTypedMessage.bind(this),
- })
- this.provider = this.networkController.providerProxy
- this.blockTracker = this.networkController.blockTrackerProxy
+ // rpc provider
+ this.provider = this.initializeProvider()
+ this.blockTracker = this.provider._blockTracker
// eth data query tools
this.ethQuery = new EthQuery(this.provider)
@@ -229,6 +214,36 @@ module.exports = class MetamaskController extends EventEmitter {
// Constructor helpers
//
+ initializeProvider () {
+ const providerOpts = {
+ static: {
+ eth_syncing: false,
+ web3_clientVersion: `MetaMask/v${version}`,
+ },
+ // account mgmt
+ getAccounts: (cb) => {
+ const isUnlocked = this.keyringController.memStore.getState().isUnlocked
+ const result = []
+ const selectedAddress = this.preferencesController.getSelectedAddress()
+
+ // only show address if account is unlocked
+ if (isUnlocked && selectedAddress) {
+ result.push(selectedAddress)
+ }
+ cb(null, result)
+ },
+ // tx signing
+ processTransaction: nodeify(async (txParams) => await this.txController.newUnapprovedTransaction(txParams), this),
+ // old style msg signing
+ processMessage: this.newUnsignedMessage.bind(this),
+ // personal_sign msg signing
+ processPersonalMessage: this.newUnsignedPersonalMessage.bind(this),
+ processTypedMessage: this.newUnsignedTypedMessage.bind(this),
+ }
+ const providerProxy = this.networkController.initializeProvider(providerOpts)
+ return providerProxy
+ }
+
initPublicConfigStore () {
// get init state
const publicConfigStore = new ObservableStore()
@@ -476,18 +491,6 @@ module.exports = class MetamaskController extends EventEmitter {
// Opinionated Keyring Management
//
- async getAccounts () {
- const isUnlocked = this.keyringController.memStore.getState().isUnlocked
- const result = []
- const selectedAddress = this.preferencesController.getSelectedAddress()
-
- // only show address if account is unlocked
- if (isUnlocked && selectedAddress) {
- result.push(selectedAddress)
- }
- return result
- }
-
addNewAccount (cb) {
const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
if (!primaryKeyring) return cb(new Error('MetamaskController - No HD Key Tree found'))
@@ -534,11 +537,6 @@ module.exports = class MetamaskController extends EventEmitter {
// Identity Management
//
- // this function wrappper lets us pass the fn reference before txController is instantiated
- async newTransaction (txParams) {
- return await this.txController.newUnapprovedTransaction(txParams)
- }
-
newUnsignedMessage (msgParams, cb) {
const msgId = this.messageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()