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

feat(sol-macro): provide a way to override import paths for dependencies #527

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Feb 12, 2024

Allows creating sol! wrappers to specify the import path for dependencies so downstream users don't have to worry about the dependency import problem.

For example alloy_core::sol! is a wrapper that provides #![sol(alloy_sol_types = $crate::sol_types)].

Achieved by:

  • removing leading :: from imports
  • adding #[sol({alloy_sol_types,alloy_contract} = <path>)] attributes
  • adding a use #attribute_value_or_default as alloy_sol_types; import where possible, or directly using the value where not possible (like in struct or type declarations, because we don't "own" the scope multiple sol! calls would fail)

Tested with alloy-contract by patching to this branch locally and using #![sol(alloy_contract = crate)].

@DaniPopes DaniPopes force-pushed the dani/sol-configurable-imports branch 5 times, most recently from 18c3044 to 3c1ac68 Compare February 13, 2024 00:04
/// [`sol!`](alloy_sol_types::sol!) macro wrapper to route imports to the correct crate.
///
/// See [`sol!`](alloy_sol_types::sol!) for the actual macro documentation.
#[cfg(all(not(doc), feature = "sol-types"))]
Copy link
Member Author

Choose a reason for hiding this comment

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

not(doc) so that generated documentation (e.g. docs.rs) displays the sol! re-export instead of this wrapper.

@DaniPopes DaniPopes merged commit 5624e45 into main Feb 13, 2024
21 checks passed
@DaniPopes DaniPopes deleted the dani/sol-configurable-imports branch February 13, 2024 16:51
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.

2 participants