Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove effective_canister_id from fn fetch_api_boundary_nodes() signature #543

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 17 additions & 10 deletions ic-agent/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/<effective_canister_id>/read_state
pub async fn fetch_api_boundary_nodes_by_canister_id(
&self,
effective_canister_id: Principal,
canister_id: Principal,
) -> Result<Vec<ApiBoundaryNode>, 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/<subnet_id>/read_state
pub async fn fetch_api_boundary_nodes_by_subnet_id(
&self,
subnet_id: Principal,
) -> Result<Vec<ApiBoundaryNode>, 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)
}
Expand Down Expand Up @@ -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,
Expand Down