Conversation
| #[proc_macro_derive(CodamaPdaHelpers, attributes(codama))] | ||
| pub fn codama_pda_helpers_derive(input: TokenStream) -> TokenStream { |
There was a problem hiding this comment.
Whatever we land on with the derive name, just want to flag that IMO it should start with Codama since it purely relies on codama attributes.
| /// (wrapping `Address` methods) | ||
| /// - `derive_address` | ||
| /// - `create_program_address` | ||
| /// - `find_program_address` | ||
| /// - `try_find_program_address` | ||
| /// - `derive_program_address` |
There was a problem hiding this comment.
@febo thoughts on which Address methods this should include? This sort of wraps everything, but maybe it should be a blessed subset.
lorisleiva
left a comment
There was a problem hiding this comment.
I'll go through this thoroughly asap but I just wanted to share some early first impression feedback.
| @@ -0,0 +1,97 @@ | |||
| use heck::ToSnakeCase; | |||
There was a problem hiding this comment.
Since we already have an exported CamelCaseString struct in codama-nodes maybe it would be cleaner / more consistent to also add a SnakeCaseString struct there instead of introducing a new dependency.
| #[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 | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
It would be nice if this macro was on its own crate. Maybe something like codama-pda-helpers or whatever the name ends up being here.
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.
Adds
#[derive(CodamaPdaHelpers)]which generates runtime PDA helper methods from existing #[codama(seed(...))] attributes. This reduces repeated manual PDA boilerplate program devs are writing.API
#[codama(seed(...))]directives and generates:seedsseeds_with_bumpsigner_seedsderive_addresscreate_program_addressfind_program_addresstry_find_program_addressderive_program_addressDiscussion points
Addressmethods be shipped? Aka, should we dropfind_program_address?implvs external crate helpers