-
Notifications
You must be signed in to change notification settings - Fork 213
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-416] Allow multiple well-formed values in "/Cardano.Wallet.Api/"… #2085
[ADP-416] Allow multiple well-formed values in "/Cardano.Wallet.Api/"… #2085
Conversation
@@ -150,7 +150,9 @@ instance Malformed (PathParam ApiTxId) where | |||
msg = "Invalid tx hash: expecting a hex-encoded value that is 32 bytes in length." | |||
|
|||
instance Wellformed (PathParam ApiPoolId) where | |||
wellformed = PathParam $ T.replicate 64 "0" | |||
wellformed = PathParam <$> | |||
[ T.replicate 64 "0" |
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 where the bech32 wellformed would go
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.
Looks pretty good so far. 👍
Just a couple of requested changes, and a few suggestions. (See comments!)
ee2942c
to
a9d46b3
Compare
659566f
to
67e684a
Compare
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.
Hi @hasufell
This looks good to me. Thanks for addressing the previous feedback! (See comments.) 👍
I suspect @KtorZ will also have an opinion on this approach (judging by #2055 (comment)), so it would be good to get confirmation from him, if you can!
|
||
|
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.
Some minor remarks about consistency and readability that I fixed in a commit.
Nice work dealing with this, hope you didn't caught a headache 😬
@@ -218,31 +218,38 @@ instance (GenericApiSpec a, GenericApiSpec b) => GenericApiSpec (a :<|> b) where | |||
instance GenericApiSpec Request where | |||
gSpec _ _ = pure () | |||
|
|||
instance GenericApiSpec a => GenericApiSpec [a] where | |||
gSpec xs toSpec = foldr (\x y -> gSpec x toSpec >> y) (pure ()) xs |
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 mistakenly expected a foldl here but no, foldr is right because of the composition of actions done as such 👍
toSpec . SomeTest (Proxy @a) =<< traverseLeft runIO tests | ||
let tests :: [(IO [Request], ExpectedError)] | ||
tests = first toRequest <$> malformed @(BodyParam a) | ||
toSpec . SomeTest (Proxy @a) . insideOut =<< traverseLeft runIO tests |
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.
👍
SomeTest (Proxy @h) (first toRequest <$> malformed @(Header h ct)) | ||
gSpec toRequest toSpec = do | ||
let tests = fmap (\(xs, e) -> fmap (,e) xs) | ||
(first toRequest <$> malformed @(Header h ct)) |
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 find the insideOut
version with the list comprehension much more readable
where | ||
t = wellformed :: PathParam t | ||
t = wellformed :: [PathParam t] |
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.
Would be better to stick to a consistent naming like ts
before. These things are actually the same thing so they ought to have the same name.
bors r+ |
I did... and I completely forgot everything I did 🤣 so don't ask me anything about this code. |
@@ -565,6 +579,9 @@ instance | |||
-- Helpers | |||
-- | |||
|
|||
distributeFirst :: [([x], y)] -> [(x, y)] |
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.
Thanks... I wasn't able to come up with a sensible name.
The downside is that this won't inline in something like fmap distributeFirst xs
. But I don't think there's anything performance critical about it.
Build succeeded |
Related: #2055 (comment)
Test log shows that it tries both variants of pool id encodings when combined with #2055