txManager - depend on preferencesStore

feature/default_network_editable
kumavis 8 years ago
parent 0c6df24ecf
commit f08f40aee2
  1. 2
      app/scripts/metamask-controller.js
  2. 10
      app/scripts/transaction-manager.js
  3. 1
      test/unit/tx-manager-test.js

@ -72,8 +72,8 @@ module.exports = class MetamaskController extends EventEmitter {
this.txManager = new TxManager({
initState: initState.TransactionManager,
networkStore: this.networkStore,
preferencesStore: this.preferencesController.store,
txHistoryLimit: 40,
getSelectedAddress: this.preferencesController.getSelectedAddress.bind(this.preferencesController),
getNetwork: this.getNetworkState.bind(this),
signTransaction: this.keyringController.signTransaction.bind(this.keyringController),
provider: this.provider,

@ -17,9 +17,8 @@ module.exports = class TransactionManager extends EventEmitter {
}, opts.initState))
this.memStore = new ObservableStore({})
this.networkStore = opts.networkStore || new ObservableStore({})
this.preferencesStore = opts.preferencesStore || new ObservableStore({})
this.txHistoryLimit = opts.txHistoryLimit
this.getSelectedAddress = opts.getSelectedAddress
this.provider = opts.provider
this.blockTracker = opts.blockTracker
this.txProviderUtils = new TxProviderUtil(this.provider)
@ -27,10 +26,11 @@ module.exports = class TransactionManager extends EventEmitter {
this.signEthTx = opts.signTransaction
this.nonceLock = Semaphore(1)
// memstore is computed from diskStore
// memstore is computed from a few different stores
this._updateMemstore()
this.store.subscribe(() => this._updateMemstore() )
this.networkStore.subscribe(() => this._updateMemstore() )
this.preferencesStore.subscribe(() => this._updateMemstore() )
}
getState () {
@ -41,6 +41,10 @@ module.exports = class TransactionManager extends EventEmitter {
return this.networkStore.getState().network
}
getSelectedAddress () {
return this.preferencesStore.getState().selectedAddress
}
// Returns the tx list
getTxList () {
let network = this.getNetwork()

@ -14,7 +14,6 @@ describe('Transaction Manager', function() {
networkStore: new ObservableStore({ network: 'unit test' }),
txHistoryLimit: 10,
blockTracker: new EventEmitter(),
getSelectedAddress: function(){ return '0xabcd' },
})
})

Loading…
Cancel
Save