Repository: holochain/holochain (language: rust)

Issue:
Update `hc sandbox call` to support ListCapabilityGrants
There is a new admin option available, `ListCapabilityGrants`. It should be accessible from the sandbox.

Update https://github.com/holochain/holochain/blob/develop/crates/hc_sandbox/src/calls.rs so that there is an option that calls this new admin option.


Discussion / hints:

Fix patch:
diff --git a/crates/hc_sandbox/CHANGELOG.md b/crates/hc_sandbox/CHANGELOG.md
index 276468ee2b..18b4dce229 100644
--- a/crates/hc_sandbox/CHANGELOG.md
+++ b/crates/hc_sandbox/CHANGELOG.md
@@ -6,6 +6,7 @@ default_semver_increment_mode: !pre_minor dev
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## \[Unreleased\]
+- Support for the hc sandbox to use the 'list capability grants' feature.
 
 ## 0.5.0-dev.18
 
diff --git a/crates/hc_sandbox/src/calls.rs b/crates/hc_sandbox/src/calls.rs
index f78d41544b..97952e1664 100644
--- a/crates/hc_sandbox/src/calls.rs
+++ b/crates/hc_sandbox/src/calls.rs
@@ -21,6 +21,7 @@ use holochain_conductor_api::{AdminRequest, AppInterfaceInfo};
 use holochain_types::app::AppManifest;
 use holochain_types::app::RoleSettingsMap;
 use holochain_types::app::RoleSettingsMapYaml;
+use holochain_types::prelude::AppCapGrantInfo;
 use holochain_types::prelude::DnaModifiersOpt;
 use holochain_types::prelude::RegisterDnaPayload;
 use holochain_types::prelude::Timestamp;
@@ -86,6 +87,7 @@ pub enum AdminRequestCli {
     DumpConductorState,
     DumpNetworkMetrics(DumpNetworkMetrics),
     DumpNetworkStats,
+    ListCapabilityGrants(ListCapGrants),
     /// Calls AdminRequest::AddAgentInfo.
     /// _Unimplemented_.
     AddAgents,
@@ -244,6 +246,15 @@ pub struct DumpNetworkMetrics {
     pub dna: Option<DnaHash>,
 }
 
+/// Arguments for listing capability grants info.
+#[derive(Debug, Args, Clone)]
+pub struct ListCapGrants {
+    /// app id to filter by
+    pub installed_app_id: String,
+    /// include revoked grants
+    pub include_revoked: bool,
+}
+
 /// Calls AdminRequest::RequestAgentInfo
 /// and pretty prints the agent info on
 /// this conductor.
@@ -423,6 +434,11 @@ async fn call_inner(cmd: &mut CmdRunner, call: AdminRequestCli) -> anyhow::Resul
             // Print without other text so it can be piped
             println!("{}", stats);
         }
+        AdminRequestCli::ListCapabilityGrants(args) => {
+            let info = list_capability_grants(cmd, args).await?;
+            // Print without other text so it can be piped
+            println!("{:?}", info);
+        }
         AdminRequestCli::AddAgents => todo!("Adding agent info via CLI is coming soon"),
         AdminRequestCli::ListAgents(args) => {
             use std::fmt::Write;
@@ -732,6 +748,23 @@ async fn dump_network_stats(cmd: &mut CmdRunner) -> anyhow::Result<String> {
     Ok(expect_match!(resp => AdminResponse::NetworkStatsDumped, "Failed to dump network stats"))
 }
 
+/// Calls [`AdminRequest::ListCapabilityGrants`] and lists the cap grant info.
+async fn list_capability_grants(
+    cmd: &mut CmdRunner,
+    args: ListCapGrants,
+) -> anyhow::Result<AppCapGrantInfo> {
+    let (installed_app_id, include_revoked) = (args.installed_app_id, args.include_revoked);
+    let resp = cmd
+        .command(AdminRequest::ListCapabilityGrants {
+            installed_app_id,
+            include_revoked,
+        })
+        .await?;
+    Ok(
+        expect_match!(resp => AdminResponse::CapabilityGrantsInfo, "Failed to list capability grants"),
+    )
+}
+
 /// Calls [`AdminRequest::AddAgentInfo`] with and adds the list of agent info.
 pub async fn add_agent_info(cmd: &mut CmdRunner, args: Vec<AgentInfoSigned>) -> anyhow::Result<()> {
     let resp = cmd


Test patch: