Commit af22ea3f authored by yann300's avatar yann300 Committed by ioedeveloper

let txlistener reads on the last compilation per file and not only the last one

parent 5473908f
...@@ -14,28 +14,52 @@ module.exports = class CompilerArtefacts extends Plugin { ...@@ -14,28 +14,52 @@ module.exports = class CompilerArtefacts extends Plugin {
constructor () { constructor () {
super(profile) super(profile)
this.compilersArtefacts = {} this.compilersArtefacts = {}
this.compilersArtefactsPerFile = {}
} }
clear () { clear () {
this.compilersArtefacts = {} this.compilersArtefacts = {}
this.compilersArtefactsPerFile = {}
} }
onActivation () { onActivation () {
const saveCompilationPerFileResult = (file, source, languageVersion, data) => {
this.compilersArtefactsPerFile[file] = new CompilerAbstract(languageVersion, data, source)
}
this.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => { this.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
}) })
this.on('vyper', 'compilationFinished', (file, source, languageVersion, data) => { this.on('vyper', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
}) })
this.on('lexon', 'compilationFinished', (file, source, languageVersion, data) => { this.on('lexon', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
}) })
this.on('yulp', 'compilationFinished', (file, source, languageVersion, data) => { this.on('yulp', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source) 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) { addResolvedContract (address, compilerData) {
......
...@@ -32,7 +32,7 @@ export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) { ...@@ -32,7 +32,7 @@ export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) {
const txlistener = blockchain.getTxListener({ const txlistener = blockchain.getTxListener({
api: { api: {
contracts: function () { contracts: function () {
if (compilersArtefacts['__last']) return compilersArtefacts['__last'].getContracts() if (compilersArtefacts['__last']) return compilersArtefacts.getAllContractDatas()
return null return null
}, },
resolveReceipt: function (tx, cb) { resolveReceipt: function (tx, cb) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment