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

Fix Gas Flag Usage + CLI Flag APIs #6685

Merged
merged 4 commits into from
Jul 11, 2020
Merged

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Jul 10, 2020

Description

  • Fix gas flag usage (no longer singleton)
  • Use flags.AddTxFlagsToCmd and flags.AddQueryFlagsToCmd in favor of poorly designed (Get|Post)Commands.

closes: #6545


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

@alexanderbez alexanderbez added C:CLI Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity. A:automerge Automatically merge PR once all prerequisites pass. labels Jul 10, 2020
@codecov
Copy link

codecov bot commented Jul 11, 2020

Codecov Report

Merging #6685 into master will decrease coverage by 4.42%.
The diff coverage is 8.51%.

@@            Coverage Diff             @@
##           master    #6685      +/-   ##
==========================================
- Coverage   58.36%   53.94%   -4.43%     
==========================================
  Files         503      338     -165     
  Lines       30226    19456   -10770     
==========================================
- Hits        17641    10495    -7146     
+ Misses      11295     8239    -3056     
+ Partials     1290      722     -568     

@alexanderbez alexanderbez marked this pull request as ready for review July 11, 2020 01:47
@@ -52,13 +52,16 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory {
gasAdj, _ := flagSet.GetFloat64(flags.FlagGasAdjustment)
memo, _ := flagSet.GetString(flags.FlagMemo)

gasStr, _ := flagSet.GetString(flags.FlagGas)
gasSetting, _ := flags.ParseGasSetting(gasStr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gasSetting, _ := flags.ParseGasSetting(gasStr)
gasSetting, err := flags.ParseGasSetting(gasStr)
if err != nil {
panic(err)
}

This is because ParseGasSetting must never fail there, but if it does it must panic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we return an error here.

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.

Just left a comment on error checking. A long-overdue one, thanks!!

@mergify mergify bot merged commit e7554bb into master Jul 11, 2020
@mergify mergify bot deleted the bez/6545-gas-var-cli-tweaks branch July 11, 2020 08:13
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
* Use new APIs

* fix usage

* fix usage of gas flag

* tests: TestParseGasSetting
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 Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gas Flag: Remove usage or Var*
3 participants