mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-10 00:38:07 +00:00
sp-api: Use macro to detect if frame-metadata is enabled (#4117)
While `sp-api-proc-macro` isn't used directly and thus, it should have the same features enabled as `sp-api`. However, I have seen issues around `frame-metadata` not being enabled for `sp-api`, but for `sp-api-proc-macro`. This can be prevented by using the `frame_metadata_enabled` macro from `sp-api` that ensures we have the same feature set between both crates.
This commit is contained in:
@@ -164,15 +164,17 @@ pub fn generate_decl_runtime_metadata(decl: &ItemTrait) -> TokenStream2 {
|
||||
let (impl_generics, _, where_clause) = generics.split_for_impl();
|
||||
|
||||
quote!(
|
||||
#( #attrs )*
|
||||
#[inline(always)]
|
||||
pub fn runtime_metadata #impl_generics () -> #crate_::metadata_ir::RuntimeApiMetadataIR
|
||||
#where_clause
|
||||
{
|
||||
#crate_::metadata_ir::RuntimeApiMetadataIR {
|
||||
name: #trait_name,
|
||||
methods: #crate_::vec![ #( #methods, )* ],
|
||||
docs: #docs,
|
||||
#crate_::frame_metadata_enabled! {
|
||||
#( #attrs )*
|
||||
#[inline(always)]
|
||||
pub fn runtime_metadata #impl_generics () -> #crate_::metadata_ir::RuntimeApiMetadataIR
|
||||
#where_clause
|
||||
{
|
||||
#crate_::metadata_ir::RuntimeApiMetadataIR {
|
||||
name: #trait_name,
|
||||
methods: #crate_::vec![ #( #methods, )* ],
|
||||
docs: #docs,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -255,14 +257,16 @@ pub fn generate_impl_runtime_metadata(impls: &[ItemImpl]) -> Result<TokenStream2
|
||||
// `construct_runtime!` is called.
|
||||
|
||||
Ok(quote!(
|
||||
#[doc(hidden)]
|
||||
trait InternalImplRuntimeApis {
|
||||
#[inline(always)]
|
||||
fn runtime_metadata(&self) -> #crate_::vec::Vec<#crate_::metadata_ir::RuntimeApiMetadataIR> {
|
||||
#crate_::vec![ #( #metadata, )* ]
|
||||
#crate_::frame_metadata_enabled! {
|
||||
#[doc(hidden)]
|
||||
trait InternalImplRuntimeApis {
|
||||
#[inline(always)]
|
||||
fn runtime_metadata(&self) -> #crate_::vec::Vec<#crate_::metadata_ir::RuntimeApiMetadataIR> {
|
||||
#crate_::vec![ #( #metadata, )* ]
|
||||
}
|
||||
}
|
||||
#[doc(hidden)]
|
||||
impl InternalImplRuntimeApis for #runtime_name {}
|
||||
}
|
||||
#[doc(hidden)]
|
||||
impl InternalImplRuntimeApis for #runtime_name {}
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user