diff --git a/CHANGELOG.md b/CHANGELOG.md index 5896a5e86821..d8eae44208a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#9969](https://github.com/cosmos/cosmos-sdk/pull/9969) fix: use keyring in config for add-genesis-account cmd. * (x/genutil) [#10104](https://github.com/cosmos/cosmos-sdk/pull/10104) Ensure the `init` command reads the `--home` flag value correctly. * [\#10061](https://github.com/cosmos/cosmos-sdk/pull/10061) Ensure that `LegacyAminoPubKey` struct correctly unmarshals from JSON +* (x/feegrant) [\#10049](https://github.com/cosmos/cosmos-sdk/issues/10049) Fixed the error message when `period` or `period-limit` flag is not set on a feegrant grant transaction. ## [v0.44.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.0) - 2021-09-01 diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 44b673d809b0..66022abfa90a 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -125,25 +125,28 @@ Examples: return err } - if periodClock > 0 && periodLimit != nil { - periodReset := getPeriodReset(periodClock) - if exp != "" && periodReset.Sub(expiresAtTime) > 0 { - return fmt.Errorf("period(%d) cannot reset after expiration(%v)", periodClock, exp) - } - - periodic := feegrant.PeriodicAllowance{ - Basic: basic, - Period: getPeriod(periodClock), - PeriodReset: getPeriodReset(periodClock), - PeriodSpendLimit: periodLimit, - PeriodCanSpend: periodLimit, - } - - grant = &periodic - - } else { - return fmt.Errorf("invalid number of args %d", len(args)) + if periodClock <= 0 { + return fmt.Errorf("period clock was not set") } + + if periodLimit == nil { + return fmt.Errorf("period limit was not set") + } + + periodReset := getPeriodReset(periodClock) + if exp != "" && periodReset.Sub(expiresAtTime) > 0 { + return fmt.Errorf("period (%d) cannot reset after expiration (%v)", periodClock, exp) + } + + periodic := feegrant.PeriodicAllowance{ + Basic: basic, + Period: getPeriod(periodClock), + PeriodReset: getPeriodReset(periodClock), + PeriodSpendLimit: periodLimit, + PeriodCanSpend: periodLimit, + } + + grant = &periodic } allowedMsgs, err := cmd.Flags().GetStringSlice(FlagAllowedMsgs)