mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 12:09:37 +00:00
Use a transaction layer when executing each InInstruction
This commit is contained in:
parent
e7e30150f0
commit
6068978676
1 changed files with 6 additions and 2 deletions
|
@ -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(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue