Skip to content

Commit 4c56005

Browse files
author
gege251
committed
Add support for PosixTimeRangeToContainedSlotRangeReq
1 parent 92599e2 commit 4c56005

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/BotPlutusInterface/Contract.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import Ledger (POSIXTime)
3131
import Ledger.Address (PaymentPubKeyHash (PaymentPubKeyHash))
3232
import Ledger.Constraints.OffChain (UnbalancedTx (..))
3333
import Ledger.Slot (Slot (Slot))
34-
import Ledger.TimeSlot (slotToEndPOSIXTime)
34+
import Ledger.TimeSlot (posixTimeRangeToContainedSlotRange, slotToEndPOSIXTime)
3535
import Ledger.Tx (CardanoTx)
3636
import Ledger.Tx qualified as Tx
3737
import Plutus.ChainIndex.Types (RollbackState (Committed), TxValidity (..))
@@ -134,6 +134,11 @@ handlePABReq contractEnv req = do
134134
AwaitSlotReq s -> AwaitSlotResp <$> awaitSlot @w contractEnv s
135135
CurrentSlotReq -> CurrentSlotResp <$> currentSlot @w contractEnv
136136
CurrentTimeReq -> CurrentTimeResp <$> currentTime @w contractEnv
137+
PosixTimeRangeToContainedSlotRangeReq posixTimeRange ->
138+
pure $
139+
PosixTimeRangeToContainedSlotRangeResp $
140+
Right $
141+
posixTimeRangeToContainedSlotRange contractEnv.cePABConfig.pcSlotConfig posixTimeRange
137142
------------------------
138143
-- Unhandled requests --
139144
------------------------
@@ -142,7 +147,6 @@ handlePABReq contractEnv req = do
142147
-- AwaitUtxoProducedReq Address -> pure $ AwaitUtxoProducedResp (NonEmpty ChainIndexTx)
143148
AwaitTxStatusChangeReq txId -> pure $ AwaitTxStatusChangeResp txId (Committed TxValid ())
144149
-- ExposeEndpointReq ActiveEndpoint -> ExposeEndpointResp EndpointDescription (EndpointValue JSON.Value)
145-
-- PosixTimeRangeToContainedSlotRangeReq POSIXTimeRange -> PosixTimeRangeToContainedSlotRangeResp (Either SlotConversionError SlotRange)
146150
unsupported -> error ("Unsupported PAB effect: " ++ show unsupported)
147151

148152
printLog @w Debug $ show resp

0 commit comments

Comments
 (0)