Skip to content

Commit

Permalink
Merge pull request #967 from IntersectMBO/smelc/update-api-to-10.2.0.0
Browse files Browse the repository at this point in the history
Update cardano-api to 10.2.0.0
  • Loading branch information
smelc authored Nov 14, 2024
2 parents 31e628f + cb2f488 commit fb7950e
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository cardano-haskell-packages
-- you need to run if you change them
index-state:
, hackage.haskell.org 2024-10-11T15:49:11Z
, cardano-haskell-packages 2024-10-21T23:08:22Z
, cardano-haskell-packages 2024-11-12T08:40:13Z

packages:
cardano-cli
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ library
binary,
bytestring,
canonical-json,
cardano-api ^>=10.1,
cardano-api ^>=10.2,
cardano-binary,
cardano-crypto,
cardano-crypto-class ^>=2.1.2,
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ pNumberOfByronKeyWitnesses =

pTotalUTxOValue :: Parser Value
pTotalUTxOValue =
Opt.option (readerFromParsecParser parseValue) $
Opt.option (readerFromParsecParser $ parseValue RoleUTxO) $
mconcat
[ Opt.long "total-utxo-value"
, Opt.metavar "VALUE"
Expand Down Expand Up @@ -2136,7 +2136,7 @@ pMintMultiAsset
pMintMultiAsset sbe balanceExecUnits =
(,)
<$> Opt.option
(readerFromParsecParser parseValue)
(readerFromParsecParser $ parseValue RoleMint)
( Opt.long "mint"
<> Opt.metavar "VALUE"
<> Opt.help helpText
Expand Down Expand Up @@ -2194,7 +2194,7 @@ pMintMultiAsset sbe balanceExecUnits =

pPolicyId :: Parser PolicyId
pPolicyId =
Opt.option (readerFromParsecParser policyId) $
Opt.option (readerFromParsecParser parsePolicyId) $
mconcat
[ Opt.long "policy-id"
, Opt.metavar "HASH"
Expand Down Expand Up @@ -3308,7 +3308,7 @@ parseTxOutShelleyBasedEra = do
-- Accept the old style of separating the address and value in a
-- transaction output:
Parsec.option () (Parsec.char '+' >> Parsec.spaces)
val <- parseValue
val <- parseValue RoleUTxO -- UTxO role works for transaction output
return (TxOutShelleyBasedEra addr val)

parseShelleyAddress :: Parsec.Parser (Address ShelleyAddr)
Expand All @@ -3326,7 +3326,7 @@ parseTxOutAnyEra = do
-- Accept the old style of separating the address and value in a
-- transaction output:
Parsec.option () (Parsec.char '+' >> Parsec.spaces)
val <- parseValue
val <- parseValue RoleUTxO -- UTxO role works for transaction output
return (TxOutAnyEra addr val)

--------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ toTxAlonzoDatum supp cliDatum =
pure (TxOutDatumHash supp $ hashScriptDataBytes sData)
TxOutDatumByValue sDataOrFile -> do
sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile sDataOrFile
pure (TxOutDatumInTx supp sData)
pure (TxOutSupplementalDatum supp sData)
TxOutInlineDatumByValue sDataOrFile -> do
let cEra = toCardanoEra supp
forEraInEon cEra (txFeatureMismatch cEra TxFeatureInlineDatums) $ \babbageOnwards -> do
Expand Down
17 changes: 1 addition & 16 deletions cardano-cli/src/Cardano/CLI/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ friendlyTxBodyImpl
txValidityUpperBound
txMetadata
txAuxScripts
txSupplementalData
txExtraKeyWits
_txProtocolParams
txWithdrawals
Expand Down Expand Up @@ -252,10 +251,6 @@ friendlyTxBodyImpl
era
(`getRedeemerDetails` tb)
)
++ ( monoidForEraInEon @AlonzoEraOnwards
era
(`friendlySupplementalDatums` txSupplementalData)
)
++ ( monoidForEraInEon @ConwayEraOnwards
era
( \cOnwards ->
Expand Down Expand Up @@ -293,16 +288,6 @@ friendlyTxBodyImpl
friendlyLedgerProposals cOnwards proposalProcedures =
Array $ fromList $ map (friendlyLedgerProposal cOnwards) proposalProcedures

-- | API doesn't yet show that supplemental datums are alonzo onwards. So we do it in this function prototype,
-- even if we don't use the witness.
friendlySupplementalDatums
:: AlonzoEraOnwards era -> BuildTxWith build (TxSupplementalDatums era) -> [Aeson.Pair]
friendlySupplementalDatums _era = \case
ViewTx -> []
BuildTxWith TxSupplementalDataNone -> []
BuildTxWith (TxSupplementalDatums hashableScriptDatas) ->
["supplemental datums" .= toJSON hashableScriptDatas]

friendlyLedgerProposal
:: ConwayEraOnwards era -> L.ProposalProcedure (ShelleyLedgerEra era) -> Aeson.Value
friendlyLedgerProposal cOnwards proposalProcedure = object $ friendlyProposalImpl cOnwards (Proposal proposalProcedure)
Expand Down Expand Up @@ -483,7 +468,7 @@ friendlyTxOut era (TxOut addr amount mdatum script) =
renderDatum = \case
TxOutDatumNone -> Nothing
TxOutDatumHash _ h -> Just $ toJSON h
TxOutDatumInTx _ sData -> Just $ scriptDataToJson ScriptDataJsonDetailedSchema sData
TxOutSupplementalDatum _ sData -> Just $ scriptDataToJson ScriptDataJsonDetailedSchema sData
TxOutDatumInline _ sData -> Just $ scriptDataToJson ScriptDataJsonDetailedSchema sData

friendlyStakeReference :: StakeAddressReference -> Aeson.Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,52 @@ hprop_conway_transaction_build_one_voter_many_votes = propertyOnce $ H.moduleWor

exitCode H.=== ExitFailure 1
H.assertWith stderr ("This would cause ignoring some of the votes" `isInfixOf`)

-- | This is a test of https://github.com/IntersectMBO/cardano-cli/issues/904
-- Execute me with:
-- @cabal test cardano-cli-test --test-options '-p "/conway transaction build raw negative txout/"'@
hprop_conway_transaction_build_raw_negative_txout :: Property
hprop_conway_transaction_build_raw_negative_txout = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
outFile <- H.noteTempFile tempDir "tx.traw"

(exitCode, _stdout, stderr) <-
H.noteShowM $
execDetailCardanoCLI
[ "conway"
, "transaction"
, "build-raw"
, "--fee"
, "200000"
, "--tx-in"
, "e25450233e4bedd00c8bda15c48c2d4018223bd88271e194052294c4e5be7d55#0"
, "--tx-out"
, "addr_test1vqfxq2s8yce3tuhjq9ulu2awuk623hzvtft9z8fh6qelzts49vuqw+-1" -- This is the negative txout
, "--out-file"
, outFile
]

exitCode H.=== ExitFailure 1
H.assertWith stderr ("Value must be positive in UTxO (or transaction output)" `isInfixOf`)

-- | This is a test that we allow transaction outputs to contain negative bits, if
-- the grand total is positive.
-- @cabal test cardano-cli-test --test-options '-p "/conway transaction build raw negative bits positive total txout/"'@
hprop_conway_transaction_build_raw_negative_bits_positive_total_txout :: Property
hprop_conway_transaction_build_raw_negative_bits_positive_total_txout = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
outFile <- H.noteTempFile tempDir "tx.traw"

-- This checks that the command succeeds
H.noteShowM_ $
execCardanoCLI
[ "conway"
, "transaction"
, "build-raw"
, "--fee"
, "200000"
, "--tx-in"
, "e25450233e4bedd00c8bda15c48c2d4018223bd88271e194052294c4e5be7d55#0"
, "--tx-out"
, "addr_test1vqfxq2s8yce3tuhjq9ulu2awuk623hzvtft9z8fh6qelzts49vuqw+-1+3" -- Negative txout (-1) summed with positive txout (+3), so total is positive
, "--out-file"
, outFile
]
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb7950e

Please sign in to comment.