-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add signer::Stellar trait and sign & send
Also add Ledger options.
- Loading branch information
1 parent
0552599
commit 3c65b14
Showing
9 changed files
with
827 additions
and
563 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use async_trait::async_trait; | ||
use soroban_rpc::GetTransactionResponse; | ||
|
||
use crate::commands::{config, global, NetworkRunnable}; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
XdrArgs(#[from] super::xdr::Error), | ||
#[error(transparent)] | ||
Config(#[from] super::super::config::Error), | ||
#[error(transparent)] | ||
Rpc(#[from] crate::rpc::Error), | ||
#[error(transparent)] | ||
SerdeJson(#[from] serde_json::Error), | ||
} | ||
|
||
#[derive(Debug, clap::Parser, Clone)] | ||
#[group(skip)] | ||
/// Command to send a transaction envelope to the network | ||
/// e.g. `cat file.txt | soroban tx send` | ||
pub struct Cmd { | ||
#[clap(flatten)] | ||
pub config: super::super::config::Args, | ||
} | ||
|
||
impl Cmd { | ||
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> { | ||
let response = self | ||
.run_against_rpc_server(Some(global_args), Some(&self.config)) | ||
.await?; | ||
println!("{}", serde_json::to_string_pretty(&response)?); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl NetworkRunnable for Cmd { | ||
type Error = Error; | ||
|
||
type Result = GetTransactionResponse; | ||
async fn run_against_rpc_server( | ||
&self, | ||
_: Option<&global::Args>, | ||
config: Option<&config::Args>, | ||
) -> Result<Self::Result, Self::Error> { | ||
let config = config.unwrap_or(&self.config); | ||
let network = config.get_network()?; | ||
let client = crate::rpc::Client::new(&network.rpc_url)?; | ||
let tx_env = super::xdr::tx_envelope_from_stdin()?; | ||
Ok(client.send_transaction(&tx_env).await?) | ||
} | ||
} |
Oops, something went wrong.