obce_codegen/
extension.rs1use proc_macro2::TokenStream;
2use quote::quote;
3use syn::{
4 parse2,
5 Error,
6 ItemStruct,
7};
8
9pub fn ink(_: TokenStream, input: TokenStream) -> Result<TokenStream, Error> {
10 let struct_item: ItemStruct = parse2(input)?;
11
12 let struct_name = &struct_item.ident;
13
14 Ok(quote! {
15 #struct_item
16
17 #[cfg(feature = "ink")]
18 impl ::obce::ink_lang::ChainExtensionInstance for #struct_name {
19 type Instance = #struct_name;
20
21 fn instantiate() -> Self::Instance {
22 #struct_name
23 }
24 }
25 })
26}