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

Add ERC721EnumerableComponent extension #983

Draft
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

andrew-fleming
Copy link
Collaborator

@andrew-fleming andrew-fleming commented Apr 30, 2024

Fixes #722.

Deps:

PR Checklist

  • Tests
  • Documentation
  • Added entry to CHANGELOG.md
  • Tried the feature on a public network

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.

The implementation looks good, I left a couple of broad suggestions, I will give a full review after the PR is finished. I vote we use StorageArray for releasing, but we can finish the PR either way since the changes should be small, and we can commit to one impl at the end.

CHANGELOG.md Outdated
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- before_update and after_update hooks to ERC721Component (#978)
Copy link
Member

Choose a reason for hiding this comment

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

Lets not forget to add the entry to the changelog.

#[starknet::component]
mod ERC721EnumerableComponent {
use openzeppelin::introspection::src5::SRC5Component::InternalTrait as SRC5InternalTrait;
use openzeppelin::introspection::src5::SRC5Component::SRC5;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this import?

}

///
fn _update(ref self: ComponentState<TContractState>, to: ContractAddress, token_id: u256,) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we provide this as a hooks implementation (after_update)? Something like a function maybe is enough, and then users can call each extension after_update in the preset Hooks implementation. We need to document it, but I think it will be easy enough to use.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's basically the idea behind the design. I went back and forth on update vs before_update. I do like the idea of having a pattern of extension functions (required in hooks) named before/after_update. Will update

@andrew-fleming andrew-fleming marked this pull request as ready for review May 14, 2024 16:42
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.

Hey Andrew, the PR looks great but I have two "big" suggestions to consider before getting it merged:

  1. I feel it is worth waiting until at least the next milestone to release it since we are going to have two good additions to the language: Map and StorageArray, that can help both making the implementation cleaner and avoid breaking right after we release a first version. I don't think we should target being backward compatible for this module, which brings us into suggestion two.

  2. Break backward compatibility to use Map and StorageArray, and also remove the camelCase interface. I think at this point we are not targeting contracts that may upgrade from cairo0 to this new version, since they either upgraded already or are not gonna do it.

src/tests/mocks/erc721_enumerable_mocks.cairo Outdated Show resolved Hide resolved
Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
@andrew-fleming
Copy link
Collaborator Author

  1. I feel it is worth waiting until at least the next milestone to release it since we are going to have two good additions to the language: Map and StorageArray, that can help both making the implementation cleaner and avoid breaking right after we release a first version. I don't think we should target being backward compatible for this module, which brings us into suggestion two.

Mmmmm yeah, I think that's fair. I'll change this to a draft and we can revisit in either the next or after milestone

  1. Break backward compatibility to use Map and StorageArray, and also remove the camelCase interface. I think at this point we are not targeting contracts that may upgrade from cairo0 to this new version, since they either upgraded already or are not gonna do it.

Agreed. Will update!

@andrew-fleming andrew-fleming marked this pull request as draft May 15, 2024 15:43
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.

Migrate ERC721 Enumerate extension
2 participants