|
@@ -1,9 +1,8 @@
|
|
|
use crate::forum;
|
|
|
use crate::storage;
|
|
|
use crate::VERSION;
|
|
|
-use rstd::prelude::*;
|
|
|
use runtime_io::print;
|
|
|
-use srml_support::{decl_event, decl_module, decl_storage, StorageMap, StorageValue};
|
|
|
+use srml_support::{decl_event, decl_module, decl_storage, StorageValue};
|
|
|
use sudo;
|
|
|
use system;
|
|
|
|
|
@@ -12,7 +11,7 @@ use system;
|
|
|
// the runtime doesn't need to maintain any logic for old migrations. All knowledge about state of the chain and runtime
|
|
|
// prior to the new runtime taking over is implicit in the migration code implementation. If assumptions are incorrect
|
|
|
// behaviour is undefined.
|
|
|
-const MIGRATION_FOR_SPEC_VERSION: u32 = 4;
|
|
|
+const MIGRATION_FOR_SPEC_VERSION: u32 = 0;
|
|
|
|
|
|
impl<T: Trait> Module<T> {
|
|
|
fn runtime_initialization() {
|
|
@@ -26,67 +25,11 @@ impl<T: Trait> Module<T> {
|
|
|
// add initialization of other modules introduced in this runtime
|
|
|
// ...
|
|
|
|
|
|
- Self::initialize_forum_module();
|
|
|
-
|
|
|
- Self::initialize_storage_module();
|
|
|
-
|
|
|
Self::deposit_event(RawEvent::Migrated(
|
|
|
<system::Module<T>>::block_number(),
|
|
|
VERSION.spec_version,
|
|
|
));
|
|
|
}
|
|
|
-
|
|
|
- fn initialize_forum_module() {
|
|
|
- // next id's
|
|
|
- <forum::NextCategoryId<T>>::put(1);
|
|
|
- <forum::NextThreadId<T>>::put(1);
|
|
|
- <forum::NextPostId<T>>::put(1);
|
|
|
-
|
|
|
- // sudo key will be used as initial forum sudo key
|
|
|
- <forum::ForumSudo<T>>::put(<sudo::Module<T>>::key().clone());
|
|
|
-
|
|
|
- // input validation constraints
|
|
|
- <forum::CategoryTitleConstraint<T>>::put(Self::create_input_validation_length_constraint(
|
|
|
- 10, 90,
|
|
|
- ));
|
|
|
- <forum::CategoryDescriptionConstraint<T>>::put(
|
|
|
- Self::create_input_validation_length_constraint(10, 490),
|
|
|
- );
|
|
|
- <forum::ThreadTitleConstraint<T>>::put(Self::create_input_validation_length_constraint(
|
|
|
- 10, 90,
|
|
|
- ));
|
|
|
- <forum::PostTextConstraint<T>>::put(Self::create_input_validation_length_constraint(
|
|
|
- 10, 990,
|
|
|
- ));
|
|
|
- <forum::ThreadModerationRationaleConstraint<T>>::put(
|
|
|
- Self::create_input_validation_length_constraint(10, 290),
|
|
|
- );
|
|
|
- <forum::PostModerationRationaleConstraint<T>>::put(
|
|
|
- Self::create_input_validation_length_constraint(10, 290),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- fn create_input_validation_length_constraint(
|
|
|
- min: u16,
|
|
|
- max_min_diff: u16,
|
|
|
- ) -> forum::InputValidationLengthConstraint {
|
|
|
- return forum::InputValidationLengthConstraint { min, max_min_diff };
|
|
|
- }
|
|
|
-
|
|
|
- fn initialize_storage_module() {
|
|
|
- // Remove hardcoded liaison
|
|
|
- <storage::data_directory::PrimaryLiaisonAccountId<T>>::take();
|
|
|
-
|
|
|
- // remove all content
|
|
|
- for content_id in <storage::data_directory::KnownContentIds<T>>::get().iter() {
|
|
|
- <storage::data_directory::DataObjectByContentId<T>>::remove(content_id);
|
|
|
- <storage::data_directory::MetadataByContentId<T>>::remove(content_id);
|
|
|
- <storage::data_object_storage_registry::RelationshipsByContentId<T>>::remove(
|
|
|
- content_id,
|
|
|
- );
|
|
|
- }
|
|
|
- <storage::data_directory::KnownContentIds<T>>::put(vec![]);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
pub trait Trait:
|