-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
proposal.go
70 lines (56 loc) · 2.06 KB
/
proposal.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
58
59
60
61
62
63
64
65
66
67
68
69
70
package types
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
)
const (
// ProposalTypeClientUpdate defines the type for a ClientUpdateProposal
ProposalTypeClientUpdate = "ClientUpdate"
)
var (
_ govtypes.Content = &ClientUpdateProposal{}
_ codectypes.UnpackInterfacesMessage = ClientUpdateProposal{}
)
// NewClientUpdateProposal creates a new client update proposal.
func NewClientUpdateProposal(title, description, clientID string, header exported.Header) (*ClientUpdateProposal, error) {
any, err := PackHeader(header)
if err != nil {
return nil, err
}
return &ClientUpdateProposal{
Title: title,
Description: description,
ClientId: clientID,
Header: any,
}, nil
}
// GetTitle returns the title of a client update proposal.
func (cup *ClientUpdateProposal) GetTitle() string { return cup.Title }
// GetDescription returns the description of a client update proposal.
func (cup *ClientUpdateProposal) GetDescription() string { return cup.Description }
// ProposalRoute returns the routing key of a client update proposal.
func (cup *ClientUpdateProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of a client update proposal.
func (cup *ClientUpdateProposal) ProposalType() string { return ProposalTypeClientUpdate }
// ValidateBasic runs basic stateless validity checks
func (cup *ClientUpdateProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(cup)
if err != nil {
return err
}
if err := host.ClientIdentifierValidator(cup.ClientId); err != nil {
return err
}
header, err := UnpackHeader(cup.Header)
if err != nil {
return err
}
return header.ValidateBasic()
}
// UnpackInterfaces implements the UnpackInterfacesMessage interface.
func (cup ClientUpdateProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
var header exported.Header
return unpacker.UnpackAny(cup.Header, &header)
}