Skip to content

Commit

Permalink
Change TxBody.mint field to MultiAsset in alonzo
Browse files Browse the repository at this point in the history
  • Loading branch information
teodanciu committed Aug 8, 2022
1 parent a6dbc50 commit bb0fb56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody.hs
Expand Up @@ -108,7 +108,7 @@ import qualified Cardano.Ledger.Core as Core
import Cardano.Ledger.Credential (Credential (..), PaymentCredential, StakeReference (..))
import qualified Cardano.Ledger.Crypto as CC
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
import Cardano.Ledger.Mary.Value (MaryValue (..), policies, policyID)
import Cardano.Ledger.Mary.Value (MaryValue (MaryValue), MultiAsset (..), policies, policyID)
import Cardano.Ledger.SafeHash
( HashAnnotated,
SafeHash,
Expand All @@ -127,7 +127,6 @@ import Cardano.Ledger.Val
decodeMint,
decodeNonNegative,
encodeMint,
isZero,
)
import Control.DeepSeq (NFData (..), rwhnf)
import Control.Monad (guard, (<$!>))
Expand Down Expand Up @@ -410,7 +409,7 @@ data TxBodyRaw era = TxBodyRaw
_vldt :: !ValidityInterval,
_update :: !(StrictMaybe (Update era)),
_reqSignerHashes :: Set (KeyHash 'Witness (Crypto era)),
_mint :: !(MaryValue (Crypto era)),
_mint :: !(MultiAsset (Crypto era)),
-- The spec makes it clear that the mint field is a
-- Cardano.Ledger.Mary.Value.MaryValue, not a Cardano.Ledger.Core.Value.
-- Operations on the TxBody in the AlonzoEra depend upon this.
Expand Down Expand Up @@ -488,6 +487,8 @@ instance CC.Crypto c => ShelleyMAEraTxBody (AlonzoEra c) where
mintTxBodyL =
lensTxBodyRaw _mint (\txBodyRaw mint_ -> txBodyRaw {_mint = mint_})

mintValueTxBodyF = mintTxBodyL . to (MaryValue 0)

class (ShelleyMAEraTxBody era, AlonzoEraTxOut era) => AlonzoEraTxBody era where
collateralInputsTxBodyL :: Lens' (Core.TxBody era) (Set (TxIn (Crypto era)))

Expand Down Expand Up @@ -539,7 +540,7 @@ pattern AlonzoTxBody ::
ValidityInterval ->
StrictMaybe (Update era) ->
Set (KeyHash 'Witness (Crypto era)) ->
MaryValue (Crypto era) ->
MultiAsset (Crypto era) ->
StrictMaybe (ScriptIntegrityHash (Crypto era)) ->
StrictMaybe (AuxiliaryDataHash (Crypto era)) ->
StrictMaybe Network ->
Expand Down Expand Up @@ -635,7 +636,7 @@ vldt' :: AlonzoTxBody era -> ValidityInterval
update' :: AlonzoTxBody era -> StrictMaybe (Update era)
reqSignerHashes' :: AlonzoTxBody era -> Set (KeyHash 'Witness (Crypto era))
adHash' :: AlonzoTxBody era -> StrictMaybe (AuxiliaryDataHash (Crypto era))
mint' :: AlonzoTxBody era -> MaryValue (Crypto era)
mint' :: AlonzoTxBody era -> MultiAsset (Crypto era)
scriptIntegrityHash' :: AlonzoTxBody era -> StrictMaybe (ScriptIntegrityHash (Crypto era))
txnetworkid' :: AlonzoTxBody era -> StrictMaybe Network
inputs' (TxBodyConstr (Memo raw _)) = _inputs raw
Expand Down Expand Up @@ -782,7 +783,7 @@ encodeTxBodyRaw
!> encodeKeyedStrictMaybe 6 _update
!> encodeKeyedStrictMaybe 8 bot
!> Omit null (Key 14 (E encodeFoldable _reqSignerHashes))
!> Omit isZero (Key 9 (E encodeMint _mint))
!> Omit (== mempty) (Key 9 (E encodeMint _mint))
!> encodeKeyedStrictMaybe 11 _scriptIntegrityHash
!> encodeKeyedStrictMaybe 7 _adHash
!> encodeKeyedStrictMaybe 15 _txnetworkid
Expand Down
4 changes: 2 additions & 2 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxInfo.hs
Expand Up @@ -84,8 +84,8 @@ import Cardano.Ledger.Alonzo.Tx
import Cardano.Ledger.Alonzo.TxBody
( AlonzoEraTxBody (..),
AlonzoEraTxOut (..),
ShelleyMAEraTxBody (mintValueTxBodyF),
certsTxBodyL,
mintTxBodyL,
vldtTxBodyL,
wdrlsTxBodyL,
)
Expand Down Expand Up @@ -535,7 +535,7 @@ alonzoTxInfo pp lang ei sysS utxo tx = do
txWits = tx ^. witsTxL
txOuts = txBody ^. outputsTxBodyL
fee = txBody ^. feeTxBodyL
mint = txBody ^. mintTxBodyL
mint = txBody ^. mintValueTxBodyF
interval = txBody ^. vldtTxBodyL

datpairs = Map.toList (unTxDats $ txdats' txWits)
Expand Down

0 comments on commit bb0fb56

Please sign in to comment.