-
Notifications
You must be signed in to change notification settings - Fork 15
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
Initial Byron isolation 1 of n #450
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
26a2327
Propagate removal of ByronOnlyEra era from ...
Jimbo4350 9113dfb
runTransactionCalculateMinValueCmd was never Byron compatible
Jimbo4350 31ad919
Propagate minimum value calculation changes
Jimbo4350 d756cab
Return collateral only makes sense in the context of a ShelleyBasedEra
Jimbo4350 b1fcca9
Propagate changes related to removing support for specifying a byron
Jimbo4350 74f5a76
SRP: Remove me
Jimbo4350 ba4a419
Update golden tests
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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DuplicateRecordFields #-} | ||
{-# LANGUAGE EmptyCase #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
|
@@ -164,7 +165,7 @@ runTransactionBuildCmd | |
_ -> pure TxUpdateProposalNone | ||
|
||
requiredSigners <- mapM (firstExceptT TxCmdRequiredSignerError . newExceptT . readRequiredSigner) reqSigners | ||
mReturnCollateral <- forM mReturnColl $ toTxOutInAnyEra era | ||
mReturnCollateral <- forM mReturnColl $ toTxOutInShelleyBasedEra eon | ||
|
||
txOuts <- mapM (toTxOutInAnyEra era) txouts | ||
|
||
|
@@ -319,7 +320,11 @@ runTransactionBuildRawCmd | |
_ -> pure TxUpdateProposalNone | ||
|
||
requiredSigners <- mapM (firstExceptT TxCmdRequiredSignerError . newExceptT . readRequiredSigner) reqSigners | ||
mReturnCollateral <- forM mReturnColl $ toTxOutInAnyEra eon | ||
|
||
mReturnCollateral <- forEraInEon eon (pure Nothing) $ \sbe -> | ||
forM mReturnColl $ toTxOutInShelleyBasedEra sbe | ||
|
||
-- NB: We need to be able to construct txs in Byron to other Byron addresses | ||
txOuts <- mapM (toTxOutInAnyEra eon) txouts | ||
|
||
-- the same collateral input can be used for several plutus scripts | ||
|
@@ -690,6 +695,14 @@ toAddressInAnyEra era addrAny = runExcept $ do | |
pure (AddressInEra (ShelleyAddressInEra sbe) sAddr) | ||
|
||
|
||
toAddressInShelleyBasedEra | ||
:: ShelleyBasedEra era | ||
-> Address ShelleyAddr | ||
-> Either TxCmdError (AddressInEra era) | ||
toAddressInShelleyBasedEra sbe sAddr = runExcept $ | ||
pure (AddressInEra (ShelleyAddressInEra sbe) sAddr) | ||
|
||
|
||
lovelaceToCoin :: Lovelace -> Ledger.Coin | ||
lovelaceToCoin (Lovelace ll) = Ledger.Coin ll | ||
|
||
|
@@ -698,10 +711,10 @@ toTxOutValueInAnyEra | |
-> Value | ||
-> Either TxCmdError (TxOutValue era) | ||
toTxOutValueInAnyEra era val = | ||
caseByronOrShelleyBasedEra | ||
(\w -> | ||
caseByronOrShelleyBasedEra | ||
(const $ | ||
case valueToLovelace val of | ||
Just l -> return (TxOutValueByron w l) | ||
Just l -> return (TxOutValueByron l) | ||
Nothing -> txFeatureMismatchPure era TxFeatureMultiAssetOutputs | ||
) | ||
(\sbe -> | ||
|
@@ -715,7 +728,46 @@ toTxOutValueInAnyEra era val = | |
sbe | ||
) | ||
era | ||
toTxOutValueInShelleyBasedEra | ||
:: ShelleyBasedEra era | ||
-> Value | ||
-> Either TxCmdError (TxOutValue era) | ||
toTxOutValueInShelleyBasedEra sbe val = | ||
caseShelleyToAllegraOrMaryEraOnwards | ||
(\_ -> case valueToLovelace val of | ||
Just l -> return (TxOutValueShelleyBased sbe $ lovelaceToCoin l) | ||
Nothing -> txFeatureMismatchPure (toCardanoEra sbe) TxFeatureMultiAssetOutputs | ||
) | ||
(\w -> return (TxOutValueShelleyBased sbe (toLedgerValue w val)) | ||
) | ||
sbe | ||
|
||
|
||
toTxOutInShelleyBasedEra | ||
:: ShelleyBasedEra era | ||
-> TxOutShelleyBasedEra | ||
-> ExceptT TxCmdError IO (TxOut CtxTx era) | ||
toTxOutInShelleyBasedEra era (TxOutShelleyBasedEra addr' val' mDatumHash refScriptFp) = do | ||
addr <- hoistEither $ toAddressInShelleyBasedEra era addr' | ||
val <- hoistEither $ toTxOutValueInShelleyBasedEra era val' | ||
|
||
datum <- | ||
caseShelleyToMaryOrAlonzoEraOnwards | ||
(const (pure TxOutDatumNone)) | ||
(\wa -> toTxAlonzoDatum wa mDatumHash) | ||
era | ||
|
||
refScript <- inEonForEra | ||
(pure ReferenceScriptNone) | ||
(\wb -> getReferenceScript wb refScriptFp) | ||
(toCardanoEra era) | ||
|
||
pure $ TxOut addr val datum refScript | ||
|
||
|
||
-- TODO: toTxOutInAnyEra eventually will not be needed because | ||
-- byron related functionality will be treated | ||
-- separately | ||
toTxOutInAnyEra :: CardanoEra era | ||
-> TxOutAnyEra | ||
-> ExceptT TxCmdError IO (TxOut CtxTx era) | ||
|
@@ -735,37 +787,35 @@ toTxOutInAnyEra era (TxOutAnyEra addr' val' mDatumHash refScriptFp) = do | |
(const (pure ReferenceScriptNone)) | ||
(\wb -> getReferenceScript wb refScriptFp) | ||
era | ||
|
||
pure $ TxOut addr val datum refScript | ||
|
||
where | ||
getReferenceScript :: () | ||
=> BabbageEraOnwards era | ||
-> ReferenceScriptAnyEra | ||
-> ExceptT TxCmdError IO (ReferenceScript era) | ||
getReferenceScript w = \case | ||
ReferenceScriptAnyEraNone -> return ReferenceScriptNone | ||
ReferenceScriptAnyEra fp -> ReferenceScript w <$> firstExceptT TxCmdScriptFileError (readFileScriptInAnyLang fp) | ||
|
||
toTxAlonzoDatum :: () | ||
=> AlonzoEraOnwards era | ||
-> TxOutDatumAnyEra | ||
-> ExceptT TxCmdError IO (TxOutDatum CtxTx era) | ||
toTxAlonzoDatum supp cliDatum = | ||
case cliDatum of | ||
TxOutDatumByNone -> pure TxOutDatumNone | ||
TxOutDatumByHashOnly h -> pure (TxOutDatumHash supp h) | ||
TxOutDatumByHashOf sDataOrFile -> do | ||
sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile sDataOrFile | ||
pure (TxOutDatumHash supp $ hashScriptDataBytes sData) | ||
TxOutDatumByValue sDataOrFile -> do | ||
sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile sDataOrFile | ||
pure (TxOutDatumInTx supp sData) | ||
TxOutInlineDatumByValue sDataOrFile -> do | ||
let cEra = alonzoEraOnwardsToCardanoEra supp | ||
forEraInEon cEra (txFeatureMismatch cEra TxFeatureInlineDatums) $ \babbageOnwards -> do | ||
sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile sDataOrFile | ||
pure $ TxOutDatumInline babbageOnwards sData | ||
getReferenceScript :: () | ||
=> BabbageEraOnwards era | ||
-> ReferenceScriptAnyEra | ||
-> ExceptT TxCmdError IO (ReferenceScript era) | ||
getReferenceScript w = \case | ||
ReferenceScriptAnyEraNone -> return ReferenceScriptNone | ||
ReferenceScriptAnyEra fp -> ReferenceScript w <$> firstExceptT TxCmdScriptFileError (readFileScriptInAnyLang fp) | ||
|
||
toTxAlonzoDatum :: () | ||
=> AlonzoEraOnwards era | ||
-> TxOutDatumAnyEra | ||
-> ExceptT TxCmdError IO (TxOutDatum CtxTx era) | ||
toTxAlonzoDatum supp cliDatum = | ||
case cliDatum of | ||
TxOutDatumByNone -> pure TxOutDatumNone | ||
TxOutDatumByHashOnly h -> pure (TxOutDatumHash supp h) | ||
TxOutDatumByHashOf sDataOrFile -> do | ||
sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile sDataOrFile | ||
pure (TxOutDatumHash supp $ hashScriptDataBytes sData) | ||
TxOutDatumByValue sDataOrFile -> do | ||
sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile sDataOrFile | ||
pure (TxOutDatumInTx supp sData) | ||
TxOutInlineDatumByValue sDataOrFile -> do | ||
let cEra = alonzoEraOnwardsToCardanoEra supp | ||
forEraInEon cEra (txFeatureMismatch cEra TxFeatureInlineDatums) $ \babbageOnwards -> do | ||
sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile sDataOrFile | ||
pure $ TxOutDatumInline babbageOnwards sData | ||
|
||
-- TODO: Currently we specify the policyId with the '--mint' option on the cli | ||
-- and we added a separate '--policy-id' parser that parses the policy id for the | ||
|
@@ -1023,14 +1073,14 @@ runTransactionCalculateMinValueCmd | |
, txOut | ||
} = do | ||
pp <- firstExceptT TxCmdProtocolParamsError (readProtocolParameters protocolParamsFile) | ||
out <- toTxOutInAnyEra eon txOut | ||
out <- toTxOutInShelleyBasedEra eon txOut | ||
-- TODO: shouldn't we just require shelley based era here instead of error-ing for byron? | ||
forEraInEon eon (error "runTransactionCalculateMinValueCmd: Byron era not implemented yet") $ \sbe -> do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Byron was never supported There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
firstExceptT TxCmdPParamsErr . hoistEither | ||
$ checkProtocolParameters sbe pp | ||
pp' <- hoistEither . first TxCmdProtocolParamsConverstionError $ toLedgerPParams sbe pp | ||
let minValue = calculateMinimumUTxO sbe out pp' | ||
liftIO . IO.print $ minValue | ||
|
||
firstExceptT TxCmdPParamsErr . hoistEither | ||
$ checkProtocolParameters eon pp | ||
pp' <- hoistEither . first TxCmdProtocolParamsConverstionError $ toLedgerPParams eon pp | ||
let minValue = calculateMinimumUTxO eon out pp' | ||
liftIO . IO.print $ minValue | ||
|
||
runTransactionPolicyIdCmd :: () | ||
=> Cmd.TransactionPolicyIdCmdArgs | ||
|
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to not need
caseByronOrShelleyBasedEra
in the future. Required byron based functionality will be hard coded and available under thebyron
command group.