diff --git a/nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger-api.nix b/nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger-api.nix index 9f95e38fbf1..8213471379b 100644 --- a/nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger-api.nix +++ b/nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger-api.nix @@ -39,8 +39,6 @@ (hsPkgs."cborg" or (errorHandler.buildDepError "cborg")) (hsPkgs."containers" or (errorHandler.buildDepError "containers")) (hsPkgs."cryptonite" or (errorHandler.buildDepError "cryptonite")) - (hsPkgs."cardano-crypto" or (errorHandler.buildDepError "cardano-crypto")) - (hsPkgs."cardano-crypto-class" or (errorHandler.buildDepError "cardano-crypto-class")) (hsPkgs."flat" or (errorHandler.buildDepError "flat")) (hsPkgs."hashable" or (errorHandler.buildDepError "hashable")) (hsPkgs."plutus-core" or (errorHandler.buildDepError "plutus-core")) diff --git a/nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger.nix b/nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger.nix index 6616db1b580..a2a51b484f8 100644 --- a/nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger.nix +++ b/nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger.nix @@ -69,6 +69,7 @@ (hsPkgs."cardano-api" or (errorHandler.buildDepError "cardano-api")) (hsPkgs."cardano-binary" or (errorHandler.buildDepError "cardano-binary")) (hsPkgs."cardano-crypto" or (errorHandler.buildDepError "cardano-crypto")) + (hsPkgs."cardano-crypto-class" or (errorHandler.buildDepError "cardano-crypto-class")) (hsPkgs."deepseq" or (errorHandler.buildDepError "deepseq")) (hsPkgs."freer-simple" or (errorHandler.buildDepError "freer-simple")) (hsPkgs."semigroups" or (errorHandler.buildDepError "semigroups")) @@ -77,12 +78,15 @@ modules = [ "Data/Time/Units/Extra" "Ledger" + "Ledger/Address" "Ledger/AddressMap" "Ledger/Blockchain" "Ledger/Constraints" "Ledger/Constraints/OffChain" "Ledger/Constraints/OnChain" "Ledger/Constraints/TxConstraints" + "Ledger/Contexts" + "Ledger/Crypto" "Ledger/Fee" "Ledger/Generators" "Ledger/Oracle" @@ -91,6 +95,7 @@ "Ledger/Scripts" "Ledger/TimeSlot" "Ledger/Tokens" + "Ledger/Tx" "Ledger/Typed/Scripts" "Ledger/Typed/Scripts/Validators" "Ledger/Typed/Scripts/MonetaryPolicies" diff --git a/nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger-api.nix b/nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger-api.nix index 9f95e38fbf1..8213471379b 100644 --- a/nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger-api.nix +++ b/nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger-api.nix @@ -39,8 +39,6 @@ (hsPkgs."cborg" or (errorHandler.buildDepError "cborg")) (hsPkgs."containers" or (errorHandler.buildDepError "containers")) (hsPkgs."cryptonite" or (errorHandler.buildDepError "cryptonite")) - (hsPkgs."cardano-crypto" or (errorHandler.buildDepError "cardano-crypto")) - (hsPkgs."cardano-crypto-class" or (errorHandler.buildDepError "cardano-crypto-class")) (hsPkgs."flat" or (errorHandler.buildDepError "flat")) (hsPkgs."hashable" or (errorHandler.buildDepError "hashable")) (hsPkgs."plutus-core" or (errorHandler.buildDepError "plutus-core")) diff --git a/nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger.nix b/nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger.nix index 6616db1b580..a2a51b484f8 100644 --- a/nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger.nix +++ b/nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger.nix @@ -69,6 +69,7 @@ (hsPkgs."cardano-api" or (errorHandler.buildDepError "cardano-api")) (hsPkgs."cardano-binary" or (errorHandler.buildDepError "cardano-binary")) (hsPkgs."cardano-crypto" or (errorHandler.buildDepError "cardano-crypto")) + (hsPkgs."cardano-crypto-class" or (errorHandler.buildDepError "cardano-crypto-class")) (hsPkgs."deepseq" or (errorHandler.buildDepError "deepseq")) (hsPkgs."freer-simple" or (errorHandler.buildDepError "freer-simple")) (hsPkgs."semigroups" or (errorHandler.buildDepError "semigroups")) @@ -77,12 +78,15 @@ modules = [ "Data/Time/Units/Extra" "Ledger" + "Ledger/Address" "Ledger/AddressMap" "Ledger/Blockchain" "Ledger/Constraints" "Ledger/Constraints/OffChain" "Ledger/Constraints/OnChain" "Ledger/Constraints/TxConstraints" + "Ledger/Contexts" + "Ledger/Crypto" "Ledger/Fee" "Ledger/Generators" "Ledger/Oracle" @@ -91,6 +95,7 @@ "Ledger/Scripts" "Ledger/TimeSlot" "Ledger/Tokens" + "Ledger/Tx" "Ledger/Typed/Scripts" "Ledger/Typed/Scripts/Validators" "Ledger/Typed/Scripts/MonetaryPolicies" diff --git a/plutus-ledger-api/plutus-ledger-api.cabal b/plutus-ledger-api/plutus-ledger-api.cabal index a4c30b949a4..919b6a86d99 100644 --- a/plutus-ledger-api/plutus-ledger-api.cabal +++ b/plutus-ledger-api/plutus-ledger-api.cabal @@ -61,8 +61,6 @@ library cborg -any, containers -any, cryptonite >=0.25, - cardano-crypto -any, - cardano-crypto-class -any, flat -any, hashable -any, plutus-core -any, diff --git a/plutus-ledger-api/src/Plutus/V1/Ledger/Address.hs b/plutus-ledger-api/src/Plutus/V1/Ledger/Address.hs index 0897c787b7b..5aeab6a383e 100644 --- a/plutus-ledger-api/src/Plutus/V1/Ledger/Address.hs +++ b/plutus-ledger-api/src/Plutus/V1/Ledger/Address.hs @@ -10,9 +10,7 @@ module Plutus.V1.Ledger.Address ( Address (..), - pubKeyAddress, pubKeyHashAddress, - scriptAddress, scriptHashAddress, toPubKeyHash, toValidatorHash, @@ -25,7 +23,7 @@ import Data.Aeson (FromJSON, FromJSONKey (..), ToJSON import Data.Hashable (Hashable) import Data.Text.Prettyprint.Doc import GHC.Generics (Generic) -import qualified PlutusTx as PlutusTx +import qualified PlutusTx import qualified PlutusTx.Bool as PlutusTx import qualified PlutusTx.Eq as PlutusTx @@ -35,7 +33,7 @@ import Plutus.V1.Ledger.Orphans () import Plutus.V1.Ledger.Scripts -- | Address with two kinds of credentials, normal and staking -data Address = Address{ addressCredential :: Credential, addressStakingCredential :: (Maybe StakingCredential)} +data Address = Address{ addressCredential :: Credential, addressStakingCredential :: Maybe StakingCredential } deriving stock (Eq, Ord, Show, Generic) deriving anyclass (ToJSON, FromJSON, ToJSONKey, FromJSONKey, Serialise, Hashable, NFData) @@ -44,17 +42,11 @@ instance Pretty Address where let staking = maybe "no staking credential" pretty stakingCred in "addressed to" <+> pretty cred <+> parens staking - instance PlutusTx.Eq Address where Address cred stakingCred == Address cred' stakingCred' = cred PlutusTx.== cred' PlutusTx.&& stakingCred PlutusTx.== stakingCred' -{-# INLINABLE pubKeyAddress #-} --- | The address that should be targeted by a transaction output locked by the given public key. -pubKeyAddress :: PubKey -> Address -pubKeyAddress pk = Address (PubKeyCredential (pubKeyHash pk)) Nothing - {-# INLINABLE pubKeyHashAddress #-} -- | The address that should be targeted by a transaction output locked by the public key with the given hash. pubKeyHashAddress :: PubKeyHash -> Address @@ -72,10 +64,6 @@ toValidatorHash :: Address -> Maybe ValidatorHash toValidatorHash (Address (ScriptCredential k) _) = Just k toValidatorHash _ = Nothing --- | The address that should be used by a transaction output locked by the given validator script. -scriptAddress :: Validator -> Address -scriptAddress validator = Address (ScriptCredential (validatorHash validator)) Nothing - {-# INLINABLE scriptHashAddress #-} -- | The address that should be used by a transaction output locked by the given validator script hash. scriptHashAddress :: ValidatorHash -> Address diff --git a/plutus-ledger-api/src/Plutus/V1/Ledger/Api.hs b/plutus-ledger-api/src/Plutus/V1/Ledger/Api.hs index a406ce1115a..2e184953a25 100644 --- a/plutus-ledger-api/src/Plutus/V1/Ledger/Api.hs +++ b/plutus-ledger-api/src/Plutus/V1/Ledger/Api.hs @@ -79,18 +79,14 @@ module Plutus.V1.Ledger.Api ( , mkValidatorScript , unValidatorScript , ValidatorHash (..) - , validatorHash , MintingPolicy (..) , mkMintingPolicyScript , unMintingPolicyScript , MintingPolicyHash (..) - , mintingPolicyHash , Redeemer (..) , RedeemerHash (..) - , redeemerHash , Datum (..) , DatumHash (..) - , datumHash -- * Data , PLC.Data (..) , BuiltinData (..) diff --git a/plutus-ledger-api/src/Plutus/V1/Ledger/Contexts.hs b/plutus-ledger-api/src/Plutus/V1/Ledger/Contexts.hs index 7f61b00515a..cb172ce69c8 100644 --- a/plutus-ledger-api/src/Plutus/V1/Ledger/Contexts.hs +++ b/plutus-ledger-api/src/Plutus/V1/Ledger/Contexts.hs @@ -32,8 +32,6 @@ module Plutus.V1.Ledger.Contexts , findContinuingOutputs , getContinuingOutputs -- ** Hashes (see note [Hashes in validator scripts]) - , scriptCurrencySymbol - , pubKeyHash -- * Validator functions -- ** Signatures , txSignedBy @@ -64,14 +62,13 @@ import qualified Plutus.V1.Ledger.Ada as Ada import Plutus.V1.Ledger.Address (Address (..), toPubKeyHash) import Plutus.V1.Ledger.Bytes (LedgerBytes (..)) import Plutus.V1.Ledger.Credential (Credential (..), StakingCredential) -import Plutus.V1.Ledger.Crypto (PubKey (..), PubKeyHash (..), Signature (..), pubKeyHash) +import Plutus.V1.Ledger.Crypto (PubKey (..), PubKeyHash (..), Signature (..)) import Plutus.V1.Ledger.DCert (DCert (..)) import Plutus.V1.Ledger.Scripts import Plutus.V1.Ledger.Time (POSIXTimeRange) import Plutus.V1.Ledger.Tx (TxOut (..), TxOutRef (..)) import Plutus.V1.Ledger.TxId import Plutus.V1.Ledger.Value (CurrencySymbol (..), Value) -import qualified Plutus.V1.Ledger.Value as Value {- Note [Script types in pending transactions] To validate a transaction, we have to evaluate the validation script of each of @@ -181,11 +178,6 @@ them from the correct types in Haskell, and for comparing them (in -} -{-# INLINABLE scriptCurrencySymbol #-} --- | The 'CurrencySymbol' of a 'MintingPolicy' -scriptCurrencySymbol :: MintingPolicy -> CurrencySymbol -scriptCurrencySymbol scrpt = let (MintingPolicyHash hsh) = mintingPolicyHash scrpt in Value.currencySymbol hsh - {-# INLINABLE txSignedBy #-} -- | Check if a transaction was signed by the given public key. txSignedBy :: TxInfo -> PubKeyHash -> Bool diff --git a/plutus-ledger-api/src/Plutus/V1/Ledger/Crypto.hs b/plutus-ledger-api/src/Plutus/V1/Ledger/Crypto.hs index 1a5b1be6218..f5d8efd0c36 100644 --- a/plutus-ledger-api/src/Plutus/V1/Ledger/Crypto.hs +++ b/plutus-ledger-api/src/Plutus/V1/Ledger/Crypto.hs @@ -5,56 +5,32 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-} + {-# OPTIONS_GHC -fno-omit-interface-pragmas #-} module Plutus.V1.Ledger.Crypto( PubKey(..) , PubKeyHash(..) - , pubKeyHash , PrivateKey(..) , Signature(..) - , signedBy - , sign - , signTx - , fromHex - , toPublicKey - -- $privateKeys - , knownPrivateKeys - , privateKey1 - , privateKey2 - , privateKey3 - , privateKey4 - , privateKey5 - , privateKey6 - , privateKey7 - , privateKey8 - , privateKey9 - , privateKey10 ) where -import Cardano.Crypto.Hash as Crypto import Codec.Serialise.Class (Serialise) import Control.DeepSeq (NFData) import Control.Newtype.Generics (Newtype) -import qualified Crypto.ECC.Ed25519Donna as ED25519 -import Crypto.Error (throwCryptoError) import Data.Aeson (FromJSON (parseJSON), FromJSONKey, FromJSONKeyFunction (FromJSONKeyValue), ToJSON (toJSON), ToJSONKey, ToJSONKeyFunction (ToJSONKeyValue), genericParseJSON, genericToJSON, (.:)) import qualified Data.Aeson as JSON import qualified Data.Aeson.Extras as JSON -import qualified Data.ByteArray as BA import qualified Data.ByteString as BS -import Data.Either.Extras (unsafeFromEither) import Data.Hashable (Hashable) import Data.String import Data.Text.Prettyprint.Doc import GHC.Generics (Generic) import Plutus.V1.Ledger.Bytes (LedgerBytes (..)) -import qualified Plutus.V1.Ledger.Bytes as KB import Plutus.V1.Ledger.Orphans () -import Plutus.V1.Ledger.TxId -import qualified PlutusTx as PlutusTx +import qualified PlutusTx import qualified PlutusTx.Builtins as Builtins import PlutusTx.Lift (makeLift) import qualified PlutusTx.Prelude as P @@ -83,13 +59,6 @@ newtype PubKeyHash = PubKeyHash { getPubKeyHash :: BS.ByteString } deriving (Show, Pretty) via LedgerBytes makeLift ''PubKeyHash --- | Compute the hash of a public key. -pubKeyHash :: PubKey -> PubKeyHash -pubKeyHash (PubKey (LedgerBytes bs)) = - PubKeyHash - $ Crypto.hashToBytes - $ Crypto.hashWith @Crypto.Blake2b_224 id bs - -- | A cryptographic private key. newtype PrivateKey = PrivateKey { getPrivateKey :: LedgerBytes } deriving stock (Eq, Ord, Generic) @@ -123,55 +92,3 @@ instance FromJSON Signature where pure . Signature $ bytes makeLift ''Signature - --- | Check whether the given 'Signature' was signed by the private key corresponding to the given public key. -signedBy :: Signature -> PubKey -> TxId -> Bool -signedBy (Signature s) (PubKey k) txId = - let k' = ED25519.publicKey $ KB.getLedgerBytes k - s' = ED25519.signature s - in throwCryptoError $ ED25519.verify <$> k' <*> pure (getTxId txId) <*> s' -- TODO: is this what we want - --- | Sign the hash of a transaction using a private key. -signTx :: TxId -> PrivateKey -> Signature -signTx (TxId txId) = sign txId - --- | Sign a message using a private key. -sign :: BA.ByteArrayAccess a => a -> PrivateKey -> Signature -sign msg (PrivateKey privKey) = - let k = ED25519.secretKey $ KB.getLedgerBytes privKey - pk = ED25519.toPublic <$> k - salt :: BS.ByteString - salt = "" -- TODO: do we need better salt? - convert = Signature . BS.pack . BA.unpack - in throwCryptoError $ fmap convert (ED25519.sign <$> k <*> pure salt <*> pk <*> pure msg) - -fromHex :: BS.ByteString -> Either String PrivateKey -fromHex = fmap PrivateKey . KB.fromHex - -toPublicKey :: PrivateKey -> PubKey -toPublicKey = PubKey . KB.fromBytes . BS.pack . BA.unpack . ED25519.toPublic . f . KB.bytes . getPrivateKey where - f = throwCryptoError . ED25519.secretKey - --- $privateKeys --- 'privateKey1', 'privateKey2', ... 'privateKey10' are ten predefined 'PrivateKey' values. --- --- The private keys can be found in the 'sign.input' file linked from --- http://ed25519.cr.yp.to/software.html. - -privateKey1, privateKey2, privateKey3, privateKey4, privateKey5, privateKey6, privateKey7, privateKey8, privateKey9, privateKey10 :: PrivateKey -privateKey1 = unsafeFromEither $ fromHex "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60" -privateKey2 = unsafeFromEither $ fromHex "4ccd089b28ff96da9db6c346ec114e0f5b8a319f35aba624da8cf6ed4fb8a6fb" -privateKey3 = unsafeFromEither $ fromHex "c5aa8df43f9f837bedb7442f31dcb7b166d38535076f094b85ce3a2e0b4458f7" -privateKey4 = unsafeFromEither $ fromHex "691865bfc82a1e4b574eecde4c7519093faf0cf867380234e3664645c61c5f79" -privateKey5 = unsafeFromEither $ fromHex "3b26516fb3dc88eb181b9ed73f0bcd52bcd6b4c788e4bcaf46057fd078bee073" -privateKey6 = unsafeFromEither $ fromHex "edc6f5fbdd1cee4d101c063530a30490b221be68c036f5b07d0f953b745df192" -privateKey7 = unsafeFromEither $ fromHex "a980f892db13c99a3e8971e965b2ff3d41eafd54093bc9f34d1fd22d84115bb6" -privateKey8 = unsafeFromEither $ fromHex "9acad959d216212d789a119252ebfe0c96512a23c73bd9f3b202292d6916a738" -privateKey9 = unsafeFromEither $ fromHex "d5aeee41eeb0e9d1bf8337f939587ebe296161e6bf5209f591ec939e1440c300" -privateKey10 = unsafeFromEither $ fromHex "0a47d10452ae2febec518a1c7c362890c3fc1a49d34b03b6467d35c904a8362d" - --- | A list of 10 private keys. --- TODO: Generate random private keys (I couldn't find a way to --- do this in 'Crypto.ECC.Ed25519Donna' in 'cardano-crypto') -knownPrivateKeys :: [PrivateKey] -knownPrivateKeys = [privateKey1, privateKey2, privateKey3, privateKey4, privateKey5, privateKey6, privateKey7, privateKey8, privateKey9, privateKey10] diff --git a/plutus-ledger-api/src/Plutus/V1/Ledger/Scripts.hs b/plutus-ledger-api/src/Plutus/V1/Ledger/Scripts.hs index 5d84f676854..b46c58976c8 100644 --- a/plutus-ledger-api/src/Plutus/V1/Ledger/Scripts.hs +++ b/plutus-ledger-api/src/Plutus/V1/Ledger/Scripts.hs @@ -14,6 +14,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ViewPatterns #-} + {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-specialise #-} @@ -46,10 +47,6 @@ module Plutus.V1.Ledger.Scripts( RedeemerHash(..), ValidatorHash(..), MintingPolicyHash (..), - datumHash, - redeemerHash, - validatorHash, - mintingPolicyHash, -- * Example scripts unitRedeemer, unitDatum, @@ -57,7 +54,6 @@ module Plutus.V1.Ledger.Scripts( import qualified Prelude as Haskell -import qualified Cardano.Crypto.Hash as Crypto import Codec.CBOR.Decoding (decodeBytes) import Codec.Serialise (Serialise, decode, encode, serialise) import Control.DeepSeq (NFData) @@ -314,32 +310,6 @@ newtype MintingPolicyHash = deriving newtype (Haskell.Eq, Haskell.Ord, Eq, Ord, Hashable, IsData) deriving anyclass (FromJSON, ToJSON, ToJSONKey, FromJSONKey) -datumHash :: Datum -> DatumHash -datumHash = DatumHash . Builtins.sha2_256 . BA.convert - -redeemerHash :: Redeemer -> RedeemerHash -redeemerHash = RedeemerHash . Builtins.sha2_256 . BA.convert - -validatorHash :: Validator -> ValidatorHash -validatorHash vl = - ValidatorHash - $ Crypto.hashToBytes - $ Crypto.hashWith @Crypto.Blake2b_224 id - $ Crypto.hashToBytes - $ Crypto.hashWith @Crypto.Blake2b_224 id - $ BSL.toStrict - $ serialise vl - -mintingPolicyHash :: MintingPolicy -> MintingPolicyHash -mintingPolicyHash vl = - MintingPolicyHash - $ Crypto.hashToBytes - $ Crypto.hashWith @Crypto.Blake2b_224 id - $ Crypto.hashToBytes - $ Crypto.hashWith @Crypto.Blake2b_224 id - $ BSL.toStrict - $ serialise vl - -- | Information about the state of the blockchain and about the transaction -- that is currently being validated, represented as a value in 'Data'. newtype Context = Context BuiltinData diff --git a/plutus-ledger-api/src/Plutus/V1/Ledger/Tx.hs b/plutus-ledger-api/src/Plutus/V1/Ledger/Tx.hs index 18fc822d32e..341c5333bf0 100644 --- a/plutus-ledger-api/src/Plutus/V1/Ledger/Tx.hs +++ b/plutus-ledger-api/src/Plutus/V1/Ledger/Tx.hs @@ -32,7 +32,6 @@ module Plutus.V1.Ledger.Tx( lookupSignature, lookupDatum, lookupRedeemer, - addSignature, mint, fee, ScriptTag (..), @@ -53,10 +52,7 @@ module Plutus.V1.Ledger.Tx( outValue, txOutPubKey, txOutDatum, - pubKeyTxOut, pubKeyHashTxOut, - scriptTxOut, - scriptTxOut', txOutTxDatum, -- * Transaction inputs TxInType(..), @@ -87,7 +83,7 @@ import qualified Data.Set as Set import Data.Text.Prettyprint.Doc import GHC.Generics (Generic) -import qualified PlutusTx as PlutusTx +import qualified PlutusTx import qualified PlutusTx.Bool as PlutusTx import qualified PlutusTx.Eq as PlutusTx import PlutusTx.Lattice @@ -435,19 +431,6 @@ data TxOutTx = TxOutTx { txOutTxTx :: Tx, txOutTxOut :: TxOut } txOutTxDatum :: TxOutTx -> Maybe Datum txOutTxDatum (TxOutTx tx out) = txOutDatum out >>= lookupDatum tx --- | Create a transaction output locked by a validator script hash --- with the given data script attached. -scriptTxOut' :: Value -> Address -> Datum -> TxOut -scriptTxOut' v a ds = TxOut a v (Just (datumHash ds)) - --- | Create a transaction output locked by a validator script and with the given data script attached. -scriptTxOut :: Value -> Validator -> Datum -> TxOut -scriptTxOut v vs = scriptTxOut' v (scriptAddress vs) - --- | Create a transaction output locked by a public key. -pubKeyTxOut :: Value -> PubKey -> TxOut -pubKeyTxOut v pk = TxOut (pubKeyAddress pk) v Nothing - -- | Create a transaction output locked by a public key. pubKeyHashTxOut :: Value -> PubKeyHash -> TxOut pubKeyHashTxOut v pkh = TxOut (pubKeyHashAddress pkh) v Nothing @@ -471,13 +454,6 @@ updateUtxo tx unspent = (unspent `Map.withoutKeys` spentOutputs tx) `Map.union` updateUtxoCollateral :: Tx -> Map TxOutRef TxOut -> Map TxOutRef TxOut updateUtxoCollateral tx unspent = unspent `Map.withoutKeys` (Set.map txInRef . txCollateral $ tx) --- | Sign the transaction with a 'PrivateKey' and add the signature to the --- transaction's list of signatures. -addSignature :: PrivateKey -> Tx -> Tx -addSignature privK tx = tx & signatures . at pubK ?~ sig where - sig = signTx (txId tx) privK - pubK = toPublicKey privK - PlutusTx.makeIsDataIndexed ''TxOut [('TxOut,0)] PlutusTx.makeLift ''TxOut diff --git a/plutus-ledger/plutus-ledger.cabal b/plutus-ledger/plutus-ledger.cabal index 7860665eb94..4da1cbf3049 100644 --- a/plutus-ledger/plutus-ledger.cabal +++ b/plutus-ledger/plutus-ledger.cabal @@ -43,12 +43,15 @@ library exposed-modules: Data.Time.Units.Extra Ledger + Ledger.Address Ledger.AddressMap Ledger.Blockchain Ledger.Constraints Ledger.Constraints.OffChain Ledger.Constraints.OnChain Ledger.Constraints.TxConstraints + Ledger.Contexts + Ledger.Crypto Ledger.Fee Ledger.Generators Ledger.Oracle @@ -57,6 +60,7 @@ library Ledger.Scripts Ledger.TimeSlot Ledger.Tokens + Ledger.Tx Ledger.Typed.Scripts Ledger.Typed.Scripts.Validators Ledger.Typed.Scripts.MonetaryPolicies @@ -66,22 +70,23 @@ library Data.Aeson.Extras, Data.Either.Extras, Data.Text.Prettyprint.Doc.Extras, - Plutus.V1.Ledger.Address as Ledger.Address, Plutus.V1.Ledger.Ada as Ledger.Ada, Plutus.V1.Ledger.Bytes as Ledger.Bytes, - Plutus.V1.Ledger.Contexts as Ledger.Contexts, Plutus.V1.Ledger.Credential as Ledger.Credential, Plutus.V1.Ledger.DCert as Ledger.DCert, - Plutus.V1.Ledger.Crypto as Ledger.Crypto, Plutus.V1.Ledger.Interval as Ledger.Interval, - -- We manually re-export that module so we can include some extra - -- instances - -- Plutus.V1.Ledger.Scripts as Ledger.Scripts, Plutus.V1.Ledger.Slot as Ledger.Slot, - Plutus.V1.Ledger.Tx as Ledger.Tx, Plutus.V1.Ledger.TxId as Ledger.TxId, Plutus.V1.Ledger.Time as Ledger.Time, Plutus.V1.Ledger.Value as Ledger.Value + -- We manually re-export these modules so we can include some functions + -- that don't need to used outside of plutus: + -- Plutus.V1.Ledger.Address as Ledger.Address, + -- Plutus.V1.Ledger.Contexts as Ledger.Contexts, + -- Plutus.V1.Ledger.Crypto as Ledger.Crypto, + -- Plutus.V1.Ledger.Scripts as Ledger.Scripts, + -- Plutus.V1.Ledger.Tx as Ledger.Tx, + build-depends: base >=4.9 && <5, aeson -any, @@ -119,6 +124,7 @@ library cardano-api -any, cardano-binary -any, cardano-crypto -any, + cardano-crypto-class -any, deepseq -any, freer-simple -any, semigroups -any diff --git a/plutus-ledger/src/Ledger.hs b/plutus-ledger/src/Ledger.hs index d248e7b31b3..9b44672b8fc 100644 --- a/plutus-ledger/src/Ledger.hs +++ b/plutus-ledger/src/Ledger.hs @@ -12,15 +12,15 @@ import Ledger.Index as Export import Ledger.Orphans () -- We manually re-export 'Plutus.V1.Ledger.Scripts' so we can include some -- extra instances +import Ledger.Address as Export +import Ledger.Contexts as Export +import Ledger.Crypto as Export import Ledger.Scripts as Export +import Ledger.Tx as Export import Plutus.V1.Ledger.Ada (Ada) -import Plutus.V1.Ledger.Address as Export -import Plutus.V1.Ledger.Contexts as Export -import Plutus.V1.Ledger.Crypto as Export import Plutus.V1.Ledger.Interval as Export import Plutus.V1.Ledger.Orphans () import Plutus.V1.Ledger.Slot as Export import Plutus.V1.Ledger.Time as Export -import Plutus.V1.Ledger.Tx as Export import Plutus.V1.Ledger.TxId as Export import Plutus.V1.Ledger.Value (AssetClass, CurrencySymbol, TokenName, Value) diff --git a/plutus-ledger/src/Ledger/Address.hs b/plutus-ledger/src/Ledger/Address.hs new file mode 100644 index 00000000000..03e31308e71 --- /dev/null +++ b/plutus-ledger/src/Ledger/Address.hs @@ -0,0 +1,20 @@ +module Ledger.Address + ( module Export + , pubKeyAddress + , scriptAddress + ) where + +import Ledger.Crypto (pubKeyHash) +import Ledger.Scripts (Validator, validatorHash) +import Plutus.V1.Ledger.Address as Export +import Plutus.V1.Ledger.Credential (Credential (..)) +import Plutus.V1.Ledger.Crypto (PubKey) + +{-# INLINABLE pubKeyAddress #-} +-- | The address that should be targeted by a transaction output locked by the given public key. +pubKeyAddress :: PubKey -> Address +pubKeyAddress pk = Address (PubKeyCredential (pubKeyHash pk)) Nothing + +-- | The address that should be used by a transaction output locked by the given validator script. +scriptAddress :: Validator -> Address +scriptAddress validator = Address (ScriptCredential (validatorHash validator)) Nothing diff --git a/plutus-ledger/src/Ledger/Constraints/OffChain.hs b/plutus-ledger/src/Ledger/Constraints/OffChain.hs index ff1628e5252..2ae9d7b9558 100644 --- a/plutus-ledger/src/Ledger/Constraints/OffChain.hs +++ b/plutus-ledger/src/Ledger/Constraints/OffChain.hs @@ -61,21 +61,21 @@ import PlutusTx.Lattice import qualified PlutusTx.Numeric as N import Data.Default (Default (def)) +import Ledger.Address (Address (..), pubKeyHashAddress) +import qualified Ledger.Address as Address import Ledger.Constraints.TxConstraints hiding (requiredSignatories) import Ledger.Orphans () +import Ledger.Scripts (Datum (..), DatumHash, MintingPolicy, MintingPolicyHash, + Redeemer (..), Validator, datumHash, mintingPolicyHash) import qualified Ledger.TimeSlot as TimeSlot +import Ledger.Tx (RedeemerPtr (..), ScriptTag (..), Tx, TxOut (..), TxOutRef, + TxOutTx (..)) +import qualified Ledger.Tx as Tx import Ledger.Typed.Scripts (TypedValidator, ValidatorTypes (..)) import qualified Ledger.Typed.Scripts as Scripts import Ledger.Typed.Tx (ConnectionError) import qualified Ledger.Typed.Tx as Typed -import Plutus.V1.Ledger.Address (Address (..), pubKeyHashAddress) -import qualified Plutus.V1.Ledger.Address as Address import Plutus.V1.Ledger.Crypto (PubKeyHash) -import Plutus.V1.Ledger.Scripts (Datum (..), DatumHash, MintingPolicy, MintingPolicyHash, - Redeemer (..), Validator, datumHash, mintingPolicyHash) -import Plutus.V1.Ledger.Tx (RedeemerPtr (..), ScriptTag (..), Tx, TxOut (..), TxOutRef, - TxOutTx (..)) -import qualified Plutus.V1.Ledger.Tx as Tx import Plutus.V1.Ledger.Value (Value) import qualified Plutus.V1.Ledger.Value as Value diff --git a/plutus-ledger/src/Ledger/Contexts.hs b/plutus-ledger/src/Ledger/Contexts.hs new file mode 100644 index 00000000000..742737d4422 --- /dev/null +++ b/plutus-ledger/src/Ledger/Contexts.hs @@ -0,0 +1,17 @@ +module Ledger.Contexts + ( module Export + , pubKeyHash + , scriptCurrencySymbol + ) where + +import Ledger.Crypto (pubKeyHash) +import Ledger.Scripts (MintingPolicy, MintingPolicyHash (..), mintingPolicyHash) +import Plutus.V1.Ledger.Contexts as Export +import Plutus.V1.Ledger.Value (CurrencySymbol (..)) +import qualified Plutus.V1.Ledger.Value as Value + +{-# INLINABLE scriptCurrencySymbol #-} +-- | The 'CurrencySymbol' of a 'MintingPolicy' +scriptCurrencySymbol :: MintingPolicy -> CurrencySymbol +scriptCurrencySymbol scrpt = let (MintingPolicyHash hsh) = mintingPolicyHash scrpt in Value.currencySymbol hsh + diff --git a/plutus-ledger/src/Ledger/Crypto.hs b/plutus-ledger/src/Ledger/Crypto.hs new file mode 100644 index 00000000000..115b4567ba2 --- /dev/null +++ b/plutus-ledger/src/Ledger/Crypto.hs @@ -0,0 +1,95 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TypeApplications #-} + +module Ledger.Crypto + ( module Export + , pubKeyHash + , signedBy + , sign + , signTx + , fromHex + , toPublicKey + -- $privateKeys + , knownPrivateKeys + , privateKey1 + , privateKey2 + , privateKey3 + , privateKey4 + , privateKey5 + , privateKey6 + , privateKey7 + , privateKey8 + , privateKey9 + , privateKey10 + ) where + +import Cardano.Crypto.Hash as Crypto +import qualified Crypto.ECC.Ed25519Donna as ED25519 +import Crypto.Error (throwCryptoError) +import qualified Data.ByteArray as BA +import qualified Data.ByteString as BS +import Data.Either.Extras (unsafeFromEither) +import Plutus.V1.Ledger.Bytes (LedgerBytes (..)) +import qualified Plutus.V1.Ledger.Bytes as KB +import Plutus.V1.Ledger.Crypto as Export +import Plutus.V1.Ledger.TxId + +-- | Compute the hash of a public key. +pubKeyHash :: PubKey -> PubKeyHash +pubKeyHash (PubKey (LedgerBytes bs)) = + PubKeyHash + $ Crypto.hashToBytes + $ Crypto.hashWith @Crypto.Blake2b_224 id bs + +-- | Check whether the given 'Signature' was signed by the private key corresponding to the given public key. +signedBy :: Signature -> PubKey -> TxId -> Bool +signedBy (Signature s) (PubKey k) txId = + let k' = ED25519.publicKey $ KB.getLedgerBytes k + s' = ED25519.signature s + in throwCryptoError $ ED25519.verify <$> k' <*> pure (getTxId txId) <*> s' -- TODO: is this what we want + +-- | Sign the hash of a transaction using a private key. +signTx :: TxId -> PrivateKey -> Signature +signTx (TxId txId) = sign txId + +-- | Sign a message using a private key. +sign :: BA.ByteArrayAccess a => a -> PrivateKey -> Signature +sign msg (PrivateKey privKey) = + let k = ED25519.secretKey $ KB.getLedgerBytes privKey + pk = ED25519.toPublic <$> k + salt :: BS.ByteString + salt = "" -- TODO: do we need better salt? + convert = Signature . BS.pack . BA.unpack + in throwCryptoError $ fmap convert (ED25519.sign <$> k <*> pure salt <*> pk <*> pure msg) + +fromHex :: BS.ByteString -> Either String PrivateKey +fromHex = fmap PrivateKey . KB.fromHex + +toPublicKey :: PrivateKey -> PubKey +toPublicKey = PubKey . KB.fromBytes . BS.pack . BA.unpack . ED25519.toPublic . f . KB.bytes . getPrivateKey where + f = throwCryptoError . ED25519.secretKey + +-- $privateKeys +-- 'privateKey1', 'privateKey2', ... 'privateKey10' are ten predefined 'PrivateKey' values. +-- +-- The private keys can be found in the 'sign.input' file linked from +-- http://ed25519.cr.yp.to/software.html. + +privateKey1, privateKey2, privateKey3, privateKey4, privateKey5, privateKey6, privateKey7, privateKey8, privateKey9, privateKey10 :: PrivateKey +privateKey1 = unsafeFromEither $ fromHex "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60" +privateKey2 = unsafeFromEither $ fromHex "4ccd089b28ff96da9db6c346ec114e0f5b8a319f35aba624da8cf6ed4fb8a6fb" +privateKey3 = unsafeFromEither $ fromHex "c5aa8df43f9f837bedb7442f31dcb7b166d38535076f094b85ce3a2e0b4458f7" +privateKey4 = unsafeFromEither $ fromHex "691865bfc82a1e4b574eecde4c7519093faf0cf867380234e3664645c61c5f79" +privateKey5 = unsafeFromEither $ fromHex "3b26516fb3dc88eb181b9ed73f0bcd52bcd6b4c788e4bcaf46057fd078bee073" +privateKey6 = unsafeFromEither $ fromHex "edc6f5fbdd1cee4d101c063530a30490b221be68c036f5b07d0f953b745df192" +privateKey7 = unsafeFromEither $ fromHex "a980f892db13c99a3e8971e965b2ff3d41eafd54093bc9f34d1fd22d84115bb6" +privateKey8 = unsafeFromEither $ fromHex "9acad959d216212d789a119252ebfe0c96512a23c73bd9f3b202292d6916a738" +privateKey9 = unsafeFromEither $ fromHex "d5aeee41eeb0e9d1bf8337f939587ebe296161e6bf5209f591ec939e1440c300" +privateKey10 = unsafeFromEither $ fromHex "0a47d10452ae2febec518a1c7c362890c3fc1a49d34b03b6467d35c904a8362d" + +-- | A list of 10 private keys. +-- TODO: Generate random private keys (I couldn't find a way to +-- do this in 'Crypto.ECC.Ed25519Donna' in 'cardano-crypto') +knownPrivateKeys :: [PrivateKey] +knownPrivateKeys = [privateKey1, privateKey2, privateKey3, privateKey4, privateKey5, privateKey6, privateKey7, privateKey8, privateKey9, privateKey10] + diff --git a/plutus-ledger/src/Ledger/Index.hs b/plutus-ledger/src/Ledger/Index.hs index 8ebce3a84bb..16f55ddcec6 100644 --- a/plutus-ledger/src/Ledger/Index.hs +++ b/plutus-ledger/src/Ledger/Index.hs @@ -59,6 +59,8 @@ import Data.Text.Prettyprint.Doc (Pretty) import Data.Text.Prettyprint.Doc.Extras (PrettyShow (..)) import GHC.Generics (Generic) import Ledger.Blockchain +import Ledger.Crypto +import Ledger.Scripts import qualified Ledger.TimeSlot as TimeSlot import qualified Plutus.V1.Ledger.Ada as Ada import Plutus.V1.Ledger.Address @@ -66,9 +68,7 @@ import qualified Plutus.V1.Ledger.Api as Api import Plutus.V1.Ledger.Contexts (ScriptContext (..), ScriptPurpose (..), TxInfo (..)) import qualified Plutus.V1.Ledger.Contexts as Validation import Plutus.V1.Ledger.Credential (Credential (..)) -import Plutus.V1.Ledger.Crypto import qualified Plutus.V1.Ledger.Interval as Interval -import Plutus.V1.Ledger.Scripts import qualified Plutus.V1.Ledger.Scripts as Scripts import qualified Plutus.V1.Ledger.Slot as Slot import Plutus.V1.Ledger.Tx diff --git a/plutus-ledger/src/Ledger/Oracle.hs b/plutus-ledger/src/Ledger/Oracle.hs index ff38c00aaff..128bc347de7 100644 --- a/plutus-ledger/src/Ledger/Oracle.hs +++ b/plutus-ledger/src/Ledger/Oracle.hs @@ -38,12 +38,12 @@ import PlutusTx.Prelude import Ledger.Constraints (TxConstraints) import qualified Ledger.Constraints as Constraints +import Ledger.Crypto (PrivateKey, PubKey (..), Signature (..)) +import qualified Ledger.Crypto as Crypto +import Ledger.Scripts (Datum (..), DatumHash (..)) +import qualified Ledger.Scripts as Scripts import Plutus.V1.Ledger.Bytes import Plutus.V1.Ledger.Contexts (ScriptContext) -import Plutus.V1.Ledger.Crypto (PrivateKey, PubKey (..), Signature (..)) -import qualified Plutus.V1.Ledger.Crypto as Crypto -import Plutus.V1.Ledger.Scripts (Datum (..), DatumHash (..)) -import qualified Plutus.V1.Ledger.Scripts as Scripts import Plutus.V1.Ledger.Time (POSIXTime) import qualified Prelude as Haskell diff --git a/plutus-ledger/src/Ledger/Scripts.hs b/plutus-ledger/src/Ledger/Scripts.hs index ec90079d53d..793d55522f7 100644 --- a/plutus-ledger/src/Ledger/Scripts.hs +++ b/plutus-ledger/src/Ledger/Scripts.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -11,17 +12,25 @@ the Cardano Node CLI expects serialised binary values to be wrapped with a 'Cardano.Api.TextEnvelope'. -} module Ledger.Scripts ( - module Export - ) where + module Export + , datumHash + , redeemerHash + , validatorHash + , mintingPolicyHash + ) where import Cardano.Api (AsType, HasTextEnvelope (textEnvelopeType), HasTypeProxy (proxyToAsType), SerialiseAsCBOR, TextEnvelopeType (TextEnvelopeType)) import Cardano.Binary (FromCBOR (fromCBOR), ToCBOR (toCBOR)) -import Codec.Serialise (decode, encode) +import qualified Cardano.Crypto.Hash as Crypto +import Codec.Serialise (decode, encode, serialise) +import qualified Data.ByteArray as BA +import qualified Data.ByteString.Lazy as BSL import qualified Data.Text as Text import Plutus.V1.Ledger.Api (plutusDatumEnvelopeType, plutusRedeemerEnvelopeType, plutusScriptEnvelopeType) import Plutus.V1.Ledger.Scripts as Export +import PlutusTx.Builtins as Builtins instance HasTextEnvelope Script where textEnvelopeType _ = TextEnvelopeType $ Text.unpack plutusScriptEnvelopeType @@ -67,3 +76,29 @@ instance ToCBOR Redeemer where instance HasTypeProxy Redeemer where data AsType Redeemer = AsRedeemer proxyToAsType _ = AsRedeemer + +datumHash :: Datum -> DatumHash +datumHash = DatumHash . Builtins.sha2_256 . BA.convert + +redeemerHash :: Redeemer -> RedeemerHash +redeemerHash = RedeemerHash . Builtins.sha2_256 . BA.convert + +validatorHash :: Validator -> ValidatorHash +validatorHash vl = + ValidatorHash + $ Crypto.hashToBytes + $ Crypto.hashWith @Crypto.Blake2b_224 id + $ Crypto.hashToBytes + $ Crypto.hashWith @Crypto.Blake2b_224 id + $ BSL.toStrict + $ serialise vl + +mintingPolicyHash :: MintingPolicy -> MintingPolicyHash +mintingPolicyHash vl = + MintingPolicyHash + $ Crypto.hashToBytes + $ Crypto.hashWith @Crypto.Blake2b_224 id + $ Crypto.hashToBytes + $ Crypto.hashWith @Crypto.Blake2b_224 id + $ BSL.toStrict + $ serialise vl diff --git a/plutus-ledger/src/Ledger/Tx.hs b/plutus-ledger/src/Ledger/Tx.hs new file mode 100644 index 00000000000..30b7e450699 --- /dev/null +++ b/plutus-ledger/src/Ledger/Tx.hs @@ -0,0 +1,35 @@ +module Ledger.Tx + ( module Export + , addSignature + , pubKeyTxOut + , scriptTxOut + , scriptTxOut' + ) where + +import Control.Lens +import Ledger.Address (pubKeyAddress, scriptAddress) +import Ledger.Crypto (PrivateKey, PubKey, signTx, toPublicKey) +import Ledger.Scripts (Datum, Validator, datumHash) +import Plutus.V1.Ledger.Tx as Export +import Plutus.V1.Ledger.Value + +-- | Create a transaction output locked by a validator script hash +-- with the given data script attached. +scriptTxOut' :: Value -> Address -> Datum -> TxOut +scriptTxOut' v a ds = TxOut a v (Just (datumHash ds)) + +-- | Create a transaction output locked by a validator script and with the given data script attached. +scriptTxOut :: Value -> Validator -> Datum -> TxOut +scriptTxOut v vs = scriptTxOut' v (scriptAddress vs) + +-- | Create a transaction output locked by a public key. +pubKeyTxOut :: Value -> PubKey -> TxOut +pubKeyTxOut v pk = TxOut (pubKeyAddress pk) v Nothing + +-- | Sign the transaction with a 'PrivateKey' and add the signature to the +-- transaction's list of signatures. +addSignature :: PrivateKey -> Tx -> Tx +addSignature privK tx = tx & signatures . at pubK ?~ sig where + sig = signTx (txId tx) privK + pubK = toPublicKey privK + diff --git a/plutus-ledger/src/Ledger/Typed/Scripts.hs b/plutus-ledger/src/Ledger/Typed/Scripts.hs index 6ec9b761fe3..24dadef7757 100644 --- a/plutus-ledger/src/Ledger/Typed/Scripts.hs +++ b/plutus-ledger/src/Ledger/Typed/Scripts.hs @@ -4,7 +4,7 @@ module Ledger.Typed.Scripts( , MintingPolicy ) where -import Plutus.V1.Ledger.Scripts hiding (mintingPolicyHash, validatorHash) +import Ledger.Scripts hiding (mintingPolicyHash, validatorHash) import Ledger.Typed.Scripts.MonetaryPolicies as Export import Ledger.Typed.Scripts.Validators as Export diff --git a/plutus-ledger/src/Ledger/Typed/Scripts/Validators.hs b/plutus-ledger/src/Ledger/Typed/Scripts/Validators.hs index bfdd5471afb..612e6792938 100644 --- a/plutus-ledger/src/Ledger/Typed/Scripts/Validators.hs +++ b/plutus-ledger/src/Ledger/Typed/Scripts/Validators.hs @@ -1,16 +1,28 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE ViewPatterns #-} + {-# OPTIONS_GHC -fno-specialise #-} {-# OPTIONS_GHC -fno-strictness #-} {-# OPTIONS_GHC -Wno-simplifiable-class-constraints #-} {-# OPTIONS_GHC -fno-omit-interface-pragmas #-} -module Ledger.Typed.Scripts.Validators (ValidatorTypes(..), ValidatorType, WrappedValidatorType, wrapValidator, TypedValidator, mkTypedValidator, mkTypedValidatorParam, validatorHash, validatorAddress, validatorScript, unsafeMkTypedValidator, forwardingMintingPolicy, forwardingMintingPolicyHash) where + +module Ledger.Typed.Scripts.Validators + ( ValidatorTypes(..) + , ValidatorType + , WrappedValidatorType + , wrapValidator + , TypedValidator + , mkTypedValidator + , mkTypedValidatorParam + , validatorHash + , validatorAddress + , validatorScript + , unsafeMkTypedValidator + , forwardingMintingPolicy + , forwardingMintingPolicyHash + ) where import Data.Aeson (FromJSON, ToJSON) import Data.Kind @@ -21,9 +33,9 @@ import PlutusCore.Default (DefaultUni) import PlutusTx import PlutusTx.Prelude (check) +import qualified Ledger.Scripts as Scripts import Plutus.V1.Ledger.Address (Address (..), scriptHashAddress) import qualified Plutus.V1.Ledger.Contexts as Validation -import qualified Plutus.V1.Ledger.Scripts as Scripts import qualified Ledger.Typed.Scripts.MonetaryPolicies as MPS import Ledger.Typed.TypeUtils (Any) diff --git a/plutus-ledger/src/Ledger/Typed/Tx.hs b/plutus-ledger/src/Ledger/Typed/Tx.hs index 9a6cf1ddfdc..2594fd09d63 100644 --- a/plutus-ledger/src/Ledger/Typed/Tx.hs +++ b/plutus-ledger/src/Ledger/Typed/Tx.hs @@ -16,21 +16,20 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -{-# LANGUAGE ViewPatterns #-} + {-# OPTIONS_GHC -Wno-orphans #-} + -- | Typed transaction inputs and outputs. This module defines typed versions -- of various ledger types. The ultimate goal is to make sure that the script -- types attached to inputs and outputs line up, to avoid type errors at -- validation time. module Ledger.Typed.Tx where +import Ledger.Scripts +import Ledger.Tx import Ledger.Typed.Scripts -import Plutus.V1.Ledger.Address import Plutus.V1.Ledger.Crypto -import Plutus.V1.Ledger.Scripts -import Plutus.V1.Ledger.Tx import Plutus.V1.Ledger.TxId import qualified Plutus.V1.Ledger.Value as Value