/
querier.go
70 lines (56 loc) · 2.06 KB
/
querier.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
61
62
63
64
65
66
67
68
69
70
package keeper
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
abci "github.com/tendermint/tendermint/abci/types"
)
const (
QueryEntityDoc = "queryEntityDoc"
)
func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err error) {
switch path[0] {
default:
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Unknown project query endpoint")
}
}
}
// func queryProjectDoc(ctx sdk.Context, path []string, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
// storedDoc, err := k.GetProjectDoc(ctx, path[0])
// if err != nil {
// return nil, err
// }
// res, errRes := codec.MarshalJSONIndent(legacyQuerierCdc, storedDoc)
// if errRes != nil {
// return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, "failed to marshal iid: %s", err)
// }
// return res, nil
// }
// func queryProjectAccounts(ctx sdk.Context, path []string, k Keeper) ([]byte, error) {
// resp := k.GetAccountMap(ctx, path[0])
// res, err := json.Marshal(resp)
// if err != nil {
// return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, "failed to marshal iid %s", err)
// }
// return res, nil
// }
// func queryProjectTx(ctx sdk.Context, path []string, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
// info, err := k.GetProjectWithdrawalTransactions(ctx, path[0])
// if err != nil {
// return nil, err
// }
// res, err := codec.MarshalJSONIndent(legacyQuerierCdc, info)
// if err != nil {
// return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, "failed to marshal iid %s", err)
// }
// return res, nil
// }
// func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
// params := k.GetParams(ctx)
// res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params)
// if err != nil {
// return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, "failed to marshal iid %s", err)
// }
// return res, nil
// }