From bfa947c8cc58ea4fb5fcf9946af2ad426613cf6c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 1 Jan 2020 11:34:46 -0500 Subject: [PATCH] listen to new transaction using blockchain abstraction instead of txlistener --- src/app/ui/txLogger.js | 2 +- src/blockchain/blockchain.js | 5 ++++- src/blockchain/universalDapp.js | 8 -------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/app/ui/txLogger.js b/src/app/ui/txLogger.js index 15c45f6982..bbdc73ed79 100644 --- a/src/app/ui/txLogger.js +++ b/src/app/ui/txLogger.js @@ -164,7 +164,7 @@ class TxLogger { } }) - this.txListener.event.register('newTransaction', (tx, receipt) => { + blockchain.event.register('newTransaction', (tx, receipt) => { log(this, tx, receipt) }) diff --git a/src/blockchain/blockchain.js b/src/blockchain/blockchain.js index 27d8378864..44d749eb17 100644 --- a/src/blockchain/blockchain.js +++ b/src/blockchain/blockchain.js @@ -266,7 +266,10 @@ class Blockchain { } startListening (txlistener) { - this.udapp.startListening(txlistener) + txlistener.event.register('newTransaction', (tx, receipt) => { + this.event.emit('newTransaction', tx, receipt) + this.udapp.events.emit('newTransaction', tx, receipt) // for plugin backwards compatibility + }) } runOrCallContractMethod (contractName, contractABI, funABI, value, address, params, lookupOnly, logMsg, logCallback, outputCb, callbacksInContext) { diff --git a/src/blockchain/universalDapp.js b/src/blockchain/universalDapp.js index 370dedbb54..ea28834529 100644 --- a/src/blockchain/universalDapp.js +++ b/src/blockchain/universalDapp.js @@ -33,14 +33,6 @@ class UniversalDApp { this.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 (this.executionContext.isVM()) {