mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Use a transaction layer when executing each InInstruction
This commit is contained in:
@@ -71,13 +71,17 @@ pub mod pallet {
|
|||||||
StorageMap<_, Blake2_256, NetworkId, BlockHash, OptionQuery>;
|
StorageMap<_, Blake2_256, NetworkId, BlockHash, OptionQuery>;
|
||||||
|
|
||||||
impl<T: Config> Pallet<T> {
|
impl<T: Config> Pallet<T> {
|
||||||
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 {
|
match instruction.instruction {
|
||||||
InInstruction::Transfer(address) => {
|
InInstruction::Transfer(address) => {
|
||||||
Coins::<T>::mint(address.into(), instruction.balance).map_err(|_| ())
|
Coins::<T>::mint(address.into(), instruction.balance)?;
|
||||||
}
|
}
|
||||||
_ => panic!("unsupported instruction"),
|
_ => panic!("unsupported instruction"),
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user