/
msg_participate.go
47 lines (38 loc) · 1.01 KB
/
msg_participate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package types
import (
sdkerrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const TypeMsgParticipate = "participate"
var _ sdk.Msg = &MsgParticipate{}
func NewMsgParticipate(participant string, auctionID uint64, tierID uint64) *MsgParticipate {
return &MsgParticipate{
Participant: participant,
AuctionID: auctionID,
TierID: tierID,
}
}
func (msg *MsgParticipate) Route() string {
return RouterKey
}
func (msg *MsgParticipate) Type() string {
return TypeMsgParticipate
}
func (msg *MsgParticipate) GetSigners() []sdk.AccAddress {
participant, err := sdk.AccAddressFromBech32(msg.Participant)
if err != nil {
panic(err)
}
return []sdk.AccAddress{participant}
}
func (msg *MsgParticipate) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
func (msg *MsgParticipate) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Participant)
if err != nil {
return sdkerrors.Wrap(ErrInvalidAddress, err.Error())
}
return nil
}