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

Update erc721 docs #763

Merged
merged 263 commits into from
Nov 26, 2023
Merged

Update erc721 docs #763

merged 263 commits into from
Nov 26, 2023

Conversation

andrew-fleming
Copy link
Collaborator

Supersedes #699 and fixes #563.

andrew-fleming and others added 30 commits February 18, 2023 11:48
* Change the spelling of "StarkNet" to "Starknet" (OpenZeppelin#557)

* fix: link (OpenZeppelin#545)

* change StarkNet to Starknet

---------

Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>

* add Cargo and Makefile

* add deps in cairo_project, create lib

* add presets

* add base lib

* add tests

* remove old cairo lib and interface

* remove unused import

* fix vars

* change external funcs to snake case

* remove unused import

* add tests for externals

* add bool assertions

* remove preset mods

* add IERC20 trait

* clean up test

* remove assertion

* simplify max_u256

* clarify error msg

* clean up python project. ready for rust/cairo1

* add erc165 + tests

* kickstart account module

* re-structure project

* re-structure project

* re-structure project

* update makefile

* re-structure project

* update to felt252, add use ContractAddress

* formatting

* remove colons from storage, remove _mint from initializer

* add constructor test

* add comments

* fix format

* check error msg in tests

* set max_u256 as func

* update cairo

* update cargo

* revert doc commit

* remove __init__

* refix link

---------

Co-authored-by: kongtaoxing <69096526+kongtaoxing@users.noreply.github.com>
Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
Co-authored-by: Martín Triay <martriay@gmail.com>
* update cairo

* fix path

* add security mod

* add initializable

* add tests

* Update src/openzeppelin/security/initializable.cairo

Co-authored-by: Martín Triay <martriay@gmail.com>

* remove underscore

* add internal macros

---------

Co-authored-by: Martín Triay <martriay@gmail.com>
* fix path

* add security mod

* add pausable

* add mock

* add tests

* add security mod

* update cargo

* update cairo

* Apply suggestions from code review

Co-authored-by: Martín Triay <martriay@gmail.com>

* remove underscore from _paused

* remove unused imports

* add test assertion for is_paused

* move mocks inside tests crate

* remove underscore

* add blank line

---------

Co-authored-by: Martín Triay <martriay@gmail.com>
* Apply suggestions from code review

Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>

* apply review suggestions

* remove unused import

* add internal macro

* add deregister

---------

Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
* add utils and constants

* simplify role val

* add context comments for interface ids
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.

this needs to be updated to use components, but other than that it looks good!

docs/modules/ROOT/pages/erc721.adoc Outdated Show resolved Hide resolved
Comment on lines +30 to +31
trait IERC721ABI {
// IERC721
Copy link
Contributor

Choose a reason for hiding this comment

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

now that we have components and presets, I wonder if we should begin with this chunk of interface. It's kindof big and with lots of information (non standard, camel support). maybe i'd focus in the component. what do you think?

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 agree that it is kind of big with a lot going on. I'm not sure what you're suggesting though. Do you mean removing the Interface section entirely? Or removing the individual interface subsections and just keep the ERC721ABI?

Copy link
Contributor

@martriay martriay Nov 24, 2023

Choose a reason for hiding this comment

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

i'm not sure i understood the second option, did you mean IERC721? i was suggesting to remove the interface section, although it may require a bit more of thought. My impression is that it's not that important now we have components because it's not a single module with all of it anymore, now you can select the impls.

If anything, it is closer to the preset, which is no yet documented and probably not the main focus of the section either. The focus should be the component and design/implementation details.

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'm not sure i understood the second option, did you mean IERC721?

Yeah, that section, IERC721Metadata, and ISRC5. I removed those section already since I left that response

i was suggesting to remove the interface section, although it may require a bit more of thought. My impression is that it's not that important now we have components because it's not a single module with all of it anymore, now you can select the impls.

If anything, it is closer to the preset, which is no yet documented and probably not the main focus of the section either. The focus should be the component and design/implementation details.

Agreed^

Maybe it'd make sense to follow a structure like this in the doc:

ERC721Component

  • Implementations
    • ERC721Impl
    • ERC721MetadataImpl
      ...
  • ERC721 compatibility
  • Usage
    ...

We can either head the impls with the interface snippet or just provide a link to the interface in the API...or just remove the Interface/Implementations section entirely, idk

Copy link
Contributor

@martriay martriay Nov 26, 2023

Choose a reason for hiding this comment

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

Right now we have this inconsistent structures:

Upgrades

  1. explainer
  2. usage

Account

  1. interface

Access

  1. usage
  2. interface

ERC20 and ERC721

  1. interface
  2. compatibility
  3. usage

Security

  1. usage

Introspection

  1. interface
  2. usage

Copy link
Contributor

@martriay martriay Nov 26, 2023

Choose a reason for hiding this comment

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

I think we should have

  1. explainer
  2. usage
  3. compatibility

and leave interface for API, of have it between explainer and usage. Either way we can merge this and fix it all together later in #829.

docs/modules/ROOT/pages/erc721.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/erc721.adoc Show resolved Hide resolved
docs/modules/ROOT/pages/api/erc721.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/erc721.adoc Outdated Show resolved Hide resolved
Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

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

Looking good Andrew! Left a couple of small comments but I think it looks ready.

docs/modules/ROOT/pages/erc721.adoc Outdated Show resolved Hide resolved
Comment on lines 106 to 107
component!(path: SRC5Component, storage: src5, event: SRC5Event);
component!(path: ERC721Component, storage: erc721, event: ERC721Event);
Copy link
Member

Choose a reason for hiding this comment

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

I think we should swap the order (this applies to the impls below as well). This is compliant with the account preset too.

Comment on lines 231 to 232
component!(path: SRC5Component, storage: src5, event: SRC5Event);
component!(path: ERC721ReceiverComponent, storage: erc721_receiver, event: ERC721ReceiverEvent);
Copy link
Member

Choose a reason for hiding this comment

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

Same comment regarding swapping

docs/modules/ROOT/pages/api/erc721.adoc Outdated Show resolved Hide resolved
andrew-fleming and others added 2 commits November 22, 2023 10:20
Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

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

LGTM!

src/token/erc721/interface.cairo Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/erc721.adoc Outdated Show resolved Hide resolved
Comment on lines +30 to +31
trait IERC721ABI {
// IERC721
Copy link
Contributor

@martriay martriay Nov 24, 2023

Choose a reason for hiding this comment

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

i'm not sure i understood the second option, did you mean IERC721? i was suggesting to remove the interface section, although it may require a bit more of thought. My impression is that it's not that important now we have components because it's not a single module with all of it anymore, now you can select the impls.

If anything, it is closer to the preset, which is no yet documented and probably not the main focus of the section either. The focus should be the component and design/implementation details.

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 good! Left minor comments.

I'm having troubles compiling the snippet from the usage section. Most probably an error on my end, but couldn't yet pinpoint it. Can you confirm it works?

image

I'm using scarb 2.3.1 and I'm using main branch

docs/modules/ROOT/pages/api/erc721.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/erc721.adoc Show resolved Hide resolved
Co-authored-by: Martín Triay <martriay@gmail.com>
@andrew-fleming
Copy link
Collaborator Author

andrew-fleming commented Nov 25, 2023

I'm having troubles compiling the snippet from the usage section. Most probably an error on my end, but couldn't yet pinpoint it. Can you confirm it works?

Weird. Yeah, I copied the .toml you posted and I'm also using Scarb 2.3.1 and it compiles on my end. I don't have the syntax highlighting though. Maybe try just pasting the code in MyToken/src/lib.cairo

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.

It works now, I had to delete my Scarb.lock.

@martriay martriay merged commit 50ed6b5 into OpenZeppelin:main Nov 26, 2023
5 checks passed
@andrew-fleming andrew-fleming deleted the add-erc721-docs branch August 6, 2024 01:28
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.

update erc721 docs
6 participants