diff --git a/Cargo.lock b/Cargo.lock index b1e412877..feca98a60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2737,7 +2737,7 @@ dependencies = [ [[package]] name = "sargon" -version = "1.1.43" +version = "1.1.44" dependencies = [ "actix-rt", "aes-gcm", @@ -2791,7 +2791,7 @@ dependencies = [ [[package]] name = "sargon-uniffi" -version = "1.1.43" +version = "1.1.44" dependencies = [ "actix-rt", "assert-json-diff", diff --git a/_typos.toml b/_typos.toml index f87d783d4..d9d4336ec 100644 --- a/_typos.toml +++ b/_typos.toml @@ -17,6 +17,7 @@ resource_tdx_2_1thw7yclz24h5xjp3086cj8z2ya0d7p9mydk0yh68c28ha02uhzrnyy = "resour resource_tdx_2_1ntuaekqexa73m9en04jj3vdt3fk9u9kdk8q9su4efldun2y7nd3cga = "resource_tdx_2_1ntuaekqexa73m9en04jj3vdt3fk9u9kdk8q9su4efldun2y7nd3cga" package_tdx_2_1p4lftg7zjtmvyw5dwv3fg9cxyumlrya03p5uecqdge9thje4nm5qtk = "package_tdx_2_1p4lftg7zjtmvyw5dwv3fg9cxyumlrya03p5uecqdge9thje4nm5qtk" account_tdx_2_12yf9gd53yfep7a669fv2t3wm7nz9zeezwd04n02a433ker8vza6rhe = "account_tdx_2_12yf9gd53yfep7a669fv2t3wm7nz9zeezwd04n02a433ker8vza6rhe" +resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785 = "resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785" ec4892a8ba3b86f1 = "ec4892a8ba3b86f1" f87611f279e0daa3 = "f87611f279e0daa3" fo = "fo" diff --git a/crates/sargon-uniffi/Cargo.toml b/crates/sargon-uniffi/Cargo.toml index 37e20d6b6..4e1e96482 100644 --- a/crates/sargon-uniffi/Cargo.toml +++ b/crates/sargon-uniffi/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sargon-uniffi" # Don't forget to update version in crates/sargon/Cargo.toml -version = "1.1.43" +version = "1.1.44" edition = "2021" build = "build.rs" diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposit.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposit.rs index dae3f4d94..cdd52e038 100644 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposit.rs +++ b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposit.rs @@ -1,9 +1,9 @@ use crate::prelude::*; -use sargon::AccountDeposit as InternalAccountDeposit; +use sargon::AccountDeposits as InternalAccountDeposits; /// Represents an account deposit, which includes specified and unspecified resources. #[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Record)] -pub struct AccountDeposit { - specified_resources: HashMap, +pub struct AccountDeposits { + specified_resources: Vec, unspecified_resources: UnspecifiedResources, } diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/allowed_ids.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/allowed_ids.rs deleted file mode 100644 index 6c376fde2..000000000 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/allowed_ids.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::prelude::*; -use sargon::AllowedIds as InternalAllowedIds; - -/// Represents which ids are possible in a non-fungible balance. -/// -/// `Any` represents that any id is possible. `Allowlist` represents that -/// any ids in the balance have to be in the allowlist. -#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Enum)] -pub enum AllowedIds { - Allowlist { ids: Vec }, - Any, -} diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/lower_bound.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/lower_bound.rs deleted file mode 100644 index 7139a8391..000000000 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/lower_bound.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::prelude::*; -use sargon::LowerBound as InternalLowerBound; - -/// Represents a lower bound on a non-negative decimal. -#[derive(Clone, Debug, PartialEq, Eq, InternalConversion, uniffi::Enum)] -pub enum LowerBound { - /// Represents a lower bound of an infinitesimal amount above 0, and is included for - /// clarity of intention. Considering Decimal has a limited precision of 10^(-18), it is roughly - /// equivalent to an inclusive bound of 10^(-18), or Decimal::from_attos(1). - NonZero, - - /// The amount is required to be non-negative before using this model. - /// This can be validated via [`ManifestResourceConstraint::is_valid_for`]. - Inclusive { decimal: Decimal }, -} diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/mod.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/mod.rs index 4e6bd5857..1d4e720f5 100644 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/mod.rs +++ b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/mod.rs @@ -1,19 +1,13 @@ mod account_deposit; -mod allowed_ids; mod change_source; -mod lower_bound; mod simple_fungible_resource_bounds; mod simple_non_fungible_resource_bounds; mod simple_resource_bounds; mod unspecified_resources; -mod upper_bound; pub use account_deposit::*; -pub use allowed_ids::*; pub use change_source::*; -pub use lower_bound::*; pub use simple_fungible_resource_bounds::*; pub use simple_non_fungible_resource_bounds::*; pub use simple_resource_bounds::*; pub use unspecified_resources::*; -pub use upper_bound::*; diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_fungible_resource_bounds.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_fungible_resource_bounds.rs index 1ce3c2af2..53ec1a0d3 100644 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_fungible_resource_bounds.rs +++ b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_fungible_resource_bounds.rs @@ -1,10 +1,10 @@ use crate::prelude::*; -use sargon::SimpleFungibleResourceBounds as InternalSimpleFungibleResourceBounds; +use sargon::SimpleCountedResourceBounds as InternalSimpleCountedResourceBounds; /// Represents the bounds for a simple fungible resource, which can /// be exact, at most, at least, between, or unknown amount. #[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Enum)] -pub enum SimpleFungibleResourceBounds { +pub enum SimpleCountedResourceBounds { Exact { amount: Decimal, }, diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_non_fungible_resource_bounds.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_non_fungible_resource_bounds.rs index 871b6a179..cf313eb42 100644 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_non_fungible_resource_bounds.rs +++ b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_non_fungible_resource_bounds.rs @@ -2,16 +2,8 @@ use crate::prelude::*; use sargon::SimpleNonFungibleResourceBounds as InternalSimpleNonFungibleResourceBounds; /// Represents the bounds for a simple non-fungible resource, which can be either exact or not exact. -#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Enum)] -pub enum SimpleNonFungibleResourceBounds { - Exact { - amount: Decimal, - certain_ids: Vec, - }, - NotExact { - certain_ids: Vec, - lower_bound: LowerBound, - upper_bound: UpperBound, - allowed_ids: AllowedIds, - }, +#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Record)] +pub struct SimpleNonFungibleResourceBounds { + pub certain_ids: Vec, + pub additional_amount: Option, } diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_resource_bounds.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_resource_bounds.rs index 84481d8c1..4e4c4d363 100644 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_resource_bounds.rs +++ b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_resource_bounds.rs @@ -5,9 +5,11 @@ use sargon::SimpleResourceBounds as InternalSimpleResourceBounds; #[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Enum)] pub enum SimpleResourceBounds { Fungible { - bounds: SimpleFungibleResourceBounds, + resource_address: ResourceAddress, + bounds: SimpleCountedResourceBounds, }, NonFungible { + resource_address: ResourceAddress, bounds: SimpleNonFungibleResourceBounds, }, } diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/unspecified_resources.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/unspecified_resources.rs index 73ff1f967..ac635d6e6 100644 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/unspecified_resources.rs +++ b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/unspecified_resources.rs @@ -9,5 +9,5 @@ pub enum UnspecifiedResources { NonePresent, /// There might be non-zero balances of unspecified resources present - MayBePresent { change_sources: Vec }, + MayBePresent, } diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/upper_bound.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/upper_bound.rs deleted file mode 100644 index 7c060e519..000000000 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/upper_bound.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::prelude::*; -use sargon::UpperBound as InternalUpperBound; - -/// Represents an upper bound on a non-negative decimal. -#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Enum)] -pub enum UpperBound { - /// The amount is required to be non-negative before using this model. - /// This can be validated via [`ManifestResourceConstraint::is_valid_for`]. - Inclusive { decimal: Decimal }, - - /// `Unbounded` represents an upper bound above any possible decimal, and is included for - /// clarity of intention. Considering Decimal has a max size, it is effectively equivalent to - /// an inclusive bound of [`Decimal::max()`]. - Unbounded, -} diff --git a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/manifest_summary.rs b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/manifest_summary.rs index 5a224b7c5..8c09665e0 100644 --- a/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/manifest_summary.rs +++ b/crates/sargon-uniffi/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/manifest_summary.rs @@ -8,7 +8,7 @@ pub struct ManifestSummary { pub account_withdrawals: HashMap>, /// The deposits done in the manifest. - pub account_deposits: HashMap>, + pub account_deposits: HashMap, /// The list of the resources of proofs that were presented in the manifest. pub presented_proofs: Vec, diff --git a/crates/sargon/Cargo.toml b/crates/sargon/Cargo.toml index ad8b97f2f..3fbe4cc89 100644 --- a/crates/sargon/Cargo.toml +++ b/crates/sargon/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sargon" # Don't forget to update version in crates/sargon-uniffi/Cargo.toml -version = "1.1.43" +version = "1.1.44" edition = "2021" build = "build.rs" diff --git a/crates/sargon/fixtures/transaction/mint_nft_gumball_card.rtm b/crates/sargon/fixtures/transaction/mint_nft_gumball_card.rtm index a6a5d8742..246d2bfd3 100644 --- a/crates/sargon/fixtures/transaction/mint_nft_gumball_card.rtm +++ b/crates/sargon/fixtures/transaction/mint_nft_gumball_card.rtm @@ -28,4 +28,4 @@ CALL_METHOD Address("account_tdx_2_129qq7m9ttup2kn6t4g4s0dvazxplktj7vd7my76hfd7xh7ham5zeac") "deposit" Bucket("bucket2") -; +; \ No newline at end of file diff --git a/crates/sargon/fixtures/transaction/open_subintent_fungibles.rtm b/crates/sargon/fixtures/transaction/open_subintent_fungibles.rtm new file mode 100644 index 000000000..0afc818b0 --- /dev/null +++ b/crates/sargon/fixtures/transaction/open_subintent_fungibles.rtm @@ -0,0 +1,52 @@ +ASSERT_WORKTOP_RESOURCES_INCLUDE + Map( + Address("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc") => Enum( + Tuple( + Array(), + Enum(), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785") => Enum( + Tuple( + Array(), + Enum(Decimal("6")), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp") => Enum( + Tuple( + Array(), + Enum(), + Enum(Decimal("10")), + Enum() + ) + ), + Address("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd") => Enum( + Tuple( + Array(), + Enum(Decimal("100")), + Enum(Decimal("159")), + Enum() + ) + ), + Address("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck") => Enum( + Tuple( + Array(), + Enum(Decimal("3")), + Enum(Decimal("3")), + Enum() + ) + ), + ) +; + +CALL_METHOD + Address("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") + "deposit_batch" + Expression("ENTIRE_WORKTOP") +; + +YIELD_TO_PARENT; \ No newline at end of file diff --git a/crates/sargon/fixtures/transaction/open_subintent_mix_multiple_deposits.rtm b/crates/sargon/fixtures/transaction/open_subintent_mix_multiple_deposits.rtm new file mode 100644 index 000000000..9f4c43db6 --- /dev/null +++ b/crates/sargon/fixtures/transaction/open_subintent_mix_multiple_deposits.rtm @@ -0,0 +1,160 @@ +ASSERT_WORKTOP_RESOURCES_INCLUDE + Map( + Address("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc") => Enum( + Tuple( + Array(), + Enum(), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785") => Enum( + Tuple( + Array(), + Enum(Decimal("6")), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp") => Enum( + Tuple( + Array(), + Enum(), + Enum(Decimal("10")), + Enum() + ) + ), + Address("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd") => Enum( + Tuple( + Array(), + Enum(Decimal("100")), + Enum(Decimal("159")), + Enum() + ) + ), + Address("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck") => Enum( + Tuple( + Array(), + Enum(Decimal("3")), + Enum(Decimal("3")), + Enum() + ) + ), + ) +; + +CALL_METHOD + Address("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") + "deposit_batch" + Expression("ENTIRE_WORKTOP") +; + +YIELD_TO_PARENT; + +ASSERT_WORKTOP_RESOURCES_ONLY + Map( + Address("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc") => Enum( + Tuple( + Array(), + Enum(), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785") => Enum( + Tuple( + Array(), + Enum(Decimal("6")), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp") => Enum( + Tuple( + Array(), + Enum(), + Enum(Decimal("10")), + Enum() + ) + ), + Address("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd") => Enum( + Tuple( + Array(), + Enum(Decimal("100")), + Enum(Decimal("159")), + Enum() + ) + ), + Address("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck") => Enum( + Tuple( + Array(), + Enum(Decimal("3")), + Enum(Decimal("3")), + Enum() + ) + ), + ) +; + +CALL_METHOD + Address("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") + "deposit_batch" + Expression("ENTIRE_WORKTOP") +; + + +YIELD_TO_PARENT; + +ASSERT_WORKTOP_RESOURCES_ONLY + Map( + Address("resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc") => Enum( + Tuple( + Array(), + Enum(), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1th4gzm9rk5s28yf5gud0a32m082g4x60d6na4ecsccte032y3xu785") => Enum( + Tuple( + Array(), + Enum(Decimal("6")), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1tkd957yt3rwqze7elmzlphfjnmfyzkf9l5rau5ccsx9h2vs9nq3tzp") => Enum( + Tuple( + Array(), + Enum(), + Enum(Decimal("10")), + Enum() + ) + ), + Address("resource_tdx_2_1t5jcmwqx39ym7fw0hrlpnxwechr0mzlgulcfcye59qm9y9fa5uvdrd") => Enum( + Tuple( + Array(), + Enum(Decimal("100")), + Enum(Decimal("159")), + Enum() + ) + ), + Address("resource_tdx_2_1t5dapa24l4xvwqtqe2jrdphtn7ga46gw67wr9fwn4gp532myfjqpck") => Enum( + Tuple( + Array(), + Enum(Decimal("3")), + Enum(Decimal("3")), + Enum() + ) + ), + ) +; + +CALL_METHOD + Address("account_tdx_2_1288u4aka2dm8787texaeta8ruzhcr7dyckmnck5wt0llrm6x0ak7e4") + "deposit_batch" + Expression("ENTIRE_WORKTOP") +; + + +YIELD_TO_PARENT; \ No newline at end of file diff --git a/crates/sargon/fixtures/transaction/open_subintent_non_fungibles_no_certain_ids.rtm b/crates/sargon/fixtures/transaction/open_subintent_non_fungibles_no_certain_ids.rtm new file mode 100644 index 000000000..17c88ac24 --- /dev/null +++ b/crates/sargon/fixtures/transaction/open_subintent_non_fungibles_no_certain_ids.rtm @@ -0,0 +1,52 @@ +ASSERT_WORKTOP_RESOURCES_INCLUDE + Map( + Address("resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue") => Enum( + Tuple( + Array(), + Enum(), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1n2lj0rk7pye8h2cxs347lf70ksyzwaez0mjkssccfthp6m408hfny7") => Enum( + Tuple( + Array(), + Enum(Decimal("6")), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1nf8g5dhl6rxvq78j6q3kdxfkl7rweychjzyv848clhezg44rn0qgy5") => Enum( + Tuple( + Array(), + Enum(), + Enum(Decimal("10")), + Enum() + ) + ), + Address("resource_tdx_2_1nfn4gd24pcpnqegcq07mgvz9cea4zryytswn5vmgepnan7tjqedkxp") => Enum( + Tuple( + Array(), + Enum(Decimal("100")), + Enum(Decimal("159")), + Enum() + ) + ), + Address("resource_tdx_2_1nt8pgfd7xj954403vfgkej25g8kcc56ldu4j3akl4vzlcfen6jcfjg") => Enum( + Tuple( + Array(), + Enum(Decimal("3")), + Enum(Decimal("3")), + Enum() + ) + ), + ) +; + +CALL_METHOD + Address("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") + "deposit_batch" + Expression("ENTIRE_WORKTOP") +; + +YIELD_TO_PARENT; \ No newline at end of file diff --git a/crates/sargon/fixtures/transaction/open_subintent_non_fungibles_with_certain_ids.rtm b/crates/sargon/fixtures/transaction/open_subintent_non_fungibles_with_certain_ids.rtm new file mode 100644 index 000000000..88542d820 --- /dev/null +++ b/crates/sargon/fixtures/transaction/open_subintent_non_fungibles_with_certain_ids.rtm @@ -0,0 +1,119 @@ +ASSERT_WORKTOP_RESOURCES_INCLUDE + Map( + Address("resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue") => Enum( + Tuple( + Array( + NonFungibleLocalId("") + ), + Enum(), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1n2lj0rk7pye8h2cxs347lf70ksyzwaez0mjkssccfthp6m408hfny7") => Enum( + Tuple( + Array( + NonFungibleLocalId("#0#"), + NonFungibleLocalId("#1#"), + NonFungibleLocalId("#2#") + ), + Enum(Decimal("3")), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1nf8g5dhl6rxvq78j6q3kdxfkl7rweychjzyv848clhezg44rn0qgy5") => Enum( + Tuple( + Array( + NonFungibleLocalId("#0#"), + NonFungibleLocalId("#1#"), + NonFungibleLocalId("#2#"), + ), + Enum(Decimal("3")), + Enum(Decimal("3")), + Enum() + ) + ), + Address("resource_tdx_2_1nfn4gd24pcpnqegcq07mgvz9cea4zryytswn5vmgepnan7tjqedkxp") => Enum( + Tuple( + Array( + NonFungibleLocalId("#0#"), + NonFungibleLocalId("#1#"), + NonFungibleLocalId("#2#"), + ), + Enum(Decimal("3")), + Enum(Decimal("5")), + Enum() + ) + ), + Address("resource_tdx_2_1nt8pgfd7xj954403vfgkej25g8kcc56ldu4j3akl4vzlcfen6jcfjg") => Enum( + Tuple( + Array( + NonFungibleLocalId("#0#"), + NonFungibleLocalId("#1#"), + NonFungibleLocalId("#2#"), + ), + Enum(), + Enum(Decimal("3")), + Enum() + ) + ), + + Address("resource_tdx_2_1n2q3kj4sfa6sh45kvau2f08hfhjuls7zcevwl77vjzmgf3sea0uzzu") => Enum( + Tuple( + Array( + NonFungibleLocalId("#0#"), + NonFungibleLocalId("#1#"), + NonFungibleLocalId("#2#"), + ), + Enum(), + Enum(Decimal("5")), + Enum() + ) + ), + Address("resource_tdx_2_1n2rpk9w8d8kzu578jxvqr0dplctfh5clylmyqpu9kvnz7hvceh2mxe") => Enum( + Tuple( + Array( + NonFungibleLocalId("#0#"), + NonFungibleLocalId("#1#"), + NonFungibleLocalId("#2#"), + ), + Enum(Decimal("5")), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1ngu8tgxvv26rpmdwxxfd8gclnsnjeew7zdcw2p3genru58a7wkmue4") => Enum( + Tuple( + Array( + NonFungibleLocalId("#0#"), + NonFungibleLocalId("#1#"), + NonFungibleLocalId("#2#"), + ), + Enum(Decimal("5")), + Enum(Decimal("5")), + Enum() + ) + ), + Address("resource_tdx_2_1nfve52p2wvx0kp0eq3xaznuvwakcu5a6aqtsjqq8x30zk4wkglxmlv") => Enum( + Tuple( + Array( + NonFungibleLocalId("#0#"), + NonFungibleLocalId("#1#"), + NonFungibleLocalId("#2#"), + ), + Enum(Decimal("5")), + Enum(Decimal("8")), + Enum() + ) + ), + ) +; + +CALL_METHOD + Address("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") + "deposit_batch" + Expression("ENTIRE_WORKTOP") +; + +YIELD_TO_PARENT; \ No newline at end of file diff --git a/crates/sargon/fixtures/transaction/open_subintent_pool_stakes_stake_claim.rtm b/crates/sargon/fixtures/transaction/open_subintent_pool_stakes_stake_claim.rtm new file mode 100644 index 000000000..a12dc8b25 --- /dev/null +++ b/crates/sargon/fixtures/transaction/open_subintent_pool_stakes_stake_claim.rtm @@ -0,0 +1,48 @@ +ASSERT_WORKTOP_RESOURCES_INCLUDE + Map( + Address("resource_tdx_2_1t5f8cwz2maeskwhz7vx4k45pv5aehn48du3cccs8mejtvfyny5t3qu") => Enum( + Tuple( + Array(), + Enum(), + Enum(), + Enum() + ) + ), + Address("resource_tdx_2_1t47y7qd020rhdlyp36yc9hurckxg303l2wezqwzzqz6qtvspekppag") => Enum( + Tuple( + Array(), + Enum(Decimal("100")), + Enum(Decimal("159")), + Enum() + ) + ), + Address("resource_tdx_2_1thjlp88pc28eyfg3f2alq8zkggnr273j0saye4nj70vfnga6ldy7ru") => Enum( + Tuple( + Array(), + Enum(), + Enum(Decimal("3")), + Enum() + ) + ), + Address("resource_tdx_2_1nf2eptx9ajuxkgr6g6aagxrvcuh480hca8kwrc2684xp3y44s5askz") => Enum( + Tuple( + Array( + NonFungibleLocalId("{0fe8993beda6012c-ff636a32ebc7087a-01416163a61ab103-c2760cef588c3fe5}"), + NonFungibleLocalId("{13f78cfd81d9a96f-de4a5c44ea715ed0-d0d6e39185707030-d6fd887ca7b9b7d4}"), + NonFungibleLocalId("{44e3cad7d68859f1-575b1c0e4cefdd9b-f4357e7aa9a2ce61-643aa7dd9f02bacc}"), + ), + Enum(Decimal("3")), + Enum(Decimal("3")), + Enum() + ) + ), + ) +; + +CALL_METHOD + Address("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") + "deposit_batch" + Expression("ENTIRE_WORKTOP") +; + +YIELD_TO_PARENT; \ No newline at end of file diff --git a/crates/sargon/src/gateway_api/models/logic/request/transaction/preview/transaction_preview.rs b/crates/sargon/src/gateway_api/models/logic/request/transaction/preview/transaction_preview.rs index 840ab3993..d3076166e 100644 --- a/crates/sargon/src/gateway_api/models/logic/request/transaction/preview/transaction_preview.rs +++ b/crates/sargon/src/gateway_api/models/logic/request/transaction/preview/transaction_preview.rs @@ -32,7 +32,7 @@ impl TransactionPreviewRequest { notary_is_signatory: signer_public_keys.is_empty(), tip_percentage: 0, nonce: nonce.into(), - signer_public_keys: signer_public_keys, + signer_public_keys, flags: TransactionPreviewRequestFlags::default(), opt_ins: TransactionPreviewRequestOptIns::default(), } @@ -83,7 +83,7 @@ mod tests { .map(|b| b.to_string()) .collect_vec() ); - assert_eq!(sut.notary_is_signatory, false); + assert!(!sut.notary_is_signatory); assert_eq!( sut.notary_public_key.unwrap(), GWPublicKey::from(header.notary_public_key) diff --git a/crates/sargon/src/system/sargon_os/transactions/sargon_os_transaction_analysis.rs b/crates/sargon/src/system/sargon_os/transactions/sargon_os_transaction_analysis.rs index 7ce8617e6..1b11b2379 100644 --- a/crates/sargon/src/system/sargon_os/transactions/sargon_os_transaction_analysis.rs +++ b/crates/sargon/src/system/sargon_os/transactions/sargon_os_transaction_analysis.rs @@ -128,7 +128,7 @@ impl SargonOS { } None => PreAuthToReview::Open(PreAuthOpenManifest { manifest: subintent_manifest, - summary: summary, + summary, }), }; diff --git a/crates/sargon/src/system/sargon_os/transactions/support/signable_manifest_summary.rs b/crates/sargon/src/system/sargon_os/transactions/support/signable_manifest_summary.rs index ff438b165..8ea9c7ea7 100644 --- a/crates/sargon/src/system/sargon_os/transactions/support/signable_manifest_summary.rs +++ b/crates/sargon/src/system/sargon_os/transactions/support/signable_manifest_summary.rs @@ -10,7 +10,7 @@ impl SignableManifestSummary { pub fn new(summary: ManifestSummary) -> Self { Self { id: Exactly32Bytes::generate(), - summary: summary, + summary, } } } @@ -35,7 +35,7 @@ impl SignableID for Exactly32Bytes {} impl From for Exactly32Bytes { fn from(val: SignableManifestSummary) -> Exactly32Bytes { - val.id.clone() + val.id } } @@ -57,7 +57,7 @@ impl Signable for SignableManifestSummary { } fn get_id(&self) -> Self::ID { - self.id.clone() + self.id } fn get_payload(&self) -> Self::Payload { diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposit.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposit.rs deleted file mode 100644 index 67f0d143e..000000000 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposit.rs +++ /dev/null @@ -1,113 +0,0 @@ -use crate::prelude::*; -use std::collections::HashMap; - -/// Represents an account deposit, which includes specified and unspecified resources. -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct AccountDeposit { - pub specified_resources: HashMap, - pub unspecified_resources: UnspecifiedResources, -} - -impl AccountDeposit { - pub fn new( - specified_resources: IndexMap, - unspecified_resources: UnspecifiedResources, - ) -> Self { - Self { - specified_resources: specified_resources.into_iter().collect(), - unspecified_resources, - } - } -} - -impl From<(ScryptoAccountDeposit, NetworkID)> for AccountDeposit { - fn from(value: (ScryptoAccountDeposit, NetworkID)) -> Self { - let (scrypto_value, network_id) = value; - let specified_resources = scrypto_value - .specified_resources() - .into_iter() - .map(|(address, bounds)| { - ( - ResourceAddress::from((*address, network_id)), - SimpleResourceBounds::from(bounds.clone()), - ) - }) - .collect(); - let unspecified_resources = - scrypto_value.unspecified_resources().into(); - Self::new(specified_resources, unspecified_resources) - } -} - -impl HasSampleValues for AccountDeposit { - fn sample() -> Self { - Self::new( - vec![(ResourceAddress::sample(), SimpleResourceBounds::sample())] - .into_iter() - .collect(), - UnspecifiedResources::sample(), - ) - } - - fn sample_other() -> Self { - Self::new( - vec![( - ResourceAddress::sample_sim_xrd(), - SimpleResourceBounds::sample(), - )] - .into_iter() - .collect(), - UnspecifiedResources::NonePresent, - ) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[allow(clippy::upper_case_acronyms)] - type SUT = AccountDeposit; - - #[test] - fn equality() { - assert_eq!(SUT::sample(), SUT::sample()); - assert_eq!(SUT::sample_other(), SUT::sample_other()); - } - - #[test] - fn inequality() { - assert_ne!(SUT::sample(), SUT::sample_other()); - } - - #[test] - fn new_account_deposit() { - let specified_resources: IndexMap< - ResourceAddress, - SimpleResourceBounds, - > = vec![ - (ResourceAddress::sample(), SimpleResourceBounds::sample()), - ( - ResourceAddress::sample_other(), - SimpleResourceBounds::sample_other(), - ), - ] - .into_iter() - .collect(); - let unspecified_resources = UnspecifiedResources::sample(); - - let account_deposit = AccountDeposit::new( - specified_resources.clone(), - unspecified_resources.clone(), - ); - - assert_eq!( - account_deposit.specified_resources, - specified_resources.into_iter().collect() - ); - assert_eq!( - account_deposit.unspecified_resources, - unspecified_resources - ); - } -} diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposits.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposits.rs new file mode 100644 index 000000000..bdb657b59 --- /dev/null +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/account_deposits.rs @@ -0,0 +1,93 @@ +use crate::prelude::*; +use std::collections::HashMap; + +/// Represents an account deposit, which includes specified and unspecified resources. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct AccountDeposits { + pub specified_resources: Vec, + pub unspecified_resources: UnspecifiedResources, +} + +impl AccountDeposits { + fn new( + specified_resources: Vec, + unspecified_resources: UnspecifiedResources, + ) -> Self { + Self { + specified_resources, + unspecified_resources, + } + } +} + +#[cfg(test)] +impl AccountDeposits { + pub fn new_for_test( + specified_resources: Vec, + unspecified_resources: UnspecifiedResources, + ) -> Self { + Self::new(specified_resources, unspecified_resources) + } +} + +impl From<(Vec, NetworkID)> for AccountDeposits { + fn from(value: (Vec, NetworkID)) -> Self { + let (deposits, network_id) = value; + // flatten the specified resources into a vec + let specified_resources = deposits + .iter() + .flat_map(|deposit| { + deposit.specified_resources().into_iter().map( + |(address, bounds)| { + SimpleResourceBounds::from(( + (*address, network_id).into(), + bounds.clone(), + )) + }, + ) + }) + .collect(); + + // fold the unspecified resources into a single value. + let unspecified_resources = deposits + .iter() + .map(|deposit| deposit.unspecified_resources()) + .fold(ScryptoUnspecifiedResources::NonePresent, |acc, next| { + acc.add(next) + }); + + Self::new(specified_resources, unspecified_resources.into()) + } +} + +impl HasSampleValues for AccountDeposits { + fn sample() -> Self { + Self::new(Vec::<_>::sample(), UnspecifiedResources::sample()) + } + + fn sample_other() -> Self { + Self::new( + Vec::<_>::sample_other(), + UnspecifiedResources::sample_other(), + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::upper_case_acronyms)] + type SUT = AccountDeposits; + + #[test] + fn equality() { + assert_eq!(SUT::sample(), SUT::sample()); + assert_eq!(SUT::sample_other(), SUT::sample_other()); + } + + #[test] + fn inequality() { + assert_ne!(SUT::sample(), SUT::sample_other()); + } +} diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/allowed_ids.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/allowed_ids.rs deleted file mode 100644 index c9a7b0ec8..000000000 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/allowed_ids.rs +++ /dev/null @@ -1,109 +0,0 @@ -use crate::prelude::*; - -/// Represents which ids are possible in a non-fungible balance. -/// -/// `Any` represents that any id is possible. `Allowlist` represents that -/// any ids in the balance have to be in the allowlist. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum AllowedIds { - Allowlist { ids: Vec }, - Any, -} - -impl AllowedIds { - pub fn allowlist( - ids: impl IntoIterator, - ) -> Self { - Self::Allowlist { - ids: ids.into_iter().collect(), - } - } - - pub fn any() -> Self { - Self::Any - } - - pub fn ids(&self) -> IndexSet { - match self { - AllowedIds::Allowlist { ids } => ids.clone().into_iter().collect(), - AllowedIds::Any => IndexSet::new(), - } - } -} - -impl From for AllowedIds { - fn from(value: ScryptoAllowedIds) -> Self { - match value { - ScryptoAllowedIds::Allowlist(ids) => Self::Allowlist { - ids: ids.into_iter().map(NonFungibleLocalId::from).collect(), - }, - ScryptoAllowedIds::Any => Self::Any, - } - } -} - -impl HasSampleValues for AllowedIds { - fn sample() -> Self { - Self::allowlist([ - NonFungibleLocalId::sample(), - NonFungibleLocalId::sample_other(), - ]) - } - - fn sample_other() -> Self { - Self::any() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[allow(clippy::upper_case_acronyms)] - type SUT = AllowedIds; - - #[test] - fn equality() { - assert_eq!(SUT::sample(), SUT::sample()); - assert_eq!(SUT::sample_other(), SUT::sample_other()); - } - - #[test] - fn inequality() { - assert_ne!(SUT::sample(), SUT::sample_other()); - } - - #[test] - fn get_ids() { - let ids = [ - NonFungibleLocalId::random(), - NonFungibleLocalId::random(), - NonFungibleLocalId::random(), - ] - .into_iter() - .collect::>(); - - assert_eq!(SUT::allowlist(ids.clone()).ids(), ids); - assert_eq!(SUT::any().ids(), IndexSet::new()); - } - - #[test] - fn from_scrypto_allowlist() { - let scrypto = ScryptoAllowedIds::Allowlist( - [ - NonFungibleLocalId::sample(), - NonFungibleLocalId::sample_other(), - ] - .into_iter() - .map(ScryptoNonFungibleLocalId::from) - .collect::>(), - ); - assert_eq!(SUT::from(scrypto), SUT::sample()); - } - - #[test] - fn from_scrypto_any() { - let scrypto = ScryptoAllowedIds::Any; - assert_eq!(SUT::from(scrypto), SUT::sample_other()); - } -} diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/lower_bound.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/lower_bound.rs deleted file mode 100644 index 9def2843a..000000000 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/lower_bound.rs +++ /dev/null @@ -1,116 +0,0 @@ -use crate::prelude::*; -use radix_common::prelude::ManifestResourceConstraint; - -/// Represents a lower bound on a non-negative decimal. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum LowerBound { - /// Represents a lower bound of an infinitesimal amount above 0, and is included for - /// clarity of intention. Considering Decimal has a limited precision of 10^(-18), it is roughly - /// equivalent to an inclusive bound of 10^(-18), or Decimal::from_attos(1). - NonZero, - - /// The amount is required to be non-negative before using this model. - /// This can be validated via [`ManifestResourceConstraint::is_valid_for`]. - Inclusive { decimal: Decimal }, -} - -impl LowerBound { - pub fn inclusive(decimal: impl Into) -> Self { - Self::Inclusive { - decimal: decimal.into(), - } - } - pub fn non_zero() -> Self { - Self::NonZero - } -} - -impl LowerBound { - pub fn get_amount(&self) -> Decimal { - ScryptoLowerBound::from(self.clone()) - .equivalent_decimal() - .into() - } -} - -impl From for LowerBound { - fn from(value: ScryptoLowerBound) -> Self { - match value { - ScryptoLowerBound::Inclusive(decimal) => Self::Inclusive { - decimal: decimal.into(), - }, - ScryptoLowerBound::NonZero => Self::NonZero, - } - } -} - -impl From for ScryptoLowerBound { - fn from(value: LowerBound) -> Self { - match value { - LowerBound::Inclusive { decimal } => { - ScryptoLowerBound::Inclusive(decimal.into()) - } - LowerBound::NonZero => ScryptoLowerBound::NonZero, - } - } -} - -impl HasSampleValues for LowerBound { - fn sample() -> Self { - Self::inclusive(1) - } - - fn sample_other() -> Self { - Self::non_zero() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[allow(clippy::upper_case_acronyms)] - type SUT = LowerBound; - - #[test] - fn equality() { - assert_eq!(SUT::sample(), SUT::sample()); - assert_eq!(SUT::sample_other(), SUT::sample_other()); - } - - #[test] - fn inequality() { - assert_ne!(SUT::sample(), SUT::sample_other()); - } - - #[test] - fn from_scrypto_inclusive() { - let scrypto = ScryptoLowerBound::Inclusive(1.into()); - assert_eq!(SUT::from(scrypto), SUT::sample()) - } - - #[test] - fn from_scrypto_none_zero() { - let scrypto = ScryptoLowerBound::NonZero; - assert_eq!(SUT::from(scrypto), SUT::sample_other()) - } - - #[test] - fn to_scrypto_inclusive() { - let lower_bound = LowerBound::inclusive(1); - let scrypto: ScryptoLowerBound = lower_bound.into(); - assert_eq!(scrypto, ScryptoLowerBound::Inclusive(1.into())); - } - - #[test] - fn to_scrypto_none_zero() { - let lower_bound = LowerBound::non_zero(); - let scrypto: ScryptoLowerBound = lower_bound.into(); - assert_eq!(scrypto, ScryptoLowerBound::NonZero); - } - - #[test] - fn get_amount() { - assert_eq!(SUT::sample().get_amount(), Decimal::from(1)); - } -} diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/mod.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/mod.rs index 4e6bd5857..04dd6ceee 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/mod.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/mod.rs @@ -1,19 +1,13 @@ -mod account_deposit; -mod allowed_ids; +mod account_deposits; mod change_source; -mod lower_bound; -mod simple_fungible_resource_bounds; +mod simple_counted_resource_bounds; mod simple_non_fungible_resource_bounds; mod simple_resource_bounds; mod unspecified_resources; -mod upper_bound; -pub use account_deposit::*; -pub use allowed_ids::*; +pub use account_deposits::*; pub use change_source::*; -pub use lower_bound::*; -pub use simple_fungible_resource_bounds::*; +pub use simple_counted_resource_bounds::*; pub use simple_non_fungible_resource_bounds::*; pub use simple_resource_bounds::*; pub use unspecified_resources::*; -pub use upper_bound::*; diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_fungible_resource_bounds.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_counted_resource_bounds.rs similarity index 93% rename from crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_fungible_resource_bounds.rs rename to crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_counted_resource_bounds.rs index 6ca889701..f204de961 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_fungible_resource_bounds.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_counted_resource_bounds.rs @@ -3,7 +3,7 @@ use crate::prelude::*; /// Represents the bounds for a simple fungible resource, which can /// be exact, at most, at least, between, or unknown amount. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum SimpleFungibleResourceBounds { +pub enum SimpleCountedResourceBounds { Exact { amount: Decimal, }, @@ -20,7 +20,7 @@ pub enum SimpleFungibleResourceBounds { UnknownAmount, } -impl SimpleFungibleResourceBounds { +impl SimpleCountedResourceBounds { pub fn exact(amount: impl Into) -> Self { Self::Exact { amount: amount.into(), @@ -64,9 +64,7 @@ impl SimpleFungibleResourceBounds { } } -impl From - for SimpleFungibleResourceBounds -{ +impl From for SimpleCountedResourceBounds { fn from(value: ScryptoSimpleFungibleResourceBounds) -> Self { match value { ScryptoSimpleFungibleResourceBounds::Exact(amount) => { @@ -89,7 +87,7 @@ impl From } } -impl HasSampleValues for SimpleFungibleResourceBounds { +impl HasSampleValues for SimpleCountedResourceBounds { fn sample() -> Self { Self::sample_exact() } @@ -99,7 +97,7 @@ impl HasSampleValues for SimpleFungibleResourceBounds { } } -impl SimpleFungibleResourceBounds { +impl SimpleCountedResourceBounds { fn sample_exact() -> Self { Self::exact(1337) } @@ -129,7 +127,7 @@ mod tests { use super::*; #[allow(clippy::upper_case_acronyms)] - type SUT = SimpleFungibleResourceBounds; + type SUT = SimpleCountedResourceBounds; #[test] fn equality() { diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_non_fungible_resource_bounds.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_non_fungible_resource_bounds.rs index fd9a225ee..2e510b703 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_non_fungible_resource_bounds.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_non_fungible_resource_bounds.rs @@ -1,60 +1,23 @@ +use uuid::fmt::Simple; + use crate::prelude::*; -/// Represents the bounds for a simple non-fungible resource, which can be either exact or not exact. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum SimpleNonFungibleResourceBounds { - Exact { - amount: Decimal, - certain_ids: Vec, - }, - NotExact { - certain_ids: Vec, - lower_bound: LowerBound, - upper_bound: UpperBound, - allowed_ids: AllowedIds, - }, +pub struct SimpleNonFungibleResourceBounds { + /// The IDs of the non-fungible resources that are certain to be deposited. + pub certain_ids: Vec, + /// The additional amount of non-fungible resources that may be deposited. + pub additional_amount: Option, } impl SimpleNonFungibleResourceBounds { - pub fn exact( - amount: impl Into, + pub fn new( certain_ids: impl IntoIterator, + additional_amount: Option, ) -> Self { - Self::Exact { - amount: amount.into(), - certain_ids: certain_ids.into_iter().collect(), - } - } - - /// # Panics - /// Panics if `lower_bound` is greater than `upper_bound`. - pub fn not_exact( - certain_ids: impl IntoIterator, - lower_bound: LowerBound, - upper_bound: UpperBound, - allowed_ids: AllowedIds, - ) -> Self { - assert!( - lower_bound.get_amount() <= upper_bound.get_amount(), - "Upper bound MUST be greater than or equal lower bound." - ); - - Self::NotExact { + Self { certain_ids: certain_ids.into_iter().collect(), - lower_bound, - upper_bound, - allowed_ids, - } - } - - pub fn certain_ids(&self) -> IndexSet { - match self { - Self::Exact { certain_ids, .. } => { - certain_ids.clone().into_iter().collect() - } - Self::NotExact { certain_ids, .. } => { - certain_ids.clone().into_iter().collect() - } + additional_amount, } } } @@ -65,59 +28,137 @@ impl From fn from(value: ScryptoSimpleNonFungibleResourceBounds) -> Self { match value { ScryptoSimpleNonFungibleResourceBounds::Exact { - amount, + amount: _, certain_ids, - } => Self::exact( - amount, + } => Self::new( certain_ids .into_iter() .map(NonFungibleLocalId::from) .collect::>(), + None, ), ScryptoSimpleNonFungibleResourceBounds::NotExact { certain_ids, lower_bound, upper_bound, - allowed_ids, - } => Self::not_exact( + allowed_ids: _, + } => Self::new( certain_ids + .clone() .into_iter() .map(NonFungibleLocalId::from) .collect::>(), - LowerBound::from(lower_bound), - UpperBound::from(upper_bound), - AllowedIds::from(allowed_ids), + Some(SimpleCountedResourceBounds::from(( + certain_ids.len(), + lower_bound, + upper_bound, + ))), ), } } } +/// Converts the ScryptoSimpleNonFungibleResourceBounds::NotExact to SimpleCountedResourceBounds. +/// The following invariants are guaranteed by scrypto: +/// - certain_ids.len() <= lower_bound_inclusive <= upper_bound_inclusive +/// - certain_ids.len() is included in the bounds +/// - if certain_ids.len() == upper_bound_inclusive, then the bounds are exact, and it will be represented as ScryptoSimpleNonFungibleResourceBounds::Exact. +impl From<(usize, ScryptoLowerBound, ScryptoUpperBound)> + for SimpleCountedResourceBounds +{ + fn from(val: (usize, ScryptoLowerBound, ScryptoUpperBound)) -> Self { + let (certain_ids_size, lower_bound, upper_bound) = val; + + // Adjust the bound values to account for the certain IDs count. + fn adjusted_bound_value( + bound_value: ScryptoDecimal192, + certain_ids_size: usize, + ) -> Decimal { + Decimal::from( + u64::try_from(bound_value).unwrap() - certain_ids_size as u64, + ) + } + + match (lower_bound, upper_bound) { + (ScryptoLowerBound::NonZero, ScryptoUpperBound::Unbounded) => { + SimpleCountedResourceBounds::UnknownAmount + } + ( + ScryptoLowerBound::NonZero, + ScryptoUpperBound::Inclusive(upper_bound), + ) => SimpleCountedResourceBounds::AtMost { + amount: adjusted_bound_value(upper_bound, certain_ids_size), + }, + ( + ScryptoLowerBound::Inclusive(lower_bound), + ScryptoUpperBound::Unbounded, + ) => { + let adjusted_lower_bound_value = + adjusted_bound_value(lower_bound, certain_ids_size); + if adjusted_lower_bound_value.is_zero() { + SimpleCountedResourceBounds::UnknownAmount + } else { + SimpleCountedResourceBounds::AtLeast { + amount: adjusted_lower_bound_value, + } + } + } + ( + ScryptoLowerBound::Inclusive(lower_bound), + ScryptoUpperBound::Inclusive(upper_bound), + ) => { + let adjusted_lower_bound_value = + adjusted_bound_value(lower_bound, certain_ids_size); + let adjusted_upper_bound_value = + adjusted_bound_value(upper_bound, certain_ids_size); + + if adjusted_lower_bound_value.is_zero() { + SimpleCountedResourceBounds::AtMost { + amount: adjusted_upper_bound_value, + } + } else if adjusted_lower_bound_value + == adjusted_upper_bound_value + { + SimpleCountedResourceBounds::Exact { + amount: adjusted_lower_bound_value, + } + } else { + SimpleCountedResourceBounds::Between { + min_amount: adjusted_lower_bound_value, + max_amount: adjusted_upper_bound_value, + } + } + } + } + } +} + impl HasSampleValues for SimpleNonFungibleResourceBounds { fn sample() -> Self { - Self::exact( - 150, + Self::new( [ NonFungibleLocalId::sample(), NonFungibleLocalId::sample_other(), ], + None, ) } fn sample_other() -> Self { - Self::not_exact( + Self::new( [ NonFungibleLocalId::sample(), NonFungibleLocalId::sample_other(), ], - LowerBound::sample(), - UpperBound::sample(), - AllowedIds::sample_other(), + Some(SimpleCountedResourceBounds::between(3, 5)), ) } } #[cfg(test)] mod tests { + use sbor::prelude::indexmap::IndexSet; + use super::*; #[allow(clippy::upper_case_acronyms)] @@ -136,88 +177,128 @@ mod tests { #[test] fn from_scrypto_exact() { + let certain_ids = vec![ + NonFungibleLocalId::sample(), + NonFungibleLocalId::sample_other(), + ]; + let scrypto = ScryptoSimpleNonFungibleResourceBounds::Exact { - amount: 150.into(), - certain_ids: [ - NonFungibleLocalId::sample(), - NonFungibleLocalId::sample_other(), - ] - .into_iter() - .map(ScryptoNonFungibleLocalId::from) - .collect(), + amount: Decimal::from(2).into(), + certain_ids: certain_ids + .clone() + .into_iter() + .map(ScryptoNonFungibleLocalId::from) + .collect(), }; - assert_eq!(SUT::from(scrypto), SUT::sample()); - } - #[test] - fn from_scrypto_not_exact() { - let scrypto = ScryptoSimpleNonFungibleResourceBounds::NotExact { - certain_ids: [ - NonFungibleLocalId::sample(), - NonFungibleLocalId::sample_other(), - ] - .into_iter() - .map(ScryptoNonFungibleLocalId::from) - .collect(), - lower_bound: ScryptoLowerBound::Inclusive(1.into()), - upper_bound: ScryptoUpperBound::Inclusive(1.into()), - allowed_ids: ScryptoAllowedIds::Any, - }; - assert_eq!(SUT::from(scrypto), SUT::sample_other()); + assert_eq!(SUT::from(scrypto), SUT::new(certain_ids, None)); } #[test] - fn test_certain_ids_exact() { - let exact = SUT::exact( - 100, - [ - NonFungibleLocalId::sample(), - NonFungibleLocalId::sample_other(), - ], + fn from_scrypto_non_exact_no_certain_ids() { + fn assert_bounds( + lower_bound: ScryptoLowerBound, + upper_bound: ScryptoUpperBound, + expected: SimpleCountedResourceBounds, + ) { + let scrypto = ScryptoSimpleNonFungibleResourceBounds::NotExact { + certain_ids: IndexSet::new(), + lower_bound, + upper_bound, + allowed_ids: ScryptoAllowedIds::Any, + }; + + assert_eq!( + SUT::from(scrypto), + SUT::new(Vec::new(), Some(expected)) + ); + } + + assert_bounds( + ScryptoLowerBound::NonZero, + ScryptoUpperBound::Unbounded, + SimpleCountedResourceBounds::unknown_amount(), ); - assert_eq!( - exact.certain_ids(), - [ - NonFungibleLocalId::sample(), - NonFungibleLocalId::sample_other() - ] - .into_iter() - .collect::>() - ) - } - #[test] - fn test_certain_ids_not_exact() { - let not_exact = SUT::not_exact( - [ - NonFungibleLocalId::sample(), - NonFungibleLocalId::sample_other(), - ], - LowerBound::sample(), - UpperBound::sample(), - AllowedIds::sample(), + assert_bounds( + ScryptoLowerBound::NonZero, + ScryptoUpperBound::Inclusive(Decimal::from(5).into()), + SimpleCountedResourceBounds::at_most(5), + ); + + assert_bounds( + ScryptoLowerBound::Inclusive(Decimal::from(3).into()), + ScryptoUpperBound::Unbounded, + SimpleCountedResourceBounds::at_least(3), + ); + + assert_bounds( + ScryptoLowerBound::Inclusive(Decimal::from(3).into()), + ScryptoUpperBound::Inclusive(Decimal::from(5).into()), + SimpleCountedResourceBounds::between(3, 5), + ); + + assert_bounds( + ScryptoLowerBound::Inclusive(Decimal::from(3).into()), + ScryptoUpperBound::Inclusive(Decimal::from(3).into()), + SimpleCountedResourceBounds::exact(3), ); - assert_eq!( - not_exact.certain_ids(), - [ - NonFungibleLocalId::sample(), - NonFungibleLocalId::sample_other() - ] - .into_iter() - .collect::>() - ) } #[test] - #[should_panic( - expected = "Upper bound MUST be greater than or equal lower bound." - )] - fn not_exact_should_panic_when_upper_bound_less_than_lower_bound() { - SUT::not_exact( - [], - LowerBound::inclusive(2), - UpperBound::inclusive(1), - AllowedIds::sample(), + fn from_scrypto_non_exact_with_certain_ids() { + let certain_ids = vec![ + NonFungibleLocalId::sample(), + NonFungibleLocalId::sample_other(), + ]; + + let scrypto_certain_ids: IndexSet = + certain_ids + .clone() + .into_iter() + .map(ScryptoNonFungibleLocalId::from) + .collect(); + + let assert_bounds = + |lower_bound: ScryptoLowerBound, + upper_bound: ScryptoUpperBound, + expected: SimpleCountedResourceBounds| { + let scrypto = + ScryptoSimpleNonFungibleResourceBounds::NotExact { + certain_ids: scrypto_certain_ids.clone(), + lower_bound, + upper_bound, + allowed_ids: ScryptoAllowedIds::Any, + }; + + assert_eq!( + SUT::from(scrypto), + SUT::new(certain_ids.clone(), Some(expected)) + ); + }; + + assert_bounds( + ScryptoLowerBound::at_least(certain_ids.len().into()), + ScryptoUpperBound::Unbounded, + SimpleCountedResourceBounds::unknown_amount(), + ); + + assert_bounds( + ScryptoLowerBound::at_least((certain_ids.len() + 1).into()), + ScryptoUpperBound::Unbounded, + SimpleCountedResourceBounds::at_least(1), + ); + + assert_bounds( + ScryptoLowerBound::at_least((certain_ids.len() + 2).into()), + ScryptoUpperBound::at_most((certain_ids.len() + 2).into()), + SimpleCountedResourceBounds::exact(2), + ); + + assert_bounds( + ScryptoLowerBound::at_least((certain_ids.len() + 3).into()), + ScryptoUpperBound::at_most((certain_ids.len() + 5).into()), + SimpleCountedResourceBounds::between(3, 5), ); } } diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_resource_bounds.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_resource_bounds.rs index 2db6bf9a2..1468dee62 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_resource_bounds.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/simple_resource_bounds.rs @@ -4,31 +4,58 @@ use crate::prelude::*; #[derive(Clone, Debug, PartialEq, Eq)] pub enum SimpleResourceBounds { Fungible { - bounds: SimpleFungibleResourceBounds, + resource_address: ResourceAddress, + bounds: SimpleCountedResourceBounds, }, NonFungible { + resource_address: ResourceAddress, bounds: SimpleNonFungibleResourceBounds, }, } impl SimpleResourceBounds { - pub fn fungible(bounds: SimpleFungibleResourceBounds) -> Self { - Self::Fungible { bounds } + pub fn fungible( + resource_address: impl Into, + bounds: SimpleCountedResourceBounds, + ) -> Self { + Self::Fungible { + resource_address: resource_address.into(), + bounds, + } } - pub fn non_fungible(bounds: SimpleNonFungibleResourceBounds) -> Self { - Self::NonFungible { bounds } + pub fn non_fungible( + resource_address: impl Into, + bounds: SimpleNonFungibleResourceBounds, + ) -> Self { + Self::NonFungible { + resource_address: resource_address.into(), + bounds, + } + } + + pub fn exact_fungible( + resource_address: ResourceAddress, + amount: impl Into, + ) -> Self { + Self::fungible( + resource_address, + SimpleCountedResourceBounds::exact(amount.into()), + ) } } -impl From for SimpleResourceBounds { - fn from(value: ScryptoSimpleResourceBounds) -> Self { - match value { +impl From<(ResourceAddress, ScryptoSimpleResourceBounds)> + for SimpleResourceBounds +{ + fn from(value: (ResourceAddress, ScryptoSimpleResourceBounds)) -> Self { + let (resource_address, bounds) = value; + match bounds { ScryptoSimpleResourceBounds::Fungible(bounds) => { - Self::fungible(bounds.into()) + Self::fungible(resource_address, bounds.into()) } ScryptoSimpleResourceBounds::NonFungible(bounds) => { - Self::non_fungible(bounds.into()) + Self::non_fungible(resource_address, bounds.into()) } } } @@ -36,11 +63,17 @@ impl From for SimpleResourceBounds { impl HasSampleValues for SimpleResourceBounds { fn sample() -> Self { - Self::fungible(SimpleFungibleResourceBounds::sample()) + Self::fungible( + ResourceAddress::sample(), + SimpleCountedResourceBounds::sample(), + ) } fn sample_other() -> Self { - Self::non_fungible(SimpleNonFungibleResourceBounds::sample()) + Self::non_fungible( + ResourceAddress::sample_other(), + SimpleNonFungibleResourceBounds::sample_other(), + ) } } @@ -69,7 +102,10 @@ mod tests { Decimal::from(1337).into(), ), ); - assert_eq!(SUT::from(scrypto), SUT::sample()); + assert_eq!( + SUT::from((ResourceAddress::sample(), scrypto)), + SUT::sample() + ); } #[test] @@ -86,6 +122,18 @@ mod tests { .collect(), }, ); - assert_eq!(SUT::from(scrypto), SUT::sample_other()); + assert_eq!( + SUT::from((ResourceAddress::sample_mainnet_nft_other(), scrypto)), + SUT::non_fungible( + ResourceAddress::sample_mainnet_nft_other(), + SimpleNonFungibleResourceBounds::new( + vec![ + NonFungibleLocalId::sample(), + NonFungibleLocalId::sample_other(), + ], + None, + ) + ) + ); } } diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/unspecified_resources.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/unspecified_resources.rs index cea152cf1..abea04c86 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/unspecified_resources.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/unspecified_resources.rs @@ -8,7 +8,7 @@ pub enum UnspecifiedResources { NonePresent, /// There might be non-zero balances of unspecified resources present - MayBePresent { change_sources: Vec }, + MayBePresent, } impl UnspecifiedResources { @@ -16,12 +16,8 @@ impl UnspecifiedResources { Self::NonePresent } - pub fn may_be_present( - change_sources: impl IntoIterator, - ) -> Self { - Self::MayBePresent { - change_sources: change_sources.into_iter().collect(), - } + pub fn may_be_present() -> Self { + Self::MayBePresent } } @@ -29,25 +25,18 @@ impl From for UnspecifiedResources { fn from(value: ScryptoUnspecifiedResources) -> Self { match value { ScryptoUnspecifiedResources::NonePresent => Self::NonePresent, - ScryptoUnspecifiedResources::MayBePresent(sources) => { - Self::MayBePresent { - change_sources: sources - .into_iter() - .map(ChangeSource::from) - .collect(), - } - } + ScryptoUnspecifiedResources::MayBePresent(_) => Self::MayBePresent, } } } impl HasSampleValues for UnspecifiedResources { fn sample() -> Self { - Self::NonePresent + Self::none_present() } fn sample_other() -> Self { - Self::may_be_present(vec![ChangeSource::sample()]) + Self::may_be_present() } } diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/upper_bound.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/upper_bound.rs deleted file mode 100644 index 23c94a0c8..000000000 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/account_deposit/upper_bound.rs +++ /dev/null @@ -1,115 +0,0 @@ -use crate::prelude::*; -use radix_common::prelude::ManifestResourceConstraint; - -/// Represents an upper bound on a non-negative decimal. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum UpperBound { - /// The amount is required to be non-negative before using this model. - /// This can be validated via [`ManifestResourceConstraint::is_valid_for`]. - Inclusive { decimal: Decimal }, - - /// `Unbounded` represents an upper bound above any possible decimal, and is included for - /// clarity of intention. Considering Decimal has a max size, it is effectively equivalent to - /// an inclusive bound of [`Decimal::max()`]. - Unbounded, -} - -impl UpperBound { - pub fn inclusive(decimal: impl Into) -> Self { - Self::Inclusive { - decimal: decimal.into(), - } - } - pub fn unbounded() -> Self { - Self::Unbounded - } -} - -impl UpperBound { - pub fn get_amount(&self) -> Decimal { - ScryptoUpperBound::from(self.clone()) - .equivalent_decimal() - .into() - } -} - -impl From for UpperBound { - fn from(value: ScryptoUpperBound) -> Self { - match value { - ScryptoUpperBound::Inclusive(decimal) => Self::inclusive(decimal), - ScryptoUpperBound::Unbounded => Self::unbounded(), - } - } -} - -impl From for ScryptoUpperBound { - fn from(value: UpperBound) -> Self { - match value { - UpperBound::Inclusive { decimal } => { - ScryptoUpperBound::Inclusive(decimal.into()) - } - UpperBound::Unbounded => ScryptoUpperBound::Unbounded, - } - } -} - -impl HasSampleValues for UpperBound { - fn sample() -> Self { - Self::inclusive(1) - } - - fn sample_other() -> Self { - Self::unbounded() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[allow(clippy::upper_case_acronyms)] - type SUT = UpperBound; - - #[test] - fn equality() { - assert_eq!(SUT::sample(), SUT::sample()); - assert_eq!(SUT::sample_other(), SUT::sample_other()); - } - - #[test] - fn inequality() { - assert_ne!(SUT::sample(), SUT::sample_other()); - } - - #[test] - fn from_scrypto_inclusive() { - let scrypto = ScryptoUpperBound::Inclusive(1.into()); - assert_eq!(SUT::from(scrypto), SUT::sample()) - } - - #[test] - fn from_scrypto_unbounded() { - let scrypto = ScryptoUpperBound::Unbounded; - assert_eq!(SUT::from(scrypto), SUT::sample_other()) - } - - #[test] - fn to_scrypto_inclusive() { - let upper_bound = SUT::sample(); - let scrypto: ScryptoUpperBound = upper_bound.into(); - assert_eq!(scrypto, ScryptoUpperBound::Inclusive(1.into())); - } - - #[test] - fn to_scrypto_unbounded() { - let upper_bound = SUT::sample_other(); - let scrypto: ScryptoUpperBound = upper_bound.into(); - assert_eq!(scrypto, ScryptoUpperBound::Unbounded); - } - - #[test] - fn get_amount() { - assert_eq!(SUT::sample().get_amount(), Decimal::from(1)); - assert_eq!(SUT::sample_other().get_amount(), Decimal::max()); - } -} diff --git a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/manifest_summary.rs b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/manifest_summary.rs index a25c7c867..18547950d 100644 --- a/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/manifest_summary.rs +++ b/crates/sargon/src/wrapped_radix_engine_toolkit/low_level/manifest_summary/manifest_summary.rs @@ -7,7 +7,7 @@ pub struct ManifestSummary { pub account_withdrawals: HashMap>, /// The deposits done in the manifest. - pub account_deposits: HashMap>, + pub account_deposits: HashMap, /// The list of the resources of proofs that were presented in the manifest. pub presented_proofs: Vec, @@ -43,7 +43,7 @@ pub struct ManifestSummary { impl ManifestSummary { pub fn new( account_withdraws: impl Into>>, - account_deposits: impl Into>>, + account_deposits: impl Into>, presented_proofs: impl IntoIterator, withdrawn_from: impl IntoIterator, deposited_into: impl IntoIterator, @@ -102,13 +102,6 @@ fn account_withdraw_from_scrypto( AccountWithdraw::from((item, network_id)) } -fn account_deposit_from_scrypto( - item: ScryptoAccountDeposit, - network_id: NetworkID, -) -> AccountDeposit { - AccountDeposit::from((item, network_id)) -} - impl From<(RetStaticAnalysis, NetworkID)> for ManifestSummary { fn from(value: (RetStaticAnalysis, NetworkID)) -> Self { let (ret, network_id) = value; @@ -119,11 +112,16 @@ impl From<(RetStaticAnalysis, NetworkID)> for ManifestSummary { account_withdraw_from_scrypto, ); - let account_deposits = convert_from_scrypto( - ret.account_deposits, - network_id, - account_deposit_from_scrypto, - ); + let account_deposits: HashMap = ret + .account_deposits + .into_iter() + .map(|(addr, items)| { + ( + AccountAddress::from((addr, network_id)), + AccountDeposits::from((items, network_id)), + ) + }) + .collect(); let addresses_of_accounts_withdrawn_from = to_vec_network_aware(ret.accounts_withdrawn_from, network_id); 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 55304aeaf..16d958eef 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 @@ -461,7 +461,7 @@ BURN_RESOURCE AccountAddress::sample() => vec![AccountWithdraw::amount(ResourceAddress::sample(), 1337)], ), hashmap!( - AccountAddress::sample_other() => vec![AccountDeposit::sample()], + AccountAddress::sample_other() => AccountDeposits::sample(), ), [], [AccountAddress::sample()], @@ -487,36 +487,23 @@ BURN_RESOURCE a => vec![AccountWithdraw::sample()], ), hashmap!( - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(150)))), - ] - .into_iter() - .collect(), + AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 150)], UnspecifiedResources::NonePresent, ) - ], - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(50)))), - ] - .into_iter() - .collect(), + , + AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 50)], UnspecifiedResources::NonePresent, ) - ], - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(130)))), - ] - .into_iter() - .collect(), + , + AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 130)], UnspecifiedResources::NonePresent, - ) - ], + ), ), [], [ 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 6acc4a8bd..8344ecfc4 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 @@ -240,7 +240,8 @@ mod tests { use crate::prelude::*; use radix_rust::hashmap; use radix_transactions::manifest::{ - CallMethod, DropAllProofs, DropAuthZoneProofs, YieldToParent, + BlobProvider, CallMethod, DropAllProofs, DropAuthZoneProofs, + YieldToParent, }; use radix_transactions::model::InstructionV1; use sbor::ValueKind as ScryptoValueKind; @@ -497,7 +498,7 @@ DROP_AUTH_ZONE_PROOFS; AccountAddress::sample() => vec![AccountWithdraw::amount(ResourceAddress::sample(), 1337)], ), hashmap!( - AccountAddress::sample_other() => vec![AccountDeposit::sample()], + AccountAddress::sample_other() => AccountDeposits::sample(), ), [], [AccountAddress::sample()], @@ -523,36 +524,23 @@ DROP_AUTH_ZONE_PROOFS; a => vec![AccountWithdraw::sample()], ), hashmap!( - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(150)))), - ] - .into_iter() - .collect(), + AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 150)], UnspecifiedResources::NonePresent, ) - ], - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(50)))), - ] - .into_iter() - .collect(), + , + AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 50)], UnspecifiedResources::NonePresent, ) - ], - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(130)))), - ] - .into_iter() - .collect(), + , + AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 130)], UnspecifiedResources::NonePresent, - ) - ], + ), ), [], [ @@ -601,9 +589,228 @@ DROP_AUTH_ZONE_PROOFS; .lock_fee_from_faucet() .yield_to_parent(()); + let manifest = SUT::sargon_built(builder, NetworkID::Mainnet); assert_eq!( - SUT::sargon_built(builder, NetworkID::Mainnet,).manifest_string(), + manifest.manifest_string(), "CALL_METHOD\n Address(\"component_rdx1cptxxxxxxxxxfaucetxxxxxxxxx000527798379xxxxxxxxxfaucet\")\n \"lock_fee\"\n Decimal(\"5000\")\n;\nYIELD_TO_PARENT;\n", ) } + + #[test] + fn open_pre_auth_fungibles_deposit_summary() { + let manifest_str = include_str!(concat!( + env!("FIXTURES_TX"), + "open_subintent_fungibles.rtm" + )); + + let network = NetworkID::Stokenet.network_definition(); + let man: ScryptoSubintentManifestV2 = scrypto_compile_manifest( + manifest_str, + &network, + BlobProvider::new(), + ) + .unwrap(); + + let manifest: SubintentManifest = + (man, NetworkID::Stokenet).try_into().unwrap(); + let summary = manifest.summary().unwrap(); + + pretty_assertions::assert_eq!( + summary.account_deposits, + hashmap! { + AccountAddress::from("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") => + 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)), + ], + UnspecifiedResources::MayBePresent, + ), + } + ) + } + + #[test] + fn open_pre_auth_non_fungibles_no_certain_ids_deposit_summary() { + let manifest_str = include_str!(concat!( + env!("FIXTURES_TX"), + "open_subintent_non_fungibles_no_certain_ids.rtm" + )); + + let network = NetworkID::Stokenet.network_definition(); + let man: ScryptoSubintentManifestV2 = scrypto_compile_manifest( + manifest_str, + &network, + BlobProvider::new(), + ) + .unwrap(); + + let manifest: SubintentManifest = + (man, NetworkID::Stokenet).try_into().unwrap(); + let summary = manifest.summary().unwrap(); + + pretty_assertions::assert_eq!( + summary.account_deposits, + hashmap!( + AccountAddress::from("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") => + AccountDeposits::new_for_test( + vec![ + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue", + SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::unknown_amount())), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1n2lj0rk7pye8h2cxs347lf70ksyzwaez0mjkssccfthp6m408hfny7", + SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::at_least(6))), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nf8g5dhl6rxvq78j6q3kdxfkl7rweychjzyv848clhezg44rn0qgy5", + SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::at_most(10))), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nfn4gd24pcpnqegcq07mgvz9cea4zryytswn5vmgepnan7tjqedkxp", + SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::between(100, 159))), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nt8pgfd7xj954403vfgkej25g8kcc56ldu4j3akl4vzlcfen6jcfjg", + SimpleNonFungibleResourceBounds::new(Vec::new(), Some(SimpleCountedResourceBounds::exact(3))), + ), + ], + UnspecifiedResources::MayBePresent, + ), + ) + ); + } + + #[test] + fn open_pre_auth_non_fungibles_with_certain_ids_deposit_summary() { + let manifest_str = include_str!(concat!( + env!("FIXTURES_TX"), + "open_subintent_non_fungibles_with_certain_ids.rtm" + )); + + let network = NetworkID::Stokenet.network_definition(); + let man: ScryptoSubintentManifestV2 = scrypto_compile_manifest( + manifest_str, + &network, + BlobProvider::new(), + ) + .unwrap(); + + let manifest: SubintentManifest = + (man, NetworkID::Stokenet).try_into().unwrap(); + let summary = manifest.summary().unwrap(); + + let certain_ids_sample = vec![ + NonFungibleLocalId::from("#0#"), + NonFungibleLocalId::from("#1#"), + NonFungibleLocalId::from("#2#"), + ]; + + let member_card_id = NonFungibleLocalId::from(""); + + pretty_assertions::assert_eq!( + summary.account_deposits, + hashmap!( + AccountAddress::from("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") => + AccountDeposits::new_for_test( + vec![ + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nfmxggm4plrrmc9ft9qn79g7uehqlhjaszv02dnuk85s0h9xnh3xue", + SimpleNonFungibleResourceBounds::new(vec![member_card_id], Some(SimpleCountedResourceBounds::unknown_amount())), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1n2lj0rk7pye8h2cxs347lf70ksyzwaez0mjkssccfthp6m408hfny7", + SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::unknown_amount())), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nf8g5dhl6rxvq78j6q3kdxfkl7rweychjzyv848clhezg44rn0qgy5", + SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), None), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nfn4gd24pcpnqegcq07mgvz9cea4zryytswn5vmgepnan7tjqedkxp", + SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::at_most(2))), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nt8pgfd7xj954403vfgkej25g8kcc56ldu4j3akl4vzlcfen6jcfjg", + SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), None), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1n2q3kj4sfa6sh45kvau2f08hfhjuls7zcevwl77vjzmgf3sea0uzzu", + SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::at_most(2))), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1n2rpk9w8d8kzu578jxvqr0dplctfh5clylmyqpu9kvnz7hvceh2mxe", + SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::at_least(2))), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1ngu8tgxvv26rpmdwxxfd8gclnsnjeew7zdcw2p3genru58a7wkmue4", + SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::exact(2))), + ), + SimpleResourceBounds::non_fungible( + "resource_tdx_2_1nfve52p2wvx0kp0eq3xaznuvwakcu5a6aqtsjqq8x30zk4wkglxmlv", + SimpleNonFungibleResourceBounds::new(certain_ids_sample.clone(), Some(SimpleCountedResourceBounds::between(2, 5))), + ), + ], + UnspecifiedResources::MayBePresent, + ), + ) + ); + } + + #[test] + fn test_multiple_deposits() { + let manifest_str = include_str!(concat!( + env!("FIXTURES_TX"), + "open_subintent_mix_multiple_deposits.rtm" + )); + + let network = NetworkID::Stokenet.network_definition(); + let man: ScryptoSubintentManifestV2 = scrypto_compile_manifest( + manifest_str, + &network, + BlobProvider::new(), + ) + .unwrap(); + + let manifest: SubintentManifest = + (man, NetworkID::Stokenet).try_into().unwrap(); + let summary = manifest.summary().unwrap(); + + pretty_assertions::assert_eq!( + summary.account_deposits, + hashmap!( + AccountAddress::from("account_tdx_2_129rfcz44zxflyaf6d65fdvaqtk5rlvdu8nzek2nz435zknhqure2xl") => + 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)), + ], + UnspecifiedResources::MayBePresent, + ), + AccountAddress::from("account_tdx_2_1288u4aka2dm8787texaeta8ruzhcr7dyckmnck5wt0llrm6x0ak7e4") => 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)), + ], + 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 813c41159..1678ca605 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 @@ -450,7 +450,7 @@ DROP_AUTH_ZONE_PROOFS; AccountAddress::sample() => vec![AccountWithdraw::amount(ResourceAddress::sample(), 1337)], ), hashmap!( - AccountAddress::sample_other() => vec![AccountDeposit::sample()], + AccountAddress::sample_other() => AccountDeposits::sample(), ), [], [AccountAddress::sample()], @@ -476,36 +476,23 @@ DROP_AUTH_ZONE_PROOFS; a => vec![AccountWithdraw::sample()], ), hashmap!( - AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(150)))), - ] - .into_iter() - .collect(), + AccountAddress::from("account_sim1c8mulhl5yrk6hh4jsyldps5sdrp08r5v9wusupvzxgqvhlp4c4nwjz") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 150)], UnspecifiedResources::NonePresent, ) - ], - AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(50)))), - ] - .into_iter() - .collect(), + , + AccountAddress::from("account_sim1c8ct6jdcwqrg3gzskyxuy0z933fe55fyjz6p56730r95ulzwl3ppva") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 50)], UnspecifiedResources::NonePresent, ) - ], - AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => vec![ - AccountDeposit::new( - vec![ - (ResourceAddress::sample_sim_xrd(), SimpleResourceBounds::fungible(SimpleFungibleResourceBounds::exact(Decimal::from(130)))), - ] - .into_iter() - .collect(), + , + AccountAddress::from("account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr") => + AccountDeposits::new_for_test( + vec![SimpleResourceBounds::exact_fungible(ResourceAddress::sample_sim_xrd(), 130)], UnspecifiedResources::NonePresent, - ) - ], + ), ), [], [