Skip to content

Commit

Permalink
Combine blueprint and commit tx metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch authored and ch1bo committed May 3, 2024
1 parent c350a50 commit 0294de9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hydra-node/src/Hydra/Chain/Direct/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Cardano.Ledger.Api (
unRedeemers,
witsTxL,
)
import Cardano.Ledger.BaseTypes (StrictMaybe (..))
import Cardano.Ledger.BaseTypes (StrictMaybe (..), fromSMaybe)
import Control.Lens ((.~), (<>~), (^.))
import Data.Aeson qualified as Aeson
import Data.ByteString qualified as BS
Expand Down Expand Up @@ -255,7 +255,7 @@ commitTx networkId scriptRegistry headId party commitBlueprintTx (initialInput,
& bodyTxL . referenceInputsTxBodyL <>~ Set.fromList [toLedgerTxIn initialScriptRef]
& bodyTxL . outputsTxBodyL .~ StrictSeq.singleton (toLedgerTxOut commitOutput)
& bodyTxL . reqSignerHashesTxBodyL <>~ Set.singleton (toLedgerKeyHash vkh)
& bodyTxL . auxDataHashTxBodyL .~ SJust (hashAlonzoTxAuxData txAuxMetadata)
& bodyTxL . auxDataHashTxBodyL .~ combinedMetadata
& bodyTxL . mintTxBodyL .~ mempty
& auxDataTxL .~ addMetadata txAuxMetadata
existingWits = toLedgerTx blueprintTx ^. witsTxL
Expand Down Expand Up @@ -338,6 +338,12 @@ commitTx networkId scriptRegistry headId party commitBlueprintTx (initialInput,
TxMetadata commitMetadataMap = commitMetadata

txAuxMetadata = mkAlonzoTxAuxData @[] @LedgerEra (toShelleyMetadata commitMetadataMap) []

combinedMetadata =
let existingMetadataMap = fromSMaybe mempty $ getAuxMetadata <$> toLedgerTx blueprintTx ^. auxDataTxL
in SJust . hashAlonzoTxAuxData $
mkAlonzoTxAuxData @[] @LedgerEra (Map.union (toShelleyMetadata commitMetadataMap) existingMetadataMap) []

CommitBlueprintTx{lookupUTxO, blueprintTx} = commitBlueprintTx

commitMetadata :: TxMetadata
Expand Down

0 comments on commit 0294de9

Please sign in to comment.