-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.go
60 lines (51 loc) · 1.78 KB
/
query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package cli
import (
"fmt"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/coinexchain/cet-sdk/modules/bancorlite/internal/keepers"
"github.com/coinexchain/cet-sdk/modules/bancorlite/internal/types"
dex "github.com/coinexchain/cet-sdk/types"
"github.com/coinexchain/cosmos-utils/client/cliutil"
)
func QueryParamsCmd(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "params",
Args: cobra.NoArgs,
Short: "Query bancorlite params",
RunE: func(cmd *cobra.Command, args []string) error {
route := fmt.Sprintf("custom/%s/%s", types.StoreKey, keepers.QueryParameters)
return cliutil.CliQuery(cdc, route, nil)
},
}
}
func QueryBancorInfoCmd(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "info [stock] [money]",
Short: "query the banor pool's information about a symbol pair",
Long: `query the banor pool's information about a symbol pair.
Example :
cetcli query bancorlite info stock money --trust-node=true --chain-id=coinexdex`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
query := fmt.Sprintf("custom/%s/%s", types.StoreKey, keepers.QueryBancorInfo)
symbol := dex.GetSymbol(args[0], args[1])
param := &keepers.QueryBancorInfoParam{Symbol: symbol}
return cliutil.CliQuery(cdc, query, param)
},
}
}
func QueryBancorListCmd(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "infos",
Short: "query all bancor infos in blockchain",
Long: `query all bancor infos in blockchain.
Example :
cetcli query bancorlite infos \
--trust-node=true --chain-id=coinexdex`,
RunE: func(cmd *cobra.Command, args []string) error {
query := fmt.Sprintf("custom/%s/%s", types.StoreKey, keepers.QueryBancors)
return cliutil.CliQuery(cdc, query, nil)
},
}
}