From 3209130957a9f8b6c3385d8430b1b0870cf16e10 Mon Sep 17 00:00:00 2001 From: Dhanraj Avhad <95683132+Dhanraj30@users.noreply.github.com> Date: Wed, 6 Nov 2024 04:06:14 +0530 Subject: [PATCH] =?UTF-8?q?Fix:=20stellar=20contract=20info=20*=20commands?= =?UTF-8?q?=20require=20network=20when=20network=20no=E2=80=A6=20(#1676)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: stellar contract info * commands require network when network not required * Added wasm field to Args struct and updated Cmd::run logic * fix: prevent network resolution when local wasm is provided in fetch_wasm * Update cmd/soroban-cli/src/commands/global.rs Co-authored-by: Willem Wyndham * Update cmd/soroban-cli/src/commands/network/mod.rs Co-authored-by: Willem Wyndham * Update cmd/soroban-cli/src/commands/global.rs Co-authored-by: Willem Wyndham * Update cmd/soroban-cli/src/commands/contract/info/shared.rs Co-authored-by: Willem Wyndham * fix: make network args optional and postpone error until resolution --------- Co-authored-by: Willem Wyndham Co-authored-by: Willem Wyndham Co-authored-by: Jane Wang --- .../src/commands/contract/info/shared.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/info/shared.rs b/cmd/soroban-cli/src/commands/contract/info/shared.rs index 0974632ae..b34ec7da8 100644 --- a/cmd/soroban-cli/src/commands/contract/info/shared.rs +++ b/cmd/soroban-cli/src/commands/contract/info/shared.rs @@ -59,11 +59,16 @@ pub enum Error { } pub async fn fetch_wasm(args: &Args) -> Result>, Error> { - let network = &args.network.get(&args.locator)?; + // Check if a local WASM file path is provided + if let Some(path) = &args.wasm { + // Read the WASM file and return its contents + let wasm_bytes = wasm::Args { wasm: path.clone() }.read()?; + return Ok(Some(wasm_bytes)); + } - let wasm = if let Some(path) = &args.wasm { - wasm::Args { wasm: path.clone() }.read()? - } else if let Some(wasm_hash) = &args.wasm_hash { + // If no local wasm, then check for wasm_hash and fetch from the network + let network = &args.network.get(&args.locator)?; + let wasm = if let Some(wasm_hash) = &args.wasm_hash { let hash = hex::decode(wasm_hash) .map_err(|_| InvalidWasmHash(wasm_hash.clone()))? .try_into()