forked from open-web3-stack/open-runtime-module-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'open-web3-stack:master' into master
- Loading branch information
Showing
90 changed files
with
1,726 additions
and
705 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::{Config, LocationToAssetId, Pallet, Weight}; | ||
use frame_support::pallet_prelude::*; | ||
use frame_support::{migration::storage_key_iter, traits::OnRuntimeUpgrade, StoragePrefixedMap}; | ||
|
||
use xcm::v3::prelude::*; | ||
|
||
pub struct Migration<T>(PhantomData<T>); | ||
impl<T: Config> OnRuntimeUpgrade for Migration<T> { | ||
fn on_runtime_upgrade() -> Weight { | ||
let mut weight: Weight = Weight::zero(); | ||
let onchain_version = Pallet::<T>::on_chain_storage_version(); | ||
if onchain_version < 2 { | ||
let inner_weight = v2::migrate::<T>(); | ||
weight.saturating_accrue(inner_weight); | ||
} | ||
weight | ||
} | ||
} | ||
|
||
mod v2 { | ||
use super::*; | ||
|
||
pub(crate) fn migrate<T: Config>() -> Weight { | ||
let mut weight: Weight = Weight::zero(); | ||
let module_prefix = LocationToAssetId::<T>::module_prefix(); | ||
let storage_prefix = LocationToAssetId::<T>::storage_prefix(); | ||
|
||
weight.saturating_accrue(T::DbWeight::get().reads(1)); | ||
let old_data = | ||
storage_key_iter::<xcm::v2::MultiLocation, T::AssetId, Blake2_128Concat>(module_prefix, storage_prefix) | ||
.drain(); | ||
|
||
for (old_key, value) in old_data { | ||
weight.saturating_accrue(T::DbWeight::get().writes(1)); | ||
let new_key: MultiLocation = old_key.try_into().expect("Stored xcm::v2::MultiLocation"); | ||
LocationToAssetId::<T>::insert(new_key, value); | ||
} | ||
|
||
StorageVersion::new(2).put::<Pallet<T>>(); | ||
weight.saturating_accrue(T::DbWeight::get().writes(1)); | ||
weight | ||
} | ||
} |
Oops, something went wrong.