solana-go
solana-go copied to clipboard
Check for malformed responses in getAccountInfo/getMultipleAccounts
GetObject could unmarshal into nil which would cause a panic when referring to out.Value.
This is unlikely since a node will typically return well formed responses but still worth fixing.
Most RPC calls also have issues: they return pointers which could be deserialized to nil
.
For example https://github.com/gagliardetto/solana-go/blob/7de08b22f3afd588a275212aff05fa5f2580f356/rpc/getBalance.go#L25-L34 could return GetBalanceResult
rather than *GetBalanceResult
?
See https://github.com/gagliardetto/solana-go/issues/45
Most RPC calls also have issues: they return pointers which could be deserialized to
nil
.For example
https://github.com/gagliardetto/solana-go/blob/7de08b22f3afd588a275212aff05fa5f2580f356/rpc/getBalance.go#L25-L34
could return
GetBalanceResult
rather than*GetBalanceResult
?
How would you know that you have a real GetBalanceResult
an not just one that was null
json? You can only if you use a *GetBalanceResult
.
If the response deserializes to nil, that either follows the spec (e.g. getBlock: https://github.com/solana-labs/solana/blob/master/docs/src/developing/clients/jsonrpc-api.md#getblock ) or is an error on the RPC provider part.
I'll leave that to the library user for now to implement given they know best that RPC they are dealing with.