diff --git a/agora/Agora/Governor.hs b/agora/Agora/Governor.hs index ea34a5d..facb2bd 100644 --- a/agora/Agora/Governor.hs +++ b/agora/Agora/Governor.hs @@ -78,8 +78,7 @@ import Agora.Utils ( pfindTxInByTxOutRef, pisDJust, pisJust, - pisUxtoSpent, - pownCurrencySymbol, + pisUTXOSpent, psymbolValueOf, ptxSignedBy, pvalueSpent, @@ -95,7 +94,7 @@ import Plutarch.Api.V1 ( PDatumHash, PMap, PMintingPolicy, - PScriptPurpose (PSpending), + PScriptPurpose (PSpending, PMinting), PTxOut, PValidator, PValidatorHash, @@ -244,12 +243,13 @@ governorPolicy :: Governor -> ClosedTerm PMintingPolicy governorPolicy gov = plam $ \_ ctx' -> P.do let oref = pconstant gov.gstOutRef - ownSymbol = pownCurrencySymbol # ctx' + + PMinting ((pfield @"_0" #) -> ownSymbol) <- pmatch (pfromData $ pfield @"purpose" # ctx') mintValue <- plet $ pownMintValue # ctx' passert "Referenced utxo should be spent" $ - pisUxtoSpent # oref #$ pfield @"txInfo" # ctx' + pisUTXOSpent # oref #$ pfield @"txInfo" # ctx' passert "Exactly one token should be minted" $ psymbolValueOf # ownSymbol # mintValue #== 1 diff --git a/agora/Agora/Utils.hs b/agora/Agora/Utils.hs index 3ea3fb4..2ad5d86 100644 --- a/agora/Agora/Utils.hs +++ b/agora/Agora/Utils.hs @@ -30,8 +30,7 @@ module Agora.Utils ( pnub, pisUniq, pisDJust, - pownCurrencySymbol, - pisUxtoSpent, + pisUTXOSpent, -- * Functions which should (probably) not be upstreamed anyOutput, @@ -379,18 +378,10 @@ pisDJust = phoistAcyclic $ _ -> pconstant False ) --- | The 'CurrencySymbol' of the current minting policy. --- FIXME: Yeet/reimplement this function, since passing the whole script context is highly inefficient. -pownCurrencySymbol :: Term s (PScriptContext :--> PCurrencySymbol) -pownCurrencySymbol = phoistAcyclic $ - plam $ \ctx -> P.do - PMinting m <- pmatch $ pfield @"purpose" # ctx - pfield @"_0" # m - -- | Determines if a given UTXO is spent. -- TODO: no need to pass the whole TxInfo here. -pisUxtoSpent :: Term s (PTxOutRef :--> PTxInfo :--> PBool) -pisUxtoSpent = phoistAcyclic $ +pisUTXOSpent :: Term s (PTxOutRef :--> PTxInfo :--> PBool) +pisUTXOSpent = phoistAcyclic $ plam $ \oref info -> P.do pisJust #$ pfindTxInByTxOutRef # oref # info