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

chore: move define_udt! decl macro to sol! proc macro #471

Merged
merged 2 commits into from
Dec 30, 2023

Conversation

fgimenez
Copy link
Contributor

Motivation

Closes #39

Solution

Follows the suggestion here #39 (comment), just moves the define_udt! content to proc macro in udt's expand function using quote!.

Besides moving the code I've used expand_type(ty) as #underlying and hardcoded ::alloy_sol_types::private::just_ok instead of $path, let me know if that's ok. I've also added #[automatically_derived] annotations.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

#[inline]
fn type_check(token: &Self::Token<'_>) -> ::alloy_sol_types::Result<()> {
<#underlying as ::alloy_sol_types::SolType>::type_check(token)?;
::alloy_sol_types::private::just_ok(token)
Copy link
Member

Choose a reason for hiding this comment

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

If you don't mind, I think we can keep the user input with a #[sol(type_check = "function_name")] attribute. Otherwise I'll open an issue after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, should be done here e7e7b8f PTAL

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

Thanks!

@DaniPopes DaniPopes merged commit 1b51841 into alloy-rs:main Dec 30, 2023
21 checks passed
@DaniPopes DaniPopes mentioned this pull request Dec 30, 2023
3 tasks
@fgimenez fgimenez deleted the chore/move-define-udt branch December 30, 2023 20:34
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.

Move define_udt! decl macro to sol! proc macro
2 participants