You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 81ad8e6 a temporary measure was added for compatibility with the latest VF-GraphQL spec without requiring extensive updates to the zome APIs. To prevent any possible numerical truncation, the new Decimal type should be de/serialized as a string rather than a JavaScript number.
This will require a new externally-facing variant of the QuantityValue struct where has_numerical_value is a String. Custom serialization logic will need to be added to convert to/from the external string-based representation to an internal Rust format that is able to handle accurate arbitrary-precision decimal math. There are probably crates that integrate with Serde to do this automatically, but some investigation needs to be made.
Filing this as a bug since until these changes are made, very large values (in excess of 2^1024-1) will be truncated before sending. Since such use-cases are likely to be very rare, we can consider this a low priority issue.
The text was updated successfully, but these errors were encountered:
pospi
changed the title
Update zome API structs to use strings for passing numerical values
Update zome API structs to use strings for passing numerical values, avoiding potential value truncation
Jan 31, 2023
(Probably best to add that I'm unclear on the details re maximum expressible values in JS; could equally be 2^53 - 1 or some other value depending on floating point storage overhead and script engine.)
In 81ad8e6 a temporary measure was added for compatibility with the latest VF-GraphQL spec without requiring extensive updates to the zome APIs. To prevent any possible numerical truncation, the new
Decimal
type should be de/serialized as a string rather than a JavaScript number.This will require a new externally-facing variant of the
QuantityValue
struct wherehas_numerical_value
is a String. Custom serialization logic will need to be added to convert to/from the external string-based representation to an internal Rust format that is able to handle accurate arbitrary-precision decimal math. There are probably crates that integrate with Serde to do this automatically, but some investigation needs to be made.Filing this as a bug since until these changes are made, very large values (in excess of 2^1024-1) will be truncated before sending. Since such use-cases are likely to be very rare, we can consider this a low priority issue.
The text was updated successfully, but these errors were encountered: