remove anyInput
This commit is contained in:
parent
03c514c88e
commit
f18b0992e7
2 changed files with 15 additions and 35 deletions
|
|
@ -11,8 +11,8 @@ import Agora.Record (mkRecordConstr, (.&), (.=))
|
||||||
import Agora.SafeMoney (GTTag)
|
import Agora.SafeMoney (GTTag)
|
||||||
import Agora.Stake
|
import Agora.Stake
|
||||||
import Agora.Utils (
|
import Agora.Utils (
|
||||||
anyInput,
|
|
||||||
anyOutput,
|
anyOutput,
|
||||||
|
mustFindDatum',
|
||||||
paddValue,
|
paddValue,
|
||||||
pfindTxInByTxOutRef,
|
pfindTxInByTxOutRef,
|
||||||
pgeqByClass,
|
pgeqByClass,
|
||||||
|
|
@ -77,7 +77,7 @@ stakePolicy gtClassRef =
|
||||||
txInfo <- tclet $ ctx.txInfo
|
txInfo <- tclet $ ctx.txInfo
|
||||||
let _a :: Term _ PTxInfo
|
let _a :: Term _ PTxInfo
|
||||||
_a = txInfo
|
_a = txInfo
|
||||||
txInfoF <- tcont $ pletFields @'["mint", "inputs", "outputs", "signatories"] txInfo
|
txInfoF <- tcont $ pletFields @'["mint", "inputs", "outputs", "signatories", "datums"] txInfo
|
||||||
|
|
||||||
PMinting ownSymbol' <- tcmatch $ pfromData ctx.purpose
|
PMinting ownSymbol' <- tcmatch $ pfromData ctx.purpose
|
||||||
ownSymbol <- tclet $ pfield @"_0" # ownSymbol'
|
ownSymbol <- tclet $ pfield @"_0" # ownSymbol'
|
||||||
|
|
@ -92,12 +92,19 @@ stakePolicy gtClassRef =
|
||||||
mintedST #== -1
|
mintedST #== -1
|
||||||
|
|
||||||
tcassert "An unlocked input existed containing an ST" $
|
tcassert "An unlocked input existed containing an ST" $
|
||||||
anyInput @PStakeDatum # txInfo
|
pany
|
||||||
#$ plam
|
# plam
|
||||||
$ \value _ stakeDatum' ->
|
( \((pfield @"resolved" #) -> txOut) -> unTermCont $ do
|
||||||
let hasST = psymbolValueOf # ownSymbol # value #== 1
|
txOutF <- tcont $ pletFields @'["value", "datumHash"] txOut
|
||||||
unlocked = pnot # (stakeLocked # stakeDatum')
|
pure $
|
||||||
in hasST #&& unlocked
|
pif
|
||||||
|
(psymbolValueOf # ownSymbol # txOutF.value #== 1)
|
||||||
|
( let datum = mustFindDatum' @PStakeDatum # txOutF.datumHash # txInfoF.datums
|
||||||
|
in pnot # (stakeLocked # datum)
|
||||||
|
)
|
||||||
|
(pconstant False)
|
||||||
|
)
|
||||||
|
# pfromData txInfoF.inputs
|
||||||
|
|
||||||
pure $ popaque (pconstant ())
|
pure $ popaque (pconstant ())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ module Agora.Utils (
|
||||||
-- * Functions which should (probably) not be upstreamed
|
-- * Functions which should (probably) not be upstreamed
|
||||||
anyOutput,
|
anyOutput,
|
||||||
allOutputs,
|
allOutputs,
|
||||||
anyInput,
|
|
||||||
findTxOutByTxOutRef,
|
findTxOutByTxOutRef,
|
||||||
scriptHashFromAddress,
|
scriptHashFromAddress,
|
||||||
findOutputsToAddress,
|
findOutputsToAddress,
|
||||||
|
|
@ -606,32 +605,6 @@ allOutputs = phoistAcyclic $
|
||||||
)
|
)
|
||||||
# pfromData txInfo.outputs
|
# pfromData txInfo.outputs
|
||||||
|
|
||||||
-- | Check if any (resolved) input matches the predicate.
|
|
||||||
anyInput ::
|
|
||||||
forall (datum :: PType) s.
|
|
||||||
( PIsData datum
|
|
||||||
, PTryFrom PData (PAsData datum)
|
|
||||||
) =>
|
|
||||||
Term s (PTxInfo :--> (PValue :--> PAddress :--> datum :--> PBool) :--> PBool)
|
|
||||||
anyInput = phoistAcyclic $
|
|
||||||
plam $ \txInfo' predicate -> unTermCont $ do
|
|
||||||
txInfo <- tcont $ pletFields @'["inputs", "datums"] txInfo'
|
|
||||||
pure $
|
|
||||||
pany
|
|
||||||
# plam
|
|
||||||
( \txInInfo'' -> unTermCont $ do
|
|
||||||
PTxInInfo txInInfo' <- tcmatch (pfromData txInInfo'')
|
|
||||||
let txOut'' = pfield @"resolved" # txInInfo'
|
|
||||||
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 # txOut.value # txOut.address # pfromData datum
|
|
||||||
PNothing -> pcon PFalse
|
|
||||||
)
|
|
||||||
# pfromData txInfo.inputs
|
|
||||||
|
|
||||||
-- | 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