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

Commit

Permalink
Respect showRewards parameter in tx meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Sep 14, 2022
1 parent 67363ba commit 750a083
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions transaction-status/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl UiTransactionStatusMeta {
}
}

fn build_simple(meta: TransactionStatusMeta) -> Self {
fn build_simple(meta: TransactionStatusMeta, show_rewards: bool) -> Self {
Self {
err: meta.status.clone().err(),
status: meta.status,
Expand All @@ -455,7 +455,11 @@ impl UiTransactionStatusMeta {
.post_token_balances
.map(|balance| balance.into_iter().map(Into::into).collect())
.into(),
rewards: OptionSerializer::Skip,
rewards: if show_rewards {
meta.rewards.into()
} else {
OptionSerializer::Skip
},
loaded_addresses: OptionSerializer::Skip,
return_data: OptionSerializer::Skip,
compute_units_consumed: OptionSerializer::Skip,
Expand Down Expand Up @@ -647,8 +651,10 @@ impl ConfirmedBlock {
self.transactions
.into_iter()
.map(|tx_with_meta| {
tx_with_meta
.build_json_accounts(options.max_supported_transaction_version)
tx_with_meta.build_json_accounts(
options.max_supported_transaction_version,
options.show_rewards,
)
})
.collect::<Result<Vec<_>, _>>()?,
),
Expand Down Expand Up @@ -781,6 +787,7 @@ impl TransactionWithStatusMeta {
fn build_json_accounts(
self,
max_supported_transaction_version: Option<u8>,
show_rewards: bool,
) -> Result<EncodedTransactionWithStatusMeta, EncodeError> {
match self {
Self::MissingMetadata(ref transaction) => Ok(EncodedTransactionWithStatusMeta {
Expand All @@ -789,7 +796,7 @@ impl TransactionWithStatusMeta {
meta: None,
}),
Self::Complete(tx_with_meta) => {
tx_with_meta.build_json_accounts(max_supported_transaction_version)
tx_with_meta.build_json_accounts(max_supported_transaction_version, show_rewards)
}
}
}
Expand Down Expand Up @@ -858,6 +865,7 @@ impl VersionedTransactionWithStatusMeta {
fn build_json_accounts(
self,
max_supported_transaction_version: Option<u8>,
show_rewards: bool,
) -> Result<EncodedTransactionWithStatusMeta, EncodeError> {
let version = self.validate_version(max_supported_transaction_version)?;

Expand All @@ -880,7 +888,10 @@ impl VersionedTransactionWithStatusMeta {
.collect(),
account_keys,
}),
meta: Some(UiTransactionStatusMeta::build_simple(self.meta)),
meta: Some(UiTransactionStatusMeta::build_simple(
self.meta,
show_rewards,
)),
version,
})
}
Expand Down

0 comments on commit 750a083

Please sign in to comment.