-
Notifications
You must be signed in to change notification settings - Fork 16
/
message_withdraw_and_mint.go
48 lines (38 loc) · 1.09 KB
/
message_withdraw_and_mint.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
48
package types
import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ sdk.Msg = &MsgWithdrawAndMint{}
func NewMsgWithdrawAndMint(address string, microMintRate int64) *MsgWithdrawAndMint {
return &MsgWithdrawAndMint{
Address: address,
MicroMintRate: microMintRate,
}
}
func (msg MsgWithdrawAndMint) Route() string {
return RouterKey
}
func (msg MsgWithdrawAndMint) Type() string {
return "WithdrawAndMint"
}
func (msg *MsgWithdrawAndMint) GetSigners() []sdk.AccAddress {
depositor := sdk.MustAccAddressFromBech32(msg.GetAddress())
return []sdk.AccAddress{depositor}
}
func (msg *MsgWithdrawAndMint) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
func (msg *MsgWithdrawAndMint) ValidateBasic() error {
// Ensure the address is correct and that we are able to acquire it
_, err := sdk.AccAddressFromBech32(msg.GetAddress())
if err != nil {
return errorsmod.Wrapf(ErrInvalidSignerAddress, err.Error())
}
// Check the micro min rate
if msg.MicroMintRate <= 0 {
return ErrEmptyMicroMintRate
}
return nil
}