Skip to content

Commit

Permalink
Merge branch 'master' into fix-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang authored Apr 27, 2021
2 parents adf5485 + 3ab1bc2 commit 87c85f8
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 263 deletions.
2 changes: 1 addition & 1 deletion x/authz/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Examples:

func NewCmdRevokeAuthorization() *cobra.Command {
cmd := &cobra.Command{
Use: "revoke [grantee_address] [msg_type] --from=[granter_address]",
Use: "revoke [grantee] [msg_type] --from=[granter]",
Short: "revoke authorization",
Long: strings.TrimSpace(
fmt.Sprintf(`revoke authorization from a granter to a grantee:
Expand Down
29 changes: 17 additions & 12 deletions x/feegrant/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func NewCmdFeeGrant() *cobra.Command {
ignored as it is implied from [granter].
Examples:
%s tx %s grant cosmos1skjw... cosmos1skjw... --spend-limit 100stake --expiration 36000 or
%s tx %s grant cosmos1skjw... cosmos1skjw... --spend-limit 100stake --expiration 2022-01-30T15:04:05Z or
%s tx %s grant cosmos1skjw... cosmos1skjw... --spend-limit 100stake --period 3600 --period-limit 10stake --expiration 36000 or
%s tx %s grant cosmos1skjw... cosmos1skjw... --spend-limit 100stake --expiration 36000
%s tx %s grant cosmos1skjw... cosmos1skjw... --spend-limit 100stake --expiration 2022-01-30T15:04:05Z
--allowed-messages "/cosmos.gov.v1beta1.Msg/SubmitProposal,/cosmos.gov.v1beta1.Msg/Vote"
`, version.AppName, types.ModuleName, version.AppName, types.ModuleName, version.AppName, types.ModuleName,
),
Expand Down Expand Up @@ -92,7 +92,7 @@ Examples:
return err
}

exp, err := cmd.Flags().GetInt64(FlagExpiration)
exp, err := cmd.Flags().GetString(FlagExpiration)
if err != nil {
return err
}
Expand All @@ -101,9 +101,13 @@ Examples:
SpendLimit: limit,
}

if exp != 0 {
expDuration := time.Duration(exp) * time.Second
basic.Expiration = types.ExpiresAtTime(time.Now().Add(expDuration))
var expiresAtTime time.Time
if exp != "" {
expiresAtTime, err = time.Parse(time.RFC3339, exp)
if err != nil {
return err
}
basic.Expiration = types.ExpiresAtTime(expiresAtTime)
}

var grant types.FeeAllowanceI
Expand All @@ -127,14 +131,15 @@ Examples:
}

if periodClock > 0 && periodLimit != nil {
if exp > 0 && periodClock > exp {
return fmt.Errorf("period(%d) cannot be greater than the expiration(%d)", periodClock, exp)
periodReset := time.Now().Add(time.Duration(periodClock) * time.Second)
if exp != "" && periodReset.Sub(expiresAtTime) > 0 {
return fmt.Errorf("period(%d) cannot reset after expiration(%v)", periodClock, exp)
}

periodic := types.PeriodicFeeAllowance{
Basic: basic,
Period: types.ClockDuration(time.Duration(periodClock) * time.Second),
PeriodReset: types.ExpiresAtTime(time.Now().Add(time.Duration(periodClock) * time.Second)),
PeriodReset: types.ExpiresAtTime(periodReset),
PeriodSpendLimit: periodLimit,
PeriodCanSpend: periodLimit,
}
Expand Down Expand Up @@ -176,7 +181,7 @@ Examples:

flags.AddTxFlagsToCmd(cmd)
cmd.Flags().StringSlice(FlagAllowedMsgs, []string{}, "Set of allowed messages for fee allowance")
cmd.Flags().Int64(FlagExpiration, 0, "The second unit of time duration which the grant is active for the user")
cmd.Flags().String(FlagExpiration, "", "The RFC 3339 timestamp after which the grant expires for the user")
cmd.Flags().String(FlagSpendLimit, "", "Spend limit specifies the max limit can be used, if not mentioned there is no limit")
cmd.Flags().Int64(FlagPeriod, 0, "period specifies the time duration in which period_spend_limit coins can be spent before that allowance is reset")
cmd.Flags().String(FlagPeriodLimit, "", "period limit specifies the maximum number of coins that can be spent in the period")
Expand All @@ -187,11 +192,11 @@ Examples:
// NewCmdRevokeFeegrant returns a CLI command handler for creating a MsgRevokeFeeAllowance transaction.
func NewCmdRevokeFeegrant() *cobra.Command {
cmd := &cobra.Command{
Use: "revoke [granter_address] [grantee_address]",
Use: "revoke [granter] [grantee]",
Short: "revoke fee-grant",
Long: strings.TrimSpace(
fmt.Sprintf(`revoke fee grant from a granter to a grantee. Note, the'--from' flag is
ignored as it is implied from [granter_address].
ignored as it is implied from [granter].
Example:
$ %s tx %s revoke cosmos1skj.. cosmos1skj..
Expand Down
210 changes: 0 additions & 210 deletions x/feegrant/client/rest/grpc_query_test.go

This file was deleted.

Loading

0 comments on commit 87c85f8

Please sign in to comment.