From a152824c3b7d7807b17e2358808066680e9d04e9 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Tue, 20 Feb 2024 10:42:37 +0100 Subject: [PATCH] :bug: Fix macros --- crates/bolt-lang/attribute/component/src/lib.rs | 3 +-- crates/bolt-lang/attribute/system-input/src/lib.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/bolt-lang/attribute/component/src/lib.rs b/crates/bolt-lang/attribute/component/src/lib.rs index 1f3847a..4ee1b7e 100644 --- a/crates/bolt-lang/attribute/component/src/lib.rs +++ b/crates/bolt-lang/attribute/component/src/lib.rs @@ -62,11 +62,10 @@ pub fn component(attr: TokenStream, item: TokenStream) -> TokenStream { let name = &input.ident; let component_name = syn::Ident::new(&name.to_string().to_lowercase(), input.ident.span()); - let mod_name = syn::Ident::new(&format!("component_{}", component_name), input.ident.span()); let anchor_program = quote! { #[bolt_program(#name)] - pub mod #mod_name { + pub mod #component_name { use super::*; } }; diff --git a/crates/bolt-lang/attribute/system-input/src/lib.rs b/crates/bolt-lang/attribute/system-input/src/lib.rs index 5cb23db..bd1a7ac 100644 --- a/crates/bolt-lang/attribute/system-input/src/lib.rs +++ b/crates/bolt-lang/attribute/system-input/src/lib.rs @@ -34,11 +34,17 @@ pub fn system_input(_attr: TokenStream, item: TokenStream) -> TokenStream { if let Ok(Meta::List(meta_list)) = attr.parse_meta() { if meta_list.path.is_ident("component_id") { for nested_meta in meta_list.nested.iter() { - if let syn::NestedMeta::Meta(Meta::NameValue(MetaNameValue { path, lit: Lit::Str(lit_str), .. })) = nested_meta { + if let syn::NestedMeta::Meta(Meta::NameValue(MetaNameValue { + path, + lit: Lit::Str(lit_str), + .. + })) = nested_meta + { if path.is_ident("address") { let address = lit_str.value(); let field_type = &field.ty; return Some(quote! { + use std::str::FromStr; impl Owner for #field_type { fn owner() -> Pubkey { @@ -46,7 +52,7 @@ pub fn system_input(_attr: TokenStream, item: TokenStream) -> TokenStream { } } impl AccountSerialize for #field_type { - fn try_serialize(&self, _writer: &mut W) -> Result<()> { + fn try_serialize(&self, _writer: &mut W) -> Result<()> { Ok(()) } }