michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
979 stars 252 forks source link

Discrepancy in `get_account_info` Response Using Client vs. Direct RPC #429

Closed rehanpunjwani closed 4 months ago

rehanpunjwani commented 4 months ago

Overview

There appears to be a discrepancy in the response received when querying account information using the client method versus a direct RPC call.

Client Method

Version: 0.34 Request:

Python

client.get_account_info(Pubkey.from_string("BLZEEuZUBVqFhj8adcCFPJvPVCiCyVmh3hkJMrU8KuJA")).to_json()

Response:

JSON

{
    "jsonrpc": "2.0",
    "result": {
        "context": {
            "slot": 266143855,
            "apiVersion": "1.17.28"
        },
        "value": {
            "lamports": 2558366285,
            "data": [
                "AAAAAAi2aQPmj/kyc1PszrLaqtyAYSpJobj5d6Ix+gjkmqjkxKegvsQjxYoJAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
                "base64"
            ],
            "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
            "executable": false,
            "rentEpoch": 18446744073709551615,
            "space": null
        }
    },
    "id": 0
}

Direct RPC Method

Request:

curl --location 'https://api.mainnet-beta.solana.com'\
--header 'Content-Type: application/json'\
--data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getAccountInfo",
    "params": [
        "BLZEEuZUBVqFhj8adcCFPJvPVCiCyVmh3hkJMrU8KuJA",
        {
            "encoding": "jsonParsed"
        }
    ]
}'

Response:

JSON

{
    "jsonrpc": "2.0",
    "result": {
        "context": {
            "apiVersion": "1.17.28",
            "slot": 266143976
        },
        "value": {
            "data": {
                "parsed": {
                    "info": {
                        "decimals": 9,
                        "freezeAuthority": null,
                        "isInitialized": true,
                        "mintAuthority": null,
                        "supply": "9999437875564816324"
                    },
                    "type": "mint"
                },
                "program": "spl-token",
                "space": 82
            },
            "executable": false,
            "lamports": 2558366285,
            "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
            "rentEpoch": 18446744073709551615,
            "space": 82
        }
    },
    "id": 1
}

Issue

The client method response does not include the parsed data, which contains important information such as decimalsisInitialized, and supply.

Expected Behavior

Both the client method and the direct RPC call should return the same level of detailed information.

Steps to Reproduce

  1. Execute the client method code to fetch account information.
  2. Execute the direct RPC call using curl.
  3. Compare the responses from both methods.
michaelhly commented 4 months ago

You can use https://michaelhly.com/solana-py/rpc/api/#solana.rpc.api.Client.get_account_info_json_parsed