michaelhly / solana-py

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

get account info fails #430

Closed benjiqq closed 3 months ago

benjiqq commented 3 months ago

trying to get account info with

data = rpc.get_account_info(Pubkey.from_string('AqHXpryMJGV3moqj1db9VwpHHUpa6514z2cjKEQAEave')).value.data

result

  File ".venv/lib/python3.12/site-packages/solana/rpc/providers/http.py", line 49, in make_request
    return _parse_raw(raw, parser=parser)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/solana/rpc/providers/core.py", line 98, in _parse_raw
    parsed = parser.from_json(raw)  # type: ignore
             ^^^^^^^^^^^^^^^^^^^^^
solders.SerdeJSONError: data did not match any variant of untagged enum Resp
kevinheavey commented 3 months ago

Can you share the raw JSON response please?

benjiqq commented 3 months ago

this is with solders v0.21

{"jsonrpc":"2.0","result":{"context":{"apiVersion":"1.17.31","slot":266554982},"value":{"data":["c2VydW0DAAAAAAAAAJIXwNx73+92frrHtiqY5nZ7GtaxW1pOkpAFGjX0xJsDAAAAAAAAAAAgYjCqmYLW2An36Cdc4LHRnnisNgMHMaAPgX0JdBJKrgabiFf+q4GE+2h/Y0YYwDXaxDncGus7VZig8AAAAAABGzP2S1SD8dnU2qQ5Jl0K5m8omk8DF7xtonYAIECcwwMAAAAAAAAAAAAAAAAAAAAAvKsswOi7ENPYfUUrMZzNqgc7Qk8V/e+wskcTcy/1BzEAAAAAAAAAAAAAAAAAAAAA9AEAAAAAAAB0VbYDzMan0ps8x3gPLVJJX9e6wJlIt/dOlVOBCkiKTSAa/1CEqQyY2+c26Lhk9JHUW3ruCAzrIv2K29zXoNZEUeR822+axIOs5eMMrYL5xlMMxXHwFAhvqq/hvG1FNJjRznt2p1rP++YudOFG1WhLCvqmvU/XxO7aa65xJNFMK+gDAAAAAAAA6AMAAAAAAACWAAAAAAAAAAAAAAAAAAAAcGFkZGluZw==","base64"],"executable":false,"lamports":3591360,"owner":"srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX","rentEpoch":18446744073709552000,"space":388}},"id":0}

benjiqq commented 3 months ago

might had been related to some config on my system, works now. there is also get_account_info_json_parsed

uv pip  show solana
Name: solana
Version: 0.34.0
Requires: construct-typing, httpx, solders, typing-extensions, websockets
Required-by:

uv pip  show solders
Name: solders
Version: 0.21.0
Requires: jsonalias, typing-extensions
Required-by: solana
data = rpc.get_account_info(Pubkey.from_string('AqHXpryMJGV3moqj1db9VwpHHUpa6514z2cjKEQAEave')).value.data    
    print(data)

    data = rpc.get_account_info_json_parsed(Pubkey.from_string('AqHXpryMJGV3moqj1db9VwpHHUpa6514z2cjKEQAEave'))
    print(data)

