mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
Adds ability to trigger tasks via unsigned transactions (#4075)
This PR updates the `validate_unsigned` hook for `frame_system` to allow valid tasks to be submitted as unsigned transactions. It also updates the task example to be able to submit such transactions via an off-chain worker. --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -741,9 +741,7 @@ pub mod pallet {
|
||||
#[cfg(feature = "experimental")]
|
||||
#[pallet::call_index(8)]
|
||||
#[pallet::weight(task.weight())]
|
||||
pub fn do_task(origin: OriginFor<T>, task: T::RuntimeTask) -> DispatchResultWithPostInfo {
|
||||
ensure_signed(origin)?;
|
||||
|
||||
pub fn do_task(_origin: OriginFor<T>, task: T::RuntimeTask) -> DispatchResultWithPostInfo {
|
||||
if !task.is_valid() {
|
||||
return Err(Error::<T>::InvalidTask.into())
|
||||
}
|
||||
@@ -1032,6 +1030,18 @@ pub mod pallet {
|
||||
})
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "experimental")]
|
||||
if let Call::do_task { ref task } = call {
|
||||
if task.is_valid() {
|
||||
return Ok(ValidTransaction {
|
||||
priority: u64::max_value(),
|
||||
requires: Vec::new(),
|
||||
provides: vec![T::Hashing::hash_of(&task.encode()).as_ref().to_vec()],
|
||||
longevity: TransactionLongevity::max_value(),
|
||||
propagate: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
Err(InvalidTransaction::Call.into())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user