Skip to content

Commit b2e3b43

Browse files
authored
feat(cat-gateway): Updated Catalyst Signed Document validation (#3466)
* change catalyst-signed-doc version * wip * define f15 uuids * cleanup * fix * wip * fix * cleanup * update test * wip * update f15 uuids * update test_signed_doc.py * fix tests * update templates() test
1 parent 3b91fc3 commit b2e3b43

File tree

14 files changed

+231
-90
lines changed

14 files changed

+231
-90
lines changed

β€Žcatalyst-gateway/Cargo.lockβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žcatalyst-gateway/bin/Cargo.tomlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ cardano-chain-follower = { version = "0.0.10", git = "https://github.com/input-o
1919
rbac-registration = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-chain-follower-v0.0.10" }
2020
catalyst-types = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250724-01" }
2121
cardano-blockchain-types = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250724-01" }
22-
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-chain-follower-v0.0.10" }
22+
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-signed-doc/v0.0.4-f15-rc" }
2323
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250724-01" }
2424

2525
pallas = { version = "0.33.0" }

β€Žcatalyst-gateway/bin/src/service/api/documents/common/mod.rsβ€Ž

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,13 @@ use std::collections::HashMap;
55

66
use catalyst_signed_doc::CatalystSignedDocument;
77

8-
use super::templates::get_doc_static_template;
8+
use super::templates::get_active_doc_static_template;
99
use crate::{
1010
db::event::{error::NotFoundError, signed_docs::FullSignedDoc},
1111
service::common::auth::rbac::token::CatalystRBACTokenV1,
1212
settings::Settings,
1313
};
1414

15-
/// Get document from the database
16-
pub(crate) async fn get_document(
17-
document_id: &uuid::Uuid,
18-
version: Option<&uuid::Uuid>,
19-
) -> anyhow::Result<CatalystSignedDocument> {
20-
// Find the doc in the static templates first
21-
if let Some(doc) = get_doc_static_template(document_id) {
22-
return Ok(doc);
23-
}
24-
25-
// If doesn't exist in the static templates, try to find it in the database
26-
let db_doc = FullSignedDoc::retrieve(document_id, version).await?;
27-
db_doc.raw().try_into()
28-
}
29-
3015
/// A struct which implements a
3116
/// `catalyst_signed_doc::providers::CatalystSignedDocumentProvider` trait
3217
pub(crate) struct DocProvider;
@@ -38,8 +23,14 @@ impl catalyst_signed_doc::providers::CatalystSignedDocumentProvider for DocProvi
3823
) -> anyhow::Result<Option<CatalystSignedDocument>> {
3924
let id = doc_ref.id.uuid();
4025
let ver = doc_ref.ver.uuid();
41-
match get_document(&id, Some(&ver)).await {
42-
Ok(doc) => Ok(Some(doc)),
26+
27+
// Find the doc in the static templates first
28+
if let Some(doc) = get_active_doc_static_template(&id) {
29+
return Ok(Some(doc));
30+
}
31+
32+
match FullSignedDoc::retrieve(&id, Some(&ver)).await {
33+
Ok(doc) => doc.raw().try_into().map(Some),
4334
Err(err) if err.is::<NotFoundError>() => Ok(None),
4435
Err(err) => Err(err),
4536
}

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use poem_openapi::ApiResponse;
44

5-
use super::common;
5+
use super::templates::get_doc_static_template;
66
use crate::{
7-
db::event::error::NotFoundError,
7+
db::event::{error::NotFoundError, signed_docs::FullSignedDoc},
88
service::common::{responses::WithErrorResponses, types::payload::cbor::Cbor},
99
};
1010

@@ -31,13 +31,16 @@ pub(crate) async fn endpoint(
3131
document_id: uuid::Uuid,
3232
version: Option<uuid::Uuid>,
3333
) -> AllResponses {
34-
match common::get_document(&document_id, version.as_ref()).await {
35-
Ok(doc) => {
36-
match doc.try_into() {
37-
Ok(doc_cbor_bytes) => Responses::Ok(Cbor(doc_cbor_bytes)).into(),
38-
Err(err) => AllResponses::handle_error(&err),
39-
}
40-
},
34+
// Find the doc in the static templates first
35+
if let Some(doc) = get_doc_static_template(&document_id) {
36+
return match doc.try_into() {
37+
Ok(doc_cbor_bytes) => Responses::Ok(Cbor(doc_cbor_bytes)).into(),
38+
Err(err) => AllResponses::handle_error(&err),
39+
};
40+
}
41+
42+
match FullSignedDoc::retrieve(&document_id, version.as_ref()).await {
43+
Ok(doc) => Responses::Ok(Cbor(doc.raw().to_vec())).into(),
4144
Err(err) if err.is::<NotFoundError>() => Responses::NotFound.into(),
4245
Err(err) => AllResponses::handle_error(&err),
4346
}

β€Žcatalyst-gateway/bin/src/service/api/documents/templates/docs/f14_comment_template.schema.jsonβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žcatalyst-gateway/bin/src/service/api/documents/templates/docs/proposal/f14_concept.schema.jsonβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žcatalyst-gateway/bin/src/service/api/documents/templates/docs/proposal/f14_developer.schema.jsonβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žcatalyst-gateway/bin/src/service/api/documents/templates/docs/proposal/f14_ecosystem.schema.jsonβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žcatalyst-gateway/bin/src/service/api/documents/templates/docs/proposal/f14_partner_product.schema.jsonβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žcatalyst-gateway/bin/src/service/api/documents/templates/docs/proposal/f14_proposal_template.schema.jsonβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
Β (0)