Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix storage migration for assets-manager #1288

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions runtime/calamari/src/migrations/asset_manager.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading