From 0f9894efc642a6aee3f400968f78f89260fdbdbb Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 11 Jun 2020 14:40:25 +0200 Subject: [PATCH] let txlistener reads on the last compilation per file and not only the last one --- src/app/compiler/compiler-artefacts.js | 24 ++++++++++++++++++++++++ src/app/udapp/make-udapp.js | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/app/compiler/compiler-artefacts.js b/src/app/compiler/compiler-artefacts.js index 3fcc312c2b..78a342391a 100644 --- a/src/app/compiler/compiler-artefacts.js +++ b/src/app/compiler/compiler-artefacts.js @@ -14,28 +14,52 @@ module.exports = class CompilerArtefacts extends Plugin { constructor () { super(profile) this.compilersArtefacts = {} + this.compilersArtefactsPerFile = {} } clear () { this.compilersArtefacts = {} + this.compilersArtefactsPerFile = {} } onActivation () { + const saveCompilationPerFileResult = (file, source, languageVersion, data) => { + this.compilersArtefactsPerFile[file] = new CompilerAbstract(languageVersion, data, source) + } + this.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => { this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) + saveCompilationPerFileResult(file, source, languageVersion, data) }) this.on('vyper', 'compilationFinished', (file, source, languageVersion, data) => { this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) + saveCompilationPerFileResult(file, source, languageVersion, data) }) this.on('lexon', 'compilationFinished', (file, source, languageVersion, data) => { this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) + saveCompilationPerFileResult(file, source, languageVersion, data) }) this.on('yulp', 'compilationFinished', (file, source, languageVersion, data) => { this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) + saveCompilationPerFileResult(file, source, languageVersion, data) + }) + } + + getAllContractDatas () { + const contractsData = {} + Object.keys(this.compilersArtefactsPerFile).map((targetFile) => { + const contracts = this.compilersArtefactsPerFile[targetFile].getContracts() + Object.keys(contracts).map((file) => { contractsData[file] = contracts[file] }) }) + // making sure we shave last compilation result in there + if (this.compilersArtefacts['__last']) { + const contracts = this.compilersArtefacts['__last'].getContracts() + Object.keys(contracts).map((file) => { contractsData[file] = contracts[file] }) + } + return contractsData } addResolvedContract (address, compilerData) { diff --git a/src/app/udapp/make-udapp.js b/src/app/udapp/make-udapp.js index 9b7a247f50..a5d3176edc 100644 --- a/src/app/udapp/make-udapp.js +++ b/src/app/udapp/make-udapp.js @@ -32,7 +32,7 @@ export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) { const txlistener = blockchain.getTxListener({ api: { contracts: function () { - if (compilersArtefacts['__last']) return compilersArtefacts['__last'].getContracts() + if (compilersArtefacts['__last']) return compilersArtefacts.getAllContractDatas() return null }, resolveReceipt: function (tx, cb) {