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:
jwinterm
2026-06-23 10:39:25 -04:00
parent e2beb17dda
commit b7e3199200
5 changed files with 65 additions and 2 deletions
+4 -1
View File
@@ -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(),
});