project-serum / serum-js

JavaScript client library for interacting with the Project Serum DEX.
82 stars 33 forks source link

Provide a centralised conversion from binary to language specific format #9

Closed leofisG closed 3 years ago

leofisG commented 4 years ago

Currently, a huge part of the js-serum client codebase is doing binary parsing (which is returned by the Solana client), i.e. from a binary format to JS class. If someone is to build another client say, in Python, the developer needs to implement similar parsing logic to convert from a binary format into the language native format which is super error-prone and tedious.

It will be great if the conversion from binary format to a language-specific format can be done once across various language. The team can have a conversion from binary to, say protobuf or json. So it will be easier for different language client to be built.

thaaddeus commented 4 years ago

Don't want to open another issue, perhaps silly question by why not use 'jsonParsed' option (https://docs.solana.com/apps/jsonrpc-api#accountsubscribe) instead of base64? It's because it's unstable?

leofisG commented 4 years ago

This will only work with the native program in Solana. The Serum program is not native so it will not get parsed (since it doesn't know the format), and base64 result will be returned even if you used the jsonParsed option.

thaaddeus commented 4 years ago

Got it, makes perfect sense, thanks!

armaniferrante commented 4 years ago

I'm told this will be addressed, at least in part, by https://github.com/solana-labs/solana/issues/11214. There should be generic Solana tools to generate IDLs along with clients.

armaniferrante commented 3 years ago

This repository has moved to https://github.com/project-serum/serum-ts/tree/master/packages/serum. Please migrate this issue over, if desired.