-
Notifications
You must be signed in to change notification settings - Fork 214
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
[ADP-3359] Simplify construction of API errors relating to recent eras. #4603
Conversation
This commit adjusts the golden file for `ApiError.json` so that `supported_recent_eras` fields: - do not include duplicate eras - list eras in alphabetic order This is necessary, as the Haskell type for this field has changed from a list to a `Set`, which changes the behaviour of the generator for the `ApiErrorNodeNotYetInRecentEra` data type.
52a29bf
to
e7481b6
Compare
@@ -463,13 +471,21 @@ instance Bounded AnyRecentEra where | |||
minBound = AnyRecentEra RecentEraBabbage | |||
maxBound = AnyRecentEra RecentEraConway | |||
|
|||
instance Ord AnyRecentEra where | |||
compare = compare `on` fromEnum |
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 instance is needed in order to have a Set AnyRecentEra
.
instance Show AnyRecentEra where | ||
show (AnyRecentEra era) = "AnyRecentEra " <> show era | ||
|
||
instance Eq AnyRecentEra where | ||
AnyRecentEra e1 == AnyRecentEra e2 = | ||
isJust $ testEquality e1 e2 | ||
|
||
-- | The complete set of supported recent eras. | ||
-- | ||
supportedRecentEras :: Set AnyRecentEra |
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.
supportedRecentEras
What would an unsupported recent era be?
It seems like it's saying the same things twice. I.e. could it be more suitable to name it allRecentEras
or supportedErasForTxConstruction
(the latter more for the api, not here) ?
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.
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.
👍 (I think the api
is the wrong place for computations, but this is not relevant for the refactoring)
In response to review feedback: #4603 (comment)
I agree with you! Though hopefully this refactoring goes in the right direction: the definition of the set of recent eras is now in the |
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 PR:
recentEras :: Set AnyRecentEra
ApiErrorNodeNotYetInRecentEra
ApiErrorUnsupportedEra
Issue
ADP-3359
Follow-on from #4595.