From 7cea1ce281134eb2e287d603dd6aeaddfbee801d Mon Sep 17 00:00:00 2001 From: ThetaSinner Date: Thu, 29 Feb 2024 01:28:54 +0000 Subject: [PATCH] Lint and format --- .../integrity/trusted/src/key_collection.rs | 56 +++++++++---------- .../zomes/integrity/trusted/src/lib.rs | 14 ++++- ui/src/component/LoadingSpinner.vue | 2 - ui/src/trusted/trusted/KeyCollections.vue | 7 ++- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/dnas/trusted/zomes/integrity/trusted/src/key_collection.rs b/dnas/trusted/zomes/integrity/trusted/src/key_collection.rs index 743ec58..bc078e0 100644 --- a/dnas/trusted/zomes/integrity/trusted/src/key_collection.rs +++ b/dnas/trusted/zomes/integrity/trusted/src/key_collection.rs @@ -221,53 +221,51 @@ pub fn validate_delete_key_collection_to_gpg_key_dist_link( let action: Action = action.clone().into(); hash_action(action)? }; - let activity = must_get_agent_activity(action.author, ChainFilter::new(action_hash).until(original_action_hash))?; + let activity = must_get_agent_activity( + action.author, + ChainFilter::new(action_hash).until(original_action_hash), + )?; - // Look for the reverse create link, needed to find the associated delete. let reverse_link_type = { let scoped_link_type: ScopedLinkType = LinkTypes::GpgKeyDistToKeyCollection.try_into()?; scoped_link_type.zome_type }; - let matched_gpg_key_dist_to_collection_creates = activity.iter().filter(|agent_activity| { - match agent_activity.action.action() { - Action::CreateLink(CreateLink { - link_type, - tag, - .. - }) if *link_type == reverse_link_type && *tag == original_action.tag => true, - _ => false, - } - }).collect::>(); + let matched_gpg_key_dist_to_collection_creates = activity + .iter() + .filter(|agent_activity| matches!(agent_activity.action.action(), Action::CreateLink(CreateLink { link_type, tag, .. }) if *link_type == reverse_link_type && *tag == original_action.tag)) + .collect::>(); if matched_gpg_key_dist_to_collection_creates.len() > 1 { return Ok(ValidateCallbackResult::Invalid( - "Found duplicate create links to delete, this should have been prevented on create".to_string(), + "Found duplicate create links to delete, this should have been prevented on create" + .to_string(), )); } - if matched_gpg_key_dist_to_collection_creates.len() == 0 { + if matched_gpg_key_dist_to_collection_creates.is_empty() { return Ok(ValidateCallbackResult::Invalid( "The create link to delete does not exist".to_string(), )); } - let reverse_create = matched_gpg_key_dist_to_collection_creates.first().ok_or_else(|| { - wasm_error!(WasmErrorInner::Guest( - "The create link to delete does not exist".to_string() - )) - })?; + let reverse_create = matched_gpg_key_dist_to_collection_creates + .first() + .ok_or_else(|| { + wasm_error!(WasmErrorInner::Guest( + "The create link to delete does not exist".to_string() + )) + })?; let reverse_create_hash = reverse_create.action.as_hash(); - let match_gpg_key_dist_to_collection_deletes = activity.iter().filter(|agent_activity| { - match agent_activity.action.action() { - Action::DeleteLink(DeleteLink { - link_add_address, - .. - }) if link_add_address == reverse_create_hash => true, - _ => false, - } - }).collect::>(); + let match_gpg_key_dist_to_collection_deletes = activity + .iter() + .filter(|agent_activity| { + matches!(agent_activity.action.action(), Action::DeleteLink(DeleteLink { + link_add_address, .. + }) if link_add_address == reverse_create_hash) + }) + .collect::>(); if match_gpg_key_dist_to_collection_deletes.len() > 1 { return Ok(ValidateCallbackResult::Invalid( @@ -275,7 +273,7 @@ pub fn validate_delete_key_collection_to_gpg_key_dist_link( )); } - if match_gpg_key_dist_to_collection_deletes.len() == 0 { + if match_gpg_key_dist_to_collection_deletes.is_empty() { return Ok(ValidateCallbackResult::Invalid( "Missing associated reverse deletion".to_string(), )); diff --git a/dnas/trusted/zomes/integrity/trusted/src/lib.rs b/dnas/trusted/zomes/integrity/trusted/src/lib.rs index 0462e6b..8c76e8e 100644 --- a/dnas/trusted/zomes/integrity/trusted/src/lib.rs +++ b/dnas/trusted/zomes/integrity/trusted/src/lib.rs @@ -161,7 +161,12 @@ pub fn validate(op: Op) -> ExternResult { ) } }, - FlatOp::RegisterDeleteLink { link_type, original_action, action, .. } => match link_type { + FlatOp::RegisterDeleteLink { + link_type, + original_action, + action, + .. + } => match link_type { LinkTypes::GpgKeyDistToKeyCollection => { key_collection::validate_delete_gpg_key_dist_to_key_collection_link( original_action, @@ -174,7 +179,10 @@ pub fn validate(op: Op) -> ExternResult { action, ) } - lt => Ok(ValidateCallbackResult::Invalid(format!("Link type [{:?}] cannot be deleted", lt))), + lt => Ok(ValidateCallbackResult::Invalid(format!( + "Link type [{:?}] cannot be deleted", + lt + ))), }, FlatOp::StoreRecord(store_record) => { match store_record { @@ -349,7 +357,7 @@ pub fn validate(op: Op) -> ExternResult { // Complementary validation to the `RegisterDeleteLink` Op, in which the record itself is validated // If you want to optimize performance, you can remove the validation for an entry type here and keep it in `RegisterDeleteLink` // Notice that doing so will cause `must_get_valid_record` for this record to return a valid record even if the `RegisterDeleteLink` validation failed - OpRecord::DeleteLink { .. } => Ok(ValidateCallbackResult::Valid), + OpRecord::DeleteLink { .. } => Ok(ValidateCallbackResult::Valid), OpRecord::CreatePrivateEntry { .. } => Ok(ValidateCallbackResult::Valid), OpRecord::UpdatePrivateEntry { .. } => Ok(ValidateCallbackResult::Valid), OpRecord::CreateCapClaim { .. } => Ok(ValidateCallbackResult::Valid), diff --git a/ui/src/component/LoadingSpinner.vue b/ui/src/component/LoadingSpinner.vue index 00f2990..e91a99b 100644 --- a/ui/src/component/LoadingSpinner.vue +++ b/ui/src/component/LoadingSpinner.vue @@ -1,9 +1,7 @@