Skip to content

Commit

Permalink
Assert that libraries have both name and version
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed May 21, 2021
1 parent b47cba5 commit dc14b9e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/hardhat-core/src/internal/solidity/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
validateSourceNameExistenceAndCasing,
validateSourceNameFormat,
} from "../../utils/source-names";
import { HardhatError } from "../core/errors";
import { assertHardhatInvariant, HardhatError } from "../core/errors";
import { ERRORS } from "../core/errors-list";
import { createNonCryptographicHashBasedIdentifier } from "../util/hash";

Expand All @@ -39,6 +39,12 @@ export class ResolvedFile implements IResolvedFile {
libraryName?: string,
libraryVersion?: string
) {
assertHardhatInvariant(
(libraryName === undefined && libraryVersion === undefined) ||
(libraryName !== undefined && libraryVersion !== undefined),
"Libraries should have both name and version, or neither one"
);

if (libraryName !== undefined && libraryVersion !== undefined) {
this.library = {
name: libraryName,
Expand Down

0 comments on commit dc14b9e

Please sign in to comment.