From 69e372089892db43ce3620e70be166c0304c4570 Mon Sep 17 00:00:00 2001 From: David Edey Date: Tue, 15 Oct 2024 00:10:37 +0100 Subject: [PATCH] tweak: Rename `register_subintent` to `use_child` --- .../builder/manifest_builder/builder_v2.rs | 7 +- .../tests/transaction_v2_builder.rs | 74 ++++++++++--------- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/crates/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder_v2.rs b/crates/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder_v2.rs index 67625024..e8aaf883 100644 --- a/crates/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder_v2.rs +++ b/crates/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder_v2.rs @@ -1098,15 +1098,14 @@ impl ManifestV2Builder { }) } - pub fn register_subintent( + pub fn use_child( self: Arc, - subintent: Arc, + subintent_hash: Arc, name: ManifestBuilderIntent, ) -> Result> { builder_arc_map(self, |builder| { builder.name_record.new_intent(&name.name)?; - let intent_hash = subintent.subintent_hash()?.0; - builder.children.push(intent_hash); + builder.children.push(subintent_hash.0); Ok(()) }) } diff --git a/crates/radix-engine-toolkit-uniffi/tests/transaction_v2_builder.rs b/crates/radix-engine-toolkit-uniffi/tests/transaction_v2_builder.rs index 3d24fc33..6a7f1cc7 100644 --- a/crates/radix-engine-toolkit-uniffi/tests/transaction_v2_builder.rs +++ b/crates/radix-engine-toolkit-uniffi/tests/transaction_v2_builder.rs @@ -17,12 +17,12 @@ fn subintent_transaction_hash_is_derived_correctly() -> Result<()> { intent_discriminator: 100, }) .manifest( - ManifestV2Builder::new() + ManifestV2Builder::new(1) .drop_all_proofs()? .drop_auth_zone_proofs()? .drop_auth_zone_signature_proofs()? .yield_to_parent(vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -32,8 +32,7 @@ fn subintent_transaction_hash_is_derived_correctly() -> Result<()> { let subintent_hash = partial_transaction .partial_transaction() .root_subintent - .subintent_hash() - .unwrap() + .subintent_hash()? .as_str(); // Assert @@ -59,12 +58,12 @@ fn partial_transaction_builder_produces_valid_partial_transactions() intent_discriminator: 100, }) .manifest( - ManifestV2Builder::new() + ManifestV2Builder::new(1) .drop_all_proofs()? .drop_auth_zone_proofs()? .drop_auth_zone_signature_proofs()? .yield_to_parent(vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -101,12 +100,12 @@ fn partial_transaction_builder_produces_valid_partial_transactions_with_child_su intent_discriminator: 100, }) .manifest( - ManifestV2Builder::new() + ManifestV2Builder::new(1) .drop_all_proofs()? .drop_auth_zone_proofs()? .drop_auth_zone_signature_proofs()? .yield_to_parent(vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -124,16 +123,17 @@ fn partial_transaction_builder_produces_valid_partial_transactions_with_child_su }) .add_child(child_partial_transaction.clone()) .manifest( - ManifestV2Builder::new() - .register_subintent( + ManifestV2Builder::new(1) + .use_child( child_partial_transaction .partial_transaction() - .root_subintent(), + .root_subintent() + .subintent_hash()?, "subintent".into(), )? .yield_to_child("subintent".into(), vec![])? .yield_to_parent(vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -171,12 +171,12 @@ fn partial_transaction_builder_produces_valid_partial_transactions_with_multiple intent_discriminator: 100, }) .manifest( - ManifestV2Builder::new() + ManifestV2Builder::new(1) .drop_all_proofs()? .drop_auth_zone_proofs()? .drop_auth_zone_signature_proofs()? .yield_to_parent(vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -190,19 +190,20 @@ fn partial_transaction_builder_produces_valid_partial_transactions_with_multiple max_proposer_timestamp_exclusive: None, intent_discriminator: 100, }) - .add_child(child_child_partial_transaction.clone()) .manifest( - ManifestV2Builder::new() - .register_subintent( + ManifestV2Builder::new(1) + .use_child( child_child_partial_transaction .partial_transaction() - .root_subintent(), + .root_subintent() + .subintent_hash()?, "subintent".into(), )? .yield_to_child("subintent".into(), vec![])? .yield_to_parent(vec![])? - .build(1), + .build(), ) + .add_child(child_child_partial_transaction) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) .build(); @@ -219,16 +220,17 @@ fn partial_transaction_builder_produces_valid_partial_transactions_with_multiple }) .add_child(child_partial_transaction.clone()) .manifest( - ManifestV2Builder::new() - .register_subintent( + ManifestV2Builder::new(1) + .use_child( child_partial_transaction .partial_transaction() - .root_subintent(), + .root_subintent() + .subintent_hash()?, "subintent".into(), )? .yield_to_child("subintent".into(), vec![])? .yield_to_parent(vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -272,11 +274,11 @@ fn transaction_builder_v2_produces_statically_valid_transactions() -> Result<()> intent_discriminator: 100, }) .manifest( - ManifestV2Builder::new() + ManifestV2Builder::new(1) .drop_all_proofs()? .drop_auth_zone_proofs()? .drop_auth_zone_signature_proofs()? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -314,12 +316,12 @@ fn transaction_builder_v2_produces_statically_valid_transactions_with_multiple_l intent_discriminator: 100, }) .manifest( - ManifestV2Builder::new() + ManifestV2Builder::new(1) .drop_all_proofs()? .drop_auth_zone_proofs()? .drop_auth_zone_signature_proofs()? .yield_to_parent(vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -335,16 +337,17 @@ fn transaction_builder_v2_produces_statically_valid_transactions_with_multiple_l }) .add_child(child_child_partial_transaction.clone()) .manifest( - ManifestV2Builder::new() - .register_subintent( + ManifestV2Builder::new(1) + .use_child( child_child_partial_transaction .partial_transaction() - .root_subintent(), + .root_subintent() + .subintent_hash()?, "subintent".into(), )? .yield_to_child("subintent".into(), vec![])? .yield_to_parent(vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone()) @@ -367,15 +370,16 @@ fn transaction_builder_v2_produces_statically_valid_transactions_with_multiple_l }) .add_child(child_partial_transaction.clone()) .manifest( - ManifestV2Builder::new() - .register_subintent( + ManifestV2Builder::new(1) + .use_child( child_partial_transaction .partial_transaction() - .root_subintent(), + .root_subintent() + .subintent_hash()?, "subintent".into(), )? .yield_to_child("subintent".into(), vec![])? - .build(1), + .build(), ) .prepare_for_signing()? .sign_with_private_key(signer_private_key.clone())