Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Shield Wallet Interaction Part 2 #355

Merged
merged 28 commits into from
Jan 29, 2025
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1a52f44
[no ci] WIP
Sajjon Jan 23, 2025
fdea748
[no ci] wip
CyonAlexRDX Jan 23, 2025
9015925
[no ci] wip
CyonAlexRDX Jan 23, 2025
e7fd884
first initial impl of manifests for updating securified entities
Sajjon Jan 24, 2025
54e9967
remove unused input type
Sajjon Jan 24, 2025
20cbf2a
remove unused input types
Sajjon Jan 24, 2025
25188e9
Merge branch 'main' into ac/wallet_interaction_applying_shield_abw-40…
Sajjon Jan 24, 2025
4d8fc6d
add modify_manifest_add_lock_fee_against_xrd_vault_of_access_controller
Sajjon Jan 24, 2025
f2babd1
fix typos
Sajjon Jan 24, 2025
12704e2
doc
Sajjon Jan 24, 2025
58fc8cb
split out confirm of time based to be done later.
Sajjon Jan 24, 2025
4007bae
Replace bad wording 'auto_confirm' with 'timed_confirm' to make it cl…
Sajjon Jan 24, 2025
0ce2b35
fix typo
Sajjon Jan 24, 2025
5529715
review comments
Sajjon Jan 24, 2025
15e0558
refactor and assert manifests
Sajjon Jan 25, 2025
252f2bd
refactored fixtures moved incorrectly placed ones from vector folder.
Sajjon Jan 25, 2025
3489880
interaction
Sajjon Jan 26, 2025
3ac37f3
add interaction model
Sajjon Jan 26, 2025
ebde221
change 'number_of_days_until_timed_confirmation_is_callable' into 'ti…
Sajjon Jan 26, 2025
be7fdca
simplify interaction to use Vec<UnvalidatedTransactionManifest> again
Sajjon Jan 27, 2025
f567ae3
doc
Sajjon Jan 27, 2025
79ef5a7
try fix swift tests
Sajjon Jan 27, 2025
c36de91
try fix kotlin
Sajjon Jan 27, 2025
6e8a14a
Merge branch 'main' into ac/wallet_interaction_applying_shield_abw-40…
Sajjon Jan 27, 2025
30ebbdc
polish
CyonAlexRDX Jan 29, 2025
f24f196
dont set ROLA key when using timed completion of recovery.
CyonAlexRDX Jan 29, 2025
383d131
Merge branch 'main' into ac/wallet_interaction_applying_shield_abw-40…
CyonAlexRDX Jan 29, 2025
0de346a
Release 1.1.123
CyonAlexRDX Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
first initial impl of manifests for updating securified entities
Sajjon committed Jan 24, 2025
commit e7fd884560a2171285a589355abcf65ee4e5cc51
Original file line number Diff line number Diff line change
@@ -62,8 +62,11 @@
Into::<AddressOfAccountOrPersona>::into(self.entity.address())
}

