aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-27 13:19:09 +0800
committerkumavis <aaron@kumavis.me>2017-01-27 13:19:09 +0800
commitfc1b11e373851ad4ab3a3f74e7d6850aebe6ba82 (patch)
treec198d15384600991a10b1b8eb05042cf9a4754ec /app
parent832772414e8dba08e0fcfefea59a4e24b1f4a0d3 (diff)
downloadtangerine-wallet-browser-fc1b11e373851ad4ab3a3f74e7d6850aebe6ba82.tar
tangerine-wallet-browser-fc1b11e373851ad4ab3a3f74e7d6850aebe6ba82.tar.gz
tangerine-wallet-browser-fc1b11e373851ad4ab3a3f74e7d6850aebe6ba82.tar.bz2
tangerine-wallet-browser-fc1b11e373851ad4ab3a3f74e7d6850aebe6ba82.tar.lz
tangerine-wallet-browser-fc1b11e373851ad4ab3a3f74e7d6850aebe6ba82.tar.xz
tangerine-wallet-browser-fc1b11e373851ad4ab3a3f74e7d6850aebe6ba82.tar.zst
tangerine-wallet-browser-fc1b11e373851ad4ab3a3f74e7d6850aebe6ba82.zip
metamask - organize into sections
Diffstat (limited to 'app')
-rw-r--r--app/scripts/metamask-controller.js110
1 files changed, 61 insertions, 49 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index ec5fd498b..841e35db2 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -98,6 +98,63 @@ module.exports = class MetamaskController extends EventEmitter {
this.txManager.on('update', this.sendUpdate.bind(this))
}
+ //
+ // Constructor helpers
+ //
+
+ initializeProvider () {
+ let provider = MetaMaskProvider({
+ static: {
+ eth_syncing: false,
+ web3_clientVersion: `MetaMask/v${version}`,
+ },
+ rpcUrl: this.configManager.getCurrentRpcAddress(),
+ // account mgmt
+ getAccounts: (cb) => {
+ let selectedAccount = this.configManager.getSelectedAccount()
+ let result = selectedAccount ? [selectedAccount] : []
+ cb(null, result)
+ },
+ // tx signing
+ processTransaction: (txParams, cb) => this.newUnapprovedTransaction(txParams, cb),
+ // msg signing
+ approveMessage: this.newUnsignedMessage.bind(this),
+ signMessage: (...args) => {
+ this.keyringController.signMessage(...args)
+ this.sendUpdate()
+ },
+ })
+ return provider
+ }
+
+ initPublicConfigStore () {
+ // get init state
+ const publicConfigStore = new ObservableStore()
+
+ // sync publicConfigStore with transform
+ pipe(
+ this.store,
+ storeTransform(selectPublicState),
+ publicConfigStore
+ )
+
+ function selectPublicState(state) {
+ const result = { selectedAccount: undefined }
+ try {
+ result.selectedAccount = state.config.selectedAccount
+ } catch (_) {
+ // thats fine, im sure it will be there next time...
+ }
+ return result
+ }
+
+ return publicConfigStore
+ }
+
+ //
+ // Constructor helpers
+ //
+
getState () {
return this.keyringController.getState()
.then((keyringControllerState) => {
@@ -114,6 +171,10 @@ module.exports = class MetamaskController extends EventEmitter {
})
}
+ //
+ // Remote Features
+ //
+
getApi () {
const keyringController = this.keyringController
const txManager = this.txManager
@@ -253,55 +314,6 @@ module.exports = class MetamaskController extends EventEmitter {
})
}
- initializeProvider () {
- let provider = MetaMaskProvider({
- static: {
- eth_syncing: false,
- web3_clientVersion: `MetaMask/v${version}`,
- },
- rpcUrl: this.configManager.getCurrentRpcAddress(),
- // account mgmt
- getAccounts: (cb) => {
- let selectedAccount = this.configManager.getSelectedAccount()
- let result = selectedAccount ? [selectedAccount] : []
- cb(null, result)
- },
- // tx signing
- processTransaction: (txParams, cb) => this.newUnapprovedTransaction(txParams, cb),
- // msg signing
- approveMessage: this.newUnsignedMessage.bind(this),
- signMessage: (...args) => {
- this.keyringController.signMessage(...args)
- this.sendUpdate()
- },
- })
- return provider
- }
-
- initPublicConfigStore () {
- // get init state
- const publicConfigStore = new ObservableStore()
-
- // sync publicConfigStore with transform
- pipe(
- this.store,
- storeTransform(selectPublicState),
- publicConfigStore
- )
-
- function selectPublicState(state) {
- const result = { selectedAccount: undefined }
- try {
- result.selectedAccount = state.config.selectedAccount
- } catch (_) {
- // thats fine, im sure it will be there next time...
- }
- return result
- }
-
- return publicConfigStore
- }
-
newUnapprovedTransaction (txParams, cb) {
const self = this
self.txManager.addUnapprovedTransaction(txParams, (err, txMeta) => {