Skip to content

Commit

Permalink
Fixing the Mint field translation.
Browse files Browse the repository at this point in the history
It was incorrectly fixed in 21825f1

This is due to the fact that the Map in Plutus is not like a Map in
Haskell's containers library. Plutus Map is an assoc Map that is based
on lists and the order of elements actually matters. So, the original
fix placed the ADA value at the end, while the original and correct
implementation, as in this commit, places it at the beginning.
  • Loading branch information
lehins committed Apr 29, 2023
1 parent cffa75f commit 2f3a747
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,10 @@ transAssetName :: AssetName -> PV1.TokenName
transAssetName (AssetName bs) = PV1.TokenName (PV1.toBuiltin (SBS.fromShort bs))

transMultiAsset :: MultiAsset c -> PV1.Value
transMultiAsset (MultiAsset m) = Map.foldlWithKey' accum1 mempty m
transMultiAsset ma = transMultiAssetInternal ma mempty

transMultiAssetInternal :: MultiAsset c -> PV1.Value -> PV1.Value
transMultiAssetInternal (MultiAsset m) initAcc = Map.foldlWithKey' accum1 initAcc m
where
accum1 ans sym mp2 = Map.foldlWithKey' accum2 ans mp2
where
Expand All @@ -380,7 +383,7 @@ transMultiAsset (MultiAsset m) = Map.foldlWithKey' accum1 mempty m
-- makes no sense). However, if we don't preserve previous translation, scripts that
-- previously succeeded will fail.
transMintValue :: MultiAsset c -> PV1.Value
transMintValue m = transMultiAsset m <> justZeroAda
transMintValue m = transMultiAssetInternal m justZeroAda
where
justZeroAda = PV1.singleton PV1.adaSymbol PV1.adaToken 0

Expand Down

0 comments on commit 2f3a747

Please sign in to comment.