Skip to content

Commit

Permalink
let txlistener reads on the last compilation per file and not only th…
Browse files Browse the repository at this point in the history
…e last one
  • Loading branch information
yann300 committed Jun 17, 2020
1 parent 64b5a09 commit 4628ece
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/app/compiler/compiler-artefacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.compilerArtefacts['__last']) {
const contracts = this.compilersArtefacts['__last'].getContracts()
Object.keys(contracts).map((file) => { contractsData[file] = contracts[file] })
}
return contractsData
}

addResolvedContract (address, compilerData) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/udapp/make-udapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4628ece

Please sign in to comment.