Additional auction module commands #3

Merged
ashwin merged 8 commits from pm-bid-commands into main 2024-02-15 06:56:20 +00:00
3 changed files with 22 additions and 7 deletions
Showing only changes of commit 842dfc6185 - Show all commits

View File

@ -367,3 +367,11 @@ func (k Keeper) GetParams(ctx sdk.Context) (*auctiontypes.Params, error) {
return &params, 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
}

View File

@ -10,8 +10,6 @@ import (
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
)
// TODO: Add required read methods
var _ auctiontypes.QueryServer = queryServer{}
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) {
ctx := sdk.UnwrapSDKContext(c)
resp, err := qs.k.ListAuctions(ctx)
auctions, err := qs.k.ListAuctions(ctx)
if err != nil {
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
@ -91,12 +89,12 @@ func (qs queryServer) GetBids(c context.Context, req *auctiontypes.QueryBidsRequ
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 {
return nil, err
}
return &auctiontypes.QueryBidsResponse{Bids: resp}, nil
return &auctiontypes.QueryBidsResponse{Bids: bids}, nil
}
// 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
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
}

View File

@ -68,6 +68,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
{ProtoField: "bidder_address"},
},
},
{
RpcMethod: "GetAuctionModuleBalance",
Use: "balance",
Short: "Get auction module account balances",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{},
},
},
},
Tx: &autocliv1.ServiceCommandDescriptor{