-
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
Add forget pending transaction endpoint (Part1) #845
Conversation
data ErrForgetPendingTx | ||
= ErrForgetPendingTxNoSuchWallet ErrNoSuchWallet | ||
| ErrForgetPendingTxNoSuchTransaction ErrNoSuchTransaction | ||
| ErrForgetPendingTxTransactionIsNotPending (Hash "Tx") |
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.
Ah. Good point 😅
@@ -611,6 +614,23 @@ postExternalTransaction ctx (PostExternalTransactionData load) = do | |||
tx <- liftHandler $ W.submitExternalTx @ctx @t @k ctx load | |||
return $ ApiTxId (ApiT (txId @t tx)) | |||
|
|||
deleteTransaction | |||
:: forall ctx s t k. | |||
( s ~ SeqState 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.
I think s ~ SeqState t
is superfluous 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.
indeed, fixed
ErrForgetPendingTxTransactionIsNotPending tid -> | ||
apiError err404 TransactionNotPending $ mconcat | ||
[ "The transaction with id : ", pretty tid, | ||
"cannot be forgotten as it is not pending anymore." |
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'll need an extra blank space before "cannot" ☝️
ErrForgetPendingTxNoSuchTransaction e -> handler e | ||
ErrForgetPendingTxTransactionIsNotPending tid -> | ||
apiError err404 TransactionNotPending $ mconcat | ||
[ "The transaction with id : ", pretty tid, |
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.
pretty
will show a truncated transaction id, in the API response, we probably want to show the full id so I'd advise for toText
instead.
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.
good point - fixed
instance FromText ApiTxId where | ||
fromText txt = case fromText txt of | ||
Left err -> Left $ TextDecodingError $ show err | ||
Right tid -> Right $ ApiTxId $ ApiT tid |
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 FromText
instance is confusing here 🤔 (especially because we have to still do some conversion on top in parseUrlPiece
for the error).
I'd suggest to inline this with the definition in FromHttpApiData ApiTxId
and return the right error type directly.
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.
done
where | ||
fromText' txt = case fromText txt of | ||
Left err -> Left $ TextDecodingError $ show err | ||
Right tid -> Right $ ApiTxId $ ApiT tid |
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.
Suggestion:
instance FromHttpApiData ApiTxId where
parseUrlPiece txt = case fromText txt of
Left (TextDecodingError err) -> Left $ T.pack err
Right tid -> Right $ ApiTxId $ ApiT tid
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 good!
However, I have a question regarding naming. There seems to be some inconsistency:
- The endpoint operation name is called
deleteTransaction
(delete) - The response type is called
responsesDeleteTransaction
(delete) - The endpoint description is "forget pending transaction" (forget)
- The wallet layer function is called
forgetPendingTx
(forget) - The associated error functions are called
ErrForgetPendingTx...
(forget)
For consistency, is there any way we can pick one of these (either "delete" or "forget") and use that consistently throughout?
I think it would make the code easier to follow. What do you think?
@jonathanknowles I was thinking about it. So in order to follow REST API I would stick to DELETE, but underneath, like in |
I second @paweljakubas on this. |
b80eab9
to
e28d965
Compare
@KtorZ wrote:
Just to clarify, what is the motivation behind this? Is it to restrict ourselves to just the verbs that are HTTP verbs? We already seem to violate this principle in a few places. Consider the following API-level names:
|
…e the stuff through codebase
simplifying FromHttpApiData
e28d965
to
c65982c
Compare
rebased and resolved conflicts |
I am fine with both so long as naming is consistent although I find the former more readable (use of list). For Having said that, we are really neat-picking here. |
bors r+ |
👎 Rejected by too few approved reviews |
bors r+ |
834: DaedalusIPC: Fix isWindows function r=KtorZ a=rvl # Issue Number None. # Overview Fixes a typo in the OS detection code for NodeIPC. # Comments I again looked at the possibility of importing the cardano-shell package for this functionality. But it is pulling in more dependencies. Also the `daedalusIPC` function there had the logging replaced with `putTextLn`. Branch is [rvl/daedalus-ipc-cardano-shell](rvl/daedalus-ipc-fix...rvl/daedalus-ipc-cardano-shell) for reference though. 840: Make Jörmungandr NetworkLayer use raw blocks r=KtorZ a=Anviking # Issue Number #711 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] I changed the constructors in `Cardano.Wallet.Jormungandr.Network` to create NetworkLayers with raw jörmungadnr-specific blocks, and later used `toWLBlock <$> nl`. This way we can later use `toSPBlock <$> nl` for stake-pools. # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Acknowledge any changes required to the Wiki --> 845: Add forget pending transaction endpoint (Part1) r=KtorZ a=paweljakubas # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #836 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] I have added forget pending transaction endpoint, errors and types - [x] I have updated swagger accordingly # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: Rodney Lorrimar <[email protected]> Co-authored-by: Johannes Lund <[email protected]> Co-authored-by: Pawel Jakubas <[email protected]>
Build succeeded |
Issue Number
#836
Overview
Comments