From 60689786762d55e928c1d0b9c0de70bcffe6b913 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 22 Oct 2023 05:46:03 -0400 Subject: [PATCH] Use a transaction layer when executing each InInstruction --- substrate/in-instructions/pallet/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/substrate/in-instructions/pallet/src/lib.rs b/substrate/in-instructions/pallet/src/lib.rs index f81bdd09..a536f5c0 100644 --- a/substrate/in-instructions/pallet/src/lib.rs +++ b/substrate/in-instructions/pallet/src/lib.rs @@ -71,13 +71,17 @@ pub mod pallet { StorageMap<_, Blake2_256, NetworkId, BlockHash, OptionQuery>; impl Pallet { - fn execute(instruction: InInstructionWithBalance) -> Result<(), ()> { + // Use a dedicated transaction layer when executing this InInstruction + // This lets it individually error without causing any storage modifications + #[frame_support::transactional] + fn execute(instruction: InInstructionWithBalance) -> Result<(), DispatchError> { match instruction.instruction { InInstruction::Transfer(address) => { - Coins::::mint(address.into(), instruction.balance).map_err(|_| ()) + Coins::::mint(address.into(), instruction.balance)?; } _ => panic!("unsupported instruction"), } + Ok(()) } }