/
query_keeper.go
33 lines (25 loc) · 1.02 KB
/
query_keeper.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
// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors
// SPDX-License-Identifier: Apache-2.0
package splits
import (
"context"
"github.com/AssetMantle/modules/helpers"
)
type queryKeeper struct {
mapper helpers.Mapper
}
var _ helpers.QueryKeeper = (*queryKeeper)(nil)
func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) {
queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest))
return queryResponse, err
}
func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) {
return newQueryResponse(queryKeeper.mapper.NewCollection(context).FetchPaginated(queryRequest.Key, queryRequest.Limit)), nil
}
func (queryKeeper queryKeeper) Initialize(mapper helpers.Mapper, _ helpers.ParameterManager, _ []interface{}) helpers.Keeper {
queryKeeper.mapper = mapper
return queryKeeper
}
func keeperPrototype() helpers.QueryKeeper {
return queryKeeper{}
}