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

Migrate SRC5 to component #767

Merged

Conversation

ericnordelo
Copy link
Member

@ericnordelo ericnordelo commented Oct 2, 2023

Supersedes #755 Fixes #754

PR Checklist

  • Tests
  • Tried the feature on a public network
  • Documentation

ericnordelo and others added 8 commits September 15, 2023 15:55
* feat: update format and add api

* fix: typo

* feat: add counterfactual deployment doc

* feat: add API entries

* feat: add events

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/guides/deployment.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/guides/deployment.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* feat: update from reviews

* feat: apply review updates

* feat: update docs

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: apply review updates

* fix: account casing

* feat: add headers

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: add link

* feat: move API

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* refactor: update wording

* Update docs/antora.yml

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: apply update reviews

* Update docs/modules/ROOT/pages/api/account.adoc

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

* refactor: UI

* fix: UI

* feat: focus on SRC6

* Update docs/modules/ROOT/pages/accounts.adoc

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

* feat: apply review updates

---------

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
Co-authored-by: Martín Triay <martriay@gmail.com>
* feat: update format and add api

* fix: typo

* feat: add counterfactual deployment doc

* feat: add API entries

* feat: add events

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/guides/deployment.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/guides/deployment.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* feat: update from reviews

* feat: apply review updates

* feat: update docs

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: apply review updates

* fix: account casing

* feat: add headers

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: add link

* feat: move API

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* refactor: update wording

* Update docs/antora.yml

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: apply update reviews

* Update docs/modules/ROOT/pages/api/account.adoc

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

* refactor: UI

* fix: UI

* feat: focus on SRC6

* add interface & dispatchers docs

* apply review feedback

* address feedback comments

---------

Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
* feat: update format and add api

* fix: typo

* feat: add counterfactual deployment doc

* feat: add API entries

* feat: add events

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/guides/deployment.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/guides/deployment.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* feat: update from reviews

* feat: apply review updates

* feat: update docs

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/accounts.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/guides/deployment.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: apply review updates

* fix: account casing

* feat: add headers

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: add link

* feat: move API

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/accounts.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* refactor: update wording

* Update docs/antora.yml

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* Update docs/modules/ROOT/pages/api/account.adoc

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

* Update docs/modules/ROOT/pages/api/account.adoc

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

* feat: apply update reviews

* Update docs/modules/ROOT/pages/api/account.adoc

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

* refactor: UI

* fix: UI

* feat: focus on SRC6

* Update docs/modules/ROOT/pages/accounts.adoc

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

* feat: update overview

* feat: apply review updates

* Update docs/modules/ROOT/pages/index.adoc

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

* feat: apply review updates

* Update docs/modules/ROOT/pages/index.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

* feat: apply review updates

* Update docs/modules/ROOT/pages/index.adoc

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

---------

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
Co-authored-by: Martín Triay <martriay@gmail.com>
* feat: add prefixes

* Update src/access/accesscontrol/accesscontrol.cairo

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>

---------

Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
* refactor: sanitizing

* feat: sanitizing

* feat: apply review updates

* feat: apply review updates
Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

Great work, Eric! I left a few questions. And as mentioned in our discussion, I vote that we update the relevant documentation with each component migration PR

src/introspection/src5.cairo Outdated Show resolved Hide resolved
src/introspection/src5.cairo Show resolved Hide resolved
src/introspection/src5.cairo Outdated Show resolved Hide resolved
src/tests/introspection/test_src5.cairo Outdated Show resolved Hide resolved
src/tests/mocks/erc721_receiver.cairo Outdated Show resolved Hide resolved
@ericnordelo ericnordelo changed the title Migrate src5 to component Migrate SRC5 to component Oct 6, 2023
Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

Improvements look good, sir! I left a couple suggestions and a question :)

docs/modules/ROOT/pages/introspection.adoc Outdated Show resolved Hide resolved
src/introspection/src5.cairo Outdated Show resolved Hide resolved
Comment on lines 72 to 73
[#SRC5-External-Functions]
==== External Functions
[#SRC5-Embeddable-Implementations-Functions]
==== Embeddable Implementations Functions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we change the self type in the functions below to ComponentState<TContractState>?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think about leaving just ComponentState? I think the generic TState is implicit since TContractState is always required, and this will appear frequently in the APIs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good call, and it's much less noisy. +1

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I think we should leave just ContractState, because the embeddable implementation generated when you use embeddable_as is the one having just ContractState, like this:

#[starknet::embeddable]
impl SRC5Impl<
            TContractState, +HasComponent<TContractState>
, impl TContractStateDrop: Drop<TContractState>
> of interface::ISRC5<TContractState> {
    
    fn supports_interface(self: @TContractState, interface_id: felt252
) -> bool {
        let component = HasComponent::get_component(self);
        SRC5::supports_interface(component, interface_id, )
    }

Copy link
Member Author

Choose a reason for hiding this comment

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

The impl we embed is not the one we write in the component, but the one the compiler generates from the embeddable_as attribute. And this is the one the user would usually use. Is different for InternalImpl though, because this doesn't use embeddable_as. For this one I think we should use ComponentState.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm if we go that route, should we include a NOTE or something to explain the rationale behind using ContractState for embeddables and ComponentState for internals? IMO it'd be weird to not say anything about it

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree it can be confusing, but where can we add such note? It seems we would need to add it to every component API

Copy link
Collaborator

Choose a reason for hiding this comment

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

Repeating the same note is definitely not ideal. Even though this is about reading the API, it's IMO more about understanding the component architecture (as you described above). Maybe this can be addressed in the Extensibility doc

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, let's stick with ContractState for embeddable impls functions, and ComponentState for InternalImpl in components, at least until we revisit how we present this in the Extensibility PR. wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me

@andrew-fleming andrew-fleming mentioned this pull request Oct 6, 2023
3 tasks
ericnordelo and others added 4 commits October 6, 2023 16:48
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
…lo/cairo-contracts into feat/migrate-src5-to-component
Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

I left an optional comment to address and a couple small suggestions. Otherwise, LGTM!

==== External Functions
[#SRC5-Embeddable-Implementations-Functions]
==== Embeddable Implementations Functions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Regarding the title: Embeddable Implementations Functions, it reads kind of awkward. This is nitpicky, I know. I don't have a good alternative, just throwing it out there

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's call it just Embeddable Functions in the meantime (I think it reads better). Any suggestion is more than welcome.

src/tests/utils.cairo Outdated Show resolved Hide resolved
src/introspection/src5.cairo Outdated Show resolved Hide resolved
.External Functions
.Embeddable Implementations
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the Ownable API, the index name is Embeddable Implementations Functions. We should normalize

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's stick with just Embeddable Implementations then if you agree.

@ericnordelo ericnordelo merged commit d46470b into OpenZeppelin:main Oct 10, 2023
2 checks passed
@ericnordelo ericnordelo deleted the feat/migrate-src5-to-component branch October 10, 2023 17:24
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 SRC5 to component
6 participants