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

Add 'Convert Experimental.Era MaryEraOnwards' instance #701

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cardano-api/internal/Cardano/Api/Experimental/Eras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ where

import Cardano.Api.Eon.BabbageEraOnwards
import Cardano.Api.Eon.Convert
import Cardano.Api.Eon.MaryEraOnwards
import Cardano.Api.Eon.ShelleyBasedEra (ShelleyBasedEra (..), ShelleyLedgerEra)
import qualified Cardano.Api.Eras as Api
import Cardano.Api.Eras.Core (BabbageEra, ConwayEra, Eon (..))
Expand Down Expand Up @@ -201,6 +202,11 @@ instance Convert Era ShelleyBasedEra where
BabbageEra -> ShelleyBasedEraBabbage
ConwayEra -> ShelleyBasedEraConway

instance Convert Era MaryEraOnwards where
Copy link
Contributor

Choose a reason for hiding this comment

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

This is indicative of a deeper cardano-api issue. We should not be converting to the "old api".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but this is required until we fully separate the old and new apis right?

And we already do that anyway (on master at the time I'm writing this):

instance Convert Era Api.CardanoEra where

Copy link
Contributor Author

@smelc smelc Dec 11, 2024

Choose a reason for hiding this comment

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

@Jimbo4350> The issue is as follows right now:

Here (within the implementation of transaction build-estimate): https://github.com/IntersectMBO/cardano-cli/blob/3c0af7a8088b7c885ddc3c5c03734f2a2d5577cb/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L509

We call API's estimateBalancedTxBody:

And the thing is that transaction build-estimate takes an experimental witness, whereas estimateBalancedTxBody expects a MaryEraOnwards witness.

So I'm not sure how you want to fix that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just convert @BabbageEraOnwards . convert instead of adding a new instance?

Otherwise we will en up with N! instances for converting between eons. That's a lot of duplicated boilerplate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed thank you @carbolymer, I modified the CLI here accordingly, to avoid the additional instance: IntersectMBO/cardano-cli#1004

convert = \case
BabbageEra -> MaryEraOnwardsBabbage
ConwayEra -> MaryEraOnwardsConway

instance Convert Era BabbageEraOnwards where
convert = \case
BabbageEra -> BabbageEraOnwardsBabbage
Expand Down
Loading