Skip to content

Commit 5e77ece

Browse files
committed
fix
1 parent 6fdae93 commit 5e77ece

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

rust/catalyst-signed-doc-spec/src/signers/update.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
#[derive(serde::Deserialize)]
55
#[allow(clippy::missing_docs_in_private_items)]
66
pub struct Update {
7-
pub author: bool,
8-
pub collaborators: Collaborators,
7+
pub r#type: UpdatersType,
98
}
109

1110
#[derive(serde::Deserialize)]
1211
#[allow(clippy::missing_docs_in_private_items)]
1312
#[serde(rename_all = "lowercase")]
14-
pub enum Collaborators {
13+
pub enum UpdatersType {
1514
Collaborators,
1615
Ref,
17-
Excluded,
16+
Author,
1817
}

rust/signed_doc/src/validator/rules/ownership/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::collections::HashSet;
88
use anyhow::ensure;
99
use catalyst_signed_doc_spec::{
1010
is_required::IsRequired,
11-
signers::update::{Collaborators, Update},
11+
signers::update::{Update, UpdatersType},
1212
DocSpec,
1313
};
1414
use catalyst_types::catalyst_id::CatalystId;
@@ -26,7 +26,7 @@ pub(crate) enum DocumentOwnershipRule {
2626
/// Collaborators are allowed, based on the 'ref' metadata field.
2727
RefFieldBased,
2828
/// Collaborators are not allowed, only original author.
29-
WitoutCollaborators,
29+
OriginalAuthor,
3030
}
3131

3232
impl DocumentOwnershipRule {
@@ -35,17 +35,15 @@ impl DocumentOwnershipRule {
3535
spec: &Update,
3636
doc_spec: &DocSpec,
3737
) -> anyhow::Result<Self> {
38-
ensure!(spec.author, "'author' field must always be equal to `true`");
39-
40-
match spec.collaborators {
41-
Collaborators::Collaborators => {
38+
match spec.r#type {
39+
UpdatersType::Collaborators => {
4240
ensure!(
4341
doc_spec.metadata.collaborators.required != IsRequired::Excluded,
4442
"'collaborators' metadata field cannot be 'excluded' if 'update'->'collaborators' is 'collaborators' based"
4543
);
4644
Ok(Self::CollaboratorsFieldBased)
4745
},
48-
Collaborators::Ref => {
46+
UpdatersType::Ref => {
4947
ensure!(
5048
doc_spec.metadata.doc_ref.required == IsRequired::Yes,
5149
"'ref' metadata field cannot be 'excluded' or 'optional' if 'update'->'collaborators' is 'ref' based"
@@ -56,7 +54,7 @@ impl DocumentOwnershipRule {
5654
);
5755
Ok(Self::RefFieldBased)
5856
},
59-
Collaborators::Excluded => Ok(Self::WitoutCollaborators),
57+
UpdatersType::Author => Ok(Self::OriginalAuthor),
6058
}
6159
}
6260

rust/signed_doc/src/validator/rules/ownership/tests/without_collaborators.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async fn ownership_test(
127127

128128
let doc = doc_gen(&mut provider);
129129

130-
let res = DocumentOwnershipRule::WitoutCollaborators
130+
let res = DocumentOwnershipRule::OriginalAuthor
131131
.check(&doc, &provider)
132132
.await
133133
.unwrap();

0 commit comments

Comments
 (0)