Skip to content

Commit

Permalink
fix: use async_trait
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Feb 29, 2024
1 parent a5927c2 commit 9b77f3a
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ sha2 = "0.10.7"
ethnum = "1.3.2"
hex = "0.4.3"
itertools = "0.10.0"
async-trait = "0.1.76"

serde-aux = "4.1.2"
serde_json = "1.0.82"
Expand Down
14 changes: 7 additions & 7 deletions cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ soroban-sdk = { workspace = true }
soroban-rpc = { workspace = true }

clap = { workspace = true, features = [
"derive",
"env",
"deprecated",
"string",
"derive",
"env",
"deprecated",
"string",
] }
clap_complete = {workspace = true}

clap_complete = { workspace = true }
async-trait = { workspace = true }
base64 = { workspace = true }
thiserror = { workspace = true }
serde = { workspace = true, features = ["derive"] }
Expand Down Expand Up @@ -101,7 +101,7 @@ gix = { version = "0.58.0", default-features = false, features = [
"blocking-http-transport-reqwest-rust-tls",
"worktree-mutation",
] }
ureq = {version = "2.9.1", features = ["json"]}
ureq = { version = "2.9.1", features = ["json"] }

tempfile = "3.8.1"
toml_edit = "0.21.0"
Expand Down
2 changes: 2 additions & 0 deletions cmd/soroban-cli/src/commands/contract/deploy/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ impl Cmd {
Ok(())
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = String;
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl Cmd {
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = String;
Expand Down
4 changes: 3 additions & 1 deletion cmd/soroban-cli/src/commands/contract/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ impl Cmd {
res
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = u32;
Expand All @@ -108,7 +110,7 @@ impl NetworkRunnable for Cmd {
&self,
_args: Option<&global::Args>,
config: Option<&config::Args>,
) -> Result<u32, Error> {
) -> Result<u32, Self::Error> {
let config = config.unwrap_or(&self.config);
let network = config.get_network()?;
tracing::trace!(?network);
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/contract/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl Cmd {
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = Vec<u8>;
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/contract/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl Cmd {
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = Hash;
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ impl Cmd {
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = String;
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/contract/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl Cmd {
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = FullLedgerEntries;
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/contract/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl Cmd {
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = u32;
Expand Down
2 changes: 2 additions & 0 deletions cmd/soroban-cli/src/commands/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ impl Cmd {
Ok(start)
}
}

#[async_trait::async_trait]
impl NetworkRunnable for Cmd {
type Error = Error;
type Result = rpc::GetEventsResponse;
Expand Down
6 changes: 4 additions & 2 deletions cmd/soroban-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::str::FromStr;

use async_trait::async_trait;
use clap::{command, error::ErrorKind, CommandFactory, FromArgMatches, Parser};

pub mod completion;
Expand Down Expand Up @@ -159,13 +160,14 @@ pub enum Error {
Network(#[from] network::Error),
}

#[async_trait]
pub trait NetworkRunnable {
type Error;
type Result;

fn run_against_rpc_server(
async fn run_against_rpc_server(
&self,
global_args: Option<&global::Args>,
config: Option<&config::Args>,
) -> impl std::future::Future<Output = Result<Self::Result, Self::Error>> + Send;
) -> Result<Self::Result, Self::Error>;
}

0 comments on commit 9b77f3a

Please sign in to comment.