Skip to content
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

Refactor TxMintValue #663

Merged
merged 4 commits into from
Nov 20, 2024
Merged

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Oct 25, 2024

Changelog

- description: |
    Add `sbeToSimpleScriptLanguageInEra`, `getScriptWitnessScript`, `getScriptWitnessReferenceInput`, `getScriptWitnessReferenceInputOrScript` function
    Refactor `TxMintValue` to better represent minting state
    Propagate `IsPlutusLanguage` constraint to `ScriptLanguage lang`, `AnyPlutusScriptVersion`, `Script lang` and `ScriptWitness witctx era` types.
    Remove `Maybe ScriptHash` from `PReferenceScript` and `SReferenceScript`.

# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
   - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
   - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Supersedes:

Fixes:

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

@carbolymer carbolymer force-pushed the mgalazyn/feature/refactor-txmintvalue branch 3 times, most recently from ef2b00c to c2c740b Compare October 31, 2024 11:49
@carbolymer carbolymer force-pushed the mgalazyn/feature/refactor-txmintvalue branch 8 times, most recently from 6e860f9 to fefbe40 Compare November 4, 2024 20:31
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

This looks good to me. One gripe regarding traverseScriptWitnesses. Clean up and I'll have a final look before approving.

cardano-api/internal/Cardano/Api/Tx/Body.hs Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Tx/Body.hs Outdated Show resolved Hide resolved

traverseScriptWitnesses
:: [(a, Either (TxBodyErrorAutoBalance era) (ScriptWitness ctx era))]
-> Either (TxBodyErrorAutoBalance era) [(a, ScriptWitness ctx era)]
:: [(a, Either (TxBodyErrorAutoBalance era) b)]
Copy link
Contributor

Choose a reason for hiding this comment

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

This may be "neater" Haskell but making this more generic doesn't really help the reader IMO. Also it's only instantiated to ScriptWitness ctx era.

Copy link
Contributor Author

@carbolymer carbolymer Nov 12, 2024

Choose a reason for hiding this comment

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

It's not only instantiated to ScriptWitness ctx era - in line 1629 it is used against

        [ (Value, Either (TxBodyErrorAutoBalance era)
          ( AssetName
          , Quantity
          , BuildTxWith build (ScriptWitness WitCtxMint era)
          )
        ]

So the previous function type won't work.

(Map PolicyId (ScriptWitness WitCtxMint era))
-> Map
PolicyId
[ ( AssetName
Copy link
Contributor

Choose a reason for hiding this comment

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

A 3-tuple is less than ideal but I can't think of what to call this instead.

cardano-api/internal/Cardano/Api/Script.hs Outdated Show resolved Hide resolved
@carbolymer carbolymer force-pushed the mgalazyn/feature/refactor-txmintvalue branch from 5842e38 to 416a201 Compare November 19, 2024 13:33
@carbolymer
Copy link
Contributor Author

carbolymer commented Nov 19, 2024

@carbolymer carbolymer force-pushed the mgalazyn/feature/refactor-txmintvalue branch 5 times, most recently from 7953b50 to 6bcac77 Compare November 19, 2024 22:44
@carbolymer carbolymer marked this pull request as ready for review November 19, 2024 22:44
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

LGTM!

cardano-api/internal/Cardano/Api/Script.hs Outdated Show resolved Hide resolved
@carbolymer carbolymer linked an issue Nov 20, 2024 that may be closed by this pull request
@carbolymer carbolymer force-pushed the mgalazyn/feature/refactor-txmintvalue branch from 6bcac77 to 927cf0a Compare November 20, 2024 15:32
@carbolymer carbolymer force-pushed the mgalazyn/feature/refactor-txmintvalue branch from 927cf0a to 0f51874 Compare November 20, 2024 15:34
@carbolymer carbolymer enabled auto-merge November 20, 2024 15:34
@carbolymer carbolymer added this pull request to the merge queue Nov 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Nov 20, 2024
@carbolymer carbolymer added this pull request to the merge queue Nov 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Nov 20, 2024
@carbolymer carbolymer merged commit 9af6866 into master Nov 20, 2024
29 checks passed
@carbolymer carbolymer deleted the mgalazyn/feature/refactor-txmintvalue branch November 20, 2024 18:21
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.

Remove redundant Maybe ScriptHash from PReferenceScript
2 participants