-
Notifications
You must be signed in to change notification settings - Fork 13
/
querier.go
33 lines (26 loc) · 966 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
30
31
32
33
package keeper
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
vbrTypes "github.com/commercionetwork/commercionetwork/x/vbr/internal/types"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
)
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 vbrTypes.QueryBlockRewardsPoolFunds:
return queryGetBlockRewardsPoolFunds(ctx, path[1:], keeper)
default:
return nil, sdk.ErrUnknownRequest(fmt.Sprintf("Unknown %s query endpoint", vbrTypes.ModuleName))
}
}
}
func queryGetBlockRewardsPoolFunds(ctx sdk.Context, _ []string, keeper Keeper) (res []byte, err sdk.Error) {
funds := keeper.GetTotalRewardPool(ctx)
fundsBz, err2 := codec.MarshalJSONIndent(keeper.cdc, funds)
if err2 != nil {
return nil, sdk.ErrUnknownRequest("Could not marshal result to JSON")
}
return fundsBz, nil
}