-
Notifications
You must be signed in to change notification settings - Fork 100
/
msg_attest.go
48 lines (39 loc) · 1.31 KB
/
msg_attest.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 data
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)
var _ legacytx.LegacyMsg = &MsgAttest{}
// ValidateBasic does a sanity check on the provided data.
func (m *MsgAttest) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Attestor); err != nil {
return sdkerrors.ErrInvalidAddress.Wrap(err.Error())
}
if len(m.ContentHashes) == 0 {
return sdkerrors.ErrInvalidRequest.Wrap("content hashes cannot be empty")
}
for _, hash := range m.ContentHashes {
if hash == nil {
return sdkerrors.ErrInvalidRequest.Wrap("content hash cannot be empty")
}
err := hash.Validate()
if err != nil {
return err
}
}
return nil
}
// GetSigners returns the expected signers for MsgAttest.
func (m *MsgAttest) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Attestor)
return []sdk.AccAddress{addr}
}
// Route implements the LegacyMsg interface.
func (m MsgAttest) Route() string { return sdk.MsgTypeURL(&m) }
// Type implements the LegacyMsg interface.
func (m MsgAttest) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes implements the LegacyMsg interface.
func (m MsgAttest) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}