diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ebd4ba44..f79bb9b8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: - name: Install Rust Toolchain uses: RDXWorks-actions/toolchain@master with: - toolchain: nightly-2024-02-01 + toolchain: nightly-2024-12-14 default: true profile: minimal # - name: Run sccache-cache @@ -113,7 +113,7 @@ jobs: - name: Install Rust Toolchain uses: RDXWorks-actions/toolchain@master with: - toolchain: nightly-2024-02-01 + toolchain: nightly-2024-12-14 default: true profile: minimal target: ${{ matrix.build-target.target-triple }} diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index f1d31096..e250b40a 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -33,20 +33,19 @@ jobs: uses: RDXWorks-actions/checkout@main - name: Install Rust Target run: | - # Install nightly-2024-02-01 - rustup toolchain install nightly-2024-02-01 + # Install nightly-2024-12-14 + rustup toolchain install nightly-2024-12-14 # Update both toolchains - rustup update nightly-2024-07-30 - rustup update nightly-2024-02-01 + rustup update nightly-2024-12-14 # Add target rustup target install ${{ matrix.build-target.target-triple }} - rustup +nightly-2024-02-01 target install ${{ matrix.build-target.target-triple }} + rustup +nightly-2024-12-14 target install ${{ matrix.build-target.target-triple }} - # Install the nightly-2024-02-01 toolchain of the target of this machine. + # Install the nightly-2024-12-14 toolchain of the target of this machine. DEFAULT_TARGET=$(rustc -vV | sed -n 's|host: ||p') - rustup component add rust-src --toolchain nightly-2024-02-01-$DEFAULT_TARGET + rustup component add rust-src --toolchain nightly-2024-12-14-$DEFAULT_TARGET - name: Build dependencies (x86_64-pc-windows-gnu) if: ${{ matrix.build-target.target-triple == 'x86_64-pc-windows-gnu' }} run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8174070..b004f976 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - name: Install Rust Toolchain uses: RDXWorks-actions/toolchain@master with: - toolchain: nightly-2024-07-30 + toolchain: nightly-2024-12-14 default: true components: rustfmt, clippy - name: Install cargo nextest @@ -79,7 +79,7 @@ jobs: - name: Install Rust Toolchain uses: RDXWorks-actions/toolchain@master with: - toolchain: nightly-2024-07-30 + toolchain: nightly-2024-12-14 default: true profile: minimal - name: Cargo Check @@ -91,7 +91,7 @@ jobs: - name: Install Rust Toolchain uses: RDXWorks-actions/toolchain@master with: - toolchain: nightly-2024-07-30 + toolchain: nightly-2024-12-14 default: true components: rustfmt, clippy - name: Clippy Check diff --git a/crates/radix-engine-toolkit-uniffi/src/blueprints/metadata.rs b/crates/radix-engine-toolkit-uniffi/src/blueprints/metadata.rs index f77e0bba..8a98588e 100644 --- a/crates/radix-engine-toolkit-uniffi/src/blueprints/metadata.rs +++ b/crates/radix-engine-toolkit-uniffi/src/blueprints/metadata.rs @@ -44,10 +44,13 @@ impl ToNative for MetadataInit { None => None, }; - Ok((key, NativeKeyValueStoreInitEntry:: { - lock: value.lock, - value: metadata, - })) + Ok(( + key, + NativeKeyValueStoreInitEntry:: { + lock: value.lock, + value: metadata, + }, + )) }) .collect:: for ManifestBlobRef { impl From for NativeManifestBlobRef { fn from(value: ManifestBlobRef) -> Self { - Self(value.value.0.0) + Self(value.value.0 .0) } } 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 2b10b35e..0301fe01 100644 --- a/crates/radix-engine-toolkit-uniffi/tests/transaction_v2_builder.rs +++ b/crates/radix-engine-toolkit-uniffi/tests/transaction_v2_builder.rs @@ -61,8 +61,8 @@ fn subintent_transaction_hash_is_derived_correctly() -> Result<()> { } #[test] -fn partial_transaction_builder_produces_valid_partial_transactions() --> Result<()> { +fn partial_transaction_builder_produces_valid_partial_transactions( +) -> Result<()> { // Arrange let [signer_private_key] = private_keys(); @@ -105,8 +105,8 @@ fn partial_transaction_builder_produces_valid_partial_transactions() } #[test] -fn partial_transaction_builder_produces_valid_partial_transactions_with_child_subintents() --> Result<()> { +fn partial_transaction_builder_produces_valid_partial_transactions_with_child_subintents( +) -> Result<()> { // Arrange let [signer_private_key] = private_keys(); let child_partial_transaction = SignedPartialTransactionV2Builder::new() @@ -172,8 +172,8 @@ fn partial_transaction_builder_produces_valid_partial_transactions_with_child_su } #[test] -fn partial_transaction_builder_produces_valid_partial_transactions_with_multiple_layers_of_child_subintents() --> Result<()> { +fn partial_transaction_builder_produces_valid_partial_transactions_with_multiple_layers_of_child_subintents( +) -> Result<()> { // Arrange let [signer_private_key] = private_keys(); let child_child_partial_transaction = @@ -314,8 +314,8 @@ fn transaction_builder_v2_produces_statically_valid_transactions() -> Result<()> } #[test] -fn transaction_builder_v2_produces_statically_valid_transactions_with_multiple_layers_of_child_subintents() --> Result<()> { +fn transaction_builder_v2_produces_statically_valid_transactions_with_multiple_layers_of_child_subintents( +) -> Result<()> { // Arrange let [notary_private_key, signer_private_key] = private_keys(); let child_child_partial_transaction = diff --git a/crates/radix-engine-toolkit/src/functions/manifest_sbor.rs b/crates/radix-engine-toolkit/src/functions/manifest_sbor.rs index f7f144c6..732a4c09 100644 --- a/crates/radix-engine-toolkit/src/functions/manifest_sbor.rs +++ b/crates/radix-engine-toolkit/src/functions/manifest_sbor.rs @@ -16,7 +16,7 @@ // under the License. use radix_transactions::data::{ - ManifestDecompilationDisplayContext, format_manifest_value, + format_manifest_value, ManifestDecompilationDisplayContext, }; use sbor::prelude::ContextualSerialize; use sbor::representations::{SerializationMode, SerializationParameters}; diff --git a/crates/radix-engine-toolkit/src/functions/transaction_v1/manifest.rs b/crates/radix-engine-toolkit/src/functions/transaction_v1/manifest.rs index cff3d57a..802658c4 100644 --- a/crates/radix-engine-toolkit/src/functions/transaction_v1/manifest.rs +++ b/crates/radix-engine-toolkit/src/functions/transaction_v1/manifest.rs @@ -18,8 +18,8 @@ use radix_common::prelude::*; use radix_engine_toolkit_common::receipt::RuntimeToolkitTransactionReceipt; use radix_transactions::errors::*; -use radix_transactions::manifest::BuildableManifest; use radix_transactions::manifest::static_resource_movements::StaticResourceMovementsError; +use radix_transactions::manifest::BuildableManifest; use radix_transactions::prelude::*; use radix_transactions::validation::*; diff --git a/crates/radix-engine-toolkit/src/functions/transaction_v2/subintent_manifest.rs b/crates/radix-engine-toolkit/src/functions/transaction_v2/subintent_manifest.rs index 0cc51887..adb94596 100644 --- a/crates/radix-engine-toolkit/src/functions/transaction_v2/subintent_manifest.rs +++ b/crates/radix-engine-toolkit/src/functions/transaction_v2/subintent_manifest.rs @@ -56,13 +56,10 @@ pub fn as_enclosed( object_names, }: &SubintentManifestV2, ) -> Option { - let [ - assert_worktop_empty_instruction @ InstructionV2::AssertWorktopResourcesOnly(AssertWorktopResourcesOnly { + let [assert_worktop_empty_instruction @ InstructionV2::AssertWorktopResourcesOnly(AssertWorktopResourcesOnly { constraints, - }), - other_instructions @ .., - InstructionV2::YieldToParent(..), - ] = instructions.as_slice() + }), other_instructions @ .., InstructionV2::YieldToParent(..)] = + instructions.as_slice() else { return None; }; diff --git a/crates/radix-engine-toolkit/src/models/canonical_address_types.rs b/crates/radix-engine-toolkit/src/models/canonical_address_types.rs index 25d3101f..d5f3b4cd 100644 --- a/crates/radix-engine-toolkit/src/models/canonical_address_types.rs +++ b/crates/radix-engine-toolkit/src/models/canonical_address_types.rs @@ -295,11 +295,14 @@ mod tests { let input = "account_sim1cyvgx33089ukm2pl97pv4max0x40ruvfy4lt60yvya744cve475w0q"; let x = CanonicalAccountAddress::from_str(input).unwrap(); - assert_eq!(x.node_id.as_bytes(), [ - 193, 24, 131, 70, 47, 57, 121, 109, 168, 63, 47, 130, 202, 239, - 166, 121, 170, 241, 241, 137, 37, 126, 189, 60, 140, 39, 125, 90, - 225, 153 - ]); + assert_eq!( + x.node_id.as_bytes(), + [ + 193, 24, 131, 70, 47, 57, 121, 109, 168, 63, 47, 130, 202, 239, + 166, 121, 170, 241, 241, 137, 37, 126, 189, 60, 140, 39, 125, + 90, 225, 153 + ] + ); assert_eq!(x.network_id, 0xf2); assert_eq!(x.to_string(), input); diff --git a/crates/radix-engine-toolkit/src/transaction_types/interface.rs b/crates/radix-engine-toolkit/src/transaction_types/interface.rs index 9a60a82d..7ce4544e 100644 --- a/crates/radix-engine-toolkit/src/transaction_types/interface.rs +++ b/crates/radix-engine-toolkit/src/transaction_types/interface.rs @@ -513,14 +513,17 @@ pub fn dynamically_analyze( k, v.into_iter() .map(|(badge, operation)| { - (badge, match operation { - Update::Set(()) => { - Operation::Added - } - Update::Remove => { - Operation::Removed - } - }) + ( + badge, + match operation { + Update::Set(()) => { + Operation::Added + } + Update::Remove => { + Operation::Removed + } + }, + ) }) .collect(), ) diff --git a/crates/radix-engine-toolkit/src/transaction_types/traverser/types/general.rs b/crates/radix-engine-toolkit/src/transaction_types/traverser/types/general.rs index 4738191d..b82a583c 100644 --- a/crates/radix-engine-toolkit/src/transaction_types/traverser/types/general.rs +++ b/crates/radix-engine-toolkit/src/transaction_types/traverser/types/general.rs @@ -33,7 +33,11 @@ impl GeneralDetector { } pub fn output(self) -> Option<()> { - if self.is_valid() { Some(()) } else { None } + if self.is_valid() { + Some(()) + } else { + None + } } } diff --git a/crates/radix-engine-toolkit/src/transaction_types/traverser/types/general_subintent.rs b/crates/radix-engine-toolkit/src/transaction_types/traverser/types/general_subintent.rs index 72206e6d..7dffe8cc 100644 --- a/crates/radix-engine-toolkit/src/transaction_types/traverser/types/general_subintent.rs +++ b/crates/radix-engine-toolkit/src/transaction_types/traverser/types/general_subintent.rs @@ -34,7 +34,11 @@ impl GeneralSubintentDetector { } pub fn output(self) -> Option<()> { - if self.is_valid() { Some(()) } else { None } + if self.is_valid() { + Some(()) + } else { + None + } } } diff --git a/crates/radix-engine-toolkit/tests/manifest_sbor.rs b/crates/radix-engine-toolkit/tests/manifest_sbor.rs index f743090b..9233590e 100644 --- a/crates/radix-engine-toolkit/tests/manifest_sbor.rs +++ b/crates/radix-engine-toolkit/tests/manifest_sbor.rs @@ -16,7 +16,7 @@ // under the License. use radix_common::prelude::{ - AddressBech32Encoder, ManifestValue, ScryptoCustomSchema, manifest_encode, + manifest_encode, AddressBech32Encoder, ManifestValue, ScryptoCustomSchema, }; use radix_common::{ManifestSbor, ScryptoSbor}; use radix_engine_toolkit::functions::manifest_sbor::ManifestSborStringRepresentation; diff --git a/crates/radix-engine-toolkit/tests/non_fungible.rs b/crates/radix-engine-toolkit/tests/non_fungible.rs index 30dc3ab3..3271e489 100644 --- a/crates/radix-engine-toolkit/tests/non_fungible.rs +++ b/crates/radix-engine-toolkit/tests/non_fungible.rs @@ -53,16 +53,12 @@ fn dynamic_analysis_new_non_fungible_list_initial_supply() { // Assert assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 2); - assert!( - dynamic_analysis - .newly_created_non_fungibles - .contains(&NonFungibleGlobalId::new(*address, nf_id_1)) - ); - assert!( - dynamic_analysis - .newly_created_non_fungibles - .contains(&NonFungibleGlobalId::new(*address, nf_id_2)) - ); + assert!(dynamic_analysis + .newly_created_non_fungibles + .contains(&NonFungibleGlobalId::new(*address, nf_id_1))); + assert!(dynamic_analysis + .newly_created_non_fungibles + .contains(&NonFungibleGlobalId::new(*address, nf_id_2))); } #[test] @@ -105,11 +101,9 @@ fn dynamic_analysis_new_non_fungible_list_after_mint() { // Assert assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 1); - assert!( - dynamic_analysis - .newly_created_non_fungibles - .contains(&NonFungibleGlobalId::new(*address, nf_id_2)) - ); + assert!(dynamic_analysis + .newly_created_non_fungibles + .contains(&NonFungibleGlobalId::new(*address, nf_id_2))); } #[test] @@ -200,11 +194,9 @@ fn dynamic_analysis_new_non_fungible_list_after_mint_and_burn() { // Assert assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 1); - assert!( - dynamic_analysis - .newly_created_non_fungibles - .contains(&NonFungibleGlobalId::new(*address, nf_id_3)) - ); + assert!(dynamic_analysis + .newly_created_non_fungibles + .contains(&NonFungibleGlobalId::new(*address, nf_id_3))); } #[test] @@ -234,12 +226,18 @@ fn dynamic_analysis_new_non_fungible_list_after_update() { NonFungibleResourceRoles::single_locked_rule(AccessRule::AllowAll), ModuleConfig::default(), Some(vec![ - (nf_id_1.clone(), NfData { - name: "data_1".to_string(), - }), - (nf_id_2.clone(), NfData { - name: "data_2".to_string(), - }), + ( + nf_id_1.clone(), + NfData { + name: "data_1".to_string(), + }, + ), + ( + nf_id_2.clone(), + NfData { + name: "data_2".to_string(), + }, + ), ]), ) .try_deposit_entire_worktop_or_abort(account, None) diff --git a/crates/radix-engine-toolkit/tests/schema_visitor.rs b/crates/radix-engine-toolkit/tests/schema_visitor.rs index 906755d9..af1af3b3 100644 --- a/crates/radix-engine-toolkit/tests/schema_visitor.rs +++ b/crates/radix-engine-toolkit/tests/schema_visitor.rs @@ -15,8 +15,8 @@ // specific language governing permissions and limitations // under the License. -use radix_common::ScryptoSbor; use radix_common::prelude::ScryptoCustomSchema; +use radix_common::ScryptoSbor; use radix_engine_toolkit::schema_visitor::core::traverser::traverse; use radix_engine_toolkit::schema_visitor::visitors::bucket_in_path_visitor::BucketInPathVisitor; use radix_engine_toolkit::schema_visitor::visitors::proof_in_path_visitor::ProofInPathVisitor; diff --git a/crates/radix-engine-toolkit/tests/scrypto_sbor.rs b/crates/radix-engine-toolkit/tests/scrypto_sbor.rs index ca46e7f0..3bfdfc7c 100644 --- a/crates/radix-engine-toolkit/tests/scrypto_sbor.rs +++ b/crates/radix-engine-toolkit/tests/scrypto_sbor.rs @@ -15,10 +15,10 @@ // specific language governing permissions and limitations // under the License. -use radix_common::ScryptoSbor; use radix_common::prelude::{ - AddressBech32Encoder, ScryptoCustomSchema, ScryptoValue, scrypto_encode, + scrypto_encode, AddressBech32Encoder, ScryptoCustomSchema, ScryptoValue, }; +use radix_common::ScryptoSbor; use sbor::generate_full_schema_from_single_type; use sbor::representations::SerializationMode; diff --git a/crates/radix-engine-toolkit/tests/subintent_manifest_v2.rs b/crates/radix-engine-toolkit/tests/subintent_manifest_v2.rs index 35cca3bf..8a523aa1 100644 --- a/crates/radix-engine-toolkit/tests/subintent_manifest_v2.rs +++ b/crates/radix-engine-toolkit/tests/subintent_manifest_v2.rs @@ -21,8 +21,8 @@ use radix_engine_toolkit::functions::transaction_v2::subintent_manifest::{ use scrypto_test::prelude::*; #[test] -fn subintent_manifest_with_no_initial_resources_and_a_final_yield_is_considered_enclosed() - { +fn subintent_manifest_with_no_initial_resources_and_a_final_yield_is_considered_enclosed( +) { // Arrange let manifest = ManifestBuilder::new_subintent_v2() .assert_worktop_is_empty() diff --git a/crates/radix-engine-toolkit/tests/test_runner_extension.rs b/crates/radix-engine-toolkit/tests/test_runner_extension.rs index 683adb1d..56bd3378 100644 --- a/crates/radix-engine-toolkit/tests/test_runner_extension.rs +++ b/crates/radix-engine-toolkit/tests/test_runner_extension.rs @@ -33,12 +33,17 @@ where &mut self, manifest: TransactionManifestV1, ) -> TransactionReceiptV1 { - self.preview_manifest(manifest, vec![], 0, PreviewFlags { - use_free_credit: true, - assume_all_signature_proofs: true, - skip_epoch_check: true, - disable_auth: true, - }) + self.preview_manifest( + manifest, + vec![], + 0, + PreviewFlags { + use_free_credit: true, + assume_all_signature_proofs: true, + skip_epoch_check: true, + disable_auth: true, + }, + ) } fn summarize( diff --git a/crates/radix-engine-toolkit/tests/transaction_types.rs b/crates/radix-engine-toolkit/tests/transaction_types.rs index a42a1837..c1fcabce 100644 --- a/crates/radix-engine-toolkit/tests/transaction_types.rs +++ b/crates/radix-engine-toolkit/tests/transaction_types.rs @@ -64,8 +64,8 @@ fn empty_manifest_matches_none_of_the_transaction_types() { } #[test] -fn lock_fee_still_keeps_the_transfer_classification_but_adds_a_reserved_instruction() - { +fn lock_fee_still_keeps_the_transfer_classification_but_adds_a_reserved_instruction( +) { // Arrange let mut ledger = LedgerSimulatorBuilder::new().without_kernel_trace().build(); @@ -121,21 +121,27 @@ fn lock_fee_still_keeps_the_transfer_classification_but_adds_a_reserved_instruct assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account1]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account2]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::Transfer, - ManifestClass::General - ]); - - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account2 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::Transfer, ManifestClass::General] + ); + + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account2 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert!(matches!( &dynamic_analysis.detailed_classification[0], @@ -207,21 +213,27 @@ fn simple_transfer_satisfies_the_transfer_and_general_transaction_types() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account1]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account2]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::Transfer, - ManifestClass::General - ]); - - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account2 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::Transfer, ManifestClass::General] + ); + + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account2 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert!(matches!( dynamic_analysis.detailed_classification[0], @@ -296,23 +308,29 @@ fn non_simple_transfer_satisfies_the_transfer_and_general_transaction_types() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account1]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account2]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::Transfer, - ManifestClass::General - ]); - - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))), - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))), - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account2 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))), - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))), - ] - }); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::Transfer, ManifestClass::General] + ); + + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))), + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))), + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account2 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))), + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert!(matches!( dynamic_analysis.detailed_classification[0], @@ -386,16 +404,22 @@ fn transfers_with_try_deposit_or_refund_are_invalid() { assert_eq!(static_analysis.accounts_deposited_into, indexset![account2]); assert_eq!(static_analysis.classification, indexset![]); - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account2 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account2 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 0); @@ -460,16 +484,22 @@ fn lock_fee_is_recognized_as_a_reserved_instruction1() { assert_eq!(static_analysis.accounts_deposited_into, indexset![account2]); assert_eq!(static_analysis.classification, indexset![]); - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account2 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account2 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 0); @@ -533,16 +563,22 @@ fn lock_fee_is_recognized_as_a_reserved_instruction2() { assert_eq!(static_analysis.accounts_deposited_into, indexset![account2]); assert_eq!(static_analysis.classification, indexset![]); - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account2 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) - ] - }); + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account2 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10))) + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 0); @@ -603,16 +639,20 @@ fn faucet_fee_xrd_is_recognized_as_a_general_transaction() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account1]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::General - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::General] + ); assert!(dynamic_analysis.account_withdraws.is_empty()); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10_000))), - ] - }); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10_000))), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert!(matches!( dynamic_analysis.detailed_classification[0], @@ -677,16 +717,20 @@ fn account_deposit_is_recognized_as_a_method_that_requires_auth() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account1]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::General - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::General] + ); assert!(dynamic_analysis.account_withdraws.is_empty()); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10_000))), - ] - }); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Guaranteed(dec!(10_000))), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert!(matches!( dynamic_analysis.detailed_classification[0], @@ -746,16 +790,20 @@ fn account_deposit_batch_is_recognized_as_a_method_that_requires_auth() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account1]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::General - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::General] + ); assert!(dynamic_analysis.account_withdraws.is_empty()); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Predicted(Predicted { value: dec!(10_000), instruction_index: 1 })), - ] - }); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Predicted(Predicted { value: dec!(10_000), instruction_index: 1 })), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert!(matches!( dynamic_analysis.detailed_classification[0], @@ -820,16 +868,20 @@ fn instruction_index_of_predicted_bucket_is_its_creation_instruction() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account1]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::General - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::General] + ); assert!(dynamic_analysis.account_withdraws.is_empty()); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account1 => vec![ - ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Predicted(Predicted { value: dec!(10_000), instruction_index: 1 })), - ] - }); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account1 => vec![ + ResourceIndicator::Fungible(XRD, FungibleResourceIndicator::Predicted(Predicted { value: dec!(10_000), instruction_index: 1 })), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert!(matches!( dynamic_analysis.detailed_classification[0], @@ -942,123 +994,132 @@ fn pool_contribution_transactions_are_recognized() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::PoolContribution - ]); - - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account => vec![ - /* One pool contribution */ - ResourceIndicator::Fungible( - resource1, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - /* Two pool contribution */ - ResourceIndicator::Fungible( - resource1, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource2, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - /* Multi pool contribution */ - ResourceIndicator::Fungible( - resource1, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource2, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource3, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource4, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account => vec![ - /* One Pool Units */ - ResourceIndicator::Fungible( - one_pool_unit, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(100), - instruction_index: 3 - } - ) - ), - /* Two Pool Units */ - ResourceIndicator::Fungible( - two_pool_unit, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(100), - instruction_index: 9 - } - ) - ), - /* Multi Pool Units */ - ResourceIndicator::Fungible( - multi_pool_unit, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(100), - instruction_index: 15 - } - ) - ), - ] - }); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::PoolContribution] + ); + + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account => vec![ + /* One pool contribution */ + ResourceIndicator::Fungible( + resource1, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + /* Two pool contribution */ + ResourceIndicator::Fungible( + resource1, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource2, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + /* Multi pool contribution */ + ResourceIndicator::Fungible( + resource1, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource2, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource3, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource4, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account => vec![ + /* One Pool Units */ + ResourceIndicator::Fungible( + one_pool_unit, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(100), + instruction_index: 3 + } + ) + ), + /* Two Pool Units */ + ResourceIndicator::Fungible( + two_pool_unit, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(100), + instruction_index: 9 + } + ) + ), + /* Multi Pool Units */ + ResourceIndicator::Fungible( + multi_pool_unit, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(100), + instruction_index: 15 + } + ) + ), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); - let [ - DetailedManifestClass::PoolContribution { - pool_addresses, - pool_contributions, - }, - ] = dynamic_analysis.detailed_classification.as_slice() + let [DetailedManifestClass::PoolContribution { + pool_addresses, + pool_contributions, + }] = dynamic_analysis.detailed_classification.as_slice() else { panic!("Unexpected contents") }; - assert_eq!(pool_addresses.clone(), indexset![ - one_pool, two_pool, multi_pool, - ]); - assert_eq!(pool_contributions.clone(), vec![ - TrackedPoolContribution { - pool_address: one_pool, - contributed_resources: indexmap! { - resource1 => dec!(100) + assert_eq!( + pool_addresses.clone(), + indexset![one_pool, two_pool, multi_pool,] + ); + assert_eq!( + pool_contributions.clone(), + vec![ + TrackedPoolContribution { + pool_address: one_pool, + contributed_resources: indexmap! { + resource1 => dec!(100) + }, + pool_units_resource_address: one_pool_unit, + pool_units_amount: dec!(100) }, - pool_units_resource_address: one_pool_unit, - pool_units_amount: dec!(100) - }, - TrackedPoolContribution { - pool_address: two_pool, - contributed_resources: indexmap! { - resource1 => dec!(100), - resource2 => dec!(100) + TrackedPoolContribution { + pool_address: two_pool, + contributed_resources: indexmap! { + resource1 => dec!(100), + resource2 => dec!(100) + }, + pool_units_resource_address: two_pool_unit, + pool_units_amount: dec!(100) }, - pool_units_resource_address: two_pool_unit, - pool_units_amount: dec!(100) - }, - TrackedPoolContribution { - pool_address: multi_pool, - contributed_resources: indexmap! { - resource1 => dec!(100), - resource2 => dec!(100), - resource3 => dec!(100), - resource4 => dec!(100) + TrackedPoolContribution { + pool_address: multi_pool, + contributed_resources: indexmap! { + resource1 => dec!(100), + resource2 => dec!(100), + resource3 => dec!(100), + resource4 => dec!(100) + }, + pool_units_resource_address: multi_pool_unit, + pool_units_amount: dec!(100) }, - pool_units_resource_address: multi_pool_unit, - pool_units_amount: dec!(100) - }, - ]); + ] + ); assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 0); } @@ -1142,131 +1203,139 @@ fn multi_resource_pool_contribution_with_change_is_correctly_handled() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::PoolContribution - ]); - - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account => vec![ - ResourceIndicator::Fungible( - resource1, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource2, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource3, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource4, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource1, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource2, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource3, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - resource4, - FungibleResourceIndicator::Guaranteed(dec!(50)) - ), - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account => vec![ - ResourceIndicator::Fungible( - multi_pool_unit, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(100), - instruction_index: 5 - } - ) - ), - ResourceIndicator::Fungible( - multi_pool_unit, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(50), - instruction_index: 11 - } - ) - ), - ResourceIndicator::Fungible( - resource1, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(50), - instruction_index: 11 - } - ) - ), - ResourceIndicator::Fungible( - resource2, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(50), - instruction_index: 11 - } - ) - ), - ResourceIndicator::Fungible( - resource3, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(50), - instruction_index: 11 - } - ) - ), - ] - }); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::PoolContribution] + ); + + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account => vec![ + ResourceIndicator::Fungible( + resource1, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource2, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource3, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource4, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource1, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource2, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource3, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + resource4, + FungibleResourceIndicator::Guaranteed(dec!(50)) + ), + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account => vec![ + ResourceIndicator::Fungible( + multi_pool_unit, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(100), + instruction_index: 5 + } + ) + ), + ResourceIndicator::Fungible( + multi_pool_unit, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(50), + instruction_index: 11 + } + ) + ), + ResourceIndicator::Fungible( + resource1, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(50), + instruction_index: 11 + } + ) + ), + ResourceIndicator::Fungible( + resource2, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(50), + instruction_index: 11 + } + ) + ), + ResourceIndicator::Fungible( + resource3, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(50), + instruction_index: 11 + } + ) + ), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); - let [ - DetailedManifestClass::PoolContribution { - pool_addresses, - pool_contributions, - }, - ] = dynamic_analysis.detailed_classification.as_slice() + let [DetailedManifestClass::PoolContribution { + pool_addresses, + pool_contributions, + }] = dynamic_analysis.detailed_classification.as_slice() else { panic!("Unexpected contents") }; assert_eq!(pool_addresses.clone(), indexset![multi_pool,]); - assert_eq!(pool_contributions.clone(), vec![ - TrackedPoolContribution { - pool_address: multi_pool, - contributed_resources: indexmap! { - resource1 => dec!(100), - resource2 => dec!(100), - resource3 => dec!(100), - resource4 => dec!(100) - }, - pool_units_resource_address: multi_pool_unit, - pool_units_amount: dec!(100) - }, - TrackedPoolContribution { - pool_address: multi_pool, - contributed_resources: indexmap! { - resource1 => dec!(50), - resource2 => dec!(50), - resource3 => dec!(50), - resource4 => dec!(50) + assert_eq!( + pool_contributions.clone(), + vec![ + TrackedPoolContribution { + pool_address: multi_pool, + contributed_resources: indexmap! { + resource1 => dec!(100), + resource2 => dec!(100), + resource3 => dec!(100), + resource4 => dec!(100) + }, + pool_units_resource_address: multi_pool_unit, + pool_units_amount: dec!(100) }, - pool_units_resource_address: multi_pool_unit, - pool_units_amount: dec!(50) - } - ]); + TrackedPoolContribution { + pool_address: multi_pool, + contributed_resources: indexmap! { + resource1 => dec!(50), + resource2 => dec!(50), + resource3 => dec!(50), + resource4 => dec!(50) + }, + pool_units_resource_address: multi_pool_unit, + pool_units_amount: dec!(50) + } + ] + ); assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 0); } @@ -1331,9 +1400,10 @@ fn pool_redemption_transactions_are_recognized() { .try_deposit_entire_worktop_or_abort(account, None) .build(); ledger - .execute_manifest(manifest, vec![NonFungibleGlobalId::from_public_key( - &pk, - )]) + .execute_manifest( + manifest, + vec![NonFungibleGlobalId::from_public_key(&pk)], + ) .expect_commit_success(); let manifest = ManifestBuilder::new() @@ -1414,111 +1484,120 @@ fn pool_redemption_transactions_are_recognized() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::PoolRedemption - ]); - - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account => vec![ - ResourceIndicator::Fungible( - one_pool_unit, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - two_pool_unit, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - multi_pool_unit, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account => vec![ - /* One pool contribution */ - ResourceIndicator::Fungible( - resource1, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(300), - instruction_index: 9 - } - ) - ), - ResourceIndicator::Fungible( - resource2, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(200), - instruction_index: 9 - } - ) - ), - ResourceIndicator::Fungible( - resource3, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(100), - instruction_index: 9 - } - ) - ), - ResourceIndicator::Fungible( - resource4, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(100), - instruction_index: 9 - } - ) - ), - ] - }); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::PoolRedemption] + ); + + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account => vec![ + ResourceIndicator::Fungible( + one_pool_unit, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + two_pool_unit, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + multi_pool_unit, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account => vec![ + /* One pool contribution */ + ResourceIndicator::Fungible( + resource1, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(300), + instruction_index: 9 + } + ) + ), + ResourceIndicator::Fungible( + resource2, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(200), + instruction_index: 9 + } + ) + ), + ResourceIndicator::Fungible( + resource3, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(100), + instruction_index: 9 + } + ) + ), + ResourceIndicator::Fungible( + resource4, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(100), + instruction_index: 9 + } + ) + ), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); - let [ - DetailedManifestClass::PoolRedemption { - pool_addresses, - pool_redemptions, - }, - ] = dynamic_analysis.detailed_classification.as_slice() + let [DetailedManifestClass::PoolRedemption { + pool_addresses, + pool_redemptions, + }] = dynamic_analysis.detailed_classification.as_slice() else { panic!("Unexpected contents") }; - assert_eq!(pool_addresses.clone(), indexset![ - one_pool, two_pool, multi_pool, - ]); - assert_eq!(pool_redemptions.clone(), vec![ - TrackedPoolRedemption { - pool_address: one_pool, - redeemed_resources: indexmap! { - resource1 => dec!(100) + assert_eq!( + pool_addresses.clone(), + indexset![one_pool, two_pool, multi_pool,] + ); + assert_eq!( + pool_redemptions.clone(), + vec![ + TrackedPoolRedemption { + pool_address: one_pool, + redeemed_resources: indexmap! { + resource1 => dec!(100) + }, + pool_units_resource_address: one_pool_unit, + pool_units_amount: dec!(100) }, - pool_units_resource_address: one_pool_unit, - pool_units_amount: dec!(100) - }, - TrackedPoolRedemption { - pool_address: two_pool, - redeemed_resources: indexmap! { - resource1 => dec!(100), - resource2 => dec!(100) + TrackedPoolRedemption { + pool_address: two_pool, + redeemed_resources: indexmap! { + resource1 => dec!(100), + resource2 => dec!(100) + }, + pool_units_resource_address: two_pool_unit, + pool_units_amount: dec!(100) }, - pool_units_resource_address: two_pool_unit, - pool_units_amount: dec!(100) - }, - TrackedPoolRedemption { - pool_address: multi_pool, - redeemed_resources: indexmap! { - resource1 => dec!(100), - resource2 => dec!(100), - resource3 => dec!(100), - resource4 => dec!(100) + TrackedPoolRedemption { + pool_address: multi_pool, + redeemed_resources: indexmap! { + resource1 => dec!(100), + resource2 => dec!(100), + resource3 => dec!(100), + resource4 => dec!(100) + }, + pool_units_resource_address: multi_pool_unit, + pool_units_amount: dec!(100) }, - pool_units_resource_address: multi_pool_unit, - pool_units_amount: dec!(100) - }, - ]); + ] + ); assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 0); } @@ -1584,34 +1663,41 @@ fn validator_stake_transactions_are_recognized() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::ValidatorStake - ]); - - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account => vec![ - ResourceIndicator::Fungible( - XRD, - FungibleResourceIndicator::Guaranteed(dec!(200)) - ) - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account => vec![ - ResourceIndicator::Fungible( - stake_unit1, - FungibleResourceIndicator::Predicted( - Predicted { value: dec!(100), instruction_index: 5 } - ) - ), - ResourceIndicator::Fungible( - stake_unit2, - FungibleResourceIndicator::Predicted( - Predicted { value: dec!(100), instruction_index: 5 } + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::ValidatorStake] + ); + + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account => vec![ + ResourceIndicator::Fungible( + XRD, + FungibleResourceIndicator::Guaranteed(dec!(200)) ) - ), - ] - }); + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account => vec![ + ResourceIndicator::Fungible( + stake_unit1, + FungibleResourceIndicator::Predicted( + Predicted { value: dec!(100), instruction_index: 5 } + ) + ), + ResourceIndicator::Fungible( + stake_unit2, + FungibleResourceIndicator::Predicted( + Predicted { value: dec!(100), instruction_index: 5 } + ) + ), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert_eq!( dynamic_analysis.detailed_classification[0], @@ -1717,9 +1803,10 @@ fn validator_unstake_transactions_are_recognized() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::ValidatorUnstake - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::ValidatorUnstake] + ); let nf_id_local_1 = NonFungibleLocalId::from_str( "{9da60161aa56f3dc-b05ee091e6e496eb-926b11ceb384a4cb-16af5319924a3426}", @@ -1730,52 +1817,58 @@ fn validator_unstake_transactions_are_recognized() { ) .unwrap(); - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account => vec![ - ResourceIndicator::Fungible( - stake_unit1, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ResourceIndicator::Fungible( - stake_unit2, - FungibleResourceIndicator::Guaranteed(dec!(100)) - ), - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account => vec![ - ResourceIndicator::NonFungible( - claim_nft1, - NonFungibleResourceIndicator::ByAll { - predicted_amount: Predicted { - value: dec!(1), - instruction_index: 6 - }, - predicted_ids: Predicted { - value: indexset![ - nf_id_local_1.clone() - ], - instruction_index: 6 - }, - } - ), - ResourceIndicator::NonFungible( - claim_nft2, - NonFungibleResourceIndicator::ByAll { - predicted_amount: Predicted { - value: dec!(1), - instruction_index: 6 - }, - predicted_ids: Predicted { - value: indexset![ - nf_id_local_2.clone() - ], - instruction_index: 6 - }, - } - ), - ] - }); + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account => vec![ + ResourceIndicator::Fungible( + stake_unit1, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ResourceIndicator::Fungible( + stake_unit2, + FungibleResourceIndicator::Guaranteed(dec!(100)) + ), + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account => vec![ + ResourceIndicator::NonFungible( + claim_nft1, + NonFungibleResourceIndicator::ByAll { + predicted_amount: Predicted { + value: dec!(1), + instruction_index: 6 + }, + predicted_ids: Predicted { + value: indexset![ + nf_id_local_1.clone() + ], + instruction_index: 6 + }, + } + ), + ResourceIndicator::NonFungible( + claim_nft2, + NonFungibleResourceIndicator::ByAll { + predicted_amount: Predicted { + value: dec!(1), + instruction_index: 6 + }, + predicted_ids: Predicted { + value: indexset![ + nf_id_local_2.clone() + ], + instruction_index: 6 + }, + } + ), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert_eq!( dynamic_analysis.detailed_classification[0], @@ -1819,16 +1912,12 @@ fn validator_unstake_transactions_are_recognized() { ); assert_eq!(dynamic_analysis.newly_created_non_fungibles.len(), 2); - assert!( - dynamic_analysis - .newly_created_non_fungibles - .contains(&NonFungibleGlobalId::new(claim_nft1, nf_id_local_1)) - ); - assert!( - dynamic_analysis - .newly_created_non_fungibles - .contains(&NonFungibleGlobalId::new(claim_nft2, nf_id_local_2)) - ); + assert!(dynamic_analysis + .newly_created_non_fungibles + .contains(&NonFungibleGlobalId::new(claim_nft1, nf_id_local_1))); + assert!(dynamic_analysis + .newly_created_non_fungibles + .contains(&NonFungibleGlobalId::new(claim_nft2, nf_id_local_2))); } #[test] @@ -1940,9 +2029,10 @@ fn validator_claim_transactions_are_recognized() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![account]); assert_eq!(static_analysis.accounts_deposited_into, indexset![account]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::ValidatorClaim - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::ValidatorClaim] + ); let nf_id_local_1 = NonFungibleLocalId::from_str( "{88187e7fec84a59c-9713f20d4bdd245a-90c9c04347db595f-07a038d384ce12a4}", @@ -1953,47 +2043,53 @@ fn validator_claim_transactions_are_recognized() { ) .unwrap(); - assert_eq!(dynamic_analysis.account_withdraws, indexmap! { - account => vec![ - ResourceIndicator::NonFungible( - claim_nft1, - NonFungibleResourceIndicator::ByAmount { - amount: dec!(1), - predicted_ids: Predicted { - value: indexset![ - nf_id_local_1.clone() - ], - instruction_index: 0 - }, - } - ), - ResourceIndicator::NonFungible( - claim_nft2, - NonFungibleResourceIndicator::ByAmount { - amount: dec!(1), - predicted_ids: Predicted { - value: indexset![ - nf_id_local_2.clone() - ], - instruction_index: 1 - }, - } - ), - ] - }); - assert_eq!(dynamic_analysis.account_deposits, indexmap! { - account => vec![ - ResourceIndicator::Fungible( - XRD, - FungibleResourceIndicator::Predicted( - Predicted { - value: dec!(200), - instruction_index: 6 + assert_eq!( + dynamic_analysis.account_withdraws, + indexmap! { + account => vec![ + ResourceIndicator::NonFungible( + claim_nft1, + NonFungibleResourceIndicator::ByAmount { + amount: dec!(1), + predicted_ids: Predicted { + value: indexset![ + nf_id_local_1.clone() + ], + instruction_index: 0 + }, } - ) - ), - ] - }); + ), + ResourceIndicator::NonFungible( + claim_nft2, + NonFungibleResourceIndicator::ByAmount { + amount: dec!(1), + predicted_ids: Predicted { + value: indexset![ + nf_id_local_2.clone() + ], + instruction_index: 1 + }, + } + ), + ] + } + ); + assert_eq!( + dynamic_analysis.account_deposits, + indexmap! { + account => vec![ + ResourceIndicator::Fungible( + XRD, + FungibleResourceIndicator::Predicted( + Predicted { + value: dec!(200), + instruction_index: 6 + } + ) + ), + ] + } + ); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); assert_eq!( dynamic_analysis.detailed_classification[0], @@ -2128,9 +2224,10 @@ fn account_deposit_settings_changes_are_recognized() { assert_eq!(static_analysis.accounts_withdrawn_from, indexset![]); assert_eq!(static_analysis.accounts_deposited_into, indexset![]); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::AccountDepositSettingsUpdate - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::AccountDepositSettingsUpdate] + ); assert!(dynamic_analysis.account_withdraws.is_empty()); assert!(dynamic_analysis.account_deposits.is_empty()); assert_eq!(dynamic_analysis.new_entities, NewEntities::default()); @@ -2227,23 +2324,37 @@ fn presented_proofs_non_fungible() { //Act let manifest = ManifestBuilder::new() .lock_fee_from_faucet() - .create_proof_from_account_of_non_fungibles(account_1, address_1, [ - NonFungibleLocalId::integer(1), - ]) - .create_proof_from_account_of_non_fungibles(account_1, address_2, [ - NonFungibleLocalId::integer(3), - ]) - .create_proof_from_account_of_non_fungibles(account_2, address_3, [ - NonFungibleLocalId::integer(2), - NonFungibleLocalId::integer(3), - ]) - .create_proof_from_account_of_non_fungibles(account_1, address_1, [ - NonFungibleLocalId::integer(1), - NonFungibleLocalId::integer(2), - ]) - .create_proof_from_account_of_non_fungibles(account_2, address_3, [ - NonFungibleLocalId::integer(2), - ]) + .create_proof_from_account_of_non_fungibles( + account_1, + address_1, + [NonFungibleLocalId::integer(1)], + ) + .create_proof_from_account_of_non_fungibles( + account_1, + address_2, + [NonFungibleLocalId::integer(3)], + ) + .create_proof_from_account_of_non_fungibles( + account_2, + address_3, + [ + NonFungibleLocalId::integer(2), + NonFungibleLocalId::integer(3), + ], + ) + .create_proof_from_account_of_non_fungibles( + account_1, + address_1, + [ + NonFungibleLocalId::integer(1), + NonFungibleLocalId::integer(2), + ], + ) + .create_proof_from_account_of_non_fungibles( + account_2, + address_3, + [NonFungibleLocalId::integer(2)], + ) .build(); let (static_analysis, _) = ledger.summarize(manifest); @@ -2455,9 +2566,10 @@ fn account_locker_is_recognized_as_general_transaction() { dynamic_analysis.detailed_classification.len(), 1 ); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::General - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::General] + ); assert_eq_three!( static_analysis.presented_proofs.len(), dynamic_analysis.presented_proofs.len(), @@ -2542,9 +2654,10 @@ fn lock_fee_manifest_has_no_classification_except_general() { dynamic_analysis.detailed_classification.len(), 1 ); - assert_eq!(static_analysis.classification, indexset![ - ManifestClass::General - ]); + assert_eq!( + static_analysis.classification, + indexset![ManifestClass::General] + ); } #[test] @@ -2593,8 +2706,8 @@ fn subintent_manifest_with_yield_to_child_is_not_a_general_subintent() { } #[test] -fn subintent_manifest_of_transfer_with_metadata_update_is_not_a_general_subintent() - { +fn subintent_manifest_of_transfer_with_metadata_update_is_not_a_general_subintent( +) { let account = ComponentAddress::new_or_panic([EntityType::GlobalAccount as u8; 30]); subintent_manifest_classification_test( diff --git a/crates/sbor-json/src/common/address.rs b/crates/sbor-json/src/common/address.rs index a128d873..9ea16f5d 100644 --- a/crates/sbor-json/src/common/address.rs +++ b/crates/sbor-json/src/common/address.rs @@ -34,7 +34,7 @@ impl Display for SerializableNodeId { crate::utils::network_definition_from_network_id(self.1); let bech32_encoder = AddressBech32Encoder::new(&network_definition); bech32_encoder - .encode_to_fmt(f, &self.0.0) + .encode_to_fmt(f, &self.0 .0) .map_err(|_| std::fmt::Error) } } diff --git a/crates/sbor-json/src/scrypto/programmatic/utils.rs b/crates/sbor-json/src/scrypto/programmatic/utils.rs index a1e5a07f..e011a932 100644 --- a/crates/sbor-json/src/scrypto/programmatic/utils.rs +++ b/crates/sbor-json/src/scrypto/programmatic/utils.rs @@ -16,7 +16,7 @@ // under the License. use super::value::ProgrammaticScryptoValue; -use super::visitor::{AddressNetworkMismatchVisitor, traverse}; +use super::visitor::{traverse, AddressNetworkMismatchVisitor}; pub fn value_contains_network_mismatch( value: &ProgrammaticScryptoValue, diff --git a/crates/sbor-json/tests/programmatic_scrypto_sbor.rs b/crates/sbor-json/tests/programmatic_scrypto_sbor.rs index 0d87dd62..564c2e9b 100644 --- a/crates/sbor-json/tests/programmatic_scrypto_sbor.rs +++ b/crates/sbor-json/tests/programmatic_scrypto_sbor.rs @@ -76,8 +76,8 @@ serialization_tests! { } #[test] -pub fn payload_serialized_with_schema_can_be_deserialized_as_no_schema_programmatic_json_model() - { +pub fn payload_serialized_with_schema_can_be_deserialized_as_no_schema_programmatic_json_model( +) { // Arrange let value = MyEnum::VariantWithFieldNames { field: 1 }; let payload = scrypto_encode(&value).unwrap(); @@ -107,10 +107,13 @@ pub fn payload_serialized_with_schema_can_be_deserialized_as_no_schema_programma .unwrap(); // Assert - assert_eq!(deserialized, ProgrammaticScryptoValue::Enum { - discriminator: 2, - fields: vec![ProgrammaticScryptoValue::U8 { value: 1 }] - }) + assert_eq!( + deserialized, + ProgrammaticScryptoValue::Enum { + discriminator: 2, + fields: vec![ProgrammaticScryptoValue::U8 { value: 1 }] + } + ) } #[test] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b79b1837..7ddbac98 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2024-07-30" \ No newline at end of file +channel = "nightly-2024-12-14" \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml index 8f429713..5c8d9318 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,5 +1 @@ -version = "Two" -max_width = 80 -comment_width = 80 -unstable_features = true -imports_granularity = "Module" \ No newline at end of file +max_width = 80 \ No newline at end of file diff --git a/scripts/build_wasm.sh b/scripts/build_wasm.sh index 99102850..1a2065e3 100755 --- a/scripts/build_wasm.sh +++ b/scripts/build_wasm.sh @@ -1,6 +1,6 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -cargo +nightly-2024-07-30 build \ +cargo +nightly-2024-12-14 build \ -Z build-std=std,panic_abort \ -Z build-std-features=panic_immediate_abort \ --manifest-path="$SCRIPT_DIR/../Cargo.toml" \ diff --git a/scripts/format.sh b/scripts/format.sh index 0b733c9a..073dfbab 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,4 +1,4 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) cd $SCRIPT_DIR/.. -cargo +nightly-2024-02-01 fmt \ No newline at end of file +cargo +nightly-2024-12-14 fmt \ No newline at end of file