mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00

* aggregating error messages * removed duplicate err msgs * removed obsolete test (two times equal behaviour ) * added global error msg module * refactored test utils to have sample types and sample objects by keepers separated * excluded auto-generated code from sonarcube analysis Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package keeper
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/cosmos/cosmos-sdk/store/prefix"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/query"
|
|
"github.com/planetmint/planetmint-go/errormsg"
|
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
func (k Keeper) Reissuances(goCtx context.Context, req *types.QueryReissuancesRequest) (*types.QueryReissuancesResponse, error) {
|
|
if req == nil {
|
|
return nil, status.Error(codes.InvalidArgument, errormsg.InvalidRequest)
|
|
}
|
|
|
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
|
|
|
reissuances := make([]types.Reissuance, 0)
|
|
|
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReissuanceBlockHeightKey))
|
|
pageRes, err := query.Paginate(store, req.Pagination, func(_ []byte, value []byte) (err error) {
|
|
var reissuance types.Reissuance
|
|
err = reissuance.Unmarshal(value)
|
|
reissuances = append(reissuances, reissuance)
|
|
return
|
|
})
|
|
|
|
if err != nil {
|
|
return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err)
|
|
}
|
|
|
|
return &types.QueryReissuancesResponse{Reissuances: reissuances, Pagination: pageRes}, nil
|
|
}
|