From a92593f1e55219731f1ec37cdf9ef948e7ce08ff Mon Sep 17 00:00:00 2001 From: Sahith Reddy Narahari Date: Tue, 10 Dec 2019 19:53:49 +0530 Subject: [PATCH] Added expiration flag to grant tx --- x/msg_authorization/client/cli/flags.go | 3 +++ x/msg_authorization/client/cli/tx.go | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 x/msg_authorization/client/cli/flags.go diff --git a/x/msg_authorization/client/cli/flags.go b/x/msg_authorization/client/cli/flags.go new file mode 100644 index 000000000000..a77534c3551f --- /dev/null +++ b/x/msg_authorization/client/cli/flags.go @@ -0,0 +1,3 @@ +package cli + +const FlagExpiration = "expiration" diff --git a/x/msg_authorization/client/cli/tx.go b/x/msg_authorization/client/cli/tx.go index 9242e3f61dff..ff33d7fa57ae 100644 --- a/x/msg_authorization/client/cli/tx.go +++ b/x/msg_authorization/client/cli/tx.go @@ -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" @@ -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 @@ -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 { @@ -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 }