Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Jul 24, 2024
1 parent 601d88f commit 2780429
Show file tree
Hide file tree
Showing 12 changed files with 465 additions and 139 deletions.
68 changes: 46 additions & 22 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ pScriptDatumOrFile scriptFlagPrefix witctx =
case witctx of
WitCtxTxIn ->
asum
[ ScriptDatumOrFileForTxIn
[ ScriptDatumOrFileForTxIn . Just
<$> pScriptDataOrFile
(scriptFlagPrefix ++ "-datum")
"The script datum."
Expand Down Expand Up @@ -1583,9 +1583,10 @@ pTxBuildOutputOptions =
)

pCertificateFile
:: BalanceTxExecUnits
:: ShelleyBasedEra era
-> BalanceTxExecUnits
-> Parser (CertificateFile, Maybe (ScriptWitnessFiles WitCtxStake))
pCertificateFile balanceExecUnits =
pCertificateFile sbe balanceExecUnits =
(,)
<$> ( fmap CertificateFile $
asum
Expand All @@ -1605,6 +1606,7 @@ pCertificateFile balanceExecUnits =
:: BalanceTxExecUnits -> Parser (ScriptWitnessFiles WitCtxStake)
pCertifyingScriptOrReferenceScriptWit bExecUnits =
pScriptWitnessFiles
sbe
WitCtxStake
balanceExecUnits
"certificate"
Expand Down Expand Up @@ -1682,13 +1684,14 @@ pMetadataFile =
]

pWithdrawal
:: BalanceTxExecUnits
:: ShelleyBasedEra era
-> BalanceTxExecUnits
-> Parser
( StakeAddress
, L.Coin
, Maybe (ScriptWitnessFiles WitCtxStake)
)
pWithdrawal balance =
pWithdrawal sbe balance =
(\(stakeAddr, lovelace) maybeScriptFp -> (stakeAddr, lovelace, maybeScriptFp))
<$> Opt.option
(readerFromParsecParser parseWithdrawal)
Expand All @@ -1701,6 +1704,7 @@ pWithdrawal balance =
pWithdrawalScriptOrReferenceScriptWit :: Parser (ScriptWitnessFiles WitCtxStake)
pWithdrawalScriptOrReferenceScriptWit =
pScriptWitnessFiles
sbe
WitCtxStake
balance
"withdrawal"
Expand Down Expand Up @@ -2199,9 +2203,10 @@ pTxSubmitFile =
]

