Skip to content

Commit 32a6a06

Browse files
fix(cat-gateway): Update Document references (#2229)
* fix(rust/signed-doc): use catalyst-libs from working branch * fix(rust/signed-doc): update docref type usage * fix(cat-gateway): update catalyst-libs tag * fix(cat-gateway): fix missing associated constant * fix(cat-gateway): restore API surface * restore optional version in query * fix(cat-gateway): Use ID as version for category, campain and brand * fix(cat-gateway): fix signed doc json doc refs * bump ver * wip * revert --------- Co-authored-by: Mr-Leshiy <[email protected]>
1 parent 7f0455d commit 32a6a06

File tree

6 files changed

+40
-20
lines changed

6 files changed

+40
-20
lines changed

catalyst-gateway/bin/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ repository.workspace = true
1515
workspace = true
1616

1717
[dependencies]
18-
cardano-chain-follower = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
19-
rbac-registration = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
20-
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
21-
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
22-
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
23-
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
18+
cardano-chain-follower = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
19+
rbac-registration = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
20+
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
21+
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
22+
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
23+
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
2424

2525
pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
2626
pallas-traverse = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }

catalyst-gateway/bin/src/service/api/documents/get_document.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ impl catalyst_signed_doc::providers::CatalystSignedDocumentProvider for DocProvi
6565
&self, doc_ref: &catalyst_signed_doc::DocumentRef,
6666
) -> anyhow::Result<Option<CatalystSignedDocument>> {
6767
let id = doc_ref.id.uuid();
68-
let ver = doc_ref.ver.map(|uuid| uuid.uuid());
69-
match get_document(&id, ver.as_ref()).await {
68+
let ver = doc_ref.ver.uuid();
69+
match get_document(&id, Some(&ver)).await {
7070
Ok(doc) => Ok(Some(doc)),
7171
Err(err) if err.is::<NotFoundError>() => Ok(None),
7272
Err(err) => Err(err),

catalyst-gateway/bin/src/service/api/documents/templates/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ use uuid::Uuid;
1212

1313
/// Catalyst brand ID.
1414
const BRAND_ID: &str = "0194cfcd-bddc-7bb3-b5e9-455168bd3ff7";
15+
/// Catalyst brand Version (same as ID).
16+
const BRAND_VERSION: &str = BRAND_ID;
1517

1618
/// Fund 14 Campaign ID.
1719
const CAMPAIGN_ID: &str = "0194cfcf-15a2-7e32-b559-386b93d0724e";
20+
/// Fund 14 Campaign Version (Same as ID).
21+
const CAMPAIGN_VERSION: &str = CAMPAIGN_ID;
1822

1923
/// A map of signed document templates to its ID.
2024
pub(crate) static TEMPLATES: LazyLock<Option<HashMap<Uuid, CatalystSignedDocument>>> =
@@ -96,11 +100,11 @@ fn build_signed_doc(data: &SignedDocData, sk: &SigningKey) -> (Uuid, CatalystSig
96100
"type": data.doc_type,
97101
"id": data.id,
98102
"ver": data.ver,
99-
"category_id": data.category_id.map(|v| serde_json::json!({"id": v})),
103+
"category_id": data.category_id.map(|v| serde_json::json!({"id": v, "ver": v })),
100104
"content-type": ContentType::Json.to_string(),
101105
"content-encoding": ContentEncoding::Brotli.to_string(),
102-
"campaign_id": {"id": CAMPAIGN_ID},
103-
"brand_id": {"id": BRAND_ID},
106+
"campaign_id": {"id": CAMPAIGN_ID, "ver": CAMPAIGN_VERSION},
107+
"brand_id": {"id": BRAND_ID, "ver": BRAND_VERSION},
104108
});
105109

106110
let kid = IdUri::new(KID_NETWORK, None, sk.verifying_key());

catalyst-gateway/bin/src/service/common/auth/rbac/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl CatalystRBACTokenV1 {
9696
return Err(anyhow!("Catalyst ID must have nonce"));
9797
}
9898
let (role, rotation) = catalyst_id.role_and_rotation();
99-
if role != RoleIndex::DEFAULT {
99+
if role != RoleIndex::ROLE_0 {
100100
return Err(anyhow!("Catalyst ID mustn't have role specified"));
101101
}
102102
if rotation != KeyRotation::DEFAULT {

catalyst-gateway/bin/src/service/common/types/document/doc_ref.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ pub(crate) struct DocumentReference {
204204
doc_id: DocumentId,
205205
/// Document Version
206206
#[oai(skip_serializing_if_is_none)]
207-
ver: Option<DocumentVer>,
207+
ver: DocumentVer,
208208
}
209209

210210
impl Example for DocumentReference {
211211
fn example() -> Self {
212212
Self {
213213
doc_id: DocumentId::example(),
214-
ver: Some(DocumentVer::example()),
214+
ver: DocumentVer::example(),
215215
}
216216
}
217217
}
@@ -220,7 +220,7 @@ impl From<catalyst_signed_doc::DocumentRef> for DocumentReference {
220220
fn from(value: catalyst_signed_doc::DocumentRef) -> Self {
221221
Self {
222222
doc_id: value.id.into(),
223-
ver: value.ver.map(Into::into),
223+
ver: value.ver.into(),
224224
}
225225
}
226226
}

catalyst-gateway/tests/api_tests/integration/test_signed_doc.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def proposal_doc_factory(proposal_templates, rbac_auth_token_factory):
7070
def __proposal_doc_factory() -> SignedDocument:
7171
rbac_auth_token = rbac_auth_token_factory()
7272
proposal_doc_id = uuid_v7.uuid_v7()
73+
category_id = "0194d490-30bf-7473-81c8-a0eaef369619"
7374
proposal_metadata_json = {
7475
"id": proposal_doc_id,
7576
"ver": proposal_doc_id,
@@ -78,9 +79,15 @@ def __proposal_doc_factory() -> SignedDocument:
7879
"content-type": "application/json",
7980
"content-encoding": "br",
8081
# referenced to the defined proposal template id, comes from the 'templates/data.rs' file
81-
"template": {"id": proposal_templates[0]},
82+
"template": {
83+
"id": proposal_templates[0],
84+
"ver": proposal_templates[0],
85+
},
8286
# referenced to the defined category id, comes from the 'templates/data.rs' file
83-
"category_id": {"id": "0194d490-30bf-7473-81c8-a0eaef369619"},
87+
"category_id": {
88+
"id": category_id,
89+
"ver": category_id,
90+
},
8491
}
8592
with open("./test_data/signed_docs/proposal.json", "r") as proposal_json_file:
8693
proposal_json = json.load(proposal_json_file)
@@ -112,8 +119,14 @@ def __comment_doc_factory() -> SignedDocument:
112119
"type": "b679ded3-0e7c-41ba-89f8-da62a17898ea",
113120
"content-type": "application/json",
114121
"content-encoding": "br",
115-
"ref": {"id": proposal_doc.metadata["id"]},
116-
"template": {"id": comment_templates[0]},
122+
"ref": {
123+
"id": proposal_doc.metadata["id"],
124+
"ver": proposal_doc.metadata["ver"],
125+
},
126+
"template": {
127+
"id": comment_templates[0],
128+
"ver": comment_templates[0],
129+
},
117130
}
118131
with open("./test_data/signed_docs/comment.json", "r") as comment_json_file:
119132
comment_json = json.load(comment_json_file)
@@ -145,7 +158,10 @@ def __submission_action_factory() -> SignedDocument:
145158
"type": "5e60e623-ad02-4a1b-a1ac-406db978ee48",
146159
"content-type": "application/json",
147160
"content-encoding": "br",
148-
"ref": {"id": proposal_doc.metadata["id"]},
161+
"ref": {
162+
"id": proposal_doc.metadata["id"],
163+
"ver": proposal_doc.metadata["ver"],
164+
},
149165
}
150166
with open(
151167
"./test_data/signed_docs/submission_action.json", "r"

0 commit comments

Comments
 (0)