solana-foundation / developer-content

Collection of Developer content for exploring, learning, and building in the Solana ecosystem.
https://solana.com/developers
94 stars 136 forks source link

Fix typo in block.rewards.rewardType literals - Capitalize #152

Open paul-leydier opened 4 months ago

paul-leydier commented 4 months ago

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.

nickfrosty commented 4 months ago

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