-
Notifications
You must be signed in to change notification settings - Fork 23
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
Single TxOutValue
constructor
#366
Conversation
@@ -59,6 +61,8 @@ import qualified Data.Text as Text | |||
import Data.Type.Equality (TestEquality (..), (:~:) (Refl)) | |||
import Data.Typeable (Typeable, showsTypeRep, typeOf) | |||
|
|||
type instance L.Value (L.ByronEra _c) = L.Coin |
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.
This is the only ledger adapter we need to unify all the constructors in TxOutValue
.
This can be moved into ledger if it would be accepted. Otherwise it can stay here as it is only one line.
. showString "TxOutValue " | ||
. showsPrec 11 era | ||
. showString " " | ||
. showsPrec 11 v |
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.
We can rely on CardanoEra
argument and cardanoEraConstraints
to implement instances so there isn't a need to carry any additional constraints in the constructors.
a07e6e4
to
fca1c36
Compare
data TxOutValue era = | ||
TxOutValue | ||
(CardanoEra era) | ||
(L.Value (LedgerEra era)) |
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.
We now only have one constructor spanning all eras which also means we don't need a GADT.
fca1c36
to
198666a
Compare
(\w -> TxOutValueByron w ll) | ||
(\w -> TxOutValueShelleyBased w $ A.mkAdaValue w $ lovelaceToCoin ll) | ||
era | ||
TxOutValue era $ A.mkAdaValue era $ lovelaceToCoin ll |
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 unification means that as long as client keeps to lens to access the ADA asset (not the multi-asset feature), no constraints summoning nor casing is necessary.
|
||
TxOut (AddressInEra ByronAddressInAnyEra (ByronAddress _)) (TxOutValueShelleyBased w _) _ _ -> case w of {} |
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 unification means some cases like this go away.
198666a
to
12a3bca
Compare
@@ -3099,10 +3084,7 @@ toShelleyTxOutAny :: forall ctx era ledgerera. | |||
-> TxOut ctx era | |||
-> Ledger.TxOut ledgerera | |||
toShelleyTxOutAny sbe = \case | |||
TxOut _ (TxOutValueByron ByronEraOnlyByron _) _ _ -> | |||
case sbe of {} |
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 unification means some cases like this go away.
@@ -697,11 +695,8 @@ toShelleyTxOut :: forall era ledgerera. | |||
=> ShelleyBasedEra era | |||
-> TxOut CtxUTxO era | |||
-> Ledger.TxOut ledgerera | |||
toShelleyTxOut sbe = \case -- jky simplify | |||
TxOut _ (TxOutValueByron ByronEraOnlyByron _) _ _ -> | |||
case sbe of {} |
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.
Unification means empty cases like this go away.
TxOut (AddressInEra ByronAddressInAnyEra (ByronAddress addr)) (TxOutValueByron _ value) _ _ -> | ||
Byron.TxOut addr <$> toByronLovelace value | ||
TxOut (AddressInEra ByronAddressInAnyEra (ByronAddress _)) (TxOutValueShelleyBased w _) _ _ -> | ||
case w of {} |
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.
Unification means empty cases like this go away.
ad68950
to
728c769
Compare
TxOutValue
constructor
728c769
to
7b6ca66
Compare
…es-for-governance-actions-commands Make `governance action create-protocol-parameters-update` Conway onwards only
Changelog
Context
This builds on #361
Review without the first comment to ignore changes from #361.
The most substantive change here is that the
data TxOutValue
now only has one constructor which allows it to not be a GADT.The adjustment simplifies some code. For instance Byron is now unified with all other eras and casing is only necessary when using era-specific features. Notably accessing the ADA asset feature can be uniform across all eras.
Not being a GADT also eliminates the need for some empty cases.
How to trust this PR
Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.
Checklist