-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In the artifact resolver detect whether a FQN is being used to refer to the contract and use Hardhat's own build info resolution method as we can rely on the fqn. This is now covered with an additional integration test for repos with multiple contracts with the same name in different files and an Ignition module where those contracts are referred to by FQNs. Fixes #778.
- Loading branch information
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...dhat-plugin/test/fixture-projects/multiple-contracts-with-same-name/contracts/Rocket1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
// This contract name is the same as in `./Rocket2.sol` | ||
contract Rocket { | ||
string public name; | ||
|
||
constructor(string memory _name) { | ||
name = _name; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...dhat-plugin/test/fixture-projects/multiple-contracts-with-same-name/contracts/Rocket2.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
// This contract name is the same as in `./Rocket1.sol` | ||
contract Rocket { | ||
string public name; | ||
|
||
constructor(string memory _name) { | ||
name = _name; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
.../hardhat-plugin/test/fixture-projects/multiple-contracts-with-same-name/hardhat.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require("../../../src/index"); | ||
|
||
module.exports = { | ||
solidity: "0.8.19", | ||
}; |
39 changes: 39 additions & 0 deletions
39
packages/hardhat-plugin/test/module-api/fully-qualified-names.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { buildModule } from "@nomicfoundation/ignition-core"; | ||
import { assert } from "chai"; | ||
|
||
import { useFileIgnitionProject } from "../test-helpers/use-ignition-project"; | ||
|
||
describe("fully qualified names", () => { | ||
describe("where there are multiple contracts with the same name in the project", () => { | ||
useFileIgnitionProject( | ||
"multiple-contracts-with-same-name", | ||
"contract-deploy" | ||
); | ||
|
||
it("should deploy contracts by referring using fully qualified names", async function () { | ||
const LaunchModule = buildModule("Apollo", (m) => { | ||
const rocket1 = m.contract( | ||
"contracts/Rocket1.sol:Rocket", | ||
["Rocket 1"], | ||
{ | ||
id: "Rocket1", | ||
} | ||
); | ||
const rocket2 = m.contract( | ||
"contracts/Rocket2.sol:Rocket", | ||
["Rocket 2"], | ||
{ | ||
id: "Rocket2", | ||
} | ||
); | ||
|
||
return { rocket1, rocket2 }; | ||
}); | ||
|
||
const result = await this.hre.ignition.deploy(LaunchModule); | ||
|
||
assert.equal(await result.rocket1.read.name(), "Rocket 1"); | ||
assert.equal(await result.rocket2.read.name(), "Rocket 2"); | ||
}); | ||
}); | ||
}); |