developer-content icon indicating copy to clipboard operation
developer-content copied to clipboard

Fix typo in block.rewards.rewardType literals - Capitalize

Open paul-leydier opened this issue 1 year ago • 1 comments

Problem

The documentation page for GetBlock endpoint shows potential rewardType to be one of:

"fee", "rent", "voting", "staking"

These are not capitalized.

However, querying the endpoint on block 257199412 with the following HTTP body:

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getBlock",
    "params": [
        257199412,
        {
            "encoding": "json",
            "maxSupportedTransactionVersion": 0,
            "transactionDetails": "none",
            "rewards": true
        }
    ]
}

Returns:

{
    "jsonrpc": "2.0",
    "result": {
        "blockHeight": 237611155,
        "blockTime": 1711735787,
        "blockhash": "B1Y7EQCzGxR9SdWEDYBNEZ3rGNDzm474bCmNCKCHUXfq",
        "parentSlot": 257199411,
        "previousBlockhash": "8rQyMomtZUgeEtmgfXXd6HAmf6Yfw7dCyfdqdmPHeSKb",
        "rewards": [
            {
                "commission": null,
                "lamports": 31619653,
                "postBalance": 3194164089961,
                "pubkey": "q9XWcZ7T1wP4bW9SB4XgNNwjnFEJ982nE8aVbbNuwot",
                "rewardType": "Fee"
            }
        ]
    },
    "id": 1
}

Note the capitalization of "Fee" in the response. This can cause confusion for developper parsing the response with non-loose parsers.

Summary of Changes

I simply capitalized the described rewardType literals in the docs.

paul-leydier avatar Mar 29 '24 18:03 paul-leydier

Nice catch! The current response does in fact give a response with the first letter capitalized.

After a bit of digging in the rpc code base, I think this is actually not intended. Based on the Reward struct within a ConfirmedBlock

It should be using this formatter giving a lower case value

nickfrosty avatar Apr 03 '24 18:04 nickfrosty