pub fn current_authentication_signing_factor_instance(&self) -> HierarchicalDeterministicFactorInstance {
self.securified_entity_control().authentication_signing_factor_instance()
pub fn current_authentication_signing_factor_instance(

Check warning on line 65 in crates/profile/models/supporting-types/src/abstract_securified_entity.rs

Codecov / codecov/patch

crates/profile/models/supporting-types/src/abstract_securified_entity.rs#L65

Added line #L65 was not covered by tests
&self,
) -> HierarchicalDeterministicFactorInstance {
self.securified_entity_control()

Check warning on line 68 in crates/profile/models/supporting-types/src/abstract_securified_entity.rs

Codecov / codecov/patch

crates/profile/models/supporting-types/src/abstract_securified_entity.rs#L68

Added line #L68 was not covered by tests
.authentication_signing_factor_instance()
}

pub fn veci(&self) -> Option<VirtualEntityCreatingInstance> {
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
use crate::prelude::*;
use radix_engine_interface::blueprints::access_controller::{
AccessControllerInitiateRecoveryAsPrimaryInput as ScryptoAccessControllerInitiateRecoveryAsPrimaryInput,
AccessControllerInitiateRecoveryAsRecoveryInput as ScryptoAccessControllerInitiateRecoveryAsRecoveryInput,
AccessControllerQuickConfirmPrimaryRoleRecoveryProposalInput as ScryptoAccessControllerQuickConfirmPrimaryRoleRecoveryProposalInput,
AccessControllerQuickConfirmRecoveryRoleRecoveryProposalInput as ScryptoAccessControllerQuickConfirmRecoveryRoleRecoveryProposalInput,
AccessControllerTimedConfirmRecoveryInput as ScryptoAccessControllerTimedConfirmRecoveryInput,
};

#[derive(Debug, Clone)]
pub struct AccessControllerFactorsAndTimeInput {
Copy link
Contributor

@Sajjon Sajjon Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shared type to create:

  • AccessControllerInitiateRecoveryAsPrimaryInput
  • AccessControllerInitiateRecoveryAsRecoveryInput
  • AccessControllerQuickConfirmPrimaryRoleRecoveryProposalInput
  • AccessControllerQuickConfirmRecoveryRoleRecoveryProposalInput
  • AccessControllerTimedConfirmRecoveryInput

Input to call_method instruction, using SecurityStructureOfFactorInstances - which is Into<RuleSet> (and time u32).

rule_set: ScryptoRuleSet,
timed_recovery_delay_in_minutes: u32,
}

impl AccessControllerFactorsAndTimeInput {
pub fn new(

Check warning on line 17 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L17

Added line #L17 was not covered by tests
security_structure_of_factor_instances: &SecurityStructureOfFactorInstances,
) -> Self {
let rule_set = ScryptoRuleSet::from(
security_structure_of_factor_instances
.matrix_of_factors
.clone(),

Check warning on line 23 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L21-L23

Added lines #L21 - L23 were not covered by tests
);

let timed_recovery_delay_in_minutes =
security_structure_of_factor_instances

Check warning on line 27 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L26-L27

Added lines #L26 - L27 were not covered by tests
.timed_recovery_delay_in_minutes();

Self {
rule_set,
timed_recovery_delay_in_minutes,
}
}
}

impl From<&AccessControllerFactorsAndTimeInput>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR rust style point: It's rare (although certainly not unheard of) to create a From from a reference, for a few reasons: (&x).into() looks ugly and is hard to discover; and if you already have an x, requiring a clone in the into is a small cost.

Often an alternative is a From impl on the type itself, and a .clone().into()... or a .to_x() method/extension not using From.

for ScryptoAccessControllerInitiateRecoveryAsRecoveryInput
{
fn from(value: &AccessControllerFactorsAndTimeInput) -> Self {

Check warning on line 40 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L40

Added line #L40 was not covered by tests
Self {
rule_set: value.rule_set.clone(),
timed_recovery_delay_in_minutes: Some(

Check warning on line 43 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L42-L43

Added lines #L42 - L43 were not covered by tests
value.timed_recovery_delay_in_minutes,
),
}
}
}

impl From<&AccessControllerFactorsAndTimeInput>
for ScryptoAccessControllerInitiateRecoveryAsPrimaryInput
{
fn from(value: &AccessControllerFactorsAndTimeInput) -> Self {

Check warning on line 53 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L53

Added line #L53 was not covered by tests
Self {
rule_set: value.rule_set.clone(),
timed_recovery_delay_in_minutes: Some(

Check warning on line 56 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L55-L56

Added lines #L55 - L56 were not covered by tests
value.timed_recovery_delay_in_minutes,
),
}
}
}

impl From<&AccessControllerFactorsAndTimeInput>
for ScryptoAccessControllerQuickConfirmRecoveryRoleRecoveryProposalInput
{
fn from(value: &AccessControllerFactorsAndTimeInput) -> Self {

Check warning on line 66 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L66

Added line #L66 was not covered by tests
Self {
rule_set: value.rule_set.clone(),
timed_recovery_delay_in_minutes: Some(

Check warning on line 69 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L68-L69

Added lines #L68 - L69 were not covered by tests
value.timed_recovery_delay_in_minutes,
),
}
}
}

impl From<&AccessControllerFactorsAndTimeInput>
for ScryptoAccessControllerQuickConfirmPrimaryRoleRecoveryProposalInput
{
fn from(value: &AccessControllerFactorsAndTimeInput) -> Self {

Check warning on line 79 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L79

Added line #L79 was not covered by tests
Self {
rule_set: value.rule_set.clone(),
timed_recovery_delay_in_minutes: Some(

Check warning on line 82 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L81-L82

Added lines #L81 - L82 were not covered by tests
value.timed_recovery_delay_in_minutes,
),
}
}
}

impl From<&AccessControllerFactorsAndTimeInput>
for ScryptoAccessControllerTimedConfirmRecoveryInput
{
fn from(value: &AccessControllerFactorsAndTimeInput) -> Self {

Check warning on line 92 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L92

Added line #L92 was not covered by tests
Self {
rule_set: value.rule_set.clone(),
timed_recovery_delay_in_minutes: Some(

Check warning on line 95 in crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/access_controller_factors_and_time_input.rs#L94-L95

Added lines #L94 - L95 were not covered by tests
value.timed_recovery_delay_in_minutes,
),
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![allow(dead_code)]
use profile_supporting_types::AnySecurifiedEntity;

use crate::prelude::*;
use std::ops::Deref;

use profile_supporting_types::AnySecurifiedEntity;

pub trait TransactionManifestSecurifySecurifiedEntity:
TransactionManifestSetRolaKey
@@ -10,61 +11,76 @@
securified_entity: AnySecurifiedEntity,
input: TransactionManifestApplySecurityShieldSecurifiedInput,
) -> Result<TransactionManifest>;

fn _update_shield_exercising_recovery_and_explicit_confirmation(
builder: ScryptoTransactionManifestBuilder,
securified_entity: &AnySecurifiedEntity,
input: &TransactionManifestApplySecurityShieldSecurifiedInput,
) -> Result<ScryptoTransactionManifestBuilder> {
todo!()
}
}

impl TransactionManifestSecurifySecurifiedEntity for TransactionManifest {
fn apply_security_shield_for_securified_entity(

Check warning on line 17 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L17

Added line #L17 was not covered by tests
securified_entity: AnySecurifiedEntity,
input: TransactionManifestApplySecurityShieldSecurifiedInput,
) -> Result<Self> {
let TransactionManifestApplySecurityShieldSecurifiedInput {
security_structure_of_factor_instances,
apply_shield_manifest_kind: kind,
} = input.clone();

Check warning on line 24 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L21-L24

Added lines #L21 - L24 were not covered by tests

let entity_address = securified_entity.entity.address();

Check warning on line 26 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L26

Added line #L26 was not covered by tests

let mut builder = ScryptoTransactionManifestBuilder::new();
// ACCESS_CONTROLLER_CREATE_PROOF_IDENT
let mut builder = TransactionManifest::produce_owner_badge(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does:

builder.call_method(
    access_controller_address.scrypto(),
    ACCESS_CONTROLLER_CREATE_PROOF_IDENT,
    (),
);

ScryptoTransactionManifestBuilder::new(),
&securified_entity.entity,

Check warning on line 31 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L30-L31

Added lines #L30 - L31 were not covered by tests
);

let access_controller_address = securified_entity
.securified_entity_control
.access_controller_address;

Check warning on line 36 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L34-L36

Added lines #L34 - L36 were not covered by tests

let factors_and_time_input = &AccessControllerFactorsAndTimeInput::new(
&security_structure_of_factor_instances,

Check warning on line 39 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L38-L39

Added lines #L38 - L39 were not covered by tests
);

use TransactionManifestApplySecurityShieldKindSelector::*;
builder = match kind {
PrimaryAndRecoveryWithExplicitConfirmation => Self::_update_shield_exercising_recovery_and_explicit_confirmation(builder, &securified_entity, &input)?,
PrimaryAndRecoveryWithTimedAutoConfirm => todo!(),
PrimaryAndExplicitConfirmation => todo!(),
PrimaryWithTimedAutoConfirm => todo!(),
RecoveryAndExplicitConfirmation => todo!(),
RecoveryWithTimedAutoConfirm => todo!(),
};
// INITIATE RECOVERY
let (init_method, init_input) =
kind.input_for_initialization(factors_and_time_input);
Copy link
Contributor

@Sajjon Sajjon Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on roles_combination: RolesExercisableInTransactionManifestCombination we use different roles for initialization of recovery (and the correct concrete scrypto "Input"-type (Box dyn-ed))

For details see roles_exercisable_in_transaction_manifest_combination.rs which was added by this PR

builder = builder.call_method(
access_controller_address.scrypto(),
init_method,
(init_input.deref(),),

Check warning on line 48 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L43-L48

Added lines #L43 - L48 were not covered by tests
);

// CONFIRM RECOVERY
// TODO: for timed, should we really call it here, now? Should
// we not call it AFTER the time has elapsed???
let (confirm_method, confirm_input) =
kind.input_for_confirm(factors_and_time_input);
builder = builder.call_method(
access_controller_address.scrypto(),
confirm_method,
(confirm_input.deref(),),

Check warning on line 59 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L54-L59

Added lines #L54 - L59 were not covered by tests
);

// Set Rola Key
let should_set_rola_key = security_structure_of_factor_instances
.authentication_signing_factor_instance
!= securified_entity
.current_authentication_signing_factor_instance();

Check warning on line 66 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L63-L66

Added lines #L63 - L66 were not covered by tests

if should_set_rola_key {
if kind.can_set_rola_key() {
builder = TransactionManifest::set_rola_key(
builder,
&security_structure_of_factor_instances
.authentication_signing_factor_instance,
&entity_address,

Check warning on line 74 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L68-L74

Added lines #L68 - L74 were not covered by tests
);
} else {
return Err(CommonError::Unknown); // TODO: new error variant

Check warning on line 77 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L77

Added line #L77 was not covered by tests
}
}

let manifest = TransactionManifest::sargon_built(
builder,
securified_entity.network_id(),

Check warning on line 83 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L82-L83

Added lines #L82 - L83 were not covered by tests
);

// N.B.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, although it's generally better to lock a fee of 0 and then edit it later. This provides a more accurate previewed fee.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Harder to modify later

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This provides a more accurate previewed fee.

@dhedey Wallet has logic to include the cost of the lock fee instruction in the total transaction fee

@@ -74,154 +90,6 @@
// after user has selected account to pay in wallet GUI.
// (and as usual also call `modify_manifest_lock_fee`)

Ok(manifest)

Check warning on line 93 in crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs

Codecov / codecov/patch

crates/transaction/manifests/src/manifests_security_shield/manifests_securify_shield_securified_entity.rs#L93

Added line #L93 was not covered by tests
}
}

impl TransactionManifestApplySecurityShieldKindSelector {
fn can_exercise_primary_role(&self) -> bool {
match self {
Self::PrimaryAndRecoveryWithExplicitConfirmation => true,
Self::PrimaryAndRecoveryWithTimedAutoConfirm => true,
Self::PrimaryAndExplicitConfirmation => true,
Self::PrimaryWithTimedAutoConfirm => true,
Self::RecoveryAndExplicitConfirmation => false,
Self::RecoveryWithTimedAutoConfirm => false,
}
}

fn can_set_rola_key(&self) -> bool {
self.can_exercise_primary_role()
}

fn should_confirm_recovery_with_explicit(&self) -> bool {
match self {
Self::PrimaryAndRecoveryWithExplicitConfirmation => true,
Self::PrimaryAndRecoveryWithTimedAutoConfirm => false,
Self::PrimaryAndExplicitConfirmation => true,
Self::PrimaryWithTimedAutoConfirm => false,
Self::RecoveryAndExplicitConfirmation => true,
Self::RecoveryWithTimedAutoConfirm => false,
}
}

fn should_confirm_recovery_with_time(&self) -> bool {
match self {
Self::PrimaryAndRecoveryWithExplicitConfirmation => false,
Self::PrimaryAndRecoveryWithTimedAutoConfirm => true,
Self::PrimaryAndExplicitConfirmation => false,
Self::PrimaryWithTimedAutoConfirm => true,
Self::RecoveryAndExplicitConfirmation => false,
Self::RecoveryWithTimedAutoConfirm => true,
}
}

fn should_confirm_recovery(&self) -> bool {
self.should_confirm_recovery_with_explicit()
|| self.should_confirm_recovery_with_time()
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum TransactionManifestApplySecurityShieldKindSelector {
/// (Primary Recovery Confirmation)
PrimaryAndRecoveryWithExplicitConfirmation,

/// (Primary Recovery Time)
PrimaryAndRecoveryWithTimedAutoConfirm,

/// (Primary Confirmation)
PrimaryAndExplicitConfirmation,

/// (Primary Time) ‼️ REQUIRES "Dugong" ‼️
PrimaryWithTimedAutoConfirm,

/// (Recovery Confirmation)
RecoveryAndExplicitConfirmation,

/// (Recovery Time)
RecoveryWithTimedAutoConfirm,
}

#[derive(Debug, Clone)]
pub struct TransactionManifestApplySecurityShieldAnyInput {
pub security_structure_of_factor_instances:
SecurityStructureOfFactorInstances,
pub apply_shield_manifest_kind:
Option<TransactionManifestApplySecurityShieldKindSelector>,
}
impl TransactionManifestApplySecurityShieldAnyInput {
fn new(
security_structure_of_factor_instances:
SecurityStructureOfFactorInstances,
apply_shield_manifest_kind: impl Into<
Option<TransactionManifestApplySecurityShieldKindSelector>,
>,
) -> Self {
Self {
security_structure_of_factor_instances,
apply_shield_manifest_kind: apply_shield_manifest_kind.into(),
}
}
pub fn for_securified(
security_structure_of_factor_instances:
SecurityStructureOfFactorInstances,
apply_shield_manifest_kind: TransactionManifestApplySecurityShieldKindSelector,
) -> Self {
Self::new(
security_structure_of_factor_instances,
apply_shield_manifest_kind,
)
}
pub fn as_securified(
&self,
) -> Result<TransactionManifestApplySecurityShieldSecurifiedInput> {
let apply_shield_manifest_kind = self
.apply_shield_manifest_kind
.clone()
.ok_or(CommonError::Unknown)?; // TODO: replace with proper error
Ok(TransactionManifestApplySecurityShieldSecurifiedInput {
security_structure_of_factor_instances: self
.security_structure_of_factor_instances
.clone(),
apply_shield_manifest_kind,
})
}
pub fn for_unsecurified(
security_structure_of_factor_instances:
SecurityStructureOfFactorInstances,
) -> Self {
Self::new(security_structure_of_factor_instances, None)
}

pub fn as_unsecurified(
&self,
) -> Result<TransactionManifestApplySecurityShieldUnsecurifiedInput> {
Ok(TransactionManifestApplySecurityShieldUnsecurifiedInput {
security_structure_of_factor_instances: self
.security_structure_of_factor_instances
.clone(),
})
}
}

#[derive(Debug, Clone)]
pub struct TransactionManifestApplySecurityShieldSecurifiedInput {
pub security_structure_of_factor_instances:
SecurityStructureOfFactorInstances,
pub apply_shield_manifest_kind:
TransactionManifestApplySecurityShieldKindSelector,
}

impl TransactionManifestApplySecurityShieldSecurifiedInput {
pub fn new(
security_structure_of_factor_instances:
SecurityStructureOfFactorInstances,
apply_shield_manifest_kind: TransactionManifestApplySecurityShieldKindSelector,
) -> Self {
Self {
security_structure_of_factor_instances,
apply_shield_manifest_kind,
}
}
}
Loading