OpenZeppelin / OpenZeppelin/openzeppelin-contracts

Unused class/interface in flattened code

Open
#4,629 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

idea
Dominant language
Solidity
Stars
27.2k
Forks
12.4k
Avg merge
2d 19h
Merged PRs (30d)
33

Description

Using flattener (both truffle or hardhat) all the custom errors from draft-IERC6093.sol are imported into the flattened file also if unused.
I mean using the ERC20 contract we will find also the IERC721Errors and IERC1155Errors into the code.
It should import only the required (and necessary) file in import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; instead of importing the whole file.

Is there a way to avoid this behavior?
Is this a flattener issue and should we reference it there?

To reproduce simply run:

npx hardhat flatten contracts/token/ERC20/ERC20.sol > ERC20.flat.sol

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run npx hardhat flatten contracts/token/ERC20/ERC20.sol > ERC20.flat.sol and inspect contracts/token/ERC20/ERC20.sol alongside draft-IERC6093.sol. Determine whether the extra IERC721Errors and IERC1155Errors declarations originate in OpenZeppelin Contracts or the Truffle/Hardhat flattener. Done means the ownership and expected flattening behavior are established, with the issue routed or scoped accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.