Skip to content

Commit 085ab06

Browse files
authored
fix: feegrant grant cli bug (#9720)
<!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## 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 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### 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)
1 parent 6098d7e commit 085ab06

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
7777

7878
### Bug Fixes
7979

80+
* [\#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
8081
* [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter.
8182
* [\#9639](https://github.com/cosmos/cosmos-sdk/pull/9639) Check store keys length before accessing them by making sure that `key` is of length `m+1` (for `key[n:m]`)
8283
* (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt`

x/feegrant/client/cli/tx.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func GetTxCmd() *cobra.Command {
4646
// NewCmdFeeGrant returns a CLI command handler for creating a MsgGrantAllowance transaction.
4747
func NewCmdFeeGrant() *cobra.Command {
4848
cmd := &cobra.Command{
49-
Use: "grant [granter] [grantee]",
49+
Use: "grant [granter_key_or_address] [grantee]",
5050
Short: "Grant Fee allowance to an address",
5151
Long: strings.TrimSpace(
5252
fmt.Sprintf(
@@ -63,10 +63,6 @@ Examples:
6363
),
6464
Args: cobra.ExactArgs(2),
6565
RunE: func(cmd *cobra.Command, args []string) error {
66-
_, err := sdk.AccAddressFromBech32(args[0])
67-
if err != nil {
68-
return err
69-
}
7066

7167
cmd.Flags().Set(flags.FlagFrom, args[0])
7268
clientCtx, err := client.GetClientTxContext(cmd)

x/feegrant/client/testutil/suite.go

+31
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/stretchr/testify/suite"
1111
tmcli "github.com/tendermint/tendermint/libs/cli"
1212

13+
"github.com/cosmos/cosmos-sdk/client"
1314
"github.com/cosmos/cosmos-sdk/client/flags"
1415
"github.com/cosmos/cosmos-sdk/crypto/hd"
1516
"github.com/cosmos/cosmos-sdk/crypto/keyring"
@@ -258,6 +259,10 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
258259
alreadyExistedGrantee := s.addedGrantee
259260
clientCtx := val.ClientCtx
260261

262+
fromAddr, fromName, _, err := client.GetFromFields(clientCtx.Keyring, granter.String(), clientCtx.GenerateOnly)
263+
s.Require().Equal(fromAddr, granter)
264+
s.Require().NoError(err)
265+
261266
commonFlags := []string{
262267
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
263268
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
@@ -297,6 +302,19 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
297302
),
298303
true, 0, nil,
299304
},
305+
{
306+
"wrong granter key name",
307+
append(
308+
[]string{
309+
"invalid_granter",
310+
"cosmos16dun6ehcc86e03wreqqww89ey569wuj4em572w",
311+
fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"),
312+
fmt.Sprintf("--%s=%s", flags.FlagFrom, granter),
313+
},
314+
commonFlags...,
315+
),
316+
true, 0, nil,
317+
},
300318
{
301319
"valid basic fee grant",
302320
append(
@@ -310,6 +328,19 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
310328
),
311329
false, 0, &sdk.TxResponse{},
312330
},
331+
{
332+
"valid basic fee grant with granter key name",
333+
append(
334+
[]string{
335+
fromName,
336+
"cosmos16dun6ehcc86e03wreqqww89ey569wuj4em572w",
337+
fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"),
338+
fmt.Sprintf("--%s=%s", flags.FlagFrom, fromName),
339+
},
340+
commonFlags...,
341+
),
342+
false, 0, &sdk.TxResponse{},
343+
},
313344
{
314345
"valid basic fee grant with amino",
315346
append(

0 commit comments

Comments
 (0)