tendermint / go-amino

Protobuf3 with Interface support - Designed for blockchains (deterministic, upgradeable, fast, and compact)
Other
260 stars 84 forks source link

Expose types #292

Open jackzampolin opened 4 years ago

jackzampolin commented 4 years ago

Replaces https://github.com/tendermint/go-amino/pull/291

ebuchman commented 4 years ago

Can we open an issue for this please?

Also note there is the Codec.PrintTypes method which outputs a pretty table like: https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/encoding.md#public-key-cryptography. Ie that table is the output of https://github.com/tendermint/tendermint/blob/master/crypto/encoding/amino/encode_test.go#L56

I'm not sure exactly the use case here, but if you don't need it programmatically, hopefully printing the table is sufficient. Otherwise you will need to grab the mutex and copy the map, as bez pointed out

jackzampolin commented 4 years ago

This was some quick hacking I did one afternoon to try to expose the types tracked by amino in a json format so that we could turn them easily into typescript definitions. The codec.PrintTypes function doesn't give enough info for this. This PR should be in draft and thats my bad.

I believe that Hans is working on this so I would like to check with him before closing/doing more work.

ebuchman commented 4 years ago

Oh cool - would a method that just dumps JSON be sufficient then? Might be easier than trying to programmatically export the mutex protected maps ...

jackzampolin commented 4 years ago

@ebuchman I think it would. How to do that with the existing code? This also could be useful for generating .proto types.