/
msg-setaccount.go
48 lines (40 loc) · 1.25 KB
/
msg-setaccount.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 msg
import (
"encoding/json"
"fmt"
"github.com/Sotatek-huytran2/go-sdk/common/types"
)
const (
AccountFlagsRoute = "accountFlags"
SetAccountFlagsMsgType = "setAccountFlags"
)
type SetAccountFlagsMsg struct {
From types.AccAddress `json:"from"`
Flags uint64 `json:"flags"`
}
func NewSetAccountFlagsMsg(from types.AccAddress, flags uint64) SetAccountFlagsMsg {
return SetAccountFlagsMsg{
From: from,
Flags: flags,
}
}
func (msg SetAccountFlagsMsg) Route() string { return AccountFlagsRoute }
func (msg SetAccountFlagsMsg) Type() string { return SetAccountFlagsMsgType }
func (msg SetAccountFlagsMsg) String() string {
return fmt.Sprintf("setAccountFlags{%v#%v}", msg.From, msg.Flags)
}
func (msg SetAccountFlagsMsg) GetInvolvedAddresses() []types.AccAddress { return msg.GetSigners() }
func (msg SetAccountFlagsMsg) GetSigners() []types.AccAddress { return []types.AccAddress{msg.From} }
func (msg SetAccountFlagsMsg) ValidateBasic() error {
if len(msg.From) != types.AddrLen {
return fmt.Errorf("Expected address length is %d, actual length is %d", types.AddrLen, len(msg.From))
}
return nil
}
func (msg SetAccountFlagsMsg) GetSignBytes() []byte {
b, err := json.Marshal(msg)
if err != nil {
panic(err)
}
return b
}