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

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)

# Conflicts:
#	cli-output/src/display.rs
#	client/src/mock_sender.rs
#	transaction-status/src/lib.rs
  • Loading branch information
Tyera Eulberg authored and mergify[bot] committed Sep 14, 2022
1 parent aa0b46c commit 1bb22a8
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 21 deletions.
11 changes: 11 additions & 0 deletions cli-output/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,19 @@ 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)?;
<<<<<<< HEAD
write_log_messages(w, transaction_status.log_messages.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)?;
>>>>>>> 360ca07a4 (Add serialization-control enum for RPC Options (#27676))
} else {
writeln!(w, "{}Status: Unavailable", prefix)?;
}
Expand Down
14 changes: 13 additions & 1 deletion 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,12 +224,23 @@ impl RpcSender for MockSender {
fee: 0,
pre_balances: vec![499999999999999950, 50, 1],
post_balances: vec![499999999999999950, 50, 1],
<<<<<<< HEAD:client/src/mock_sender.rs
inner_instructions: None,
log_messages: None,
pre_token_balances: None,
post_token_balances: None,
rewards: None,
loaded_addresses: 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,
>>>>>>> 360ca07a4 (Add serialization-control enum for RPC Options (#27676)):rpc-client/src/mock_sender.rs
}),
},
block_time: Some(1628633791),
Expand Down
Loading

0 comments on commit 1bb22a8

Please sign in to comment.