-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aliases `tx-status` and `transaction-status` are also accepted. This command uses the `starknet_getTransactionStatus` to instruct the JSON-RPC node to query the sequencer for mempool transaction status.
- Loading branch information
1 parent
3642be9
commit 348bc75
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
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,34 @@ | ||
use anyhow::Result; | ||
use clap::Parser; | ||
use colored_json::{ColorMode, Output}; | ||
use starknet::{core::types::FieldElement, providers::Provider}; | ||
|
||
use crate::{verbosity::VerbosityArgs, ProviderArgs}; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct TransactionStatus { | ||
#[clap(flatten)] | ||
provider: ProviderArgs, | ||
#[clap(help = "Transaction hash")] | ||
hash: String, | ||
#[clap(flatten)] | ||
verbosity: VerbosityArgs, | ||
} | ||
|
||
impl TransactionStatus { | ||
pub async fn run(self) -> Result<()> { | ||
self.verbosity.setup_logging(); | ||
|
||
let provider = self.provider.into_provider()?; | ||
let transaction_hash = FieldElement::from_hex_be(&self.hash)?; | ||
|
||
let status = provider.get_transaction_status(transaction_hash).await?; | ||
|
||
let status_json = serde_json::to_value(status)?; | ||
let status_json = | ||
colored_json::to_colored_json(&status_json, ColorMode::Auto(Output::StdOut))?; | ||
println!("{status_json}"); | ||
|
||
Ok(()) | ||
} | ||
} |