diff --git a/cmd/soroban-cli/src/commands/contract/arg_parsing.rs b/cmd/soroban-cli/src/commands/contract/arg_parsing.rs index 0718ad192..ae068a25b 100644 --- a/cmd/soroban-cli/src/commands/contract/arg_parsing.rs +++ b/cmd/soroban-cli/src/commands/contract/arg_parsing.rs @@ -86,9 +86,15 @@ pub fn build_host_function_parameters( .map(|i| { let name = i.name.to_utf8_string()?; if let Some(mut val) = matches_.get_raw(&name) { - let mut s = val.next().unwrap().to_string_lossy().to_string(); + let mut s = val + .next() + .unwrap() + .to_string_lossy() + .trim_matches('"') + .to_string(); if matches!(i.type_, ScSpecTypeDef::Address) { - let (addr, signer) = resolve_sc_address(&s, config)?; + let addr = resolve_address(&s, config)?; + let signer = resolve_signer(&s, config); s = addr; if let Some(signer) = signer { signers.push(signer); @@ -247,26 +253,26 @@ pub fn output_to_string( Ok(TxnResult::Res(res_str)) } -fn resolve_sc_address( - addr_or_alias: &str, - config: &config::Args, -) -> Result<(String, Option), Error> { - let addr_or_alias = addr_or_alias.trim_matches('"'); +fn resolve_address(addr_or_alias: &str, config: &config::Args) -> Result { let sc_address: ScAddress = addr_or_alias.parse().unwrap(); let account = match sc_address { - ScAddress::Address(addr) => return Ok((addr.to_string(), None)), + ScAddress::Address(addr) => addr.to_string(), addr @ ScAddress::Alias(_) => { let addr = addr.resolve(&config.locator, &config.get_network()?.network_passphrase)?; match addr { xdr::ScAddress::Account(account) => account.to_string(), - contract @ xdr::ScAddress::Contract(_) => return Ok((contract.to_string(), None)), + contract @ xdr::ScAddress::Contract(_) => contract.to_string(), } } }; + Ok(account) +} + +fn resolve_signer(addr_or_alias: &str, config: &config::Args) -> Option { let cmd = crate::commands::keys::address::Cmd { name: addr_or_alias.to_string(), hd_path: Some(0), locator: config.locator.clone(), }; - Ok((account, cmd.private_key().ok())) + cmd.private_key().ok() }