Skip to content
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

Merged
merged 13 commits into from
Jul 2, 2020
Merged

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Jul 1, 2020

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.

  • 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.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov
Copy link

codecov bot commented Jul 1, 2020

Codecov Report

Merging #6572 into master will increase coverage by 0.19%.
The diff coverage is 60.86%.

@@            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     

@alexanderbez alexanderbez mentioned this pull request Jul 1, 2020
27 tasks
@alexanderbez alexanderbez marked this pull request as ready for review July 2, 2020 02:02
@@ -11,6 +11,23 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
)

type contextKey string
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@alessio alessio left a 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

simapp/cmd/simcli/main.go Outdated Show resolved Hide resolved
simapp/cmd/simcli/main.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
testCases := []struct {
name string
from, to sdk.AccAddress
Copy link
Contributor

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:

"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.

alexanderbez and others added 2 commits July 2, 2020 08:56
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
alexanderbez and others added 3 commits July 2, 2020 08:57
@alexanderbez alexanderbez added the A:automerge Automatically merge PR once all prerequisites pass. label Jul 2, 2020
@mergify mergify bot merged commit 14d1ee5 into master Jul 2, 2020
@mergify mergify bot deleted the bez/tx-send-util branch July 2, 2020 13:02
@alexanderbez alexanderbez mentioned this pull request Jul 2, 2020
8 tasks
@aaronc
Copy link
Member

aaronc commented Jul 2, 2020

Hope this makes things cleaner! 👍

larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants