Merge #697

697: Remove inconsistent insertedAtTime lens. r=piotr-iohk a=jonathanknowles

Issue Number

None.

Overview

This lens is not quite correct, as the setter updates the slot ID to (1, 1) regardless of what time is specified. Using the setter could lead to inconsistency between the slot ID and the time.

Luckily, since we only need the getter functionality, we can remove the lens and replicate the functionality with simple function composition.

Co-authored-by: Jonathan Knowles [email protected]

View on GitHub
File Changes
    , direction
    , feeEstimator
    , inputs
-
    , insertedAtTime
    , passphraseLastUpdate
    , state
    , status
import Cardano.Wallet.Api.Types
    ( AddressAmount
    , ApiAddress
-
    , ApiBlockData (..)
    , ApiT (..)
    , ApiTransaction
    , ApiTxInput (..)
    , Hash (..)
    , HistogramBar (..)
    , PoolId (..)
-
    , SlotId (..)
    , SortOrder (..)
    , TxIn (..)
    , TxOut (..)
    _set :: HasType (ApiT Direction) s => (s, Direction) -> s
    _set (s, v) = set typed (ApiT v) s

                      
-
insertedAtTime :: HasType (Maybe ApiBlockData) s => Lens' s (Maybe UTCTime)
-
insertedAtTime =
-
    lens _get _set
-
  where
-
    _get :: HasType (Maybe ApiBlockData) s => s -> (Maybe UTCTime)
-
    _get = fmap (time) . view typed
-
    _set :: HasType (Maybe ApiBlockData) s => (s, (Maybe UTCTime)) -> s
-
    _set (s, v) = set typed (fn <$> v) s
-
         where fn t = ApiBlockData (t) (ApiT (SlotId 1 1))
-

                      
inputs :: HasType [ApiTxInput t] s => Lens' s [ApiTxInput t]
inputs =
    lens _get _set
    , fixtureWallet
    , fixtureWalletWith
    , getWalletEp
-
    , insertedAtTime
    , json
    , listAddresses
    , listAllTransactions
                , replicate 10 2
                ]
        txs <- listAllTransactions ctx w
-
        let [Just t2, Just t1] = map (view insertedAtTime) txs
+
        let [Just t2, Just t1] = fmap (fmap time . insertedAt) txs
        let matrix :: [TestCase [ApiTransaction t]] =
                [ TestCase -- 1
                    { query = toQueryString