Skip to content

Commit

Permalink
Initial work
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Jan 14, 2025
1 parent c5cb6b2 commit 6eac8f2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cardano-api/internal/Cardano/Api/Tx/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ module Cardano.Api.Tx.Body
, TxProposalProcedures (..)
, mkTxProposalProcedures
, indexTxProposalProcedures
, convProposalProcedures

-- ** Building vs viewing transactions
, BuildTxWith (..)
Expand Down Expand Up @@ -1445,7 +1444,7 @@ data TxProposalProcedures build era where
TxProposalProceduresNone :: TxProposalProcedures build era
-- | Create Tx proposal procedures. Prefer 'mkTxProposalProcedures' smart constructor to using this constructor
-- directly.
TxProposalProcedures
UnsafeTxProposalProcedures
:: Ledger.EraPParams (ShelleyLedgerEra era)
=> OSet (L.ProposalProcedure (ShelleyLedgerEra era))
-- ^ a set of proposals
Expand All @@ -1458,6 +1457,10 @@ deriving instance Eq (TxProposalProcedures build era)

deriving instance Show (TxProposalProcedures build era)

pattern TxProposalProcedures
:: OSet (L.ProposalProcedure (ShelleyLedgerEra era)) -> TxProposalProcedures build era
pattern TxProposalProcedures oset <- (convProposalProcedures -> oset)

-- | A smart constructor for 'TxProposalProcedures'. It makes sure that the value produced is consistent - the
-- witnessed proposals are also present in the first constructor parameter.
mkTxProposalProcedures
Expand All @@ -1471,7 +1474,7 @@ mkTxProposalProcedures proposalsWithWitnessesList = do
bimap toList toList $
Foldable.foldl' partitionProposals mempty proposalsWithWitnessesList
shelleyBasedEraConstraints (shelleyBasedEra @era) $
TxProposalProcedures (fromList proposals) (pure $ fromList proposalsWithWitnesses)
UnsafeTxProposalProcedures (fromList proposals) (pure $ fromList proposalsWithWitnesses)
where
partitionProposals (ps, pws) (p, Nothing) =
(DList.snoc ps p, pws) -- add a proposal to the list
Expand Down Expand Up @@ -2797,7 +2800,7 @@ convReferenceInputs txInsReference =
convProposalProcedures
:: TxProposalProcedures build era -> OSet (L.ProposalProcedure (ShelleyLedgerEra era))
convProposalProcedures TxProposalProceduresNone = OSet.empty
convProposalProcedures (TxProposalProcedures pp bWits) = do
convProposalProcedures (UnsafeTxProposalProcedures pp bWits) = do
let wits = fromMaybe mempty $ buildTxWithToMaybe bWits
pp |>< fromList (Map.keys wits)

Expand Down

0 comments on commit 6eac8f2

Please sign in to comment.