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
During the review of #573@andrevmatos found a potential problem: our losslessParse() function, which is used for parsing JSON API responses, only converts numbers of the type string into BigNumber. This is because the Raiden API does return all numbers as strings. However the PFS API uses the JSON number type for numbers. This is no problem at the moment, because we don't use the numbers from the PFS API, but could be one in the future. We should use a library for parsing.
This losslessParse may work only if the BNs are stringified on the JSONs (since this revive function from JSON.parse is called only after the number already got parsed as such), while it seems the current PFS implementation encodes the capacity and other BNs as JSON number. This may only be working now if the numbers on your test were small (i.e. < 2^53).
We had this issue on the LC, and ended up using json-bigint lib to parse these JSONs. Check here for our implementation.
Notice you need to use a proper decoder/schema validator if you go the way we did, since it'll ensure these values are kept as strings, or use it with your reviver function after using the lib to ensure the BNs are kept as strings or bigint or whatever.. We already had the schemas in place, so went with it, but you can use the reviver as well if you don't care that much with the typesafety there.
The text was updated successfully, but these errors were encountered:
During the review of #573 @andrevmatos found a potential problem: our
losslessParse()
function, which is used for parsing JSON API responses, only converts numbers of the typestring
intoBigNumber
. This is because the Raiden API does return all numbers as strings. However the PFS API uses the JSONnumber
type for numbers. This is no problem at the moment, because we don't use the numbers from the PFS API, but could be one in the future. We should use a library for parsing.André's comment from #573:
The text was updated successfully, but these errors were encountered: