Skip to content

Commit

Permalink
Fix storage migration for assets-manager (#1288)
Browse files Browse the repository at this point in the history
Signed-off-by: Dengjianping <djptux@gmail.com>
  • Loading branch information
Dengjianping committed Dec 28, 2023
1 parent 74aeb00 commit c050a00
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 5 deletions.
42 changes: 39 additions & 3 deletions runtime/calamari/src/migrations/asset_manager.rs
Expand Up @@ -382,6 +382,18 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
})) = v1_location
{
match interior {
// kusama location
v1::Junctions::Here => {
let v3_junctions = Junctions::Here;
let v3_location =
VersionedMultiLocation::V3(MultiLocation::new(parents, v3_junctions));
put_storage_value(
pallet_prefix,
storage_item_prefix,
&Blake2_128Concat::hash(&asset_id.encode()),
v3_location,
);
}
// we have two X1::Junction::Parachain: 2004 and 2084
// { Parachain }: 2
v1::Junctions::X1(v1::Junction::Parachain(para_id)) => {
Expand All @@ -402,7 +414,7 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
) => {
let v3_general_key = {
let mut data = [0u8; 32];
data.copy_from_slice(&general_key[..]);
data[..general_key.len()].copy_from_slice(&general_key[..]);
Junction::GeneralKey {
length: general_key.len() as u8,
data,
Expand Down Expand Up @@ -484,6 +496,18 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
})) = v1_location
{
match interior {
// kusama location
v1::Junctions::Here => {
let v3_junctions = Junctions::Here;
let v3_location =
VersionedMultiLocation::V3(MultiLocation::new(parents, v3_junctions));
put_storage_value(
pallet_prefix,
storage_item_prefix,
&Blake2_128Concat::hash(&v3_location.encode()),
asset_id,
);
}
// we have two X1::Junction::Parachain: 2004 and 2084
// { Parachain }: 2
v1::Junctions::X1(v1::Junction::Parachain(para_id)) => {
Expand All @@ -504,7 +528,7 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
) => {
let v3_general_key = {
let mut data = [0u8; 32];
data.copy_from_slice(&general_key[..]);
data[..general_key.len()].copy_from_slice(&general_key[..]);
Junction::GeneralKey {
length: general_key.len() as u8,
data,
Expand Down Expand Up @@ -586,6 +610,18 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
})) = v1_location
{
match interior {
// kusama location
v1::Junctions::Here => {
let v3_junctions = Junctions::Here;
let v3_location =
VersionedMultiLocation::V3(MultiLocation::new(parents, v3_junctions));
put_storage_value(
pallet_prefix,
storage_item_prefix,
&Blake2_128Concat::hash(&v3_location.encode()),
fees,
);
}
// we have two X1::Junction::Parachain: 2004 and 2084
// { Parachain }: 2
v1::Junctions::X1(v1::Junction::Parachain(para_id)) => {
Expand All @@ -606,7 +642,7 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
) => {
let v3_general_key = {
let mut data = [0u8; 32];
data.copy_from_slice(&general_key[..]);
data[..general_key.len()].copy_from_slice(&general_key[..]);
Junction::GeneralKey {
length: general_key.len() as u8,
data,
Expand Down
28 changes: 26 additions & 2 deletions runtime/manta/src/migrations/asset_manager.rs
Expand Up @@ -382,6 +382,18 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
})) = v1_location
{
match interior {
// polkadot location
v1::Junctions::Here => {
let v3_junctions = Junctions::Here;
let v3_location =
VersionedMultiLocation::V3(MultiLocation::new(parents, v3_junctions));
put_storage_value(
pallet_prefix,
storage_item_prefix,
&Blake2_128Concat::hash(&asset_id.encode()),
v3_location,
);
}
// we have two X1::Junction::Parachain: 2004 and 2084
// { Parachain }: 2
v1::Junctions::X1(v1::Junction::Parachain(para_id)) => {
Expand All @@ -402,7 +414,7 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
) => {
let v3_general_key = {
let mut data = [0u8; 32];
data.copy_from_slice(&general_key[..]);
data[..general_key.len()].copy_from_slice(&general_key[..]);
Junction::GeneralKey {
length: general_key.len() as u8,
data,
Expand Down Expand Up @@ -505,6 +517,18 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
})) = v1_location
{
match interior {
// polkadot location
v1::Junctions::Here => {
let v3_junctions = Junctions::Here;
let v3_location =
VersionedMultiLocation::V3(MultiLocation::new(parents, v3_junctions));
put_storage_value(
pallet_prefix,
storage_item_prefix,
&Blake2_128Concat::hash(&v3_location.encode()),
asset_id,
);
}
// we have 1 X1::Junction::Parachain: 2104
// { Parachain }: 1
v1::Junctions::X1(v1::Junction::Parachain(para_id)) => {
Expand All @@ -525,7 +549,7 @@ impl<T: frame_system::Config + pallet_asset_manager::Config> OnRuntimeUpgrade fo
) => {
let v3_general_key = {
let mut data = [0u8; 32];
data.copy_from_slice(&general_key[..]);
data[..general_key.len()].copy_from_slice(&general_key[..]);
Junction::GeneralKey {
length: general_key.len() as u8,
data,
Expand Down

0 comments on commit c050a00

Please sign in to comment.