Skip to content

Q: Is process_fn branch in #[trusted_relayer] needed? #6

@olga24912

Description

@olga24912
pub fn trusted_relayer(args: TokenStream, input: TokenStream) -> TokenStream {
    let input_clone: proc_macro2::TokenStream = input.clone().into();

    if is_impl_block(&input_clone) {
        if args.is_empty() {
            process_impl_block_guard_only(input)
        } else {
            process_impl_block(args, input)
        }
    } else {
        if !args.is_empty() {
            return syn::Error::new(
                proc_macro2::Span::call_site(),
                "`#[trusted_relayer]` on methods does not accept arguments",
            )
            .to_compile_error()
            .into();
        }
        process_fn(input)
    }
}

Why do we need the else branch with process_fn? Both process_impl_block and process_impl_block_guard_only already inject guards into all methods marked with #[trusted_relayer] inside the impl block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions