mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 19:47:59 +00:00
Implements require_transactional (#7261)
* Implements require_transactional * support wasm * only enable for debug build * remove wasm support and add feature flag * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * only use check for debug_assertions * update per review * update docs * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * remove duplicated tests * fix test Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -325,3 +325,8 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream {
|
||||
pub fn transactional(attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||
transactional::transactional(attr, input).unwrap_or_else(|e| e.to_compile_error().into())
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn require_transactional(attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||
transactional::require_transactional(attr, input).unwrap_or_else(|e| e.to_compile_error().into())
|
||||
}
|
||||
|
||||
@@ -41,3 +41,18 @@ pub fn transactional(_attr: TokenStream, input: TokenStream) -> Result<TokenStre
|
||||
|
||||
Ok(output.into())
|
||||
}
|
||||
|
||||
pub fn require_transactional(_attr: TokenStream, input: TokenStream) -> Result<TokenStream> {
|
||||
let ItemFn { attrs, vis, sig, block } = syn::parse(input)?;
|
||||
|
||||
let crate_ = generate_crate_access_2018()?;
|
||||
let output = quote! {
|
||||
#(#attrs)*
|
||||
#vis #sig {
|
||||
#crate_::storage::require_transaction();
|
||||
#block
|
||||
}
|
||||
};
|
||||
|
||||
Ok(output.into())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user