github.com/lino-network/lino@v0.6.11/x/developer/client/cli/query.go (about) 1 package cli 2 3 import ( 4 "fmt" 5 6 "github.com/cosmos/cosmos-sdk/client" 7 "github.com/cosmos/cosmos-sdk/codec" 8 "github.com/spf13/cobra" 9 10 linotypes "github.com/lino-network/lino/types" 11 "github.com/lino-network/lino/utils" 12 "github.com/lino-network/lino/x/developer/model" 13 "github.com/lino-network/lino/x/developer/types" 14 ) 15 16 func GetQueryCmd(cdc *codec.Codec) *cobra.Command { 17 cmd := &cobra.Command{ 18 Use: types.ModuleName, 19 Short: "Querying commands for the developer module", 20 DisableFlagParsing: true, 21 SuggestionsMinimumDistance: 2, 22 RunE: client.ValidateCmd, 23 } 24 cmd.AddCommand(client.GetCommands( 25 getCmdShow(cdc), 26 getCmdList(cdc), 27 getCmdListAffiliated(cdc), 28 getCmdIDAShow(cdc), 29 getCmdIDABalance(cdc), 30 getCmdReservePool(cdc), 31 getCmdIDAStats(cdc), 32 )...) 33 return cmd 34 } 35 36 // GetCmdShow queries information about a name 37 func getCmdShow(cdc *codec.Codec) *cobra.Command { 38 return &cobra.Command{ 39 Use: "show <username>", 40 Short: "show <username>, developer detail", 41 Args: cobra.ExactArgs(1), 42 RunE: func(cmd *cobra.Command, args []string) error { 43 name := args[0] 44 uri := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryDeveloper, name) 45 return utils.CLIQueryJSONPrint(cdc, uri, nil, 46 func() interface{} { return &model.Developer{} }) 47 }, 48 } 49 } 50 51 // GetCmdList lists all developers 52 func getCmdList(cdc *codec.Codec) *cobra.Command { 53 return &cobra.Command{ 54 Use: "list", 55 Short: "list all developers", 56 Args: cobra.ExactArgs(0), 57 RunE: func(cmd *cobra.Command, args []string) error { 58 uri := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryDeveloperList) 59 rst := make(map[string]model.Developer) 60 return utils.CLIQueryJSONPrint(cdc, uri, nil, 61 func() interface{} { return &rst }) 62 }, 63 } 64 } 65 66 // GetCmdListAffiliated - list all affiliated accounts. 67 func getCmdListAffiliated(cdc *codec.Codec) *cobra.Command { 68 return &cobra.Command{ 69 Use: "list-affiliated [app]", 70 Short: "list <app>, all affiliated accounts of app", 71 Args: cobra.ExactArgs(1), 72 RunE: func(cmd *cobra.Command, args []string) error { 73 app := args[0] 74 uri := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryAffiliated, app) 75 rst := make([]linotypes.AccountKey, 0) 76 return utils.CLIQueryJSONPrint(cdc, uri, nil, 77 func() interface{} { return &rst }) 78 }, 79 } 80 } 81 82 // GetCmdIDAShow - 83 func getCmdIDAShow(cdc *codec.Codec) *cobra.Command { 84 return &cobra.Command{ 85 Use: "ida-show <app>", 86 Short: "ida-show <app>, show ida details", 87 Args: cobra.ExactArgs(1), 88 RunE: func(cmd *cobra.Command, args []string) error { 89 app := args[0] 90 uri := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryIDA, app) 91 rst := model.AppIDA{} 92 return utils.CLIQueryJSONPrint(cdc, uri, nil, 93 func() interface{} { return &rst }) 94 }, 95 } 96 } 97 98 // GetCmdIDABalance - 99 func getCmdIDABalance(cdc *codec.Codec) *cobra.Command { 100 return &cobra.Command{ 101 Use: "ida-balance <app> <user>", 102 Short: "ida-balance <app> <user>", 103 Args: cobra.ExactArgs(2), 104 RunE: func(cmd *cobra.Command, args []string) error { 105 app := args[0] 106 user := args[1] 107 uri := fmt.Sprintf("custom/%s/%s/%s/%s", types.QuerierRoute, types.QueryIDABalance, app, user) 108 rst := types.QueryResultIDABalance{} 109 return utils.CLIQueryJSONPrint(cdc, uri, nil, 110 func() interface{} { return &rst }) 111 }, 112 } 113 } 114 115 // GetCmdReservePool - 116 func getCmdReservePool(cdc *codec.Codec) *cobra.Command { 117 return &cobra.Command{ 118 Use: "reserve-pool", 119 Short: "reserve-pool", 120 Args: cobra.ExactArgs(0), 121 RunE: func(cmd *cobra.Command, args []string) error { 122 uri := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryReservePool) 123 rst := model.ReservePool{} 124 return utils.CLIQueryJSONPrint(cdc, uri, nil, 125 func() interface{} { return &rst }) 126 }, 127 } 128 } 129 130 // GetCmdIDAStats - 131 func getCmdIDAStats(cdc *codec.Codec) *cobra.Command { 132 return &cobra.Command{ 133 Use: "ida-stats", 134 Short: "ida-stats", 135 Args: cobra.ExactArgs(1), 136 RunE: func(cmd *cobra.Command, args []string) error { 137 app := args[0] 138 uri := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryIDAStats, app) 139 rst := model.AppIDAStats{} 140 return utils.CLIQueryJSONPrint(cdc, uri, nil, 141 func() interface{} { return &rst }) 142 }, 143 } 144 }