diff --git a/src/Plutus/Types/Address.purs b/src/Plutus/Types/Address.purs index f70b56124..139684905 100644 --- a/src/Plutus/Types/Address.purs +++ b/src/Plutus/Types/Address.purs @@ -18,7 +18,7 @@ import Aeson , encodeAeson' , (.:) ) -import Contract.Prelude (Either(Left)) +import Data.Either (Either(Left)) import Data.Generic.Rep (class Generic) import Data.Maybe (Maybe(Just, Nothing)) import Data.Newtype (class Newtype, wrap, unwrap) @@ -39,7 +39,11 @@ import Plutus.Types.DataSchema import Serialization.Address (NetworkId) import ToData (class ToData, genericToData) import TypeLevel.Nat (Z) -import Types.PubKeyHash (PaymentPubKeyHash(..), StakePubKeyHash, PubKeyHash) +import Types.PubKeyHash + ( PaymentPubKeyHash(PaymentPubKeyHash) + , StakePubKeyHash + , PubKeyHash + ) import Types.Scripts (ValidatorHash) -------------------------------------------------------------------------------- @@ -94,14 +98,11 @@ instance FromData Address where fromData = genericFromData instance DecodeAeson Address where - decodeAeson aes = caseAesonObject - (Left $ TypeMismatch "Expected object") - ( \obj -> do - addressCredential <- obj .: "addressCredential" - addressStakingCredential <- obj .: "addressStakingCredential" - pure $ Address { addressCredential, addressStakingCredential } - ) - aes + decodeAeson = caseAesonObject (Left $ TypeMismatch "Expected object") $ + \obj -> do + addressCredential <- obj .: "addressCredential" + addressStakingCredential <- obj .: "addressStakingCredential" + pure $ Address { addressCredential, addressStakingCredential } instance EncodeAeson Address where encodeAeson' (Address addr) = encodeAeson' addr diff --git a/src/Plutus/Types/Credential.purs b/src/Plutus/Types/Credential.purs index 1b0fc0ce2..b198ca175 100644 --- a/src/Plutus/Types/Credential.purs +++ b/src/Plutus/Types/Credential.purs @@ -23,8 +23,8 @@ import Plutus.Types.DataSchema ) import ToData (class ToData, genericToData) import TypeLevel.Nat (S, Z) -import Aeson.Decode as D -import Aeson.Encode as E +import Aeson.Decode as Decode +import Aeson.Encode as Encode import Data.Map as Map import Serialization.Address (CertificateIndex, Slot, TransactionIndex) import Types.PubKeyHash (PubKeyHash) @@ -64,18 +64,22 @@ instance -- NOTE: mlabs-haskell/purescript-bridge generated and applied here instance EncodeAeson Credential where - encodeAeson' x = encodeAeson' $ - ( defer \_ -> case _ of - PubKeyCredential a -> E.encodeTagged "PubKeyCredential" a E.value - ScriptCredential a -> E.encodeTagged "ScriptCredential" a E.value - ) x + encodeAeson' = encodeAeson' <<< + ( defer $ const $ case _ of + PubKeyCredential a -> Encode.encodeTagged "PubKeyCredential" a + Encode.value + ScriptCredential a -> Encode.encodeTagged "ScriptCredential" a + Encode.value + ) instance DecodeAeson Credential where - decodeAeson = defer \_ -> D.decode - $ D.sumType "Credential" + decodeAeson = defer $ const $ Decode.decode + $ Decode.sumType "Credential" $ Map.fromFoldable - [ "PubKeyCredential" /\ D.content (PubKeyCredential <$> D.value) - , "ScriptCredential" /\ D.content (ScriptCredential <$> D.value) + [ "PubKeyCredential" /\ Decode.content + (PubKeyCredential <$> Decode.value) + , "ScriptCredential" /\ Decode.content + (ScriptCredential <$> Decode.value) ] instance ToData Credential where @@ -128,21 +132,25 @@ instance FromData StakingCredential where -- NOTE: mlabs-haskell/purescript-bridge generated and applied here instance EncodeAeson StakingCredential where - encodeAeson' x = encodeAeson' $ - ( defer \_ -> case _ of - StakingHash a -> E.encodeTagged "StakingHash" a E.value - StakingPtr ptr -> E.encodeTagged "StakingPtr" + encodeAeson' = encodeAeson' <<< defer + ( const $ case _ of + StakingHash a -> Encode.encodeTagged "StakingHash" a Encode.value + StakingPtr ptr -> Encode.encodeTagged "StakingPtr" (ptr.slot /\ ptr.txIx /\ ptr.certIx) - (E.tuple (E.value >/\< E.value >/\< E.value)) - ) x + (Encode.tuple (Encode.value >/\< Encode.value >/\< Encode.value)) + ) instance DecodeAeson StakingCredential where - decodeAeson = defer \_ -> D.decode - $ D.sumType "StakingCredential" + decodeAeson = defer $ const $ Decode.decode + $ Decode.sumType "StakingCredential" $ Map.fromFoldable - [ "StakingHash" /\ D.content (StakingHash <$> D.value) - , "StakingPtr" /\ D.content - (D.tuple $ toStakingPtr D.value D.value D.value) + [ "StakingHash" /\ Decode.content (StakingHash <$> Decode.value) + , "StakingPtr" /\ Decode.content + ( Decode.tuple $ toStakingPtr Decode.value Decode.value + Decode.value + ) ] where + toStakingPtr + :: Slot -> TransactionIndex -> CertificateIndex -> StakingCredential toStakingPtr slot txIx certIx = StakingPtr { slot, txIx, certIx } diff --git a/src/Plutus/Types/Value.purs b/src/Plutus/Types/Value.purs index a361cb7f2..fa92f7185 100644 --- a/src/Plutus/Types/Value.purs +++ b/src/Plutus/Types/Value.purs @@ -36,10 +36,10 @@ import Aeson , getField , JsonDecodeError(TypeMismatch) ) -import Contract.Prelude (Either(..)) import Control.Apply (lift3) import Data.Array (concatMap, filter) import Data.BigInt (BigInt) +import Data.Either (Either(Left)) import Data.Foldable (all) import Data.Generic.Rep (class Generic) import Data.Lattice (class JoinSemilattice, class MeetSemilattice) diff --git a/src/ReindexRedeemers.purs b/src/ReindexRedeemers.purs index 8e061d2d1..865d29db2 100644 --- a/src/ReindexRedeemers.purs +++ b/src/ReindexRedeemers.purs @@ -14,7 +14,7 @@ import Data.Array (elemIndex) import Data.BigInt (fromInt) import Data.Either (Either(Right), note) import Data.Generic.Rep (class Generic) -import Data.Maybe (Maybe(Just, Nothing)) +import Data.Maybe (Maybe(Just)) import Data.Show.Generic (genericShow) import Data.Traversable (traverse) import Data.Tuple (fst) @@ -65,5 +65,4 @@ reindexSpentScriptRedeemers' inputs redeemersTxIns = runExceptT do index <- note (CannotGetTxOutRefIndexForRedeemer red) (fromInt <$> elemIndex txOutRef ipts) Right $ T.Redeemer red' { index = index } /\ Just txOutRef - red@(T.Redeemer { tag: Spend }) /\ Nothing -> Right $ red /\ Nothing mintRed /\ txOutRef -> Right $ mintRed /\ txOutRef diff --git a/src/Serialization/Hash.purs b/src/Serialization/Hash.purs index 9e17525a2..d0479b1dc 100644 --- a/src/Serialization/Hash.purs +++ b/src/Serialization/Hash.purs @@ -22,8 +22,7 @@ import Aeson , caseAesonString , encodeAeson' ) -import Contract.Prelude (Either(..)) -import Data.Either (Either(Left), note) +import Data.Either (Either(Left, Right), note) import Data.Function (on) import Data.Maybe (Maybe(Nothing, Just), maybe) import Data.Newtype (unwrap, wrap) @@ -144,12 +143,9 @@ instance FromMetadata ScriptHash where -- Corresponds to Plutus' `Plutus.V1.Ledger.Api.Script` Aeson instances instance DecodeAeson ScriptHash where - decodeAeson aes = do - let - mayHash = caseAesonString Nothing - (Just <=< scriptHashFromBytes <=< hexToRawBytes) - aes - maybe (Left $ TypeMismatch "Expected hex-encoded script hash") Right mayHash + decodeAeson = do + maybe (Left $ TypeMismatch "Expected hex-encoded script hash") Right <<< + caseAesonString Nothing (Just <=< scriptHashFromBytes <=< hexToRawBytes) instance EncodeAeson ScriptHash where encodeAeson' sh = encodeAeson' $ scriptHashToBytes sh diff --git a/src/Types/Datum.purs b/src/Types/Datum.purs index 917f32052..f7b1c0818 100644 --- a/src/Types/Datum.purs +++ b/src/Types/Datum.purs @@ -16,8 +16,8 @@ import FromData (class FromData) import ToData (class ToData, toData) import Types.PlutusData (PlutusData) import Types.Transaction (DataHash(DataHash)) as X -import Aeson.Decode as D -import Aeson.Encode as E +import Aeson.Decode as Decode +import Aeson.Encode as Encode -- | Define data types mirroring Plutus `Datum`, like `Datum` itself and -- | `Redeemer` where the latter is not to be confused with the CSL-stype @@ -34,13 +34,14 @@ derive newtype instance Ord Datum derive newtype instance ToData Datum instance EncodeAeson Datum where - encodeAeson' x = encodeAeson' $ (defer \_ -> E.encode $ unwrap >$< E.value) x + encodeAeson' = encodeAeson' <<< + defer (const $ Encode.encode $ unwrap >$< Encode.value) instance DecodeAeson Datum where - decodeAeson = defer \_ -> D.decode $ (Datum <$> D.value) + decodeAeson = defer $ const $ Decode.decode $ Datum <$> Decode.value instance Show Datum where show = genericShow unitDatum :: Datum -unitDatum = Datum (toData unit) +unitDatum = Datum $ toData unit diff --git a/src/Types/Interval.purs b/src/Types/Interval.purs index 2963bdd97..dce854e71 100644 --- a/src/Types/Interval.purs +++ b/src/Types/Interval.purs @@ -65,9 +65,9 @@ import Aeson , isNull ) import Aeson.Decode ((), ()) -import Aeson.Decode as D +import Aeson.Decode as Decode import Aeson.Encode ((>$<), (>/\<)) -import Aeson.Encode as E +import Aeson.Encode as Encode import Control.Lazy (defer) import Control.Monad.Error.Class (throwError) import Control.Monad.Except.Trans (ExceptT(ExceptT), runExceptT) @@ -132,6 +132,7 @@ import TypeLevel.Nat (S, Z) type Closure = Boolean -- | A set extended with a positive and negative infinity. +data Extended :: Type -> Type data Extended a = NegInf | Finite a | PosInf instance @@ -273,7 +274,7 @@ instance EncodeAeson a => EncodeAeson (Interval a) where instance DecodeAeson a => DecodeAeson (Interval a) where decodeAeson a = do - (HaskInterval i) <- decodeAeson a + HaskInterval i <- decodeAeson a pure $ Interval { from: i.ivFrom, to: i.ivTo } -------------------------------------------------------------------------------- @@ -1026,57 +1027,62 @@ derive instance Functor HaskInterval derive instance Newtype (HaskInterval a) _ instance (EncodeAeson a) => EncodeAeson (HaskInterval a) where - encodeAeson' x = encodeAeson' $ - ( defer \_ -> E.encode $ unwrap >$< - ( E.record - { ivFrom: E.value :: _ (LowerBound a) - , ivTo: E.value :: _ (UpperBound a) - } - ) - ) x + encodeAeson' = encodeAeson' <<< + defer + ( const $ Encode.encode $ unwrap >$< + ( Encode.record + { ivFrom: Encode.value :: _ (LowerBound a) + , ivTo: Encode.value :: _ (UpperBound a) + } + ) + ) instance (DecodeAeson a) => DecodeAeson (HaskInterval a) where - decodeAeson = defer \_ -> D.decode $ - ( HaskInterval <$> D.record "Interval" - { ivFrom: D.value :: _ (LowerBound a) - , ivTo: D.value :: _ (UpperBound a) - } - ) + decodeAeson = defer $ const $ Decode.decode $ + HaskInterval <$> Decode.record "Interval" + { ivFrom: Decode.value :: _ (LowerBound a) + , ivTo: Decode.value :: _ (UpperBound a) + } instance (EncodeAeson a) => EncodeAeson (LowerBound a) where - encodeAeson' x = encodeAeson' $ - ( defer \_ -> E.encode $ (case _ of LowerBound a b -> (a /\ b)) >$< - (E.tuple (E.value >/\< E.value)) - ) x + encodeAeson' = encodeAeson' <<< + defer + ( const $ Encode.encode $ (case _ of LowerBound a b -> (a /\ b)) >$< + (Encode.tuple (Encode.value >/\< Encode.value)) + ) instance (DecodeAeson a) => DecodeAeson (LowerBound a) where - decodeAeson = defer \_ -> D.decode $ - (D.tuple $ LowerBound D.value D.value) + decodeAeson = defer $ const $ Decode.decode + $ Decode.tuple + $ LowerBound Decode.value Decode.value instance (EncodeAeson a) => EncodeAeson (UpperBound a) where - encodeAeson' x = encodeAeson' $ - ( defer \_ -> E.encode $ (case _ of UpperBound a b -> (a /\ b)) >$< - (E.tuple (E.value >/\< E.value)) - ) x + encodeAeson' = encodeAeson' <<< + defer + ( const $ Encode.encode $ (case _ of UpperBound a b -> (a /\ b)) >$< + (Encode.tuple (Encode.value >/\< Encode.value)) + ) instance (DecodeAeson a) => DecodeAeson (UpperBound a) where - decodeAeson = defer \_ -> D.decode $ - (D.tuple $ UpperBound D.value D.value) + decodeAeson = defer $ const $ Decode.decode + $ Decode.tuple + $ UpperBound Decode.value Decode.value instance (EncodeAeson a) => EncodeAeson (Extended a) where - encodeAeson' x = encodeAeson' $ - ( defer \_ -> case _ of - NegInf -> encodeAeson { tag: "NegInf" } - Finite a -> E.encodeTagged "Finite" a E.value - PosInf -> encodeAeson { tag: "PosInf" } - ) x + encodeAeson' = encodeAeson' <<< + defer + ( const $ case _ of + NegInf -> encodeAeson { tag: "NegInf" } + Finite a -> Encode.encodeTagged "Finite" a Encode.value + PosInf -> encodeAeson { tag: "PosInf" } + ) instance (DecodeAeson a) => DecodeAeson (Extended a) where - decodeAeson = defer \_ -> D.decode - $ D.sumType "Extended" + decodeAeson = defer $ const $ Decode.decode + $ Decode.sumType "Extended" $ Map.fromFoldable [ "NegInf" /\ pure NegInf - , "Finite" /\ D.content (Finite <$> D.value) + , "Finite" /\ Decode.content (Finite <$> Decode.value) , "PosInf" /\ pure PosInf ] diff --git a/src/Types/PubKeyHash.purs b/src/Types/PubKeyHash.purs index 262e478b8..dc562e1b0 100644 --- a/src/Types/PubKeyHash.purs +++ b/src/Types/PubKeyHash.purs @@ -22,8 +22,8 @@ import Aeson , encodeAeson' , getField ) -import Aeson.Decode as D -import Aeson.Encode as E +import Aeson.Decode as Decode +import Aeson.Encode as Encode import Data.Either (Either(Left)) import Data.Generic.Rep (class Generic) import Data.Newtype (class Newtype, unwrap, wrap) @@ -65,14 +65,16 @@ instance Show PubKeyHash where -- NOTE: mlabs-haskell/purescript-bridge generated and applied here instance EncodeAeson PubKeyHash where - encodeAeson' x = encodeAeson' $ E.encode - (E.record { getPubKeyHash: E.value :: _ (Ed25519KeyHash) }) + encodeAeson' x = encodeAeson' $ Encode.encode + (Encode.record { getPubKeyHash: Encode.value :: _ (Ed25519KeyHash) }) { getPubKeyHash: unwrap x } instance DecodeAeson PubKeyHash where - decodeAeson x = wrap <<< get (Proxy :: Proxy "getPubKeyHash") <$> D.decode - (D.record "getPubKeyHash " { getPubKeyHash: D.value :: _ (Ed25519KeyHash) }) - x + decodeAeson = map (wrap <<< get (Proxy :: Proxy "getPubKeyHash")) <<< + Decode.decode + ( Decode.record "getPubKeyHash " + { getPubKeyHash: Decode.value :: _ (Ed25519KeyHash) } + ) ed25519EnterpriseAddress :: forall (n :: Type) @@ -126,11 +128,9 @@ instance Show PaymentPubKeyHash where -- This is needed for `ApplyArgs`. Plutus has an `unPaymentPubKeyHash` field so -- don't newtype derive. instance DecodeAeson PaymentPubKeyHash where - decodeAeson = caseAesonObject - (Left $ TypeMismatch "Expected object") - ( flip getField "unPaymentPubKeyHash" >=> - decodeAeson >>> map PaymentPubKeyHash - ) + decodeAeson = caseAesonObject (Left $ TypeMismatch "Expected object") + $ flip getField "unPaymentPubKeyHash" >=> decodeAeson >>> map + PaymentPubKeyHash newtype StakePubKeyHash = StakePubKeyHash PubKeyHash diff --git a/src/Types/Scripts.purs b/src/Types/Scripts.purs index 59275d791..e696bc68d 100644 --- a/src/Types/Scripts.purs +++ b/src/Types/Scripts.purs @@ -48,12 +48,12 @@ instance Show PlutusScript where show = genericShow decodeAesonHelper - ∷ ∀ (a ∷ Type) (b :: Type) + :: ∀ (a :: Type) (b :: Type) . DecodeAeson a => String - → (a -> b) - → Aeson - → Either JsonDecodeError b + -> (a -> b) + -> Aeson + -> Either JsonDecodeError b decodeAesonHelper constrName constr = caseAesonObject (Left $ TypeMismatch "Expected object") (flip getField constrName >=> decodeAeson >>> map constr) diff --git a/src/Types/TokenName.purs b/src/Types/TokenName.purs index ab855365b..2f261cf46 100644 --- a/src/Types/TokenName.purs +++ b/src/Types/TokenName.purs @@ -62,51 +62,47 @@ fromTokenName arrayHandler stringHandler (TokenName cba) = either stringHandler (decodeUtf8 <<< unwrap <<< cborBytesToByteArray $ cba) +-- | Corresponds to following Haskell instance: +-- | +-- | ``` +-- | toJSON = JSON.object . Haskell.pure . (,) "unTokenName" . JSON.toJSON . +-- | fromTokenName +-- | (\bs -> Text.cons '\NUL' (asBase16 bs)) + +-- | (\t -> case Text.take 1 t of "\NUL" -> Text.concat ["\NUL\NUL", t]; _ -> t) +-- | ``` instance DecodeAeson TokenName where - {- - toJSON = JSON.object . Haskell.pure . (,) "unTokenName" . JSON.toJSON . - fromTokenName - (\bs -> Text.cons '\NUL' (asBase16 bs)) - - (\t -> case Text.take 1 t of "\NUL" -> Text.concat ["\NUL\NUL", t]; _ -> t) - -} - decodeAeson = caseAesonObject - (Left $ TypeMismatch "Expected object") - ( \aes -> do - tkstr :: String <- getField aes "unTokenName" - case take 3 tkstr of - """\NUL0x""" -> case tkFromStr (drop 3 tkstr) of - Nothing -> Left $ TypeMismatch ("Invalid TokenName E1: " <> tkstr) - Just tk -> Right tk - - """\NUL\NUL\NUL""" -> - note (TypeMismatch $ "Invalid TokenName E2: " <> tkstr) - $ tkFromStr (drop 2 tkstr) - - _ -> note (TypeMismatch $ "Invalid TokenName E3: " <> tkstr) - $ tkFromStr tkstr - ) + decodeAeson = caseAesonObject (Left $ TypeMismatch "Expected object") $ + \aes -> do + tkstr <- getField aes "unTokenName" + case take 3 tkstr of + """\NUL0x""" -> case tkFromStr (drop 3 tkstr) of + Nothing -> Left $ TypeMismatch ("Invalid TokenName E1: " <> tkstr) + Just tk -> Right tk + + """\NUL\NUL\NUL""" -> + note (TypeMismatch $ "Invalid TokenName E2: " <> tkstr) + $ tkFromStr (drop 2 tkstr) + + _ -> note (TypeMismatch $ "Invalid TokenName E3: " <> tkstr) + $ tkFromStr tkstr where tkFromStr :: String -> Maybe TokenName - tkFromStr str = (TokenName <<< wrap) <$> - (byteArrayFromIntArray <<< map toCharCode <<< toCharArray $ str) + tkFromStr = map (TokenName <<< wrap) <<< byteArrayFromIntArray + <<< map toCharCode + <<< toCharArray -- FIXME: what if the tokenname is actually \0\0\0? haskell will break this assuming it -- comes from purescript side -- also we will break assuming it comes from haskell -- this issue has to be fixed on the haskell side instance EncodeAeson TokenName where - encodeAeson' tk = - let - tkstr = fromTokenName - (\ba -> """\NUL""" <> asBase16 ba) - ( \t -> case take 1 t of - """\NUL""" -> """\NUL\NUL""" <> t - _ -> t - ) - tk - in - encodeAeson' { "unTokenName": tkstr } + encodeAeson' = encodeAeson' <<< { "unTokenName": _ } <<< fromTokenName + (("""\NUL""" <> _) <<< asBase16) + ( \t -> case take 1 t of + """\NUL""" -> """\NUL\NUL""" <> t + _ -> t + ) instance Show TokenName where show (TokenName tn) = "(TokenName " <> show tn <> ")" @@ -121,8 +117,9 @@ adaToken = TokenName mempty -- | Create a `TokenName` from a `ByteArray` since TokenName data constructor is -- | not exported mkTokenName :: ByteArray -> Maybe TokenName -mkTokenName byteArr = - if byteLength byteArr <= 32 then pure $ TokenName (wrap byteArr) else Nothing +mkTokenName byteArr + | byteLength byteArr <= 32 = pure $ TokenName $ wrap byteArr + | otherwise = Nothing foreign import assetNameName :: CSL.AssetName -> ByteArray diff --git a/test/Data.purs b/test/Data.purs index 6ea8fd791..5a8bfb513 100644 --- a/test/Data.purs +++ b/test/Data.purs @@ -4,11 +4,10 @@ module Test.Data (suite, tests, uniqueIndicesTests) where import Prelude import Aeson (decodeAeson, encodeAeson, JsonDecodeError(TypeMismatch)) -import Contract.PlutusData (PlutusData(Constr, Integer)) -import Contract.Prelude (Either(Left, Right)) import Control.Lazy (fix) import Data.BigInt (BigInt) import Data.BigInt as BigInt +import Data.Either (Either(Left, Right)) import Data.Generic.Rep as G import Data.Maybe (maybe, Maybe(Just, Nothing), fromJust) import Data.Show.Generic (genericShow) @@ -21,7 +20,7 @@ import FromData (class FromData, fromData, genericFromData) import Helpers (showWithParens) import Mote (group, test) import Partial.Unsafe (unsafePartial) -import Plutus.Types.AssocMap (Map(..)) +import Plutus.Types.AssocMap (Map(Map)) import Plutus.Types.DataSchema ( class HasPlutusSchema , type (:+) @@ -37,6 +36,7 @@ import Test.QuickCheck.Gen (Gen) import Test.Spec.Assertions (shouldEqual) import TestM (TestPlanM) import ToData (class ToData, genericToData, toData) +import Types.PlutusData (PlutusData(Constr, Integer)) import Type.RowList (Cons, Nil) import TypeLevel.Nat (Z, S) import TypeLevel.RowList (class AllUniqueLabels) @@ -45,7 +45,7 @@ import Types.ByteArray (hexToByteArrayUnsafe) import Untagged.Union (asOneOf) plutusDataAesonRoundTrip - ∷ ∀ (a ∷ Type). ToData a ⇒ FromData a ⇒ a → Either JsonDecodeError a + :: forall (a :: Type). ToData a => FromData a => a -> Either JsonDecodeError a plutusDataAesonRoundTrip x = do pd <- encodeAeson (toData x) # decodeAeson maybe (Left $ TypeMismatch "") (pure) $ fromData pd @@ -534,7 +534,7 @@ testBinaryFixture value binaryFixture = do (hexToByteArrayUnsafe binaryFixture) -- | Poor man's type level tests -tests ∷ Array String +tests :: Array String tests = [ testNil , testSingleton @@ -557,7 +557,7 @@ tests = => String testUniques = "[A, B, C] is all unique and should compile" -uniqueIndicesTests ∷ Array String +uniqueIndicesTests :: Array String uniqueIndicesTests = [ testNil , testSingletonZ diff --git a/test/Deserialization.purs b/test/Deserialization.purs index 7e001108c..957ed0222 100644 --- a/test/Deserialization.purs +++ b/test/Deserialization.purs @@ -194,10 +194,10 @@ suite = do group "WitnessSet - deserialization is inverse to serialization" do let witnessSetRoundTrip - ∷ ∀ (m ∷ Type -> Type) + :: ∀ (m :: Type -> Type) . MonadEffect m => MonadThrow Error m - ⇒ ByteArray + => ByteArray -> m Unit witnessSetRoundTrip fixture = do ws0 <- errMaybe "Failed deserialization" $ diff --git a/test/Fixtures.purs b/test/Fixtures.purs index 83d517510..1b7b5cce5 100644 --- a/test/Fixtures.purs +++ b/test/Fixtures.purs @@ -1088,7 +1088,7 @@ plutusDataFixture7 = PD.List , plutusDataFixture6 ] -plutusDataFixture8 ∷ PD.PlutusData +plutusDataFixture8 :: PD.PlutusData plutusDataFixture8 = PD.Constr (BigInt.fromInt 0) [ PD.Bytes ( hexToByteArrayUnsafe @@ -1107,14 +1107,14 @@ plutusDataFixture8 = PD.Constr (BigInt.fromInt 0) , PD.Integer (BigInt.fromInt 45) ] -plutusDataFixture8Bytes ∷ ByteArray +plutusDataFixture8Bytes :: ByteArray plutusDataFixture8Bytes = hexToByteArrayUnsafe "d8799f581cda13ed22b9294f1d86bbd530e99b1456884c7364bf16c90edc1ae41e1a1dcd6500\ \581c82325cbfc20b85bd1ca12e5d12b44b83f68662d8395167b45f1ff7fa4d746f6e6573206f\ \6620736b7920581cda13ed22b9294f1d86bbd530e99b1456884c7364bf16c90edc1ae41e\ \182dff" -plutusDataFixture8Bytes' ∷ ByteArray +plutusDataFixture8Bytes' :: ByteArray plutusDataFixture8Bytes' = hexToByteArrayUnsafe "d866820086581cda13ed22b9294f1d86bbd530e99b1456884c7364bf16c90edc1ae41e1a1dcd\ \6500581c82325cbfc20b85bd1ca12e5d12b44b83f68662d8395167b45f1ff7fa4d746f6e6573\ diff --git a/test/OgmiosDatumCache.purs b/test/OgmiosDatumCache.purs index 10ec7b6d1..47bcd637a 100644 --- a/test/OgmiosDatumCache.purs +++ b/test/OgmiosDatumCache.purs @@ -37,7 +37,7 @@ readPlutusDataSamples = do "./fixtures/test/ogmios-datum-cache/plutus-data-samples.json" plutusDataToFromAesonTest - ∷ forall (m ∷ Type -> Type). MonadEffect m => MonadThrow Error m => m Unit + :: forall (m :: Type -> Type). MonadEffect m => MonadThrow Error m => m Unit plutusDataToFromAesonTest = do pdsAes <- readAeson "./fixtures/test/ogmios-datum-cache/plutus-data-samples.json" @@ -50,7 +50,7 @@ plutusDataToFromAesonTest = do aes `shouldEqual` aes' plutusDataHashingTest - ∷ forall (m ∷ Type -> Type). MonadEffect m => MonadThrow Error m => m Unit + :: forall (m :: Type -> Type). MonadEffect m => MonadThrow Error m => m Unit plutusDataHashingTest = do plutusDataSamples <- readPlutusDataSamples let elems = plutusDataSamples diff --git a/test/Plutus/Address.purs b/test/Plutus/Address.purs index 23b36b144..4cc9e0593 100644 --- a/test/Plutus/Address.purs +++ b/test/Plutus/Address.purs @@ -42,8 +42,9 @@ suite = do for_ testData $ \(Tuple (Tuple addrBech32 addr) addrType) -> toFromPlutusTypeTest TestnetId addrType addrBech32 addr group "Aeson tests" $ do - group "Roundtrip tests" $ do - for_ addresses toFromAesonTest + group "Roundtrip tests" + $ for_ addresses + $ toFromAesonTest "Address" toFromPlutusTypeTest :: NetworkId -> Int -> Bech32String -> Plutus.Address -> TestPlanM Unit diff --git a/test/Plutus/Credential.purs b/test/Plutus/Credential.purs index 7863f451b..366ab6279 100644 --- a/test/Plutus/Credential.purs +++ b/test/Plutus/Credential.purs @@ -20,10 +20,9 @@ suite :: TestPlanM Unit suite = do group "Plutus.Types.Credential" $ do group "Aeson tests" $ do - group "Roundtrip tests" $ do - for_ creds toFromAesonTest + group "Roundtrip tests" $ for_ creds $ toFromAesonTest "Credential" -creds ∷ Array Credential +creds :: Array Credential creds = [ pubKeyCredential , scriptCredential