diff --git a/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs b/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs index ca0904b6..4d2a24fe 100644 --- a/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs +++ b/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs @@ -18,6 +18,8 @@ #![allow(clippy::too_many_arguments)] use crate::prelude::*; +use radix_engine::types::FromPublicKey; +use radix_engine_common::prelude::to_manifest_value; #[derive(Debug, Clone, Object, Default)] pub struct ManifestBuilder { @@ -834,6 +836,110 @@ impl ManifestBuilder { /* Access Controller */ + pub fn access_controller_initiate_recovery( + self: Arc, + access_controller_address: Arc
, + proposer: Proposer, + proposed_primary_role: Arc, + proposed_recovery_role: Arc, + proposed_confirmation_role: Arc, + proposed_timed_recovery_delay_in_minutes: Option, + ) -> Result> { + builder_arc_map(self, |builder| { + let rule_set = NativeRuleSet { + primary_role: proposed_primary_role.0.clone(), + recovery_role: proposed_recovery_role.0.clone(), + confirmation_role: proposed_confirmation_role.0.clone(), + }; + + let (method_name, args) = match proposer { + Proposer::Primary => ( + NATIVE_ACCESS_CONTROLLER_INITIATE_RECOVERY_AS_PRIMARY_IDENT, + native_to_manifest_value_and_unwrap!( + &NativeAccessControllerInitiateRecoveryAsPrimaryInput { + rule_set, + timed_recovery_delay_in_minutes: + proposed_timed_recovery_delay_in_minutes, + } + ), + ), + Proposer::Recovery => ( + NATIVE_ACCESS_CONTROLLER_INITIATE_RECOVERY_AS_RECOVERY_IDENT, + native_to_manifest_value_and_unwrap!( + &NativeAccessControllerInitiateRecoveryAsRecoveryInput { + rule_set, + timed_recovery_delay_in_minutes: + proposed_timed_recovery_delay_in_minutes, + } + ), + ), + }; + + let instruction = NativeInstruction::CallMethod { + address: NativeDynamicGlobalAddress::Static( + (*access_controller_address).try_into()?, + ), + method_name: method_name.to_owned(), + args, + }; + builder.instructions.push(instruction); + + Ok(()) + }) + } + + pub fn access_controller_quick_confirm_recovery( + self: Arc, + access_controller_address: Arc
, + proposer: Proposer, + proposed_primary_role: Arc, + proposed_recovery_role: Arc, + proposed_confirmation_role: Arc, + proposed_timed_recovery_delay_in_minutes: Option, + ) -> Result> { + builder_arc_map(self, |builder| { + let rule_set = NativeRuleSet { + primary_role: proposed_primary_role.0.clone(), + recovery_role: proposed_recovery_role.0.clone(), + confirmation_role: proposed_confirmation_role.0.clone(), + }; + + let (method_name, args) = match proposer { + Proposer::Primary => ( + NATIVE_ACCESS_CONTROLLER_QUICK_CONFIRM_PRIMARY_ROLE_RECOVERY_PROPOSAL_IDENT, + native_to_manifest_value_and_unwrap!( + &NativeAccessControllerQuickConfirmPrimaryRoleRecoveryProposalInput { + rule_set, + timed_recovery_delay_in_minutes: + proposed_timed_recovery_delay_in_minutes, + } + ), + ), + Proposer::Recovery => ( + NATIVE_ACCESS_CONTROLLER_QUICK_CONFIRM_RECOVERY_ROLE_RECOVERY_PROPOSAL_IDENT, + native_to_manifest_value_and_unwrap!( + &NativeAccessControllerQuickConfirmRecoveryRoleRecoveryProposalInput { + rule_set, + timed_recovery_delay_in_minutes: + proposed_timed_recovery_delay_in_minutes, + } + ), + ), + }; + + let instruction = NativeInstruction::CallMethod { + address: NativeDynamicGlobalAddress::Static( + (*access_controller_address).try_into()?, + ), + method_name: method_name.to_owned(), + args, + }; + builder.instructions.push(instruction); + + Ok(()) + }) + } + pub fn create_signature_based_access_controller( self: Arc, controlled_asset: ManifestBuilderBucket, diff --git a/radix-engine-toolkit-uniffi/src/lib.rs b/radix-engine-toolkit-uniffi/src/lib.rs index 7f63d7f7..7943434f 100644 --- a/radix-engine-toolkit-uniffi/src/lib.rs +++ b/radix-engine-toolkit-uniffi/src/lib.rs @@ -66,6 +66,7 @@ pub mod prelude { pub use crate::error::*; /* Events */ + pub use crate::events::functions::*; pub use crate::events::*; /* Cryptography */