Additional auction module commands #3
@ -367,3 +367,11 @@ func (k Keeper) GetParams(ctx sdk.Context) (*auctiontypes.Params, error) {
|
|||||||
|
|
||||||
return ¶ms, nil
|
return ¶ms, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAuctionModuleBalances gets the auction module account(s) balances.
|
||||||
|
func (k Keeper) GetAuctionModuleBalances(ctx sdk.Context) sdk.Coins {
|
||||||
|
moduleAddress := k.accountKeeper.GetModuleAddress(auctiontypes.ModuleName)
|
||||||
|
balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress)
|
||||||
|
|
||||||
|
return balances
|
||||||
|
}
|
||||||
|
@ -10,8 +10,6 @@ import (
|
|||||||
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
|
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Add required read methods
|
|
||||||
|
|
||||||
var _ auctiontypes.QueryServer = queryServer{}
|
var _ auctiontypes.QueryServer = queryServer{}
|
||||||
|
|
||||||
type queryServer struct {
|
type queryServer struct {
|
||||||
@ -39,12 +37,12 @@ func (qs queryServer) Params(c context.Context, req *auctiontypes.QueryParamsReq
|
|||||||
func (qs queryServer) Auctions(c context.Context, req *auctiontypes.QueryAuctionsRequest) (*auctiontypes.QueryAuctionsResponse, error) {
|
func (qs queryServer) Auctions(c context.Context, req *auctiontypes.QueryAuctionsRequest) (*auctiontypes.QueryAuctionsResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
|
||||||
resp, err := qs.k.ListAuctions(ctx)
|
auctions, err := qs.k.ListAuctions(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &auctiontypes.QueryAuctionsResponse{Auctions: &auctiontypes.Auctions{Auctions: resp}}, nil
|
return &auctiontypes.QueryAuctionsResponse{Auctions: &auctiontypes.Auctions{Auctions: auctions}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAuction queries an auction by id
|
// GetAuction queries an auction by id
|
||||||
@ -91,12 +89,12 @@ func (qs queryServer) GetBids(c context.Context, req *auctiontypes.QueryBidsRequ
|
|||||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "auction id is required")
|
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "auction id is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := qs.k.GetBids(ctx, req.AuctionId)
|
bids, err := qs.k.GetBids(ctx, req.AuctionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &auctiontypes.QueryBidsResponse{Bids: resp}, nil
|
return &auctiontypes.QueryBidsResponse{Bids: bids}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuctionsByBidder queries auctions by bidder
|
// AuctionsByBidder queries auctions by bidder
|
||||||
@ -133,5 +131,8 @@ func (qs queryServer) AuctionsByOwner(c context.Context, req *auctiontypes.Query
|
|||||||
|
|
||||||
// GetAuctionModuleBalance queries the auction module account balance
|
// GetAuctionModuleBalance queries the auction module account balance
|
||||||
func (qs queryServer) GetAuctionModuleBalance(c context.Context, req *auctiontypes.QueryGetAuctionModuleBalanceRequest) (*auctiontypes.QueryGetAuctionModuleBalanceResponse, error) {
|
func (qs queryServer) GetAuctionModuleBalance(c context.Context, req *auctiontypes.QueryGetAuctionModuleBalanceRequest) (*auctiontypes.QueryGetAuctionModuleBalanceResponse, error) {
|
||||||
panic("unimplemented")
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
balances := qs.k.GetAuctionModuleBalances(ctx)
|
||||||
|
|
||||||
|
return &auctiontypes.QueryGetAuctionModuleBalanceResponse{Balance: balances}, nil
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
|
|||||||
{ProtoField: "bidder_address"},
|
{ProtoField: "bidder_address"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
RpcMethod: "GetAuctionModuleBalance",
|
||||||
|
Use: "balance",
|
||||||
|
Short: "Get auction module account balances",
|
||||||
|
PositionalArgs: []*autocliv1.PositionalArgDescriptor{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Tx: &autocliv1.ServiceCommandDescriptor{
|
Tx: &autocliv1.ServiceCommandDescriptor{
|
||||||
|
Loading…
Reference in New Issue
Block a user