-
Notifications
You must be signed in to change notification settings - Fork 22
Experimental api propagation 2025-05-28 #1205
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
81b1f4e
Parameterize readMintScriptWitness on IsEra era
Jimbo4350 40370de
Parameterize `pGovernanceCommitteeCmds` on `IsEra era`
Jimbo4350 8fafe5c
Parameterize `pGovernanceDRepCmds` on `IsEra era`
Jimbo4350 0dc1cce
Parameterize `pGovernanceVoteCmds` on `IsEra era`
Jimbo4350 bfed724
Parameterize pTransactionCalculatePlutusScriptCost and pCalculateMinR…
Jimbo4350 f9f5a46
Parameterize `validateTxInsCollateral` on `IsEra era`
Jimbo4350 d480f65
Remove unused `TxFeature` constructors
Jimbo4350 035bfbe
Parameterize `createTxMintValue` on `IsEra era`
Jimbo4350 867ee5c
Parameterize `validateTxInsReference` on `IsEra era`
Jimbo4350 0036586
Move `mkTxOut` and `toTxOutInAnyEra` to Cardano.CLI.Compatible.Helper
Jimbo4350 6425a8f
Convert the following to return `CIO e ()`:
Jimbo4350 6afdf14
Remove unused `TxCmdError` constructors
Jimbo4350 84c1bb0
Address reviews
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
131 changes: 131 additions & 0 deletions
131
cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.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,131 @@ | ||
| {-# LANGUAGE LambdaCase #-} | ||
| {-# LANGUAGE RankNTypes #-} | ||
|
|
||
| module Cardano.CLI.Compatible.Transaction.TxOut | ||
| ( mkTxOut | ||
| , toTxOutInAnyEra | ||
| ) | ||
| where | ||
|
|
||
| import Cardano.Api | ||
| import Cardano.Api.Shelley | ||
|
|
||
| import Cardano.CLI.Compatible.Exception | ||
| import Cardano.CLI.EraBased.Script.Read.Common | ||
| import Cardano.CLI.Orphan () | ||
| import Cardano.CLI.Read | ||
| import Cardano.CLI.Type.Common | ||
|
|
||
| import Data.Text (Text) | ||
|
|
||
| toTxOutInAnyEra | ||
| :: ShelleyBasedEra era | ||
| -> TxOutAnyEra | ||
| -> CIO e (TxOut CtxTx era) | ||
| toTxOutInAnyEra era (TxOutAnyEra addr' val' mDatumHash refScriptFp) = do | ||
| let addr = anyAddressInShelleyBasedEra era addr' | ||
| mkTxOut era addr val' mDatumHash refScriptFp | ||
|
|
||
| mkTxOut | ||
| :: ShelleyBasedEra era | ||
| -> AddressInEra era | ||
| -> Value | ||
| -> TxOutDatumAnyEra | ||
| -> ReferenceScriptAnyEra | ||
| -> CIO e (TxOut CtxTx era) | ||
| mkTxOut sbe addr val' mDatumHash refScriptFp = do | ||
| let era = toCardanoEra sbe | ||
| val <- toTxOutValueInShelleyBasedEra sbe val' | ||
|
|
||
| datum <- | ||
| inEonForEra | ||
| (pure TxOutDatumNone) | ||
| (`toTxAlonzoDatum` mDatumHash) | ||
| era | ||
|
|
||
| refScript <- | ||
| inEonForEra | ||
| (pure ReferenceScriptNone) | ||
| (`getReferenceScript` refScriptFp) | ||
| era | ||
|
|
||
| pure $ TxOut addr val datum refScript | ||
|
|
||
| toTxOutValueInShelleyBasedEra | ||
| :: ShelleyBasedEra era | ||
| -> Value | ||
| -> CIO e (TxOutValue era) | ||
| toTxOutValueInShelleyBasedEra sbe val = | ||
| caseShelleyToAllegraOrMaryEraOnwards | ||
| ( \_ -> case valueToLovelace val of | ||
| Just l -> return (TxOutValueShelleyBased sbe l) | ||
| Nothing -> txFeatureMismatch sbe TxFeatureMultiAssetOutputs | ||
| ) | ||
| (\w -> return (TxOutValueShelleyBased sbe (toLedgerValue w val))) | ||
| sbe | ||
|
|
||
| toTxAlonzoDatum | ||
| :: () | ||
| => AlonzoEraOnwards era | ||
| -> TxOutDatumAnyEra | ||
| -> CIO e (TxOutDatum CtxTx era) | ||
| toTxAlonzoDatum supp cliDatum = | ||
| case cliDatum of | ||
| TxOutDatumByNone -> pure TxOutDatumNone | ||
| TxOutDatumByHashOnly h -> pure (TxOutDatumHash supp h) | ||
| TxOutDatumByHashOf sDataOrFile -> do | ||
| sData <- fromExceptTCli $ readScriptDataOrFile sDataOrFile | ||
| pure (TxOutDatumHash supp $ hashScriptDataBytes sData) | ||
| TxOutDatumByValue sDataOrFile -> do | ||
| sData <- fromExceptTCli $ readScriptDataOrFile sDataOrFile | ||
| pure (TxOutSupplementalDatum supp sData) | ||
| TxOutInlineDatumByValue sDataOrFile -> do | ||
| let cEra = toCardanoEra supp | ||
| forEraInEon cEra (txFeatureMismatch cEra TxFeatureInlineDatums) $ \babbageOnwards -> do | ||
| sData <- fromExceptTCli $ readScriptDataOrFile sDataOrFile | ||
| pure $ TxOutDatumInline babbageOnwards sData | ||
|
|
||
| getReferenceScript | ||
| :: () | ||
| => BabbageEraOnwards era | ||
| -> ReferenceScriptAnyEra | ||
| -> CIO e (ReferenceScript era) | ||
| getReferenceScript w = \case | ||
| ReferenceScriptAnyEraNone -> return ReferenceScriptNone | ||
| ReferenceScriptAnyEra fp -> ReferenceScript w <$> fromExceptTCli (readFileScriptInAnyLang fp) | ||
|
|
||
| -- | An enumeration of era-dependent features where we have to check that it | ||
| -- is permissible to use this feature in this era. | ||
| data TxFeature | ||
| = TxFeatureMultiAssetOutputs | ||
| | TxFeatureInlineDatums | ||
| deriving Show | ||
|
|
||
| renderFeature :: TxFeature -> Text | ||
| renderFeature = \case | ||
| TxFeatureMultiAssetOutputs -> "Multi-Asset outputs" | ||
| TxFeatureInlineDatums -> "Inline datums" | ||
|
|
||
| data TxCmdTxFeatureMismatch = TxCmdTxFeatureMismatch !AnyCardanoEra !TxFeature deriving Show | ||
|
|
||
| instance Error TxCmdTxFeatureMismatch where | ||
| prettyError (TxCmdTxFeatureMismatch (AnyCardanoEra era) feature) = | ||
| pretty $ | ||
| mconcat | ||
| [ renderFeature feature | ||
| , " cannot be used for " | ||
| , eraToStringKey era | ||
| , " era transactions." | ||
| ] | ||
|
|
||
| txFeatureMismatch | ||
| :: () | ||
| => ToCardanoEra eon | ||
| => eon era | ||
| -> TxFeature | ||
| -> CIO e a | ||
| txFeatureMismatch eon feature = | ||
| throwCliError $ TxCmdTxFeatureMismatch (anyCardanoEra $ toCardanoEra eon) feature | ||
|
|
||
| eraToStringKey :: CardanoEra a -> Text | ||
| eraToStringKey = docToText . pretty |
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
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.