-
Notifications
You must be signed in to change notification settings - Fork 15
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
Minting script witness refactor #971
base: master
Are you sure you want to change the base?
Conversation
Define the data definition CliMintScriptRequirements This type makes it clearer that we require the policy id for transaction construction when using a minting script
AnyScriptLanguage Replace ScriptWitnessFiles WitCtxMint with CliMintScriptRequirements
AnyPlutusScriptVersion instead of AnyScriptLanguage
Refactor readScriptWitness and eliminate invalid states Factor out fromSomeTypeSimpleScript and fromSomeTypePlutusScripts fromSomeTypePlutusScripts should automatically be updated as soon as the Enum AnyPlutusScriptVersion instance is updated in cardano-api
Add ScriptDecodeUnknownPlutusScriptVersion to ScriptDecodeError
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.
LGTM after first pass 👍🏻 Nice work.
, createOnDiskSimpleOfPlutusScriptCliArgs | ||
, createOnDiskSimpleReferenceScriptCliArgs | ||
, createOnDiskPlutusReferenceScriptCliArgs |
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.
I think we should switch to either using OnDiskXXXXThing
or FileXXXXThing
names convention for the consistency, eventually. It would make navigating codebase easier.
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.
I don't think this module is in the right place. Can we split it into two:
cardano-cli/src/Cardano/CLI/Types/Plutus.hs
withMintScriptWitWithPolId
,CliMintScriptRequirements
andcreateOnDiskXXX
functionscardano-cli/src/Cardano/CLI/Read/Plutus.hs
withreadMintScriptWitness
andCliScriptWitnessError
?
I'm not a fan of the current module structure, but it never felt like a good moment to turn everything upside down.
For the moment I think we should follow it rather than introducing different changes.
I propose the following change:
https://gist.github.com/carbolymer/63b23d0df940c61d1501a6763d86134c
I'm not insisting on keeping EraBased
if we have a better alternative here.
Thoughts?
data MintScriptWitWithPolId era | ||
= MintScriptWitWithPolId | ||
{ mswPolId :: PolicyId |
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.
data MintScriptWitWithPolId era | |
= MintScriptWitWithPolId | |
{ mswPolId :: PolicyId | |
data MintScriptWitWithPolicyId era | |
= MintScriptWitWithPolicyId | |
{ mswPolicyId :: PolicyId |
I don't think we're gaining much here by shortening the names here
sbeToSimpleScriptLangInEra ShelleyBasedEraShelley = SimpleScriptInShelley | ||
sbeToSimpleScriptLangInEra ShelleyBasedEraAllegra = SimpleScriptInAllegra | ||
sbeToSimpleScriptLangInEra ShelleyBasedEraMary = SimpleScriptInMary | ||
sbeToSimpleScriptLangInEra ShelleyBasedEraAlonzo = SimpleScriptInAlonzo | ||
sbeToSimpleScriptLangInEra ShelleyBasedEraBabbage = SimpleScriptInBabbage | ||
sbeToSimpleScriptLangInEra ShelleyBasedEraConway = SimpleScriptInConway |
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.
- I'll upstream this to
Cardano.Api.Script
.
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.
done in IntersectMBO/cardano-api#663
case deserialiseFromTextEnvelopeAnyOf [teTypes (AnyPlutusScriptVersion PlutusScriptV1)] te of | ||
Left err -> Left (PlutusScriptDecodeTextEnvelopeError err) | ||
Right script -> Right script |
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 can be simplified too
case deserialiseFromJSON AsTextEnvelope bs of | ||
Left err -> Left $ PlutusScriptJsonDecodeError err | ||
Right te -> |
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.
case deserialiseFromJSON AsTextEnvelope bs of | |
Left err -> Left $ PlutusScriptJsonDecodeError err | |
Right te -> | |
te <- first PlutusScriptJsonDecodeError $ deserialiseFromJSON AsTextEnvelope bs of |
data PlutusRefScriptCliArgs | ||
= PlutusRefScriptCliArgs | ||
TxIn | ||
AnyPlutusScriptVersion | ||
ScriptDataOrFile | ||
ExecutionUnits | ||
PolicyId | ||
deriving Show | ||
|
||
createOnDiskPlutusReferenceScriptCliArgs | ||
:: TxIn | ||
-> AnyPlutusScriptVersion | ||
-> ScriptDataOrFile | ||
-> ExecutionUnits | ||
-> PolicyId | ||
-> CliMintScriptRequirements | ||
createOnDiskPlutusReferenceScriptCliArgs txin scriptVersion scriptData execUnits polid = | ||
OnDiskPlutusRefScript $ PlutusRefScriptCliArgs txin scriptVersion scriptData execUnits polid |
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.
Can you put those definitions below the type CliMintScriptRequirements
? It makes hard to read when you have to jump up and down from definition to definiton to follow the call/type hierarchy.
data CliMintScriptRequirements | ||
= OnDiskSimpleOrPlutusScript OnDiskSimpleOrPlutusScriptCliArgs | ||
| OnDiskSimpleRefScript SimpleRefScriptCliArgs | ||
| OnDiskPlutusRefScript PlutusRefScriptCliArgs | ||
deriving Show | ||
|
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.
Same like my previous comment, can you put this definition near the top of the module, before any of its "dependencies"?
(also applies to other types here, I don't want to highlight the whole file for that purpose)
Changelog
Context
Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.
How to trust this PR
Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.
Checklist