Skip to content

Commit

Permalink
Merge branch 'main' into feat/1414-rich-text-component
Browse files Browse the repository at this point in the history
  • Loading branch information
LynxLynxx authored Jan 17, 2025
2 parents 54d70b1 + 6358f6e commit 7d6a278
Show file tree
Hide file tree
Showing 154 changed files with 4,276 additions and 2,581 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:

jobs:
ci:
uses: input-output-hk/catalyst-forge/.github/workflows/ci.yml@ci/v1.5.1
uses: input-output-hk/catalyst-forge/.github/workflows/ci.yml@ci/v1.5.3
with:
forge_version: 0.8.0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/flutter-uikit-example-firebase-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Forge
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.5.3
with:
version: 0.8.0
- name: Setup CI
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.5.3
- name: Build Flutter Web
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.3
if: always()
continue-on-error: true
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,40 @@ jobs:
- uses: actions/checkout@v4

- name: Install Forge
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.5.3
with:
version: 0.8.0
if: always()

- name: Setup CI
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.5.3

- name: Get catalyst gateway unit test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.3
if: always()
continue-on-error: true
with:
command: run
args: ./catalyst-gateway+build

- name: Get schemathesis test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.3
if: always()
continue-on-error: true
with:
command: run
args: ./catalyst-gateway/tests/schemathesis_tests+test-fuzzer-api

- name: Get flutter unit test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.3
if: always()
continue-on-error: true
with:
command: run
args: ./catalyst_voices+test-unit

- name: Get python api test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.1
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.3
if: always()
continue-on-error: true
with:
Expand Down
4 changes: 4 additions & 0 deletions catalyst-gateway/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ workspace = true
cardano-chain-follower = {version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag="v0.0.10" }
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.3" }
rbac-registration = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.8" }
catalyst-signed-doc = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250116-00" }


pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
pallas-traverse = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
Expand Down Expand Up @@ -98,6 +100,8 @@ regex = "1.11.1"
minijinja = "2.5.0"
bytes = "1.9.0"
mime = "0.3.17"
stats_alloc = "0.1.10"
memory-stats = "1.0.0"

[dev-dependencies]
proptest = "1.5.0"
Expand Down
28 changes: 18 additions & 10 deletions catalyst-gateway/bin/src/db/event/signed_docs/full_signed_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ impl FullSignedDoc {

/// Returns the document author.
#[allow(dead_code)]
pub(crate) fn author(&self) -> &String {
self.body.author()
pub(crate) fn authors(&self) -> &Vec<String> {
self.body.authors()
}

/// Returns the `SignedDocBody`.
Expand All @@ -57,7 +57,15 @@ impl FullSignedDoc {
&self.body
}

/// Returns the document raw bytes.
#[allow(dead_code)]
pub(crate) fn raw(&self) -> &Vec<u8> {
&self.raw
}

/// Uploads a `FullSignedDoc` to the event db.
/// Returns `true` if document was added into the db, `false` if it was already added
/// previously.
///
/// Make an insert query into the `event-db` by adding data into the `signed_docs`
/// table.
Expand All @@ -73,21 +81,21 @@ impl FullSignedDoc {
/// - `ver` is a UUID v7
/// - `doc_type` is a UUID v4
#[allow(dead_code)]
pub(crate) async fn store(&self) -> anyhow::Result<()> {
pub(crate) async fn store(&self) -> anyhow::Result<bool> {
match Self::retrieve(self.id(), Some(self.ver())).await {
Ok(res_doc) => {
anyhow::ensure!(
&res_doc == self,
"Document with the same `id` and `ver` already exists"
);
return Ok(());
Ok(false)
},
Err(err) if err.is::<NotFoundError>() => {},
Err(err) => return Err(err),
Err(err) if err.is::<NotFoundError>() => {
EventDB::modify(INSERT_SIGNED_DOCS, &self.postgres_db_fields()).await?;
Ok(true)
},
Err(err) => Err(err),
}

EventDB::modify(INSERT_SIGNED_DOCS, &self.postgres_db_fields()).await?;
Ok(())
}

/// Loads a `FullSignedDoc` from the event db.
Expand Down Expand Up @@ -146,7 +154,7 @@ impl FullSignedDoc {
*id,
ver,
row.try_get("type")?,
row.try_get("author")?,
row.try_get("authors")?,
row.try_get("metadata")?,
),
payload: row.try_get("payload")?,
Expand Down
4 changes: 2 additions & 2 deletions catalyst-gateway/bin/src/db/event/signed_docs/query_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) enum DocsQueryFilter {
DocId(uuid::Uuid),
/// Select docs with the specific `id` and `ver` field
DocVer(uuid::Uuid, uuid::Uuid),
/// Select docs with the specific `author` field
/// Select docs with the specific `authors` field
Author(String),
}

Expand All @@ -26,7 +26,7 @@ impl Display for DocsQueryFilter {
Self::DocVer(id, ver) => {
write!(f, "signed_docs.id = '{id}' AND signed_docs.ver = '{ver}'")
},
Self::Author(author) => write!(f, "signed_docs.author = '{author}'"),
Self::Author(author) => write!(f, "signed_docs.authors @> '{{ \"{author}\" }}'"),
}
}
}
21 changes: 10 additions & 11 deletions catalyst-gateway/bin/src/db/event/signed_docs/signed_doc_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub(crate) struct SignedDocBody {
ver: uuid::Uuid,
/// `signed_doc` table `type` field
doc_type: uuid::Uuid,
/// `signed_doc` table `author` field
author: String,
/// `signed_doc` table `authors` field
authors: Vec<String>,
/// `signed_doc` table `metadata` field
metadata: Option<serde_json::Value>,
}
Expand All @@ -40,9 +40,9 @@ impl SignedDocBody {
&self.ver
}

/// Returns the document author.
pub(crate) fn author(&self) -> &String {
&self.author
/// Returns the document authors.
pub(crate) fn authors(&self) -> &Vec<String> {
&self.authors
}

/// Returns all signed document fields for the event db queries
Expand All @@ -51,22 +51,21 @@ impl SignedDocBody {
&self.id,
&self.ver,
&self.doc_type,
&self.author,
&self.authors,
&self.metadata,
]
}

/// Creates a `SignedDocBody` instance.
#[allow(dead_code)]
pub(crate) fn new(
id: uuid::Uuid, ver: uuid::Uuid, doc_type: uuid::Uuid, author: String,
id: uuid::Uuid, ver: uuid::Uuid, doc_type: uuid::Uuid, authors: Vec<String>,
metadata: Option<serde_json::Value>,
) -> Self {
Self {
id,
ver,
doc_type,
author,
authors,
metadata,
}
}
Expand All @@ -91,13 +90,13 @@ impl SignedDocBody {
let id = row.try_get("id")?;
let ver = row.try_get("ver")?;
let doc_type = row.try_get("type")?;
let author = row.try_get("author")?;
let authors = row.try_get("authors")?;
let metadata = row.try_get("metadata")?;
Ok(Self {
id,
ver,
doc_type,
author,
authors,
metadata,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SELECT
signed_docs.id,
signed_docs.ver,
signed_docs.type,
signed_docs.author,
signed_docs.authors,
signed_docs.metadata
FROM signed_docs
WHERE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ INSERT INTO signed_docs
id,
ver,
type,
author,
authors,
metadata,
payload,
raw
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SELECT
{% if not ver %} signed_docs.ver, {% endif %}
signed_docs.type,
signed_docs.author,
signed_docs.authors,
signed_docs.metadata,
signed_docs.payload,
signed_docs.raw
Expand Down
20 changes: 13 additions & 7 deletions catalyst-gateway/bin/src/db/event/signed_docs/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn queries_test() {
uuid::Uuid::now_v7(),
uuid::Uuid::now_v7(),
doc_type,
"Alex".to_string(),
vec!["Alex".to_string()],
Some(serde_json::Value::Null),
),
Some(serde_json::Value::Null),
Expand All @@ -29,7 +29,7 @@ async fn queries_test() {
uuid::Uuid::now_v7(),
uuid::Uuid::now_v7(),
doc_type,
"Steven".to_string(),
vec!["Steven".to_string()],
Some(serde_json::Value::Null),
),
Some(serde_json::Value::Null),
Expand All @@ -40,7 +40,7 @@ async fn queries_test() {
uuid::Uuid::now_v7(),
uuid::Uuid::now_v7(),
doc_type,
"Sasha".to_string(),
vec!["Sasha".to_string()],
None,
),
None,
Expand All @@ -49,12 +49,18 @@ async fn queries_test() {
];

for doc in &docs {
doc.store().await.unwrap();
assert!(doc.store().await.unwrap());
// try to insert the same data again
doc.store().await.unwrap();
assert!(!doc.store().await.unwrap());
// try another doc with the same `id` and `ver` and with different other fields
let another_doc = FullSignedDoc::new(
SignedDocBody::new(*doc.id(), *doc.ver(), doc_type, "Neil".to_string(), None),
SignedDocBody::new(
*doc.id(),
*doc.ver(),
doc_type,
vec!["Neil".to_string()],
None,
),
None,
vec![],
);
Expand Down Expand Up @@ -87,7 +93,7 @@ async fn queries_test() {
assert!(res_docs.try_next().await.unwrap().is_none());

let mut res_docs = SignedDocBody::retrieve(
&DocsQueryFilter::Author(doc.author().clone()),
&DocsQueryFilter::Author(doc.authors().first().unwrap().clone()),
&QueryLimits::ALL,
)
.await
Expand Down
Loading

0 comments on commit 7d6a278

Please sign in to comment.