-
Notifications
You must be signed in to change notification settings - Fork 138
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
Use Cairo 1+ and OpenZeppelin Contracts for Cairo v0.8.0 #305
Conversation
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
Hey Eric, this may be intentional, but In the token name, for example, I can use spaces and symbols like ; or any unicode one, and this is not reflected on the class/module name, but it is reflected on the registered token name. Shouldn't we add more strict validation to inputs? |
@ericnordelo Thanks for the suggestion. The intention is to sanitize the user inputted name into a separate valid identifier name and a valid string. These can be different as there is no requirement for them to be exactly the same, and I think it provides a better UX to sanitize rather than give an error if invalid characters are provided. I've updated the sanitization to conform to Cairo's rules for identifiers and short strings as much as possible. The logic for these are defined here. |
@martriay @ericnordelo @andrew-fleming This PR is ready for review. Thanks! |
Looking good Eric! Some comments:
Into this:
We could also have:
But I like the former the most. This also applies for ERC721. |
to
I know we have it without it in the docs, that's my fault, but it should be ExternalImpl to be consistent with the unwritten patterns we follow. I will update the docs accordingly. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the comments I left, it looks ready to go to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really great! Thanks.
I see upgrades and access control are not affected by pausable, is it intentional?
Do you think it makes sense to add some warning/visual feedback when the values are not right? For example
- empty module name (token metadata is fine to be empty)
- empty license ("" results in MIT, but " " does not)
- the provided metadata values exceed what can be represented by short strings. right now this is "sanitized" but the user has no feedback about it, potentially resulting in a different behavior than expected.
This was intentional. I see a reason to have them unaffected: if there is a vulnerability identified in a contract, the pauser may want to pause it, but not unpause it until after they have upgraded the contract. Is there a reason to do otherwise?
Changed this to an error if identifier is empty.
This is currently the same as Solidity, although SPDX-License-Identifier is strongly encouraged by the Solidity compiler. For Cairo, perhaps it could omit the SPDX-License-Identifier if the user input is "" (but not " "). What do you think?
Changed this to an error if short string length > 31 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentional. I see a reason to have them unaffected: if there is a vulnerability identified in a contract, the pauser may want to pause it, but not unpause it until after they have upgraded the contract. Is there a reason to do otherwise?
For upgrades I guess you can unpause + upgrade in the same tx as we have built-in multicall in Starknet thanks to the standard account design, but I think your pattern works too. For access control, I guess you could argue that if you don't pause it you cannot prevent a compromised role admin from making access changes. Not a very strong case though.
Changed this to an error if short string length > 31
maybe it's intentional/not worth fixing, but this only gets displayed if it's the first error in the form. if the name is empty, this error won't be shown. Should we do the same for decimals
?
We haven't established a pattern to make these pausable, and this is the same for Solidity (UUPS or access control). If there is a strong case for changing these, we should consider it for both Solidity and Cairo along with any security implications.
This is related to how we are handling the error. Once there is an error, we raise an exception to the UI and nothing else takes effect until that error is fixed. Opened #312 to consider improving this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wizard looks excellent, Eric! A couple notes:
- When adding
PausableComponent
, ERC20 canmint
and ERC721 cansafe_mint
while the contract is paused. Is this intentional? - When adding
AccessControlComponent
, both token contracts can only be burned by the owner. IMO the expected behavior would be having aBURNER_ROLE
handle the burning. WDYT?
Good catch, looks like this was missed. I think we should add this!
I don't think that would be appropriate. ERC20: ERC721: |
You're correct, good call! I was thinking of the examples we have in the |
Changed ERC20 mint and ERC721 safe_mint to be affected by pausable. |
Agree. I expect these patterns to be written down, analyzed, and applied cross-projects as long as it make sense
Looking at it now, I wonder if it's a good example to have. |
Don't we need a |
@martriay Added |
Perhaps with Cairo. It'd be a better example if we had an embeddable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvements look good! I left a final suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Preview: https://deploy-preview-305--openzeppelin-contracts-wizard.netlify.app/cairo
Cairo-specific highlighting will be handled in a separate PR.