-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a few modules to the template (#20)
Added `AuctionMintingPolicy.hs`, `GenAuctionValidatorBlueprint.hs` and `app/GenMintingPolicyBlueprint.hs`, to make it compatible with IntersectMBO/plutus#6477. --------- Co-authored-by: zeme <[email protected]>
- Loading branch information
Showing
10 changed files
with
572 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE ImportQualifiedPost #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
{-# LANGUAGE ViewPatterns #-} | ||
|
||
module Main where | ||
|
||
import AuctionValidator | ||
import Data.ByteString.Short qualified as Short | ||
import Data.Set qualified as Set | ||
import PlutusLedgerApi.Common (serialiseCompiledCode) | ||
import PlutusTx.Blueprint | ||
import System.Environment (getArgs) | ||
|
||
auctionParams :: AuctionParams | ||
auctionParams = | ||
AuctionParams | ||
{ apSeller = error "Replace with seller public key hash" | ||
, apCurrencySymbol = error "Replace with currency symbol" | ||
, apTokenName = "TokenToBeAuctioned" | ||
, apMinBid = 100 | ||
, apEndTime = error "Replace with the auction's end time" | ||
} | ||
|
||
myContractBlueprint :: ContractBlueprint | ||
myContractBlueprint = | ||
MkContractBlueprint | ||
{ contractId = Just "auction-validator" | ||
, contractPreamble = myPreamble | ||
, contractValidators = Set.singleton myValidator | ||
, contractDefinitions = deriveDefinitions @[AuctionParams, AuctionDatum, AuctionRedeemer] | ||
} | ||
|
||
myPreamble :: Preamble | ||
myPreamble = | ||
MkPreamble | ||
{ preambleTitle = "Auction Validator" | ||
, preambleDescription = Just "Blueprint for a Plutus script validating auction transactions" | ||
, preambleVersion = "1.0.0" | ||
, preamblePlutusVersion = PlutusV2 | ||
, preambleLicense = Just "MIT" | ||
} | ||
|
||
myValidator :: ValidatorBlueprint referencedTypes | ||
myValidator = | ||
MkValidatorBlueprint | ||
{ validatorTitle = "Auction Validator" | ||
, validatorDescription = Just "Plutus script validating auction transactions" | ||
, validatorParameters = | ||
[ MkParameterBlueprint | ||
{ parameterTitle = Just "Parameters" | ||
, parameterDescription = Just "Compile-time validator parameters" | ||
, parameterPurpose = Set.singleton Spend | ||
, parameterSchema = definitionRef @AuctionParams | ||
} | ||
] | ||
, validatorRedeemer = | ||
MkArgumentBlueprint | ||
{ argumentTitle = Just "Redeemer" | ||
, argumentDescription = Just "Redeemer for the auction validator" | ||
, argumentPurpose = Set.fromList [Spend] | ||
, argumentSchema = definitionRef @() | ||
} | ||
, validatorDatum = Nothing | ||
, validatorCompiledCode = | ||
Just . Short.fromShort . serialiseCompiledCode $ | ||
auctionValidatorScript auctionParams | ||
} | ||
|
||
writeBlueprintToFile :: FilePath -> IO () | ||
writeBlueprintToFile path = writeBlueprint path myContractBlueprint | ||
|
||
main :: IO () | ||
main = | ||
getArgs >>= \case | ||
[arg] -> writeBlueprintToFile arg | ||
args -> fail $ "Expects one argument, got " <> show (length args) |
Oops, something went wrong.