Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Add mustPayWithDatumToPubKey (fix #146). #154

Merged
1 commit merged into from
Dec 6, 2021
Merged

Conversation

ghost
Copy link

@ghost ghost commented Nov 30, 2021

Should fix #146.


Pre-submit checklist:

  • Branch
    • Tests are provided (if possible)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
    • Relevant tickets are mentioned in commit messages
    • Formatting, materialized Nix files, PNG optimization, etc. are updated
  • PR
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@@ -85,7 +85,7 @@ checkTxConstraint ctx@ScriptContext{scriptContextTxInfo} = \case
MustMintValue mps _ tn v ->
traceIfFalse "L9" -- "Value minted not OK"
$ Value.valueOf (txInfoMint scriptContextTxInfo) (Value.mpsSymbol mps) tn == v
MustPayToPubKey pk vl ->
MustPayToPubKey pk _ vl ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should do a datum check too, just like MustPayToOtherScript? Probably you should make checkOutput from there usable by both.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I guess so. I've just wrote a contract test to ensure that datum is presented in TxOut and it seems to work. How do I test datumWitnesses and checkOutput behaviour?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only check for the hash, the actual datum probably isn't available. You can check that with findDatum.

checkOutput behaviour is a bit harder to test since the constraint mechanism should make sure a transaction satisfies it. I guess you should at least make sure the OnChain code is called by some test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to test the datum's presence but something isn't working. Test passes with any validator results. I guess I'm doing something wrong. But I have fixed the comments.

@ghost ghost requested review from j-mueller, silky and sjoerdvisscher December 1, 2021 12:19
@ghost ghost force-pushed the attach-datum-pubkey-output branch from 4b53944 to 58d2ede Compare December 2, 2021 11:55
Copy link
Contributor

@sjoerdvisscher sjoerdvisscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ghost ghost merged commit 63123ff into main Dec 6, 2021
@ghost ghost deleted the attach-datum-pubkey-output branch December 6, 2021 12:15
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Constraint to attach a Datum to a PubKey Output
1 participant