From 0ee554469feeb226d4e7059fa7fb8c12a1b22a3e Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 21 Feb 2023 15:34:41 +0100 Subject: [PATCH] fix debugging with source code --- .../src/lib/compiler-fetch-and-compile.ts | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts b/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts index 2b63efc433..ed53f4fea0 100644 --- a/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts +++ b/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) { 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) if (resolved) return resolved @@ -87,20 +94,20 @@ export class FetchAndCompile extends Plugin { return localCompilation() } if (!network) return localCompilation() - if (!this.sourceVerifierNetWork.includes(network.name)) return localCompilation() - - // check if the contract if part of the local compilation result - const compilation = await localCompilation() - if (compilation) { - let found = false - compilation.visitContracts((contract) => { - found = util.compareByteCode('0x' + contract.object.evm.deployedBytecode.object, codeAtAddress) - return found - }) - if (found) { - await this.call('compilerArtefacts', 'addResolvedContract', contractAddress, compilation) - setTimeout(_ => this.emit('usingLocalCompilation', contractAddress), 0) - return compilation + if (!this.sourceVerifierNetWork.includes(network.name)) { + // check if the contract if part of the local compilation result + const compilation = await localCompilation() + if (compilation) { + let found = false + compilation.visitContracts((contract) => { + found = util.compareByteCode('0x' + contract.object.evm.deployedBytecode.object, codeAtAddress) + return found + }) + if (found) { + await this.call('compilerArtefacts', 'addResolvedContract', contractAddress, compilation) + setTimeout(_ => this.emit('usingLocalCompilation', contractAddress), 0) + return compilation + } } }