diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f47a55a0..46b79c93 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -125,6 +125,7 @@ jobs: echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV echo "AR=aarch64-linux-gnu-gcc-ar" >> $GITHUB_ENV + echo "HOST_CC=x86_64-linux-gnu-gcc" >> $GITHUB_ENV - name: Build Dependencies (android) uses: nttld/setup-ndk@v1 id: setup-ndk @@ -154,6 +155,7 @@ jobs: echo "CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc" >> $GITHUB_ENV echo "CC=x86_64-w64-mingw32-gcc" >> $GITHUB_ENV echo "AR=x86_64-w64-mingw32-gcc-ar" >> $GITHUB_ENV + echo "HOST_CC=x86_64-linux-gnu-gcc" >> $GITHUB_ENV - name: Build working-directory: crates/${{ matrix.build-target.crate }} diff --git a/crates/generator/Cargo.toml b/crates/generator/Cargo.toml index c2642651..382bcf26 100644 --- a/crates/generator/Cargo.toml +++ b/crates/generator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "generator" -version = "1.0.9" +version = "1.0.10" edition = "2021" [dependencies] diff --git a/crates/radix-engine-toolkit-json/Cargo.toml b/crates/radix-engine-toolkit-json/Cargo.toml index 4ca47bbb..1d449805 100644 --- a/crates/radix-engine-toolkit-json/Cargo.toml +++ b/crates/radix-engine-toolkit-json/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "radix-engine-toolkit-json" -version = "1.0.9" +version = "1.0.10" edition = "2021" [dependencies] diff --git a/crates/radix-engine-toolkit-uniffi/Cargo.toml b/crates/radix-engine-toolkit-uniffi/Cargo.toml index fcebe237..e8dc010c 100644 --- a/crates/radix-engine-toolkit-uniffi/Cargo.toml +++ b/crates/radix-engine-toolkit-uniffi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "radix-engine-toolkit-uniffi" -version = "1.0.9" +version = "1.0.10" edition = "2021" build = "build.rs" diff --git a/crates/radix-engine-toolkit-uniffi/src/transaction/manifest.rs b/crates/radix-engine-toolkit-uniffi/src/transaction/manifest.rs index fabfe6b4..4b36c05f 100644 --- a/crates/radix-engine-toolkit-uniffi/src/transaction/manifest.rs +++ b/crates/radix-engine-toolkit-uniffi/src/transaction/manifest.rs @@ -701,7 +701,7 @@ impl DetailedManifestClass { pub struct ExecutionSummary { pub account_withdraws: HashMap>, pub account_deposits: HashMap>, - pub presented_proofs: Vec>, + pub presented_proofs: HashMap>, pub new_entities: NewEntities, pub encountered_entities: Vec>, pub accounts_requiring_auth: Vec>, @@ -753,10 +753,19 @@ impl ExecutionSummary { .presented_proofs .into_iter() .map(|item| { - Arc::new(Address::unsafe_from_raw( - item.into_node_id(), - network_id, - )) + ( + Address::unsafe_from_raw( + item.0.into_node_id(), + network_id, + ) + .address_string(), + item.1 + .iter() + .map(|i| { + ResourceSpecifier::from_native(i, network_id) + }) + .collect(), + ) }) .collect(), new_entities: NewEntities::from_native( @@ -826,7 +835,7 @@ impl ExecutionSummary { #[derive(Clone, Debug, Record)] pub struct ManifestSummary { - pub presented_proofs: Vec>, + pub presented_proofs: HashMap>, pub accounts_withdrawn_from: Vec>, pub accounts_deposited_into: Vec>, pub encountered_entities: Vec>, @@ -843,10 +852,19 @@ impl ManifestSummary { .presented_proofs .into_iter() .map(|item| { - Arc::new(Address::unsafe_from_raw( - item.into_node_id(), - network_id, - )) + ( + Address::unsafe_from_raw( + item.0.into_node_id(), + network_id, + ) + .address_string(), + item.1 + .iter() + .map(|i| { + ResourceSpecifier::from_native(i, network_id) + }) + .collect(), + ) }) .collect(), accounts_withdrawn_from: native diff --git a/crates/radix-engine-toolkit-uniffi/tests/bindings/example.kts b/crates/radix-engine-toolkit-uniffi/tests/bindings/example.kts index 80f62d53..7c6ea144 100644 --- a/crates/radix-engine-toolkit-uniffi/tests/bindings/example.kts +++ b/crates/radix-engine-toolkit-uniffi/tests/bindings/example.kts @@ -4,4 +4,4 @@ import com.radixdlt.ret.*; val information = buildInformation(); // Assert -assert(information.version == "1.0.9"); \ No newline at end of file +assert(information.version == "1.0.10"); \ No newline at end of file diff --git a/crates/radix-engine-toolkit-uniffi/tests/bindings/example.py b/crates/radix-engine-toolkit-uniffi/tests/bindings/example.py index 070225ac..519100f8 100644 --- a/crates/radix-engine-toolkit-uniffi/tests/bindings/example.py +++ b/crates/radix-engine-toolkit-uniffi/tests/bindings/example.py @@ -4,4 +4,4 @@ build_info = build_information() # Assert -assert build_info.version == "1.0.9" \ No newline at end of file +assert build_info.version == "1.0.10" \ No newline at end of file diff --git a/crates/radix-engine-toolkit-uniffi/tests/bindings/example.swift b/crates/radix-engine-toolkit-uniffi/tests/bindings/example.swift index a5f518ef..4882e5fe 100644 --- a/crates/radix-engine-toolkit-uniffi/tests/bindings/example.swift +++ b/crates/radix-engine-toolkit-uniffi/tests/bindings/example.swift @@ -6,5 +6,5 @@ do { let buildInformation = radix_engine_toolkit_uniffi.buildInformation() // Assert - assert(buildInformation.version == "1.0.9") + assert(buildInformation.version == "1.0.10") } diff --git a/crates/radix-engine-toolkit/Cargo.toml b/crates/radix-engine-toolkit/Cargo.toml index 0b9fa2ef..fecce573 100644 --- a/crates/radix-engine-toolkit/Cargo.toml +++ b/crates/radix-engine-toolkit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "radix-engine-toolkit" -version = "1.0.9" +version = "1.0.10" edition = "2021" build = "build.rs" diff --git a/crates/radix-engine-toolkit/src/transaction_types/traverser/auxiliary/presented_proofs.rs b/crates/radix-engine-toolkit/src/transaction_types/traverser/auxiliary/presented_proofs.rs index 162a32ea..c1afc8c9 100644 --- a/crates/radix-engine-toolkit/src/transaction_types/traverser/auxiliary/presented_proofs.rs +++ b/crates/radix-engine-toolkit/src/transaction_types/traverser/auxiliary/presented_proofs.rs @@ -15,24 +15,32 @@ // specific language governing permissions and limitations // under the License. +use radix_engine::system::system_modules::execution_trace::*; use scrypto::prelude::*; use crate::transaction_types::*; #[derive(Default)] pub struct PresentedProofsDetector { - presented_proofs: IndexSet, + presented_proofs: IndexMap>, } impl PresentedProofsDetector { - pub fn output(self) -> IndexSet { + pub fn output(self) -> IndexMap> { self.presented_proofs } } impl ManifestSummaryCallback for PresentedProofsDetector { - fn on_create_proof(&mut self, resource_address: &ResourceAddress) { - self.presented_proofs.insert(*resource_address); + fn on_create_proof( + &mut self, + account: &ComponentAddress, + resource: &ResourceSpecifier, + ) { + self.presented_proofs + .entry(*account) + .and_modify(|res_vector| res_vector.push(resource.clone())) + .or_insert(vec![resource.clone()]); } } diff --git a/crates/radix-engine-toolkit/src/transaction_types/traverser/traits.rs b/crates/radix-engine-toolkit/src/transaction_types/traverser/traits.rs index d05acf19..671a9908 100644 --- a/crates/radix-engine-toolkit/src/transaction_types/traverser/traits.rs +++ b/crates/radix-engine-toolkit/src/transaction_types/traverser/traits.rs @@ -36,7 +36,12 @@ pub trait ManifestSummaryCallback { /// Called when a proof is created out of an account. #[inline] - fn on_create_proof(&mut self, _resource_address: &ResourceAddress) {} + fn on_create_proof( + &mut self, + _account: &ComponentAddress, + _resource: &ResourceSpecifier, + ) { + } /// Called when a global entity is encountered in the manifest #[inline] diff --git a/crates/radix-engine-toolkit/src/transaction_types/traverser/traverser.rs b/crates/radix-engine-toolkit/src/transaction_types/traverser/traverser.rs index 77098630..35b08481 100644 --- a/crates/radix-engine-toolkit/src/transaction_types/traverser/traverser.rs +++ b/crates/radix-engine-toolkit/src/transaction_types/traverser/traverser.rs @@ -19,6 +19,7 @@ pub mod manifest_summary { use crate::sbor::indexed_manifest_value::*; use crate::transaction_types::*; use crate::utils::*; + use radix_engine::system::system_modules::execution_trace::*; use radix_engine_interface::blueprints::account::*; use transaction::prelude::*; @@ -67,7 +68,7 @@ pub mod manifest_summary { instruction: &InstructionV1, ) { if let InstructionV1::CallMethod { - address: dynamic_address @ DynamicGlobalAddress::Static(_address), + address: dynamic_address @ DynamicGlobalAddress::Static(address), method_name, args, } = instruction @@ -76,25 +77,40 @@ pub mod manifest_summary { return; } + let account = + ComponentAddress::try_from(*address).expect("Must succeed"); + if method_name == ACCOUNT_CREATE_PROOF_OF_AMOUNT_IDENT { if let Some(AccountCreateProofOfAmountInput { resource_address, - .. + amount, }) = to_manifest_type(args) { callbacks.iter_mut().for_each(|callback| { - callback.on_create_proof(&resource_address) + callback.on_create_proof( + &account, + &ResourceSpecifier::Amount( + resource_address, + amount, + ), + ) }); } } else if method_name == ACCOUNT_CREATE_PROOF_OF_NON_FUNGIBLES_IDENT { if let Some(AccountCreateProofOfNonFungiblesInput { resource_address, - .. + ids, }) = to_manifest_type(args) { callbacks.iter_mut().for_each(|callback| { - callback.on_create_proof(&resource_address) + callback.on_create_proof( + &account, + &ResourceSpecifier::Ids( + resource_address, + ids.clone(), + ), + ) }); } } diff --git a/crates/radix-engine-toolkit/src/transaction_types/types.rs b/crates/radix-engine-toolkit/src/transaction_types/types.rs index 24825b66..959dedc2 100644 --- a/crates/radix-engine-toolkit/src/transaction_types/types.rs +++ b/crates/radix-engine-toolkit/src/transaction_types/types.rs @@ -33,9 +33,8 @@ use super::*; /// A summary of the manifest #[derive(Clone, Debug)] pub struct ManifestSummary { - /// The set of the resource addresses of proofs that were presented in - /// the manifest. - pub presented_proofs: IndexSet, + /// The list of the resources of proofs that were presented in the manifest. + pub presented_proofs: IndexMap>, /// The set of accounts withdrawn from observed in the manifest. pub accounts_withdrawn_from: IndexSet, /// The set of accounts deposited into observed in the manifest. @@ -65,9 +64,8 @@ pub struct ExecutionSummary { pub account_withdraws: IndexMap>, /// The deposits done in the manifest. pub account_deposits: IndexMap>, - /// The set of the resource addresses of proofs that were presented in - /// the manifest. - pub presented_proofs: IndexSet, + /// The list of the resources of proofs that were presented in the manifest. + pub presented_proofs: IndexMap>, /// Information on the global entities created in the transaction. pub new_entities: NewEntities, /// The set of all the global entities encountered in the manifest. This is diff --git a/crates/radix-engine-toolkit/tests/transaction_types.rs b/crates/radix-engine-toolkit/tests/transaction_types.rs index 8eab673b..2acfb000 100644 --- a/crates/radix-engine-toolkit/tests/transaction_types.rs +++ b/crates/radix-engine-toolkit/tests/transaction_types.rs @@ -2282,6 +2282,164 @@ fn account_deposit_settings_changes_are_recognized() { ); } +#[test] +fn presented_proofs_fungible() { + use radix_engine::system::system_modules::execution_trace::*; + + // Arrange + let mut test_runner = TestRunnerBuilder::new().without_trace().build(); + let (_, _, account_1) = test_runner.new_allocated_account(); + let (_, _, account_2) = test_runner.new_allocated_account(); + let address_1 = + test_runner.create_fungible_resource(dec!(100), 0, account_1); + let address_2 = + test_runner.create_fungible_resource(dec!(100), 0, account_1); + let address_3 = + test_runner.create_fungible_resource(dec!(100), 0, account_2); + + //Act + let manifest = ManifestBuilder::new() + .lock_fee_from_faucet() + .create_proof_from_account_of_amount(account_1, address_1, 60) + .create_proof_from_account_of_amount(account_2, address_3, 30) + .create_proof_from_account_of_amount(account_1, address_2, 100) + .create_proof_from_account_of_amount(account_1, address_1, 80) + .create_proof_from_account_of_amount(account_2, address_3, 5) + .build(); + let (manifest_summary, _) = test_runner.summarize(manifest); + + // Assert + assert_eq!(manifest_summary.presented_proofs.len(), 2); + let account_1_proofs = + manifest_summary.presented_proofs.get(&account_1).unwrap(); + assert_eq!(account_1_proofs.len(), 3); + assert_eq!( + account_1_proofs[0], + ResourceSpecifier::Amount(address_1, dec!(60)) + ); + assert_eq!( + account_1_proofs[1], + ResourceSpecifier::Amount(address_2, dec!(100)) + ); + assert_eq!( + account_1_proofs[2], + ResourceSpecifier::Amount(address_1, dec!(80)) + ); + let account_2_proofs = + manifest_summary.presented_proofs.get(&account_2).unwrap(); + assert_eq!(account_2_proofs.len(), 2); + assert_eq!( + account_2_proofs[0], + ResourceSpecifier::Amount(address_3, dec!(30)) + ); + assert_eq!( + account_2_proofs[1], + ResourceSpecifier::Amount(address_3, dec!(5)) + ); +} + +#[test] +fn presented_proofs_non_fungible() { + use radix_engine::system::system_modules::execution_trace::*; + + // Arrange + let mut test_runner = TestRunnerBuilder::new().without_trace().build(); + let (_, _, account_1) = test_runner.new_allocated_account(); + let (_, _, account_2) = test_runner.new_allocated_account(); + let address_1 = test_runner.create_non_fungible_resource(account_1); + let address_2 = test_runner.create_non_fungible_resource(account_1); + let address_3 = test_runner.create_non_fungible_resource(account_2); + + //Act + let manifest = ManifestBuilder::new() + .lock_fee_from_faucet() + .create_proof_from_account_of_non_fungibles( + account_1, + address_1, + [NonFungibleLocalId::integer(1)], + ) + .create_proof_from_account_of_non_fungibles( + account_1, + address_2, + [NonFungibleLocalId::integer(3)], + ) + .create_proof_from_account_of_non_fungibles( + account_2, + address_3, + [ + NonFungibleLocalId::integer(2), + NonFungibleLocalId::integer(3), + ], + ) + .create_proof_from_account_of_non_fungibles( + account_1, + address_1, + [ + NonFungibleLocalId::integer(1), + NonFungibleLocalId::integer(2), + ], + ) + .create_proof_from_account_of_non_fungibles( + account_2, + address_3, + [NonFungibleLocalId::integer(2)], + ) + .build(); + let (manifest_summary, _) = test_runner.summarize(manifest); + + // Assert + assert_eq!(manifest_summary.presented_proofs.len(), 2); + let account_1_proofs = + manifest_summary.presented_proofs.get(&account_1).unwrap(); + assert_eq!(account_1_proofs.len(), 3); + assert_eq!( + account_1_proofs[0], + ResourceSpecifier::Ids( + address_1, + [NonFungibleLocalId::integer(1)].into() + ) + ); + assert_eq!( + account_1_proofs[1], + ResourceSpecifier::Ids( + address_2, + [NonFungibleLocalId::integer(3)].into() + ) + ); + assert_eq!( + account_1_proofs[2], + ResourceSpecifier::Ids( + address_1, + [ + NonFungibleLocalId::integer(1), + NonFungibleLocalId::integer(2) + ] + .into() + ) + ); + let account_2_proofs = + manifest_summary.presented_proofs.get(&account_2).unwrap(); + assert_eq!(account_2_proofs.len(), 2); + assert_eq!( + account_2_proofs[0], + ResourceSpecifier::Ids( + address_3, + [ + NonFungibleLocalId::integer(2), + NonFungibleLocalId::integer(3) + ] + .into() + ) + ); + assert_eq!( + account_2_proofs[01], + ResourceSpecifier::Ids( + address_3, + [NonFungibleLocalId::integer(2)].into() + ) + ); +} + fn create_pools( test_runner: &mut DefaultTestRunner, account: ComponentAddress, diff --git a/crates/sbor-json/Cargo.toml b/crates/sbor-json/Cargo.toml index 4bcda932..083b97c3 100644 --- a/crates/sbor-json/Cargo.toml +++ b/crates/sbor-json/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sbor-json" -version = "1.0.9" +version = "1.0.10" edition = "2021" description = "The implementation of the SBOR JSON representations" diff --git a/crates/uniffi-bindgen/Cargo.toml b/crates/uniffi-bindgen/Cargo.toml index 8c14092d..3db838e9 100644 --- a/crates/uniffi-bindgen/Cargo.toml +++ b/crates/uniffi-bindgen/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uniffi-bindgen" -version = "1.0.9" +version = "1.0.10" edition = "2021" [dependencies] -uniffi = { git = "https://github.com/0xOmarA/uniffi-rs", tag = "v0.25.4", features = ["cli"] } \ No newline at end of file +uniffi = { git = "https://github.com/0xOmarA/uniffi-rs", tag = "v0.25.4", features = ["cli"] } diff --git a/scripts/version_update.sh b/scripts/version_update.sh new file mode 100755 index 00000000..bfa5fcb0 --- /dev/null +++ b/scripts/version_update.sh @@ -0,0 +1,14 @@ +# +# Update version before release +# +# How to use: edit 'old_version' and 'new_version' variables, run script from current folder. +# +# Requires cargo-edit utility, to install run command: cargo install cargo-edit +# + +old_version="1.0.9" +new_version="1.0.10" + +cd .. +cargo set-version $new_version +sed -i "" -e "s/$old_version/$new_version/g" crates/radix-engine-toolkit-uniffi/tests/bindings/example.kts crates/radix-engine-toolkit-uniffi/tests/bindings/example.py crates/radix-engine-toolkit-uniffi/tests/bindings/example.swift