From f04aa0d2bfe24be041680a3736c9bff9d79543b6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 4 Oct 2022 10:58:42 +0200 Subject: [PATCH] fix use of metadata --- libs/remixd/src/services/foundryClient.ts | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libs/remixd/src/services/foundryClient.ts b/libs/remixd/src/services/foundryClient.ts index 3eb55803e1..ae5c2978ec 100644 --- a/libs/remixd/src/services/foundryClient.ts +++ b/libs/remixd/src/services/foundryClient.ts @@ -108,20 +108,23 @@ export class FoundryClient extends PluginClient { async feedContractArtifactFile (path, content, compilationResultPart) { const contentJSON = JSON.parse(content) - if (path.endsWith('.metadata.json')) { - // extract source and version - compilationResultPart.solcVersion = contentJSON.compiler.version - for (const path in contentJSON.sources) { - const absPath = utils.absolutePath(path, this.currentSharedFolder) - try { - const content = await fs.readFile(absPath, { encoding: 'utf-8' }) - compilationResultPart.input[path] = { content } - } catch (e) { - compilationResultPart.input[path] = { content: '' } + + // extract source and version + const metadata = contentJSON.metadata + compilationResultPart.solcVersion = metadata.compiler.version + for (const path in metadata.sources) { + const absPath = utils.absolutePath(path, this.currentSharedFolder) + try { + const content = await fs.readFile(absPath, { encoding: 'utf-8' }) + compilationResultPart.input[path] = { content } + } catch (e) { + compilationResultPart.input[path] = { content: '' } + } } } - } else { - const contractName = basename(path).replace('.json', '') + } + + const contractName = basename(path).replace('.json', '') compilationResultPart.compilationTarget = contentJSON.ast.absolutePath // extract data if (!compilationResultPart.output['sources'][contentJSON.ast.absolutePath]) compilationResultPart.output['sources'][contentJSON.ast.absolutePath] = {} @@ -141,7 +144,6 @@ export class FoundryClient extends PluginClient { methodIdentifiers: contentJSON.methodIdentifiers } } - } } async sync () {