Skip to content

Commit

Permalink
Merge branch 'release/rcnet-v2-phase-2' into release/rcnet-v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOmarA committed Sep 8, 2023
2 parents 73db864 + ddf5371 commit ff62068
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
106 changes: 106 additions & 0 deletions radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -834,6 +836,110 @@ impl ManifestBuilder {

/* Access Controller */

pub fn access_controller_initiate_recovery(
self: Arc<Self>,
access_controller_address: Arc<Address>,
proposer: Proposer,
proposed_primary_role: Arc<AccessRule>,
proposed_recovery_role: Arc<AccessRule>,
proposed_confirmation_role: Arc<AccessRule>,
proposed_timed_recovery_delay_in_minutes: Option<u32>,
) -> Result<Arc<Self>> {
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<Self>,
access_controller_address: Arc<Address>,
proposer: Proposer,
proposed_primary_role: Arc<AccessRule>,
proposed_recovery_role: Arc<AccessRule>,
proposed_confirmation_role: Arc<AccessRule>,
proposed_timed_recovery_delay_in_minutes: Option<u32>,
) -> Result<Arc<Self>> {
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<Self>,
controlled_asset: ManifestBuilderBucket,
Expand Down
1 change: 1 addition & 0 deletions radix-engine-toolkit-uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub mod prelude {
pub use crate::error::*;

/* Events */
pub use crate::events::functions::*;
pub use crate::events::*;

/* Cryptography */
Expand Down

0 comments on commit ff62068

Please sign in to comment.