laconicd/x/auction/msgs.go
Prathamesh Musale 92764535a6 Additional registry module commands (#6)
For registry module:
- Add commands to:
  - get records by bond id
  - reserve name authority
  - get name authority
  - set authority bond id
  - set name
  - get and list names
  - resolve name to a record
  - delete name
- Handle:
  - genesis import / export
  - returning names when fetching record(s)
  - sub-authority reservation
- To be handled in an upcoming PR:
  - module end blocker
  - record expiry
  - command to renew records
  - bond-association commands

Reviewed-on: deep-stack/laconic2d#6
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-02-26 05:42:36 +00:00

78 lines
2.0 KiB
Go

package auction
import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
var (
_ sdk.Msg = &MsgCreateAuction{}
_ sdk.Msg = &MsgCommitBid{}
_ sdk.Msg = &MsgRevealBid{}
)
// NewMsgCreateAuction is the constructor function for MsgCreateAuction.
func NewMsgCreateAuction(params Params, signer sdk.AccAddress) MsgCreateAuction {
return MsgCreateAuction{
CommitsDuration: params.CommitsDuration,
RevealsDuration: params.RevealsDuration,
CommitFee: params.CommitFee,
RevealFee: params.RevealFee,
MinimumBid: params.MinimumBid,
Signer: signer.String(),
}
}
// NewMsgCommitBid is the constructor function for MsgCommitBid.
func NewMsgCommitBid(auctionID string, commitHash string, signer sdk.AccAddress) MsgCommitBid {
return MsgCommitBid{
AuctionId: auctionID,
CommitHash: commitHash,
Signer: signer.String(),
}
}
// ValidateBasic Implements Msg.
func (msg MsgCommitBid) ValidateBasic() error {
if msg.Signer == "" {
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer address")
}
if msg.AuctionId == "" {
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction id")
}
if msg.CommitHash == "" {
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid commit hash")
}
return nil
}
// NewMsgRevealBid is the constructor function for MsgRevealBid.
func NewMsgRevealBid(auctionId string, reveal string, signer sdk.AccAddress) MsgRevealBid {
return MsgRevealBid{
AuctionId: auctionId,
Reveal: reveal,
Signer: signer.String(),
}
}
// ValidateBasic Implements Msg.
func (msg MsgRevealBid) ValidateBasic() error {
if msg.Signer == "" {
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer address")
}
if msg.AuctionId == "" {
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction id")
}
if msg.Reveal == "" {
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal data")
}
return nil
}