remove allOutputs

This commit is contained in:
fanghr 2022-05-23 18:20:49 +08:00
parent 02bf6f49cc
commit 75c236db01
No known key found for this signature in database
GPG key ID: 0B261157257380F2
2 changed files with 7 additions and 31 deletions

View file

@ -37,7 +37,6 @@ import GHC.Generics qualified as GHC
--------------------------------------------------------------------------------
import Agora.Utils (
allOutputs,
plookup,
psymbolValueOf,
ptokenSpent,
@ -134,7 +133,7 @@ authorityTokenPolicy params =
pmatch ctx' $ \(PScriptContext ctx') -> unTermCont $ do
ctx <- tcont $ pletFields @'["txInfo", "purpose"] ctx'
PTxInfo txInfo' <- tcmatch $ pfromData ctx.txInfo
txInfo <- tcont $ pletFields @'["inputs", "mint"] txInfo'
txInfo <- tcont $ pletFields @'["inputs", "mint", "outputs"] txInfo'
let inputs = txInfo.inputs
mintedValue = pfromData txInfo.mint
AssetClass (govCs, govTn) = params.authority
@ -151,10 +150,12 @@ authorityTokenPolicy params =
( unTermCont $ do
tcassert "Parent token did not move in minting GATs" govTokenSpent
tcassert "All outputs only emit valid GATs" $
allOutputs @PData # pfromData ctx.txInfo #$ plam $ \txOut _value _address _datum ->
authorityTokensValidIn
# ownSymbol
# txOut
pall
# plam
( (authorityTokensValidIn # ownSymbol #)
. pfromData
)
# txInfo.outputs
pure $ popaque $ pconstant ()
)
(popaque $ pconstant ())

View file

@ -45,7 +45,6 @@ module Agora.Utils (
-- * Functions which should (probably) not be upstreamed
anyOutput,
allOutputs,
findTxOutByTxOutRef,
scriptHashFromAddress,
findOutputsToAddress,
@ -581,30 +580,6 @@ anyOutput = phoistAcyclic $
)
# pfromData txInfo.outputs
-- | Check if all outputs match the predicate.
allOutputs ::
forall (datum :: PType) s.
( PIsData datum
, PTryFrom PData (PAsData datum)
) =>
Term s (PTxInfo :--> (PTxOut :--> PValue :--> PAddress :--> datum :--> PBool) :--> PBool)
allOutputs = phoistAcyclic $
plam $ \txInfo' predicate -> unTermCont $ do
txInfo <- tcont $ pletFields @'["outputs", "datums"] txInfo'
pure $
pall
# plam
( \txOut'' -> unTermCont $ do
PTxOut txOut' <- tcmatch (pfromData txOut'')
txOut <- tcont $ pletFields @'["value", "datumHash", "address"] txOut'
PDJust dh <- tcmatch txOut.datumHash
pure $
pmatch (ptryFindDatum @(PAsData datum) # (pfield @"_0" # dh) # txInfo.datums) $ \case
PJust datum -> predicate # pfromData txOut'' # txOut.value # txOut.address # pfromData datum
PNothing -> pcon PFalse
)
# pfromData txInfo.outputs
-- | Create a value with a single asset class.
psingletonValue :: forall s. Term s (PCurrencySymbol :--> PTokenName :--> PInteger :--> PValue)
psingletonValue = phoistAcyclic $