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 hooks section #1090

Merged
merged 12 commits into from
Aug 15, 2024
Merged

Conversation

andrew-fleming
Copy link
Collaborator

Fixes #979.

PR Checklist

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

docs/modules/ROOT/pages/components.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/components.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/components.adoc Show resolved Hide resolved
docs/modules/ROOT/pages/components.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-fleming. Left a suggestion to simplify the code. Not sure if we should update the Medium post accordingly.

}

// Occurs after token transfers
fn after_update(
Copy link
Member

Choose a reason for hiding this comment

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

We now can have default function implementations in traits, so we can simplify this pattern by setting default empty functions in the Hooks trait, removing the need for an empty function in the custom impl. I think we can use this PR for that as well.

Copy link
Member

Choose a reason for hiding this comment

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

Note that the default empty impl is still helpful, but it should be refactored to an empty (without functions) impl definition, since the empty functions should come from the Hook trait definition itself.

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 this example shouldn't include the empty function, but maybe a note stating that the default for the other hook functions is an empty implementation.

@andrew-fleming
Copy link
Collaborator Author

andrew-fleming commented Aug 12, 2024

Not sure if we should update the Medium post accordingly.

@ericnordelo It's probably enough to just include a note in the post ("As of v0.15.1..."). The default fns doesn't break the old flow. I'll wait until near the next release though

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!

@immrsd immrsd self-requested a review August 13, 2024 07:32
Copy link
Collaborator

@immrsd immrsd 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!

@andrew-fleming andrew-fleming merged commit 486699f into OpenZeppelin:main Aug 15, 2024
6 checks passed
@andrew-fleming andrew-fleming deleted the add-hooks-section branch August 15, 2024 00:40
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.

Add hooks usage section
3 participants