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

Refactor directory structure #350

Merged
merged 30 commits into from
Jul 23, 2022

Conversation

andrew-fleming
Copy link
Collaborator

Resolves #335.

This PR proposes to separate libraries and preset contracts in separate directories. For library-only directories (like security), this PR includes the library directory here as well i.e.
from openzeppelin.security.library.Initializable import Initializable.

This PR also proposes to remove underscores from library and preset contract names meaning ERC20_Mintable_Burnable.cairo is now ERC20MintableBurnable.cairo.

Copy link
Contributor

@JulissaDantes JulissaDantes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good, should we also update the contributing guidelines of our CONTRIBUTING file?

ericglau added a commit to ericglau/contracts-wizard that referenced this pull request Jun 17, 2022
@andrew-fleming andrew-fleming marked this pull request as draft June 24, 2022 18:55
ericglau added a commit to ericglau/contracts-wizard that referenced this pull request Jun 27, 2022
Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments on the CONTRIBUTING section to orient the refactor design towards the latest proposal.

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
@andrew-fleming
Copy link
Collaborator Author

Some things to note in this latest iteration:

  • the security directory includes subdirectories for each library i.e.
    • openzeppelin/security/initializable/library.cairo
    • openzeppelin/security/pausable/library.cairo
  • the ERC721Enumerable library follows @martriay's suggestion => openzeppelin/token/erc721/enumerable/library.cairo
  • the interfaces directories have been removed. Interfaces now sit alongside the library:
    • openzeppelin/token/erc20/library.cairo
    • openzeppelin/token/erc20/IERC20.cairo

@andrew-fleming andrew-fleming marked this pull request as ready for review July 15, 2022 02:28
Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good! Amazing progress and I think this is going to be a very positive change for the project. I'm slightly concerned about conflicts between this and the docs integration PRs. Don't forget to merge the latest main as soon there's anything new merged to avoid changes to be lost in the file migration.

e.g. the recent SPDX identifiers bump might get lost otherwise

- `openzeppelin.token.erc20.presets.ERC20Mintable`
- And a visual guide:

```
```python
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why python?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter expects a language with the code block. Python is an arbitrary solution since this is just a visual aid

Comment on lines +13 to +15
- [ERC20Mintable](#erc20mintable)
- [ERC20Pausable](#erc20pausable)
- [ERC20Upgradeable](#erc20upgradeable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what a lovely race condition with #396

docs/ERC721.md Outdated Show resolved Hide resolved
docs/Introspection.md Outdated Show resolved Hide resolved
docs/Introspection.md Outdated Show resolved Hide resolved
docs/Security.md Outdated Show resolved Hide resolved
docs/Security.md Outdated Show resolved Hide resolved
docs/Security.md Outdated Show resolved Hide resolved
@@ -1,14 +1,14 @@
# SPDX-License-Identifier: MIT
# OpenZeppelin Contracts for Cairo v0.2.0 (token/erc721/utils/ERC721_Holder.cairo)
# OpenZeppelin Contracts for Cairo v0.2.0 (token/erc721/utils/ERC721Holder.cairo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mh this one is not strictly following the presets/ directory requirement in CONTRIBUTING. not sure if it needs to, but at least it's worth noticing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe moving utils so it's erc721/presets/utils instead? or just removing the directory entirely

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point...I'll try the former and see how we like it

@@ -1,12 +1,13 @@
# SPDX-License-Identifier: MIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why doesn't it need the file name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially used the openzeppelin-contracts as a template and that repo doesn't include file names for mocks. Do you prefer we add them in?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need

@andrew-fleming andrew-fleming marked this pull request as draft July 15, 2022 21:40
@andrew-fleming andrew-fleming marked this pull request as ready for review July 20, 2022 05:58
Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting close. Not sure what to do re: proxy. I wouldn't make Proxies all about upgrades, let alone remove the concept of upgrades from the names.

Either

openzeppelin/upgrades/library.cairo
openzeppelin/upgrades/presets/Proxy.cairo

or

openzeppelin/proxy/upgrades/library.cairo
openzeppelin/proxy/presets/UpgradeableProxy.cairo

tox.ini Outdated Show resolved Hide resolved
tests/mocks/Ownable.cairo Show resolved Hide resolved
src/openzeppelin/proxy/presets/Proxy.cairo Outdated Show resolved Hide resolved
@andrew-fleming
Copy link
Collaborator Author

We're getting close. Not sure what to do re: proxy. I wouldn't make Proxies all about upgrades, let alone remove the concept of upgrades from the names.

Either

openzeppelin/upgrades/library.cairo
openzeppelin/upgrades/presets/Proxy.cairo

or

openzeppelin/proxy/upgrades/library.cairo
openzeppelin/proxy/presets/UpgradeableProxy.cairo

I think the former makes the most sense. I'll update and see what we think

@andrew-fleming andrew-fleming marked this pull request as draft July 22, 2022 19:38
@andrew-fleming andrew-fleming marked this pull request as ready for review July 22, 2022 21:33
Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proxy looks good! We're almost done: I just noticed theres some broken links in the docs e.g.

OpenZeppelin Contracts for Cairo provides [Ownable](../src/openzeppelin/access/ownable.cairo) for implementing ownership in your contracts.


### Quickstart

Integrating [Ownable](../src/openzeppelin/access/ownable.cairo) into a contract first requires assigning an owner. The implementing contract's constructor should set the initial owner by passing the owner's address to Ownable's [initializer](#initializer) like this:
Integrating [Ownable](../src/openzeppelin/access/library.cairo) into a contract first requires assigning an owner. The implementing contract's constructor should set the initial owner by passing the owner's address to Ownable's [initializer](#initializer) like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Integrating [Ownable](../src/openzeppelin/access/library.cairo) into a contract first requires assigning an owner. The implementing contract's constructor should set the initial owner by passing the owner's address to Ownable's [initializer](#initializer) like this:
Integrating [Ownable](../src/openzeppelin/access/ownable/library.cairo) into a contract first requires assigning an owner. The implementing contract's constructor should set the initial owner by passing the owner's address to Ownable's [initializer](#initializer) like this:

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

Successfully merging this pull request may close these issues.

Refactor directory structure
3 participants