From 7178fe5213a27cce4af5426668a8021b927680fe Mon Sep 17 00:00:00 2001 From: Alexander Cyon <116169792+CyonAlexRDX@users.noreply.github.com> Date: Mon, 30 Dec 2024 09:54:08 +0100 Subject: [PATCH] Split out Addresses and KeysCollector into separate crates (#325) Split out module `Addresses` & `KeysCollector` into new crates --- Cargo.lock | 38 +++++++ Cargo.toml | 11 +- crates/sargon-addresses/Cargo.toml | 27 +++++ .../src}/address/access_controller_address.rs | 0 .../src}/address/account_address.rs | 6 + .../src}/address/address.rs | 0 .../src}/address/address_format.rs | 0 .../address}/address_of_account_or_persona.rs | 2 +- .../src/address}/address_union.rs | 2 - .../src}/address/component_address.rs | 0 .../src}/address/entity_address.rs | 2 - .../src}/address/identity_address.rs | 0 .../address/legacy_olympia_account_address.rs | 0 .../src}/address/locker_address.rs | 0 .../src}/address/mod.rs | 8 ++ .../src}/address/non_fungible_global_id.rs | 0 .../src}/address/non_fungible_local_id.rs | 2 +- .../address/non_fungible_local_id_string.rs | 0 .../address/non_fungible_resource_address.rs | 0 .../src}/address/package_address.rs | 0 .../src}/address/pool_address.rs | 0 .../src/address}/public_key_hash.rs | 0 .../src}/address/resource_address.rs | 3 +- .../src}/address/validator_address.rs | 0 .../src}/address/vault_address.rs | 0 .../src}/address/wrap_ret_address.rs | 19 ++-- .../addresses_manifest_builder_support.rs | 45 -------- .../src/address_conversion/mod.rs | 2 + .../resource_address_from.rs | 0 crates/sargon-addresses/src/lib.rs | 85 ++++++++++++++ crates/sargon-addresses/src/resource/mod.rs | 3 + .../src/resource}/resource_or_non_fungible.rs | 37 ++++++ crates/sargon-core-utils/src/string_utils.rs | 7 ++ .../src}/types/hidden_constructor.rs | 2 - crates/sargon-core/src/types/mod.rs | 2 + .../src/factor_instance}/factor_instances.rs | 0 .../sargon-factors/src/factor_instance/mod.rs | 2 + .../src}/factor_sources_of_kind.rs | 31 +++++- crates/sargon-factors/src/lib.rs | 2 + .../Cargo.toml | 1 - crates/sargon-keys-collector/Cargo.toml | 15 +++ .../src}/collector/derivation_purpose.rs | 0 .../src}/collector/key_derivation_outcome.rs | 0 .../src}/collector/key_ring.rs | 0 .../src}/collector/keys_collector.rs | 91 --------------- .../collector/keys_collector_dependencies.rs | 0 .../collector/keys_collector_preprocessor.rs | 0 .../src}/collector/keys_collector_state.rs | 0 .../src}/collector/mod.rs | 0 .../src}/derivation_testing/mod.rs | 5 +- .../stateless_dummy_indices.rs | 0 .../test_keys_collector/mod.rs | 3 - .../test_derivation_interactor.rs | 80 ++++++++++--- .../test_keys_collector.rs | 0 .../key_derivation_interactor.rs | 0 .../key_derivation_request.rs | 0 .../key_derivation_response.rs | 0 .../src}/host_interaction/mod.rs | 0 crates/sargon-keys-collector/src/lib.rs | 26 +++++ .../src}/tests/derivation_tests.rs | 91 +++++++++++++++ .../src}/tests/mod.rs | 0 crates/sargon-uniffi/Cargo.toml | 12 +- crates/sargon/Cargo.toml | 12 +- .../factor_instances_provider/types/mod.rs | 4 - crates/sargon/src/keys_collector/mod.rs | 15 --- crates/sargon/src/lib.rs | 52 +-------- .../supporting_types/account_for_display.rs | 2 +- .../third_party_deposits/mod.rs | 2 - crates/sargon/src/profile/v100/mod.rs | 2 - .../authorized_dapp/authorized_dapp.rs | 8 -- .../signatures_collector_preprocessor.rs | 25 ----- .../secure_storage_client.rs | 31 ++++++ crates/sargon/src/types/mod.rs | 2 - .../access_controller_address_samples.rs | 20 ++-- .../types/samples/account_address_samples.rs | 9 +- .../src/types/samples/account_samples.rs | 4 +- .../types/samples/identity_address_samples.rs | 18 ++- .../src/types/samples/persona_samples.rs | 1 + .../delete_account/manifest_delete_account.rs | 4 +- .../manifest_account_locker.rs | 32 +++--- .../high_level/manifest_building/mod.rs | 2 - .../manifest_third_party_deposit_update.rs | 2 +- .../third_party_deposits_delta.rs | 31 ------ .../per_recipient_asset_transfers.rs | 10 +- .../manifest_encountered_component_address.rs | 2 + .../high_level/sargon_specific_types/mod.rs | 7 -- .../low_level/address_conversion/mod.rs | 2 - .../execution_summary/execution_summary.rs | 43 +++++++ .../low_level/mod.rs | 4 - .../transaction_manifest_execution_summary.rs | 82 +++++++------- .../transaction_manifest.rs | 16 +-- .../subintent_manifest.rs | 105 +++++++++--------- .../transaction_manifest_v2.rs | 16 +-- 93 files changed, 723 insertions(+), 504 deletions(-) create mode 100644 crates/sargon-addresses/Cargo.toml rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/access_controller_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/account_address.rs (98%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/address_format.rs (100%) rename crates/{sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types => sargon-addresses/src/address}/address_of_account_or_persona.rs (96%) rename crates/{sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types => sargon-addresses/src/address}/address_union.rs (99%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/component_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/entity_address.rs (94%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/identity_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/legacy_olympia_account_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/locker_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/mod.rs (86%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/non_fungible_global_id.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/non_fungible_local_id.rs (99%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/non_fungible_local_id_string.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/non_fungible_resource_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/package_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/pool_address.rs (100%) rename crates/{sargon/src/wrapped_radix_engine_toolkit/low_level => sargon-addresses/src/address}/public_key_hash.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/resource_address.rs (99%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/validator_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/vault_address.rs (100%) rename crates/{sargon/src/profile/v100 => sargon-addresses/src}/address/wrap_ret_address.rs (97%) rename crates/{sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building => sargon-addresses/src/address_conversion}/addresses_manifest_builder_support.rs (87%) create mode 100644 crates/sargon-addresses/src/address_conversion/mod.rs rename crates/{sargon/src/wrapped_radix_engine_toolkit/low_level => sargon-addresses/src}/address_conversion/resource_address_from.rs (100%) create mode 100644 crates/sargon-addresses/src/lib.rs create mode 100644 crates/sargon-addresses/src/resource/mod.rs rename crates/{sargon/src/profile/v100/entity/account/on_ledger_settings/third_party_deposits => sargon-addresses/src/resource}/resource_or_non_fungible.rs (79%) rename crates/{sargon/src/factor_instances_provider => sargon-core/src}/types/hidden_constructor.rs (95%) rename crates/{sargon/src/factor_instances_provider/types => sargon-factors/src/factor_instance}/factor_instances.rs (100%) rename crates/{sargon/src/types => sargon-factors/src}/factor_sources_of_kind.rs (76%) create mode 100644 crates/sargon-keys-collector/Cargo.toml rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/collector/derivation_purpose.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/collector/key_derivation_outcome.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/collector/key_ring.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/collector/keys_collector.rs (66%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/collector/keys_collector_dependencies.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/collector/keys_collector_preprocessor.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/collector/keys_collector_state.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/collector/mod.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/derivation_testing/mod.rs (53%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/derivation_testing/stateless_dummy_indices.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/derivation_testing/test_keys_collector/mod.rs (69%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/derivation_testing/test_keys_collector/test_derivation_interactor.rs (62%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/derivation_testing/test_keys_collector/test_keys_collector.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/host_interaction/key_derivation_interactor.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/host_interaction/key_derivation_request.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/host_interaction/key_derivation_response.rs (100%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/host_interaction/mod.rs (100%) create mode 100644 crates/sargon-keys-collector/src/lib.rs rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/tests/derivation_tests.rs (88%) rename crates/{sargon/src/keys_collector => sargon-keys-collector/src}/tests/mod.rs (100%) delete mode 100644 crates/sargon/src/keys_collector/mod.rs delete mode 100644 crates/sargon/src/wrapped_radix_engine_toolkit/low_level/address_conversion/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 37f2e48c4..d547a7f1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2801,9 +2801,11 @@ dependencies = [ "radix-transactions", "rand", "reqwest", + "sargon-addresses", "sargon-core", "sargon-factors", "sargon-hierarchical-deterministic", + "sargon-keys-collector", "sbor", "security-framework", "security-framework-sys", @@ -2818,6 +2820,28 @@ dependencies = [ "zeroize 1.7.0", ] +[[package]] +name = "sargon-addresses" +version = "1.2.1" +dependencies = [ + "derive_more", + "enum-iterator", + "log", + "pretty_assertions", + "radix-common", + "radix-engine", + "radix-engine-interface", + "radix-engine-toolkit", + "radix-rust", + "radix-transactions", + "sargon-core", + "sargon-factors", + "sargon-hierarchical-deterministic", + "serde", + "serde_json 1.0.108", + "serde_with 3.4.0", +] + [[package]] name = "sargon-core" version = "1.2.1" @@ -2972,6 +2996,20 @@ dependencies = [ "zeroize 1.7.0", ] +[[package]] +name = "sargon-keys-collector" +version = "1.2.1" +dependencies = [ + "actix-rt", + "async-trait", + "derive_more", + "log", + "sargon-addresses", + "sargon-core", + "sargon-factors", + "sargon-hierarchical-deterministic", +] + [[package]] name = "sargon-uniffi" version = "1.2.1" diff --git a/Cargo.toml b/Cargo.toml index 22ffb1ad5..2e20d5bb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,8 @@ members = [ "crates/sargon-core", "crates/sargon-hierarchical-deterministic", "crates/sargon-factors", + "crates/sargon-addresses", + "crates/sargon-keys-collector", "crates/sargon", # to be split @@ -34,18 +36,24 @@ radix-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v1 "serde", "secp256k1_sign_and_validate", ] } +radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v1.3.0" } radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v1.3.0" } radix-rust = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v1.3.0", features = [ "serde", ] } radix-transactions = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v1.3.0" } - +radix-engine-toolkit = { git = "https://github.com/radixdlt/radix-engine-toolkit", rev = "2ab5b35a6cb96c9faeb98ed8df67b870336e6873" } # ===== EXTERNAL DEPENDENCIES ======== arraystring = { git = "https://github.com/paulocsanz/arraystring", rev = "ebd7d8ba94fa0d5068fe048d5445f6b1af56035d", features = [ "serde-traits", ] } +# actix-rt = "3.3.0" +actix-rt = { git = "https://github.com/actix/actix-net", rev = "57fd6ea8098d1f2d281c305fc331216c4fe1992e" } + +async-trait = { git = "https://github.com/dtolnay/async-trait", rev = "1eb21ed8bd87029bf4dcbea41ff309f2b2220c43" } + # hkdf = "0.12.4" hkdf = { git = "https://github.com/RustCrypto/KDFs/", rev = "1ac16e8b9d4ee7a67613c9396c6cc1327652eaba" } # thiserror = "1.0.50" @@ -116,6 +124,7 @@ paste = { git = "https://github.com/dtolnay/paste", rev = "1e0cc1025af5388397c67 # pretty_assertions = "1.4.0" pretty_assertions = { git = "https://github.com/rust-pretty-assertions/rust-pretty-assertions", rev = "3f1ebc0cac5f88e875f036bf16636e15fa935c8d" } + serde = { version = "1.0.193", features = ["derive", "rc", "std"] } # serde_json = "1.0.108" diff --git a/crates/sargon-addresses/Cargo.toml b/crates/sargon-addresses/Cargo.toml new file mode 100644 index 000000000..4722d7b2b --- /dev/null +++ b/crates/sargon-addresses/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "sargon-addresses" +version = "1.2.1" +edition = "2021" + +[dependencies] +sargon-core = { path = "../sargon-core" } +sargon-factors = { path = "../sargon-factors" } +sargon-hierarchical-deterministic = { path = "../sargon-hierarchical-deterministic" } + +# ==== RADIX DEPENDENCIES ==== +radix-common = { workspace = true } +radix-engine-interface = { workspace = true } +radix-engine = { workspace = true } +radix-rust = { workspace = true } +radix-transactions = { workspace = true } + +radix-engine-toolkit = { workspace = true } + +# ==== EXTERNAL DEPENDENCIES ==== +derive_more = { workspace = true } +enum-iterator = { workspace = true } +log = { workspace = true } +pretty_assertions = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +serde_with = { workspace = true } diff --git a/crates/sargon/src/profile/v100/address/access_controller_address.rs b/crates/sargon-addresses/src/address/access_controller_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/access_controller_address.rs rename to crates/sargon-addresses/src/address/access_controller_address.rs diff --git a/crates/sargon/src/profile/v100/address/account_address.rs b/crates/sargon-addresses/src/address/account_address.rs similarity index 98% rename from crates/sargon/src/profile/v100/address/account_address.rs rename to crates/sargon-addresses/src/address/account_address.rs index bbe45eaf1..a57665862 100644 --- a/crates/sargon/src/profile/v100/address/account_address.rs +++ b/crates/sargon-addresses/src/address/account_address.rs @@ -65,6 +65,12 @@ impl HasSampleValues for AccountAddress { } } +impl From for ScryptoComponentAddress { + fn from(value: AccountAddress) -> ScryptoComponentAddress { + ScryptoComponentAddress::new_or_panic(value.node_id().0) + } +} + impl AccountAddress { /// A sample used to facilitate unit tests. pub fn sample_mainnet() -> Self { diff --git a/crates/sargon/src/profile/v100/address/address.rs b/crates/sargon-addresses/src/address/address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/address.rs rename to crates/sargon-addresses/src/address/address.rs diff --git a/crates/sargon/src/profile/v100/address/address_format.rs b/crates/sargon-addresses/src/address/address_format.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/address_format.rs rename to crates/sargon-addresses/src/address/address_format.rs diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/address_of_account_or_persona.rs b/crates/sargon-addresses/src/address/address_of_account_or_persona.rs similarity index 96% rename from crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/address_of_account_or_persona.rs rename to crates/sargon-addresses/src/address/address_of_account_or_persona.rs index 19b3c798d..ed0c957ce 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/address_of_account_or_persona.rs +++ b/crates/sargon-addresses/src/address/address_of_account_or_persona.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use crate::{address_union, prelude::*}; address_union!( /// A tagged union of addresses of either an Account or a Persona (IdentityAddress) diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/address_union.rs b/crates/sargon-addresses/src/address/address_union.rs similarity index 99% rename from crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/address_union.rs rename to crates/sargon-addresses/src/address/address_union.rs index 6a71ef698..80e08dfe4 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/address_union.rs +++ b/crates/sargon-addresses/src/address/address_union.rs @@ -1,5 +1,3 @@ -use crate::prelude::*; - #[macro_export] macro_rules! address_union { ( diff --git a/crates/sargon/src/profile/v100/address/component_address.rs b/crates/sargon-addresses/src/address/component_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/component_address.rs rename to crates/sargon-addresses/src/address/component_address.rs diff --git a/crates/sargon/src/profile/v100/address/entity_address.rs b/crates/sargon-addresses/src/address/entity_address.rs similarity index 94% rename from crates/sargon/src/profile/v100/address/entity_address.rs rename to crates/sargon-addresses/src/address/entity_address.rs index 2d914d5f9..66d89070c 100644 --- a/crates/sargon/src/profile/v100/address/entity_address.rs +++ b/crates/sargon-addresses/src/address/entity_address.rs @@ -24,7 +24,6 @@ pub trait IsEntityAddress: { /// Creates a new address from `public_key` and `network_id` by bech32 encoding /// it. - #[cfg(not(tarpaulin_include))] // false negative fn from_public_key

(public_key: P, network_id: NetworkID) -> Self where P: Into + Clone, @@ -39,7 +38,6 @@ pub trait IsEntityAddress: Self::new(node_id, network_id).expect("To always be able to create a address from public key and network id.") } - #[cfg(not(tarpaulin_include))] // false negative fn from_hd_factor_instance_virtual_entity_creation( hd_factor_instance_virtual_entity_creation: HDFactorInstanceTransactionSigning, ) -> Self { diff --git a/crates/sargon/src/profile/v100/address/identity_address.rs b/crates/sargon-addresses/src/address/identity_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/identity_address.rs rename to crates/sargon-addresses/src/address/identity_address.rs diff --git a/crates/sargon/src/profile/v100/address/legacy_olympia_account_address.rs b/crates/sargon-addresses/src/address/legacy_olympia_account_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/legacy_olympia_account_address.rs rename to crates/sargon-addresses/src/address/legacy_olympia_account_address.rs diff --git a/crates/sargon/src/profile/v100/address/locker_address.rs b/crates/sargon-addresses/src/address/locker_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/locker_address.rs rename to crates/sargon-addresses/src/address/locker_address.rs diff --git a/crates/sargon/src/profile/v100/address/mod.rs b/crates/sargon-addresses/src/address/mod.rs similarity index 86% rename from crates/sargon/src/profile/v100/address/mod.rs rename to crates/sargon-addresses/src/address/mod.rs index d19c0f1e3..7e643e202 100644 --- a/crates/sargon/src/profile/v100/address/mod.rs +++ b/crates/sargon-addresses/src/address/mod.rs @@ -2,6 +2,11 @@ mod access_controller_address; mod account_address; mod address; mod address_format; +mod address_of_account_or_persona; + +#[macro_use] +mod address_union; + mod component_address; mod entity_address; mod identity_address; @@ -13,6 +18,7 @@ mod non_fungible_local_id_string; mod non_fungible_resource_address; mod package_address; mod pool_address; +mod public_key_hash; mod resource_address; mod validator_address; mod vault_address; @@ -22,6 +28,7 @@ pub use access_controller_address::*; pub use account_address::*; pub use address::*; pub use address_format::*; +pub use address_of_account_or_persona::*; pub use component_address::*; pub use entity_address::*; pub use identity_address::*; @@ -33,6 +40,7 @@ pub use non_fungible_local_id_string::*; pub use non_fungible_resource_address::*; pub use package_address::*; pub use pool_address::*; +pub use public_key_hash::*; pub use resource_address::*; pub use validator_address::*; pub use vault_address::*; diff --git a/crates/sargon/src/profile/v100/address/non_fungible_global_id.rs b/crates/sargon-addresses/src/address/non_fungible_global_id.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/non_fungible_global_id.rs rename to crates/sargon-addresses/src/address/non_fungible_global_id.rs diff --git a/crates/sargon/src/profile/v100/address/non_fungible_local_id.rs b/crates/sargon-addresses/src/address/non_fungible_local_id.rs similarity index 99% rename from crates/sargon/src/profile/v100/address/non_fungible_local_id.rs rename to crates/sargon-addresses/src/address/non_fungible_local_id.rs index c3afcc978..9afb97f66 100644 --- a/crates/sargon/src/profile/v100/address/non_fungible_local_id.rs +++ b/crates/sargon-addresses/src/address/non_fungible_local_id.rs @@ -65,7 +65,7 @@ impl NonFungibleLocalId { } impl NonFungibleLocalId { - pub(crate) fn derives_account_address( + pub fn derives_account_address( &self, account_address: AccountAddress, ) -> bool { diff --git a/crates/sargon/src/profile/v100/address/non_fungible_local_id_string.rs b/crates/sargon-addresses/src/address/non_fungible_local_id_string.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/non_fungible_local_id_string.rs rename to crates/sargon-addresses/src/address/non_fungible_local_id_string.rs diff --git a/crates/sargon/src/profile/v100/address/non_fungible_resource_address.rs b/crates/sargon-addresses/src/address/non_fungible_resource_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/non_fungible_resource_address.rs rename to crates/sargon-addresses/src/address/non_fungible_resource_address.rs diff --git a/crates/sargon/src/profile/v100/address/package_address.rs b/crates/sargon-addresses/src/address/package_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/package_address.rs rename to crates/sargon-addresses/src/address/package_address.rs diff --git a/crates/sargon/src/profile/v100/address/pool_address.rs b/crates/sargon-addresses/src/address/pool_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/pool_address.rs rename to crates/sargon-addresses/src/address/pool_address.rs diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/public_key_hash.rs b/crates/sargon-addresses/src/address/public_key_hash.rs similarity index 100% rename from crates/sargon/src/wrapped_radix_engine_toolkit/low_level/public_key_hash.rs rename to crates/sargon-addresses/src/address/public_key_hash.rs diff --git a/crates/sargon/src/profile/v100/address/resource_address.rs b/crates/sargon-addresses/src/address/resource_address.rs similarity index 99% rename from crates/sargon/src/profile/v100/address/resource_address.rs rename to crates/sargon-addresses/src/address/resource_address.rs index 48c4f5668..5294c1ad2 100644 --- a/crates/sargon/src/profile/v100/address/resource_address.rs +++ b/crates/sargon-addresses/src/address/resource_address.rs @@ -134,8 +134,7 @@ impl ResourceAddress { .expect("valid sample value") } - #[allow(unused)] - pub(crate) fn sample_sim_xrd() -> Self { + pub fn sample_sim_xrd() -> Self { "resource_sim1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxakj8n3" .parse() .expect("valid sample value") diff --git a/crates/sargon/src/profile/v100/address/validator_address.rs b/crates/sargon-addresses/src/address/validator_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/validator_address.rs rename to crates/sargon-addresses/src/address/validator_address.rs diff --git a/crates/sargon/src/profile/v100/address/vault_address.rs b/crates/sargon-addresses/src/address/vault_address.rs similarity index 100% rename from crates/sargon/src/profile/v100/address/vault_address.rs rename to crates/sargon-addresses/src/address/vault_address.rs diff --git a/crates/sargon/src/profile/v100/address/wrap_ret_address.rs b/crates/sargon-addresses/src/address/wrap_ret_address.rs similarity index 97% rename from crates/sargon/src/profile/v100/address/wrap_ret_address.rs rename to crates/sargon-addresses/src/address/wrap_ret_address.rs index 0c16e0825..e0a6334ba 100644 --- a/crates/sargon/src/profile/v100/address/wrap_ret_address.rs +++ b/crates/sargon-addresses/src/address/wrap_ret_address.rs @@ -37,17 +37,6 @@ pub(crate) trait FromRetAddress { type RetAddress; } -pub(crate) fn format_string( - s: impl AsRef, - start: usize, - end: usize, -) -> String { - let s = s.as_ref(); - let prefix = &s[0..start]; - let suffix = suffix_str(end, s); - format!("{}...{}", prefix, suffix) -} - pub trait IntoScryptoAddress: IsNetworkAware { fn scrypto(&self) -> ScryptoGlobalAddress; } @@ -92,6 +81,14 @@ macro_rules! decl_ret_wrapped_address { } } + impl Identifiable for [< $address_type:camel Address >] { + type ID = Self; + + fn id(&self) -> Self::ID { + *self + } + } + #[cfg(test)] impl From<&str> for [< $address_type:camel Address >] { /// TEST ONLY diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/addresses_manifest_builder_support.rs b/crates/sargon-addresses/src/address_conversion/addresses_manifest_builder_support.rs similarity index 87% rename from crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/addresses_manifest_builder_support.rs rename to crates/sargon-addresses/src/address_conversion/addresses_manifest_builder_support.rs index 4e8874b0a..5fcac9780 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/addresses_manifest_builder_support.rs +++ b/crates/sargon-addresses/src/address_conversion/addresses_manifest_builder_support.rs @@ -140,51 +140,6 @@ impl From for ScryptoResourceOrNonFungible { } } -#[cfg(not(tarpaulin_include))] // false negative, tested. -pub(crate) fn to_vec_network_aware( - values: impl IntoIterator, - network_id: NetworkID, -) -> Vec -where - U: From<(T, NetworkID)>, -{ - values - .into_iter() - .map(|x| (x, network_id)) - .map(U::from) - .collect_vec() -} - -pub(crate) fn to_hashmap_network_aware_key( - values: impl IntoIterator, - network_id: NetworkID, -) -> HashMap -where - L: Eq + std::hash::Hash + From<(K, NetworkID)>, - U: From, -{ - values - .into_iter() - .map(|(k, v)| (L::from((k, network_id)), U::from(v))) - .collect::>() -} - -#[cfg(not(tarpaulin_include))] // false negative, tested. -pub(crate) fn filter_try_to_vec_network_aware( - values: impl IntoIterator, - network_id: NetworkID, -) -> Vec -where - U: TryFrom<(T, NetworkID)>, -{ - values - .into_iter() - .map(|x| (x, network_id)) - .map(U::try_from) - .filter_map(Result::ok) - .collect_vec() -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/sargon-addresses/src/address_conversion/mod.rs b/crates/sargon-addresses/src/address_conversion/mod.rs new file mode 100644 index 000000000..0ce2b5183 --- /dev/null +++ b/crates/sargon-addresses/src/address_conversion/mod.rs @@ -0,0 +1,2 @@ +mod addresses_manifest_builder_support; +mod resource_address_from; diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/address_conversion/resource_address_from.rs b/crates/sargon-addresses/src/address_conversion/resource_address_from.rs similarity index 100% rename from crates/sargon/src/wrapped_radix_engine_toolkit/low_level/address_conversion/resource_address_from.rs rename to crates/sargon-addresses/src/address_conversion/resource_address_from.rs diff --git a/crates/sargon-addresses/src/lib.rs b/crates/sargon-addresses/src/lib.rs new file mode 100644 index 000000000..4a544b6c2 --- /dev/null +++ b/crates/sargon-addresses/src/lib.rs @@ -0,0 +1,85 @@ +mod address; +mod address_conversion; +mod resource; + +pub mod prelude { + pub(crate) use sargon_core::prelude::*; + pub(crate) use sargon_factors::prelude::*; + pub(crate) use sargon_hierarchical_deterministic::prelude::*; + + pub use crate::address::*; + pub use crate::resource::*; + + pub(crate) use radix_engine_interface::blueprints::resource::ResourceOrNonFungible as ScryptoResourceOrNonFungible; + + pub use radix_common::{ + address::{ + AddressBech32Decoder as ScryptoAddressBech32Decoder, + AddressBech32Encoder as ScryptoAddressBech32Encoder, + }, + crypto::{ + Ed25519PublicKey as ScryptoEd25519PublicKey, + Ed25519PublicKeyHash as ScryptoEd25519PublicKeyHash, + Hash as ScryptoHash, PublicKey as ScryptoPublicKey, + PublicKeyHash as ScryptoPublicKeyHash, + Secp256k1PublicKeyHash as ScryptoSecp256k1PublicKeyHash, + }, + data::scrypto::{ + model::{ + BytesNonFungibleLocalId as ScryptoBytesNonFungibleLocalId, + IntegerNonFungibleLocalId as ScryptoIntegerNonFungibleLocalId, + NonFungibleLocalId as ScryptoNonFungibleLocalId, + RUIDNonFungibleLocalId as ScryptoRUIDNonFungibleLocalId, + StringNonFungibleLocalId as ScryptoStringNonFungibleLocalId, + }, + scrypto_decode as Scrypto_scrypto_decode, + scrypto_encode as Scrypto_scrypto_encode, + }, + prelude::{ + AllowedIds as ScryptoAllowedIds, + DynamicComponentAddress as ScryptoDynamicComponentAddress, + DynamicGlobalAddress as ScryptoDynamicGlobalAddress, + DynamicResourceAddress as ScryptoDynamicResourceAddress, + FromPublicKey as ScryptoFromPublicKey, Instant as ScryptoInstant, + LowerBound as ScryptoLowerBound, + ManifestAddress as ScryptoManifestAddress, + ManifestAddressReservation as ScryptoManifestAddressReservation, + ManifestBucket as ScryptoManifestBucket, + ManifestCustomValue as ScryptoManifestCustomValue, + ManifestCustomValueKind as ScryptoManifestCustomValueKind, + ManifestEncode as ScryptoManifestEncode, + ManifestNamedAddress as ScryptoManifestNamedAddress, + ManifestProof as ScryptoManifestProof, + ManifestValue as ScryptoManifestValue, + NonFungibleData as ScryptoNonFungibleData, + NonFungibleGlobalId as ScryptoNonFungibleGlobalId, + NonFungibleIdType as ScryptoNonFungibleIdType, XRD, + }, + types::{ + ComponentAddress as ScryptoComponentAddress, + EntityType as ScryptoEntityType, + GlobalAddress as ScryptoGlobalAddress, NodeId as ScryptoNodeId, + ResourceAddress as ScryptoResourceAddress, + }, + }; + pub(crate) use radix_engine::system::system_modules::execution_trace::ResourceSpecifier as ScryptoResourceSpecifier; + + pub use radix_engine_toolkit::models::{ + canonical_address_types::{ + CanonicalAccessControllerAddress as RetAccessControllerAddress, + CanonicalAccountAddress as RetAccountAddress, + CanonicalAddress as RetIsAddressTrait, + CanonicalComponentAddress as RetComponentAddress, + CanonicalIdentityAddress as RetIdentityAddress, + CanonicalLockerAddress as RetLockerAddress, + CanonicalPackageAddress as RetPackageAddress, + CanonicalPoolAddress as RetPoolAddress, + CanonicalResourceAddress as RetResourceAddress, + CanonicalValidatorAddress as RetValidatorAddress, + CanonicalVaultAddress as RetVaultAddress, + }, + node_id::TypedNodeId as RetTypedNodeId, + }; +} + +pub use prelude::*; diff --git a/crates/sargon-addresses/src/resource/mod.rs b/crates/sargon-addresses/src/resource/mod.rs new file mode 100644 index 000000000..ae1eb6ea0 --- /dev/null +++ b/crates/sargon-addresses/src/resource/mod.rs @@ -0,0 +1,3 @@ +mod resource_or_non_fungible; + +pub use resource_or_non_fungible::*; diff --git a/crates/sargon/src/profile/v100/entity/account/on_ledger_settings/third_party_deposits/resource_or_non_fungible.rs b/crates/sargon-addresses/src/resource/resource_or_non_fungible.rs similarity index 79% rename from crates/sargon/src/profile/v100/entity/account/on_ledger_settings/third_party_deposits/resource_or_non_fungible.rs rename to crates/sargon-addresses/src/resource/resource_or_non_fungible.rs index 709186b2a..0840290f7 100644 --- a/crates/sargon/src/profile/v100/entity/account/on_ledger_settings/third_party_deposits/resource_or_non_fungible.rs +++ b/crates/sargon-addresses/src/resource/resource_or_non_fungible.rs @@ -1,5 +1,11 @@ use crate::prelude::*; +use radix_engine_interface::blueprints::account::{ + AccountAddAuthorizedDepositorInput as ScryptoAccountAddAuthorizedDepositorInput, + AccountRemoveAuthorizedDepositorInput as ScryptoAccountRemoveAuthorizedDepositorInput, + AccountRemoveResourcePreferenceInput as ScryptoAccountRemoveResourcePreferenceInput, +}; + /// The addresses that can be added as exception to the `DepositRule` #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] #[serde(tag = "discriminator")] @@ -11,6 +17,37 @@ pub enum ResourceOrNonFungible { NonFungible { value: NonFungibleGlobalId }, } +impl From + for ScryptoAccountRemoveAuthorizedDepositorInput +{ + fn from(value: ResourceOrNonFungible) -> Self { + Self { + badge: value.into(), + } + } +} +impl From for ScryptoAccountAddAuthorizedDepositorInput { + fn from(value: ResourceOrNonFungible) -> Self { + Self { + badge: value.into(), + } + } +} +impl From + for ScryptoAccountRemoveResourcePreferenceInput +{ + fn from(value: ResourceOrNonFungible) -> Self { + match value { + ResourceOrNonFungible::Resource { value } => Self { + resource_address: value.into(), + }, + ResourceOrNonFungible::NonFungible { value } => Self { + resource_address: value.resource_address.into(), + }, + } + } +} + impl std::fmt::Display for ResourceOrNonFungible { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { diff --git a/crates/sargon-core-utils/src/string_utils.rs b/crates/sargon-core-utils/src/string_utils.rs index f941a7e6f..29c6b5452 100644 --- a/crates/sargon-core-utils/src/string_utils.rs +++ b/crates/sargon-core-utils/src/string_utils.rs @@ -15,6 +15,13 @@ pub fn type_name() -> String { .to_owned() } +pub fn format_string(s: impl AsRef, start: usize, end: usize) -> String { + let s = s.as_ref(); + let prefix = &s[0..start]; + let suffix = suffix_str(end, s); + format!("{}...{}", prefix, suffix) +} + /// Returns the first `n` chars of the &str `s`. If `n` is bigger than `s` then /// the whole `s` is returned. pub fn prefix_str(n: usize, s: impl AsRef) -> String { diff --git a/crates/sargon/src/factor_instances_provider/types/hidden_constructor.rs b/crates/sargon-core/src/types/hidden_constructor.rs similarity index 95% rename from crates/sargon/src/factor_instances_provider/types/hidden_constructor.rs rename to crates/sargon-core/src/types/hidden_constructor.rs index cdfaba9fb..66c416d2a 100644 --- a/crates/sargon/src/factor_instances_provider/types/hidden_constructor.rs +++ b/crates/sargon-core/src/types/hidden_constructor.rs @@ -1,7 +1,5 @@ use serde::{Deserialize, Serialize}; -use crate::HasSampleValues; - /// A type used to hide a constructor for some other type, use /// it like this: /// diff --git a/crates/sargon-core/src/types/mod.rs b/crates/sargon-core/src/types/mod.rs index 8ca71513b..651f444cf 100644 --- a/crates/sargon-core/src/types/mod.rs +++ b/crates/sargon-core/src/types/mod.rs @@ -8,6 +8,7 @@ mod email_address; mod entity_kind; mod epoch; mod exactly_n_bytes; +mod hidden_constructor; mod host_info; mod instant; mod intent_discriminator; @@ -36,6 +37,7 @@ pub use email_address::*; pub use entity_kind::*; pub use epoch::*; pub use exactly_n_bytes::*; +pub use hidden_constructor::*; pub use host_info::*; pub use instant::*; pub use intent_discriminator::*; diff --git a/crates/sargon/src/factor_instances_provider/types/factor_instances.rs b/crates/sargon-factors/src/factor_instance/factor_instances.rs similarity index 100% rename from crates/sargon/src/factor_instances_provider/types/factor_instances.rs rename to crates/sargon-factors/src/factor_instance/factor_instances.rs diff --git a/crates/sargon-factors/src/factor_instance/mod.rs b/crates/sargon-factors/src/factor_instance/mod.rs index 134ef4e2e..decfed256 100644 --- a/crates/sargon-factors/src/factor_instance/mod.rs +++ b/crates/sargon-factors/src/factor_instance/mod.rs @@ -1,9 +1,11 @@ mod badge_virtual_source; mod factor_instance; mod factor_instance_badge; +mod factor_instances; mod private_hierarchical_deterministic_factor_instance; pub use badge_virtual_source::*; pub use factor_instance::*; pub use factor_instance_badge::*; +pub use factor_instances::*; pub use private_hierarchical_deterministic_factor_instance::*; diff --git a/crates/sargon/src/types/factor_sources_of_kind.rs b/crates/sargon-factors/src/factor_sources_of_kind.rs similarity index 76% rename from crates/sargon/src/types/factor_sources_of_kind.rs rename to crates/sargon-factors/src/factor_sources_of_kind.rs index 7aafb3e30..5fb9cd98a 100644 --- a/crates/sargon/src/types/factor_sources_of_kind.rs +++ b/crates/sargon-factors/src/factor_sources_of_kind.rs @@ -2,12 +2,12 @@ use crate::prelude::*; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct FactorSourcesOfKind { - pub(crate) kind: FactorSourceKind, + pub kind: FactorSourceKind, factor_sources: Vec, } impl FactorSourcesOfKind { - pub(crate) fn new( + pub fn new( kind: FactorSourceKind, factor_sources: impl IntoIterator, ) -> Result { @@ -32,11 +32,36 @@ impl FactorSourcesOfKind { }) } - pub(crate) fn factor_sources(&self) -> IndexSet { + pub fn factor_sources(&self) -> IndexSet { self.factor_sources.clone().into_iter().collect() } } +pub fn sort_group_factors( + used_factor_sources: HashSet, +) -> IndexSet { + let factors_of_kind: HashMap> = + used_factor_sources + .into_iter() + .into_grouping_map_by(|x| x.factor_source_kind()) + .collect::>(); + + let mut factors_of_kind = factors_of_kind + .into_iter() + .map(|(k, v)| (k, v.into_iter().sorted().collect::>())) + .collect::>>(); + + factors_of_kind.sort_keys(); + + factors_of_kind + .into_iter() + .map(|(k, v)| { + FactorSourcesOfKind::new(k, v) + .expect("All factors should be of the same kind, since this is calling iter on a Map, using kind as key. Did you just move around lines of code?") + }) + .collect::>() +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/sargon-factors/src/lib.rs b/crates/sargon-factors/src/lib.rs index 400d0a1b3..22b38e6d2 100644 --- a/crates/sargon-factors/src/lib.rs +++ b/crates/sargon-factors/src/lib.rs @@ -12,6 +12,7 @@ mod factor_source_id_from_address; mod factor_source_id_from_hash; mod factor_source_kind; mod factor_sources; +mod factor_sources_of_kind; mod hd_factor_instance_account_creation; mod hd_factor_instance_identity_creation; mod hd_transaction_signing_factor_instance; @@ -40,6 +41,7 @@ pub mod prelude { pub use crate::factor_source_id_from_hash::*; pub use crate::factor_source_kind::*; pub use crate::factor_sources::*; + pub use crate::factor_sources_of_kind::*; pub use crate::hd_factor_instance_account_creation::*; pub use crate::hd_factor_instance_identity_creation::*; pub use crate::hd_transaction_signing_factor_instance::*; diff --git a/crates/sargon-hierarchical-deterministic/Cargo.toml b/crates/sargon-hierarchical-deterministic/Cargo.toml index bb98a800b..d32008ca3 100644 --- a/crates/sargon-hierarchical-deterministic/Cargo.toml +++ b/crates/sargon-hierarchical-deterministic/Cargo.toml @@ -14,7 +14,6 @@ radix-engine-interface = { workspace = true } radix-rust = { workspace = true } radix-transactions = { workspace = true } - # ==== EXTERNAL DEPENDENCIES ==== assert-json-diff = { workspace = true } delegate = { workspace = true } diff --git a/crates/sargon-keys-collector/Cargo.toml b/crates/sargon-keys-collector/Cargo.toml new file mode 100644 index 000000000..c1cf8ffcc --- /dev/null +++ b/crates/sargon-keys-collector/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "sargon-keys-collector" +version = "1.2.1" +edition = "2021" + +[dependencies] +sargon-core = { path = "../sargon-core" } +sargon-factors = { path = "../sargon-factors" } +sargon-hierarchical-deterministic = { path = "../sargon-hierarchical-deterministic" } +sargon-addresses = { path = "../sargon-addresses" } + +actix-rt = { workspace = true } +async-trait = { workspace = true } +derive_more = { workspace = true } +log = { workspace = true } diff --git a/crates/sargon/src/keys_collector/collector/derivation_purpose.rs b/crates/sargon-keys-collector/src/collector/derivation_purpose.rs similarity index 100% rename from crates/sargon/src/keys_collector/collector/derivation_purpose.rs rename to crates/sargon-keys-collector/src/collector/derivation_purpose.rs diff --git a/crates/sargon/src/keys_collector/collector/key_derivation_outcome.rs b/crates/sargon-keys-collector/src/collector/key_derivation_outcome.rs similarity index 100% rename from crates/sargon/src/keys_collector/collector/key_derivation_outcome.rs rename to crates/sargon-keys-collector/src/collector/key_derivation_outcome.rs diff --git a/crates/sargon/src/keys_collector/collector/key_ring.rs b/crates/sargon-keys-collector/src/collector/key_ring.rs similarity index 100% rename from crates/sargon/src/keys_collector/collector/key_ring.rs rename to crates/sargon-keys-collector/src/collector/key_ring.rs diff --git a/crates/sargon/src/keys_collector/collector/keys_collector.rs b/crates/sargon-keys-collector/src/collector/keys_collector.rs similarity index 66% rename from crates/sargon/src/keys_collector/collector/keys_collector.rs rename to crates/sargon-keys-collector/src/collector/keys_collector.rs index 298f0401b..e7fb9fbb0 100644 --- a/crates/sargon/src/keys_collector/collector/keys_collector.rs +++ b/crates/sargon-keys-collector/src/collector/keys_collector.rs @@ -182,94 +182,3 @@ impl KeysCollector { .process_batch_response(response) } } - -#[cfg(test)] -mod tests { - use super::*; - use crate::DerivationPathConstructors; - - #[actix_rt::test] - async fn valid() { - let f0 = FactorSource::sample_ledger(); - let f1 = FactorSource::sample_device(); - let f2 = FactorSource::sample_device_babylon_other(); - let f3 = FactorSource::sample_arculus(); - - let paths = IndexMap::<_, _>::from_iter([ - ( - f0.id_from_hash(), - IndexSet::<_>::from_iter([ - DerivationPath::for_entity( - NetworkID::Mainnet, - CAP26EntityKind::Account, - CAP26KeyKind::TransactionSigning, - Hardened::Securified(SecurifiedU30::ZERO), - ), - DerivationPath::for_entity( - NetworkID::Mainnet, - CAP26EntityKind::Account, - CAP26KeyKind::TransactionSigning, - Hardened::Securified(SecurifiedU30::ONE), - ), - DerivationPath::for_entity( - NetworkID::Stokenet, - CAP26EntityKind::Account, - CAP26KeyKind::TransactionSigning, - Hardened::Unsecurified(UnsecurifiedHardened::TWO), - ), - ]), - ), - ( - f1.id_from_hash(), - IndexSet::<_>::just(DerivationPath::for_entity( - NetworkID::Stokenet, - CAP26EntityKind::Account, - CAP26KeyKind::TransactionSigning, - Hardened::Unsecurified(UnsecurifiedHardened::THREE), - )), - ), - ( - f2.id_from_hash(), - IndexSet::<_>::just(DerivationPath::for_entity( - NetworkID::Mainnet, - CAP26EntityKind::Account, - CAP26KeyKind::TransactionSigning, - Hardened::Unsecurified( - UnsecurifiedHardened::try_from(4u32).unwrap(), - ), - )), - ), - ( - f3.id_from_hash(), - IndexSet::<_>::just(DerivationPath::for_entity( - NetworkID::Mainnet, - CAP26EntityKind::Identity, - CAP26KeyKind::AuthenticationSigning, - Hardened::Securified( - SecurifiedU30::try_from(5u32).unwrap(), - ), - )), - ), - ]); - - let collector = KeysCollector::new( - [f0, f1, f2, f3], - paths.clone(), - Arc::new(TestDerivationInteractor::default()), - DerivationPurpose::PreDerivingKeys, - ) - .unwrap(); - - let outcome = collector.collect_keys().await; - let factors = outcome.all_factors().factor_instances(); - assert_eq!( - factors.len(), - paths - .clone() - .into_iter() - .flat_map(|(_, v)| v) - .collect::>() - .len(), - ); - } -} diff --git a/crates/sargon/src/keys_collector/collector/keys_collector_dependencies.rs b/crates/sargon-keys-collector/src/collector/keys_collector_dependencies.rs similarity index 100% rename from crates/sargon/src/keys_collector/collector/keys_collector_dependencies.rs rename to crates/sargon-keys-collector/src/collector/keys_collector_dependencies.rs diff --git a/crates/sargon/src/keys_collector/collector/keys_collector_preprocessor.rs b/crates/sargon-keys-collector/src/collector/keys_collector_preprocessor.rs similarity index 100% rename from crates/sargon/src/keys_collector/collector/keys_collector_preprocessor.rs rename to crates/sargon-keys-collector/src/collector/keys_collector_preprocessor.rs diff --git a/crates/sargon/src/keys_collector/collector/keys_collector_state.rs b/crates/sargon-keys-collector/src/collector/keys_collector_state.rs similarity index 100% rename from crates/sargon/src/keys_collector/collector/keys_collector_state.rs rename to crates/sargon-keys-collector/src/collector/keys_collector_state.rs diff --git a/crates/sargon/src/keys_collector/collector/mod.rs b/crates/sargon-keys-collector/src/collector/mod.rs similarity index 100% rename from crates/sargon/src/keys_collector/collector/mod.rs rename to crates/sargon-keys-collector/src/collector/mod.rs diff --git a/crates/sargon/src/keys_collector/derivation_testing/mod.rs b/crates/sargon-keys-collector/src/derivation_testing/mod.rs similarity index 53% rename from crates/sargon/src/keys_collector/derivation_testing/mod.rs rename to crates/sargon-keys-collector/src/derivation_testing/mod.rs index 639ebd080..4ac019438 100644 --- a/crates/sargon/src/keys_collector/derivation_testing/mod.rs +++ b/crates/sargon-keys-collector/src/derivation_testing/mod.rs @@ -3,8 +3,5 @@ mod test_keys_collector; #[cfg(test)] pub(crate) use stateless_dummy_indices::*; -#[cfg(test)] -pub(crate) use test_keys_collector::*; -use crate::prelude::*; -use std::future::ready; +pub use test_keys_collector::*; diff --git a/crates/sargon/src/keys_collector/derivation_testing/stateless_dummy_indices.rs b/crates/sargon-keys-collector/src/derivation_testing/stateless_dummy_indices.rs similarity index 100% rename from crates/sargon/src/keys_collector/derivation_testing/stateless_dummy_indices.rs rename to crates/sargon-keys-collector/src/derivation_testing/stateless_dummy_indices.rs diff --git a/crates/sargon/src/keys_collector/derivation_testing/test_keys_collector/mod.rs b/crates/sargon-keys-collector/src/derivation_testing/test_keys_collector/mod.rs similarity index 69% rename from crates/sargon/src/keys_collector/derivation_testing/test_keys_collector/mod.rs rename to crates/sargon-keys-collector/src/derivation_testing/test_keys_collector/mod.rs index e5becebab..e46d0513e 100644 --- a/crates/sargon/src/keys_collector/derivation_testing/test_keys_collector/mod.rs +++ b/crates/sargon-keys-collector/src/derivation_testing/test_keys_collector/mod.rs @@ -2,7 +2,4 @@ mod test_derivation_interactor; #[allow(clippy::module_inception)] mod test_keys_collector; -#[cfg(test)] pub use test_derivation_interactor::*; -#[cfg(test)] -pub use test_keys_collector::*; diff --git a/crates/sargon/src/keys_collector/derivation_testing/test_keys_collector/test_derivation_interactor.rs b/crates/sargon-keys-collector/src/derivation_testing/test_keys_collector/test_derivation_interactor.rs similarity index 62% rename from crates/sargon/src/keys_collector/derivation_testing/test_keys_collector/test_derivation_interactor.rs rename to crates/sargon-keys-collector/src/derivation_testing/test_keys_collector/test_derivation_interactor.rs index 1dbcf7d30..b5d0f4931 100644 --- a/crates/sargon/src/keys_collector/derivation_testing/test_keys_collector/test_derivation_interactor.rs +++ b/crates/sargon-keys-collector/src/derivation_testing/test_keys_collector/test_derivation_interactor.rs @@ -1,40 +1,64 @@ -#![cfg(test)] -#![allow(unused)] +use std::{ + future::Future, + pin::Pin, + task::{Context, Poll}, +}; use crate::prelude::*; +#[async_trait::async_trait] +pub trait MnemonicLoading: Debug + Send + Sync { + async fn load_mnemonic( + &self, + id: FactorSourceIDFromHash, + ) -> Result; +} + +#[derive(Debug, Default, Clone)] +pub struct FailingMnemonicLoader; + +#[async_trait::async_trait] +impl MnemonicLoading for FailingMnemonicLoader { + async fn load_mnemonic( + &self, + _id: FactorSourceIDFromHash, + ) -> Result { + Err(CommonError::Unknown) + } +} + /// A type impl KeyDerivationInteractor suitable for tests. /// /// Uses Sample values of MnemonicWithPassphrase for derivation, or looks up the mnemonic /// using a SecureStorageClient #[derive(Debug)] -pub(crate) struct TestDerivationInteractor { +pub struct TestDerivationInteractor { pub always_fail: bool, - pub secure_storage_client: Arc, + pub mnemonic_loading: Arc, } impl Default for TestDerivationInteractor { fn default() -> Self { Self { always_fail: false, - secure_storage_client: Arc::new(SecureStorageClient::ephemeral().0), + mnemonic_loading: Arc::new(FailingMnemonicLoader), } } } impl TestDerivationInteractor { - pub(crate) fn new( + pub fn with_mnemonic_loading( always_fail: bool, - secure_storage_client: Arc, + mnemonic_loading: Arc, ) -> Self { Self { always_fail, - secure_storage_client, + mnemonic_loading, } } - pub(crate) fn fail() -> Self { - Self::new(true, Arc::new(SecureStorageClient::always_fail())) + pub fn fail() -> Self { + Self::with_mnemonic_loading(true, Arc::new(FailingMnemonicLoader)) } async fn do_derive( @@ -46,12 +70,12 @@ impl TestDerivationInteractor { return Err(CommonError::Unknown); } - let cloned_client = self.secure_storage_client.clone(); + let cloned_mnemonic_loading = self.mnemonic_loading.clone(); Self::do_derive_serially_looking_up_with_secure_storage_and_extra( factor_source_id, derivation_paths, - cloned_client, + cloned_mnemonic_loading, async move |id| { id.maybe_sample_associated_mnemonic() .ok_or(CommonError::FactorSourceDiscrepancy) @@ -89,13 +113,13 @@ impl TestDerivationInteractor { async fn do_derive_serially_looking_up_with_secure_storage_and_extra( factor_source_id: FactorSourceIDFromHash, derivation_paths: IndexSet, - secure_storage: Arc, + mnemonic_loading: Arc, lookup_mnemonic: F, ) -> Result> where F: async Fn(FactorSourceIDFromHash) -> Result, { - let cloned_client = secure_storage.clone(); + let cloned_mnemonic_loading = mnemonic_loading.clone(); Self::do_derive_serially_with_lookup_of_mnemonic( factor_source_id, derivation_paths, @@ -103,14 +127,35 @@ impl TestDerivationInteractor { if let Ok(m) = lookup_mnemonic(id).await { return Ok(m); } - let cloned_cloned_client = cloned_client.clone(); - cloned_cloned_client.load_mnemonic_with_passphrase(id).await + let cloned_cloned_mnemonic_loading = + cloned_mnemonic_loading.clone(); + cloned_cloned_mnemonic_loading.load_mnemonic(id).await }, ) .await } } +// ==== HERE BE DRAGONS ==== +// Workaround from: +// https://github.com/rust-lang/rust/issues/64552#issuecomment-604419315 +// for Implementation of `Send` is not general enough bug +struct IamSend { + f: F, +} +impl IamSend { + pub unsafe fn new(f: F) -> Self { + IamSend { f } + } +} +unsafe impl Send for IamSend {} +impl Future for IamSend { + type Output = F::Output; + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + unsafe { self.map_unchecked_mut(|s| &mut s.f).poll(cx) } + } +} + #[async_trait::async_trait] impl KeyDerivationInteractor for TestDerivationInteractor { async fn derive( @@ -119,7 +164,8 @@ impl KeyDerivationInteractor for TestDerivationInteractor { ) -> Result { let mut pairs = IndexMap::new(); for (k, r) in request.per_factor_source { - let instances = self.do_derive(k, r).await?; + let instances = + unsafe { IamSend::new(self.do_derive(k, r)) }.await?; pairs.insert(k, instances); } Ok(KeyDerivationResponse::new(pairs)) diff --git a/crates/sargon/src/keys_collector/derivation_testing/test_keys_collector/test_keys_collector.rs b/crates/sargon-keys-collector/src/derivation_testing/test_keys_collector/test_keys_collector.rs similarity index 100% rename from crates/sargon/src/keys_collector/derivation_testing/test_keys_collector/test_keys_collector.rs rename to crates/sargon-keys-collector/src/derivation_testing/test_keys_collector/test_keys_collector.rs diff --git a/crates/sargon/src/keys_collector/host_interaction/key_derivation_interactor.rs b/crates/sargon-keys-collector/src/host_interaction/key_derivation_interactor.rs similarity index 100% rename from crates/sargon/src/keys_collector/host_interaction/key_derivation_interactor.rs rename to crates/sargon-keys-collector/src/host_interaction/key_derivation_interactor.rs diff --git a/crates/sargon/src/keys_collector/host_interaction/key_derivation_request.rs b/crates/sargon-keys-collector/src/host_interaction/key_derivation_request.rs similarity index 100% rename from crates/sargon/src/keys_collector/host_interaction/key_derivation_request.rs rename to crates/sargon-keys-collector/src/host_interaction/key_derivation_request.rs diff --git a/crates/sargon/src/keys_collector/host_interaction/key_derivation_response.rs b/crates/sargon-keys-collector/src/host_interaction/key_derivation_response.rs similarity index 100% rename from crates/sargon/src/keys_collector/host_interaction/key_derivation_response.rs rename to crates/sargon-keys-collector/src/host_interaction/key_derivation_response.rs diff --git a/crates/sargon/src/keys_collector/host_interaction/mod.rs b/crates/sargon-keys-collector/src/host_interaction/mod.rs similarity index 100% rename from crates/sargon/src/keys_collector/host_interaction/mod.rs rename to crates/sargon-keys-collector/src/host_interaction/mod.rs diff --git a/crates/sargon-keys-collector/src/lib.rs b/crates/sargon-keys-collector/src/lib.rs new file mode 100644 index 000000000..ca4042739 --- /dev/null +++ b/crates/sargon-keys-collector/src/lib.rs @@ -0,0 +1,26 @@ +#![feature(async_closure)] + +mod collector; +mod host_interaction; + +#[cfg(test)] +mod tests; + +mod derivation_testing; + +#[cfg(test)] +pub(crate) use tests::*; + +pub mod prelude { + + pub(crate) use sargon_addresses::prelude::*; + pub(crate) use sargon_core::prelude::*; + pub(crate) use sargon_factors::prelude::*; + pub(crate) use sargon_hierarchical_deterministic::prelude::*; + + pub use crate::collector::*; + pub use crate::derivation_testing::*; + pub use crate::host_interaction::*; +} + +pub use prelude::*; diff --git a/crates/sargon/src/keys_collector/tests/derivation_tests.rs b/crates/sargon-keys-collector/src/tests/derivation_tests.rs similarity index 88% rename from crates/sargon/src/keys_collector/tests/derivation_tests.rs rename to crates/sargon-keys-collector/src/tests/derivation_tests.rs index 4d08868b3..7bc3e0d01 100644 --- a/crates/sargon/src/keys_collector/tests/derivation_tests.rs +++ b/crates/sargon-keys-collector/src/tests/derivation_tests.rs @@ -115,6 +115,97 @@ impl DerivationPathConstructors for DerivationPath { } } +#[cfg(test)] +mod basic_tests { + use super::*; + use crate::DerivationPathConstructors; + + #[actix_rt::test] + async fn valid() { + let f0 = FactorSource::sample_ledger(); + let f1 = FactorSource::sample_device(); + let f2 = FactorSource::sample_device_babylon_other(); + let f3 = FactorSource::sample_arculus(); + + let paths = IndexMap::<_, _>::from_iter([ + ( + f0.id_from_hash(), + IndexSet::<_>::from_iter([ + DerivationPath::for_entity( + NetworkID::Mainnet, + CAP26EntityKind::Account, + CAP26KeyKind::TransactionSigning, + Hardened::Securified(SecurifiedU30::ZERO), + ), + DerivationPath::for_entity( + NetworkID::Mainnet, + CAP26EntityKind::Account, + CAP26KeyKind::TransactionSigning, + Hardened::Securified(SecurifiedU30::ONE), + ), + DerivationPath::for_entity( + NetworkID::Stokenet, + CAP26EntityKind::Account, + CAP26KeyKind::TransactionSigning, + Hardened::Unsecurified(UnsecurifiedHardened::TWO), + ), + ]), + ), + ( + f1.id_from_hash(), + IndexSet::<_>::just(DerivationPath::for_entity( + NetworkID::Stokenet, + CAP26EntityKind::Account, + CAP26KeyKind::TransactionSigning, + Hardened::Unsecurified(UnsecurifiedHardened::THREE), + )), + ), + ( + f2.id_from_hash(), + IndexSet::<_>::just(DerivationPath::for_entity( + NetworkID::Mainnet, + CAP26EntityKind::Account, + CAP26KeyKind::TransactionSigning, + Hardened::Unsecurified( + UnsecurifiedHardened::try_from(4u32).unwrap(), + ), + )), + ), + ( + f3.id_from_hash(), + IndexSet::<_>::just(DerivationPath::for_entity( + NetworkID::Mainnet, + CAP26EntityKind::Identity, + CAP26KeyKind::AuthenticationSigning, + Hardened::Securified( + SecurifiedU30::try_from(5u32).unwrap(), + ), + )), + ), + ]); + + let collector = KeysCollector::new( + [f0, f1, f2, f3], + paths.clone(), + Arc::new(TestDerivationInteractor::default()), + DerivationPurpose::PreDerivingKeys, + ) + .unwrap(); + + let outcome = collector.collect_keys().await; + let factors = outcome.all_factors().factor_instances(); + assert_eq!( + factors.len(), + paths + .clone() + .into_iter() + .flat_map(|(_, v)| v) + .collect::>() + .len(), + ); + } +} + mod key_derivation_tests { use super::*; use sargon_hierarchical_deterministic::CAP26EntityKind::*; diff --git a/crates/sargon/src/keys_collector/tests/mod.rs b/crates/sargon-keys-collector/src/tests/mod.rs similarity index 100% rename from crates/sargon/src/keys_collector/tests/mod.rs rename to crates/sargon-keys-collector/src/tests/mod.rs diff --git a/crates/sargon-uniffi/Cargo.toml b/crates/sargon-uniffi/Cargo.toml index 940b470ec..3d85ca5ad 100644 --- a/crates/sargon-uniffi/Cargo.toml +++ b/crates/sargon-uniffi/Cargo.toml @@ -21,7 +21,7 @@ sargon-core = { path = "../sargon-core" } sargon = { path = "../sargon" } sargon-uniffi-conversion-macros = { path = "../sargon-uniffi-conversion-macros" } -radix-engine-toolkit = { git = "https://github.com/radixdlt/radix-engine-toolkit", rev = "2ab5b35a6cb96c9faeb98ed8df67b870336e6873" } +radix-engine-toolkit = { workspace = true } zeroize = { workspace = true } @@ -74,11 +74,9 @@ clap = { git = "https://github.com/clap-rs/clap/", rev = "8a7a13a5618cfdc4ff3286 # camino = "1.0.8" camino = { git = "https://github.com/camino-rs/camino/", rev = "afa51b1b4c684b7e6698a6717ccda3affd0abd42", optional = true } -# async-trait = "0.1.79" -async-trait = { git = "https://github.com/dtolnay/async-trait", rev = "1eb21ed8bd87029bf4dcbea41ff309f2b2220c43" } +async-trait = { workspace = true } -# pretty_assertions = "1.4.0" -pretty_assertions = { git = "https://github.com/rust-pretty-assertions/rust-pretty-assertions", rev = "3f1ebc0cac5f88e875f036bf16636e15fa935c8d" } +pretty_assertions = { workspace = true } base64 = { git = "https://github.com/marshallpierce/rust-base64.git", rev = "e14400697453bcc85997119b874bc03d9601d0af" } @@ -92,9 +90,7 @@ uniffi = { git = "https://github.com/mozilla/uniffi-rs/", rev = "9127d4d9cfb8ff8 "bindgen-tests", ] } -# actix-rt = "3.3.0" -actix-rt = { git = "https://github.com/actix/actix-net", rev = "57fd6ea8098d1f2d281c305fc331216c4fe1992e" } - +actix-rt = { workspace = true } [build-dependencies] # uniffi = "0.28.3" uniffi = { git = "https://github.com/mozilla/uniffi-rs/", rev = "9127d4d9cfb8ff8372e70f2e4e0eb36bc06f146d", features = [ diff --git a/crates/sargon/Cargo.toml b/crates/sargon/Cargo.toml index f2c13dfda..46820b5b5 100644 --- a/crates/sargon/Cargo.toml +++ b/crates/sargon/Cargo.toml @@ -16,6 +16,8 @@ sargon-core = { path = "../sargon-core" } identified-vec-of = { path = "../identified-vec-of" } sargon-hierarchical-deterministic = { path = "../sargon-hierarchical-deterministic" } sargon-factors = { path = "../sargon-factors" } +sargon-keys-collector = { path = "../sargon-keys-collector" } +sargon-addresses = { path = "../sargon-addresses" } zeroize = { workspace = true } @@ -44,7 +46,7 @@ uuid = { workspace = true } strum = { workspace = true } sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v1.3.0" } radix-rust = { workspace = true } -radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v1.3.0" } +radix-engine = { workspace = true } radix-common = { workspace = true } radix-common-derive = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v1.3.0" } radix-engine-interface = { workspace = true } @@ -52,7 +54,7 @@ radix-engine-toolkit-common = { git = "https://github.com/radixdlt/radixdlt-scry radix-transactions = { workspace = true } -radix-engine-toolkit = { git = "https://github.com/radixdlt/radix-engine-toolkit", rev = "2ab5b35a6cb96c9faeb98ed8df67b870336e6873" } +radix-engine-toolkit = { workspace = true } enum-iterator = { workspace = true } @@ -83,8 +85,7 @@ paste = { workspace = true } # camino = "1.0.8" camino = { git = "https://github.com/camino-rs/camino/", rev = "afa51b1b4c684b7e6698a6717ccda3affd0abd42", optional = true } -# async-trait = "0.1.79" -async-trait = { git = "https://github.com/dtolnay/async-trait", rev = "1eb21ed8bd87029bf4dcbea41ff309f2b2220c43" } +async-trait = { workspace = true } pretty_assertions = { workspace = true } @@ -112,8 +113,7 @@ security-framework-sys = "=2.10.0" [dev-dependencies] -# actix-rt = "3.3.0" -actix-rt = { git = "https://github.com/actix/actix-net", rev = "57fd6ea8098d1f2d281c305fc331216c4fe1992e" } +actix-rt = { workspace = true } [build-dependencies] diff --git a/crates/sargon/src/factor_instances_provider/types/mod.rs b/crates/sargon/src/factor_instances_provider/types/mod.rs index 27fa95349..cfe91737f 100644 --- a/crates/sargon/src/factor_instances_provider/types/mod.rs +++ b/crates/sargon/src/factor_instances_provider/types/mod.rs @@ -2,8 +2,6 @@ mod abstract_securified_entity; mod any_securified_entity; mod appendable_collection; mod assert_derivation_path; -mod factor_instances; -mod hidden_constructor; mod is_securified_entity; mod securified_account; mod securified_persona; @@ -14,8 +12,6 @@ pub use abstract_securified_entity::*; pub use any_securified_entity::*; pub use appendable_collection::*; pub use assert_derivation_path::*; -pub use factor_instances::*; -pub use hidden_constructor::*; pub use is_securified_entity::*; pub use securified_account::*; pub use securified_persona::*; diff --git a/crates/sargon/src/keys_collector/mod.rs b/crates/sargon/src/keys_collector/mod.rs deleted file mode 100644 index 943b5ef13..000000000 --- a/crates/sargon/src/keys_collector/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -mod collector; -mod host_interaction; - -#[cfg(test)] -mod tests; - -mod derivation_testing; - -pub use collector::*; -pub use host_interaction::*; - -pub use derivation_testing::*; - -#[cfg(test)] -pub(crate) use tests::*; diff --git a/crates/sargon/src/lib.rs b/crates/sargon/src/lib.rs index c075ce1f7..c754d6419 100644 --- a/crates/sargon/src/lib.rs +++ b/crates/sargon/src/lib.rs @@ -15,7 +15,6 @@ mod error_from; mod factor_instances_provider; mod gateway_api; mod home_cards; -mod keys_collector; mod profile; mod radix_connect; mod security_center; @@ -26,15 +25,16 @@ mod wrapped_radix_engine_toolkit; pub mod prelude { pub use identified_vec_of::prelude::*; + pub use sargon_addresses::prelude::*; pub use sargon_core::prelude::*; pub use sargon_factors::prelude::*; pub use sargon_hierarchical_deterministic::prelude::*; + pub use sargon_keys_collector::prelude::*; pub use crate::error_from::*; pub use crate::factor_instances_provider::*; pub use crate::gateway_api::*; pub use crate::home_cards::*; - pub use crate::keys_collector::*; pub use crate::profile::*; pub use crate::radix_connect::*; pub use crate::security_center::*; @@ -60,67 +60,23 @@ pub mod prelude { pub(crate) use sbor::Versioned; pub(crate) use radix_common::{ - address::{ - AddressBech32Decoder as ScryptoAddressBech32Decoder, - AddressBech32Encoder as ScryptoAddressBech32Encoder, - }, crypto::{ blake2b_256_hash, verify_ed25519 as scrypto_verify_ed25519, verify_secp256k1 as scrypto_verify_secp256k1, Ed25519PrivateKey as ScryptoEd25519PrivateKey, - Ed25519PublicKey as ScryptoEd25519PublicKey, - Ed25519PublicKeyHash as ScryptoEd25519PublicKeyHash, - Ed25519Signature as ScryptoEd25519Signature, Hash as ScryptoHash, - PublicKey as ScryptoPublicKey, - PublicKeyHash as ScryptoPublicKeyHash, + Ed25519Signature as ScryptoEd25519Signature, Secp256k1PrivateKey as ScryptoSecp256k1PrivateKey, Secp256k1PublicKey as ScryptoSecp256k1PublicKey, - Secp256k1PublicKeyHash as ScryptoSecp256k1PublicKeyHash, Secp256k1Signature as ScryptoSecp256k1Signature, }, - data::scrypto::{ - model::{ - BytesNonFungibleLocalId as ScryptoBytesNonFungibleLocalId, - IntegerNonFungibleLocalId as ScryptoIntegerNonFungibleLocalId, - NonFungibleLocalId as ScryptoNonFungibleLocalId, - RUIDNonFungibleLocalId as ScryptoRUIDNonFungibleLocalId, - StringNonFungibleLocalId as ScryptoStringNonFungibleLocalId, - }, - scrypto_decode as Scrypto_scrypto_decode, - scrypto_encode as Scrypto_scrypto_encode, - }, math::{ Decimal as ScryptoDecimal192, RoundingMode as ScryptoRoundingMode, }, network::NetworkDefinition as ScryptoNetworkDefinition, prelude::{ - AllowedIds as ScryptoAllowedIds, - DynamicComponentAddress as ScryptoDynamicComponentAddress, - DynamicGlobalAddress as ScryptoDynamicGlobalAddress, - DynamicResourceAddress as ScryptoDynamicResourceAddress, - FromPublicKey as ScryptoFromPublicKey, Instant as ScryptoInstant, - LowerBound as ScryptoLowerBound, - ManifestAddress as ScryptoManifestAddress, - ManifestAddressReservation as ScryptoManifestAddressReservation, - ManifestBucket as ScryptoManifestBucket, - ManifestCustomValue as ScryptoManifestCustomValue, - ManifestCustomValueKind as ScryptoManifestCustomValueKind, - ManifestEncode as ScryptoManifestEncode, - ManifestNamedAddress as ScryptoManifestNamedAddress, - ManifestProof as ScryptoManifestProof, - ManifestValue as ScryptoManifestValue, - NonFungibleData as ScryptoNonFungibleData, - NonFungibleGlobalId as ScryptoNonFungibleGlobalId, - NonFungibleIdType as ScryptoNonFungibleIdType, UpperBound as ScryptoUpperBound, ACCOUNT_OWNER_BADGE as SCRYPTO_ACCOUNT_OWNER_BADGE, - IDENTITY_OWNER_BADGE as SCRYPTO_IDENTITY_OWNER_BADGE, XRD, - }, - types::{ - ComponentAddress as ScryptoComponentAddress, - EntityType as ScryptoEntityType, - GlobalAddress as ScryptoGlobalAddress, NodeId as ScryptoNodeId, - ResourceAddress as ScryptoResourceAddress, + IDENTITY_OWNER_BADGE as SCRYPTO_IDENTITY_OWNER_BADGE, }, ManifestSbor as ScryptoManifestSbor, ScryptoSbor, }; diff --git a/crates/sargon/src/profile/supporting_types/account_for_display.rs b/crates/sargon/src/profile/supporting_types/account_for_display.rs index f334b79d6..c0312cf78 100644 --- a/crates/sargon/src/profile/supporting_types/account_for_display.rs +++ b/crates/sargon/src/profile/supporting_types/account_for_display.rs @@ -104,7 +104,7 @@ mod tests { assert_eq!( lhs, SUT::new( - "account_rdx128dtethfy8ujrsfdztemyjk0kvhnah6dafr57frz85dcw2c8z0td87", + "account_rdx128dtethfy8ujrsfdztemyjk0kvhnah6dafr57frz85dcw2c8z0td87".parse::().unwrap(), DisplayName::new("Alice").unwrap(), AppearanceID::new(0).unwrap(), ) diff --git a/crates/sargon/src/profile/v100/entity/account/on_ledger_settings/third_party_deposits/mod.rs b/crates/sargon/src/profile/v100/entity/account/on_ledger_settings/third_party_deposits/mod.rs index 98687ea35..47e6ce3bc 100644 --- a/crates/sargon/src/profile/v100/entity/account/on_ledger_settings/third_party_deposits/mod.rs +++ b/crates/sargon/src/profile/v100/entity/account/on_ledger_settings/third_party_deposits/mod.rs @@ -3,7 +3,6 @@ mod assets_exception_list; mod deposit_address_exception_rule; mod deposit_rule; mod depositors_allow_list; -mod resource_or_non_fungible; mod third_party_deposits; pub use asset_exception::*; @@ -11,5 +10,4 @@ pub use assets_exception_list::*; pub use deposit_address_exception_rule::*; pub use deposit_rule::*; pub use depositors_allow_list::*; -pub use resource_or_non_fungible::*; pub use third_party_deposits::*; diff --git a/crates/sargon/src/profile/v100/mod.rs b/crates/sargon/src/profile/v100/mod.rs index 36091ade1..8c5fd0258 100644 --- a/crates/sargon/src/profile/v100/mod.rs +++ b/crates/sargon/src/profile/v100/mod.rs @@ -1,4 +1,3 @@ -mod address; mod app_preferences; mod entities_linked_to_factor_source; mod entity; @@ -10,7 +9,6 @@ mod profile_file_contents; mod profile_legacy_state_bugs; mod proto_profile_maybe_with_legacy_p2p_links; -pub use address::*; pub use app_preferences::*; pub use entities_linked_to_factor_source::*; pub use entity::*; diff --git a/crates/sargon/src/profile/v100/networks/network/authorized_dapp/authorized_dapp.rs b/crates/sargon/src/profile/v100/networks/network/authorized_dapp/authorized_dapp.rs index ed1e9db95..49bd58589 100644 --- a/crates/sargon/src/profile/v100/networks/network/authorized_dapp/authorized_dapp.rs +++ b/crates/sargon/src/profile/v100/networks/network/authorized_dapp/authorized_dapp.rs @@ -106,14 +106,6 @@ impl Identifiable for AuthorizedDapp { pub type DappDefinitionAddress = AccountAddress; -impl Identifiable for AccountAddress { - type ID = Self; - - fn id(&self) -> Self::ID { - *self - } -} - impl AuthorizedDapp { pub fn sample_mainnet_dashboard() -> Self { Self::new( diff --git a/crates/sargon/src/signing/collector/signatures_collector_preprocessor.rs b/crates/sargon/src/signing/collector/signatures_collector_preprocessor.rs index 5a64f43be..a5fefd8df 100644 --- a/crates/sargon/src/signing/collector/signatures_collector_preprocessor.rs +++ b/crates/sargon/src/signing/collector/signatures_collector_preprocessor.rs @@ -4,31 +4,6 @@ pub(crate) struct SignaturesCollectorPreprocessor { signables_with_entities: IdentifiedVecOf>, } -pub(crate) fn sort_group_factors( - used_factor_sources: HashSet, -) -> IndexSet { - let factors_of_kind: HashMap> = - used_factor_sources - .into_iter() - .into_grouping_map_by(|x| x.factor_source_kind()) - .collect::>(); - - let mut factors_of_kind = factors_of_kind - .into_iter() - .map(|(k, v)| (k, v.into_iter().sorted().collect::>())) - .collect::>>(); - - factors_of_kind.sort_keys(); - - factors_of_kind - .into_iter() - .map(|(k, v)| { - FactorSourcesOfKind::new(k, v) - .expect("All factors should be of the same kind, since this is calling iter on a Map, using kind as key. Did you just move around lines of code?") - }) - .collect::>() -} - impl SignaturesCollectorPreprocessor { pub(super) fn new( signables_with_entities: IdentifiedVecOf>, diff --git a/crates/sargon/src/system/clients/client/secure_storage_client/secure_storage_client.rs b/crates/sargon/src/system/clients/client/secure_storage_client/secure_storage_client.rs index 52c423c73..8498f1d0a 100644 --- a/crates/sargon/src/system/clients/client/secure_storage_client/secure_storage_client.rs +++ b/crates/sargon/src/system/clients/client/secure_storage_client/secure_storage_client.rs @@ -229,6 +229,37 @@ impl SecureStorageClient { } } +pub trait TestDerivationInteractorFromSecureStorageClient: Sized { + fn new( + always_fail: bool, + secure_storage_client: Arc, + ) -> Self; +} + +#[async_trait::async_trait] +impl MnemonicLoading for SecureStorageClient { + async fn load_mnemonic( + &self, + id: FactorSourceIDFromHash, + ) -> Result { + self.load_mnemonic_with_passphrase(id).await + } +} + +impl TestDerivationInteractorFromSecureStorageClient + for TestDerivationInteractor +{ + fn new( + always_fail: bool, + secure_storage_client: Arc, + ) -> Self { + Self::with_mnemonic_loading( + always_fail, + secure_storage_client as Arc, + ) + } +} + #[cfg(test)] impl SecureStorageClient { pub(crate) fn ephemeral( diff --git a/crates/sargon/src/types/mod.rs b/crates/sargon/src/types/mod.rs index c53204156..cdeacaeee 100644 --- a/crates/sargon/src/types/mod.rs +++ b/crates/sargon/src/types/mod.rs @@ -1,11 +1,9 @@ -mod factor_sources_of_kind; mod hd_signature; mod hd_signature_input; mod invalid_transaction_if_neglected; mod owned_types; mod samples; -pub(crate) use factor_sources_of_kind::*; pub use hd_signature::*; pub use hd_signature_input::*; pub use invalid_transaction_if_neglected::*; diff --git a/crates/sargon/src/types/samples/access_controller_address_samples.rs b/crates/sargon/src/types/samples/access_controller_address_samples.rs index d20b92b8c..dbe70874f 100644 --- a/crates/sargon/src/types/samples/access_controller_address_samples.rs +++ b/crates/sargon/src/types/samples/access_controller_address_samples.rs @@ -3,10 +3,16 @@ use crate::{ IsNetworkAware, }; -impl AccessControllerAddress { - pub fn sample_from_account_address( - account_address: AccountAddress, - ) -> Self { +pub trait SamplesFromAccountAddress { + fn sample_from_account_address(account_address: AccountAddress) -> Self; +} + +pub trait SamplesFromIdentityAddress { + fn sample_from_identity_address(identity_address: IdentityAddress) -> Self; +} + +impl SamplesFromAccountAddress for AccessControllerAddress { + fn sample_from_account_address(account_address: AccountAddress) -> Self { let node_id: [u8; 29] = account_address.node_id().as_bytes()[0..29] .try_into() .unwrap(); @@ -16,10 +22,10 @@ impl AccessControllerAddress { account_address.network_id(), ) } +} - pub fn sample_from_identity_address( - identity_address: IdentityAddress, - ) -> Self { +impl SamplesFromIdentityAddress for AccessControllerAddress { + fn sample_from_identity_address(identity_address: IdentityAddress) -> Self { let node_id: [u8; 29] = identity_address.node_id().as_bytes()[0..29] .try_into() .unwrap(); diff --git a/crates/sargon/src/types/samples/account_address_samples.rs b/crates/sargon/src/types/samples/account_address_samples.rs index 2ba27edc6..619546fe4 100644 --- a/crates/sargon/src/types/samples/account_address_samples.rs +++ b/crates/sargon/src/types/samples/account_address_samples.rs @@ -1,11 +1,14 @@ use crate::prelude::*; +use crate::types::samples::{HasIndexedSampleValues, HasManySampleValues}; -impl AccountAddress { - pub fn sample_at(index: usize) -> Self { +impl HasIndexedSampleValues for AccountAddress { + fn sample_at(index: usize) -> Self { Account::sample_at(index).address } +} - pub fn sample_all() -> Vec { +impl HasManySampleValues for AccountAddress { + fn sample_all() -> Vec { Account::sample_all().iter().map(|a| a.address).collect() } } diff --git a/crates/sargon/src/types/samples/account_samples.rs b/crates/sargon/src/types/samples/account_samples.rs index 31c69e05f..f50e37e77 100644 --- a/crates/sargon/src/types/samples/account_samples.rs +++ b/crates/sargon/src/types/samples/account_samples.rs @@ -1,6 +1,6 @@ -use radix_common::address; - use crate::prelude::*; +use crate::types::samples::access_controller_address_samples::SamplesFromAccountAddress; +use radix_common::address; static ALL_ACCOUNT_SAMPLES: Lazy<[Account; 10]> = Lazy::new(|| { [ diff --git a/crates/sargon/src/types/samples/identity_address_samples.rs b/crates/sargon/src/types/samples/identity_address_samples.rs index 4a788ecf7..bb3e12e66 100644 --- a/crates/sargon/src/types/samples/identity_address_samples.rs +++ b/crates/sargon/src/types/samples/identity_address_samples.rs @@ -1,11 +1,23 @@ use crate::prelude::*; -impl IdentityAddress { - pub fn sample_at(index: usize) -> Self { +pub trait HasManySampleValues: Sized { + #[allow(dead_code)] + fn sample_all() -> Vec; +} + +pub trait HasIndexedSampleValues: Sized { + #[allow(dead_code)] + fn sample_at(index: usize) -> Self; +} + +impl HasIndexedSampleValues for IdentityAddress { + fn sample_at(index: usize) -> Self { Persona::sample_at(index).address } +} - pub fn sample_all() -> Vec { +impl HasManySampleValues for IdentityAddress { + fn sample_all() -> Vec { Persona::sample_all().iter().map(|a| a.address).collect() } } diff --git a/crates/sargon/src/types/samples/persona_samples.rs b/crates/sargon/src/types/samples/persona_samples.rs index 6aae96816..13c172620 100644 --- a/crates/sargon/src/types/samples/persona_samples.rs +++ b/crates/sargon/src/types/samples/persona_samples.rs @@ -1,4 +1,5 @@ use crate::prelude::*; +use crate::types::samples::access_controller_address_samples::SamplesFromIdentityAddress; static ALL_PERSONA_SAMPLES: Lazy<[Persona; 8]> = Lazy::new(|| { [ diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/delete_account/manifest_delete_account.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/delete_account/manifest_delete_account.rs index 58f5f4f70..f5f548329 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/delete_account/manifest_delete_account.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/delete_account/manifest_delete_account.rs @@ -136,7 +136,7 @@ mod tests { fn manifest_without_transfers() { manifest_eq( SUT::delete_account( - &"account_tdx_2_16yll6clntk9za0wvrw0nat848uazduyqy635m8ms77md99q7yf9fzg".into(), + &"account_tdx_2_16yll6clntk9za0wvrw0nat848uazduyqy635m8ms77md99q7yf9fzg".parse::().unwrap(), None, vec![ AccountResourcePreference::sample_other().into(), @@ -206,7 +206,7 @@ CALL_METHOD vec![], ); let manifest = SUT::delete_account( - &"account_tdx_2_16yll6clntk9za0wvrw0nat848uazduyqy635m8ms77md99q7yf9fzg".into(), + &"account_tdx_2_16yll6clntk9za0wvrw0nat848uazduyqy635m8ms77md99q7yf9fzg".parse::().unwrap(), transfers, vec![ AccountResourcePreference::sample_other().into(), diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/manifest_account_locker.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/manifest_account_locker.rs index 127625d45..bef36f393 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/manifest_account_locker.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/manifest_account_locker.rs @@ -5,12 +5,6 @@ use radix_engine_interface::blueprints::locker::{ }; use std::cmp::min; -impl From for ScryptoComponentAddress { - fn from(value: AccountAddress) -> ScryptoComponentAddress { - ScryptoComponentAddress::new_or_panic(value.node_id().0) - } -} - impl TransactionManifest { pub fn account_locker_claim( locker_address: &LockerAddress, @@ -87,7 +81,7 @@ impl TransactionManifest { #[cfg(test)] mod tests { use super::*; - use radix_common::prelude::ResourceAddress; + use sargon_addresses::ResourceAddress; #[allow(clippy::upper_case_acronyms)] type SUT = TransactionManifest; @@ -95,8 +89,8 @@ mod tests { #[test] fn empty() { let manifest = SUT::account_locker_claim( - &"locker_rdx1drn4q2zk6dvljehytnhfah330xk7emfznv59rqlps5ayy52d7xkzzz".into(), - &"account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr".into(), + &"locker_rdx1drn4q2zk6dvljehytnhfah330xk7emfznv59rqlps5ayy52d7xkzzz".parse::().unwrap(), + &"account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr".parse::().unwrap(), vec![], ); manifest_eq(manifest, "") @@ -110,23 +104,23 @@ mod tests { )); let manifest = SUT::account_locker_claim( - &"locker_rdx1drn4q2zk6dvljehytnhfah330xk7emfznv59rqlps5ayy52d7xkzzz".into(), - &"account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr".into(), + &"locker_rdx1drn4q2zk6dvljehytnhfah330xk7emfznv59rqlps5ayy52d7xkzzz".parse::().unwrap(), + &"account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr".parse::().unwrap(), vec![ AccountLockerClaimableResource::Fungible { - resource_address: "resource_rdx1t4dy69k6s0gv040xa64cyadyefwtett62ng6xfdnljyydnml7t6g3j".into(), + resource_address: "resource_rdx1t4dy69k6s0gv040xa64cyadyefwtett62ng6xfdnljyydnml7t6g3j".parse::().unwrap(), amount: 123.into(), }, AccountLockerClaimableResource::NonFungible { - resource_address: "resource_rdx1nfyg2f68jw7hfdlg5hzvd8ylsa7e0kjl68t5t62v3ttamtejc9wlxa".into(), + resource_address: "resource_rdx1nfyg2f68jw7hfdlg5hzvd8ylsa7e0kjl68t5t62v3ttamtejc9wlxa".parse::().unwrap(), number_of_items: 10, }, AccountLockerClaimableResource::Fungible { - resource_address: "resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd".into(), + resource_address: "resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd".parse::().unwrap(), amount: 1500.into(), }, AccountLockerClaimableResource::NonFungible { - resource_address: "resource_rdx1n2ekdd2m0jsxjt9wasmu3p49twy2yfalpaa6wf08md46sk8dfmldnd".into(), + resource_address: "resource_rdx1n2ekdd2m0jsxjt9wasmu3p49twy2yfalpaa6wf08md46sk8dfmldnd".parse::().unwrap(), number_of_items: 1, }, ], @@ -142,15 +136,15 @@ mod tests { "account_locker_claim_max_nft_items.rtm" )); let manifest = SUT::account_locker_claim( - &"locker_rdx1drn4q2zk6dvljehytnhfah330xk7emfznv59rqlps5ayy52d7xkzzz".into(), - &"account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr".into(), + &"locker_rdx1drn4q2zk6dvljehytnhfah330xk7emfznv59rqlps5ayy52d7xkzzz".parse::().unwrap(), + &"account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr".parse::().unwrap(), vec![ AccountLockerClaimableResource::NonFungible { - resource_address: "resource_rdx1n2ekdd2m0jsxjt9wasmu3p49twy2yfalpaa6wf08md46sk8dfmldnd".into(), + resource_address: "resource_rdx1n2ekdd2m0jsxjt9wasmu3p49twy2yfalpaa6wf08md46sk8dfmldnd".parse::().unwrap(), number_of_items: 100, }, AccountLockerClaimableResource::Fungible { - resource_address: "resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd".into(), + resource_address: "resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd".parse::().unwrap(), amount: Decimal192::one(), } ], diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/mod.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/mod.rs index d9e8cc0a8..6a5033f08 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/mod.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/mod.rs @@ -1,4 +1,3 @@ -mod addresses_manifest_builder_support; mod assert_manifest; mod bucket; mod bucket_factory; @@ -12,7 +11,6 @@ mod metadata; mod modify_manifest; mod third_party_deposit_update; -pub use addresses_manifest_builder_support::*; pub use assert_manifest::*; pub use bucket::*; pub use bucket_factory::*; diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/third_party_deposit_update/manifest_third_party_deposit_update.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/third_party_deposit_update/manifest_third_party_deposit_update.rs index 5775fa2bd..938169401 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/third_party_deposit_update/manifest_third_party_deposit_update.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/third_party_deposit_update/manifest_third_party_deposit_update.rs @@ -107,7 +107,7 @@ CALL_METHOD #[test] fn update_third_party_deposits() { - let owner:AccountAddress = "account_tdx_2_128x8q5es2dstqtcc8wqm843xdtfs0lgetfcdn62a54wxspj6yhpxkf".into(); + let owner: AccountAddress = "account_tdx_2_128x8q5es2dstqtcc8wqm843xdtfs0lgetfcdn62a54wxspj6yhpxkf".parse::().unwrap(); let to_json = r#" { "assetsExceptionList" : [ diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/third_party_deposit_update/third_party_deposits_delta.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/third_party_deposit_update/third_party_deposits_delta.rs index ce023dfa5..d37e3e042 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/third_party_deposit_update/third_party_deposits_delta.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/manifest_building/third_party_deposit_update/third_party_deposits_delta.rs @@ -99,37 +99,6 @@ impl ThirdPartyDepositsDelta { } } -impl From - for ScryptoAccountRemoveAuthorizedDepositorInput -{ - fn from(value: ResourceOrNonFungible) -> Self { - Self { - badge: value.into(), - } - } -} -impl From for ScryptoAccountAddAuthorizedDepositorInput { - fn from(value: ResourceOrNonFungible) -> Self { - Self { - badge: value.into(), - } - } -} -impl From - for ScryptoAccountRemoveResourcePreferenceInput -{ - fn from(value: ResourceOrNonFungible) -> Self { - match value { - ResourceOrNonFungible::Resource { value } => Self { - resource_address: value.into(), - }, - ResourceOrNonFungible::NonFungible { value } => Self { - resource_address: value.resource_address.into(), - }, - } - } -} - impl From for ScryptoAccountSetResourcePreferenceInput { fn from(value: AssetException) -> Self { Self { diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/assets_transfers/per_recipient/per_recipient_asset_transfers.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/assets_transfers/per_recipient/per_recipient_asset_transfers.rs index 9d66b76fb..b64897a60 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/assets_transfers/per_recipient/per_recipient_asset_transfers.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/assets_transfers/per_recipient/per_recipient_asset_transfers.rs @@ -284,12 +284,12 @@ mod tests { #[test] fn transpose_complex() { - let sender: AccountAddress = "account_tdx_2_128rkfzdztjpgajucstydar2gz2vp9jj779k33jy3gect2rh5r28rgn".into(); - let recip0: AccountAddress = "account_tdx_2_129e9h6zp5z08qkc0q5tdqz9zc67gg2k7tergrj9erznmke6qeevmsv".into(); - let recip1: AccountAddress = "account_tdx_2_128a45a7hetjfpfqdlsp07eyrmhq7edldefgd7263jd58puzuq09qks".into(); + let sender: AccountAddress = "account_tdx_2_128rkfzdztjpgajucstydar2gz2vp9jj779k33jy3gect2rh5r28rgn".parse::().unwrap(); + let recip0: AccountAddress = "account_tdx_2_129e9h6zp5z08qkc0q5tdqz9zc67gg2k7tergrj9erznmke6qeevmsv".parse::().unwrap(); + let recip1: AccountAddress = "account_tdx_2_128a45a7hetjfpfqdlsp07eyrmhq7edldefgd7263jd58puzuq09qks".parse::().unwrap(); - let nft_c0: NonFungibleResourceAddress = "resource_tdx_2_1n2sjxxtk6vm6pvk8dxr798e8zpxqz50q5wlmldlat0qhh04u2mwmy8".into(); - let nft_c1: NonFungibleResourceAddress = "resource_tdx_2_1ntuaekqexa73m9en04jj3vdt3fk9u9kdk8q9su4efldun2y7nd3cga".into(); + let nft_c0 = "resource_tdx_2_1n2sjxxtk6vm6pvk8dxr798e8zpxqz50q5wlmldlat0qhh04u2mwmy8".parse::().unwrap(); + let nft_c1 = "resource_tdx_2_1ntuaekqexa73m9en04jj3vdt3fk9u9kdk8q9su4efldun2y7nd3cga".parse::().unwrap(); let fung_0: ResourceAddress = ResourceAddress::sample_stokenet_xrd(); let fung_1: ResourceAddress = diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/manifest_encountered_component_address.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/manifest_encountered_component_address.rs index 558ac059d..fd2bcb83d 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/manifest_encountered_component_address.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/manifest_encountered_component_address.rs @@ -1,3 +1,5 @@ +use sargon_addresses::address_union; + use crate::prelude::*; address_union!( diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/mod.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/mod.rs index 9318e7e28..f34302f1e 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/mod.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/high_level/sargon_specific_types/mod.rs @@ -1,8 +1,4 @@ -#[macro_use] -mod address_union; - mod account_locker; -mod address_of_account_or_persona; mod assets_transfers; mod build_information; mod manifest_encountered_component_address; @@ -10,12 +6,9 @@ mod stake_claim; mod transaction; mod transaction_guarantee; -pub use address_of_account_or_persona::*; pub use assets_transfers::*; pub use build_information::*; -pub use address_union::*; - pub use stake_claim::*; pub use transaction_guarantee::*; diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/address_conversion/mod.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/address_conversion/mod.rs deleted file mode 100644 index 9db861074..000000000 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/address_conversion/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod resource_address_from; -pub use resource_address_from::*; diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/execution_summary/execution_summary.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/execution_summary/execution_summary.rs index 718df8e97..50634d9a6 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/execution_summary/execution_summary.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/execution_summary/execution_summary.rs @@ -2,6 +2,49 @@ use radix_rust::prelude::IndexMap; use crate::prelude::*; +pub(crate) fn to_vec_network_aware( + values: impl IntoIterator, + network_id: NetworkID, +) -> Vec +where + U: From<(T, NetworkID)>, +{ + values + .into_iter() + .map(|x| (x, network_id)) + .map(U::from) + .collect_vec() +} + +pub(crate) fn to_hashmap_network_aware_key( + values: impl IntoIterator, + network_id: NetworkID, +) -> HashMap +where + L: Eq + std::hash::Hash + From<(K, NetworkID)>, + U: From, +{ + values + .into_iter() + .map(|(k, v)| (L::from((k, network_id)), U::from(v))) + .collect::>() +} + +pub(crate) fn filter_try_to_vec_network_aware( + values: impl IntoIterator, + network_id: NetworkID, +) -> Vec +where + U: TryFrom<(T, NetworkID)>, +{ + values + .into_iter() + .map(|x| (x, network_id)) + .map(U::try_from) + .filter_map(Result::ok) + .collect_vec() +} + /// A summary of the execution of the manifest and the information that helps /// wallets present the contents of a transaction. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/mod.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/mod.rs index 761c2b189..36085b203 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/mod.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/mod.rs @@ -1,4 +1,3 @@ -mod address_conversion; mod compiled_notarized_intent; mod compiled_transaction_intent; mod dynamically_analyzable_manifest; @@ -7,7 +6,6 @@ mod intent_signature; mod manifest_summary; mod notarized_transaction; mod notary_signature; -mod public_key_hash; mod sbor_depth_validation; mod signed_intent; mod statically_analyzable_manifest; @@ -16,7 +14,6 @@ mod transaction_hashes; mod v1; mod v2; -pub use address_conversion::*; pub use compiled_notarized_intent::*; pub use compiled_transaction_intent::*; pub use dynamically_analyzable_manifest::*; @@ -25,7 +22,6 @@ pub use intent_signature::*; pub use manifest_summary::*; pub use notarized_transaction::*; pub use notary_signature::*; -pub use public_key_hash::*; pub(crate) use sbor_depth_validation::*; pub use signed_intent::*; pub use statically_analyzable_manifest::*; diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v1/transaction_manifest/execution_summary/transaction_manifest_execution_summary.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v1/transaction_manifest/execution_summary/transaction_manifest_execution_summary.rs index 8bdbf8236..40b0ca07f 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v1/transaction_manifest/execution_summary/transaction_manifest_execution_summary.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v1/transaction_manifest/execution_summary/transaction_manifest_execution_summary.rs @@ -79,7 +79,7 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc_v3: AccountAddress = "account_tdx_2_12x55t8w9lf2qjh6z98jjxy04tkpjgjxawqm252gerhyath7qka34v3".into(); + let acc_v3 = "account_tdx_2_12x55t8w9lf2qjh6z98jjxy04tkpjgjxawqm252gerhyath7qka34v3".parse::().unwrap(); pretty_assertions::assert_eq!( sut, @@ -89,21 +89,21 @@ mod tests { acc_v3, vec![ ResourceIndicator::fungible( - "resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc", + "resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc".parse::().unwrap(), FungibleResourceIndicator::guaranteed(10) ), ResourceIndicator::fungible( - "resource_tdx_2_1t4nnqzrdympy0n74yhvkp7vnver90j5yurlhqu3083z8mt2gdvu7sq", + "resource_tdx_2_1t4nnqzrdympy0n74yhvkp7vnver90j5yurlhqu3083z8mt2gdvu7sq".parse::().unwrap(), FungibleResourceIndicator::guaranteed(5) ), ResourceIndicator::non_fungible( - "resource_tdx_2_1n2uml563pnl0yjmd57xnj80mzdwyh4ca4w29zt2ljwpwq2p837c4a7", + "resource_tdx_2_1n2uml563pnl0yjmd57xnj80mzdwyh4ca4w29zt2ljwpwq2p837c4a7".parse::().unwrap(), NonFungibleResourceIndicator::by_ids([ NonFungibleLocalId::integer(64), ]) ), ResourceIndicator::non_fungible( - "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue", + "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue".parse::().unwrap(), NonFungibleResourceIndicator::by_ids([ NonFungibleLocalId::string("Member_6").unwrap(), ]) @@ -113,14 +113,14 @@ mod tests { ], //withdrawals [ ( - AccountAddress::from("account_tdx_2_129n8v0x9q2zj78293sv7xhz9zcysvcvwp70pc6826k8f7dte96sfcn"), + AccountAddress::from_str("account_tdx_2_129n8v0x9q2zj78293sv7xhz9zcysvcvwp70pc6826k8f7dte96sfcn").unwrap(), vec![ ResourceIndicator::fungible( - "resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc", + "resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc".parse::().unwrap(), FungibleResourceIndicator::guaranteed(10) ), ResourceIndicator::non_fungible( - "resource_tdx_2_1n2uml563pnl0yjmd57xnj80mzdwyh4ca4w29zt2ljwpwq2p837c4a7", + "resource_tdx_2_1n2uml563pnl0yjmd57xnj80mzdwyh4ca4w29zt2ljwpwq2p837c4a7".parse::().unwrap(), NonFungibleResourceIndicator::by_ids([ NonFungibleLocalId::integer(64), ]) @@ -128,14 +128,14 @@ mod tests { ] ), ( - AccountAddress::from("account_tdx_2_12x58hfy598wl5vukv3sqrkc7h3n699nqygufncycayeuwydel8esnu"), + AccountAddress::from_str("account_tdx_2_12x58hfy598wl5vukv3sqrkc7h3n699nqygufncycayeuwydel8esnu").unwrap(), vec![ ResourceIndicator::fungible( - "resource_tdx_2_1t4nnqzrdympy0n74yhvkp7vnver90j5yurlhqu3083z8mt2gdvu7sq", + "resource_tdx_2_1t4nnqzrdympy0n74yhvkp7vnver90j5yurlhqu3083z8mt2gdvu7sq".parse::().unwrap(), FungibleResourceIndicator::guaranteed(5) ), ResourceIndicator::non_fungible( - "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue", + "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue".parse::().unwrap(), NonFungibleResourceIndicator::by_ids([ NonFungibleLocalId::string("Member_6").unwrap(), ]) @@ -187,7 +187,7 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc_g2: AccountAddress = "account_tdx_2_129uv9r46an4hwng8wc97qwpraspvnrc7v2farne4lr6ff7yaevaz2a".into(); + let acc_g2: AccountAddress = "account_tdx_2_129uv9r46an4hwng8wc97qwpraspvnrc7v2farne4lr6ff7yaevaz2a".parse().unwrap(); pretty_assertions::assert_eq!( sut, @@ -208,7 +208,7 @@ mod tests { >::from_iter([( acc_g2, HashMap::<_, _>::from_iter([( - "resource_tdx_2_1t4nnqzrdympy0n74yhvkp7vnver90j5yurlhqu3083z8mt2gdvu7sq".into(), + "resource_tdx_2_1t4nnqzrdympy0n74yhvkp7vnver90j5yurlhqu3083z8mt2gdvu7sq".parse::().unwrap(), ResourcePreferenceUpdate::Remove, )]), )]), @@ -253,8 +253,8 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc_v3: AccountAddress = "account_tdx_2_12x55t8w9lf2qjh6z98jjxy04tkpjgjxawqm252gerhyath7qka34v3".into(); - let token_address: ResourceAddress = "resource_tdx_2_1tkd0xf49tvq4wjdxn7khkt9l900750rd2jqdajukgwsyv8k9md5hh6".into(); + let acc_v3 = "account_tdx_2_12x55t8w9lf2qjh6z98jjxy04tkpjgjxawqm252gerhyath7qka34v3".parse::().unwrap(); + let token_address = "resource_tdx_2_1tkd0xf49tvq4wjdxn7khkt9l900750rd2jqdajukgwsyv8k9md5hh6".parse::().unwrap(); pretty_assertions::assert_eq!( sut, @@ -309,8 +309,8 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc: AccountAddress = "account_tdx_2_12x55t8w9lf2qjh6z98jjxy04tkpjgjxawqm252gerhyath7qka34v3".into(); - let non_fungible_address: ResourceAddress = "resource_tdx_2_1nfnyenkeznzwpnf0nufa6ajsahpu00quhm8xwfrzt8u3dqm2ltzzhl".into(); + let acc: AccountAddress = "account_tdx_2_12x55t8w9lf2qjh6z98jjxy04tkpjgjxawqm252gerhyath7qka34v3".parse().unwrap(); + let non_fungible_address: ResourceAddress = "resource_tdx_2_1nfnyenkeznzwpnf0nufa6ajsahpu00quhm8xwfrzt8u3dqm2ltzzhl".parse().unwrap(); pretty_assertions::assert_eq!( sut, @@ -396,7 +396,7 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc_ac: AccountAddress = "account_tdx_2_129qq7m9ttup2kn6t4g4s0dvazxplktj7vd7my76hfd7xh7ham5zeac".into(); + let acc_ac: AccountAddress = "account_tdx_2_129qq7m9ttup2kn6t4g4s0dvazxplktj7vd7my76hfd7xh7ham5zeac".parse().unwrap(); pretty_assertions::assert_eq!( sut, @@ -406,7 +406,7 @@ mod tests { acc_ac, vec![ ResourceIndicator::fungible( - "resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck", + "resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck".parse::().unwrap(), FungibleResourceIndicator::guaranteed(5) ), ] @@ -417,7 +417,7 @@ mod tests { acc_ac, vec![ ResourceIndicator::non_fungible( - "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue", + "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue".parse::().unwrap(), NonFungibleResourceIndicator::by_amount(1, PredictedNonFungibleLocalIds::new( [], 4 @@ -479,7 +479,7 @@ mod tests { acc_ac, vec![ ResourceIndicator::fungible( - "resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck", + "resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck".parse::().unwrap(), FungibleResourceIndicator::guaranteed(1) ), ] @@ -490,7 +490,7 @@ mod tests { [], // addresses_of_identities_requiring_auth [], // newly_created_non_fungibles [ReservedInstruction::AccountLockFee], // reserved_instructions - [ResourceSpecifier::non_fungible("resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue", vec!["".parse().unwrap()])], // presented_proofs + [ResourceSpecifier::non_fungible("resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue".parse::().unwrap(), vec!["".parse().unwrap()])], // presented_proofs ["component_tdx_2_1cr4pa9ex9xhwzfjzclv8vjnfylw93wvhkwcwc0xlahpkel0krxqedw".parse::().unwrap()], // encountered_component_addresses [ DetailedManifestClass::General @@ -581,7 +581,7 @@ mod tests { FungibleResourceIndicator::guaranteed(237) ), ResourceIndicator::fungible( - r"resource_tdx_2_1thw7yclz24h5xjp3086cj8z2ya0d7p9mydk0yh68c28ha02uhzrnyy", + r"resource_tdx_2_1thw7yclz24h5xjp3086cj8z2ya0d7p9mydk0yh68c28ha02uhzrnyy".parse::().unwrap(), FungibleResourceIndicator::guaranteed(1337) ), ] @@ -713,9 +713,9 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc_gk = AccountAddress::from("account_tdx_2_12x55t8w9lf2qjh6z98jjxy04tkpjgjxawqm252gerhyath7qka34v3"); - let resource_address_of_pool = ResourceAddress::from("resource_tdx_2_1thgnc84xkcjhs46pfvm9s8zn8t9kxwryvyr9x3947xpt6jxty7qn25"); - let pool_address = PoolAddress::from("pool_tdx_2_1c5mygu9t8rlfq6j8v2ynrg60ltts2dctsghust8u2tuztrml427830"); + let acc_gk = AccountAddress::from_str("account_tdx_2_12x55t8w9lf2qjh6z98jjxy04tkpjgjxawqm252gerhyath7qka34v3").unwrap(); + let resource_address_of_pool = ResourceAddress::from_str("resource_tdx_2_1thgnc84xkcjhs46pfvm9s8zn8t9kxwryvyr9x3947xpt6jxty7qn25").unwrap(); + let pool_address = PoolAddress::from_str("pool_tdx_2_1c5mygu9t8rlfq6j8v2ynrg60ltts2dctsghust8u2tuztrml427830").unwrap(); pretty_assertions::assert_eq!( sut, @@ -738,7 +738,7 @@ mod tests { pool_addresses: vec![pool_address], pool_redemptions: vec![TrackedPoolRedemption::new( pool_address, - ResourceAddress::from("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc"), + ResourceAddress::from_str("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc").unwrap(), 3.162277, [] )] @@ -770,11 +770,11 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc_gk: AccountAddress = "account_tdx_2_129uv9r46an4hwng8wc97qwpraspvnrc7v2farne4lr6ff7yaevaz2a".into(); + let acc_gk: AccountAddress = "account_tdx_2_129uv9r46an4hwng8wc97qwpraspvnrc7v2farne4lr6ff7yaevaz2a".parse().unwrap(); - let nf_global_id: NonFungibleGlobalId = "resource_tdx_2_1ngw8z6ut9mw54am4rr65kwcuz24q3n7waxtzyfvug5g4yuc00jydqj:{8a190d8fd0725713-e9072f0fd954196f-5f9be7adaf8d5b78-cf811ea9992983c3}".into(); + let nf_global_id: NonFungibleGlobalId = "resource_tdx_2_1ngw8z6ut9mw54am4rr65kwcuz24q3n7waxtzyfvug5g4yuc00jydqj:{8a190d8fd0725713-e9072f0fd954196f-5f9be7adaf8d5b78-cf811ea9992983c3}".parse().unwrap(); - let validator: ValidatorAddress = "validator_tdx_2_1sdlkptcwjpajqawnuya8r2mgl3eqt89hw27ww6du8kxmx3thmyu8l4".into(); + let validator: ValidatorAddress = "validator_tdx_2_1sdlkptcwjpajqawnuya8r2mgl3eqt89hw27ww6du8kxmx3thmyu8l4".parse().unwrap(); pretty_assertions::assert_eq!( sut, @@ -784,7 +784,7 @@ mod tests { acc_gk, vec![ ResourceIndicator::fungible( - "resource_tdx_2_1t5hpjckz9tm63gqvxsl60ejhzvnlguly77tltvywnj06s2x9wjdxjn", + "resource_tdx_2_1t5hpjckz9tm63gqvxsl60ejhzvnlguly77tltvywnj06s2x9wjdxjn".parse::().unwrap(), FungibleResourceIndicator::guaranteed(500) ), ] @@ -795,7 +795,7 @@ mod tests { acc_gk, vec![ ResourceIndicator::non_fungible( - "resource_tdx_2_1ngw8z6ut9mw54am4rr65kwcuz24q3n7waxtzyfvug5g4yuc00jydqj", + "resource_tdx_2_1ngw8z6ut9mw54am4rr65kwcuz24q3n7waxtzyfvug5g4yuc00jydqj".parse::().unwrap(), NonFungibleResourceIndicator::by_all( PredictedDecimal::new(0, 4), PredictedNonFungibleLocalIds::new( @@ -851,9 +851,9 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc_gk: AccountAddress = "account_tdx_2_129uv9r46an4hwng8wc97qwpraspvnrc7v2farne4lr6ff7yaevaz2a".into(); + let acc_gk: AccountAddress = "account_tdx_2_129uv9r46an4hwng8wc97qwpraspvnrc7v2farne4lr6ff7yaevaz2a".parse().unwrap(); - let validator: ValidatorAddress = "validator_tdx_2_1sdtnujyn3720ymg8lakydkvc5tw4q3zecdj95akdwt9de362mvtd94".into(); + let validator: ValidatorAddress = "validator_tdx_2_1sdtnujyn3720ymg8lakydkvc5tw4q3zecdj95akdwt9de362mvtd94".parse().unwrap(); pretty_assertions::assert_eq!( sut, @@ -863,7 +863,7 @@ mod tests { acc_gk, vec![ ResourceIndicator::non_fungible( - "resource_tdx_2_1ng3g2nj5pfpmdphgz0nrh8z0gtqcxx5z5dn48t85ar0z0zjhefufaw", + "resource_tdx_2_1ng3g2nj5pfpmdphgz0nrh8z0gtqcxx5z5dn48t85ar0z0zjhefufaw".parse::().unwrap(), NonFungibleResourceIndicator::by_ids([ NonFungibleLocalId::ruid(hex_decode("1c1ce92c810094a765659db6a666c19c6cea4367bb789b55276b137712ceecce").unwrap()).unwrap(), NonFungibleLocalId::ruid(hex_decode("5aebd0270caf3f8751031498741f57b5d24fe0d62a976589519c6a92423888cc").unwrap()).unwrap() @@ -928,9 +928,9 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc: AccountAddress = "account_tdx_2_12x2lmewv5lfen4x96aurw7a5z5ukdzyyc0fkytamqgml77lah44kkp".into(); - let fungible_address: ResourceAddress = "resource_tdx_2_1th75jg2gx9l3v0r8duzrmknfarhd3ha0387lg9n78qc9849xsfyq32".into(); - let non_fungible_address: ResourceAddress = "resource_tdx_2_1n2z4k99wuqlph9lj64ckc64znm48axl37xctsa0xqmm2sqg7klrte3".into(); + let acc: AccountAddress = "account_tdx_2_12x2lmewv5lfen4x96aurw7a5z5ukdzyyc0fkytamqgml77lah44kkp".parse().unwrap(); + let fungible_address: ResourceAddress = "resource_tdx_2_1th75jg2gx9l3v0r8duzrmknfarhd3ha0387lg9n78qc9849xsfyq32".parse().unwrap(); + let non_fungible_address: ResourceAddress = "resource_tdx_2_1n2z4k99wuqlph9lj64ckc64znm48axl37xctsa0xqmm2sqg7klrte3".parse::().unwrap(); pretty_assertions::assert_eq!( sut, @@ -953,7 +953,7 @@ mod tests { ), ] )], - vec!["account_tdx_2_12x2lmewv5lfen4x96aurw7a5z5ukdzyyc0fkytamqgml77lah44kkp".into()], // addresses_of_accounts_requiring_auth + vec!["account_tdx_2_12x2lmewv5lfen4x96aurw7a5z5ukdzyyc0fkytamqgml77lah44kkp".parse::().unwrap()], // addresses_of_accounts_requiring_auth [], // addresses_of_identities_requiring_auth [], // newly_created_non_fungibles [ReservedInstruction::AccountLockFee], // reserved_instructions @@ -986,8 +986,8 @@ mod tests { let sut = transaction_manifest.execution_summary(receipt).unwrap(); - let acc: AccountAddress = "account_tdx_2_12xy65ekdcrehj24t0ks5lvvqcvr48qgac4efq3phecp0xyetze5nyy".into(); - let badge_address: ResourceAddress = "resource_tdx_2_1nfxxxxxxxxxxaccwnrxxxxxxxxx006664022062xxxxxxxxx4vczzk".into(); + let acc = "account_tdx_2_12xy65ekdcrehj24t0ks5lvvqcvr48qgac4efq3phecp0xyetze5nyy".parse::().unwrap(); + let badge_address = "resource_tdx_2_1nfxxxxxxxxxxaccwnrxxxxxxxxx006664022062xxxxxxxxx4vczzk".parse::().unwrap(); let badge_id = NonFungibleLocalId::bytes( NonEmptyMax64Bytes::from_hex( "5189aa66cdc0f3792aab7da14fb180c30753811dc572904437ce02f3132b", diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v1/transaction_manifest/transaction_manifest.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v1/transaction_manifest/transaction_manifest.rs index cdd11424c..8b66a77b9 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v1/transaction_manifest/transaction_manifest.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v1/transaction_manifest/transaction_manifest.rs @@ -480,7 +480,7 @@ BURN_RESOURCE #[test] fn manifest_summary_multi_account_resources_transfer() { - let a = AccountAddress::from("account_sim1cyvgx33089ukm2pl97pv4max0x40ruvfy4lt60yvya744cve475w0q"); + let a = AccountAddress::from_str("account_sim1cyvgx33089ukm2pl97pv4max0x40ruvfy4lt60yvya744cve475w0q").unwrap(); let manifest = SUT::sample_other(); let summary = manifest.summary().unwrap(); @@ -491,19 +491,19 @@ BURN_RESOURCE a => vec![AccountWithdraw::sample()], ), hashmap!( - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => + AccountAddress::from_str("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 150)], UnspecifiedResources::NonePresent, ) , - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => + AccountAddress::from_str("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 50)], UnspecifiedResources::NonePresent, ) , - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => + AccountAddress::from_str("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 130)], UnspecifiedResources::NonePresent, @@ -514,9 +514,9 @@ BURN_RESOURCE a ], [ - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz"), - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr"), - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva"), + AccountAddress::from_str("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz").unwrap(), + AccountAddress::from_str("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr").unwrap(), + AccountAddress::from_str("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva").unwrap(), ], [], [a], @@ -547,6 +547,6 @@ BURN_RESOURCE ) .unwrap(); let pool_addresses = sut.involved_pool_addresses(); - assert_eq!(pool_addresses, ["pool_tdx_2_1c5mygu9t8rlfq6j8v2ynrg60ltts2dctsghust8u2tuztrml427830"].into_iter().map(PoolAddress::from).collect_vec()); + assert_eq!(pool_addresses, ["pool_tdx_2_1c5mygu9t8rlfq6j8v2ynrg60ltts2dctsghust8u2tuztrml427830"].into_iter().map(PoolAddress::from_str).map(Result::unwrap).collect_vec()); } } diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v2/transaction_manifest_v2/subintent_manifest.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v2/transaction_manifest_v2/subintent_manifest.rs index dfac6e327..cc143fe7d 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v2/transaction_manifest_v2/subintent_manifest.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v2/transaction_manifest_v2/subintent_manifest.rs @@ -523,7 +523,7 @@ DROP_AUTH_ZONE_PROOFS; #[test] fn manifest_summary_multi_account_resources_transfer() { - let a = AccountAddress::from("account_sim1cyvgx33089ukm2pl97pv4max0x40ruvfy4lt60yvya744cve475w0q"); + let a = AccountAddress::from_str("account_sim1cyvgx33089ukm2pl97pv4max0x40ruvfy4lt60yvya744cve475w0q").unwrap(); let manifest = SUT::sample_other(); let summary = manifest.summary().unwrap(); @@ -534,19 +534,19 @@ DROP_AUTH_ZONE_PROOFS; a => vec![AccountWithdraw::sample()], ), hashmap!( - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => + AccountAddress::from_str("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 150)], UnspecifiedResources::NonePresent, ) , - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => + AccountAddress::from_str("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 50)], UnspecifiedResources::NonePresent, ) , - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => + AccountAddress::from_str("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 130)], UnspecifiedResources::NonePresent, @@ -557,9 +557,9 @@ DROP_AUTH_ZONE_PROOFS; a ], [ - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz"), - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr"), - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva"), + AccountAddress::from_str("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz").unwrap(), + AccountAddress::from_str("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr").unwrap(), + AccountAddress::from_str("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva").unwrap(), ], [], [a], @@ -591,7 +591,7 @@ DROP_AUTH_ZONE_PROOFS; ) .unwrap(); let pool_addresses = sut.involved_pool_addresses(); - assert_eq!(pool_addresses, ["pool_tdx_2_1c5mygu9t8rlfq6j8v2ynrg60ltts2dctsghust8u2tuztrml427830"].into_iter().map(PoolAddress::from).collect_vec()); + assert_eq!(pool_addresses, ["pool_tdx_2_1c5mygu9t8rlfq6j8v2ynrg60ltts2dctsghust8u2tuztrml427830"].into_iter().map(PoolAddress::from_str).map(Result::unwrap).collect_vec()); } #[test] @@ -629,14 +629,14 @@ DROP_AUTH_ZONE_PROOFS; pretty_assertions::assert_eq!( summary.account_deposits, hashmap! { - AccountAddress::from("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") => + AccountAddress::from_str("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl").unwrap() => AccountDeposits::new_for_test( vec![ - SimpleResourceBounds::fungible("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc", SimpleCountedResourceBounds::unknown_amount()), - SimpleResourceBounds::fungible("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785", SimpleCountedResourceBounds::at_least(6)), - SimpleResourceBounds::fungible("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp", SimpleCountedResourceBounds::at_most(10)), - SimpleResourceBounds::fungible("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd", SimpleCountedResourceBounds::between(100, 159)), - SimpleResourceBounds::fungible("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck", SimpleCountedResourceBounds::exact(3)), + SimpleResourceBounds::fungible("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc".parse::().unwrap(), SimpleCountedResourceBounds::unknown_amount()), + SimpleResourceBounds::fungible("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785".parse::().unwrap(), SimpleCountedResourceBounds::at_least(6)), + SimpleResourceBounds::fungible("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp".parse::().unwrap(), SimpleCountedResourceBounds::at_most(10)), + SimpleResourceBounds::fungible("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd".parse::().unwrap(), SimpleCountedResourceBounds::between(100, 159)), + SimpleResourceBounds::fungible("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck".parse::().unwrap(), SimpleCountedResourceBounds::exact(3)), ], UnspecifiedResources::MayBePresent, ), @@ -666,27 +666,27 @@ DROP_AUTH_ZONE_PROOFS; pretty_assertions::assert_eq!( summary.account_deposits, hashmap!( - AccountAddress::from("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") => + AccountAddress::from_str("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl").unwrap() => AccountDeposits::new_for_test( vec![ SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue", + "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::unknown_amount())), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1n2lj0rk7pye8h2cxs347lf70ksyzwaez0mjkssccfthp6m408hfny7", + "resource_tdx_2_1n2lj0rk7pye8h2cxs347lf70ksyzwaez0mjkssccfthp6m408hfny7".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::at_least(6))), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nf8g5dhl6rxvq78j6q3kdxfkl7rweychjzyv848clhezg44rn0qgy5", + "resource_tdx_2_1nf8g5dhl6rxvq78j6q3kdxfkl7rweychjzyv848clhezg44rn0qgy5".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::at_most(10))), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nfn4gd24pcpnqegcq07mgvz9cea4zryytswn5vmgepnan7tjqedkxp", + "resource_tdx_2_1nfn4gd24pcpnqegcq07mgvz9cea4zryytswn5vmgepnan7tjqedkxp".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::between(100, 159))), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nt8pgfd7xj954403vfgkej25g8kcc56ldu4j3akl4vzlcfen6jcfjg", + "resource_tdx_2_1nt8pgfd7xj954403vfgkej25g8kcc56ldu4j3akl4vzlcfen6jcfjg".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::exact(3))), ), ], @@ -716,53 +716,54 @@ DROP_AUTH_ZONE_PROOFS; let summary = manifest.summary().unwrap(); let certain_ids_sample = vec![ - NonFungibleLocalId::from("#0#"), - NonFungibleLocalId::from("#1#"), - NonFungibleLocalId::from("#2#"), + NonFungibleLocalId::from_str("#0#").unwrap(), + NonFungibleLocalId::from_str("#1#").unwrap(), + NonFungibleLocalId::from_str("#2#").unwrap(), ]; - let member_card_id = NonFungibleLocalId::from(""); + let member_card_id = + NonFungibleLocalId::from_str("").unwrap(); pretty_assertions::assert_eq!( summary.account_deposits, hashmap!( - AccountAddress::from("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") => + AccountAddress::from_str("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl").unwrap() => AccountDeposits::new_for_test( vec![ SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue", + "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(vec![member_card_id], Some(SimpleCountedResourceBounds::unknown_amount())), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1n2lj0rk7pye8h2cxs347lf70ksyzwaez0mjkssccfthp6m408hfny7", + "resource_tdx_2_1n2lj0rk7pye8h2cxs347lf70ksyzwaez0mjkssccfthp6m408hfny7".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::unknown_amount())), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nf8g5dhl6rxvq78j6q3kdxfkl7rweychjzyv848clhezg44rn0qgy5", + "resource_tdx_2_1nf8g5dhl6rxvq78j6q3kdxfkl7rweychjzyv848clhezg44rn0qgy5".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), None), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nfn4gd24pcpnqegcq07mgvz9cea4zryytswn5vmgepnan7tjqedkxp", + "resource_tdx_2_1nfn4gd24pcpnqegcq07mgvz9cea4zryytswn5vmgepnan7tjqedkxp".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::at_most(2))), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nt8pgfd7xj954403vfgkej25g8kcc56ldu4j3akl4vzlcfen6jcfjg", + "resource_tdx_2_1nt8pgfd7xj954403vfgkej25g8kcc56ldu4j3akl4vzlcfen6jcfjg".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), None), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1n2q3kj4sfa6sh45kvau2f08hfhjuls7zcevwl77vjzmgf3sea0uzzu", + "resource_tdx_2_1n2q3kj4sfa6sh45kvau2f08hfhjuls7zcevwl77vjzmgf3sea0uzzu".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::at_most(2))), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1n2rpk9w8d8kzu578jxvqr0dplctfh5clylmyqpu9kvnz7hvceh2mxe", + "resource_tdx_2_1n2rpk9w8d8kzu578jxvqr0dplctfh5clylmyqpu9kvnz7hvceh2mxe".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::at_least(2))), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1ngu8tgxvv26rpmdwxxfd8gclnsnjeew7zdcw2p3genru58a7wkmue4", + "resource_tdx_2_1ngu8tgxvv26rpmdwxxfd8gclnsnjeew7zdcw2p3genru58a7wkmue4".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::exact(2))), ), SimpleResourceBounds::non_fungible( - "resource_tdx_2_1nfve52p2wvx0kp0eq3xaznuvwakcu5a6aqtsjqq8x30zk4wkglxmlv", + "resource_tdx_2_1nfve52p2wvx0kp0eq3xaznuvwakcu5a6aqtsjqq8x30zk4wkglxmlv".parse::().unwrap(), SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::between(2, 5))), ), ], @@ -794,30 +795,30 @@ DROP_AUTH_ZONE_PROOFS; pretty_assertions::assert_eq!( summary.account_deposits, hashmap!( - AccountAddress::from("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") => + AccountAddress::from_str("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl").unwrap() => AccountDeposits::new_for_test( vec![ - SimpleResourceBounds::fungible("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc", SimpleCountedResourceBounds::unknown_amount()), - SimpleResourceBounds::fungible("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785", SimpleCountedResourceBounds::at_least(6)), - SimpleResourceBounds::fungible("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp", SimpleCountedResourceBounds::at_most(10)), - SimpleResourceBounds::fungible("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd", SimpleCountedResourceBounds::between(100, 159)), - SimpleResourceBounds::fungible("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck", SimpleCountedResourceBounds::exact(3)), - - SimpleResourceBounds::fungible("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc", SimpleCountedResourceBounds::unknown_amount()), - SimpleResourceBounds::fungible("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785", SimpleCountedResourceBounds::at_least(6)), - SimpleResourceBounds::fungible("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp", SimpleCountedResourceBounds::at_most(10)), - SimpleResourceBounds::fungible("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd", SimpleCountedResourceBounds::between(100, 159)), - SimpleResourceBounds::fungible("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck", SimpleCountedResourceBounds::exact(3)), + SimpleResourceBounds::fungible("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc".parse::().unwrap(), SimpleCountedResourceBounds::unknown_amount()), + SimpleResourceBounds::fungible("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785".parse::().unwrap(), SimpleCountedResourceBounds::at_least(6)), + SimpleResourceBounds::fungible("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp".parse::().unwrap(), SimpleCountedResourceBounds::at_most(10)), + SimpleResourceBounds::fungible("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd".parse::().unwrap(), SimpleCountedResourceBounds::between(100, 159)), + SimpleResourceBounds::fungible("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck".parse::().unwrap(), SimpleCountedResourceBounds::exact(3)), + + SimpleResourceBounds::fungible("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc".parse::().unwrap(), SimpleCountedResourceBounds::unknown_amount()), + SimpleResourceBounds::fungible("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785".parse::().unwrap(), SimpleCountedResourceBounds::at_least(6)), + SimpleResourceBounds::fungible("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp".parse::().unwrap(), SimpleCountedResourceBounds::at_most(10)), + SimpleResourceBounds::fungible("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd".parse::().unwrap(), SimpleCountedResourceBounds::between(100, 159)), + SimpleResourceBounds::fungible("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck".parse::().unwrap(), SimpleCountedResourceBounds::exact(3)), ], UnspecifiedResources::MayBePresent, ), - AccountAddress::from("account_tdx_2_1288u4aka2dm8787texaeta8ruzhcr7dyckmnck5wt0llrm6x0ak7e4") => AccountDeposits::new_for_test( + AccountAddress::from_str("account_tdx_2_1288u4aka2dm8787texaeta8ruzhcr7dyckmnck5wt0llrm6x0ak7e4").unwrap() => AccountDeposits::new_for_test( vec![ - SimpleResourceBounds::fungible("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc", SimpleCountedResourceBounds::unknown_amount()), - SimpleResourceBounds::fungible("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785", SimpleCountedResourceBounds::at_least(6)), - SimpleResourceBounds::fungible("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp", SimpleCountedResourceBounds::at_most(10)), - SimpleResourceBounds::fungible("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd", SimpleCountedResourceBounds::between(100, 159)), - SimpleResourceBounds::fungible("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck", SimpleCountedResourceBounds::exact(3)), + SimpleResourceBounds::fungible("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc".parse::().unwrap(), SimpleCountedResourceBounds::unknown_amount()), + SimpleResourceBounds::fungible("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785".parse::().unwrap(), SimpleCountedResourceBounds::at_least(6)), + SimpleResourceBounds::fungible("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp".parse::().unwrap(), SimpleCountedResourceBounds::at_most(10)), + SimpleResourceBounds::fungible("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd".parse::().unwrap(), SimpleCountedResourceBounds::between(100, 159)), + SimpleResourceBounds::fungible("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck".parse::().unwrap(), SimpleCountedResourceBounds::exact(3)), ], UnspecifiedResources::NonePresent, ), diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v2/transaction_manifest_v2/transaction_manifest_v2.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v2/transaction_manifest_v2/transaction_manifest_v2.rs index ce1d36a10..08ec33355 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v2/transaction_manifest_v2/transaction_manifest_v2.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/v2/transaction_manifest_v2/transaction_manifest_v2.rs @@ -476,7 +476,7 @@ DROP_AUTH_ZONE_PROOFS; #[test] fn manifest_summary_multi_account_resources_transfer() { - let a = AccountAddress::from("account_sim1cyvgx33089ukm2pl97pv4max0x40ruvfy4lt60yvya744cve475w0q"); + let a = AccountAddress::from_str("account_sim1cyvgx33089ukm2pl97pv4max0x40ruvfy4lt60yvya744cve475w0q").unwrap(); let manifest = SUT::sample_other(); let summary = manifest.summary().unwrap(); @@ -487,19 +487,19 @@ DROP_AUTH_ZONE_PROOFS; a => vec![AccountWithdraw::sample()], ), hashmap!( - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => + AccountAddress::from_str("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 150)], UnspecifiedResources::NonePresent, ) , - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => + AccountAddress::from_str("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 50)], UnspecifiedResources::NonePresent, ) , - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => + AccountAddress::from_str("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr").unwrap() => AccountDeposits::new_for_test( vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 130)], UnspecifiedResources::NonePresent, @@ -510,9 +510,9 @@ DROP_AUTH_ZONE_PROOFS; a ], [ - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz"), - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr"), - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva"), + AccountAddress::from_str("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz").unwrap(), + AccountAddress::from_str("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr").unwrap(), + AccountAddress::from_str("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva").unwrap(), ], [], [a], @@ -544,7 +544,7 @@ DROP_AUTH_ZONE_PROOFS; ) .unwrap(); let pool_addresses = sut.involved_pool_addresses(); - assert_eq!(pool_addresses, ["pool_tdx_2_1c5mygu9t8rlfq6j8v2ynrg60ltts2dctsghust8u2tuztrml427830"].into_iter().map(PoolAddress::from).collect_vec()); + assert_eq!(pool_addresses, ["pool_tdx_2_1c5mygu9t8rlfq6j8v2ynrg60ltts2dctsghust8u2tuztrml427830"].into_iter().map(PoolAddress::from_str).map(Result::unwrap).collect_vec()); } #[test]