diff --git a/CHANGELOG.md b/CHANGELOG.md index ec00e06109e1..8350a6fb8ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,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 * [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter. * [\#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]`) * (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt` diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index ec2a5b0f6d4b..44b673d809b0 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -46,7 +46,7 @@ func GetTxCmd() *cobra.Command { // NewCmdFeeGrant returns a CLI command handler for creating a MsgGrantAllowance transaction. func NewCmdFeeGrant() *cobra.Command { cmd := &cobra.Command{ - Use: "grant [granter] [grantee]", + Use: "grant [granter_key_or_address] [grantee]", Short: "Grant Fee allowance to an address", Long: strings.TrimSpace( fmt.Sprintf( @@ -63,10 +63,6 @@ Examples: ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - _, err := sdk.AccAddressFromBech32(args[0]) - if err != nil { - return err - } cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) diff --git a/x/feegrant/client/testutil/suite.go b/x/feegrant/client/testutil/suite.go index 74fe155e66ea..0c716fec2c45 100644 --- a/x/feegrant/client/testutil/suite.go +++ b/x/feegrant/client/testutil/suite.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -258,6 +259,10 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { alreadyExistedGrantee := s.addedGrantee clientCtx := val.ClientCtx + 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.BroadcastBlock), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), @@ -297,6 +302,19 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { ), true, 0, nil, }, + { + "wrong granter key name", + append( + []string{ + "invalid_granter", + "cosmos16dun6ehcc86e03wreqqww89ey569wuj4em572w", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, granter), + }, + commonFlags..., + ), + true, 0, nil, + }, { "valid basic fee grant", append( @@ -310,6 +328,19 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { ), false, 0, &sdk.TxResponse{}, }, + { + "valid basic fee grant with granter key name", + append( + []string{ + fromName, + "cosmos16dun6ehcc86e03wreqqww89ey569wuj4em572w", + fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, fromName), + }, + commonFlags..., + ), + false, 0, &sdk.TxResponse{}, + }, { "valid basic fee grant with amino", append(