Skip to content
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

Make Byron constructors and functions propagate ByronEraOnly eon. Delete CardanoEraStyle #335

Conversation

newhoggy
Copy link
Collaborator

@newhoggy newhoggy commented Oct 22, 2023

Changelog

- description: |
    In `Tx`, `ByronTx` now carries additional `ByronEraOnly` witness
    In `TxBody`, `TxBodyByron` now carries additional `ByronEraOnly` witness
    Delete `CardanoEraStyle` because eons solve the same problem more generally
    Delete `cardanoEraStyle`
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - improvement    # QoL changes e.g. refactoring
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Modify Byron constructors and functions propagate ByronEraOnly eon because that makes the code more compatible with eon support.

Delete CardanoEraStyle because it is unnecessary as eons solve the same problem more generally.

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

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@@ -101,8 +102,9 @@ import Lens.Micro
data Tx era where

ByronTx
:: Byron.ATxAux ByteString
-> Tx ByronEra
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere, instead of using ByronEra directly, we leave it parameterised and add a eon witness to prove it is Byron. This makes the code compatible with eon support.

@@ -671,23 +671,23 @@ instance IsShelleyBasedEra era => FromJSON (TxOut CtxUTxO era) where
<*> return (TxOutDatumHash w dHash)
<*> return ReferenceScriptNone

fromByronTxOut :: Byron.TxOut -> TxOut ctx ByronEra
fromByronTxOut (Byron.TxOut addr value) =
fromByronTxOut :: ByronEraOnly era -> Byron.TxOut -> TxOut ctx era
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere, instead of using ByronEra directly, we leave it parameterised and add a eon witness to prove it is Byron. This makes the code compatible with eon support.

-> TxBody ByronEra
:: ByronEraOnly era
-> Annotated Byron.Tx ByteString
-> TxBody era
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere, instead of using ByronEra directly, we leave it parameterised and add a eon witness to prove it is Byron. This makes the code compatible with eon support.

getByronTxBodyContent :: ()
=> ByronEraOnly era
-> Annotated Byron.Tx ByteString
-> TxBodyContent ViewTx era
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere, instead of using ByronEra directly, we leave it parameterised and add a eon witness to prove it is Byron. This makes the code compatible with eon support.

(TxOutAdaOnly ByronToAllegraEraByron value) _ _)
| value < 0 = TxBodyOutputNegative (lovelaceToQuantity value) (txOutInAnyEra ByronEra txout)
| otherwise = TxBodyOutputOverflow (lovelaceToQuantity value) (txOutInAnyEra ByronEra txout)
classifyRangeError :: ByronEraOnly era -> TxOut CtxTx era -> TxBodyError
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere, instead of using ByronEra directly, we leave it parameterised and add a eon witness to prove it is Byron. This makes the code compatible with eon support.

makeByronTransactionBody :: ()
=> ByronEraOnly era
-> TxBodyContent BuildTx era
-> Either TxBodyError (TxBody era)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere, instead of using ByronEra directly, we leave it parameterised and add a eon witness to prove it is Byron. This makes the code compatible with eon support.

TxOut
(AddressInEra ByronAddressInAnyEra (ByronAddress addr))
(TxOutAdaOnly ByronToAllegraEraByron (fromByronLovelace value))
TxOutDatumNone ReferenceScriptNone


toByronTxOut :: TxOut ctx ByronEra -> Maybe Byron.TxOut
toByronTxOut (TxOut (AddressInEra ByronAddressInAnyEra (ByronAddress addr))
toByronTxOut :: ByronEraOnly era -> TxOut ctx era -> Maybe Byron.TxOut
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere, instead of using ByronEra directly, we leave it parameterised and add a eon witness to prove it is Byron. This makes the code compatible with eon support.

@newhoggy newhoggy changed the title Make Byron constructors and functions propagate ByronEraOnly eon Make Byron constructors and functions propagate ByronEraOnly eon. Delete CardanoEraStyle Oct 22, 2023
@newhoggy newhoggy marked this pull request as ready for review October 22, 2023 05:22
@newhoggy newhoggy force-pushed the newhoggy/make-byron-constructor-and-functions-propagate-ByronEraOnly branch from 94f6b4f to 3edfb23 Compare October 28, 2023 07:25
@newhoggy newhoggy added this pull request to the merge queue Oct 28, 2023
Merged via the queue into main with commit dd6369b Oct 28, 2023
20 checks passed
@newhoggy newhoggy deleted the newhoggy/make-byron-constructor-and-functions-propagate-ByronEraOnly branch October 28, 2023 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants