/
msg-mint.go
49 lines (42 loc) · 1.18 KB
/
msg-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
49
package msg
import (
"encoding/json"
"fmt"
"github.com/Sotatek-huytran2/go-sdk/common/types"
)
type MintMsg struct {
From types.AccAddress `json:"from"`
Symbol string `json:"symbol"`
Amount int64 `json:"amount"`
}
func NewMintMsg(from types.AccAddress, symbol string, amount int64) MintMsg {
return MintMsg{
From: from,
Symbol: symbol,
Amount: amount,
}
}
func (msg MintMsg) ValidateBasic() error {
if msg.From == nil {
return fmt.Errorf("sender address cannot be empty")
}
if msg.Amount <= 0 {
return fmt.Errorf("Amount cant be less than 0 ")
}
return nil
}
// Implements MintMsg.
func (msg MintMsg) Route() string { return "tokensIssue" }
func (msg MintMsg) Type() string { return "mintMsg" }
func (msg MintMsg) String() string { return fmt.Sprintf("MintMsg{%#v}", msg) }
func (msg MintMsg) GetSigners() []types.AccAddress { return []types.AccAddress{msg.From} }
func (msg MintMsg) GetSignBytes() []byte {
b, err := json.Marshal(msg) // XXX: ensure some canonical form
if err != nil {
panic(err)
}
return b
}
func (msg MintMsg) GetInvolvedAddresses() []types.AccAddress {
return msg.GetSigners()
}