[input-output-hk/cardano-sl] [CO-347] Wallet’s UTXO histogram view (#3402)

paweljakubas commented on this pull request.

> +instance FromJSON UtxoStatistics where
+ parseJSON = withObject «UtxoStatistics» $ \o -> do
+ histo <- o .: "histogram" :: Parser (HashMap Text Word64) + stakes <- o .: "allStakes" + case validateUtxoStatistics histo stakes of + Right (histogram, allStakes) -> do
+ let constructHistogram = uncurry HistogramBarCount
+ let histoBars = map constructHistogram $ HMS.toList histogram
+ pure $ UtxoStatistics histoBars allStakes
+ Left err -> fail $ «Failed to parse UtxoStatistics: » <> show err
+
+data UtxoStatisticsError
+ = ErrHistogramEmpty
+ | ErrHistogramNamesInvalid
+ | ErrHistogramUpperBoundsNegative
+ | ErrAllStakesNegative

addressed