remove allOutputs
This commit is contained in:
parent
f18b0992e7
commit
e89b245b20
2 changed files with 7 additions and 31 deletions
|
|
@ -37,7 +37,6 @@ import GHC.Generics qualified as GHC
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Agora.Utils (
|
import Agora.Utils (
|
||||||
allOutputs,
|
|
||||||
plookup,
|
plookup,
|
||||||
psymbolValueOf,
|
psymbolValueOf,
|
||||||
ptokenSpent,
|
ptokenSpent,
|
||||||
|
|
@ -134,7 +133,7 @@ authorityTokenPolicy params =
|
||||||
pmatch ctx' $ \(PScriptContext ctx') -> unTermCont $ do
|
pmatch ctx' $ \(PScriptContext ctx') -> unTermCont $ do
|
||||||
ctx <- tcont $ pletFields @'["txInfo", "purpose"] ctx'
|
ctx <- tcont $ pletFields @'["txInfo", "purpose"] ctx'
|
||||||
PTxInfo txInfo' <- tcmatch $ pfromData ctx.txInfo
|
PTxInfo txInfo' <- tcmatch $ pfromData ctx.txInfo
|
||||||
txInfo <- tcont $ pletFields @'["inputs", "mint"] txInfo'
|
txInfo <- tcont $ pletFields @'["inputs", "mint", "outputs"] txInfo'
|
||||||
let inputs = txInfo.inputs
|
let inputs = txInfo.inputs
|
||||||
mintedValue = pfromData txInfo.mint
|
mintedValue = pfromData txInfo.mint
|
||||||
AssetClass (govCs, govTn) = params.authority
|
AssetClass (govCs, govTn) = params.authority
|
||||||
|
|
@ -151,10 +150,12 @@ authorityTokenPolicy params =
|
||||||
( unTermCont $ do
|
( unTermCont $ do
|
||||||
tcassert "Parent token did not move in minting GATs" govTokenSpent
|
tcassert "Parent token did not move in minting GATs" govTokenSpent
|
||||||
tcassert "All outputs only emit valid GATs" $
|
tcassert "All outputs only emit valid GATs" $
|
||||||
allOutputs @PData # pfromData ctx.txInfo #$ plam $ \txOut _value _address _datum ->
|
pall
|
||||||
authorityTokensValidIn
|
# plam
|
||||||
# ownSymbol
|
( (authorityTokensValidIn # ownSymbol #)
|
||||||
# txOut
|
. pfromData
|
||||||
|
)
|
||||||
|
# txInfo.outputs
|
||||||
pure $ popaque $ pconstant ()
|
pure $ popaque $ pconstant ()
|
||||||
)
|
)
|
||||||
(popaque $ pconstant ())
|
(popaque $ pconstant ())
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ module Agora.Utils (
|
||||||
|
|
||||||
-- * Functions which should (probably) not be upstreamed
|
-- * Functions which should (probably) not be upstreamed
|
||||||
anyOutput,
|
anyOutput,
|
||||||
allOutputs,
|
|
||||||
findTxOutByTxOutRef,
|
findTxOutByTxOutRef,
|
||||||
scriptHashFromAddress,
|
scriptHashFromAddress,
|
||||||
findOutputsToAddress,
|
findOutputsToAddress,
|
||||||
|
|
@ -581,30 +580,6 @@ anyOutput = phoistAcyclic $
|
||||||
)
|
)
|
||||||
# pfromData txInfo.outputs
|
# 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.
|
-- | Create a value with a single asset class.
|
||||||
psingletonValue :: forall s. Term s (PCurrencySymbol :--> PTokenName :--> PInteger :--> PValue)
|
psingletonValue :: forall s. Term s (PCurrencySymbol :--> PTokenName :--> PInteger :--> PValue)
|
||||||
psingletonValue = phoistAcyclic $
|
psingletonValue = phoistAcyclic $
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue