lang: Add anchor-debug feature flag for logging (#253)
This commit is contained in:
parent
5d8cad6ce9
commit
d08ec0326e
|
@ -14,6 +14,7 @@ incremented for features.
|
|||
## Features
|
||||
|
||||
* client: Adds support for state instructions ([#248](https://github.com/project-serum/anchor/pull/248)).
|
||||
* lang: Add `anchor-debug` feature flag for logging ([#253](https://github.com/project-serum/anchor/pull/253)).
|
||||
* ts: Add support for u16 ([#255](https://github.com/project-serum/anchor/pull/255)).
|
||||
|
||||
## Breaking
|
||||
|
|
|
@ -10,6 +10,17 @@ description = "Solana Sealevel eDSL"
|
|||
[features]
|
||||
derive = []
|
||||
default = []
|
||||
anchor-debug = [
|
||||
"anchor-attribute-access-control/anchor-debug",
|
||||
"anchor-attribute-account/anchor-debug",
|
||||
"anchor-attribute-error/anchor-debug",
|
||||
"anchor-attribute-event/anchor-debug",
|
||||
"anchor-attribute-interface/anchor-debug",
|
||||
"anchor-attribute-program/anchor-debug",
|
||||
"anchor-attribute-program/anchor-debug",
|
||||
"anchor-attribute-state/anchor-debug",
|
||||
"anchor-derive-accounts/anchor-debug"
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
anchor-attribute-access-control = { path = "./attribute/access-control", version = "0.4.5" }
|
||||
|
|
|
@ -10,6 +10,9 @@ edition = "2018"
|
|||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
anchor-debug = ["anchor-syn/anchor-debug"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -10,6 +10,9 @@ edition = "2018"
|
|||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
anchor-debug = ["anchor-syn/anchor-debug"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -10,6 +10,9 @@ edition = "2018"
|
|||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
anchor-debug = ["anchor-syn/anchor-debug"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -10,6 +10,9 @@ edition = "2018"
|
|||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
anchor-debug = ["anchor-syn/anchor-debug"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -10,6 +10,9 @@ edition = "2018"
|
|||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
anchor-debug = ["anchor-syn/anchor-debug"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -10,6 +10,9 @@ edition = "2018"
|
|||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
anchor-debug = ["anchor-syn/anchor-debug"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -10,6 +10,9 @@ edition = "2018"
|
|||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
anchor-debug = ["anchor-syn/anchor-debug"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -10,6 +10,10 @@ edition = "2018"
|
|||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
anchor-debug = ["anchor-syn/anchor-debug"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -11,6 +11,7 @@ edition = "2018"
|
|||
idl = []
|
||||
hash = []
|
||||
default = []
|
||||
anchor-debug = []
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
|
|||
let name = &s.ident;
|
||||
let ty = &s.raw_field.ty;
|
||||
quote! {
|
||||
#[cfg(feature = "debug-log")]
|
||||
#[cfg(feature = "anchor-debug")]
|
||||
::solana_program::log::sol_log(stringify!(#name));
|
||||
let #name: #ty = anchor_lang::Accounts::try_accounts(program_id, accounts)?;
|
||||
}
|
||||
|
@ -40,12 +40,12 @@ pub fn generate(accs: AccountsStruct) -> proc_macro2::TokenStream {
|
|||
let name = &f.typed_ident();
|
||||
match f.is_init {
|
||||
false => quote! {
|
||||
#[cfg(feature = "debug-log")]
|
||||
#[cfg(feature = "anchor-debug")]
|
||||
::solana_program::log::sol_log(stringify!(#name));
|
||||
let #name = anchor_lang::Accounts::try_accounts(program_id, accounts)?;
|
||||
},
|
||||
true => quote! {
|
||||
#[cfg(feature = "debug-log")]
|
||||
#[cfg(feature = "anchor-debug")]
|
||||
::solana_program::log::sol_log(stringify!(#name));
|
||||
let #name = anchor_lang::AccountsInit::try_accounts_init(program_id, accounts)?;
|
||||
},
|
||||
|
|
|
@ -67,6 +67,10 @@ pub fn generate(program: Program) -> proc_macro2::TokenStream {
|
|||
/// program, where execution begins.
|
||||
#[cfg(not(feature = "no-entrypoint"))]
|
||||
fn entry(program_id: &Pubkey, accounts: &[AccountInfo], ix_data: &[u8]) -> ProgramResult {
|
||||
#[cfg(feature = "anchor-debug")]
|
||||
{
|
||||
msg!("anchor-debug is active");
|
||||
}
|
||||
if ix_data.len() < 8 {
|
||||
return Err(ProgramError::Custom(99));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue