-
Notifications
You must be signed in to change notification settings - Fork 25
Implement experimental estimateBalancedTxBody
#887
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
Merged
Jimbo4350
merged 4 commits into
master
from
jordan/implement-experimental-estimateBalancedTxBody
Sep 10, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eec5722
Implement experimental estimateBalancedTxBody
Jimbo4350 b44b5b9
Implement extractAllIndexedPlutusScriptWitnesses
Jimbo4350 bc6dba0
Modify extract* functions with more specific types and expose them for
Jimbo4350 079de21
Implement prop_extractAllIndexedPlutusScriptWitnesses
Jimbo4350 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Body.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
module Cardano.Api.Experimental.Tx.Internal.Body | ||
( extractAllIndexedPlutusScriptWitnesses | ||
) | ||
where | ||
|
||
import Cardano.Api.Era | ||
import Cardano.Api.Experimental.Era | ||
import Cardano.Api.Experimental.Plutus | ||
import Cardano.Api.Plutus.Internal.Script | ||
import Cardano.Api.Tx.Internal.Body | ||
|
||
import Cardano.Binary qualified as CBOR | ||
|
||
extractAllIndexedPlutusScriptWitnesses | ||
:: forall era | ||
. Era era | ||
-> TxBodyContent BuildTx era | ||
-> Either | ||
CBOR.DecoderError | ||
[AnyIndexedPlutusScriptWitness (LedgerEra era)] | ||
extractAllIndexedPlutusScriptWitnesses era b = obtainCommonConstraints era $ do | ||
let sbe = convert era | ||
aeon = convert era | ||
legacyTxInWits = extractWitnessableTxIns aeon $ txIns b | ||
legacyCertWits = extractWitnessableCertificates aeon $ txCertificates b | ||
legacyMintWits = extractWitnessableMints aeon $ txMintValue b | ||
proposalWits | ||
:: [(Witnessable ProposalItem (ShelleyLedgerEra era), BuildTxWith BuildTx (Witness WitCtxStake era))] = | ||
caseShelleyToBabbageOrConwayEraOnwards | ||
(const []) | ||
(`extractWitnessableProposals` txProposalProcedures b) | ||
sbe | ||
legacyWithdrawalWits = extractWitnessableWithdrawals aeon $ txWithdrawals b | ||
legacyVoteWits | ||
:: [(Witnessable VoterItem (ShelleyLedgerEra era), BuildTxWith BuildTx (Witness WitCtxStake era))] = | ||
caseShelleyToBabbageOrConwayEraOnwards | ||
(const []) | ||
(`extractWitnessableVotes` txVotingProcedures b) | ||
sbe | ||
|
||
txInWits <- legacyWitnessConversion aeon legacyTxInWits | ||
let indexedScriptTxInWits = alonzoEraOnwardsConstraints aeon $ createIndexedPlutusScriptWitnesses txInWits | ||
|
||
certWits <- legacyWitnessConversion aeon legacyCertWits | ||
let indexedCertScriptWits = alonzoEraOnwardsConstraints aeon $ createIndexedPlutusScriptWitnesses certWits | ||
|
||
mintWits <- legacyWitnessConversion aeon legacyMintWits | ||
let indexedMintScriptWits = alonzoEraOnwardsConstraints aeon $ createIndexedPlutusScriptWitnesses mintWits | ||
|
||
withdrawalWits <- legacyWitnessConversion aeon legacyWithdrawalWits | ||
let indexedWithdrawalScriptWits = alonzoEraOnwardsConstraints aeon $ createIndexedPlutusScriptWitnesses withdrawalWits | ||
|
||
proposalScriptWits <- legacyWitnessConversion aeon proposalWits | ||
let indexedProposalScriptWits = alonzoEraOnwardsConstraints aeon $ createIndexedPlutusScriptWitnesses proposalScriptWits | ||
|
||
voteWits <- legacyWitnessConversion aeon legacyVoteWits | ||
let indexedVoteScriptWits = alonzoEraOnwardsConstraints aeon $ createIndexedPlutusScriptWitnesses voteWits | ||
return $ | ||
mconcat | ||
[ indexedScriptTxInWits | ||
, indexedMintScriptWits | ||
, indexedCertScriptWits | ||
, indexedWithdrawalScriptWits | ||
, indexedProposalScriptWits | ||
, indexedVoteScriptWits | ||
] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.