|
|
@ -17,7 +17,6 @@ export default class FetchAndCompile extends Plugin { |
|
|
|
constructor () { |
|
|
|
constructor () { |
|
|
|
super(profile) |
|
|
|
super(profile) |
|
|
|
this.unresolvedAddresses = [] |
|
|
|
this.unresolvedAddresses = [] |
|
|
|
this.firstResolvedAddress = null |
|
|
|
|
|
|
|
this.sourceVerifierNetWork = ['Main', 'Rinkeby', 'Ropsten', 'Goerli'] |
|
|
|
this.sourceVerifierNetWork = ['Main', 'Rinkeby', 'Ropsten', 'Goerli'] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -26,15 +25,12 @@ export default class FetchAndCompile extends Plugin { |
|
|
|
* Put the artifacts in the file explorer |
|
|
|
* Put the artifacts in the file explorer |
|
|
|
* Compile the code using Solidity compiler |
|
|
|
* Compile the code using Solidity compiler |
|
|
|
* Returns compilation data |
|
|
|
* Returns compilation data |
|
|
|
* if no contract address are passed, we default to the first resolved address. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param {string} contractAddress - Address of the contrac to resolve |
|
|
|
* @param {string} contractAddress - Address of the contrac to resolve |
|
|
|
* @param {string} compilersartefacts - Object containing a mapping of compilation results (byContractAddress and __last) |
|
|
|
* @param {string} compilersartefacts - Object containing a mapping of compilation results (byContractAddress and __last) |
|
|
|
* @return {CompilerAbstract} - compilation data targeting the given @arg contractAddress |
|
|
|
* @return {CompilerAbstract} - compilation data targeting the given @arg contractAddress |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async resolve (contractAddress, targetPath, web3) { |
|
|
|
async resolve (contractAddress, targetPath, web3) { |
|
|
|
contractAddress = contractAddress || this.firstResolvedAddress |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const compilersartefacts = globalRegistry.get('compilersartefacts').api |
|
|
|
const compilersartefacts = globalRegistry.get('compilersartefacts').api |
|
|
|
|
|
|
|
|
|
|
|
const localCompilation = () => compilersartefacts.get('__last') ? compilersartefacts.get('__last') : null |
|
|
|
const localCompilation = () => compilersartefacts.get('__last') ? compilersartefacts.get('__last') : null |
|
|
@ -42,9 +38,8 @@ export default class FetchAndCompile extends Plugin { |
|
|
|
const resolved = compilersartefacts.get(contractAddress) |
|
|
|
const resolved = compilersartefacts.get(contractAddress) |
|
|
|
if (resolved) return resolved |
|
|
|
if (resolved) return resolved |
|
|
|
if (this.unresolvedAddresses.includes(contractAddress)) return localCompilation() |
|
|
|
if (this.unresolvedAddresses.includes(contractAddress)) return localCompilation() |
|
|
|
if (this.firstResolvedAddress) return compilersartefacts.get(this.firstResolvedAddress) |
|
|
|
|
|
|
|
// ^ for the moment we don't add compilation result for each adddress, but just for the root addres ^ . We can add this later.
|
|
|
|
// sometimes when doing an internal call, the only available artifact is the Solidity interface.
|
|
|
|
// usecase is: sometimes when doing an internal call, the only available artifact is the Solidity interface.
|
|
|
|
|
|
|
|
// resolving addresses of internal call would allow to step over the source code, even if the declaration was made using an Interface.
|
|
|
|
// resolving addresses of internal call would allow to step over the source code, even if the declaration was made using an Interface.
|
|
|
|
|
|
|
|
|
|
|
|
let network |
|
|
|
let network |
|
|
@ -67,7 +62,6 @@ export default class FetchAndCompile extends Plugin { |
|
|
|
}) |
|
|
|
}) |
|
|
|
if (found) { |
|
|
|
if (found) { |
|
|
|
compilersartefacts.addResolvedContract(contractAddress, compilation) |
|
|
|
compilersartefacts.addResolvedContract(contractAddress, compilation) |
|
|
|
this.firstResolvedAddress = contractAddress |
|
|
|
|
|
|
|
setTimeout(_ => this.emit('usingLocalCompilation', contractAddress), 0) |
|
|
|
setTimeout(_ => this.emit('usingLocalCompilation', contractAddress), 0) |
|
|
|
return compilation |
|
|
|
return compilation |
|
|
|
} |
|
|
|
} |
|
|
@ -119,7 +113,6 @@ export default class FetchAndCompile extends Plugin { |
|
|
|
setTimeout(_ => this.emit('compiling', settings), 0) |
|
|
|
setTimeout(_ => this.emit('compiling', settings), 0) |
|
|
|
const compData = await compile(compilationTargets, settings) |
|
|
|
const compData = await compile(compilationTargets, settings) |
|
|
|
compilersartefacts.addResolvedContract(contractAddress, compData) |
|
|
|
compilersartefacts.addResolvedContract(contractAddress, compData) |
|
|
|
this.firstResolvedAddress = contractAddress |
|
|
|
|
|
|
|
return compData |
|
|
|
return compData |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
this.unresolvedAddresses.push(contractAddress) |
|
|
|
this.unresolvedAddresses.push(contractAddress) |
|
|
|