From 5b691c59142a6ac40e7238180f997f564721d63e Mon Sep 17 00:00:00 2001 From: mmontin Date: Tue, 2 Apr 2024 15:39:40 +0200 Subject: [PATCH] UtxoState --- src/Cooked/MockChain/UtxoState.hs | 7 +++---- src/Cooked/RawUPLC.hs | 10 +++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Cooked/MockChain/UtxoState.hs b/src/Cooked/MockChain/UtxoState.hs index 04bba32ea..3ec309f00 100644 --- a/src/Cooked/MockChain/UtxoState.hs +++ b/src/Cooked/MockChain/UtxoState.hs @@ -13,7 +13,6 @@ import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import qualified Ledger as Pl hiding (Value) import qualified Plutus.Script.Utils.Value as Pl -import qualified Plutus.V2.Ledger.Api as PV2 -- | A description of who owns what in a blockchain. Owners are addresses -- and they each own a 'UtxoPayloadSet'. @@ -21,7 +20,7 @@ newtype UtxoState = UtxoState {utxoState :: Map Pl.Address UtxoPayloadSet} deriving (Eq) -- | Total value accessible to what's pointed by the address. -holdsInState :: PV2.Address -> UtxoState -> PV2.Value +holdsInState :: Pl.Address -> UtxoState -> Pl.Value holdsInState address (UtxoState m) = maybe mempty utxoPayloadSetTotal (Map.lookup address m) @@ -40,7 +39,7 @@ newtype UtxoPayloadSet = UtxoPayloadSet -- | A convenient wrapping of the interesting information of a UTxO. data UtxoPayload = UtxoPayload { utxoPayloadTxOutRef :: Pl.TxOutRef, - utxoPayloadValue :: PV2.Value, + utxoPayloadValue :: Pl.Value, utxoPayloadSkelOutDatum :: TxSkelOutDatum, utxoPayloadReferenceScript :: Maybe Pl.ScriptHash } @@ -60,5 +59,5 @@ instance Monoid UtxoPayloadSet where mempty = UtxoPayloadSet [] -- | Computes the total value in a set -utxoPayloadSetTotal :: UtxoPayloadSet -> PV2.Value +utxoPayloadSetTotal :: UtxoPayloadSet -> Pl.Value utxoPayloadSetTotal = mconcat . fmap utxoPayloadValue . utxoPayloadSet diff --git a/src/Cooked/RawUPLC.hs b/src/Cooked/RawUPLC.hs index 17f6a6ea1..6b6dc39b7 100644 --- a/src/Cooked/RawUPLC.hs +++ b/src/Cooked/RawUPLC.hs @@ -41,16 +41,20 @@ typedValidatorFromUPLC = TScripts.unsafeMkTypedValidator . flip Versioned Plutus fromPlc :: UPLC.Program UPLC.NamedDeBruijn UPLC.DefaultUni UPLC.DefaultFun () -> Script fromPlc (UPLC.Program a v t) = let nameless = UPLC.termMapNames UPLC.unNameDeBruijn t - in Script $ UPLC.Program a v nameless + in Script undefined -- UPLC.Program a v nameless + +-- TODO -- | Loads a typed validator from a bytestring that was produced by 'Flat.flat' the outputs -- of [getPlc](https://github.com/input-output-hk/plutus/blob/master/plutus-tx/src/PlutusTx/Code.hs#L84) -- applied to a 'TScripts.mkTypedValidator'. If the compiled validator was /not/ wrapped, -- stick to 'typedValidatorFromBS'. unsafeTypedValidatorFromBS :: forall a. BS.ByteString -> Either String (TScripts.TypedValidator a) -unsafeTypedValidatorFromBS = either (Left . show) (Right . unsafeTypedValidatorFromUPLC) . Flat.unflat +unsafeTypedValidatorFromBS = undefined -- either (Left . show) (Right . unsafeTypedValidatorFromUPLC) . Flat.unflat + +-- TODO -- | Loads a typed validator from a bytestring that was produced by 'Flat.flat' the outputs -- of [getPlc](https://github.com/input-output-hk/plutus/blob/master/plutus-tx/src/PlutusTx/Code.hs#L84). typedValidatorFromBS :: BS.ByteString -> Either String (TScripts.TypedValidator TScripts.Any) -typedValidatorFromBS = either (Left . show) (Right . unsafeTypedValidatorFromUPLC) . Flat.unflat +typedValidatorFromBS = undefined -- either (Left . show) (Right . unsafeTypedValidatorFromUPLC) . Flat.unflat