blocto / solana-go-sdk

Solana Golang SDK
https://blocto.github.io/solana-go-sdk/
MIT License
366 stars 95 forks source link

Remove `omitempty` from `DataSlice` fields. #114

Closed omarkilani closed 1 year ago

omarkilani commented 1 year ago

offset and length can both be 0 in RPC calls (c.f. https://docs.solana.com/developing/clients/jsonrpc-api#results-27)

The current code stops JSON from encoding the fields if they're 0, thus breaking RPC calls with:

{"code":-32602,"message":"Invalid params: missing field offset.","data":null}

yihau commented 1 year ago

I'm thinking make them become pointers. if we remove omitempty, we wouldn't use them individually. wdyt?

omarkilani commented 1 year ago

@yihau as far as I'm aware both fields should always be specified by the user in every RPC call, according to the Solana RPC docs.

C.f. https://github.com/solana-labs/solana/blob/f1427dd90cbde993f489232a13bd89f836ed98bd/web3.js/src/connection.ts#L2555

yihau commented 1 year ago

oh... yeah. you're right. I got confused by the test result. I'll remove some test cases in this PR later.

yihau commented 1 year ago

Thank you for the patching!

omarkilani commented 1 year ago

@yihau any chance you could cut a release with this fix? For quality of life purposes. :)

yihau commented 1 year ago

sure! https://github.com/portto/solana-go-sdk/releases/tag/v1.23.0