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
@@ -21,7 +21,8 @@ use tower::ServiceExt;
|
||||
use uuid::Uuid;
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
static INIT_ENV: Once = Once::new();
|
||||
@@ -68,10 +69,12 @@ pub async fn try_app() -> Option<TestApp> {
|
||||
config.secrets.ip_salt.clone(),
|
||||
);
|
||||
let sessions = SessionManager::new(&config.auth.jwt_secret, config.auth.jwt_expiry_hours);
|
||||
let chains = ChainClients::from_config(&config).expect("build chain clients");
|
||||
let state = Arc::new(AppState {
|
||||
config,
|
||||
db,
|
||||
sessions,
|
||||
chains,
|
||||
web_challenges: Arc::default(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user