Add msg validation for auction module

This commit is contained in:
Prathamesh Musale 2024-03-04 19:10:33 +05:30
parent 639b4e6333
commit a6023966e4
3 changed files with 18 additions and 7 deletions

View File

@ -118,6 +118,8 @@ func (ets *E2ETestSuite) createBond() string {
sr.NoError(err) sr.NoError(err)
// extract bond id from bonds list // extract bond id from bonds list
bond := queryResponse.GetBonds()[0] bonds := queryResponse.GetBonds()
return bond.GetId() sr.NotEmpty(bonds)
return queryResponse.GetBonds()[0].GetId()
} }

View File

@ -285,12 +285,11 @@ func (k Keeper) QueryAuctionsByBidder(ctx sdk.Context, bidderAddress string) ([]
// CreateAuction creates a new auction. // CreateAuction creates a new auction.
func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction) (*auctiontypes.Auction, error) { func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction) (*auctiontypes.Auction, error) {
// TODO: Setup checks
// Might be called from another module directly, always validate. // Might be called from another module directly, always validate.
// err := msg.ValidateBasic() err := msg.ValidateBasic()
// if err != nil { if err != nil {
// return nil, err return nil, err
// } }
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
if err != nil { if err != nil {

View File

@ -52,6 +52,11 @@ func (ms msgServer) CreateAuction(c context.Context, msg *auctiontypes.MsgCreate
// CommitBid is the command for committing a bid // CommitBid is the command for committing a bid
// nolint: all // nolint: all
func (ms msgServer) CommitBid(c context.Context, msg *auctiontypes.MsgCommitBid) (*auctiontypes.MsgCommitBidResponse, error) { func (ms msgServer) CommitBid(c context.Context, msg *auctiontypes.MsgCommitBid) (*auctiontypes.MsgCommitBidResponse, error) {
err := msg.ValidateBasic()
if err != nil {
return nil, err
}
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
@ -83,6 +88,11 @@ func (ms msgServer) CommitBid(c context.Context, msg *auctiontypes.MsgCommitBid)
// RevealBid is the command for revealing a bid // RevealBid is the command for revealing a bid
// nolint: all // nolint: all
func (ms msgServer) RevealBid(c context.Context, msg *auctiontypes.MsgRevealBid) (*auctiontypes.MsgRevealBidResponse, error) { func (ms msgServer) RevealBid(c context.Context, msg *auctiontypes.MsgRevealBid) (*auctiontypes.MsgRevealBidResponse, error) {
err := msg.ValidateBasic()
if err != nil {
return nil, err
}
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)