-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R: Allow overriding of CLI transaction response handling #3276
R4R: Allow overriding of CLI transaction response handling #3276
Conversation
@aaronc Thank you for sharing this. I'm currently refactoring that code. |
So sounds like what you're working on will supercede this PR @jackzampolin ? |
@jackzampolin I'm not seeing this addressed in the PR that you referenced or any PR that has been merged. I do see you're working on #3321, but I also don't see it addressed there. What I want is first and foremost the ability to override the default response printing if I need something different and secondly, I'd like the default response printing to be better. For me, that means printing |
@aaronc you are correct and in fact I do recall seeing a PR that did address this but maybe it was closed as I cannot find it. Essentially it simply decoded any raw bytes from the response. I believe it was mainly the tags. |
@aaronc We have prioritized this work to be prelaunch. We are planning to complete it during this sprint (sometime in the next 2 weeks). Since this PR wasn't complete, and you weren't pushing more commits I've gone ahead and closed it. If this is in error please reopen. |
Okay, well seems like this is still relevant and I'm making some tweaks. Can you reopen it please @jackzampolin? I don't seem to be able. |
Codecov Report
@@ Coverage Diff @@
## develop #3276 +/- ##
===========================================
+ Coverage 55.33% 55.34% +<.01%
===========================================
Files 135 135
Lines 9596 9598 +2
===========================================
+ Hits 5310 5312 +2
Misses 3954 3954
Partials 332 332 |
Codecov Report
@@ Coverage Diff @@
## develop #3276 +/- ##
===========================================
- Coverage 59.41% 59.39% -0.03%
===========================================
Files 135 135
Lines 9975 9975
===========================================
- Hits 5927 5925 -2
- Misses 3676 3678 +2
Partials 372 372 |
f1a9f06
to
707f364
Compare
I've updated this to be a little more generic - overriding all of the default response handling behavior in I haven't updated docs or written tests as the checklist requests because as far as I know there are really no docs for the CLI and I'm not sure what the testing procedure would be for something like this if it's even needed. So I'm going to change this to R4R and if any of that stuff is needed in some form, please let me know. |
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.
Rationale of this is a tad unclear to me. Please elaborate.
…e of broadcastTxCommit
@alessio I put more context on what I'm looking for in related issue #2953. For now, I think this PR could be considered the "escape hatch" solution which from my position as an SDK user feels really helpful to have even if the default formatting is improved which I hope happens too. Maybe there should be a better name than |
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 @aaronc -- this looks clean! I left a few remarks. Please lmk your thoughts 👍
client/context/broadcast.go
Outdated
@@ -131,6 +131,11 @@ func (ctx CLIContext) broadcastTxCommit(txBytes []byte) (*ctypes.ResultBroadcast | |||
return res, err | |||
} | |||
|
|||
if ctx.ResponseHandler != nil { |
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 suppose this is a flexible way of doing this. May I suggest a few things?
- Rename
ResponseHandler
toTxResponseHandler
to provide better context - Take the two
if
statements below this and stuff them into aDefaultTxResponseHandler
. This will DRY and cleanupbroadcastTxCommit
. - Perhaps implement another
TxResponseHandler
that pretty prints the response (this may require merging @sunnya97's PR).
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.
- Rename
ResponseHandler
toTxResponseHandler
to provide better context- Take the two
if
statements below this and stuff them into aDefaultTxResponseHandler
. This will DRY and cleanupbroadcastTxCommit
.
Okay, pushed these two changes. I added error
as the return to TxResponseHandler
because MarshalJSON
could return an error in DefaultTxResponseHandler
. Looks like the error is handled higher up. I agree this is nice for DRY because it would allow someone to just wrap the default functionality.
- Perhaps implement another
TxResponseHandler
that pretty prints the response (this may require merging @sunnya97's PR).
Happy to help with that. Is it okay if it's in a separate PR connected with the discussion in #2953 ?
…seHandler from body of broadcastTxCommit.
Looks like linting failed in CI because of some unrelated error. Can someone familiar with that setup take a look? |
This has been fixed via: #3451 going to go ahead and close this. |
Currently printing of tx results in the cli is pretty basic and encodes things like
Tags
as byte arrays whereas in most cases they are actually strings. Also, in my case I would sometimes like to useData
to return useful information to the client.This is just one of many approaches that could be used, but is pretty flexible in that it lets cli commands customize the output.
Open for discussion.
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added entries in
PENDING.md
with issue #rereviewed
Files changed
in the github PR explorerFor Admin Use: