From 334c342b537e41cbf01c0153b01bcb10305125b7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 21 Feb 2023 15:32:25 +0100 Subject: [PATCH] add getContractDataFromByteCode --- libs/remix-core-plugin/src/lib/compiler-artefacts.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/compiler-artefacts.ts b/libs/remix-core-plugin/src/lib/compiler-artefacts.ts index 6c3752b33d..4e9c55c87d 100644 --- a/libs/remix-core-plugin/src/lib/compiler-artefacts.ts +++ b/libs/remix-core-plugin/src/lib/compiler-artefacts.ts @@ -5,7 +5,7 @@ import { CompilerAbstract } from '@remix-project/remix-solidity' const profile = { name: 'compilerArtefacts', - methods: ['get', 'addResolvedContract', 'getCompilerAbstract', 'getAllContractDatas', 'getLastCompilationResult', 'getArtefactsByContractName', 'getContractDataFromAddress'], + methods: ['get', 'addResolvedContract', 'getCompilerAbstract', 'getAllContractDatas', 'getLastCompilationResult', 'getArtefactsByContractName', 'getContractDataFromAddress', 'getContractDataFromByteCode'], events: [], version: '0.0.1' } @@ -212,12 +212,16 @@ export class CompilerArtefacts extends Plugin { async getContractDataFromAddress (address) { const code = await this.call('blockchain', 'getCode', address) + return this.getContractDataFromByteCode(code) + } + + async getContractDataFromByteCode (code) { let found this.filterAllContractDatas((file, contractsData) => { for (const name of Object.keys(contractsData)) { const contract = contractsData[name] if (util.compareByteCode(code, '0x' + contract.evm.deployedBytecode.object)) { - found = { name, contract } + found = { name, contract, file } return true } }