Skip to content

Commit

Permalink
🐛 Fix macros
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielePicco committed Feb 20, 2024
1 parent d0b1bd5 commit a152824
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions crates/bolt-lang/attribute/component/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
}
};
Expand Down
10 changes: 8 additions & 2 deletions crates/bolt-lang/attribute/system-input/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,25 @@ 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 {
Pubkey::from_str(#address).unwrap()
}
}
impl AccountSerialize for #field_type {
fn try_serialize<W: Write>(&self, _writer: &mut W) -> Result<()> {
fn try_serialize<W>(&self, _writer: &mut W) -> Result<()> {
Ok(())
}
}
Expand Down

0 comments on commit a152824

Please sign in to comment.