-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sdk.Dec JSON Marshal to String() #2475
Comments
One thing to note is that if we go with marshalling using |
I don't really agree, why would we add a decimal? In JSON that might lead to reduced precision due to floating-point arithmetic. Perhaps the LCD should expose the constant precision factor via API to enable frontends to convert easily. |
There's two encodings here, JSON and amino. This proposal is basically asking about switching from encoding the number directly to instead encode the number as a string / bytes. I have no problem with marshalling as a string with the decimal in JSON. That seems like a much better approach. This then improves the clarity, and ease of integrating. There is no fear of floating point arithmetic, as it would encoded as a string essentially. For amino I don't think we should do this. Part of the efficiency of protobuf is that you know the type at the field, so you don't have to do stuff like this. |
Yeah, I'm pretty sure we can marshal differently for json/amino - we should totally marshal json decimal to a string 👍 |
Marshaling to a string with a decimal is fine but is that what @faboweb is asking for? |
I guess there were two ways to interpet |
I am only asking for marshalling to string not amino. |
FYI were switching to ints here once fee distribution is merged, so this shouldn't be a problem. I still agree with changing this anyway though, as it will be needed when handling stuff for fee distribution. |
Nice! |
Co-authored-by: Marius Poke <[email protected]>
Summary of Bug
sdk.Dec
of the value1000
marshalls to a string representation1000000000000
. 1000000000000 is an internal precision representation. The marshalled value should be1000.000000000
.Steps to Reproduce
For Admin Use
The text was updated successfully, but these errors were encountered: