`transaction-history -v` now shows the transaction timestamp if available
This commit is contained in:
parent
8376781ec8
commit
971c222cf7
|
@ -1,41 +1,42 @@
|
||||||
use crate::{
|
use {
|
||||||
display::{
|
crate::{
|
||||||
build_balance_message, build_balance_message_with_config, format_labeled_address,
|
display::{
|
||||||
writeln_name_value, BuildBalanceMessageConfig,
|
build_balance_message, build_balance_message_with_config, format_labeled_address,
|
||||||
|
unix_timestamp_to_string, writeln_name_value, BuildBalanceMessageConfig,
|
||||||
|
},
|
||||||
|
QuietDisplay, VerboseDisplay,
|
||||||
|
},
|
||||||
|
console::{style, Emoji},
|
||||||
|
inflector::cases::titlecase::to_title_case,
|
||||||
|
serde::{Deserialize, Serialize},
|
||||||
|
serde_json::{Map, Value},
|
||||||
|
solana_account_decoder::parse_token::UiTokenAccount,
|
||||||
|
solana_clap_utils::keypair::SignOnly,
|
||||||
|
solana_client::rpc_response::{
|
||||||
|
RpcAccountBalance, RpcInflationGovernor, RpcInflationRate, RpcKeyedAccount, RpcSupply,
|
||||||
|
RpcVoteAccountInfo,
|
||||||
|
},
|
||||||
|
solana_sdk::{
|
||||||
|
clock::{self, Epoch, Slot, UnixTimestamp},
|
||||||
|
epoch_info::EpochInfo,
|
||||||
|
hash::Hash,
|
||||||
|
native_token::lamports_to_sol,
|
||||||
|
pubkey::Pubkey,
|
||||||
|
signature::Signature,
|
||||||
|
stake_history::StakeHistoryEntry,
|
||||||
|
transaction::Transaction,
|
||||||
|
},
|
||||||
|
solana_stake_program::stake_state::{Authorized, Lockup},
|
||||||
|
solana_vote_program::{
|
||||||
|
authorized_voters::AuthorizedVoters,
|
||||||
|
vote_state::{BlockTimestamp, Lockout},
|
||||||
|
},
|
||||||
|
std::{
|
||||||
|
collections::{BTreeMap, HashMap},
|
||||||
|
fmt,
|
||||||
|
str::FromStr,
|
||||||
|
time::Duration,
|
||||||
},
|
},
|
||||||
QuietDisplay, VerboseDisplay,
|
|
||||||
};
|
|
||||||
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
|
|
||||||
use console::{style, Emoji};
|
|
||||||
use inflector::cases::titlecase::to_title_case;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use serde_json::{Map, Value};
|
|
||||||
use solana_account_decoder::parse_token::UiTokenAccount;
|
|
||||||
use solana_clap_utils::keypair::SignOnly;
|
|
||||||
use solana_client::rpc_response::{
|
|
||||||
RpcAccountBalance, RpcInflationGovernor, RpcInflationRate, RpcKeyedAccount, RpcSupply,
|
|
||||||
RpcVoteAccountInfo,
|
|
||||||
};
|
|
||||||
use solana_sdk::{
|
|
||||||
clock::{self, Epoch, Slot, UnixTimestamp},
|
|
||||||
epoch_info::EpochInfo,
|
|
||||||
hash::Hash,
|
|
||||||
native_token::lamports_to_sol,
|
|
||||||
pubkey::Pubkey,
|
|
||||||
signature::Signature,
|
|
||||||
stake_history::StakeHistoryEntry,
|
|
||||||
transaction::Transaction,
|
|
||||||
};
|
|
||||||
use solana_stake_program::stake_state::{Authorized, Lockup};
|
|
||||||
use solana_vote_program::{
|
|
||||||
authorized_voters::AuthorizedVoters,
|
|
||||||
vote_state::{BlockTimestamp, Lockout},
|
|
||||||
};
|
|
||||||
use std::{
|
|
||||||
collections::{BTreeMap, HashMap},
|
|
||||||
fmt,
|
|
||||||
str::FromStr,
|
|
||||||
time::Duration,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static WARNING: Emoji = Emoji("⚠️", "!");
|
static WARNING: Emoji = Emoji("⚠️", "!");
|
||||||
|
@ -1153,18 +1154,6 @@ pub struct CliBlockTime {
|
||||||
impl QuietDisplay for CliBlockTime {}
|
impl QuietDisplay for CliBlockTime {}
|
||||||
impl VerboseDisplay for CliBlockTime {}
|
impl VerboseDisplay for CliBlockTime {}
|
||||||
|
|
||||||
fn unix_timestamp_to_string(unix_timestamp: UnixTimestamp) -> String {
|
|
||||||
format!(
|
|
||||||
"{} (UnixTimestamp: {})",
|
|
||||||
match NaiveDateTime::from_timestamp_opt(unix_timestamp, 0) {
|
|
||||||
Some(ndt) =>
|
|
||||||
DateTime::<Utc>::from_utc(ndt, Utc).to_rfc3339_opts(SecondsFormat::Secs, true),
|
|
||||||
None => "unknown".to_string(),
|
|
||||||
},
|
|
||||||
unix_timestamp,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for CliBlockTime {
|
impl fmt::Display for CliBlockTime {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln_name_value(f, "Block:", &self.slot.to_string())?;
|
writeln_name_value(f, "Block:", &self.slot.to_string())?;
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
use crate::cli_output::CliSignatureVerificationStatus;
|
use {
|
||||||
use console::style;
|
crate::cli_output::CliSignatureVerificationStatus,
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc},
|
||||||
use solana_sdk::{
|
console::style,
|
||||||
hash::Hash, native_token::lamports_to_sol, program_utils::limited_deserialize,
|
indicatif::{ProgressBar, ProgressStyle},
|
||||||
transaction::Transaction,
|
solana_sdk::{
|
||||||
|
clock::UnixTimestamp, hash::Hash, native_token::lamports_to_sol,
|
||||||
|
program_utils::limited_deserialize, transaction::Transaction,
|
||||||
|
},
|
||||||
|
solana_transaction_status::UiTransactionStatusMeta,
|
||||||
|
std::{collections::HashMap, fmt, io},
|
||||||
};
|
};
|
||||||
use solana_transaction_status::UiTransactionStatusMeta;
|
|
||||||
use std::{collections::HashMap, fmt, io};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct BuildBalanceMessageConfig {
|
pub struct BuildBalanceMessageConfig {
|
||||||
|
@ -300,6 +303,13 @@ pub fn new_spinner_progress_bar() -> ProgressBar {
|
||||||
progress_bar
|
progress_bar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unix_timestamp_to_string(unix_timestamp: UnixTimestamp) -> String {
|
||||||
|
match NaiveDateTime::from_timestamp_opt(unix_timestamp, 0) {
|
||||||
|
Some(ndt) => DateTime::<Utc>::from_utc(ndt, Utc).to_rfc3339_opts(SecondsFormat::Secs, true),
|
||||||
|
None => format!("UnixTimestamp {}", unix_timestamp),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -16,7 +16,7 @@ use solana_clap_utils::{
|
||||||
use solana_cli_output::{
|
use solana_cli_output::{
|
||||||
display::{
|
display::{
|
||||||
build_balance_message, format_labeled_address, new_spinner_progress_bar,
|
build_balance_message, format_labeled_address, new_spinner_progress_bar,
|
||||||
println_name_value, println_transaction, writeln_name_value,
|
println_name_value, println_transaction, unix_timestamp_to_string, writeln_name_value,
|
||||||
},
|
},
|
||||||
*,
|
*,
|
||||||
};
|
};
|
||||||
|
@ -1812,9 +1812,14 @@ pub fn process_transaction_history(
|
||||||
for result in results {
|
for result in results {
|
||||||
if config.verbose {
|
if config.verbose {
|
||||||
println!(
|
println!(
|
||||||
"{} [slot={} status={}] {}",
|
"{} [slot={} {}status={}] {}",
|
||||||
result.signature,
|
result.signature,
|
||||||
result.slot,
|
result.slot,
|
||||||
|
match result.block_time {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(block_time) =>
|
||||||
|
format!("timestamp={} ", unix_timestamp_to_string(block_time)),
|
||||||
|
},
|
||||||
match result.err {
|
match result.err {
|
||||||
None => "Confirmed".to_string(),
|
None => "Confirmed".to_string(),
|
||||||
Some(err) => format!("Failed: {:?}", err),
|
Some(err) => format!("Failed: {:?}", err),
|
||||||
|
|
Loading…
Reference in New Issue