From e2ccf75e6a336d70c75438822f695f0e65d27dd3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 30 Jul 2021 15:50:29 +0200 Subject: [PATCH] fix: feegrant grant cli bug (backport #9720) (#9733) * fix: feegrant grant cli bug (#9720) ## Description feegrant grant cli granter now accepts key name as well as address in general and accepts only address in `--generate-only` mode Closes: #9659 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) (cherry picked from commit 085ab0669a0df6fce5c2322e7c61f25ae743fed0) # Conflicts: # CHANGELOG.md * fix conflicts * fix changelog * try fixing lint issue * remove staticcheck comments * Update server/grpc/gogoreflection/fix_registration.go * Update server/grpc/gogoreflection/fix_registration.go Co-authored-by: likhita-809 <78951027+likhita-809@users.noreply.github.com> Co-authored-by: likhita-809 Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com> --- CHANGELOG.md | 1 + x/feegrant/client/cli/tx.go | 8 ++------ x/feegrant/client/cli/tx_test.go | 15 ++++----------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e46eb7bdf95c..ebde300fb0db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* [\#9720](https://github.com/cosmos/cosmos-sdk/pull/9720) Feegrant grant cli granter now accepts key name as well as address in general and accepts only address in --generate-only mode * [\#9766](https://github.com/cosmos/cosmos-sdk/pull/9766) Fix hardcoded ledger signing algorithm on `keys add` command. ### Features diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 2ba342b21a5c..cfc6a7ef4171 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -48,9 +48,8 @@ func GetTxCmd() *cobra.Command { // This command is more powerful than AutoCLI generated command as it allows a better input validation. func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ - Use: "grant ", - Aliases: []string{"grant-allowance"}, - Short: "Grant Fee allowance to an address", + Use: "grant [granter_key_or_address] [grantee]", + Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( `Grant authorization to pay fees from your address. Note, the '--from' flag is @@ -66,9 +65,6 @@ Examples: ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - if err := cmd.Flags().Set(flags.FlagFrom, args[0]); err != nil { - return err - } clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/feegrant/client/cli/tx_test.go b/x/feegrant/client/cli/tx_test.go index 2fcb4020185e..cb75821c80cf 100644 --- a/x/feegrant/client/cli/tx_test.go +++ b/x/feegrant/client/cli/tx_test.go @@ -10,17 +10,6 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" - _ "cosmossdk.io/api/cosmos/feegrant/v1beta1" - v1 "cosmossdk.io/api/cosmos/gov/v1" - v1beta1 "cosmossdk.io/api/cosmos/gov/v1beta1" - "cosmossdk.io/core/address" - sdkmath "cosmossdk.io/math" - "cosmossdk.io/x/feegrant" - "cosmossdk.io/x/feegrant/client/cli" - "cosmossdk.io/x/feegrant/module" - "cosmossdk.io/x/gov" - govcli "cosmossdk.io/x/gov/client/cli" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" @@ -154,6 +143,10 @@ func (s *CLITestSuite) TestNewCmdFeeGrant() { s.Require().Equal(fromAddr, granter) s.Require().NoError(err) + fromAddr, fromName, _, err := client.GetFromFields(clientCtx.Keyring, granter.String(), clientCtx.GenerateOnly) + s.Require().Equal(fromAddr, granter) + s.Require().NoError(err) + commonFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),