diff --git a/CHANGELOG.md b/CHANGELOG.md index 01a90d22..5ed1fb55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Changed `WalletCanister::from_canister/create`'s version check to not rely on the reject code. * Added `QueryBuilder::call_with_verification()` and `QueryBuilder::call_without_verification()` which always/never verify query signatures regardless the Agent level configuration from `AgentBuilder::with_verify_query_signatures`. +* Function `Agent::fetch_api_boundary_nodes()` is split into two functions: `fetch_api_boundary_nodes_by_canister_id()` and `fetch_api_boundary_nodes_by_subnet_id()`. ## [0.34.0] - 2024-03-18 diff --git a/ic-agent/src/agent/mod.rs b/ic-agent/src/agent/mod.rs index 900bc924..31292a7b 100644 --- a/ic-agent/src/agent/mod.rs +++ b/ic-agent/src/agent/mod.rs @@ -1128,17 +1128,24 @@ impl Agent { } } - /// Retrieve all existing API boundary nodes from the state tree. - pub async fn fetch_api_boundary_nodes( + /// Retrieve all existing API boundary nodes from the state tree via endpoint /api/v2/canister//read_state + pub async fn fetch_api_boundary_nodes_by_canister_id( &self, - effective_canister_id: Principal, + canister_id: Principal, ) -> Result, AgentError> { - let certificate = self - .read_state_raw( - vec![vec!["api_boundary_nodes".into()]], - effective_canister_id, - ) - .await?; + let paths = vec![vec!["api_boundary_nodes".into()]]; + let certificate = self.read_state_raw(paths, canister_id).await?; + let api_boundary_nodes = lookup_api_boundary_nodes(certificate)?; + Ok(api_boundary_nodes) + } + + /// Retrieve all existing API boundary nodes from the state tree via endpoint /api/v2/subnet//read_state + pub async fn fetch_api_boundary_nodes_by_subnet_id( + &self, + subnet_id: Principal, + ) -> Result, AgentError> { + let paths = vec![vec!["api_boundary_nodes".into()]]; + let certificate = self.read_subnet_state_raw(paths, subnet_id).await?; let api_boundary_nodes = lookup_api_boundary_nodes(certificate)?; Ok(api_boundary_nodes) } @@ -1469,7 +1476,7 @@ pub(crate) struct Subnet { } /// API boundary node, which routes /api calls to IC replica nodes. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ApiBoundaryNode { /// Domain name pub domain: String,