diff --git a/nym-vpn-core/crates/nym-vpn-account-controller/src/commands/request_zknym.rs b/nym-vpn-core/crates/nym-vpn-account-controller/src/commands/request_zknym.rs index 998db6ed35..a77164286e 100644 --- a/nym-vpn-core/crates/nym-vpn-account-controller/src/commands/request_zknym.rs +++ b/nym-vpn-core/crates/nym-vpn-account-controller/src/commands/request_zknym.rs @@ -671,11 +671,18 @@ async fn import_zk_nym( .get_partial_verification_keys(shares.epoch_id, vpn_api_client) .await?; - let master_vk = credential_storage + let master_vk = if let Some(stored_master_vk) = credential_storage .get_master_verification_key(shares.epoch_id) .await .map_err(|err| RequestZkNymError::CredentialStorage(err.to_string()))? - .ok_or(RequestZkNymError::NoMasterVerificationKeyInStorage)?; + { + stored_master_vk + } else { + tracing::error!("No master verification key in storage"); + // TODO: implement fetching the missing master verification key from nym-vpn-api. + // As of writing this, that endpoint does not yet exist. + return Err(RequestZkNymError::NoMasterVerificationKeyInStorage); + }; let ticketbook_type = response .ticketbook_type @@ -694,18 +701,29 @@ async fn import_zk_nym( .await?; // Check that we have the signatures we need to import - // TODO: fetch them if we don't - let _ = credential_storage + if credential_storage .get_coin_index_signatures(shares.epoch_id) .await .map_err(|err| RequestZkNymError::CredentialStorage(err.to_string()))? - .ok_or(RequestZkNymError::NoCoinIndexSignaturesInStorage)?; + .is_none() + { + tracing::error!("No coin index signatures in storage"); + // TODO: implement fetching the missing signatures from nym-vpn-api. As of writing this, + // that endpoint does not yet exist. + return Err(RequestZkNymError::NoCoinIndexSignaturesInStorage); + } - let _ = credential_storage + if credential_storage .get_expiration_date_signatures(pending_request.expiration_date) .await .map_err(|err| RequestZkNymError::CredentialStorage(err.to_string()))? - .ok_or(RequestZkNymError::NoExpirationDateSignaturesInStorage)?; + .is_none() + { + tracing::error!("No expiration date signatures in storage"); + // TODO: implement fetching the missing signatures from nym-vpn-api. As of writing this, + // that endpoint does not yet exist. + return Err(RequestZkNymError::NoExpirationDateSignaturesInStorage); + } tracing::info!("Inserting issued ticketbook"); credential_storage diff --git a/nym-vpn-core/crates/nym-vpn-account-controller/src/storage/credentials/mod.rs b/nym-vpn-core/crates/nym-vpn-account-controller/src/storage/credentials/mod.rs index 76be2d05bb..ae4e1a0b5a 100644 --- a/nym-vpn-core/crates/nym-vpn-account-controller/src/storage/credentials/mod.rs +++ b/nym-vpn-core/crates/nym-vpn-account-controller/src/storage/credentials/mod.rs @@ -27,9 +27,7 @@ use crate::{error::Error, AvailableTicketbooks}; #[derive(Clone)] pub(crate) struct VpnCredentialStorage { data_dir: PathBuf, - credential_storage: PersistentCredentialStorage, - pending_requests_storage: PendingCredentialRequestsStorage, } @@ -214,9 +212,6 @@ impl VpnCredentialStorage { pub(crate) async fn insert_pending_request( &self, pending_request: PendingCredentialRequest, - //id: &str, - //expiration_date: Date, - //request_info: &RequestInfo, ) -> Result<(), Error> { self.pending_requests_storage .insert_pending_request(pending_request)