Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: derive Serialize,Deserialize for more types in transaction-status crate #35466

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions transaction-status/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ impl From<InnerInstructions> for UiInnerInstructions {
}
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TransactionTokenBalance {
pub account_index: u8,
pub mint: String,
Expand Down Expand Up @@ -347,7 +348,8 @@ impl From<TransactionTokenBalance> for UiTransactionTokenBalance {
}
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TransactionStatusMeta {
pub status: TransactionResult<()>,
pub fee: u64,
Expand Down Expand Up @@ -633,7 +635,8 @@ pub enum ConvertBlockError {
TransactionsMissing(usize, usize),
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConfirmedBlock {
pub previous_blockhash: String,
pub blockhash: String,
Expand All @@ -646,7 +649,8 @@ pub struct ConfirmedBlock {

// Confirmed block with type guarantees that transaction metadata
// is always present. Used for uploading to BigTable.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VersionedConfirmedBlock {
pub previous_blockhash: String,
pub blockhash: String,
Expand Down Expand Up @@ -832,16 +836,17 @@ pub struct EntrySummary {
pub starting_transaction_index: usize,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[allow(clippy::large_enum_variant)]
#[serde(rename_all = "camelCase", untagged)]
pub enum TransactionWithStatusMeta {
// Very old transactions may be missing metadata
MissingMetadata(Transaction),
// Versioned stored transaction always have metadata
Complete(VersionedTransactionWithStatusMeta),
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct VersionedTransactionWithStatusMeta {
pub transaction: VersionedTransaction,
pub meta: TransactionStatusMeta,
Expand Down Expand Up @@ -1018,14 +1023,16 @@ pub struct EncodedTransactionWithStatusMeta {
pub version: Option<TransactionVersion>,
}

#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConfirmedTransactionWithStatusMeta {
pub slot: Slot,
pub tx_with_meta: TransactionWithStatusMeta,
pub block_time: Option<UnixTimestamp>,
}

#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VersionedConfirmedTransactionWithStatusMeta {
pub slot: Slot,
pub tx_with_meta: VersionedTransactionWithStatusMeta,
Expand Down
Loading