Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Feb 21, 2024
1 parent c855bb4 commit d883951
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion near-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,26 @@ use proc_macro::TokenStream;
use self::core_impl::*;
use proc_macro2::{Ident, Span};
use quote::{quote, ToTokens};
use syn::{parse_quote, ImplItem, ItemEnum, ItemImpl, ItemStruct, ItemTrait, WhereClause};
use syn::{parse_quote, parse_macro_input, ImplItem, ItemEnum, ItemImpl, ItemStruct, ItemTrait, WhereClause, DeriveInput};

#[proc_macro_attribute]
pub fn my_near(attr: TokenStream, item: TokenStream) -> TokenStream {
let input = parse_macro_input!(item as DeriveInput);

let expanded = quote! {
// Call the derive macro you want to use
#[derive(Clone, Serialize, Deserialize, BorshDeserialize, BorshSerialize, JsonSchema)]
#[serde(crate = "near_sdk::serde")]
#[borsh(crate = "near_sdk::borsh")]
#[schemars(crate = "near_sdk::schemars")]
// Include the original input
#input
};

eprintln!("{}", expanded);

TokenStream::from(expanded)
}

/// This attribute macro is used on a struct and its implementations
/// to generate the necessary code to expose `pub` methods from the contract as well
Expand Down
2 changes: 1 addition & 1 deletion near-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern crate quickcheck;
#[cfg(feature = "abi")]
pub use near_sdk_macros::NearSchema;
pub use near_sdk_macros::{
ext_contract, near_bindgen, BorshStorageKey, EventMetadata, FunctionError, PanicOnDefault,
ext_contract, near_bindgen, my_near, BorshStorageKey, EventMetadata, FunctionError, PanicOnDefault,
};

pub mod store;
Expand Down

0 comments on commit d883951

Please sign in to comment.