/
proposal.go
62 lines (49 loc) · 1.77 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
package types
import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"gopkg.in/yaml.v3"
)
const (
// ProposalTypeUpdateRegistryProposal defines the type for a UpdateRegistryProposal
// proposal type.
ProposalTypeUpdateRegistryProposal = "UpdateRegistryProposal"
)
func init() {
govtypes.RegisterProposalType(ProposalTypeUpdateRegistryProposal)
govtypes.RegisterProposalTypeCodec(&UpdateRegistryProposal{}, "umee/UpdateRegistryProposal")
}
// Assert UpdateRegistryProposal implements govtypes.Content at compile-time
var _ govtypes.Content = &UpdateRegistryProposal{}
func NewUpdateRegistryProposal(title, description string, tokens []Token) *UpdateRegistryProposal {
return &UpdateRegistryProposal{
Title: title,
Description: description,
Registry: tokens,
}
}
// String implements the Stringer interface.
func (p UpdateRegistryProposal) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}
// GetTitle returns the title of the proposal.
func (p *UpdateRegistryProposal) GetTitle() string { return p.Title }
// GetDescription returns the description of the proposal.
func (p *UpdateRegistryProposal) GetDescription() string { return p.Description }
// ProposalRoute returns the x/gov routing key of the proposal.
func (p *UpdateRegistryProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the x/gov type of the proposal.
func (p *UpdateRegistryProposal) ProposalType() string { return ProposalTypeUpdateRegistryProposal }
// ValidateBasic validates the proposal returning an error if invalid.
func (p *UpdateRegistryProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(p)
if err != nil {
return err
}
for _, token := range p.Registry {
if err := token.Validate(); err != nil {
return err
}
}
return nil
}