diff --git a/apps/remix-ide/src/app/compiler/compiler-artefacts.js b/apps/remix-ide/src/app/compiler/compiler-artefacts.js index 3fcc312c2b..78a342391a 100644 --- a/apps/remix-ide/src/app/compiler/compiler-artefacts.js +++ b/apps/remix-ide/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/apps/remix-ide/src/app/udapp/make-udapp.js b/apps/remix-ide/src/app/udapp/make-udapp.js index 9b7a247f50..a5d3176edc 100644 --- a/apps/remix-ide/src/app/udapp/make-udapp.js +++ b/apps/remix-ide/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) {