fix debugging with source code

pull/5370/head
yann300 2 years ago committed by Aniket
parent 3e27e0aa14
commit 0ee554469f
  1. 37
      libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts

@ -43,7 +43,14 @@ export class FetchAndCompile extends Plugin {
async resolve (contractAddress, codeAtAddress, targetPath) { async resolve (contractAddress, codeAtAddress, targetPath) {
contractAddress = toChecksumAddress(contractAddress) contractAddress = toChecksumAddress(contractAddress)
const localCompilation = async () => await this.call('compilerArtefacts', 'get', contractAddress) ? await this.call('compilerArtefacts', 'get', contractAddress) : await this.call('compilerArtefacts', 'get', '__last') ? await this.call('compilerArtefacts', 'get', '__last') : null const localCompilation = async () => {
const contractData = await this.call('compilerArtefacts', 'getContractDataFromByteCode', codeAtAddress)
if (contractData) {
return await this.call('compilerArtefacts', 'getCompilerAbstract', contractData.file)
}
else
return await this.call('compilerArtefacts', 'get', '__last')
}
const resolved = await this.call('compilerArtefacts', 'get', contractAddress) const resolved = await this.call('compilerArtefacts', 'get', contractAddress)
if (resolved) return resolved if (resolved) return resolved
@ -87,20 +94,20 @@ export class FetchAndCompile extends Plugin {
return localCompilation() return localCompilation()
} }
if (!network) return localCompilation() if (!network) return localCompilation()
if (!this.sourceVerifierNetWork.includes(network.name)) return localCompilation() if (!this.sourceVerifierNetWork.includes(network.name)) {
// check if the contract if part of the local compilation result
// check if the contract if part of the local compilation result const compilation = await localCompilation()
const compilation = await localCompilation() if (compilation) {
if (compilation) { let found = false
let found = false compilation.visitContracts((contract) => {
compilation.visitContracts((contract) => { found = util.compareByteCode('0x' + contract.object.evm.deployedBytecode.object, codeAtAddress)
found = util.compareByteCode('0x' + contract.object.evm.deployedBytecode.object, codeAtAddress) return found
return found })
}) if (found) {
if (found) { await this.call('compilerArtefacts', 'addResolvedContract', contractAddress, compilation)
await this.call('compilerArtefacts', 'addResolvedContract', contractAddress, compilation) setTimeout(_ => this.emit('usingLocalCompilation', contractAddress), 0)
setTimeout(_ => this.emit('usingLocalCompilation', contractAddress), 0) return compilation
return compilation }
} }
} }

Loading…
Cancel
Save