Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Use OptionSerializer for compute_units_consumed
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Sep 14, 2022
1 parent 37998ff commit d364eb9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion cli-output/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ fn write_transaction<W: io::Write>(
write_status(w, &transaction_status.status, prefix)?;
write_fees(w, transaction_status.fee, prefix)?;
write_balances(w, transaction_status, prefix)?;
write_compute_units_consumed(w, transaction_status.compute_units_consumed, prefix)?;
write_compute_units_consumed(
w,
transaction_status.compute_units_consumed.clone().into(),
prefix,
)?;
write_log_messages(w, transaction_status.log_messages.as_ref().into(), prefix)?;
write_return_data(w, transaction_status.return_data.as_ref().into(), prefix)?;
write_rewards(w, transaction_status.rewards.as_ref().into(), prefix)?;
Expand Down
2 changes: 1 addition & 1 deletion rpc-client/src/mock_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl RpcSender for MockSender {
rewards: OptionSerializer::None,
loaded_addresses: OptionSerializer::Skip,
return_data: OptionSerializer::Skip,
compute_units_consumed: None,
compute_units_consumed: OptionSerializer::Skip,
}),
},
block_time: Some(1628633791),
Expand Down
11 changes: 7 additions & 4 deletions transaction-status/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,11 @@ pub struct UiTransactionStatusMeta {
skip_serializing_if = "OptionSerializer::should_skip"
)]
pub return_data: OptionSerializer<UiTransactionReturnData>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub compute_units_consumed: Option<u64>,
#[serde(
default = "OptionSerializer::skip",
skip_serializing_if = "OptionSerializer::should_skip"
)]
pub compute_units_consumed: OptionSerializer<u64>,
}

/// A duplicate representation of LoadedAddresses
Expand Down Expand Up @@ -423,7 +426,7 @@ impl UiTransactionStatusMeta {
return_data: OptionSerializer::or_skip(
meta.return_data.map(|return_data| return_data.into()),
),
compute_units_consumed: meta.compute_units_consumed,
compute_units_consumed: OptionSerializer::or_skip(meta.compute_units_consumed),
}
}
}
Expand Down Expand Up @@ -454,7 +457,7 @@ impl From<TransactionStatusMeta> for UiTransactionStatusMeta {
return_data: OptionSerializer::or_skip(
meta.return_data.map(|return_data| return_data.into()),
),
compute_units_consumed: meta.compute_units_consumed,
compute_units_consumed: OptionSerializer::or_skip(meta.compute_units_consumed),
}
}
}
Expand Down

0 comments on commit d364eb9

Please sign in to comment.