-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Use Context in Command instead of Argument + Util #6572
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6572 +/- ##
==========================================
+ Coverage 56.84% 57.04% +0.19%
==========================================
Files 481 481
Lines 28921 28939 +18
==========================================
+ Hits 16441 16507 +66
+ Misses 11314 11258 -56
- Partials 1166 1174 +8 |
@@ -11,6 +11,23 @@ import ( | |||
"github.com/cosmos/cosmos-sdk/client/flags" | |||
) | |||
|
|||
type contextKey string |
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.
Why defining a string type alias?
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.
You need an addressable and comparable type for context keys.
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.
Great stuff. Good to go
testCases := []struct { | ||
name string | ||
from, to sdk.AccAddress |
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.
It is fun that we came to same conclussions:
cosmos-sdk/x/bank/client/cli/cli_test.go
Line 193 in 3c5dec4
"valid transaction (gen-only)", |
Probably I will wait your merge to update mine, I needed to extract the SendTx in order to test the Auth module.
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Hope this makes things cleaner! 👍 |
* Use context * use PersistentPreRunE * undo * use init context * Update types * update tests * implement tests * Update simapp/cmd/simcli/main.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update simapp/cmd/simcli/main.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/bank/client/cli/tx.go Co-authored-by: Alessio Treglia <alessio@tendermint.com> * fix build Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Description
Use a Command's Context instead of passing by argument. This allows us to leverage pre-execution hooks and reduces the need for viper.
ref: #6571
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes