planetmint-go/x/dao/client/cli/query_reissuance.go
Julian Strobl bead62bd04
refactor(query): align with cosmos-sdk style (#466)
- use one `cmd.AddCommand(...)`
- sort commands
- use `GetCmd...` function name style

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-11-12 15:59:52 +01:00

51 lines
996 B
Go

package cli
import (
"strconv"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/planetmint/planetmint-go/x/dao/types"
"github.com/spf13/cast"
"github.com/spf13/cobra"
)
var _ = strconv.Itoa(0)
func GetCmdReissuance() *cobra.Command {
cmd := &cobra.Command{
Use: "reissuance [height]",
Short: "Query for reissuance by height",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
reqBlockHeight, err := cast.ToInt64E(args[0])
if err != nil {
return err
}
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryGetReissuanceRequest{
BlockHeight: reqBlockHeight,
}
res, err := queryClient.GetReissuance(cmd.Context(), params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}