Skip to content

Commit

Permalink
Fixed integrity lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Aug 9, 2024
1 parent ff0da33 commit a0eec3d
Showing 1 changed file with 15 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn validate_agent_joining(_agent_pub_key: AgentPubKey, _membrane_proof: &Opt
/// - If the `Op` is an update, the original entry exists and is of the same type as the new one
/// - If the `Op` is a delete link, the original action exists and is a `CreateLink` action
/// - Link tags don't exceed the maximum tag size (currently 1KB)
/// - Countersigned entries include an action from each required signer
/// - Countersigned entries include an action from each required signer
///
/// You can read more about validation here: https://docs.rs/hdi/latest/hdi/index.html#data-validation
#[hdk_extern]
Expand All @@ -53,45 +53,33 @@ pub fn validate(op: Op) -> ExternResult<ValidateCallbackResult> {
_ => Ok(ValidateCallbackResult::Valid)
},
FlatOp::RegisterUpdate(update_entry) => match update_entry {
OpUpdate::Entry {
original_action,
original_app_entry,
app_entry,
action
} => Ok(ValidateCallbackResult::Invalid(
"There are no entry types in this integrity zome".to_string(),
)),
OpUpdate::Entry { app_entry, action } => {
Ok(ValidateCallbackResult::Invalid(
"There are no entry types in this integrity zome".to_string(),
))
},
_ => Ok(ValidateCallbackResult::Valid)
},
FlatOp::RegisterDelete(delete_entry) => match delete_entry {
OpDelete::Entry {
original_action,
original_app_entry,
action
} => Ok(ValidateCallbackResult::Invalid(
"There are no entry types in this integrity zome".to_string(),
)),
_ => Ok(ValidateCallbackResult::Valid),
},
FlatOp::RegisterDelete(delete_entry) => Ok(ValidateCallbackResult::Invalid(
"There are no entry types in this integrity zome".to_string(),
)),
FlatOp::RegisterCreateLink {
link_type,
base_address,
target_address,
tag,
action
} => Ok(ValidateCallbackResult::Invalid(String::from(
"There are no link types in this integrity zome",
))),
} => Ok(ValidateCallbackResult::Invalid(
"There are no link types in this integrity zome".to_string()
)),
FlatOp::RegisterDeleteLink {
link_type,
base_address,
target_address,
tag,
original_action,
action
} => Ok(ValidateCallbackResult::Invalid(String::from(
"There are no link types in this integrity zome",
))),
} => Ok(ValidateCallbackResult::Invalid("There are no link types in this integrity zome".to_string())),
FlatOp::StoreRecord(store_record) => match store_record {
/// Complementary validation to the `StoreEntry` 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 `StoreEntry`
Expand Down Expand Up @@ -135,8 +123,8 @@ pub fn validate(op: Op) -> ExternResult<ValidateCallbackResult> {
base_address,
action
} => Ok(ValidateCallbackResult::Invalid("There are no link types in this integrity zome".to_string())),
OpRecord::CreatePrivateEntry { .. }=> Ok(ValidateCallbackResult::Valid),
OpRecord::UpdatePrivateEntry { .. }=> Ok(ValidateCallbackResult::Valid),
OpRecord::CreatePrivateEntry { .. } => Ok(ValidateCallbackResult::Valid),
OpRecord::UpdatePrivateEntry { .. } => Ok(ValidateCallbackResult::Valid),
OpRecord::CreateCapClaim { .. } => Ok(ValidateCallbackResult::Valid),
OpRecord::CreateCapGrant { .. } => Ok(ValidateCallbackResult::Valid),
OpRecord::UpdateCapClaim { .. } => Ok(ValidateCallbackResult::Valid),
Expand All @@ -162,4 +150,3 @@ pub fn validate(op: Op) -> ExternResult<ValidateCallbackResult> {
},
}
}

0 comments on commit a0eec3d

Please sign in to comment.