pTxIn
:: BalanceTxExecUnits
:: ShelleyBasedEra era
-> BalanceTxExecUnits
-> Parser (TxIn, Maybe (ScriptWitnessFiles WitCtxTxIn))
pTxIn balance =
pTxIn sbe balance =
(,)
<$> Opt.option
(readerFromParsecParser parseTxIn)
Expand All @@ -2210,9 +2215,9 @@ pTxIn balance =
<> Opt.help "TxId#TxIx"
)
<*> optional
( pPlutusReferenceScriptWitness balance
( pPlutusReferenceScriptWitness sbe balance
<|> pSimpleReferenceSpendingScriptWitess
<|> pEmbeddedPlutusScriptWitness
<|> pEmbeddedPlutusScriptWitness -- sbe
)
where
pSimpleReferenceSpendingScriptWitess :: Parser (ScriptWitnessFiles WitCtxTxIn)
Expand All @@ -2227,17 +2232,33 @@ pTxIn balance =
let simpleLang = AnyScriptLanguage SimpleScriptLanguage
in SimpleReferenceScriptWitnessFiles refTxIn simpleLang Nothing

pPlutusReferenceScriptWitness :: BalanceTxExecUnits -> Parser (ScriptWitnessFiles WitCtxTxIn)
pPlutusReferenceScriptWitness autoBalanceExecUnits =
createPlutusReferenceScriptWitnessFiles
<$> pReferenceTxIn "spending-" "plutus"
<*> pPlutusScriptLanguage "spending-"
<*> pScriptDatumOrFile "spending-reference-tx-in" WitCtxTxIn
<*> pScriptRedeemerOrFile "spending-reference-tx-in"
<*> ( case autoBalanceExecUnits of
AutoBalance -> pure (ExecutionUnits 0 0)
ManualBalance -> pExecutionUnits "spending-reference-tx-in"
)
pPlutusReferenceScriptWitness
:: ShelleyBasedEra era -> BalanceTxExecUnits -> Parser (ScriptWitnessFiles WitCtxTxIn)
pPlutusReferenceScriptWitness sbe' autoBalanceExecUnits =
caseShelleyToBabbageOrConwayEraOnwards
( const $
createPlutusReferenceScriptWitnessFiles
<$> pReferenceTxIn "spending-" "plutus"
<*> pPlutusScriptLanguage "spending-"
<*> pScriptDatumOrFile "spending-reference-tx-in" WitCtxTxIn
<*> pScriptRedeemerOrFile "spending-reference-tx-in"
<*> ( case autoBalanceExecUnits of
AutoBalance -> pure (ExecutionUnits 0 0)
ManualBalance -> pExecutionUnits "spending-reference-tx-in"
)
)
( const $
createPlutusReferenceScriptWitnessFiles
<$> pReferenceTxIn "spending-" "plutus"
<*> pPlutusScriptLanguage "spending-"
<*> pScriptDatumOrFileCip69 "spending-reference-tx-in" WitCtxTxIn
<*> pScriptRedeemerOrFile "spending-reference-tx-in"
<*> ( case autoBalanceExecUnits of
AutoBalance -> pure (ExecutionUnits 0 0)
ManualBalance -> pExecutionUnits "spending-reference-tx-in"
)
)
sbe'
where
createPlutusReferenceScriptWitnessFiles
:: TxIn
Expand All @@ -2252,6 +2273,7 @@ pTxIn balance =
pEmbeddedPlutusScriptWitness :: Parser (ScriptWitnessFiles WitCtxTxIn)
pEmbeddedPlutusScriptWitness =
pScriptWitnessFiles
sbe
WitCtxTxIn
balance
"tx-in"
Expand Down Expand Up @@ -2421,9 +2443,10 @@ pRefScriptFp =
<|> pure ReferenceScriptAnyEraNone

pMintMultiAsset
:: BalanceTxExecUnits
:: ShelleyBasedEra era
-> BalanceTxExecUnits
-> Parser (Value, [ScriptWitnessFiles WitCtxMint])
pMintMultiAsset balanceExecUnits =
pMintMultiAsset sbe balanceExecUnits =
(,)
<$> Opt.option
(readerFromParsecParser parseValue)
Expand All @@ -2441,6 +2464,7 @@ pMintMultiAsset balanceExecUnits =
:: BalanceTxExecUnits -> Parser (ScriptWitnessFiles WitCtxMint)
pMintingScriptOrReferenceScriptWit bExecUnits =
pScriptWitnessFiles
sbe
WitCtxMint
bExecUnits
"mint"
Expand Down
24 changes: 12 additions & 12 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,19 @@ pTransactionBuildCmd era envCli = do
<*> pNetworkId envCli
<*> optional pScriptValidity
<*> optional pWitnessOverride
<*> some (pTxIn AutoBalance)
<*> some (pTxIn sbe AutoBalance)
<*> many pReadOnlyReferenceTxIn
<*> many pRequiredSigner
<*> many pTxInCollateral
<*> optional pReturnCollateral
<*> optional pTotalCollateral
<*> many pTxOut
<*> pChangeAddress
<*> optional (pMintMultiAsset AutoBalance)
<*> optional (pMintMultiAsset sbe AutoBalance)
<*> optional pInvalidBefore
<*> pInvalidHereafter sbe
<*> many (pCertificateFile AutoBalance)
<*> many (pWithdrawal AutoBalance)
<*> many (pCertificateFile sbe AutoBalance)
<*> many (pWithdrawal sbe AutoBalance)
<*> pTxMetadataJsonSchema
<*> many
( pScriptFor
Expand Down Expand Up @@ -232,18 +232,18 @@ pTransactionBuildEstimateCmd era _envCli = do
<*> optional pNumberOfByronKeyWitnesses
<*> pProtocolParamsFile
<*> pTotalUTxOValue
<*> some (pTxIn ManualBalance)
<*> some (pTxIn sbe ManualBalance)
<*> many pReadOnlyReferenceTxIn
<*> many pRequiredSigner
<*> many pTxInCollateral
<*> optional pReturnCollateral
<*> many pTxOut
<*> pChangeAddress
<*> optional (pMintMultiAsset ManualBalance)
<*> optional (pMintMultiAsset sbe ManualBalance)
<*> optional pInvalidBefore
<*> pInvalidHereafter sbe
<*> many (pCertificateFile ManualBalance)
<*> many (pWithdrawal ManualBalance)
<*> many (pCertificateFile sbe ManualBalance)
<*> many (pWithdrawal sbe ManualBalance)
<*> optional pTotalCollateral
<*> optional pReferenceScriptSize
<*> pTxMetadataJsonSchema
Expand Down Expand Up @@ -275,19 +275,19 @@ pTransactionBuildRaw era =
fmap TransactionBuildRawCmd $
TransactionBuildRawCmdArgs era
<$> optional pScriptValidity
<*> some (pTxIn ManualBalance)
<*> some (pTxIn era ManualBalance)
<*> many pReadOnlyReferenceTxIn
<*> many pTxInCollateral
<*> optional pReturnCollateral
<*> optional pTotalCollateral
<*> many pRequiredSigner
<*> many pTxOut
<*> optional (pMintMultiAsset ManualBalance)
<*> optional (pMintMultiAsset era ManualBalance)
<*> optional pInvalidBefore
<*> pInvalidHereafter era
<*> pTxFee
<*> many (pCertificateFile ManualBalance)
<*> many (pWithdrawal ManualBalance)
<*> many (pCertificateFile era ManualBalance)
<*> many (pWithdrawal era ManualBalance)
<*> pTxMetadataJsonSchema
<*> many (pScriptFor "auxiliary-script-file" Nothing "Filepath of auxiliary script(s)")
<*> many pMetadataFile
Expand Down
16 changes: 8 additions & 8 deletions cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,19 @@ pTransaction envCli =
<*> pNetworkId envCli
<*> optional pScriptValidity
<*> optional pWitnessOverride
<*> some (pTxIn AutoBalance)
<*> some (pTxIn ShelleyBasedEraConway AutoBalance)
<*> many pReadOnlyReferenceTxIn
<*> many pRequiredSigner
<*> many pTxInCollateral
<*> optional pReturnCollateral
<*> optional pTotalCollateral
<*> many pTxOut
<*> pChangeAddress
<*> optional (pMintMultiAsset AutoBalance)
<*> optional (pMintMultiAsset ShelleyBasedEraConway AutoBalance)
<*> optional pInvalidBefore
<*> optional pLegacyInvalidHereafter
<*> many (pCertificateFile AutoBalance)
<*> many (pWithdrawal AutoBalance)
<*> many (pCertificateFile ShelleyBasedEraConway AutoBalance)
<*> many (pWithdrawal ShelleyBasedEraConway AutoBalance)
<*> pTxMetadataJsonSchema
<*> many
( pScriptFor
Expand Down Expand Up @@ -395,19 +395,19 @@ pTransaction envCli =
TransactionBuildRawCmd
<$> pLegacyCardanoEra envCli
<*> optional pScriptValidity
<*> some (pTxIn ManualBalance)
<*> some (pTxIn ShelleyBasedEraConway ManualBalance)
<*> many pReadOnlyReferenceTxIn
<*> many pTxInCollateral
<*> optional pReturnCollateral
<*> optional pTotalCollateral
<*> many pRequiredSigner
<*> many pTxOut
<*> optional (pMintMultiAsset ManualBalance)
<*> optional (pMintMultiAsset ShelleyBasedEraConway ManualBalance)
<*> optional pInvalidBefore
<*> optional pLegacyInvalidHereafter
<*> pTxFee
<*> many (pCertificateFile ManualBalance)
<*> many (pWithdrawal ManualBalance)
<*> many (pCertificateFile ShelleyBasedEraConway ManualBalance)
<*> many (pWithdrawal ShelleyBasedEraConway ManualBalance)
<*> pTxMetadataJsonSchema
<*> many (pScriptFor "auxiliary-script-file" Nothing "Filepath of auxiliary script(s)")
<*> many pMetadataFile
Expand Down
3 changes: 2 additions & 1 deletion cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ renderScriptDataError = \case
readScriptDatumOrFile
:: ScriptDatumOrFile witctx
-> ExceptT ScriptDataError IO (ScriptDatum witctx)
readScriptDatumOrFile (ScriptDatumOrFileForTxIn df) =
readScriptDatumOrFile (ScriptDatumOrFileForTxIn Nothing) = pure $ ScriptDatumForTxIn Nothing
readScriptDatumOrFile (ScriptDatumOrFileForTxIn (Just df)) =
ScriptDatumForTxIn . Just
<$> readScriptDataOrFile df
readScriptDatumOrFile InlineDatumPresentAtTxIn = pure InlineScriptDatum
Expand Down
Loading

0 comments on commit 2780429

Please sign in to comment.