diff --git a/pallets/migrations/src/democracy_preimages.rs b/pallets/migrations/src/democracy_preimages.rs
deleted file mode 100644
index 47cb39a..0000000
--- a/pallets/migrations/src/democracy_preimages.rs
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright Moonsong Labs
-// This file is part of Moonkit.
-
-// Moonkit is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Moonkit is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Moonkit. If not, see .
-
-use {
- super::Error,
- frame_support::{
- pallet_prelude::*,
- traits::{Currency, PalletInfo, StorageInstance},
- },
- frame_system::{pallet_prelude::*, Config as SystemConfig},
- pallet_democracy::Config as DemocracyConfig,
- pallet_preimage::{Config as PreimageConfig, RequestStatus},
- parity_scale_codec::Input,
- sp_std::prelude::*,
-};
-
-/// Maximum size of preimage we can store is 4mb.
-pub const MAX_SIZE: u32 = 4 * 1024 * 1024;
-
-pub type BalanceOf = <::Currency as Currency<
- ::AccountId,
->>::Balance;
-
-#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
-pub enum PreimageStatus {
- /// The preimage is imminently needed at the argument.
- Missing(BlockNumber),
- /// The preimage is available.
- Available {
- data: Vec,
- provider: AccountId,
- deposit: Balance,
- since: BlockNumber,
- /// None if it's not imminent.
- expiry: Option,
- },
-}
-
-// ---- Old storage ----
-
-pub struct DeprecatedDemocracyPreimagesPrefix(PhantomData);
-
-impl StorageInstance for DeprecatedDemocracyPreimagesPrefix {
- const STORAGE_PREFIX: &'static str = "Preimages";
-
- fn pallet_prefix() -> &'static str {
- T::PalletInfo::name::>()
- .expect("there is pallet democracy installed")
- }
-}
-
-/// Storage entry for preimages once stored in pallet_democracy.
-pub(crate) type DeprecatedDemocracyPreimages = StorageMap<
- DeprecatedDemocracyPreimagesPrefix,
- Identity,
- ::Hash,
- PreimageStatus<::AccountId, BalanceOf, ::BlockNumber>,
->;
-
-// ---- New storage ----
-
-pub struct StatusForPrefix(PhantomData);
-
-impl StorageInstance for StatusForPrefix {
- const STORAGE_PREFIX: &'static str = "StatusFor";
-
- fn pallet_prefix() -> &'static str {
- T::PalletInfo::name::>()
- .expect("there is pallet preimage installed")
- }
-}
-
-pub(crate) type StatusFor = StorageMap<
- StatusForPrefix,
- Identity,
- ::Hash,
- RequestStatus<::AccountId, BalanceOf>,
->;
-
-pub struct PreimageForPrefix(PhantomData);
-
-impl StorageInstance for PreimageForPrefix {
- const STORAGE_PREFIX: &'static str = "PreimageFor";
-
- fn pallet_prefix() -> &'static str {
- T::PalletInfo::name::>()
- .expect("there is pallet preimage installed")
- }
-}
-
-pub(crate) type PreimageFor = StorageMap<
- PreimageForPrefix,
- Identity,
- (::Hash, u32),
- BoundedVec>,
->;
-
-// ---- Call ----
-
-impl super::Pallet {
- pub(crate) fn migrate_democracy_preimage_inner(
- origin: OriginFor,
- proposal_hash: T::Hash,
- proposal_len_upper_bound: u32,
- ) -> DispatchResultWithPostInfo {
- let _who = ensure_signed(origin);
-
- // Check that this hash doesn't already exist in the new storage.
- ensure!(
- !StatusFor::::contains_key(proposal_hash),
- Error::::PreimageAlreadyExists,
- );
-
- // Check bound is correct.
- ensure!(
- Self::pre_image_data_len(proposal_hash)? <= proposal_len_upper_bound,
- Error::::WrongUpperBound,
- );
-
- // Get the old preimage data.
- let (data, provider, deposit) = >::get(&proposal_hash)
- .and_then(|m| match m {
- PreimageStatus::Available {
- data,
- provider,
- deposit,
- ..
- } => Some((data, provider, deposit)),
- _ => None,
- })
- .ok_or(Error::::PreimageMissing)?;
-
- // Insert data in new storages.
- let data: BoundedVec<_, _> = data.try_into().map_err(|_| Error::::PreimageIsTooBig)?;
-
- let request_status = RequestStatus::Unrequested {
- deposit: (provider, deposit),
- len: data.len() as u32,
- };
-
- StatusFor::::insert(proposal_hash, request_status);
- PreimageFor::::insert((proposal_hash, data.len() as u32), data);
-
- // Clean old storage.
- >::remove(&proposal_hash);
-
- Ok(().into())
- }
-
- fn pre_image_data_len(proposal_hash: T::Hash) -> Result {
- // To decode the `data` field of Available variant we need:
- // * one byte for the variant
- // * at most 5 bytes to decode a `Compact`
- let mut buf = [0u8; 6];
- let key = >::hashed_key_for(proposal_hash);
- let bytes = sp_io::storage::read(&key, &mut buf, 0).ok_or(Error::::PreimageMissing)?;
- // The value may be smaller that 6 bytes.
- let mut input = &buf[0..buf.len().min(bytes as usize)];
-
- match input.read_byte() {
- Ok(1) => (), // Check that input exists and is second variant.
- Ok(0) => return Err(Error::::PreimageMissing.into()),
- _ => {
- sp_runtime::print("Failed to decode `PreimageStatus` variant");
- return Err(Error::::PreimageMissing.into());
- }
- }
-
- // Decode the length of the vector.
- let len = parity_scale_codec::Compact::::decode(&mut input)
- .map_err(|_| {
- sp_runtime::print("Failed to decode `PreimageStatus` variant");
- DispatchError::from(Error::::PreimageMissing)
- })?
- .0;
-
- Ok(len)
- }
-}