Skip to content

Commit

Permalink
fix: update regex in sourcePathFromSourceCode to match contracts and …
Browse files Browse the repository at this point in the history
…libraries

Updated the regular expression in the sourcePathFromSourceCode function to account for both `contract` and `library` declarations. This resolves an issue where library definitions were not being matched, causing the function to return `null`. The new RegExp now looks for both `contract` and `library` keywords.
  • Loading branch information
juliopavila committed Sep 4, 2024
1 parent 437900c commit 5cb8078
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/artifact/internal/getBuildArtifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ export function sourcePathFromSourceCode(
compilerInput.sources
)) {
const sourceCode = (sourceCodeEntry as any).content;
const contractPattern = new RegExp(`contract\\s+${contractName}\\s+`, "g");

const contractPattern = new RegExp(
`(contract|library)\\s+${contractName}\\s+`,
"g"
);
if (contractPattern.test(sourceCode)) {
return sourceName;
}
Expand Down

0 comments on commit 5cb8078

Please sign in to comment.