|
@@ -327,6 +327,9 @@ decl_storage! {
|
|
|
/// Worker exit rationale text length limits.
|
|
|
pub WorkerExitRationaleText get(fn worker_exit_rationale_text) : InputValidationLengthConstraint;
|
|
|
|
|
|
+ /// Worker storage text length limits.
|
|
|
+ pub WorkerStorageText get(fn worker_storage_text) : InputValidationLengthConstraint;
|
|
|
+
|
|
|
/// Map member id by hiring application id.
|
|
|
/// Required by StakingEventsHandler callback call to refund the balance on unstaking.
|
|
|
pub MemberIdByHiringApplicationId get(fn member_id_by_hiring_application_id):
|
|
@@ -338,11 +341,13 @@ decl_storage! {
|
|
|
config(opening_human_readable_text_constraint): InputValidationLengthConstraint;
|
|
|
config(worker_application_human_readable_text_constraint): InputValidationLengthConstraint;
|
|
|
config(worker_exit_rationale_text_constraint): InputValidationLengthConstraint;
|
|
|
+ config(worker_storage_text_constraint): InputValidationLengthConstraint;
|
|
|
build(|config: &GenesisConfig<T, I>| {
|
|
|
Module::<T, I>::initialize_working_group(
|
|
|
config.opening_human_readable_text_constraint,
|
|
|
config.worker_application_human_readable_text_constraint,
|
|
|
config.worker_exit_rationale_text_constraint,
|
|
|
+ config.worker_storage_text_constraint,
|
|
|
config.working_group_mint_capacity)
|
|
|
});
|
|
|
}
|
|
@@ -401,6 +406,8 @@ decl_module! {
|
|
|
// Ensure there is a signer which matches role account of worker corresponding to provided id.
|
|
|
let mut worker = Self::ensure_worker_signed(origin, &worker_id)?;
|
|
|
|
|
|
+ Self::ensure_worker_role_storage_text_is_valid(&storage)?;
|
|
|
+
|
|
|
//
|
|
|
// == MUTATION SAFE ==
|
|
|
//
|
|
@@ -1358,11 +1365,21 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
|
|
)
|
|
|
.map_err(|e| DispatchError::Other(e))
|
|
|
}
|
|
|
+
|
|
|
+ fn ensure_worker_role_storage_text_is_valid(text: &[u8]) -> DispatchResult {
|
|
|
+ Self::worker_storage_text()
|
|
|
+ .ensure_valid(
|
|
|
+ text.len(),
|
|
|
+ Error::<T, I>::WorkerStorageTextTooShort.into(),
|
|
|
+ Error::<T, I>::WorkerStorageTextTooLong.into(),
|
|
|
+ )
|
|
|
+ .map_err(|e| DispatchError::Other(e))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// Creates default text constraint.
|
|
|
pub fn default_text_constraint() -> InputValidationLengthConstraint {
|
|
|
- InputValidationLengthConstraint::new(1, 1024)
|
|
|
+ InputValidationLengthConstraint::new(1, 2048)
|
|
|
}
|
|
|
|
|
|
impl<T: Trait<I>, I: Instance> Module<T, I> {
|
|
@@ -1517,6 +1534,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
|
|
opening_human_readable_text_constraint: InputValidationLengthConstraint,
|
|
|
worker_application_human_readable_text_constraint: InputValidationLengthConstraint,
|
|
|
worker_exit_rationale_text_constraint: InputValidationLengthConstraint,
|
|
|
+ worker_storage_text_constraint: InputValidationLengthConstraint,
|
|
|
working_group_mint_capacity: minting::BalanceOf<T>,
|
|
|
) {
|
|
|
// Create a mint.
|
|
@@ -1534,6 +1552,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
|
|
worker_application_human_readable_text_constraint,
|
|
|
);
|
|
|
<WorkerExitRationaleText<I>>::put(worker_exit_rationale_text_constraint);
|
|
|
+ <WorkerStorageText<I>>::put(worker_storage_text_constraint);
|
|
|
}
|
|
|
|
|
|
// Set worker id as a leader id.
|