Skip to content

Commit

Permalink
Add serialization-control enum for RPC Options (#27676)
Browse files Browse the repository at this point in the history
* Add test to verify output when deserializing/reserializing empty fields

* Add test to verify serialization from UiTransactionStatusMeta constructors

* Add OptionSerializer

* Use OptionSerializer for inner_instructions

* Use OptionSerializer for loaded_addresses

* Remove Default variant, use into instead

* Add as_ref implementation

* Use OptionSerializer for log_messages and rewards

* Use OptionSerializer for token_balances

* Use OptionSerializer for return_data

* Use OptionSerializer for compute_units_consumed

(cherry picked from commit 360ca07)
  • Loading branch information
Tyera Eulberg committed Sep 14, 2022
1 parent 8aec979 commit 2350d3e
Show file tree
Hide file tree
Showing 4 changed files with 324 additions and 54 deletions.
12 changes: 8 additions & 4 deletions cli-output/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,14 @@ 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_log_messages(w, transaction_status.log_messages.as_ref(), prefix)?;
write_return_data(w, transaction_status.return_data.as_ref(), prefix)?;
write_rewards(w, transaction_status.rewards.as_ref(), 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)?;
} else {
writeln!(w, "{}Status: Unavailable", prefix)?;
}
Expand Down
19 changes: 10 additions & 9 deletions client/src/mock_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ use {
transaction::{self, Transaction, TransactionError, TransactionVersion},
},
solana_transaction_status::{
EncodedConfirmedBlock, EncodedConfirmedTransactionWithStatusMeta, EncodedTransaction,
option_serializer::OptionSerializer, EncodedConfirmedBlock,
EncodedConfirmedTransactionWithStatusMeta, EncodedTransaction,
EncodedTransactionWithStatusMeta, Rewards, TransactionBinaryEncoding,
TransactionConfirmationStatus, TransactionStatus, UiCompiledInstruction, UiMessage,
UiRawMessage, UiTransaction, UiTransactionStatusMeta,
Expand Down Expand Up @@ -223,14 +224,14 @@ impl RpcSender for MockSender {
fee: 0,
pre_balances: vec![499999999999999950, 50, 1],
post_balances: vec![499999999999999950, 50, 1],
inner_instructions: None,
log_messages: None,
pre_token_balances: None,
post_token_balances: None,
rewards: None,
loaded_addresses: None,
return_data: None,
compute_units_consumed: None,
inner_instructions: OptionSerializer::None,
log_messages: OptionSerializer::None,
pre_token_balances: OptionSerializer::None,
post_token_balances: OptionSerializer::None,
rewards: OptionSerializer::None,
loaded_addresses: OptionSerializer::Skip,
return_data: OptionSerializer::Skip,
compute_units_consumed: OptionSerializer::Skip,
}),
},
block_time: Some(1628633791),
Expand Down
Loading

0 comments on commit 2350d3e

Please sign in to comment.