3
3
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4
4
{-# LANGUAGE ImportQualifiedPost #-}
5
5
{-# LANGUAGE MultiParamTypeClasses #-}
6
+ {-# LANGUAGE NoImplicitPrelude #-}
6
7
{-# LANGUAGE OverloadedStrings #-}
7
8
{-# LANGUAGE PatternSynonyms #-}
8
9
{-# LANGUAGE ScopedTypeVariables #-}
18
19
{-# OPTIONS_GHC -fno-unbox-small-strict-fields #-}
19
20
{-# OPTIONS_GHC -fno-unbox-strict-fields #-}
20
21
{-# OPTIONS_GHC -fplugin PlutusTx.Plugin #-}
21
- {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.0 .0 #-}
22
+ {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.1 .0 #-}
22
23
23
24
module AuctionMintingPolicy where
24
25
25
- import PlutusCore.Version (plcVersion100 )
26
- import PlutusLedgerApi.V1.Value (flattenValue )
27
- import PlutusLedgerApi.V2 (PubKeyHash , ScriptContext (.. ), TxInfo (.. ))
28
- import PlutusLedgerApi.V2.Contexts (ownCurrencySymbol , txSignedBy )
29
26
import PlutusTx
30
- import PlutusTx.Prelude qualified as PlutusTx
27
+ import PlutusTx.Prelude
28
+
29
+ import PlutusCore.Version (plcVersion110 )
30
+ import PlutusLedgerApi.V1.Value (flattenValue )
31
+ import PlutusLedgerApi.V3 (PubKeyHash , ScriptContext (.. ), TxInfo (.. ), mintValueMinted )
32
+ import PlutusLedgerApi.V3.Contexts (ownCurrencySymbol , txSignedBy )
31
33
32
34
-- BLOCK1
33
35
type AuctionMintingParams = PubKeyHash
@@ -39,32 +41,33 @@ auctionTypedMintingPolicy ::
39
41
ScriptContext ->
40
42
Bool
41
43
auctionTypedMintingPolicy pkh _redeemer ctx =
42
- txSignedBy txInfo pkh PlutusTx. && mintedExactlyOneToken
44
+ txSignedBy txInfo pkh && mintedExactlyOneToken
43
45
where
44
46
txInfo = scriptContextTxInfo ctx
45
- mintedExactlyOneToken = case flattenValue (txInfoMint txInfo) of
46
- [(currencySymbol, _tokenName, quantity)] ->
47
- currencySymbol PlutusTx. == ownCurrencySymbol ctx PlutusTx. && quantity PlutusTx. == 1
48
- _ -> False
47
+ mintedExactlyOneToken =
48
+ case flattenValue (mintValueMinted (txInfoMint txInfo)) of
49
+ [(currencySymbol, _tokenName, quantity)] ->
50
+ currencySymbol == ownCurrencySymbol ctx && quantity == 1
51
+ _ -> False
49
52
-- BLOCK2
50
53
{-# INLINEABLE auctionTypedMintingPolicy #-}
51
54
52
55
auctionUntypedMintingPolicy ::
53
56
AuctionMintingParams ->
54
57
BuiltinData ->
55
58
BuiltinData ->
56
- PlutusTx. BuiltinUnit
59
+ BuiltinUnit
57
60
auctionUntypedMintingPolicy pkh redeemer ctx =
58
- PlutusTx. check
61
+ check
59
62
( auctionTypedMintingPolicy
60
63
pkh
61
- (PlutusTx. unsafeFromBuiltinData redeemer)
62
- (PlutusTx. unsafeFromBuiltinData ctx)
64
+ (unsafeFromBuiltinData redeemer)
65
+ (unsafeFromBuiltinData ctx)
63
66
)
64
67
65
68
auctionMintingPolicyScript ::
66
69
AuctionMintingParams ->
67
- CompiledCode (BuiltinData -> BuiltinData -> PlutusTx. BuiltinUnit )
70
+ CompiledCode (BuiltinData -> BuiltinData -> BuiltinUnit )
68
71
auctionMintingPolicyScript pkh =
69
- $$ (PlutusTx. compile [|| auctionUntypedMintingPolicy|| ])
70
- `PlutusTx. unsafeApplyCode` PlutusTx. liftCode plcVersion100 pkh
72
+ $$ (compile [|| auctionUntypedMintingPolicy|| ])
73
+ `unsafeApplyCode` liftCode plcVersion110 pkh
0 commit comments