-
Notifications
You must be signed in to change notification settings - Fork 10
Time related functionalities #42
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
Conversation
szg251
commented
Feb 1, 2022
- Add awaitSlot, waitNSlots, currentTime, currentSlots contract effect handlers
- Add validity range functions
- Test on real chain with examples
…plutus-interface into gergely/wait-slots
test/Spec/MockContract.hs
Outdated
| let slot = Text.pack $ show $ getSlot $ tipSlot (state ^. tip) | ||
| blockId = decodeUtf8 $ getBlockId $ tipBlockId (state ^. tip) | ||
| blockNo = Text.pack $ show $ unBlockNumber $ tipBlockNo (state ^. tip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe unpack the tip before hand to avoid repition
Can use namepuns like
| let slot = Text.pack $ show $ getSlot $ tipSlot (state ^. tip) | |
| blockId = decodeUtf8 $ getBlockId $ tipBlockId (state ^. tip) | |
| blockNo = Text.pack $ show $ unBlockNumber $ tipBlockNo (state ^. tip) | |
| let Tip {tipSlot, tipBlockId, tipBlockNo} = state ^. tip | |
| slot = Text.pack $ show $ getSlot tipSlot | |
| blockId = decodeUtf8 $ getBlockId tipBlockId | |
| blockNo = Text.pack $ show $ unBlockNumber tipBlockNo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is the same here, Tip is a sum type, so I realised that the record functions are partial here. Used a good old case statement instead.
| tell $ Last $ Just "Finished" | ||
| where | ||
| toTx :: [(PubKeyHash, Value)] -> TxConstraints Void Void | ||
| toTx = mconcat . map (uncurry Constraints.mustPayToPubKey . first PaymentPubKeyHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theres mconcatMap in Data.List.Extra, but unsure if its worth it. Happy to merge as is
|
@samuelWilliams99 Sorry for adding these after you approved this, but I wanted to incorporate a few more changes in this PR.
|
|
No worries! Looks good to me :) |