Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent contract name collision with @openzeppelin/contracts #82

Closed
montyly opened this issue Apr 16, 2020 · 3 comments
Closed

Prevent contract name collision with @openzeppelin/contracts #82

montyly opened this issue Apr 16, 2020 · 3 comments

Comments

@montyly
Copy link

montyly commented Apr 16, 2020

Hi,

🧐 Motivation
@openzeppelin/contracts-ethereum-package and @openzeppelin/contracts share many contracts names. The duplication prevents the correct compilation artifacts to be generated if a codebase uses both packages.

📝 Details
Most of the compilation frameworks do not handle well codebase with contract's name duplicate. For example, when generating the json artifacts, Truffle will not be able to generate correctly the files trufflesuite/truffle#1087.

As a result, it can prevent the integration with third-party tools. For example, we had to develop a specific detector in Slither to know what contracts names are reused. But if a codebase uses both @openzeppelin/contracts-ethereum-package and @openzeppelin/contracts, it is difficult for a user to avoid the duplicate names.

Example
A codebase that would have both an upgradeable ERC20 token a non-upgradeable one will be affected:

// contracts/UpgradeableERC20.sol
import '@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol';

contract UpgradeableERC20 is ERC20 {
}
// contracts/NonUpgradeableERC20.sol
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract NonUpgradeableERC20 is ERC20 {
}

Running truffle compile on a codebase with these two files will result in one build/contracts/ERC20.json file that will either represent @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol or @openzeppelin/contracts/token/ERC20/ERC20.sol.

A better practice would be to have separate contract names according to the package.

Let me know if you have any questions,
Thanks!

@frangio
Copy link
Contributor

frangio commented Apr 16, 2020

Thanks for this suggestion! It's a good idea and we're going to consider this for the upcoming 3.0 release.

@frangio
Copy link
Contributor

frangio commented May 13, 2020

This has been partially fixed in 3.0 but interfaces still have names without suffix. We'll have to correct this in a later release.

@frangio
Copy link
Contributor

frangio commented Nov 12, 2020

Fixed in @openzeppelin/contracts-upgradeable@3.2.0.

See First release of OpenZeppelin Contracts Upgradeable.

@frangio frangio closed this as completed Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants