-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
lang: add anchor_lang::pubkey macro for declaring const Pubkey values #3021
Conversation
anchor_lang::solana_program::pubkey macro doesn’t work because it expands to code using ::solana_program::pubkey::Pubkey type (note leading ::). Since programs using anchor-lang crate usually don’t include solana-program dependency, that symbol ends up unresolved. Introduce anchor_lang::pubkey macro which accesses solana_program via anchor_lang instead. This is analogous to declare_id macro which also had to be repeated in anchor-lang.
@mina86 is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
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.
Yeah, there is actually a very old issue about this here: solana-labs/solana#24303
I think this could get fixed upstream + us exporting solana_program
from prelude
, but I also don't see any problem getting this in to Anchor.
Before we merge, could you note this feature in the CHANGELOG?
Done. Yes, if Solana dropped |
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.
declare_id
would still be necessary as we override it for idl-build
feature:
anchor/lang/attribute/account/src/lib.rs
Lines 437 to 444 in cdf2559
#[cfg(feature = "idl-build")] | |
{ | |
let idl_print = anchor_syn::idl::gen_idl_print_fn_address(address); | |
return proc_macro::TokenStream::from(quote! { | |
#ret | |
#idl_print | |
}); | |
} |
Thanks!
anchor_lang::solana_program::pubkey macro doesn’t work because it
expands to code using ::solana_program::pubkey::Pubkey type (note
leading ::). Since programs using anchor-lang crate usually don’t
include solana-program dependency, that symbol ends up unresolved.
Introduce anchor_lang::pubkey macro which accesses solana_program via
anchor_lang instead. This is analogous to declare_id macro which also
had to be repeated in anchor-lang.