Skip to content

Conversation

@szg251
Copy link
Collaborator

@szg251 szg251 commented Feb 1, 2022

  • Add awaitSlot, waitNSlots, currentTime, currentSlots contract effect handlers
  • Add validity range functions
  • Test on real chain with examples

Comment on lines 321 to 323
let slot = Text.pack $ show $ getSlot $ tipSlot (state ^. tip)
blockId = decodeUtf8 $ getBlockId $ tipBlockId (state ^. tip)
blockNo = Text.pack $ show $ unBlockNumber $ tipBlockNo (state ^. tip)
Copy link
Contributor

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

Suggested change
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

Copy link
Collaborator Author

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)
Copy link
Contributor

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

@szg251
Copy link
Collaborator Author

szg251 commented Feb 11, 2022

@samuelWilliams99 Sorry for adding these after you approved this, but I wanted to incorporate a few more changes in this PR.

  • Added the SlotConfig to PABConf, for most cases this can be set to def, but might need to be changed for some testnets
  • Added support for some other time related requests

@samuelWilliams99
Copy link
Contributor

No worries! Looks good to me :)

@szg251 szg251 merged commit 53ec8a7 into master Feb 11, 2022
@szg251 szg251 deleted the gergely/wait-slots branch February 11, 2022 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants