Skip to content

Commit 4cd818a

Browse files
authored
Revert to correct state (#285)
1 parent d310e78 commit 4cd818a

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

fplus-lib/src/core/mod.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,11 +2470,12 @@ impl LDNApplication {
24702470
let active_allocation = db_application_file.allocation.active();
24712471

24722472
if let Some(active_allocation) = active_allocation {
2473-
if active_allocation.signers.0.is_empty() {
2474-
db_application_file.lifecycle.state = AppState::ReadyToSign
2473+
// If there is an active allocation, set state based on signers
2474+
db_application_file.lifecycle.state = if active_allocation.signers.0.is_empty() {
2475+
AppState::ReadyToSign
24752476
} else {
2476-
db_application_file.lifecycle.state = AppState::StartSignDatacap
2477-
}
2477+
AppState::StartSignDatacap
2478+
};
24782479
} else if !db_application_file.lifecycle.is_active {
24792480
// If application is not active, we need to move it back to granted state and set last verifier and last active request
24802481
let last_active_request = Self::get_last_active_request(&db_application_file).ok_or(
@@ -2484,16 +2485,22 @@ impl LDNApplication {
24842485
.ok_or(LDNError::Load("Failed to get last verifier".to_string()))?;
24852486
db_application_file = db_application_file
24862487
.move_back_to_granted_state(&last_verifier, &last_active_request);
2487-
} else if let (Some(active_request), Some(sps_change_requests)) = (
2488-
db_application_file.lifecycle.active_request.as_ref(),
2489-
db_application_file.allowed_sps.as_ref(),
2490-
) {
2491-
if sps_change_requests
2492-
.get_active_change_request(active_request)
2493-
.is_some()
2494-
{
2495-
db_application_file.lifecycle.state = AppState::ChangingSP;
2496-
}
2488+
} else if db_application_file
2489+
.lifecycle
2490+
.active_request
2491+
.as_ref()
2492+
.and_then(|active_request| {
2493+
db_application_file
2494+
.allowed_sps
2495+
.as_ref()
2496+
.and_then(|sps_change_requests| {
2497+
sps_change_requests.get_active_change_request(active_request)
2498+
})
2499+
})
2500+
.is_some()
2501+
{
2502+
// If there is an active SPS change request, set state to ChangingSP
2503+
db_application_file.lifecycle.state = AppState::ChangingSP;
24972504
} else {
24982505
db_application_file.lifecycle.state = AppState::Granted;
24992506
}

0 commit comments

Comments
 (0)