-
Notifications
You must be signed in to change notification settings - Fork 75
Upgrade Plutus Core to v1.1.0 and modernize PlutusLedgerApi imports #58
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
Conversation
AuctionValidator.hs: - Migrate core types (CurrencySymbol, Datum, Lovelace, OutputDatum, POSIXTime, PubKeyHash, ScriptContext, TokenName, TxInfo, TxOut) from V1/V2 to V3 - Update getContinuingOutputs import to V3.Contexts - Fix ScriptContext pattern match for V3's 3-field structure - Keep V1 imports for functions not available in V3 (toPubKeyHash, contains, lovelaceValueOf, valueOf) AuctionMintingPolicy.hs: - Migrate PubKeyHash, ScriptContext, TxInfo to V3 - Update context functions (ownCurrencySymbol, txSignedBy) to V3.Contexts - Add V3 MintValue support with mintValueMinted for type compatibility - Handle V3's MintValue type in txInfoMint field All functionality preserved while using latest API versions.
After exploring the Plutus Ledger API source code structure: - Consolidated core types into main V3 module where possible - Reduced AuctionValidator.hs imports from 5 to 4 PlutusLedgerApi modules - Reduced AuctionMintingPolicy.hs imports from 4 to 3 PlutusLedgerApi modules - Leveraged V3's comprehensive re-exports while maintaining specific imports for functions not re-exported (Address, Interval, Value utilities) This improves code organization and reduces import clutter while maintaining full functionality.
Updated both validators to use the new V3 script signature pattern: - Changed from multiple parameters to single BuiltinData -> BuiltinUnit signature - Extract datum and redeemer from ScriptContext instead of separate parameters - Updated type signatures and implementations accordingly AuctionValidator changes: - Signature: AuctionParams -> ScriptContext -> Bool (was: AuctionParams -> AuctionDatum -> AuctionRedeemer -> ScriptContext -> Bool) - Extract AuctionRedeemer from scriptContextRedeemer using getRedeemer - Extract AuctionDatum from SpendingScript scriptInfo - Untyped validator: BuiltinData -> BuiltinUnit (was: BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit) AuctionMintingPolicy changes: - Signature: AuctionMintingParams -> ScriptContext -> Bool (was: AuctionMintingParams -> AuctionMintingRedeemer -> ScriptContext -> Bool) - Extract redeemer from scriptContextRedeemer (though unused in this policy) - Untyped validator: BuiltinData -> BuiltinUnit (was: BuiltinData -> BuiltinData -> BuiltinUnit) This brings the validators in line with Plutus V3 requirements where all scripts have a uniform BuiltinData -> BuiltinUnit signature, enabling the same script to be used for different purposes.
Performance optimizations: - Remove unused scriptRedeemer extraction in AuctionMintingPolicy - Use wildcard pattern (_) for unused ScriptContext fields - Remove unused import of Redeemer types in minting policy - Add explanatory comment about redeemer not being needed Code cleanup: - Remove all unused BLOCK comment markers (BLOCK1-BLOCK10) - Clean up leftover tutorial/example documentation artifacts - Improve code readability by removing noise comments These changes follow Plutus optimization best practices: - Never extract unused script context attributes - Keep imports minimal and relevant - Maintain clean, production-ready code
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.
Pull Request Overview
This PR upgrades the Plutus validators to use Plutus Core v1.1.0 and modernizes the PlutusLedgerApi imports to predominantly use V3 APIs instead of the legacy V1/V2 APIs.
- Updates Plutus Core version from 1.0.0 to 1.1.0 across both validators
- Migrates core types and functions from PlutusLedgerApi V1/V2 to V3 where available
- Adapts validator implementations to handle V3's updated ScriptContext structure and data extraction patterns
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/AuctionValidator.hs | Updates to V3 APIs, refactors validator to extract datum/redeemer from ScriptContext, and simplifies function signatures |
| src/AuctionMintingPolicy.hs | Migrates to V3 APIs, updates MintValue handling, and removes explicit redeemer parameter |
| txInfo = scriptContextTxInfo ctx | ||
| mintedExactlyOneToken = case flattenValue (txInfoMint txInfo) of | ||
| -- Note: Redeemer is not needed for this minting policy, so we don't extract it | ||
| mintedExactlyOneToken = case flattenValue (mintValueMinted (txInfoMint txInfo)) of |
Copilot
AI
Aug 14, 2025
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 call to mintValueMinted on txInfoMint txInfo appears incorrect. In V3, txInfoMint returns a MintValue which should be used directly with flattenValue, or the function should extract the underlying Value from the MintValue first.
| mintedExactlyOneToken = case flattenValue (mintValueMinted (txInfoMint txInfo)) of | |
| mintedExactlyOneToken = case flattenValue (txInfoMint txInfo) of |
Summary
This PR upgrades the validators to use Plutus Core v1.1.0, modernizes the PlutusLedgerApi imports to use V3, migrates to V3 script signatures, and includes performance optimizations.
Changes Made
1. Plutus Core Version Upgrade (v1.0.0 → v1.1.0)
plcVersion100imports withplcVersion110plcVersion1102. PlutusLedgerApi Modernization (V1/V2 → V3)
AuctionValidator.hs:
CurrencySymbol,Datum,Lovelace,OutputDatum,POSIXTime,PubKeyHash,ScriptContext,TokenName,TxInfo,TxOut) from V1/V2 to V3getContinuingOutputsimport to V3.ContextstoPubKeyHash,contains,lovelaceValueOf,valueOf)AuctionMintingPolicy.hs:
PubKeyHash,ScriptContext,TxInfoto V3ownCurrencySymbol,txSignedBy) to V3.ContextsMintValuesupport withmintValueMintedfor type compatibilityMintValuetype intxInfoMintfield3. V3 Script Signature Migration
AuctionValidator:
AuctionParams -> ScriptContext -> Bool(was:AuctionParams -> AuctionDatum -> AuctionRedeemer -> ScriptContext -> Bool)AuctionRedeemerfromscriptContextRedeemerusinggetRedeemerAuctionDatumfromSpendingScriptscriptInfoBuiltinData -> BuiltinUnit(was:BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit)AuctionMintingPolicy:
AuctionMintingParams -> ScriptContext -> Bool(was:AuctionMintingParams -> AuctionMintingRedeemer -> ScriptContext -> Bool)BuiltinData -> BuiltinUnit(was:BuiltinData -> BuiltinData -> BuiltinUnit)4. Performance Optimizations
scriptRedeemerextraction in minting policy)Redeemerimports after optimization5. Import Optimization
Technical Improvements
V3 Migration Benefits
BuiltinData -> BuiltinUnitsignaturePerformance Benefits
Test Results
Compatibility
This comprehensive modernization ensures the validators are using the latest available APIs, follow current best practices, and are optimally structured for performance and maintainability.