Skip to content

Commit

Permalink
Fix: stellar contract info * commands require network when network no… (
Browse files Browse the repository at this point in the history
#1676)

* 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 <[email protected]>

* Update cmd/soroban-cli/src/commands/network/mod.rs

Co-authored-by: Willem Wyndham <[email protected]>

* Update cmd/soroban-cli/src/commands/global.rs

Co-authored-by: Willem Wyndham <[email protected]>

* Update cmd/soroban-cli/src/commands/contract/info/shared.rs

Co-authored-by: Willem Wyndham <[email protected]>

* fix: make network args optional and postpone error until resolution

---------

Co-authored-by: Willem Wyndham <[email protected]>
Co-authored-by: Willem Wyndham <[email protected]>
Co-authored-by: Jane Wang <[email protected]>
  • Loading branch information
4 people authored Nov 5, 2024
1 parent c873f9f commit 3209130
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/soroban-cli/src/commands/contract/info/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ pub enum Error {
}

pub async fn fetch_wasm(args: &Args) -> Result<Option<Vec<u8>>, 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()
Expand Down

0 comments on commit 3209130

Please sign in to comment.