You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This issue is a syntax proposal to support atomic transaction annotation for dispatchable calls definition in decl_module.
The boilerplate
With nested storage supported #6269 , now transaction rollback on error is possible. A typical atomic dispatch call implementation would be:
use frame_support::storage::{with_transaction,TransactionOutcome};pubfnmy_call(origin){with_transaction(|| {// `my_call` implementation// -- snip --// Finally we have a `Result` of execution as `r`if r.is_ok(){TransactionOutcome::Commit(res)}else{TransactionOutcome::Rollback(res)}})?;}
This pattern would be repeated every time defining an atomic dispatchable call.
The syntax
To avoid repeating the boilerplate, I propose to add an atomic (or other names if preferred) annotation syntax, which will wrap the implementation in a with_transaction commit/rollback pattern as above. The syntax is like: