ic-query 0.103.0

Internet Computer query library for CloudEngine, NNS, SNS, ICRC, system canisters, and public network metadata
Documentation
//! Module: icrc::live::fetch
//!
//! Responsibility: expose cohesive live ICRC fetch owners and shared query context.
//! Does not own: source traits, report construction, or output.
//! Boundary: keeps account, history, and capability host calls behind one internal facade.

mod account;
mod capabilities;
mod history;

pub(super) use account::{account_from_parts, query_token_display_fields};
pub(super) use history::validate_transactions_data;

use crate::icrc::{ledger::principal_from_text, model::IcrcError};
use ic_platform::Principal;
use ic_platform::agent::Agent;

pub(super) fn live_query_context(
    source: &crate::icrc::LiveIcrcSource,
    source_endpoint: &str,
    ledger_canister_id: &str,
) -> Result<(Agent, Principal), IcrcError> {
    Ok((
        crate::agent::endpoint_agent(
            &source.agent,
            source_endpoint,
            crate::agent::MAX_IC_AGENT_RESPONSE_BODY_BYTES,
            |reason| IcrcError::AgentBuild {
                endpoint: source_endpoint.to_owned(),
                reason,
            },
        )?
        .clone(),
        principal_from_text(ledger_canister_id, "ledger_canister_id")?,
    ))
}