GetAccountInfoMaybeJsonParsedResp { context: RpcResponseContext { slot: 266883301, api_version: Some("1.17.31") }, value: Some(Parsed(AccountJSON { lamports: 1461600, data: ParsedAccount(ParsedAccount { program: "spl-token", parsed: Object {"info": Object {"decimals": Number(9), "freezeAuthority": Null, "isInitialized": Bool(true), "mintAuthority": String("CXAYcMhBa1ciER2YooiNAGVriP6xDogfELqjwNYNTAp7"), "supply": String("9900000000000000000")}, "type": String("mint")}, space: 82 }), owner: Pubkey(TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA), executable: false, rent_epoch: 18446744073709551615 })) }
b'serum\x03\x00\x00\x00\x00\x00\x00\x00\x92\x17\xc0\xdc{\xdf\xefv~\xba\xc7\xb6*\x98\xe6v{\x1a\xd6\xb1[ZN\x92\x90\x05\x1a5\xf4\xc4\x9b\x03\x00\x00\x00\x00\x00\x00\x00\x00 b0\xaa\x99\x82\xd6\xd8\t\xf7\xe8\'\\\xe0\xb1\xd1\x9ex\xac6\x03\x071\xa0\x0f\x81}\tt\x12J\xae\x06\x9b\x88W\xfe\xab\x81\x84\xfbh\x7fcF\x18\xc05\xda\xc49\xdc\x1a\xeb;U\x98\xa0\xf0\x00\x00\x00\x00\x01\x1b3\xf6KT\x83\xf1\xd9\xd4\xda\xa49&]\n\xe6o(\x9aO\x03\x17\xbcm\xa2v\x00 @\x9c\xc3\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbc\xab,\xc0\xe8\xbb\x10\xd3\xd8}E+1\x9c\xcd\xaa\x07;BO\x15\xfd\xef\xb0\xb2G\x13s/\xf5\x071\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\x01\x00\x00\x00\x00\x00\x00tU\xb6\x03\xcc\xc6\xa7\xd2\x9b<\xc7x\x0f-RI_\xd7\xba\xc0\x99H\xb7\xf7N\x95S\x81\nH\x8aM \x1a\xffP\x84\xa9\x0c\x98\xdb\xe76\xe8\xb8d\xf4\x91\xd4[z\xee\x08\x0c\xeb"\xfd\x8a\xdb\xdc\xd7\xa0\xd6DQ\xe4|\xdbo\x9a\xc4\x83\xac\xe5\xe3\x0c\xad\x82\xf9\xc6S\x0c\xc5q\xf0\x14\x08o\xaa\xaf\xe1\xbcmE4\x98\xd1\xce{v\xa7Z\xcf\xfb\xe6.t\xe1F\xd5hK\n\xfa\xa6\xbdO\xd7\xc4\xee\xdak\xaeq$\xd1L+\xe8\x03\x00\x00\x00\x00\x00\x00\xe8\x03\x00\x00\x00\x00\x00\x00\x96\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00padding'
GetAccountInfoMaybeJsonParsedResp { context: RpcResponseContext { slot: 266883301, api_version: Some("1.17.31") }, value: Some(Binary(Account { lamports: 3591360, data: [115, 101, 114, 117, 109, 3, 0, 0, 0, 0, 0, 0, 0, 146, 23, 192, 220, 123, 223, 239, 118, 126, 186, 199, 182, 42, 152, 230, 118, 123, 26, 214, 177, 91, 90, 78, 146, 144, 5, 26, 53, 244, 196, 155, 3, 0, 0, 0, 0, 0, 0, 0, 0, 32, 98, 48, 170, 153, 130, 214, 216, 9, 247, 232, 39, 92, 224, 177, 209, 158, 120, 172, 54, 3, 7, 49, 160, 15, 129, 125, 9, 116, 18, 74, 174, 6, 155, 136, 87, 254, 171, 129, 132, 251, 104, 127, 99, 70, 24, 192, 53, 218, 196, 57, 220, 26, 235, 59, 85, 152, 160, 240, 0, 0, 0, 0, 1, 27, 51, 246, 75, 84, 131, 241, 217, 212, 218, 164, 57, 38, 93, 10, 230, 111, 40, 154, 79, 3, 23, 188, 109, 162, 118, 0, 32, 64, 156, 195, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 188, 171, 44, 192, 232, 187, 16, 211, 216, 125, 69, 43, 49, 156, 205, 170, 7, 59, 66, 79, 21, 253, 239, 176, 178, 71, 19, 115, 47, 245, 7, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 0, 0, 0, 0, 116, 85, 182, 3, 204, 198, 167, 210, 155, 60, 199, 120, 15, 45, 82, 73, 95, 215, 186, 192, 153, 72, 183, 247, 78, 149, 83, 129, 10, 72, 138, 77, 32, 26, 255, 80, 132, 169, 12, 152, 219, 231, 54, 232, 184, 100, 244, 145, 212, 91, 122, 238, 8, 12, 235, 34, 253, 138, 219, 220, 215, 160, 214, 68, 81, 228, 124, 219, 111, 154, 196, 131, 172, 229, 227, 12, 173, 130, 249, 198, 83, 12, 197, 113, 240, 20, 8, 111, 170, 175, 225, 188, 109, 69, 52, 152, 209, 206, 123, 118, 167, 90, 207, 251, 230, 46, 116, 225, 70, 213, 104, 75, 10, 250, 166, 189, 79, 215, 196, 238, 218, 107, 174, 113, 36, 209, 76, 43, 232, 3, 0, 0, 0, 0, 0, 0, 232, 3, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 97, 100, 100, 105, 110, 103], owner: Pubkey(srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX), executable: false, rent_epoch: 18446744073709551615 })) }```