get rid of pownCurrencySymbol

This commit is contained in:
fanghr 2022-04-28 17:44:18 +08:00
parent c3a10f8bbd
commit 9c79585c7c
No known key found for this signature in database
GPG key ID: 35CD9A71CD5D5870
2 changed files with 8 additions and 17 deletions

View file

@ -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

View file

@ -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