Skip to content

Commit 92599e2

Browse files
author
gege251
committed
Add SlotConfig to PABConfig
1 parent 7ef736f commit 92599e2

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/BotPlutusInterface/Contract.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import Control.Monad.Freer.Extras.Log (handleLogIgnore)
2323
import Control.Monad.Freer.Extras.Modify (raiseEnd)
2424
import Control.Monad.Freer.Writer (Writer (Tell))
2525
import Data.Aeson (ToJSON, Value)
26-
import Data.Default (Default (def))
2726
import Data.Kind (Type)
2827
import Data.Map qualified as Map
2928
import Data.Row (Row)
@@ -245,4 +244,4 @@ currentTime ::
245244
ContractEnvironment w ->
246245
Eff effs POSIXTime
247246
currentTime contractEnv =
248-
slotToEndPOSIXTime def <$> currentSlot @w contractEnv
247+
slotToEndPOSIXTime contractEnv.cePABConfig.pcSlotConfig <$> currentSlot @w contractEnv

src/BotPlutusInterface/PreBalance.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import Control.Monad (foldM, void, zipWithM)
1414
import Control.Monad.Freer (Eff, Member)
1515
import Control.Monad.Trans.Class (lift)
1616
import Control.Monad.Trans.Either (EitherT, hoistEither, newEitherT, runEitherT)
17-
import Data.Default (Default (def))
1817
import Data.Either.Combinators (maybeToRight, rightToMaybe)
1918
import Data.Kind (Type)
2019
import Data.List (partition, (\\))
@@ -77,6 +76,7 @@ preBalanceTxIO pabConf ownPkh unbalancedTx =
7776
tx <-
7877
hoistEither $
7978
addValidRange
79+
pabConf
8080
(unBalancedTxValidityTimeRange unbalancedTx)
8181
(unBalancedTxTx unbalancedTx)
8282

@@ -272,10 +272,10 @@ addSignatories ownPkh privKeys pkhs tx =
272272
tx
273273
(ownPkh : pkhs)
274274

275-
addValidRange :: POSIXTimeRange -> Tx -> Either Text Tx
276-
addValidRange timeRange tx =
275+
addValidRange :: PABConfig -> POSIXTimeRange -> Tx -> Either Text Tx
276+
addValidRange pabConf timeRange tx =
277277
if validateRange timeRange
278-
then Right $ tx {txValidRange = posixTimeRangeToContainedSlotRange def timeRange}
278+
then Right $ tx {txValidRange = posixTimeRangeToContainedSlotRange pabConf.pcSlotConfig timeRange}
279279
else Left "Invalid validity interval."
280280

281281
validateRange :: forall (a :: Type). Ord a => Interval a -> Bool

src/BotPlutusInterface/Types.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Data.Map (Map)
2626
import Data.Text (Text)
2727
import GHC.Generics (Generic)
2828
import Ledger (PubKeyHash)
29+
import Ledger.TimeSlot (SlotConfig)
2930
import Network.Wai.Handler.Warp (Port)
3031
import Plutus.PAB.Core.ContractInstance.STM (Activity)
3132
import Plutus.PAB.Effects.Contract.Builtin (
@@ -43,6 +44,7 @@ data PABConfig = PABConfig
4344
, pcChainIndexUrl :: !BaseUrl
4445
, pcNetwork :: !NetworkId
4546
, pcProtocolParams :: !ProtocolParameters
47+
, pcSlotConfig :: !SlotConfig
4648
, -- | Directory name of the script and data files
4749
pcScriptFileDir :: !Text
4850
, -- | Directory name of the signing key files
@@ -107,6 +109,7 @@ instance Default PABConfig where
107109
, pcChainIndexUrl = BaseUrl Http "localhost" 9083 ""
108110
, pcNetwork = Testnet (NetworkMagic 42)
109111
, pcProtocolParams = def
112+
, pcSlotConfig = def
110113
, pcScriptFileDir = "./result-scripts"
111114
, pcSigningKeyFileDir = "./signing-keys"
112115
, pcTxFileDir = "./txs"

0 commit comments

Comments
 (0)