Skip to content

Commit

Permalink
asdfasdf
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Nov 28, 2024
1 parent a481ed2 commit 9003604
Showing 1 changed file with 54 additions and 52 deletions.
106 changes: 54 additions & 52 deletions cardano-api/internal/Cardano/Api/Tx/Compatible.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ createCompatibleSignedTx sbe ins outs witnesses anyScriptWits txFee' anyProtocol
apiScriptWitnesses = scriptWitnessesProposing proposalProcedures
ledgerScripts = convScripts apiScriptWitnesses
referenceInputs =
map toShelleyTxIn $
catMaybes [getScriptWitnessReferenceInput sWit | (_, AnyScriptWitness sWit) <- apiScriptWitnesses]
[ toShelleyTxIn txIn
| (_, AnyScriptWitness sWit) <- apiScriptWitnesses
, txIn <- maybeToList $ getScriptWitnessReferenceInput sWit
]
sData = convScriptData sbe outs apiScriptWitnesses
updatedTxBody =
conwayEraOnwardsConstraints conwayOnwards $
Expand Down Expand Up @@ -189,56 +191,56 @@ createCompatibleSignedTx sbe ins outs witnesses anyScriptWits txFee' anyProtocol
sbe
txw2

convScriptData
:: ()
=> ShelleyBasedEra era
-> [TxOut CtxTx era]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
-> TxBodyScriptData era
convScriptData sbe txOuts scriptWitnesses =
caseShelleyToMaryOrAlonzoEraOnwards
(const TxBodyNoScriptData)
( \w ->
let redeemers =
Alonzo.Redeemers $
fromList
[ (i, (toAlonzoData d, toAlonzoExUnits e))
| ( idx
, AnyScriptWitness
(PlutusScriptWitness _ _ _ _ d e)
) <-
scriptWitnesses
, Just i <- [fromScriptWitnessIndex w idx]
]

datums =
Alonzo.TxDats $
fromList
[ (L.hashData d', d')
| d <- scriptdata
, let d' = toAlonzoData d
]

scriptdata :: [HashableScriptData]
scriptdata =
[d | TxOut _ _ (TxOutSupplementalDatum _ d) _ <- txOuts]
++ [ d
| ( _
, AnyScriptWitness
( PlutusScriptWitness
_
_
_
(ScriptDatumForTxIn (Just d))
_
_
)
) <-
scriptWitnesses
]
in TxBodyScriptData w datums redeemers
)
sbe
-- convScriptData
-- :: ()
-- => ShelleyBasedEra era
-- -> [TxOut CtxTx era]
-- -> [(ScriptWitnessIndex, AnyScriptWitness era)]
-- -> TxBodyScriptData era
-- convScriptData sbe txOuts scriptWitnesses =
-- caseShelleyToMaryOrAlonzoEraOnwards
-- (const TxBodyNoScriptData)
-- ( \w ->
-- let redeemers =
-- Alonzo.Redeemers $
-- fromList
-- [ (i, (toAlonzoData d, toAlonzoExUnits e))
-- | ( idx
-- , AnyScriptWitness
-- (PlutusScriptWitness _ _ _ _ d e)
-- ) <-
-- scriptWitnesses
-- , Just i <- [fromScriptWitnessIndex w idx]
-- ]
--
-- datums =
-- Alonzo.TxDats $
-- fromList
-- [ (L.hashData d', d')
-- | d <- scriptdata
-- , let d' = toAlonzoData d
-- ]
--
-- scriptdata :: [HashableScriptData]
-- scriptdata =
-- [d | TxOut _ _ (TxOutSupplementalDatum _ d) _ <- txOuts]
-- ++ [ d
-- | ( _
-- , AnyScriptWitness
-- ( PlutusScriptWitness
-- _
-- _
-- _
-- (ScriptDatumForTxIn (Just d))
-- _
-- _
-- )
-- ) <-
-- scriptWitnesses
-- ]
-- in TxBodyScriptData w datums redeemers
-- )
-- sbe

fromScriptWitnessIndex
:: AlonzoEraOnwards era
Expand Down

0 comments on commit 9003604

Please sign in to comment.