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 Upgrades to component #792

Merged

Conversation

ericnordelo
Copy link
Member

Fixes #791

PR Checklist

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

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.

Very nice, Eric! I left a tiny suggestion

src/tests/upgrades/test_upgradeable.cairo Outdated Show resolved Hide resolved
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 really good!

impl InternalImpl<
TContractState, +HasComponent<TContractState>
> of InternalTrait<TContractState> {
fn _upgrade(ref self: ComponentState<TContractState>, new_class_hash: ClassHash) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need the underscore?

Copy link
Member Author

Choose a reason for hiding this comment

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

#794 (comment)

Andrew made a good point, we should define if we need it or not first, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

let's keep it for now and have that discussion then, did we have an issue for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines 80 to 81
OwnableEvent: ownable_component::Event,
UpgradeableEvent: upgradeable_component::Event
Copy link
Contributor

Choose a reason for hiding this comment

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

should we be flattening events?

Copy link
Member Author

Choose a reason for hiding this comment

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

My impression was that we need this only for ERC20 and ERC721 (backward compatibility with indexers). Not sure whether we should flatten all events.

Copy link
Contributor

Choose a reason for hiding this comment

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

why would we want nested events? i tonight not flattening was just to allow "overriding" events, not to expose them nested. that'd be inconsistent, and make tooling/interop more complex

Copy link
Contributor

@martriay martriay Oct 21, 2023

Choose a reason for hiding this comment

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

any pre existing event should be flattened for backwards compat, this includes far more than erc20 and 721, also pausable, ownable, etc

Copy link
Member Author

Choose a reason for hiding this comment

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

why would we want nested events? i tonight not flattening was just to allow "overriding" events, not to expose them nested. that'd be inconsistent, and make tooling/interop more complex

I think the purpose is to avoid potential clashes among components (the design from the cairo team)

Copy link
Member Author

Choose a reason for hiding this comment

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

any pre existing event should be flattened for backwards compat, this includes far more than erc20 and 721, also pausable, ownable, etc

That's a fair point, but I still think tokens are probably more important than pausable on this matter

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the purpose is to avoid potential clashes among components

that makes sense when auto embedding, as a default mechanism. but it's an app-level decision whether to prefix events or not, and there's no standard for it. if anything, standards assume they're flattened.

That's a fair point, but I still think tokens are probably more important than pausable on this matter

what do you mean by "more important"? not sure what importance implies in this context, but I think we should be compatible and standard (although there's no written standard in Cairoland, there's Ethereum standards like Ownable and defacto standards such as Pausable) independently of importance i.e. even if ERC721 is "more important" than ERC20, we want both to be standard and compatible with existing tooling.

that's for existing standards, we yet need to decide what to do with new ones. this requires a bit more of standard discussion which might exceed this library's implementations.

@ericnordelo ericnordelo merged commit 6269c5d into OpenZeppelin:main Oct 24, 2023
2 checks passed
@ericnordelo ericnordelo deleted the feat/migrate-upgrades-to-component branch October 24, 2023 11:47
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 Upgrades to component
3 participants