From 227db66c96d64b4a4b07ea052ffe35b56706b44e Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Tue, 9 Apr 2019 17:04:59 +0200 Subject: [PATCH] Udapp listen on TxListener --- src/app.js | 1 + src/universal-dapp.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app.js b/src/app.js index c3c5694e1a..b7ae5a1a3f 100644 --- a/src/app.js +++ b/src/app.js @@ -355,6 +355,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org udapp: udapp.event }}) registry.put({api: txlistener, name: 'txlistener'}) + udapp.startListening(txlistener) const eventsDecoder = new EventsDecoder({ api: { diff --git a/src/universal-dapp.js b/src/universal-dapp.js index ca8ab12a5b..f5ab1a44ec 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -24,12 +24,8 @@ module.exports = class UniversalDApp extends UdappApi { this.events = new EventEmitter() this.event = new EventManager() this._deps = { - config: registry.get('config').api, - txlistener: registry.get('txlistener').api + config: registry.get('config').api } - this._deps.txlistener.event.register('newTransaction', (tx) => { - this.events.emit('newTransaction', tx) - }) this._txRunnerAPI = { config: this._deps.config, @@ -46,6 +42,14 @@ module.exports = class UniversalDApp extends UdappApi { executionContext.event.register('contextChanged', this.resetEnvironment.bind(this)) } + // TODO : event should be triggered by Udapp instead of TxListener + /** Listen on New Transaction. (Cannot be done inside constructor because txlistener doesn't exist yet) */ + startListening (txlistener) { + txlistener.event.register('newTransaction', (tx) => { + this.events.emit('newTransaction', tx) + }) + } + resetEnvironment () { this.accounts = {} if (executionContext.isVM()) {