cli_commands/
get_genesis_utxo.rs1use sidechain_domain::UtxoId;
2use sp_api::ProvideRuntimeApi;
3use sp_blockchain::HeaderBackend;
4use sp_runtime::traits::Block as BlockT;
5use sp_sidechain::GetGenesisUtxo;
6use std::sync::Arc;
7
8pub async fn execute<B, C>(client: Arc<C>) -> Result<String, String>
10where
11 B: BlockT,
12 C: ProvideRuntimeApi<B> + Send + Sync + 'static,
13 C::Api: GetGenesisUtxo<B>,
14 C: HeaderBackend<B>,
15{
16 let api = client.runtime_api();
17 let best_block = client.info().best_hash;
18 let genesis_utxo = api.genesis_utxo(best_block).map_err(|err| err.to_string())?;
19 let output =
20 serde_json::to_string_pretty(&Output { genesis_utxo }).map_err(|err| err.to_string())?;
21 Ok(output)
22}
23
24#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, Debug)]
26struct Output {
27 pub genesis_utxo: UtxoId,
29}