use crate::{app::App, utils::HexBytes};
use anyhow::Result;
use clap::Parser;
use gear_core::ids::ActorId;
use gsdk::ext::subxt::utils::H256;
#[derive(Clone, Debug, Parser)]
pub struct ReadState {
pid: ActorId,
#[arg(short, long, default_value = "0x")]
payload: HexBytes,
#[arg(long)]
at: Option<H256>,
}
impl ReadState {
pub async fn exec(self, app: &mut App) -> Result<()> {
let api = app.signed_api().await?;
let state = api
.read_state_bytes_at(self.pid, self.payload, self.at)
.await?;
println!("0x{}", hex::encode(state));
Ok(())
}
}