mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +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:
@@ -267,7 +267,40 @@ macro_rules! ord_parameter_types {
|
||||
}
|
||||
|
||||
#[doc(inline)]
|
||||
pub use frame_support_procedural::{decl_storage, construct_runtime, transactional};
|
||||
pub use frame_support_procedural::{
|
||||
decl_storage, construct_runtime, transactional
|
||||
};
|
||||
|
||||
/// Assert the annotated function is executed within a storage transaction.
|
||||
///
|
||||
/// The assertion is enabled for native execution and when `debug_assertions` are enabled.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// # use frame_support::{
|
||||
/// # require_transactional, transactional, dispatch::DispatchResult
|
||||
/// # };
|
||||
///
|
||||
/// #[require_transactional]
|
||||
/// fn update_all(value: u32) -> DispatchResult {
|
||||
/// // Update multiple storages.
|
||||
/// // Return `Err` to indicate should revert.
|
||||
/// Ok(())
|
||||
/// }
|
||||
///
|
||||
/// #[transactional]
|
||||
/// fn safe_update(value: u32) -> DispatchResult {
|
||||
/// // This is safe
|
||||
/// update_all(value)
|
||||
/// }
|
||||
///
|
||||
/// fn unsafe_update(value: u32) -> DispatchResult {
|
||||
/// // this may panic if unsafe_update is not called within a storage transaction
|
||||
/// update_all(value)
|
||||
/// }
|
||||
/// ```
|
||||
pub use frame_support_procedural::require_transactional;
|
||||
|
||||
/// Return Err of the expression: `return Err($expression);`.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user