Merge pull request #602 from Plutonomicon/emiflake/export-script-constructor
add constructor export for `Script` type, add `deserialiseScript`
add constructor export for `Script` type, add `deserialiseScript`
(PI.:-->),
PI.ClosedTerm,
PI.compile,
PI.Script,
PI.Script (PI.Script),
PI.Dig,
PI.hashTerm,
PI.papp,
-- | $term
Term (..),
asClosedRawTerm,
Script,
Script (Script),
mapTerm,
plam',
plet,
module Plutarch.Script (Script (..), serialiseScript) where
module Plutarch.Script (Script (..), serialiseScript, deserialiseScript) where
import Data.ByteString.Short (ShortByteString)
import PlutusLedgerApi.Common (serialiseUPLC)
import GHC.Generics (Generic)
import PlutusLedgerApi.Common (deserialiseUPLC, serialiseUPLC)
import UntypedPlutusCore qualified as UPLC
newtype Script = Script {unScript :: UPLC.Program UPLC.DeBruijn UPLC.DefaultUni UPLC.DefaultFun ()}
deriving newtype (Eq)
deriving stock (Show)
deriving stock (Show, Generic)
serialiseScript :: Script -> ShortByteString
serialiseScript = serialiseUPLC . unScript
deserialiseScript :: ShortByteString -> Script
deserialiseScript = Script . deserialiseUPLC
check return collateral amount on test_duplicated_collareral
Co-authored-by: Juliano Lazzarotto <[email protected]>
Changed a couple cases where the inner Rc object was cloned to use the Rc object instead
Includes a fix for test case in #175 This also includes fixes for extra data in tables too, not just those ones in map-structs. A test case is added that covers basically anywhere you could add extra data, but under the assumption that keys of the same CBOR type as somewhere in the spec must conform to the spec. The rest of the data is ignored properly and can be whatever. Also, constants e.g. string members are also allowed that don't conform and are ignored (this is what #175 tested). It could be worth adding this operation to cddl-codegen if we get more metadata-based specs although we would need to do it a bit more generically since the other data wouldn't necessarily be a metadatum (unless we hardcode CML-related types into cddl-codegen but I'd rather not do that).:
Another cip25 test