Skip to content

Commit

Permalink
Added expiration flag to grant tx
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahith Reddy Narahari committed Dec 10, 2019
1 parent a4505b7 commit a92593f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions x/msg_authorization/client/cli/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package cli

const FlagExpiration = "expiration"
10 changes: 10 additions & 0 deletions x/msg_authorization/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cli

import (
"bufio"
"time"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -10,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/cosmos/cosmos-sdk/x/msg_authorization/internal/types"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// GetTxCmd returns the transaction commands for this module
Expand Down Expand Up @@ -53,6 +56,11 @@ func GetCmdGrantCapability(cdc *codec.Codec) *cobra.Command {
if err != nil {
return err
}
expirationString := viper.GetString(FlagExpiration)
expiration, err := time.Parse(time.RFC3339, expirationString)
if err != nil {
return err
}

msg := types.NewMsgGrantAuthorization(granter, grantee, capability, expiration)
if err := msg.ValidateBasic(); err != nil {
Expand All @@ -63,6 +71,8 @@ func GetCmdGrantCapability(cdc *codec.Codec) *cobra.Command {

},
}
cmd.Flags().String(FlagExpiration, "9999-12-31 23:59:59.52Z", "The time upto which the authorization is active for the user")

return cmd
}

Expand Down

0 comments on commit a92593f

Please sign in to comment.