|
1 | 1 | module Main (main) where
|
2 | 2 |
|
3 |
| -import HydraAuctionOnchain.Scripts (auctionMetadataValidatorUntyped, writeScript) |
| 3 | +import HydraAuctionOnchain.Scripts |
| 4 | + ( auctionMetadataValidatorUntyped |
| 5 | + , standingBidValidatorUntyped |
| 6 | + , writeScript |
| 7 | + ) |
| 8 | +import Options.Applicative |
| 9 | + ( Parser |
| 10 | + , execParser |
| 11 | + , fullDesc |
| 12 | + , help |
| 13 | + , helper |
| 14 | + , info |
| 15 | + , long |
| 16 | + , maybeReader |
| 17 | + , metavar |
| 18 | + , option |
| 19 | + ) |
4 | 20 |
|
5 | 21 | main :: IO ()
|
6 | 22 | main =
|
| 23 | + execParser (info (helper <*> scriptToCompile) fullDesc) >>= \case |
| 24 | + AllScripts -> do |
| 25 | + writeAuctionMetadataValidator |
| 26 | + writeStandingBidValidator |
| 27 | + AuctionMetadataValidator -> |
| 28 | + writeAuctionMetadataValidator |
| 29 | + StandingBidValidator -> |
| 30 | + writeStandingBidValidator |
| 31 | + |
| 32 | +writeAuctionMetadataValidator :: IO () |
| 33 | +writeAuctionMetadataValidator = |
7 | 34 | writeScript
|
8 | 35 | "Auction metadata validator"
|
9 | 36 | "compiled/auction_metadata_validator.plutus"
|
10 | 37 | auctionMetadataValidatorUntyped
|
| 38 | + |
| 39 | +writeStandingBidValidator :: IO () |
| 40 | +writeStandingBidValidator = |
| 41 | + writeScript |
| 42 | + "Standing bid validator" |
| 43 | + "compiled/standing_bid_validator.plutus" |
| 44 | + standingBidValidatorUntyped |
| 45 | + |
| 46 | +data ScriptToCompile |
| 47 | + = AllScripts |
| 48 | + | AuctionMetadataValidator |
| 49 | + | StandingBidValidator |
| 50 | + deriving stock (Show, Eq) |
| 51 | + |
| 52 | +toScript :: String -> Maybe ScriptToCompile |
| 53 | +toScript = \case |
| 54 | + "all" -> Just AllScripts |
| 55 | + "metadata" -> Just AuctionMetadataValidator |
| 56 | + "standing_bid" -> Just StandingBidValidator |
| 57 | + _ -> Nothing |
| 58 | + |
| 59 | +scriptToCompile :: Parser ScriptToCompile |
| 60 | +scriptToCompile = |
| 61 | + option |
| 62 | + (maybeReader toScript) |
| 63 | + ( long "script" |
| 64 | + <> metavar "SCRIPT" |
| 65 | + <> help "Name of the Plutarch script to compile" |
| 66 | + ) |
0 commit comments