mirror of
https://github.com/Such-Software/smirk-backend-core.git
synced 2026-10-17 07:21:32 +02:00
feat: wire chain clients into AppState (feature-gated)
Add ChainClients (infra/chains.rs): per-chain data-source handles built once at startup from config and shared via AppState. Each client is present only when its chain feature flag is on, and a malformed chain endpoint now fails startup (fail-closed) rather than the first request. Cloneable (grin's session state is shared via Arc) so it lives in the cloneable AppState. Foundation for the wallet-handlers phase — handlers will read these clients from State. No endpoints yet (openapi unchanged).
This commit is contained in:
+4
-1
@@ -9,7 +9,8 @@ use std::sync::Arc;
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
|
||||
use smirk_backend_core::{
|
||||
build_router, config::Config, core::session::SessionManager, infra::db::Database, AppState,
|
||||
build_router, config::Config, core::session::SessionManager, infra::chains::ChainClients,
|
||||
infra::db::Database, AppState,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -33,12 +34,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
config.secrets.ip_salt.clone(),
|
||||
);
|
||||
let sessions = SessionManager::new(&config.auth.jwt_secret, config.auth.jwt_expiry_hours);
|
||||
let chains = ChainClients::from_config(&config)?;
|
||||
|
||||
let addr = format!("{}:{}", config.server_host, config.server_port);
|
||||
let state = Arc::new(AppState {
|
||||
config,
|
||||
db,
|
||||
sessions,
|
||||
chains,
|
||||
web_challenges: Arc::default(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user