-
Notifications
You must be signed in to change notification settings - Fork 10
Misha/issue 100 time conversions #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
e50c779
aa382a4
b706d77
d4b2e3a
b56363e
d184cdb
5d77660
8454d26
eda445f
7534388
944b904
2f66ea7
38fab81
7cff2e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,10 +24,14 @@ module BotPlutusInterface.Effects ( | |
| callCommand, | ||
| estimateBudget, | ||
| saveBudget, | ||
| slotToPOSIXTime, | ||
| posixTimeToSlot, | ||
| posixTimeRangeToContainedSlotRange, | ||
| ) where | ||
|
|
||
| import BotPlutusInterface.ChainIndex (handleChainIndexReq) | ||
| import BotPlutusInterface.ExBudget qualified as ExBudget | ||
| import BotPlutusInterface.TimeSlot qualified as TimeSlot | ||
| import BotPlutusInterface.Types ( | ||
| BudgetEstimationError, | ||
| CLILocation (..), | ||
|
|
@@ -106,6 +110,13 @@ data PABEffect (w :: Type) (r :: Type) where | |
| QueryChainIndex :: ChainIndexQuery -> PABEffect w ChainIndexResponse | ||
| EstimateBudget :: TxFile -> PABEffect w (Either BudgetEstimationError TxBudget) | ||
| SaveBudget :: Ledger.TxId -> TxBudget -> PABEffect w () | ||
| SlotToPOSIXTime :: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I started to get a feeling that instead of introducing new effects here for each cardano-api related query, we should have a more general
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great idea, I think. It will also make things more testable (e.g. like this one). Or maybe just change part related to slot/time conversions to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed yes, let's make that a new issue (the problem with refactoring issues is that they tend to be forgotten, staying in the backlog forever, so I like to couple them with some useful feature)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made an issue #109 |
||
| Ledger.Slot -> | ||
| PABEffect w (Either TimeSlot.TimeSlotConversionError Ledger.POSIXTime) | ||
| POSIXTimeToSlot :: Ledger.POSIXTime -> PABEffect w (Either TimeSlot.TimeSlotConversionError Ledger.Slot) | ||
| POSIXTimeRangeToSlotRange :: | ||
| Ledger.POSIXTimeRange -> | ||
| PABEffect w (Either TimeSlot.TimeSlotConversionError Ledger.SlotRange) | ||
|
|
||
| handlePABEffect :: | ||
| forall (w :: Type) (effs :: [Type -> Type]). | ||
|
|
@@ -155,6 +166,12 @@ handlePABEffect contractEnv = | |
| EstimateBudget txPath -> | ||
| ExBudget.estimateBudget contractEnv.cePABConfig txPath | ||
| SaveBudget txId exBudget -> saveBudgetImpl contractEnv txId exBudget | ||
| SlotToPOSIXTime slot -> | ||
| TimeSlot.slotToPOSIXTimeIO contractEnv.cePABConfig slot | ||
| POSIXTimeToSlot pTime -> | ||
| TimeSlot.posixTimeToSlotIO contractEnv.cePABConfig pTime | ||
| POSIXTimeRangeToSlotRange pTimeRange -> | ||
| TimeSlot.posixTimeRangeToContainedSlotRangeIO contractEnv.cePABConfig pTimeRange | ||
| ) | ||
|
|
||
| printLog' :: LogLevel -> LogContext -> LogLevel -> PP.Doc () -> IO () | ||
|
|
@@ -345,3 +362,24 @@ saveBudget :: | |
| TxBudget -> | ||
| Eff effs () | ||
| saveBudget txId budget = send @(PABEffect w) $ SaveBudget txId budget | ||
|
|
||
| slotToPOSIXTime :: | ||
| forall (w :: Type) (effs :: [Type -> Type]). | ||
| Member (PABEffect w) effs => | ||
| Ledger.Slot -> | ||
| Eff effs (Either TimeSlot.TimeSlotConversionError Ledger.POSIXTime) | ||
| slotToPOSIXTime = send @(PABEffect w) . SlotToPOSIXTime | ||
|
|
||
| posixTimeToSlot :: | ||
| forall (w :: Type) (effs :: [Type -> Type]). | ||
| Member (PABEffect w) effs => | ||
| Ledger.POSIXTime -> | ||
| Eff effs (Either TimeSlot.TimeSlotConversionError Ledger.Slot) | ||
| posixTimeToSlot = send @(PABEffect w) . POSIXTimeToSlot | ||
|
|
||
| posixTimeRangeToContainedSlotRange :: | ||
| forall (w :: Type) (effs :: [Type -> Type]). | ||
| Member (PABEffect w) effs => | ||
| Ledger.POSIXTimeRange -> | ||
| Eff effs (Either TimeSlot.TimeSlotConversionError Ledger.SlotRange) | ||
| posixTimeRangeToContainedSlotRange = send @(PABEffect w) . POSIXTimeRangeToSlotRange | ||
Uh oh!
There was an error while loading. Please reload this page.