pub async fn connect(safe: &mut Safe, config: Config) -> Result<Option<Keypair>> {
    debug!("Connecting...");

    let app_keypair = if let Ok((_, keypair)) = read_credentials() {
        keypair
    } else {
        None
    };

    let found_app_keypair = app_keypair.is_some();
    if !found_app_keypair {
        info!("No credentials found for CLI, connecting with read-only access...");
    }

    let (_, bootstrap_contacts) = config.read_current_node_config()?;
    let client_cfg = client_config_path();
    match safe
        .connect(
            app_keypair.clone(),
            client_cfg.as_deref(),
            bootstrap_contacts.clone(),
        )
        .await
    {
        Err(_) if found_app_keypair => {
            warn!("Credentials found for CLI are invalid, connecting with read-only access...");
            safe.connect(None, None, bootstrap_contacts)
                .await
                .wrap_err("Failed to connect with read-only access")?;

            Ok(None)
        }
        Err(err) => Err(eyre!("Failed to connect: {}", err)),
        Ok(()) => Ok(app_keypair),
    }
}
// Attempt to connect with credentials if found and valid,
// otherwise it creates a read only connection.
// Returns the app's keypair if connection was succesfully made with credentials,
// otherwise it returns 'None' if conneciton is read only.
Attempt to connect with credentials if found and valid,
otherwise it creates a read only connection.
Returns the app's keypair if connection was succesfully made with credentials,
otherwise it returns 'None' if conneciton is read only.
Attempt to connect with credentials if found and valid otherwise it creates a read only connection . Returns the app ' s keypair if connection was succesfully made with credentials otherwise it returns ' None ' if conneciton is read only .
pub async fn connect(safe: &mut Safe, config: Config) -> Result<Option<Keypair>> {
    debug!("Connecting...");
    let app_keypair = if let Ok((_, keypair)) = read_credentials() {
        keypair
    } else {
        None
    };
    let found_app_keypair = app_keypair.is_some();
    if !found_app_keypair {
        info!("No credentials found for CLI, connecting with read-only access...");
    }
    let (_, bootstrap_contacts) = config.read_current_node_config()?;
    let client_cfg = client_config_path();
    match safe
        .connect(
            app_keypair.clone(),
            client_cfg.as_deref(),
            bootstrap_contacts.clone(),
        )
        .await
    {
        Err(_) if found_app_keypair => {
            warn!("Credentials found for CLI are invalid, connecting with read-only access...");
            safe.connect(None, None, bootstrap_contacts)
                .await
                .wrap_err("Failed to connect with read-only access")?;
            Ok(None)
        }
        Err(err) => Err(eyre!("Failed to connect: {}", err)),
        Ok(()) => Ok(app_keypair),
    }
}
pub async fn connect ( safe : & mut Safe , config : Config ) -> Result < Option < Keypair > > { debug ! ( " " ) ; let app_keypair = if let Ok ( ( _ , keypair ) ) = read_credentials ( ) { keypair } else { None } ; let found_app_keypair = app_keypair . is_some ( ) ; if ! found_app_keypair { info ! ( " " ) ; } let ( _ , bootstrap_contacts ) = config . read_current_node_config ( ) ? ; let client_cfg = client_config_path ( ) ; match safe . connect ( app_keypair . clone ( ) , client_cfg . as_deref ( ) , bootstrap_contacts . clone ( ) , ) . await { Err ( _ ) if found_app_keypair => { warn ! ( " " ) ; safe . connect ( None , None , bootstrap_contacts ) . await . wrap_err ( " " ) ? ; Ok ( None ) } Err ( err ) => Err ( eyre ! ( " " err ) ) , Ok ( ( ) ) => Ok ( app_keypair ) , } }
Attempt to connect with credentials if found and valid,
otherwise it creates a read only connection.
Attempt to connect with credentials if found and valid otherwise it creates a read only connection .
safe
&mut Safe
config
Config
safe
&mut Safe
config
Config