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

refactor(gtest): removed use of read_state_bytes_using_wasm #4320

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 0 additions & 196 deletions examples/new-meta/tests/read_state.rs

This file was deleted.

47 changes: 2 additions & 45 deletions gcli/src/cmd/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ pub enum Program {
State {
/// Program id.
pid: H256,
/// Method of reading state from wasm (hex encoding).
#[arg(short, long)]
method: Option<String>,
/// The path of "*.meta.wasm".
#[arg(short, long)]
wasm: Option<Vec<u8>>,
/// Method arguments (hex encoding).
#[arg(short, long)]
args: Option<Vec<u8>>,
/// The block hash for reading state.
#[arg(long)]
at: Option<H256>,
Expand All @@ -78,21 +69,9 @@ impl Program {
/// Run command program.
pub async fn exec(&self, app: &impl App) -> Result<()> {
match self {
Program::State {
pid,
method,
wasm,
args,
at,
} => {
Program::State { pid, at } => {
let api = app.signer().await?;
if let (Some(wasm), Some(method)) = (wasm, method) {
// read state from wasm.
Self::wasm_state(&api, *pid, wasm.to_vec(), method, args.clone(), *at).await?;
} else {
// read full state
Self::full_state(&api, *pid, *at).await?;
}
Self::full_state(&api, *pid, *at).await?;
}
Program::Meta {
meta,
Expand All @@ -112,28 +91,6 @@ impl Program {
Ok(())
}

async fn wasm_state(
api: &GearApi,
pid: H256,
wasm: Vec<u8>,
method: &str,
args: Option<Vec<u8>>,
at: Option<H256>,
) -> Result<()> {
let state = api
.read_state_bytes_using_wasm_at(
pid.0.into(),
Default::default(),
method,
wasm,
args,
at,
)
.await?;
println!("0x{}", hex::encode(state));
Ok(())
}

async fn full_state(api: &GearApi, pid: H256, at: Option<H256>) -> Result<()> {
let state = api
.read_state_bytes_at(pid.0.into(), Default::default(), at)
Expand Down
Loading
Loading