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: Incorrect error message when periodlimit is not set on a feegrant tx (backport #10050) #10168

Merged
merged 4 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* (x/genutil) [#10104](https://github.com/cosmos/cosmos-sdk/pull/10104) Ensure the `init` command reads the `--home` flag value correctly.
* (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

Expand Down
39 changes: 21 additions & 18 deletions x/feegrant/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down