pull/1/head
yann300 7 years ago
parent 9ebde45285
commit 93bc2a54ce
  1. 4
      src/app.js
  2. 21
      src/app/txListener.js

@ -851,7 +851,7 @@ function run () {
// ----------------- Tx listener -----------------
var txlistener = new Txlistener({
appAPI: {
api: {
web3: function () { return executionContext.web3() },
isVM: function () { return executionContext.isVM() },
vm: function () { return executionContext.vm() },
@ -865,7 +865,7 @@ function run () {
return executionContext.getProvider()
}
},
appEvent: {
event: {
executionContext: executionContext.event,
udapp: udapp.event
}

@ -17,19 +17,19 @@ var Web3VMProvider = remix.web3.web3VMProvider
class TxListener {
constructor (opt) {
this.event = new EventManager()
this._appAPI = opt.appAPI
this._api = opt.api
this._web3VMProvider = new Web3VMProvider() // TODO this should maybe be put in app.js
this._web3VMProvider.setVM(opt.appAPI.vm())
this._web3VMProvider.setVM(opt.api.vm())
this._resolvedTransactions = {}
this._resolvedContracts = {}
this.init()
opt.appEvent.executionContext.register('contextChanged', (context) => {
opt.event.executionContext.register('contextChanged', (context) => {
if (this.loopId) {
this.startListening(context)
}
})
opt.appEvent.udapp.register('transactionExecuted', (to, data, lookupOnly, txResult) => {
if (this.loopId && this._appAPI.isVM()) {
opt.event.udapp.register('transactionExecuted', (to, data, lookupOnly, txResult) => {
if (this.loopId && this._api.isVM()) {
this._web3VMProvider.getTransaction(txResult.transactionHash, (error, tx) => {
if (error) return console.log(error)
this._newBlock({
@ -59,15 +59,15 @@ class TxListener {
startListening () {
this.stopListening()
this.init()
if (this._appAPI.context() === 'vm') {
if (this._api.context() === 'vm') {
this.loopId = 'vm-listener'
} else {
this.loopId = setInterval(() => {
this._appAPI.web3().eth.getBlockNumber((error, blockNumber) => {
this._api.web3().eth.getBlockNumber((error, blockNumber) => {
if (error) return console.log(error)
if (!this.lastBlock || blockNumber > this.lastBlock) {
this.lastBlock = blockNumber
this._appAPI.web3().eth.getBlock(this.lastBlock, true, (error, result) => {
this._api.web3().eth.getBlock(this.lastBlock, true, (error, result) => {
if (!error) {
this._newBlock(Object.assign({type: 'web3'}, result))
}
@ -79,7 +79,7 @@ class TxListener {
}
currentWeb3 () { // TODO this should maybe be put in app.js
return this._appAPI.isVM() ? this._web3VMProvider : this._appAPI.web3()
return this._api.isVM() ? this._web3VMProvider : this._api.web3()
}
/**
@ -131,7 +131,7 @@ class TxListener {
}
_resolveTx (tx, cb) {
var contracts = this._appAPI.contracts()
var contracts = this._api.contracts()
if (!contracts) return cb()
var contractName
if (!tx.to) {
@ -240,7 +240,6 @@ class TxListener {
}
}
// those function will be duplicate after the merged of the compile and run tabs split
function getConstructorInterface (abi) {
var funABI = { 'name': '', 'inputs': [], 'type': 'constructor', 'outputs': [] }

Loading…
Cancel
Save