Skip to content

Better compatibility with remappings coming from foundry.toml #7561

@alcuadrado

Description

@alcuadrado

Describe the issue

Context

While Hardhat has native support for remappings.txt, multiple projects define them in their foundry.toml, and forge autogenerate some of them in the presence of a foundry.toml.

In those cases hardhat can fail to compile a project, due to missing remappings.

Proposal

We need to create a really simple hardhat-foundry plugins that loads those remappings to.

Expected behavior

Whenever hardhat loads the remappings for a package (either the hardhat project itself, or an npm module), it the plugin should use forge remappings to load those remappings too.

Design

We should add a hook to the package loading process, which happens here:

Just like we find all the remappings.txt files here, we should look for the foundry.toml files (that are not a node_modules), and run foge remappings in the context of that file's directory.

Out of scope

  • This plugin won't install forge, but fail with a clear message if it isn't installed.
  • This plugin won't change any default config of hardhat, like paths.

Open questions

  • Can our Remapping-related types accommodate for this? For example, source is expected to be a remapping.txt absolute path. Can we reuse it? Will the logic and error reporting break?

Metadata

Metadata

Assignees

Labels

type:KREnd-to-end implementation of a KR

Projects

Status

Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions