From 6e13229484e5d8e32987d5255fec569de7e06eef Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 6 Sep 2022 11:52:39 -0600 Subject: [PATCH] Skip serializing empty fields --- docs/src/developing/clients/jsonrpc-api.md | 6 +++--- transaction-status/src/lib.rs | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index 57beb268f785c6..c9a9b9b85106d4 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -433,10 +433,10 @@ The result field will be an object with the following fields: - `fee: ` - fee this transaction was charged, as u64 integer - `preBalances: ` - array of u64 account balances from before the transaction was processed - `postBalances: ` - array of u64 account balances after the transaction was processed - - `innerInstructions: ` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction + - `innerInstructions: ` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - `postTokenBalances: ` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - - `logMessages: ` - array of string log messages or `null` if log message recording was not enabled during this transaction + - `logMessages: ` - array of string log messages or `null` if log message recording was not enabled during this transaction - DEPRECATED: `status: ` - Transaction status - `"Ok": ` - Transaction was successful - `"Err": ` - Transaction failed with TransactionError @@ -445,7 +445,7 @@ The result field will be an object with the following fields: - `readonly: ` - Ordered list of base-58 encoded addresses for readonly loaded accounts - `version: <"legacy"|number|undefined>` - Transaction version. Undefined if `maxSupportedTransactionVersion` is not set in request params. - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block - - `rewards: ` - present if rewards are requested; an array of JSON objects containing: + - `rewards: ` - present if rewards are requested; an array of JSON objects containing: - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - `postBalance: ` - account balance in lamports after the reward was applied diff --git a/transaction-status/src/lib.rs b/transaction-status/src/lib.rs index 87cdede1ecb5b0..5e43bbc011677b 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -326,13 +326,17 @@ pub struct UiTransactionStatusMeta { pub fee: u64, pub pre_balances: Vec, pub post_balances: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] pub inner_instructions: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] pub log_messages: Option>, pub pre_token_balances: Option>, pub post_token_balances: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] pub rewards: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub loaded_addresses: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] pub return_data: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub compute_units_consumed: Option,