From 0f5330b3315408a8b4a94cf9be0e3cfedd3b72d0 Mon Sep 17 00:00:00 2001 From: Kyrylo Riabov Date: Fri, 15 Dec 2023 14:29:11 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20a=20bug=20related=20to=20parsing=20the=20?= =?UTF-8?q?same=20bytecode=20for=20two=20different=20co=E2=80=A6=20(#64)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed a bug related to parsing the same bytecode for two different contracts * Updated CHANGELOG.md and versions * Clarified comment --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/tools/storage/ArtifactProcessor.ts | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1c53d18..ebf6af79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Version 2.0.0-alpha.21 + +* Fix a bug related to parsing the same bytecode for two different contracts + ## Version 2.0.0-alpha.20 * Remove redundant initializers in a verifier task diff --git a/package.json b/package.json index 13e9b4e9..6bf82f2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/hardhat-migrate", - "version": "2.0.0-alpha.20", + "version": "2.0.0-alpha.21", "description": "Automatic deployment and verification of smart contracts", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", diff --git a/src/tools/storage/ArtifactProcessor.ts b/src/tools/storage/ArtifactProcessor.ts index eae84f2e..681d166d 100644 --- a/src/tools/storage/ArtifactProcessor.ts +++ b/src/tools/storage/ArtifactProcessor.ts @@ -25,7 +25,10 @@ export class ArtifactProcessor { } ArtifactStorage.set(name, contract); - ArtifactStorage.set(bytecodeHash(artifact.bytecode), contract); + + // Forcing the overwriting of the existing bytecode value in the Artifacts storage is necessary to prevent + // failure in edge cases, such as with internal libraries or disabled bytecode metadata hash generation. + ArtifactStorage.set(bytecodeHash(artifact.bytecode), contract, artifact.abi.length === 0); } }