Suppose I have the following cross pallet function call
// Pallet A : method that sets a storage variable
pub fn try_set_value_in_pallet_a(value: u64) -> DispatchResult {
ensure!(!value.is_zero(), Error::<T>::CannotSetZeroValue);
ValueA::<T>::set(value);
Ok(())
}
// Pallet B : extrinsic leveraging functionality in pallet A
#[weights(...)]
pub fn foo(value_a: u64, value_b: u64) -> DispatchResult {
ensure!(!b.is_zero(), Error::<T>::CannotSetZeroValue);
ValueB::<T>::set(value_b);
PalletA::<T>::try_set_value_in_pallet_a(value_a)?;
}
In this case if the following behavior is desired:
Either foo
in Pallet B succeeds or it leaves PalletA and PalletB states invariate.
Where should I put the #[transactional]
macro? Should I put it above foo
only?