diff --git a/pallets/processor/src/lib.rs b/pallets/processor/src/lib.rs index 90cd248..f743b7d 100644 --- a/pallets/processor/src/lib.rs +++ b/pallets/processor/src/lib.rs @@ -43,6 +43,9 @@ pub use weights::WeightInfo; const LOG_TARGET: &str = "runtime::order-creator"; +pub type BalanceOf = + <::Currency as Currency<::AccountId>>::Balance; + pub type RegionRecordOf = RegionRecord<::AccountId, ::Balance>; @@ -118,7 +121,12 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Order got fulfilled with a region which is matching the requirements. - OrderProcessed { order_id: OrderId, region_id: RegionId, seller: T::AccountId }, + OrderProcessed { + order_id: OrderId, + region_id: RegionId, + seller: T::AccountId, + reward: BalanceOf, + }, /// Region got successfully assigned to a parachain. RegionAssigned { region_id: RegionId, para_id: ParaId }, /// Region assignment failed. @@ -204,7 +212,12 @@ pub mod pallet { // remove the order T::Orders::remove_order(&order_id); - Self::deposit_event(Event::OrderProcessed { order_id, region_id, seller: who }); + Self::deposit_event(Event::OrderProcessed { + order_id, + region_id, + seller: who, + reward: amount, + }); // NOTE: If the assignment fails, we don't return an error; instead, we return ok and // allow anyone to attempt to assign the region. diff --git a/pallets/processor/src/tests.rs b/pallets/processor/src/tests.rs index 4d84028..ff4e20c 100644 --- a/pallets/processor/src/tests.rs +++ b/pallets/processor/src/tests.rs @@ -80,11 +80,19 @@ fn fulfill_order_works() { // Works with a region that meets the requirements and is unlocked: Regions::unlock(®ion_id.into(), None).unwrap(); + + assert_eq!(Balances::free_balance(region_owner), 0); assert_ok!(Processor::fulfill_order(RuntimeOrigin::signed(region_owner), 0, region_id)); // Check events System::assert_has_event(Event::RegionAssigned { region_id, para_id: 2000.into() }.into()); System::assert_has_event( - Event::OrderProcessed { order_id: 0, region_id, seller: region_owner }.into(), + Event::OrderProcessed { + order_id: 0, + region_id, + seller: region_owner, + reward: 1500u32.into(), + } + .into(), ); // Ensure order is removed: