difftreelog
refactor(foreign-asset) remove migration
in: master
2 files changed
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -202,7 +202,6 @@
accounts: BTreeMap::new(),
},
ethereum: EthereumConfig {},
- foreign_assets: Default::default(),
polkadot_xcm: Default::default(),
transaction_payment: Default::default(),
}
@@ -255,7 +254,6 @@
accounts: BTreeMap::new(),
},
ethereum: EthereumConfig {},
- foreign_assets: Default::default(),
polkadot_xcm: Default::default(),
transaction_payment: Default::default(),
}
pallets/foreign-assets/src/lib.rsdiffbeforeafterboth276 StorageMap<_, Twox64Concat, ForeignAssetId, CollectionId, OptionQuery>;276 StorageMap<_, Twox64Concat, ForeignAssetId, CollectionId, OptionQuery>;277277278 #[pallet::pallet]278 #[pallet::pallet]279 #[pallet::without_storage_info]280 pub struct Pallet<T>(_);279 pub struct Pallet<T>(_);281282 pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);283 #[pallet::hooks]284 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {285 fn on_runtime_upgrade() -> Weight {286 let mut weight = Weight::default();287 // 0-1 -- xcmv2 => xcmv3288 if StorageVersion::get::<Pallet<T>>() <= 0 {289 pub trait V0ToV1 {290 type Pallet: 'static + PalletInfoAccess;291 }292 #[frame_support::storage_alias]293 type LocationToCurrencyIds<T: Config> =294 StorageMap<Pallet<T>, Twox64Concat, xcm::v2::MultiLocation, ForeignAssetId>;295 <ForeignAssetLocations<T>>::translate_values::<xcm::v2::MultiLocation, _>(|loc| {296 weight += T::DbWeight::get().reads_writes(1, 1);297 Some(298 xcm::v3::MultiLocation::try_from(loc)299 .expect("failed to migrate multilocation from XCMv2 to XCMv3"),300 )301 });302303 let old_values: Vec<(xcm::v2::MultiLocation, _)> =304 <LocationToCurrencyIds<T>>::drain().collect();305 weight += T::DbWeight::get()306 .reads_writes(old_values.len() as u64, old_values.len() as u64);307 for (loc, asset_id) in old_values {308 let loc = xcm::v3::MultiLocation::try_from(loc)309 .expect("failed to migrate multilocation from XCMv2 to XCMv3");310 <crate::LocationToCurrencyIds<T>>::insert(loc, asset_id);311 }312 }313 STORAGE_VERSION.put::<Pallet<T>>();314 weight += T::DbWeight::get().writes(1);315 weight316 }317 }318319 #[pallet::genesis_config]320 pub struct GenesisConfig;321322 #[cfg(feature = "std")]323 impl Default for GenesisConfig {324 fn default() -> Self {325 Self326 }327 }328329 #[pallet::genesis_build]330 impl<T: Config> GenesisBuild<T> for GenesisConfig {331 fn build(&self) {332 STORAGE_VERSION.put::<Pallet<T>>();333 }334 }335280336 #[pallet::call]281 #[pallet::call]337 impl<T: Config> Pallet<T> {282 impl<T: Config> Pallet<T> {