diff --git a/ic-kit-macros/src/entry.rs b/ic-kit-macros/src/entry.rs index ec5b49c..bd5307f 100644 --- a/ic-kit-macros/src/entry.rs +++ b/ic-kit-macros/src/entry.rs @@ -264,16 +264,15 @@ pub fn gen_entry_point_code( }; // only declare candid if hide is false - if !attrs.hidden.unwrap_or(false) { - declare( - entry_point, - name.clone(), - candid_name, - can_args, - can_types, - &signature.output, - )?; - } + declare( + entry_point, + name.clone(), + candid_name, + attrs.hidden.unwrap_or(false), + can_args, + can_types, + &signature.output, + )?; Ok(quote! { #[doc(hidden)] diff --git a/ic-kit-macros/src/export_service.rs b/ic-kit-macros/src/export_service.rs index 46027b6..7d43278 100644 --- a/ic-kit-macros/src/export_service.rs +++ b/ic-kit-macros/src/export_service.rs @@ -7,6 +7,7 @@ use std::sync::Mutex; use syn::{DeriveInput, Error}; struct Method { + hidden: bool, mode: EntryPoint, rust_name: String, _arg_names: Vec, @@ -23,6 +24,7 @@ pub(crate) fn declare( entry_point: EntryPoint, rust_name: Ident, name: String, + hidden: bool, can_args: Vec, can_types: Vec, rt: &syn::ReturnType, @@ -41,6 +43,7 @@ pub(crate) fn declare( }; let method = Method { + hidden, mode: entry_point, rust_name: rust_name.to_string(), _arg_names: can_args.iter().map(|i| i.to_string()).collect(), @@ -113,6 +116,7 @@ pub fn export_service(input: DeriveInput, save_candid_path: Option) arg_types, rets, mode, + hidden, .. }, )| { @@ -134,15 +138,19 @@ pub fn export_service(input: DeriveInput, save_candid_path: Option) _ => unreachable!(), }; - quote! { - { - let mut args = Vec::new(); - #(#args)* - let mut rets = Vec::new(); - #(#rets)* - let func = Function { args, rets, modes: #modes }; - service.push((#name.to_string(), Type::Func(func))); + if !hidden { + quote! { + { + let mut args = Vec::new(); + #(#args)* + let mut rets = Vec::new(); + #(#rets)* + let func = Function { args, rets, modes: #modes }; + service.push((#name.to_string(), Type::Func(func))); + } } + } else { + quote! {} } }, );