-
Notifications
You must be signed in to change notification settings - Fork 1
/
querier.go
29 lines (26 loc) · 900 Bytes
/
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
package keygen
import (
"github.com/hbtc-chain/bhchain/codec"
sdk "github.com/hbtc-chain/bhchain/types"
"github.com/hbtc-chain/bhchain/x/keygen/types"
abci "github.com/tendermint/tendermint/abci/types"
)
// NewQuerier is the module level router for state queries
func NewQuerier(keeper Keeper) sdk.Querier {
return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err sdk.Error) {
switch path[0] {
case types.QueryWaitAssignKeys:
return queryWaitAssignKeys(ctx, req, keeper)
default:
return nil, sdk.ErrUnknownRequest("unknown order query endpoint")
}
}
}
func queryWaitAssignKeys(ctx sdk.Context, req abci.RequestQuery, keeper Keeper) ([]byte, sdk.Error) {
orderIDs := keeper.GetWaitAssignKeyGenOrderIDs(ctx)
res, err := codec.MarshalJSONIndent(keeper.cdc, orderIDs)
if err != nil {
panic("could not marshal result to JSON")
}
return res, nil
}