Skip to content

Conversation

@Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Jun 11, 2025

Changelog

- description: |
    Refactor simple and plutus script interface via the `ScriptRequirements` type.
# uncomment types applicable to the change:
  type:
  - compatible     # the API has changed but is non-breaking
  - refactoring    # QoL changes

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

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

Comment on lines 121 to 144
readCertificateScriptWitnesses certs =
mapM
( \(vFile, mCert) -> do
case mCert of
Nothing -> return (vFile, AnyKeyWitnessPlaceholder)
Just cert -> do
sWit <- readCertificateScriptWitness cert
return (vFile, sWit)
)
certs

Check warning

Code scanning / HLint

Eta reduce Warning

cardano-cli/src/Cardano/CLI/EraBased/Script/Certificate/Read.hs:(134,1)-(143,9): Warning: Eta reduce
  
Found:
  readCertificateScriptWitnesses certs
    = mapM
        (\\ (vFile, mCert)
           -> do case mCert of
                   Nothing -> return (vFile, AnyKeyWitnessPlaceholder)
                   Just cert
                     -> do sWit <- readCertificateScriptWitness cert
                           return (vFile, sWit))
        certs
  
Perhaps:
  readCertificateScriptWitnesses
    = mapM
        (\\ (vFile, mCert)
           -> do case mCert of
                   Nothing -> return (vFile, AnyKeyWitnessPlaceholder)
                   Just cert
                     -> do sWit <- readCertificateScriptWitness cert
                           return (vFile, sWit))
Comment on lines 209 to 213
[ (,mSwit)
<$> ( fmap (Exp.convertToNewCertificate Exp.useEra) $
fromEitherIOCli @(FileError TextEnvelopeError) $
shelleyBasedEraConstraints eon $
readFileTextEnvelope (File certFile)
)

Check notice

Code scanning / HLint

Move brackets to avoid $ Note

cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs:(182,11)-(187,17): Suggestion: Move brackets to avoid $
  
Found:
  (, mSwit)
    <$>
      (fmap (Exp.convertToNewCertificate Exp.useEra)
         $ fromEitherIOCli @(FileError TextEnvelopeError)
             $ shelleyBasedEraConstraints eon
                 $ readFileTextEnvelope (File certFile))
  
Perhaps:
  (, mSwit)
    <$>
      fmap
        (Exp.convertToNewCertificate Exp.useEra)
        (fromEitherIOCli @(FileError TextEnvelopeError)
           $ shelleyBasedEraConstraints eon
               $ readFileTextEnvelope (File certFile))
[ (,mSwit)
<$> ( fmap (Exp.convertToNewCertificate Exp.useEra) $
shelleyBasedEraConstraints sbe $
fromEitherIOCli $
readFileTextEnvelope (File certFile)
)

Check notice

Code scanning / HLint

Move brackets to avoid $ Note

cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs:(470,11)-(475,17): Suggestion: Move brackets to avoid $
  
Found:
  (, mSwit)
    <$>
      (fmap (Exp.convertToNewCertificate Exp.useEra)
         $ shelleyBasedEraConstraints sbe
             $ fromEitherIOCli $ readFileTextEnvelope (File certFile))
  
Perhaps:
  (, mSwit)
    <$>
      fmap
        (Exp.convertToNewCertificate Exp.useEra)
        (shelleyBasedEraConstraints sbe
           $ fromEitherIOCli $ readFileTextEnvelope (File certFile))
Comment on lines 711 to 706
[ (,mSwit)
<$> ( fmap (Exp.convertToNewCertificate Exp.useEra) $
fromEitherIOCli $
readFileTextEnvelope (File certFile)
)

Check notice

Code scanning / HLint

Move brackets to avoid $ Note

cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs:(704,13)-(708,19): Suggestion: Move brackets to avoid $
  
Found:
  (, mSwit)
    <$>
      (fmap (Exp.convertToNewCertificate Exp.useEra)
         $ fromEitherIOCli $ readFileTextEnvelope (File certFile))
  
Perhaps:
  (, mSwit)
    <$>
      fmap
        (Exp.convertToNewCertificate Exp.useEra)
        (fromEitherIOCli $ readFileTextEnvelope (File certFile))
@Jimbo4350 Jimbo4350 force-pushed the jordan/consolidate-script-interface branch 7 times, most recently from 6751eb0 to a08f3ca Compare June 18, 2025 18:44
@Jimbo4350 Jimbo4350 force-pushed the jordan/consolidate-script-interface branch from 32604f4 to 1e71580 Compare June 18, 2025 20:09
@Jimbo4350 Jimbo4350 force-pushed the jordan/consolidate-script-interface branch 7 times, most recently from 19ad6a5 to 8da24cc Compare June 25, 2025 13:26
@Jimbo4350 Jimbo4350 marked this pull request as ready for review June 25, 2025 13:26
@Jimbo4350 Jimbo4350 force-pushed the jordan/consolidate-script-interface branch from 8da24cc to 9ccc4c0 Compare June 25, 2025 13:31
Copy link
Contributor

@nbacquey nbacquey left a comment

Choose a reason for hiding this comment

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

Just some stylistic remarks. I'm not familiar enough with the semantics to have a relevant opinion

SimpleReferenceScript
:: SimpleRefScriptCliArgs witnessable -> ScriptRequirements witnessable

deriving instance Show (ScriptRequirements Exp.VoterItem)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not instance Show a => Show (ScriptRequirements a)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually it will ask for Show (OptionalDatum a) and I will have to provide manual instances for it because you cannot automatically derive instance for type families.

| InlineDatum
deriving Show

deriving instance Show (OnDiskPlutusScriptCliArgs Exp.VoterItem)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here about Show instances

-> ExecutionUnits
-> PlutusRefScriptCliArgs witnessable

deriving instance Show (PlutusRefScriptCliArgs Exp.VoterItem)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

data SimpleRefScriptCliArgs witnessable where
SimpleRefScriptArgs :: TxIn -> MintPolicyId witnessable -> SimpleRefScriptCliArgs witnessable

deriving instance Show (SimpleRefScriptCliArgs Exp.VoterItem)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@Jimbo4350 Jimbo4350 force-pushed the jordan/consolidate-script-interface branch from 9ccc4c0 to 8be9beb Compare June 26, 2025 14:11
Copy link
Contributor

@palas palas left a comment

Choose a reason for hiding this comment

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

Nice simplification! I don't see any issues in the PR (except for the underscore, which seems odd), and types here go a long way. But I would get some more approvals because it is a big PR and my understanding of the changes is limited

This is designed to handle reading simple and plutus scripts from disk
@Jimbo4350 Jimbo4350 force-pushed the jordan/consolidate-script-interface branch from dd34973 to d6a08be Compare June 27, 2025 15:17
@Jimbo4350 Jimbo4350 enabled auto-merge June 27, 2025 15:17
@Jimbo4350 Jimbo4350 added this pull request to the merge queue Jun 27, 2025
Merged via the queue into master with commit 298ec6d Jun 27, 2025
27 checks passed
@Jimbo4350 Jimbo4350 deleted the jordan/consolidate-script-interface branch June 27, 2025 18:42
@Jimbo4350 Jimbo4350 mentioned this pull request Jun 30, 2025
3 tasks
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.

4 participants