-
Notifications
You must be signed in to change notification settings - Fork 23
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
Remove redundant ScriptHash in ReferenceScript datatypes #642
base: master
Are you sure you want to change the base?
Conversation
@Swordlash> can you fix the formatting of Haskell files? You need to run: # order matters: fourmolu first, then stylish-haskell
fourmolu -i <modified files>
stylish-haskell -i <modified files> |
LGTM @carbolymer> WDYT? |
Formatting should be good now. Redundant whitespace it seems. |
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.
Those are used in
https://github.com/IntersectMBO/cardano-cli/blob/a157c492a4664b0ff4216e1c54a87c04adb0067b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L1381 to gather minting witnesses here: https://github.com/IntersectMBO/cardano-cli/blob/a157c492a4664b0ff4216e1c54a87c04adb0067b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L1364
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.
This is some very unfortunate coupling, isn't it? Having a library keep redundant information (and confuse users) for the sake of one of downstream tools. Maybe we could refactor it down to cardano-cli
?
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.
Of course we can argue that if the user wants to reference a script then he probably knows the hash. If the above is not possible I would at least not make it Maybe
, for the sake of API cleanliness. I think a redundant field is better than Maybe
redundant field as at least there is no ambiguity which option to use.
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.
@carbolymer I did the refactor, see the following: Swordlash/cardano-cli@b5c76a0
User provides the Maybe PolicyId
himself anyway in the CLI, so cardano-cli
code just temporarily stores this info in the PReferenceScript
to be unpacked later. We can change the signature of the appropriate function to return a pair, so that we avoid storing the information in the datatype.
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.
@carbolymer did you have a chance to take a look at the above? Tl;dr cardano-cli
uses this field as a temporary container for user provided data and it can be safely refactored out.
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.
Dzięki. Looks sensible. Can you open a PR to cardano-cli with those changes?
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.
Sure thing
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.
@carbolymer here it is: IntersectMBO/cardano-cli#918
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.
It's used in cardano-cli in handling of minting scripts.
-- have direct access to the script | ||
PReferenceScript | ||
TxIn | ||
(Maybe ScriptHash) |
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 purpose of this field should be documented better.
Changelog
Context
Sometime ago I opened an issue #606 but I didn't get any response, so I've made a PR myself.
One of the members of my team asked why is the
Maybe ScriptHash
needed in thePReferenceScript
and after some digging it seems it's completely redundant and not used anywhere (with the comment being obsolete). Therefore I removed it and everything "just compiled".Fixes #606
Checklist