Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
erikd committed Feb 7, 2023
1 parent 3d632b3 commit 798a6b7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/wallet/src/Cardano/Wallet/Write/Tx.hs
Expand Up @@ -133,15 +133,15 @@ import Cardano.Crypto.Hash
import Cardano.Ledger.Alonzo.Data
( BinaryData, Datum (..) )
import Cardano.Ledger.Alonzo.Scripts
( Script (..) )
( AlonzoScript (..) )
import Cardano.Ledger.Coin
( Coin (..) )
import Cardano.Ledger.Crypto
( StandardCrypto )
import Cardano.Ledger.Era
( Crypto )
import Cardano.Ledger.Mary
( Value )
( MaryValue )
import Cardano.Ledger.SafeHash
( SafeHash, extractHash, unsafeMakeSafeHash )
import Cardano.Ledger.Serialization
Expand Down Expand Up @@ -358,6 +358,9 @@ type TxOutInBabbage = Babbage.TxOut (Babbage.BabbageEra StandardCrypto)

type Address = Ledger.Addr StandardCrypto

type Script = AlonzoScript
type Value = MaryValue

unsafeAddressFromBytes :: ByteString -> Address
unsafeAddressFromBytes bytes = case Ledger.deserialiseAddr bytes of
Just addr -> addr
Expand Down Expand Up @@ -397,7 +400,7 @@ scriptToCardanoScriptInAnyLang =
-- will convert 'SimpleScriptV1' to 'SimpleScriptV2'. Because 'SimpleScriptV1'
-- is 'ShelleyEra'-specific, and 'ShelleyEra' is not a 'RecentEra', this should
-- not be a problem.
scriptToCardanoEnvelopeJSON :: Script LatestLedgerEra -> Aeson.Value
scriptToCardanoEnvelopeJSON :: AlonzoScript LatestLedgerEra -> Aeson.Value
scriptToCardanoEnvelopeJSON = scriptToJSON . scriptToCardanoScriptInAnyLang
where
scriptToJSON
Expand All @@ -419,7 +422,7 @@ scriptToCardanoEnvelopeJSON = scriptToJSON . scriptToCardanoScriptInAnyLang

scriptFromCardanoEnvelopeJSON
:: Aeson.Value
-> Aeson.Parser (Script LatestLedgerEra)
-> Aeson.Parser (AlonzoScript LatestLedgerEra)
scriptFromCardanoEnvelopeJSON v = fmap scriptFromCardanoScriptInAnyLang $ do
envelope <- Aeson.parseJSON v
case textEnvelopeToScript envelope of
Expand Down Expand Up @@ -514,9 +517,9 @@ datumHashToBytes = Crypto.hashToBytes . extractHash
data TxOutInRecentEra
= TxOutInRecentEra
Address
(Value LatestLedgerEra)
(MaryValue LatestLedgerEra)
(Datum LatestLedgerEra)
(Maybe (Script LatestLedgerEra))
(Maybe (AlonzoScript LatestLedgerEra))
-- Same contents as 'TxOut LatestLedgerEra'.

data ErrInvalidTxOutInEra
Expand Down

0 comments on commit 798a6b7

Please sign in to comment.