diff --git a/x/auction/keeper/grpc_query.go b/x/auction/keeper/grpc_query.go index e537594fa9..42a8e7bcf2 100644 --- a/x/auction/keeper/grpc_query.go +++ b/x/auction/keeper/grpc_query.go @@ -4,6 +4,8 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/umee-network/umee/v6/util/coin" "github.com/umee-network/umee/v6/x/auction" @@ -34,17 +36,20 @@ func (q Querier) RewardsAuction(goCtx context.Context, msg *auction.QueryRewards *auction.QueryRewardsAuctionResponse, error, ) { ctx := sdk.UnwrapSDKContext(goCtx) - bid, id := q.Keeper(&ctx).getRewardsBid(msg.Id) + k := q.Keeper(&ctx) + rewards, id := k.getRewardsAuction(msg.Id) + if rewards == nil { + return nil, status.Error(codes.NotFound, "wrong ID") + } r := &auction.QueryRewardsAuctionResponse{Id: id} + r.Rewards = rewards.Rewards + r.EndsAt = rewards.EndsAt + + bid := q.Keeper(&ctx).getRewardsBid(id) if bid != nil { r.Bidder = bid.Bidder r.Bid = coin.UmeeInt(bid.Amount) } - rewards, _ := q.Keeper(&ctx).getRewardsAuction(msg.Id) - if rewards != nil { - r.Rewards = rewards.Rewards - r.EndsAt = rewards.EndsAt - } return r, nil } diff --git a/x/auction/keeper/rewards.go b/x/auction/keeper/rewards.go index db98d8cbcd..ce7cce0a96 100644 --- a/x/auction/keeper/rewards.go +++ b/x/auction/keeper/rewards.go @@ -25,7 +25,7 @@ func (k Keeper) FinalizeRewardsAuction() error { return nil } - bid, _ := k.getRewardsBid(id) + bid := k.getRewardsBid(id) if bid != nil && len(bid.Bidder) != 0 { bidderAccAddr := sdk.MustAccAddressFromBech32(bid.Bidder) err := k.sendCoins(k.accs.RewardsCollect, bidderAccAddr, a.Rewards) @@ -98,13 +98,13 @@ func (k Keeper) rewardsBid(msg *auction.MsgRewardsBid) error { return store.SetValue(k.store, key, &bid, keyMsg) } -func (k Keeper) getRewardsBid(id uint32) (*auction.Bid, uint32) { +func (k Keeper) getRewardsBid(id uint32) *auction.Bid { if id == 0 { id = k.currentRewardsAuctionID() } keyMsg := "auction.rewards.bid" key := k.keyRewardsBid(id) - return store.GetValue[*auction.Bid](k.store, key, keyMsg), id + return store.GetValue[*auction.Bid](k.store, key, keyMsg) } func (k Keeper) getAllRewardsBids() ([]auction.BidKV, error) {