diff --git a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/Mock.hs b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/Mock.hs index 0e368b02d0f..f0655bc4b4a 100644 --- a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/Mock.hs +++ b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/Mock.hs @@ -94,5 +94,4 @@ newNetworkEnvMock = do , getTimeInterpreter = pure $ Time.toTimeTranslationPure Time.mockTimeInterpreter , slotToUTCTime = pure Time.unsafeUTCTimeOfSlot --- , utcTimeToSlot = pure . Just . Time.unsafeSlotOfUTCTime } diff --git a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/NodeToClient.hs b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/NodeToClient.hs index 6c942c9f4a5..41a6ccb4615 100644 --- a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/NodeToClient.hs +++ b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/NodeToClient.hs @@ -75,27 +75,6 @@ import qualified Cardano.Wallet.Network.Implementation as NetworkLayer NodeToClient 'NetworkEnv' ------------------------------------------------------------------------------} -withNetwork - :: HasCallStack - => NetworkParameters - -- ^ Initial blockchain parameters - -> CardanoNodeConn - -- ^ Socket for communicating with the node - -> NodeToClientVersionData - -- ^ Codecs for the node's client - -> SyncTolerance - -> (NetworkEnv IO (Read.EraValue Read.Block) -> IO a) - -- ^ Callback function with the network layer - -> IO a -withNetwork np conn vData syncTol act = - NetworkLayer.withNetworkLayer - nullTracer -- Using this for now - tunedForMainnetPipeliningStrategy - np - conn - vData - syncTol - (act . fromNetworkLayer) -- | Translate the old NetworkLayer to the new NetworkEnv interface fromNetworkLayer @@ -115,7 +94,6 @@ fromNetworkLayer nl = mapBlock Read.fromConsensusBlock $ NetworkLayer.currentPParams nl , getTimeInterpreter = toTimeTranslation (NetworkLayer.timeInterpreter nl) , slotToUTCTime = Time.slotToUTCTime <$> snapshot ti --- , utcTimeToSlot = pure . Just . Time.unsafeSlotOfUTCTime } where diff --git a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/Type.hs b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/Type.hs index 5b912b50dfb..8e3d92cff59 100644 --- a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/Type.hs +++ b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO/Network/Type.hs @@ -58,16 +58,12 @@ data NetworkEnv m block = NetworkEnv , currentPParams :: m (Read.EraValue Read.PParams) -- ^ Current protocol paramters. - , getTimeInterpreter + , getTimeTranslation :: m Time.TimeTranslation -- ^ Get the current 'TimeInterpreter' from the Cardano node. , slotToUTCTime :: m (Slot -> (Maybe (WithOrigin UTCTime))) --- -- ^ Try to convert a set of slots to their UTCTimes counterparts --- , utcTimeToSlot --- :: UTCTime --- -> m (Maybe Slot) } mapBlock diff --git a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Time.hs b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Time.hs index bda67cb7b53..cbf9992fa65 100644 --- a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Time.hs +++ b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Time.hs @@ -100,20 +100,16 @@ type LookupTimeFromSlot = Slot -> Maybe (WithOrigin UTCTime) TimeInterpreter ------------------------------------------------------------------------------} --- TODO: Is this the start time of the slot? +-- | Look up the UTCTime corresponding to the start of the provided `Slot`. + +TODO: Check roundtrip properties once we need to implement the corresponding 'utcTimeToSlot'. slotToUTCTime :: TimeInterpreter -> LookupTimeFromSlot -slotToUTCTime _ti Origin = Just Origin --either (const Nothing) Just $ interpretQuery ti $ Primitive.slotToUTCTime minBound +slotToUTCTime _ti Origin = Just Origin slotToUTCTime ti (At s) = either (const Nothing) (Just . At) . interpretQuery ti . Primitive.slotToUTCTime =<< convertSlotNo s where convertSlotNo :: SlotNo -> Maybe Primitive.SlotNo convertSlotNo (SlotNo n) = Primitive.SlotNo <$> intCastMaybe n ---utcTimeToSlot :: TimeInterpreter -> UTCTime -> Maybe Slot ---utcTimeToSlot ti t = either (const Nothing) Just . interpretQuery ti $ do --- ongoingSlotAt $ toRelativeTime startTime t --- where --- convertSlotNo :: Primitive.SlotNo -> SlotNo --- convertSlotNo (Primitive.SlotNo n) = SlotNo $ intCast n -- TODO: Rename to mainnetUTCTimeOfSlot -- TODO: Move to tests?