Skip to content

Commit

Permalink
Adjust to txValidityRange split into lower and upper bound
Browse files Browse the repository at this point in the history
  • Loading branch information
teodanciu committed Oct 27, 2023
1 parent 6faaa49 commit 2f756fd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
12 changes: 4 additions & 8 deletions cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,8 @@ txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs = do
, txTotalCollateral = TxTotalCollateralNone
, txReturnCollateral = TxReturnCollateralNone
, txFee = TxFeeImplicit ByronEraOnlyByron
, txValidityRange =
( TxValidityNoLowerBound
, defaultTxValidityUpperBound ByronEra
)
, txValidityLowerBound = TxValidityNoLowerBound
, txValidityUpperBound = defaultTxValidityUpperBound ByronEra
, txMetadata = TxMetadataNone
, txAuxScripts = TxAuxScriptsNone
, txExtraKeyWits = TxExtraKeyWitnessesNone
Expand Down Expand Up @@ -207,10 +205,8 @@ txSpendUTxOByronPBFT nId sk txIns outs = do
, txTotalCollateral = TxTotalCollateralNone
, txReturnCollateral = TxReturnCollateralNone
, txFee = TxFeeImplicit ByronEraOnlyByron
, txValidityRange =
( TxValidityNoLowerBound
, defaultTxValidityUpperBound ByronEra
)
, txValidityLowerBound = TxValidityNoLowerBound
, txValidityUpperBound = defaultTxValidityUpperBound ByronEra
, txMetadata = TxMetadataNone
, txAuxScripts = TxAuxScriptsNone
, txExtraKeyWits = TxExtraKeyWitnessesNone
Expand Down
16 changes: 10 additions & 6 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,10 @@ runTxBuildRaw era
<- first TxCmdReturnCollateralValidationError $ validateTxReturnCollateral era mReturnCollateral
validatedFee
<- first TxCmdTxFeeValidationError $ validateTxFee era mFee
validatedBounds <- (,) <$> first TxCmdTxValidityLowerBoundValidationError (validateTxValidityLowerBound era mLowerBound)
<*> first TxCmdTxValidityUpperBoundValidationError (validateTxValidityUpperBound era mUpperBound)
validatedLowerBound
<- first TxCmdTxValidityLowerBoundValidationError (validateTxValidityLowerBound era mLowerBound)
validatedUpperBound
<- first TxCmdTxValidityUpperBoundValidationError (validateTxValidityUpperBound era mUpperBound)
validatedReqSigners
<- first TxCmdRequiredSignersValidationError $ validateRequiredSigners era reqSigners
validatedPParams
Expand All @@ -443,7 +445,8 @@ runTxBuildRaw era
, txTotalCollateral = validatedTotCollateral
, txReturnCollateral = validatedRetCol
, txFee = validatedFee
, txValidityRange = validatedBounds
, txValidityLowerBound = validatedLowerBound
, txValidityUpperBound = validatedUpperBound
, txMetadata = txMetadata
, txAuxScripts = txAuxScripts
, txExtraKeyWits = validatedReqSigners
Expand Down Expand Up @@ -528,8 +531,8 @@ runTxBuild
validatedRetCol
<- hoistEither $ first TxCmdReturnCollateralValidationError $ validateTxReturnCollateral era mReturnCollateral
dFee <- hoistEither $ first TxCmdTxFeeValidationError $ validateTxFee era dummyFee
validatedBounds <- (,) <$> hoistEither (first TxCmdTxValidityLowerBoundValidationError $ validateTxValidityLowerBound era mLowerBound)
<*> hoistEither (first TxCmdTxValidityUpperBoundValidationError $ validateTxValidityUpperBound era mUpperBound)
validatedLowerBound <- hoistEither (first TxCmdTxValidityLowerBoundValidationError (validateTxValidityLowerBound era mLowerBound))
validatedUpperBound <- hoistEither (first TxCmdTxValidityUpperBoundValidationError (validateTxValidityUpperBound era mUpperBound))
validatedReqSigners <- hoistEither (first TxCmdRequiredSignersValidationError $ validateRequiredSigners era reqSigners)
validatedTxWtdrwls <- hoistEither (first TxCmdTxWithdrawalsValidationError $ validateTxWithdrawals era withdrawals)
validatedTxCerts <- hoistEither (first TxCmdTxCertificatesValidationError $ validateTxCertificates era certsAndMaybeScriptWits)
Expand Down Expand Up @@ -579,7 +582,8 @@ runTxBuild
, txTotalCollateral = validatedTotCollateral
, txReturnCollateral = validatedRetCol
, txFee = dFee
, txValidityRange = validatedBounds
, txValidityLowerBound = validatedLowerBound
, txValidityUpperBound = validatedUpperBound
, txMetadata = txMetadata
, txAuxScripts = txAuxScripts
, txExtraKeyWits = validatedReqSigners
Expand Down
7 changes: 4 additions & 3 deletions cardano-cli/src/Cardano/CLI/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ friendlyTxBodyImpl
, txReturnCollateral
, txInsReference
, txUpdateProposal
, txValidityRange
, txValidityLowerBound
,txValidityUpperBound
, txWithdrawals
}) =
[ "auxiliary scripts" .= friendlyAuxScripts txAuxScripts
Expand All @@ -169,7 +170,7 @@ friendlyTxBodyImpl
, "required signers (payment key hashes needed for scripts)" .=
friendlyExtraKeyWits txExtraKeyWits
, "update proposal" .= friendlyUpdateProposal txUpdateProposal
, "validity range" .= friendlyValidityRange era txValidityRange
, "validity range" .= friendlyValidityRange era (txValidityLowerBound, txValidityUpperBound)
, "withdrawals" .= friendlyWithdrawals txWithdrawals
]

Expand All @@ -190,7 +191,7 @@ friendlyExtraKeyWits = \case
-- | Special case of validity range:
-- in Shelley, upper bound is TTL, and no lower bound
pattern ShelleyTtl
:: SlotNo -> (TxValidityLowerBound era, TxValidityUpperBound era)
:: Maybe SlotNo -> (TxValidityLowerBound era, TxValidityUpperBound era)
pattern ShelleyTtl ttl <-
( TxValidityNoLowerBound
, TxValidityUpperBound _ ttl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ validateTxValidityUpperBound
validateTxValidityUpperBound era = \case
Just slot -> do
supported <- conjureWitness era TxValidityUpperBoundNotSupported
pure $ TxValidityUpperBound supported slot
pure $ TxValidityUpperBound supported (Just slot)
Nothing -> do
supported <- conjureWitness era TxValidityUpperBoundNotSupported
pure $ TxValidityNoUpperBound supported
Expand Down

0 comments on commit 2f756fd

Please sign in to comment.