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

* chore: remove unused asset.proto and asset.pb.go files * feat: add AssetByAddress store functionality * fix: asset query now returns numElements passed in req * chore: add migration for new store mechanics * chore: set upgradehandler for assetmodule migration * chore: removed obsolete GetCIDsByAddress function * chore: adjust cmd usage --------- Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
28 lines
820 B
Go
28 lines
820 B
Go
package keeper
|
|
|
|
import (
|
|
"context"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/planetmint/planetmint-go/errormsg"
|
|
"github.com/planetmint/planetmint-go/util"
|
|
"github.com/planetmint/planetmint-go/x/asset/types"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
func (k Keeper) GetCIDsByAddress(goCtx context.Context, req *types.QueryGetCIDsByAddressRequest) (*types.QueryGetCIDsByAddressResponse, error) {
|
|
if req == nil {
|
|
return nil, status.Error(codes.InvalidArgument, errormsg.InvalidRequest)
|
|
}
|
|
|
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
|
|
|
cids, found := k.GetAssetsByAddress(ctx, req.GetAddress(), nil, util.SerializeUint64(req.GetNumElements()))
|
|
if !found {
|
|
return nil, status.Error(codes.NotFound, "no CIDs found")
|
|
}
|
|
|
|
return &types.QueryGetCIDsByAddressResponse{Cids: cids}, nil
|
|
}
|