Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/sign_and_send
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Jun 26, 2024
2 parents c9c8e02 + dba96f3 commit 9718d07
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
10 changes: 6 additions & 4 deletions cmd/soroban-cli/src/commands/config/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
path::{Path, PathBuf},
str::FromStr,
};
use stellar_strkey::DecodeError;
use stellar_strkey::{Contract, DecodeError};

use crate::{utils::find_config_dir, Pwd};

Expand Down Expand Up @@ -319,13 +319,15 @@ impl Args {
&self,
alias_or_contract_id: &str,
network_passphrase: &str,
) -> Result<[u8; 32], Error> {
) -> Result<Contract, Error> {
let contract_id = self
.get_contract_id(alias_or_contract_id, network_passphrase)?
.unwrap_or_else(|| alias_or_contract_id.to_string());

soroban_spec_tools::utils::contract_id_from_str(&contract_id)
.map_err(|e| Error::CannotParseContractId(contract_id.clone(), e))
Ok(Contract(
soroban_spec_tools::utils::contract_id_from_str(&contract_id)
.map_err(|e| Error::CannotParseContractId(contract_id.clone(), e))?,
))
}
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/soroban-cli/src/commands/contract/bindings/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ impl NetworkRunnable for Cmd {

let contract_id = self
.locator
.resolve_contract_id(&self.contract_id, &network.network_passphrase)?;
.resolve_contract_id(&self.contract_id, &network.network_passphrase)?
.0;

get_remote_contract_spec(
&contract_id,
Expand Down
3 changes: 2 additions & 1 deletion cmd/soroban-cli/src/commands/contract/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ impl Cmd {
let network = self.network()?;
Ok(self
.locator
.resolve_contract_id(&self.contract_id, &network.network_passphrase)?)
.resolve_contract_id(&self.contract_id, &network.network_passphrase)?
.0)
}
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ impl NetworkRunnable for Cmd {
let contract_id = self
.config
.locator
.resolve_contract_id(&self.contract_id, &network.network_passphrase)?;
.resolve_contract_id(&self.contract_id, &network.network_passphrase)?
.0;
let spec_entries = self.spec_entries()?;
if let Some(spec_entries) = &spec_entries {
// For testing wasm arg parsing
Expand Down
24 changes: 14 additions & 10 deletions cmd/soroban-cli/src/commands/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::{
config::{self, locator},
global, network, NetworkRunnable,
};
use crate::{rpc, utils};
use crate::rpc;

#[derive(Parser, Debug, Clone)]
#[group(skip)]
Expand Down Expand Up @@ -159,14 +159,6 @@ impl Cmd {
}
}

// Validate contract_ids
for id in &mut self.contract_ids {
utils::contract_id_from_str(id).map_err(|e| Error::InvalidContractId {
contract_id: id.clone(),
error: e,
})?;
}

let response = self.run_against_rpc_server(None, None).await?;

for event in &response.events {
Expand Down Expand Up @@ -226,11 +218,23 @@ impl NetworkRunnable for Cmd {
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;

let contract_ids: Vec<String> = self
.contract_ids
.iter()
.map(|id| {
Ok(self
.locator
.resolve_contract_id(id, &network.network_passphrase)?
.to_string())
})
.collect::<Result<Vec<_>, Error>>()?;

Ok(client
.get_events(
start,
Some(self.event_type),
&self.contract_ids,
&contract_ids,
&self.topic_filters,
Some(self.count),
)
Expand Down

0 comments on commit 9718d07

Please sign in to comment.