-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg_register_path.go
57 lines (47 loc) · 1.49 KB
/
msg_register_path.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
50
51
52
53
54
55
56
57
package types
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
host "github.com/cosmos/ibc-go/modules/core/24-host"
)
// NewRegisterIBCPathRequest creates a message of type RegisterIBCPathRequest
func NewRegisterIBCPathRequest(sender sdk.AccAddress, chain, path string) *RegisterIBCPathRequest {
return &RegisterIBCPathRequest{
Sender: sender,
Chain: chain,
Path: path,
}
}
// Route returns the route for this message
func (m RegisterIBCPathRequest) Route() string {
return RouterKey
}
// Type returns the type of the message
func (m RegisterIBCPathRequest) Type() string {
return "RegisterIBCPath"
}
// ValidateBasic executes a stateless message validation
func (m RegisterIBCPathRequest) ValidateBasic() error {
if err := sdk.VerifyAddressFormat(m.Sender); err != nil {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, sdkerrors.Wrap(err, "sender").Error())
}
if m.Chain == "" {
return fmt.Errorf("missing chain")
}
f := host.NewPathValidator(func(path string) error {
return nil
})
if err := f(m.Path); err != nil {
return sdkerrors.Wrap(err, "invalid path")
}
return nil
}
// GetSignBytes returns the message bytes that need to be signed
func (m RegisterIBCPathRequest) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the set of signers for this message
func (m RegisterIBCPathRequest) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{m.Sender}
}