@@ -26,9 +26,9 @@ import Plutarch.Extra.Interval (pcontains)
2626import Plutarch.List (pmap )
2727import Plutarch.Monadic qualified as P
2828import Plutarch.Num (PNum (pnegate , (#+) ))
29- import Plutarch.Prelude (ClosedTerm , PAsData , PBuiltinList , PByteString , PData , PEq ((#==) ), PInteger , PListLike (pcons , phead , pnil ), PMaybe (PJust ), PPair (PPair ), PPartialOrd ((#<) , (#<=) ), Term , pcon , pconsBS , pconstant , pfield , pfoldl , pfromData , phoistAcyclic , plam , plet , pletFields , ptrace , ptraceError , (#) , (#$) , type (:--> ))
29+ import Plutarch.Prelude (ClosedTerm , PAsData , PBuiltinList , PByteString , PData , PEq ((#==) ), PInteger , PListLike (pcons , phead , pnil ), PMaybe (PJust ), PPair (PPair ), PPartialOrd ((#<) , (#<=) ), Term , pcon , pconsBS , pconstant , pdata , pfield , pfoldl , pfromData , phoistAcyclic , plam , plet , pletFields , ptrace , ptraceError , (#) , (#$) , type (:--> ))
3030import PlutusTx.Prelude (Group (inv ))
31- import Prelude (Monoid (mempty ), Semigroup ((<>) ), ($) )
31+ import Prelude (Monoid (mempty ), Semigroup ((<>) ), ($) , (.) )
3232
3333{- | Validates spending from @FsV
3434
@@ -619,7 +619,7 @@ exampleConsumer = phoistAcyclic $
619619 arrayNumbers' :: Term s (PBuiltinList (PAsData PInteger )) <- plet $ pfromData $ ptryFromData arrayNumbers'''
620620 -- Parse the elements within as Plutus Integer
621621 arrayNumbers <- plet $ pmap # plam pfromData # arrayNumbers'
622- _ <- plet $ pif (arrayNumbers #== pconstant [1 , 2 , 3 ]) (popaque punit) (ptraceError " Expected a Plutus List [1,2,3]" )
622+ _ <- plet $ pif (arrayNumbers #== pconstant [1 , 2 , 3 ]) (popaque punit) (ptraceError " Expected Plutus List [1,2,3]" )
623623
624624 -- Take the "boolean" field in the Fact Statement and assert that it is true
625625 PJust boolean' <- pmatch $ plookup # pconstant " boolean" # factStatement
@@ -628,9 +628,35 @@ exampleConsumer = phoistAcyclic $
628628
629629 -- Take the "null" field in the Fact Statement and assert that it is null
630630 PJust null' <- pmatch $ plookup # pconstant " null" # factStatement
631- null'' :: Term s (PBuiltinPair PInteger (PBuiltinList PData )) <- plet $ pasConstr # null'
632- _ <- plet $ pif ((pfstBuiltin # null'') #== 2 ) (popaque punit) (ptraceError " Expected a Plutus Boolean type (Constr 2 [])" )
633- _ <- plet $ pif ((psndBuiltin # null'') #== pconstant [] ) (popaque punit) (ptraceError " Expected a Plutus Boolean type (Constr 2 [])" )
631+ null :: Term s (PBuiltinPair PInteger (PBuiltinList PData )) <- plet $ pasConstr # null'
632+ _ <- plet $ pif ((pfstBuiltin # null ) #== 2 ) (popaque punit) (ptraceError " Expected a Plutus Constr 2 []" )
633+ _ <- plet $ pif ((psndBuiltin # null ) #== pconstant [] ) (popaque punit) (ptraceError " Expected a Plutus Constr 2 []" )
634+
635+ -- Take the "integer" field in the Fact Statement and assert that it is 123
636+ PJust integer' <- pmatch $ plookup # pconstant " integer" # factStatement
637+ integer :: Term s PInteger <- plet $ pfromData $ ptryFromData integer'
638+ _ <- plet $ pif (integer #== pconstant 123 ) (popaque punit) (ptraceError " Expected a Plutus Integer 123" )
639+
640+ -- Take the "big_integer" field in the Fact Statement and assert that it is 12300000000000000000000000
641+ PJust bigInteger' <- pmatch $ plookup # pconstant " big_integer" # factStatement
642+ bigInteger'' :: Term s (PBuiltinPair PInteger (PBuiltinList PData )) <- plet $ pasConstr # bigInteger'
643+ bigInteger''' :: Term s (PBuiltinList PInteger ) <- plet $ pmap # plam (pfromData . ptryFromData) # (psndBuiltin # bigInteger'')
644+ _ <- plet $ pif ((pfstBuiltin # bigInteger'') #== 3 ) (popaque punit) (ptraceError " Expected a Plutus Constr 3 [12300000000000000000000000, 0]" )
645+ _ <- plet $ pif (bigInteger''' #== pconstant [12300000000000000000000000 , 0 ]) (popaque punit) (ptraceError " Expected a Plutus Constr 3 [12300000000000000000000000, 0]" )
646+
647+ -- Take the "real" field in the Fact Statement and assert that it is 123.123
648+ PJust real' <- pmatch $ plookup # pconstant " real" # factStatement
649+ real'' :: Term s (PBuiltinPair PInteger (PBuiltinList PData )) <- plet $ pasConstr # real'
650+ real''' :: Term s (PBuiltinList PInteger ) <- plet $ pmap # plam (pfromData . ptryFromData) # (psndBuiltin # real'')
651+ _ <- plet $ pif ((pfstBuiltin # real'') #== 3 ) (popaque punit) (ptraceError " Expected a Plutus Constr 3 [123123, -3]" )
652+ _ <- plet $ pif (real''' #== pconstant [123123 , - 3 ]) (popaque punit) (ptraceError " Expected a Plutus Constr 3 [123123, -3]" )
653+
654+ -- Take the "big_real" field in the Fact Statement and assert that it is 123.123
655+ PJust big_real' <- pmatch $ plookup # pconstant " big_real" # factStatement
656+ big_real'' :: Term s (PBuiltinPair PInteger (PBuiltinList PData )) <- plet $ pasConstr # big_real'
657+ big_real''' :: Term s (PBuiltinList PInteger ) <- plet $ pmap # plam (pfromData . ptryFromData) # (psndBuiltin # big_real'')
658+ _ <- plet $ pif ((pfstBuiltin # big_real'') #== 3 ) (popaque punit) (ptraceError " Expected a Plutus Constr 3 [12300000000000000000000000123, -3]" )
659+ _ <- plet $ pif (big_real''' #== pconstant [12300000000000000000000000123 , - 3 ]) (popaque punit) (ptraceError " Expected a Plutus Constr 3 [12300000000000000000000000123, -3]" )
634660
635661 ptrace " exampleConsumer: Must have a Fact Statement reference input from a trusted COOP Oracle" $ popaque punit
636662 )
0 commit comments