Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
varovainen committed Nov 14, 2024
1 parent f816c2a commit 46eb43c
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 80 deletions.
176 changes: 98 additions & 78 deletions src/fill_prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,73 +1195,89 @@ fn try_default_tip_assets_in_given_asset<E: ExternalMemory, M: AsFillMetadata<E>
) {
*variant_selector = new_variant_selector;
if variant_selector.selected.fields_to_fill.len() == 1 {
if let TypeContentToFill::Composite(ref mut fields_to_fill) = variant_selector.selected.fields_to_fill[0].type_to_fill.content {
if let TypeContentToFill::Composite(ref mut fields_to_fill) =
variant_selector.selected.fields_to_fill[0]
.type_to_fill
.content
{
for field_to_fill in fields_to_fill.iter_mut() {
if let Some(field_name) = &field_to_fill.field_name {
match field_name.as_str() {
"parents" => if let TypeContentToFill::Primitive(PrimitiveToFill::Unsigned(
ref mut specialty_unsigned_to_fill,
)) = field_to_fill.type_to_fill.content {
specialty_unsigned_to_fill.content.upd_from_u8(0);
}
"interior" => if let TypeContentToFill::Variant(
ref mut variant_selector_interior,
) = field_to_fill.type_to_fill.content {
// search for index of `X2` variant here; `X2` means 2 junctions in asset address
let mut index_of_x2 = None;

for (index, variant) in variant_selector_interior
.available_variants
.iter()
.enumerate()
"parents" => {
if let TypeContentToFill::Primitive(
PrimitiveToFill::Unsigned(
ref mut specialty_unsigned_to_fill,
),
) = field_to_fill.type_to_fill.content
{
if variant.name == "X2" {
index_of_x2 = Some(index);
break;
}
specialty_unsigned_to_fill.content.upd_from_u8(0);
}
}
"interior" => {
if let TypeContentToFill::Variant(
ref mut variant_selector_interior,
) = field_to_fill.type_to_fill.content
{
// search for index of `X2` variant here; `X2` means 2 junctions in asset address
let mut index_of_x2 = None;

if let Some(index_x2) = index_of_x2 {
if let Ok(new_variant_selector_interior) =
VariantSelector::new_at::<E, M>(
&variant_selector_interior.available_variants,
ext_memory,
registry,
index_x2,
)
for (index, variant) in variant_selector_interior
.available_variants
.iter()
.enumerate()
{
*variant_selector_interior =
new_variant_selector_interior;
if variant_selector_interior
.selected
.fields_to_fill
.len()
== 2
if variant.name == "X2" {
index_of_x2 = Some(index);
break;
}
}

if let Some(index_x2) = index_of_x2 {
if let Ok(new_variant_selector_interior) =
VariantSelector::new_at::<E, M>(
&variant_selector_interior
.available_variants,
ext_memory,
registry,
index_x2,
)
{
if let TypeContentToFill::Variant(
ref mut junction_variant_selector_0,
) = variant_selector_interior
*variant_selector_interior =
new_variant_selector_interior;
if variant_selector_interior
.selected
.fields_to_fill[0]
.type_to_fill
.content
.fields_to_fill
.len()
== 2
{
let mut index_pallet_instance = None;
for (index, variant) in
junction_variant_selector_0
.available_variants
.iter()
.enumerate()
if let TypeContentToFill::Variant(
ref mut junction_variant_selector_0,
) = variant_selector_interior
.selected
.fields_to_fill[0]
.type_to_fill
.content
{
if variant.name == "PalletInstance" {
index_pallet_instance = Some(index);
break;
let mut index_pallet_instance =
None;
for (index, variant) in
junction_variant_selector_0
.available_variants
.iter()
.enumerate()
{
if variant.name
== "PalletInstance"
{
index_pallet_instance =
Some(index);
break;
}
}
}
if let Some(index_pallet_instance) =
index_pallet_instance
{
if let Ok(
if let Some(index_pallet_instance) =
index_pallet_instance
{
if let Ok(
new_junction_variant_selector_0,
) = VariantSelector::new_at::<E, M>(
&junction_variant_selector_0
Expand All @@ -1285,32 +1301,35 @@ fn try_default_tip_assets_in_given_asset<E: ExternalMemory, M: AsFillMetadata<E>
}
}
}
}
}
if let TypeContentToFill::Variant(
ref mut junction_variant_selector_1,
) = variant_selector_interior
.selected
.fields_to_fill[1]
.type_to_fill
.content
{
let mut index_general_index = None;
for (index, variant) in
junction_variant_selector_1
.available_variants
.iter()
.enumerate()
{
if variant.name == "GeneralIndex" {
index_general_index = Some(index);
break;
}
}
if let Some(index_general_index) =
index_general_index
if let TypeContentToFill::Variant(
ref mut junction_variant_selector_1,
) = variant_selector_interior
.selected
.fields_to_fill[1]
.type_to_fill
.content
{
if let Ok(
let mut index_general_index = None;
for (index, variant) in
junction_variant_selector_1
.available_variants
.iter()
.enumerate()
{
if variant.name
== "GeneralIndex"
{
index_general_index =
Some(index);
break;
}
}
if let Some(index_general_index) =
index_general_index
{
if let Ok(
new_junction_variant_selector_1,
) = VariantSelector::new_at::<E, M>(
&junction_variant_selector_1
Expand All @@ -1334,6 +1353,7 @@ fn try_default_tip_assets_in_given_asset<E: ExternalMemory, M: AsFillMetadata<E>
}
}
}
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn init_transaction_assets() {
assert!(transaction_to_fill_test.is_ok());
let mut transaction_to_fill = transaction_to_fill_test.unwrap();
transaction_to_fill.try_default_tip_assets_in_given_asset(&mut (), &metadata_statemint, 1337);

let mut found_assets_part = false;
let expected_hex_part = "00010002043205e514";
let expected_part = hex::decode(expected_hex_part).unwrap();
Expand All @@ -83,7 +83,9 @@ fn init_transaction_assets() {
break;
}
}
if !found_assets_part {panic!("Assets part did not get finalized.")}
if !found_assets_part {
panic!("Assets part did not get finalized.")
}
}

#[test]
Expand Down

0 comments on commit 46eb43c

Please sign in to comment.