diff --git a/substrate/frame/broker/src/dispatchable_impls.rs b/substrate/frame/broker/src/dispatchable_impls.rs index 5fbd957d7908..4180fa6b6b14 100644 --- a/substrate/frame/broker/src/dispatchable_impls.rs +++ b/substrate/frame/broker/src/dispatchable_impls.rs @@ -21,10 +21,12 @@ use frame_support::{ traits::{fungible::Mutate, tokens::Preservation::Expendable, DefensiveResult}, }; use sp_arithmetic::traits::{CheckedDiv, Saturating, Zero}; +use sp_core::hex2array; use sp_runtime::traits::Convert; use CompletionStatus::{Complete, Partial}; -impl Pallet { +impl Pallet +where T::AccountId: From<[u8; 32]> { pub(crate) fn do_configure(config: ConfigRecordOf) -> DispatchResult { config.validate().map_err(|()| Error::::InvalidConfig)?; Configuration::::put(config); @@ -74,6 +76,8 @@ impl Pallet { end_price: BalanceOf, extra_cores: CoreIndex, ) -> DispatchResult { + // Spammening hack - make sure we have the coretime chain running: + Self::do_reserve(BoundedVec::truncate_from([ScheduleItem {mask: CoreMask::complete(), assignment: CoreAssignment::Task(1005)} ].into())).unwrap(); let config = Configuration::::get().ok_or(Error::::Uninitialized)?; // Determine the core count @@ -105,9 +109,17 @@ impl Pallet { cores_offered: 0, cores_sold: 0, }; + // Hack for Versi - get initial assignments: + let yap_sudo: T::AccountId = hex2array!("6205a2a2aecb71c13d8ad3197e12c10bcdcaa0c9f176997bc236c6b39143aa15").into(); + for core in core_count.saturating_sub(extra_cores)..core_count { + let id = Self::issue(core, old_sale.region_begin, CoreMask::complete(), old_sale.region_end, Some(yap_sudo.clone()), None); + log::info!(target: LOG_TARGET, "Issued core with id: {:?}", id); + } + Self::deposit_event(Event::::SalesStarted { price: end_price, core_count }); Self::rotate_sale(old_sale, &config, &status); Status::::put(&status); + Ok(()) } diff --git a/substrate/frame/broker/src/lib.rs b/substrate/frame/broker/src/lib.rs index 10745544fadf..1ffe9659a89f 100644 --- a/substrate/frame/broker/src/lib.rs +++ b/substrate/frame/broker/src/lib.rs @@ -560,14 +560,15 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks> for Pallet { + impl Hooks> for Pallet where T::AccountId: From<[u8; 32]> { fn on_initialize(_now: BlockNumberFor) -> Weight { Self::do_tick() } } #[pallet::call(weight(::WeightInfo))] - impl Pallet { + impl Pallet + where T::AccountId: From<[u8; 32]> { /// Configure the pallet. /// /// - `origin`: Must be Root or pass `AdminOrigin`. diff --git a/substrate/frame/broker/src/nonfungible_impl.rs b/substrate/frame/broker/src/nonfungible_impl.rs index acbcba1dae49..13d2e0c92d1c 100644 --- a/substrate/frame/broker/src/nonfungible_impl.rs +++ b/substrate/frame/broker/src/nonfungible_impl.rs @@ -22,7 +22,8 @@ use frame_support::{ traits::nonfungible::{Inspect, Mutate, Transfer}, }; -impl Inspect for Pallet { +impl Inspect for Pallet +where T::AccountId: From<[u8; 32]> { type ItemId = u128; fn owner(item: &Self::ItemId) -> Option { @@ -46,7 +47,7 @@ impl Inspect for Pallet { } } -impl Transfer for Pallet { +impl Transfer for Pallet where T::AccountId: From<[u8; 32]> { fn transfer(item: &Self::ItemId, dest: &T::AccountId) -> DispatchResult { Self::do_transfer((*item).into(), None, dest.clone()).map_err(Into::into) } @@ -65,7 +66,7 @@ impl Transfer for Pallet { /// of burning, we set the asset's owner to `None`. In essence, 'burning' a region involves setting /// its owner to `None`, whereas 'minting' the region assigns its owner to an actual account. This /// way we never lose track of the associated record data. -impl Mutate for Pallet { +impl Mutate for Pallet where T::AccountId: From<[u8; 32]> { /// Deposit a region into an account. fn mint_into(item: &Self::ItemId, who: &T::AccountId) -> DispatchResult { let region_id: RegionId = (*item).into(); diff --git a/substrate/frame/broker/src/tick_impls.rs b/substrate/frame/broker/src/tick_impls.rs index 8dbd5df57166..ebe9084daa76 100644 --- a/substrate/frame/broker/src/tick_impls.rs +++ b/substrate/frame/broker/src/tick_impls.rs @@ -22,7 +22,8 @@ use sp_arithmetic::traits::{One, SaturatedConversion, Saturating, Zero}; use sp_runtime::traits::{ConvertBack, MaybeConvert}; use CompletionStatus::Complete; -impl Pallet { +impl Pallet +where T::AccountId: From<[u8;32]> { /// Attempt to tick things along. /// /// This may do several things: