Open ryanchristo opened 2 years ago
IMO, by default we should not think that stored object = presented object. So we should not be afraid to create a different structure for stored object and presentation object (the one we send out).
Hacky solution to this particular problem would be some proto annotations and having 2 codec modes which will understand that annotation and handle the coding. .... but to be honest, it looks too hacky ;)
With the ORM, the stored object is effectively the presented object because the ORM will expose its own direct query layer to clients. So we will need to figure out a way to solve the presentation problem with the ORM.
My current thinking has been:
cosmos_proto.scalar
annotations to indicate a bytes
field is an addressWe could also do gRPC where we auto-generated presentation types based on scalar
annotations, but that seems more heavy-handed... and graphql has other benefits...
Sorry this isn't well documented on the ORM side but we should write it up in one of the Framework WG calls
We spoke about this briefly on our standup this morning. The graphql solution sounds interesting but may require more work. @technicallyty is planning to look into the scalar annotation later today if he has the time.
Notes from product call:
For v4.0 release, we will need to create separate proto messages where addresses are represented as strings.
Moving my comments from #1022 here
This makes me want to spend a bit of time on the query infrastructure in the SDK using Cosmos scalars so we don't have to manually write all this stuff. But generally looking good @ryanchristo
There are a few design questions though if I'm going to spend some time. Do we auto-generate gRPC endpoints that just convert bytes to strings for
cosmos.AddressBytes
scalars? Do we relate this to the value renderer work for sign mode textual? Or maybe we jump straight to graphql?
What do you think @ryanchristo ?
What do you think @ryanchristo ?
I think we should consider jumping straight to graphql given we need more than just addresses converted from bytes to strings. Scalars will not eliminate our need for writing out queries as I have done in #1022.
What do you think @ryanchristo ?
I think we should consider jumping straight to graphql given we need more than just addresses converted from bytes to strings. Scalars will not eliminate our need for writing out queries as I have done in #1022.
I've sort of been leaning towards graphql as well
Summary
We are currently storing addresses as
bytes
in state proto messages for storage efficiency. We are also using the same messages in query responses and therefore returning addresses that are not human-readable.How do we make addresses readable in query responses?
Short-term solution:
Potential long-term solutions:
For Admin Use