f-o-a-m / kepler

A Haskell framework that facilitates writing ABCI applications
https://kepler.dev
Apache License 2.0
34 stars 9 forks source link

Switch protobuf library to awakesecurity/proto3-suite #95

Closed martyall closed 4 years ago

martyall commented 4 years ago

https://github.com/awakesecurity/proto3-suite

taken from rocketchat:

(1) we still use protofiles for the Network.ABCI.Types.Messages, and this library can still process those so there's no difference there (2) You can still do that for every other type that you want, i.e. ones that maybe you didn't define in your app (3) Currently you need to write protobuf files by hand in order to make tx message types. This requires you to know protobuf well enough to model all your stuff consistently in proto that you eventually want to represent in haskell

martyall commented 4 years ago

for the wrapper types, by analogy as long as Cat and Dog have FromJSON instance, this works

data Foo = Foo 
  { cat :: Cat
  , dog :: Dog
  } deriving Generic

instance FromJSON Foo where
  parseJSON = genericParseJSON defaultOptions

See if we can get a similar high level interface

IvantheTricourne commented 4 years ago

Link to the tutorial

With regards to @blinky3713:

See if we can get a similar high level interface

At first glance, it seems that most field types have to use the low level types (e.g. Word32 and Int32, see here), with some flexibility around using another proto message type as a field.

Will look for further options.

IvantheTricourne commented 4 years ago

This was also quite useful: Low level tutorial

IvantheTricourne commented 4 years ago

See here for a running example (complete with encode/decode + .proto generation capabilities):

https://github.com/f-o-a-m/hs-abci/blob/test-proto3/hs-abci-examples/nameservice/src/Nameservice/Protogen.hs