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

Minor: declare the constructor of contract Ownable internal instead of public #1394

Closed
barakman opened this issue Oct 7, 2018 · 6 comments
Closed
Labels
breaking change Changes that break backwards compatibility of the public API. contracts Smart contract code. good first issue Low hanging fruit for new contributors to get involved!
Milestone

Comments

@barakman
Copy link
Contributor

barakman commented Oct 7, 2018

🧐 Motivation
This doesn't really fall under the category of a feature-request, nor does it fall under the category of a bug-report. The motivation is to be a little more pedantic with the object-oriented implementation of contract Ownable . That said, it might have been proposed here before...

📝 Details
It makes very little sense to deploy this contract as is, so its constructor can and should be declared internal instead of public. True, it would make testing it slightly harder, as you'd need to add a helper contract inheriting from it (you could probably name it OwnableProxy or OwnableAdapter).
Nevertheless, it would emphasize to all users that this contract has no purpose other than being part of an extended contract.

@nventuro nventuro added feature New contracts, functions, or helpers. contracts Smart contract code. breaking change Changes that break backwards compatibility of the public API. kind:improvement and removed feature New contracts, functions, or helpers. labels Oct 8, 2018
@nventuro
Copy link
Contributor

nventuro commented Oct 8, 2018

We may need to better define what a feature request and an improvement are :)

I think this makes a lot of sense, and I like the idea of guiding users into the usage we intend. This same thing applies to some other contracts, such as Pausable, or PullPayment.

@barakman
Copy link
Contributor Author

barakman commented Oct 8, 2018

@nventuro:
So any chance of pushing it in before the official release of 2.0? (after passing it through your review process of course).

P.S.: I wouldn't call it a breaking change, since doubtfully anyone has ever deployed a standalone instance of Ownable for anything other than testing (unless you consider that a break).

@nventuro
Copy link
Contributor

nventuro commented Oct 8, 2018

Technically it's a breaking change of the API, though a minor one 😛

We're currently in the process of reviewing the last minor changes, it is possible this will make it into 2.0, since the scope is so small.

@nventuro
Copy link
Contributor

After thinking about this some more, it is definitely something we want to include in the release. Off the top of my head, the contracts that should have this sort of thing are:

  • All roles (e.g. MinterRole, PauserRole, etc.)
  • SignatureBouncer
  • ERC165
  • Pausable
  • Ownable and Secondary
  • PullPayment
  • ReentrancyGuard

Some of these have no constructor: maybe we should give them an empty internal one?

@nventuro nventuro added the good first issue Low hanging fruit for new contributors to get involved! label Oct 10, 2018
@barakman
Copy link
Contributor Author

barakman commented Oct 10, 2018

@nventuro:
That's exactly what I do in every contract of this sort that we have in our system, so I'm a natural supporter of this approach (empty internal constructor).
AFAIK, this is also the conventional method in other OO languages, such as C++ (empty protected constructor in that case).

I have mentioned only the Ownable contract, because that's the only OpenZeppelin contract of this type that we use (well, except for the Claimable contract, but it's been removed in the upcoming release, right?).

@nventuro
Copy link
Contributor

nventuro commented Oct 10, 2018

Claimable was indeed removed, yes. And you're right regarding this being conventional in other languages too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Changes that break backwards compatibility of the public API. contracts Smart contract code. good first issue Low hanging fruit for new contributors to get involved!
Projects
None yet
Development

No branches or pull requests

3 participants