-
Notifications
You must be signed in to change notification settings - Fork 13
Add CodamaPdaHelpers derive
#86
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /target | ||
| .idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ use proc_macro::TokenStream; | |
| mod attributes; | ||
| #[cfg(not(target_os = "solana"))] | ||
| mod derives; | ||
| #[cfg(not(target_os = "solana"))] | ||
| mod pda_helpers; | ||
|
|
||
| fn codama_derive(input: TokenStream) -> TokenStream { | ||
| #[cfg(not(target_os = "solana"))] | ||
|
|
@@ -57,6 +59,20 @@ pub fn codama_pda_derive(input: TokenStream) -> TokenStream { | |
| codama_derive(input) | ||
| } | ||
|
|
||
| #[proc_macro_derive(CodamaPdaHelpers, attributes(codama))] | ||
| pub fn codama_pda_helpers_derive(input: TokenStream) -> TokenStream { | ||
| #[cfg(not(target_os = "solana"))] | ||
| { | ||
| pda_helpers::codama_pda_helpers_derive_impl(input.into()) | ||
| .unwrap_or_else(codama_errors::CodamaError::into_compile_error) | ||
| .into() | ||
| } | ||
| #[cfg(target_os = "solana")] | ||
| { | ||
| input | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+62
to
+75
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if this macro was on its own crate. Maybe something like That way, if anyone wants to use a slightly different version of our generated code, it's easier for them to fork that crate on its own. |
||
| #[proc_macro_derive(CodamaType, attributes(codama))] | ||
| pub fn codama_type_derive(input: TokenStream) -> TokenStream { | ||
| codama_derive(input) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@febo better naming proposals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever we land on with the derive name, just want to flag that IMO it should start with
Codamasince it purely relies oncodamaattributes.