Skip to content

Commit

Permalink
finish query
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Apr 16, 2024
1 parent 788fe76 commit 87286fb
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 69 deletions.
8 changes: 8 additions & 0 deletions proto/umee/auction/v1/auction.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
syntax = "proto3";
package umee.auction.v1;

import "google/protobuf/timestamp.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/umee-network/umee/v6/x/auction";
option (gogoproto.goproto_getters_all) = false;
Expand All @@ -18,3 +20,9 @@ message Bid {
string bidder = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string amount = 2 [(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false];
}

// Auction Rewards
message Rewards {
repeated cosmos.base.v1beta1.Coin rewards = 1 [(gogoproto.nullable) = false];
google.protobuf.Timestamp ends_at = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
10 changes: 4 additions & 6 deletions proto/umee/auction/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ message QueryRewardsAuction {
message QueryRewardsAuctionResponse {
uint32 id = 1;
// highest bidder
string bidder = 2;
repeated cosmos.base.v1beta1.Coin rewards = 3 [(gogoproto.nullable) = false];
google.protobuf.Timestamp ends_at = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];

// not sure if we will need it:
// cosmos.base.v1beta1.Coin usd_rewards = 5 [(gogoproto.nullable) = false];
string bidder = 2;
cosmos.base.v1beta1.Coin bid = 3 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin rewards = 4 [(gogoproto.nullable) = false];
google.protobuf.Timestamp ends_at = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
271 changes: 251 additions & 20 deletions x/auction/auction.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions x/auction/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/umee-network/umee/v6/util/coin"
"github.com/umee-network/umee/v6/x/auction"
)

Expand Down Expand Up @@ -32,9 +34,16 @@ func (q Querier) RewardsAuction(goCtx context.Context, msg *auction.QueryRewards
) {
ctx := sdk.UnwrapSDKContext(goCtx)
bid, id := q.Keeper(&ctx).getRewardsBid(msg.Id)
return &auction.QueryRewardsAuctionResponse{
Id: id,
Bidder: bid.Bidder,
// TODO: add other fields
}, nil
r := &auction.QueryRewardsAuctionResponse{Id: id}
if bid != nil {
r.Bidder = bid.Bidder
r.Bid = coin.UmeeInt(bid.Amount)
}
rewards, _ := q.Keeper(&ctx).getRewards(msg.Id)
if rewards != nil {
r.Rewards = rewards.Rewards
r.EndsAt = rewards.EndsAt
}

return r, nil
}
Loading

0 comments on commit 87286fb

Please sign in to comment.