-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete TxVotes
and VotingEntry
and use VotingProcedures
instead
#209
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,7 @@ import Cardano.Api.Convenience.Constraints | |
import Cardano.Api.EraCast | ||
import Cardano.Api.Eras | ||
import Cardano.Api.Error | ||
import Cardano.Api.Feature | ||
import Cardano.Api.Feature.ConwayEraOnwards | ||
import Cardano.Api.Governance.Actions.ProposalProcedure | ||
import Cardano.Api.Governance.Actions.VotingProcedure | ||
|
@@ -1758,7 +1759,7 @@ data TxBodyContent build era = | |
txMintValue :: TxMintValue build era, | ||
txScriptValidity :: TxScriptValidity era, | ||
txGovernanceActions :: TxGovernanceActions era, | ||
txVotes :: TxVotes era | ||
txVotingProcedures :: Maybe (Featured ConwayEraOnwards era (VotingProcedures era)) | ||
} | ||
deriving (Eq, Show) | ||
|
||
|
@@ -1782,7 +1783,7 @@ defaultTxBodyContent = TxBodyContent | |
, txMintValue = TxMintNone | ||
, txScriptValidity = TxScriptValidityNone | ||
, txGovernanceActions = TxGovernanceActionsNone | ||
, txVotes = TxVotesNone | ||
, txVotingProcedures = Nothing | ||
} | ||
|
||
setTxIns :: TxIns build era -> TxBodyContent build era -> TxBodyContent build era | ||
|
@@ -2718,8 +2719,8 @@ fromLedgerTxBody sbe scriptValidity body scriptdata mAux = | |
, txMetadata | ||
, txAuxScripts | ||
, txScriptValidity = scriptValidity | ||
, txGovernanceActions = fromLedgerProposalProcedure sbe body | ||
, txVotes = fromLedgerTxVotes sbe body | ||
, txGovernanceActions = fromLedgerProposalProcedure sbe body | ||
, txVotingProcedures = fromLedgerVotingProcedures sbe body | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some strange spacing here |
||
} | ||
where | ||
(txMetadata, txAuxScripts) = fromLedgerTxAuxiliaryData sbe mAux | ||
|
@@ -2743,24 +2744,20 @@ fromLedgerProposalProcedure sbe body = | |
$ toList | ||
$ body_ ^. L.proposalProceduresTxBodyL | ||
|
||
fromLedgerTxVotes :: ShelleyBasedEra era -> Ledger.TxBody (ShelleyLedgerEra era) -> TxVotes era | ||
fromLedgerTxVotes sbe body = | ||
case featureInShelleyBasedEra Nothing Just sbe of | ||
Nothing -> TxVotesNone | ||
Just w -> getVotes w body | ||
where | ||
getVotes :: ConwayEraOnwards era | ||
-> Ledger.TxBody (ShelleyLedgerEra era) | ||
-> TxVotes era | ||
getVotes w body_ = | ||
fromLedgerVotingProcedures :: () | ||
=> ShelleyBasedEra era | ||
-> Ledger.TxBody (ShelleyLedgerEra era) | ||
-> Maybe (Featured ConwayEraOnwards era (VotingProcedures era)) | ||
fromLedgerVotingProcedures sbe body = | ||
featureInShelleyBasedEra | ||
Nothing | ||
(\w -> | ||
conwayEraOnwardsConstraints w | ||
$ TxVotes w | ||
$ foldMap (\(voter, innerMap) -> | ||
Map.mapKeys (\govActId -> (fromVoterRole (conwayEraOnwardsToShelleyBasedEra w) voter, GovernanceActionId govActId)) | ||
$ Map.map VotingProcedure innerMap | ||
) | ||
$ (Map.toList . Gov.unVotingProcedures) | ||
$ body_ ^. L.votingProceduresTxBodyL | ||
$ Just | ||
$ Featured w | ||
$ VotingProcedures | ||
$ body ^. L.votingProceduresTxBodyL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
sbe | ||
|
||
fromLedgerTxIns | ||
:: forall era. | ||
|
@@ -3430,7 +3427,7 @@ getByronTxBodyContent (Annotated Byron.UnsafeTx{txInputs, txOutputs} _) = | |
, txMintValue = TxMintNone | ||
, txScriptValidity = TxScriptValidityNone | ||
, txGovernanceActions = TxGovernanceActionsNone | ||
, txVotes = TxVotesNone | ||
, txVotingProcedures = Nothing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spacing |
||
} | ||
|
||
convTxIns :: TxIns BuildTx era -> Set (L.TxIn StandardCrypto) | ||
|
@@ -3611,21 +3608,6 @@ convGovActions :: TxGovernanceActions era -> Seq.StrictSeq (Gov.ProposalProcedur | |
convGovActions TxGovernanceActionsNone = Seq.empty | ||
convGovActions (TxGovernanceActions _ govActions) = Seq.fromList $ fmap unProposal govActions | ||
|
||
convVotes | ||
:: (Ledger.EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) | ||
=> ShelleyBasedEra era | ||
-> TxVotes era | ||
-> Gov.VotingProcedures (ShelleyLedgerEra era) | ||
convVotes sbe = Gov.VotingProcedures . \case | ||
TxVotesNone -> Map.empty | ||
TxVotes _ votes -> | ||
let combine = error "convVotes: impossible! `votes' contained the same key multiple times" | ||
in | ||
Map.fromListWith (Map.unionWith combine) | ||
[ (toVoterRole sbe voter, unGovernanceActionId govActId `Map.singleton` unVotingProcedure vp) | ||
| ((voter, govActId), vp) <- Map.toList votes | ||
] | ||
|
||
guardShelleyTxInsOverflow :: [TxIn] -> Either TxBodyError () | ||
guardShelleyTxInsOverflow txIns = do | ||
for_ txIns $ \txin@(TxIn _ (TxIx txix)) -> | ||
|
@@ -3654,8 +3636,8 @@ mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData = | |
& L.auxDataHashTxBodyL .~ maybe SNothing (SJust . Ledger.hashTxAuxData) txAuxData | ||
|
||
|
||
makeShelleyTransactionBody | ||
:: ShelleyBasedEra era | ||
makeShelleyTransactionBody :: forall era. () | ||
=> ShelleyBasedEra era | ||
-> TxBodyContent BuildTx era | ||
-> Either TxBodyError (TxBody era) | ||
makeShelleyTransactionBody sbe@ShelleyBasedEraShelley | ||
|
@@ -3973,7 +3955,7 @@ makeShelleyTransactionBody sbe@ShelleyBasedEraConway | |
txCertificates, | ||
txMintValue, | ||
txScriptValidity, | ||
txVotes, | ||
txVotingProcedures, | ||
txGovernanceActions | ||
} = do | ||
|
||
|
@@ -3994,7 +3976,7 @@ makeShelleyTransactionBody sbe@ShelleyBasedEraConway | |
& L.reqSignerHashesTxBodyL .~ convExtraKeyWitnesses txExtraKeyWits | ||
& L.mintTxBodyL .~ convMintValue txMintValue | ||
& L.scriptIntegrityHashTxBodyL .~ scriptIntegrityHash | ||
& L.votingProceduresTxBodyL .~ convVotes sbe txVotes | ||
& L.votingProceduresTxBodyL .~ unVotingProcedures @era (maybe emptyVotingProcedures unFeatured txVotingProcedures) | ||
& L.proposalProceduresTxBodyL .~ convGovActions txGovernanceActions | ||
-- TODO Conway: support optional network id in TxBodyContent | ||
-- & L.networkIdTxBodyL .~ SNothing | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