use crate::session::SessionManager;

// Synchronous wrappers for async Vault and EVM client APIs for use in Rhai bindings.
// These use block_on for native, and spawn_local for WASM if needed.



#[cfg(not(target_arch = "wasm32"))]
use tokio::runtime::Handle;

// Synchronous sign wrapper for Rhai: only supports signing the currently selected keypair in the unlocked keyspace
#[cfg(not(target_arch = "wasm32"))]
pub fn sign_sync<S: kvstore::traits::KVStore + Send + Sync + 'static>(
    session_manager: &SessionManager<S>,
    message: &[u8],
) -> Result<Vec<u8>, String> {
    Handle::current().block_on(async {
        session_manager.sign(message).await.map_err(|e| format!("sign error: {e}"))
    })
}


