use anchor_client::solana_sdk::signature::Keypair;
use anchor_client::{ Program, Client };
use crate::OnDemandError;
use std::sync::Arc;
use std::result::Result;
use crate::SWITCHBOARD_ATTESTATION_PROGRAM_ID;

pub fn get_on_demand_program(
    client: &Client<Arc<Keypair>>
) -> Result<Program<Arc<Keypair>>, OnDemandError> {
    client.program(*SWITCHBOARD_ATTESTATION_PROGRAM_ID).map_err(|e| OnDemandError::CustomError {
        message: "Failed to get Anchor program".to_string(),
        source: Arc::new(e),
    })
}
