Closed aaroncox closed 1 year ago
I don't think it's a good idea to treat NaN as zero. If we need to support this I think we just need to move the checks out of the float constructor and allow it to exist as a NaN or Infinity
@jnordberg Yeah, that's probably better. It looks like just removing that stuff works in https://github.com/wharfkit/antelope/pull/78/commits/6fd89b04cadc88a9c16eaeb0a207227ff31aadaf, and tests still pass.
Those records in a table row call now come back looking like:
{
id: UInt64 { value: [BN] },
token0: { contract: [Name], symbol: [Symbol] },
token1: { contract: [Name], symbol: [Symbol] },
reserve0: Asset { units: [Int64], symbol: [Symbol] },
reserve1: Asset { units: [Int64], symbol: [Symbol] },
liquidity_token: UInt64 { value: [BN] },
price0_last: Float64 { value: NaN },
price1_last: Float64 { value: NaN },
price0_cumulative_last: UInt64 { value: [BN] },
price1_cumulative_last: UInt64 { value: [BN] },
block_time_last: TimePointSec { value: [UInt32] }
}
Applications upstream can deal with NaN
when it exists then.
This is related to: https://github.com/wharfkit/contract/issues/50
The contract and APIs can apparently return
-nan
as a value here as aFloat
. This adds a check that detects this weirdness, and if found, just sets the value to the float as 0 and proceeds.I'm open to ideas on how better to resolve this. We just need to accept that the APIs will not return valid data here that matches the ABI for some reason.