telescope icon indicating copy to clipboard operation
telescope copied to clipboard

Supporting doubles

Open KeKs0r opened this issue 1 year ago • 2 comments

Hi,

I am trying to decode queries for Umee, and they apparently use the double type: https://github.com/umee-network/umee/blob/main/proto/umee/leverage/v1/query.proto#L409

But when generating code i see that the binary reader throws an error that double is not supported:

Error: double not supported

Is there a known workaround, or way to support doubles?

KeKs0r avatar Apr 02 '24 15:04 KeKs0r

hey there @KeKs0r ! Thanks for reporting. it was our understanding not to support floats, doubles, or proto2 fields.

@webmaster128 — Simon, did we misunderstand, and is double something we need? It looks like umee is using double, not sure how the encoding should output, but we can take a look at ts-proto output

ideally mayabe we can treat double similar to other fields and maybe not a big add on

pyramation avatar Apr 03 '24 01:04 pyramation

As far as I can tell (and according to this resource), the JavaScript number type is a 64 bit float, i.e. can hold protobuf floats and doubles.

Floats/doubles are generally not used much in blockchains as their behaviour can be host specific and can lead to non-deterministic execution. However, there are cases like compute in a query where this is safe as long as the query result is not used by the chain itself (which happens if you allow CosmWasm contracts to do the query).

webmaster128 avatar Apr 03 '24 06:04 webmaster128