-
Notifications
You must be signed in to change notification settings - Fork 12
/
querier.go
32 lines (27 loc) · 1.04 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
package keeper
import (
"github.com/commercionetwork/commercionetwork/x/encapsulated/bank/internal/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
)
// NewQuerier returns a new sdk.Keeper instance.
func NewQuerier(q sdk.Querier, k Keeper) sdk.Querier {
return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, sdk.Error) {
switch path[0] {
case types.QueryBlockedAccounts:
return queryBlockedAccounts(ctx, req, k)
default:
return q(ctx, path, req)
}
}
}
// queryBlockedAccounts fetch an account's balance for the supplied height.
// Height and account address are passed as first and second path components respectively.
func queryBlockedAccounts(ctx sdk.Context, _ abci.RequestQuery, k Keeper) ([]byte, sdk.Error) {
bz, err := codec.MarshalJSONIndent(types.ModuleCdc, k.GetBlockedAddresses(ctx))
if err != nil {
return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", err.Error()))
}
return bz, nil
}