Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
plutus
minting-policies
nft
Commits
c359d6c1
Commit
c359d6c1
authored
3 years ago
by
Daniel Firth
Browse files
Options
Download
Email Patches
Plain Diff
Allow multiple TokenNames per policy
parent
d69fbb28
master
lc/multiple
next-node
v0.1.0.0
No related merge requests found
Pipeline
#806
passed with stage
in 19 minutes and 34 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
src/Plutus/Validators/NFT.hs
src/Plutus/Validators/NFT.hs
+13
-9
No files found.
src/Plutus/Validators/NFT.hs
View file @
c359d6c1
...
...
@@ -9,10 +9,10 @@ import PlutusTx
import
PlutusTx.Prelude
{-# INLINEABLE mkPolicy #-}
mkPolicy
::
TxOutRef
->
TokenName
->
()
->
ScriptContext
->
Bool
mkPolicy
oref
tn
()
ctx
=
mkPolicy
::
TxOutRef
->
[
TokenName
]
->
()
->
ScriptContext
->
Bool
mkPolicy
oref
tn
s
()
ctx
=
traceIfFalse
"Seed UTxO For NFT Not Consumed"
hasUTxO
&&
traceIfFalse
"Must Mint Exactly One NFT"
checkMintedAmount
&&
traceIfFalse
"Must Mint Exactly One NFT
Per TokenName
"
checkMintedAmount
where
info
::
TxInfo
info
=
scriptContextTxInfo
ctx
...
...
@@ -20,17 +20,21 @@ mkPolicy oref tn () ctx =
hasUTxO
::
Bool
hasUTxO
=
any
((
oref
==
)
.
txInInfoOutRef
)
$
txInfoInputs
info
ownSymbol
::
CurrencySymbol
ownSymbol
=
ownCurrencySymbol
ctx
minted
::
Value
minted
=
txInfoMint
info
checkMintedAmount
::
Bool
checkMintedAmount
=
case
flattenValue
(
txInfoMint
info
)
of
[(
_
,
tn'
,
amt
)]
->
tn'
==
tn
&&
amt
==
1
_
->
False
checkMintedAmount
=
and
$
map
(
\
x
->
valueOf
minted
ownSymbol
x
==
1
)
tns
policy
::
TxOutRef
->
TokenName
->
Scripts
.
MintingPolicy
policy
::
TxOutRef
->
[
TokenName
]
->
Scripts
.
MintingPolicy
policy
oref
tn
=
mkMintingPolicyScript
$
$$
(
PlutusTx
.
compile
[
||\
oref'
tn'
->
Scripts
.
wrapMintingPolicy
$
mkPolicy
oref'
tn'
||
])
`
PlutusTx
.
applyCode
`
PlutusTx
.
liftCode
oref
`
PlutusTx
.
applyCode
`
PlutusTx
.
liftCode
tn
curSymbol
::
TxOutRef
->
TokenName
->
CurrencySymbol
curSymbol
oref
tn
=
scriptCurrencySymbol
$
policy
oref
tn
curSymbol
::
TxOutRef
->
[
TokenName
]
->
CurrencySymbol
curSymbol
oref
tn
s
=
scriptCurrencySymbol
$
policy
oref
tn
s
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help