Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auction): add noop msg server implementation #2491

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ func New(
appCodec,
keys[auction.StoreKey],
app.BankKeeper,
app.UGovKeeperB.EmergencyGroup,
)

// register the staking hooks
Expand Down
20 changes: 10 additions & 10 deletions proto/umee/auction/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ option go_package = "github.com/umee-network/umee/v6/x/auction";
// Query defines the gRPC querier service.
service Query {
// QueryRewardParams queries parameters for the reward auciton.
rpc RewardParams(QueryRewardParams) returns (QueryRewardParamsResponse) {
rpc RewardsParams(QueryRewardsParams) returns (QueryRewardsParamsResponse) {
option (google.api.http).get = "/umee/auction/v1/rewards/params";
}
// RewardAuction queries the information of the auction by ID. If ID is ommitted, returns
// current reward auction params.
rpc RewardAuction(QueryRewardAuction) returns (QueryRewardAuctionResponse) {
rpc RewardsAuction(QueryRewardsAuction) returns (QueryRewardsAuctionResponse) {
option (google.api.http).get = "/umee/auction/v1/rewards";
}
}

// Query type for Query/RewardParams
message QueryRewardParams {}
// Query type for Query/RewardsParams
message QueryRewardsParams {}

// Response type for Query/RewardParams
message QueryRewardParamsResponse {
// Response type for Query/RewardsParams
message QueryRewardsParamsResponse {
RewardsParams params = 1 [(gogoproto.nullable) = false];
}

// Query type for QueryRewardAuction
message QueryRewardAuction {
// Query type for QueryRewardsAuction
message QueryRewardsAuction {
// If zero or not present, the current auction is returned
uint32 id = 1;
}

// Response type for Query/RewardAuctionResponse
message QueryRewardAuctionResponse {
// Response type for Query/RewardsAuctionResponse
message QueryRewardsAuctionResponse {
uint32 id = 1;
// highest bidder
string bidder = 2;
Expand Down
37 changes: 37 additions & 0 deletions x/auction/keeper/grpc_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package keeper

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/umee-network/umee/v6/x/auction"
)

// Querier implements a QueryServer for the x/uibc module.
type Querier struct {
Builder
}

func NewQuerier(kb Builder) auction.QueryServer {
return Querier{Builder: kb}
}

// Params returns params of the x/auction module.
func (q Querier) RewardsParams(goCtx context.Context, _ *auction.QueryRewardsParams) (
*auction.QueryRewardsParamsResponse, error,
) {
ctx := sdk.UnwrapSDKContext(goCtx)
params := q.Keeper(&ctx).GetRewardsParams()

return &auction.QueryRewardsParamsResponse{Params: params}, nil
}

// RewardsAuction returns params of the x/auction module.
func (q Querier) RewardsAuction(goCtx context.Context, _ *auction.QueryRewardsAuction) (
*auction.QueryRewardsAuctionResponse, error,
) {
ctx := sdk.UnwrapSDKContext(goCtx)
b := q.Keeper(&ctx)
return b.currentRewardsAuction()

}
18 changes: 14 additions & 4 deletions x/auction/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,34 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

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

type Builder struct {
cdc codec.Codec
storeKey storetypes.StoreKey
bank auction.BankKeeper
ugov ugov.EmergencyGroupBuilder
}

func NewBuilder(cdc codec.Codec, key storetypes.StoreKey, b auction.BankKeeper) Builder {
return Builder{cdc: cdc, storeKey: key, bank: b}
func NewBuilder(cdc codec.Codec,
key storetypes.StoreKey,
b auction.BankKeeper,
ugov ugov.EmergencyGroupBuilder) Builder {

return Builder{cdc: cdc, storeKey: key, bank: b, ugov: ugov}
}

func (kb Builder) Keeper(ctx *sdk.Context) Keeper {
return Keeper{
ctx: ctx,
ctx: ctx,
bank: kb.bank,
ugov: kb.ugov(ctx),
}
}

type Keeper struct {
ctx *sdk.Context
ctx *sdk.Context
bank auction.BankKeeper
ugov ugov.WithEmergencyGroup
}
57 changes: 57 additions & 0 deletions x/auction/keeper/msg_server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package keeper

import (
"context"

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

var _ auction.MsgServer = msgServer{}

type msgServer struct {
kb Builder
}

// NewMsgServer returns an implementation of auction.MsgServer
func NewMsgServer(kb Builder) auction.MsgServer {
return &msgServer{kb: kb}
}

// GovSetRewardsParams implements types.MsgServer
func (m msgServer) GovSetRewardsParams(ctx context.Context, msg *auction.MsgGovSetRewardsParams) (
*auction.MsgGovSetRewardsParamsResponse, error,
) {
sdkCtx, err := sdkutil.StartMsg(ctx, msg)
if err != nil {
return nil, err
}

k := m.kb.Keeper(&sdkCtx)
byEmergencyGroup, err := checkers.EmergencyGroupAuthority(msg.Authority, k.ugov)
if err != nil {
return nil, err
}

if err := k.SetRewardsParams(msg, byEmergencyGroup); err != nil {
return nil, err
}
return &auction.MsgGovSetRewardsParamsResponse{}, nil
}

// RewardsBid implements types.MsgServer
func (m msgServer) RewardsBid(ctx context.Context, msg *auction.MsgRewardsBid) (
*auction.MsgRewardsBidResponse, error,
) {
sdkCtx, err := sdkutil.StartMsg(ctx, msg)
if err != nil {
return nil, err
}

k := m.kb.Keeper(&sdkCtx)
if err := k.rewardsBid(msg); err != nil {
return nil, err
}
return &auction.MsgRewardsBidResponse{}, nil
}
15 changes: 15 additions & 0 deletions x/auction/keeper/params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package keeper

import (
"github.com/umee-network/umee/v6/x/auction"
)

// GetRewardsParams gets the x/uibc module's parameters.
func (k Keeper) GetRewardsParams() (params auction.RewardsParams) {
panic("not implemented")
}
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved

// SetRewardsParams sets params
func (k Keeper) SetRewardsParams(msg *auction.MsgGovSetRewardsParams, byEmergencyGroup bool) error {
panic("not implemented")
}
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 13 additions & 0 deletions x/auction/keeper/rewards.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package keeper

import (
"github.com/umee-network/umee/v6/x/auction"
)

func (k Keeper) rewardsBid(msg *auction.MsgRewardsBid) error {
panic("not implemented")
}
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved

func (k Keeper) currentRewardsAuction() (*auction.QueryRewardsAuctionResponse, error) {
panic("not implemented")
}
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions x/auction/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func (AppModule) ConsensusVersion() uint64 {

// RegisterServices registers gRPC services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
// auction.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
// auction.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper))
auction.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.kb))
auction.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.kb))
}

// RegisterInvariants registers the x/auction module's invariants.
Expand Down
Loading
Loading