Skip to content

Commit

Permalink
CM-274 implemented cli tx GetCmdRenewLease
Browse files Browse the repository at this point in the history
  • Loading branch information
rnistuk committed Mar 31, 2020
1 parent cf0f040 commit f052bdd
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions x/crud/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ func GetTxCmd(_ string, cdc *codec.Codec) *cobra.Command {
RunE: client.ValidateCmd,
}
crudTxCmd.AddCommand(flags.PostCommands(
GetCmdCount(cdc),
GetCmdCreate(cdc),
GetCmdRead(cdc),
GetCmdUpdate(cdc),
GetCmdDelete(cdc),
GetCmdKeys(cdc),
GetCmdHas(cdc),
GetCmdRename(cdc),
GetCmdKeyValues(cdc),
GetCmdCount(cdc),
GetCmdDeleteAll(cdc),
GetCmdMultiUpdate(cdc),
GetCmdGetLease(cdc),
GetCmdGetNShortestLease(cdc),
GetCmdHas(cdc),
GetCmdKeyValues(cdc),
GetCmdKeys(cdc),
GetCmdMultiUpdate(cdc),
GetCmdRead(cdc),
GetCmdRename(cdc),
GetCmdRenewLease(cdc),
GetCmdUpdate(cdc),
)...)

return crudTxCmd
Expand Down Expand Up @@ -354,3 +355,33 @@ func GetCmdGetNShortestLease(cdc *codec.Codec) *cobra.Command {
},
}
}

func GetCmdRenewLease(cdc *codec.Codec) *cobra.Command {
cc := cobra.Command{
Use: "renewlease [UUID] [key]",
Short: "renew the lease of an existing entry in the database",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))

msg := types.MsgRenewLease{
UUID: args[0],
Key: args[1],
Lease: leaseValue,
Owner: cliCtx.GetFromAddress(),
}

err := msg.ValidateBasic()
if err != nil {
return err
}

return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
},
}

cc.PersistentFlags().Int64Var(&leaseValue, "lease", 0, "lease in blocks (default 172800 (10 days))")
return &cc
}

0 comments on commit f052bdd

Please sign in to comment.