Skip to content

Commit 3d79561

Browse files
committed
add command show-ownership
1 parent a567ac8 commit 3d79561

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

linera-client/src/client_context.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,13 @@ impl<Env: Environment, W: Persist<Target = Wallet>> ClientContext<Env, W> {
445445
}
446446
}
447447

448+
pub async fn ownership(&mut self, chain_id: Option<ChainId>) -> Result<ChainOwnership, Error> {
449+
let chain_id = chain_id.unwrap_or_else(|| self.default_chain());
450+
let client = self.make_chain_client(chain_id);
451+
let info = client.chain_info().await?;
452+
Ok(info.manager.ownership)
453+
}
454+
448455
pub async fn change_ownership(
449456
&mut self,
450457
chain_id: Option<ChainId>,

linera-service/src/cli/command.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ pub enum ClientCommand {
227227
balance: Amount,
228228
},
229229

230+
/// Display who owns the chain, and how the owners work together proposing blocks.
231+
ShowOwnership {
232+
/// The ID of the chain whose owners will be changed.
233+
#[clap(long)]
234+
chain_id: Option<ChainId>,
235+
},
236+
230237
/// Change who owns the chain, and how the owners work together proposing blocks.
231238
///
232239
/// Specify the complete set of new owners, by public key. Existing owners that are
@@ -957,6 +964,7 @@ impl ClientCommand {
957964
ClientCommand::Transfer { .. }
958965
| ClientCommand::OpenChain { .. }
959966
| ClientCommand::OpenMultiOwnerChain { .. }
967+
| ClientCommand::ShowOwnership { .. }
960968
| ClientCommand::ChangeOwnership { .. }
961969
| ClientCommand::SetPreferredOwner { .. }
962970
| ClientCommand::ChangeApplicationPermissions { .. }

linera-service/src/cli/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,18 @@ impl Runnable for Job {
240240
println!("{}", id);
241241
}
242242

243+
ShowOwnership { chain_id } => {
244+
let mut context = ClientContext::new(
245+
storage,
246+
options.context_options.clone(),
247+
wallet,
248+
signer.into_value(),
249+
);
250+
let ownership = context.ownership(chain_id).await?;
251+
let json = serde_json::to_string_pretty(&ownership)?;
252+
println!("{}", json);
253+
}
254+
243255
ChangeOwnership {
244256
chain_id,
245257
ownership_config,

0 commit comments

Comments
 (0)