Skip to content

Commit c73382b

Browse files
committed
feat(athena): shared types and functions
1 parent 2b4cb31 commit c73382b

File tree

43 files changed

+3192
-718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3192
-718
lines changed

hermes/apps/athena/Cargo.lock

Lines changed: 2828 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hermes/apps/athena/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[workspace]
2+
resolver = "2"
3+
members = ["shared", "modules/*"]

hermes/apps/athena/modules/Earthfile

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
VERSION 0.8
22

3-
# External Build Dependencies
4-
# ===========================
5-
# Import pre-configured build environments and tools from external repositories.
6-
# These provide standardized Rust toolchains, WASM compilation support, and CI/CD utilities.
7-
8-
# Catalyst CI Rust Environment - provides pre-configured Rust toolchain with WASM support
9-
# This includes: rustc, cargo, wasm32-wasip2 target, optimization tools, and build utilities
10-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.14 AS rust-ci
11-
12-
13-
# Alternative for local catalyst-ci debugging (uncomment when needed):
14-
# IMPORT ../../../catalyst-ci/earthly/rust AS rust-ci
15-
163
# WASI Bindings Generator - provides WebAssembly Interface Types (WIT) binding generation
174
# This generates Rust code from WIT files that define WebAssembly component interfaces
185
IMPORT ../../../../wasm/wasi AS wasi
@@ -89,10 +76,7 @@ gen-bindings:
8976
#
9077
# Duration: ~3-7 minutes total (depending on cache state and number of modules)
9178
# Output: All build artifacts ready for packaging and deployment
92-
build-all:
93-
# Build the Hermes runtime engine
94-
BUILD +get-local-hermes
95-
79+
build-all:
9680
# Build all WASM modules (currently just HTTP proxy, more coming soon)
9781
BUILD +build-http-proxy
9882

hermes/apps/athena/modules/http-proxy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
crate-type = ["cdylib"]
88

99
[dependencies]
10-
wit-bindgen = "0.43.0"
10+
shared = { path = "../../shared" }
1111
serde = { version = "1.0", features = ["derive"] }
1212
tracing = "0.1.41"
1313
regex = "1.10"

hermes/apps/athena/modules/http-proxy/Earthfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ IMPORT ../../../../ AS hermes
44
IMPORT ../../../../../wasm/wasi AS wasi
55

66
build-http-proxy:
7+
# TODO(no30bit): copy shared from workspace
78
DO wasi+BUILD_RUST_COMPONENT --wasi-src-dir=../../../../../wasm/wasi --out=http_proxy.wasm
89

910

hermes/apps/athena/modules/http-proxy/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@
2323
use regex::RegexSet;
2424
use std::sync::OnceLock;
2525

26-
use exports::hermes::http_gateway::event::{
27-
Bstr, Guest as _, Headers, HttpGatewayResponse, HttpResponse,
28-
};
26+
use exports::hermes::http_gateway::event::{Bstr, Headers, HttpGatewayResponse, HttpResponse};
2927

30-
wit_bindgen::generate!({
28+
shared::bindings_generate!({
3129
world: "hermes:app/hermes",
32-
path: "../../../wasi/wit",
30+
path: "../../../../../wasm/wasi/wit",
3331
inline: "
3432
package hermes:app;
3533
@@ -40,11 +38,11 @@ wit_bindgen::generate!({
4038
4139
}
4240
",
43-
generate_all,
41+
share: ["hermes:logging"],
4442
});
4543
export!(HttpProxyComponent);
4644

47-
use hermes::logging::api::{log, Level};
45+
use shared::bindings::hermes::logging::api::{log, Level};
4846

4947
/// What to do when a route pattern matches
5048
#[derive(Debug, Clone, Copy)]

hermes/apps/athena/modules/rbac-registration-indexer/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ edition = "2021"
77
crate-type = ["cdylib"]
88

99
[dependencies]
10-
wit-bindgen = "0.43.0"
10+
shared = { path = "../../shared" }
1111
anyhow = "1.0.98"
1212
serde_json = "1.0.142"
13-
strum = "0.27.2"
14-
strum_macros = "0.27.2"
1513

1614
cardano-blockchain-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs", tag = "cardano-blockchain-types/v0.0.6" }
1715
rbac-registration = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs", tag = "rbac-registration/v0.0.9" }

hermes/apps/athena/modules/rbac-registration-indexer/Earthfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ IMPORT ../../../../ AS hermes
44
IMPORT ../../../../../wasm/wasi AS wasi
55

66
build-rbac-registration-indexer:
7+
# TODO(no30bit): copy shared from workspace
78
DO wasi+BUILD_RUST_COMPONENT --wasi-src-dir=../../../../../wasm/wasi --out=rbac_registration_indexer.wasm
89

910
local-build-rbac-registration-indexer:

hermes/apps/athena/modules/rbac-registration-indexer/src/database/create.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
//! Create the database tables for RBAC registration.
22
3-
use crate::{
4-
database::{
5-
operation::Operation, query_builder::QueryBuilder, statement::DatabaseStatement,
6-
RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME,
7-
RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME,
8-
},
9-
hermes::sqlite::api::Sqlite,
3+
use shared::{
4+
bindings::hermes::sqlite::api::Sqlite,
5+
utils::sqlite::{operation::Operation, statement::DatabaseStatement},
6+
};
7+
8+
use crate::database::{
9+
query_builder::QueryBuilder, RBAC_REGISTRATION_PERSISTENT_TABLE_NAME,
10+
RBAC_REGISTRATION_VOLATILE_TABLE_NAME, RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME,
11+
RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME,
1012
};
1113

1214
/// Create a persistent `rbac_registration` and `rbac_stake_address` table.

hermes/apps/athena/modules/rbac-registration-indexer/src/database/delete/roll_back.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
//! Handle block rollback from volatile table.
22
3-
use crate::{
4-
database::{operation::Operation, query_builder::QueryBuilder, statement::DatabaseStatement},
5-
hermes::sqlite::api::{Sqlite, Statement},
3+
use shared::{
4+
bindings::hermes::sqlite::api::{Sqlite, Statement},
5+
utils::sqlite::{operation::Operation, statement::DatabaseStatement},
66
};
77

8+
use crate::database::query_builder::QueryBuilder;
9+
810
/// Prepare delete statement for deleting data when rollback happen from given volatile table.
911
pub(crate) fn prepare_roll_back_delete_from_volatile(
1012
sqlite: &Sqlite,

0 commit comments

Comments
 (0)