-
Notifications
You must be signed in to change notification settings - Fork 36
/
proposal.go
104 lines (86 loc) · 3.03 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package types
import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
)
// constants
const (
ProposalTypeOcrSetConfig string = "ProposalTypeOcrSetConfig"
ProposalTypeOcrBatchSetConfig string = "ProposalTypeOcrBatchSetConfig"
)
func init() {
gov.RegisterProposalType(ProposalTypeOcrSetConfig)
gov.RegisterProposalTypeCodec(&SetConfigProposal{}, "injective/OcrSetConfigProposal")
gov.RegisterProposalTypeCodec(&SetBatchConfigProposal{}, "injective/OcrSetBatchConfigProposal")
}
// Implements Proposal Interface
var _ gov.Content = &SetConfigProposal{}
var _ gov.Content = &SetBatchConfigProposal{}
// GetTitle returns the title of this proposal.
func (p *SetConfigProposal) GetTitle() string {
return p.Title
}
// GetDescription returns the description of this proposal.
func (p *SetConfigProposal) GetDescription() string {
return p.Description
}
// ProposalRoute returns router key of this proposal.
func (p *SetConfigProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns proposal type of this proposal.
func (p *SetConfigProposal) ProposalType() string {
return ProposalTypeOcrSetConfig
}
// ValidateBasic returns ValidateBasic result of this proposal.
func (p *SetConfigProposal) ValidateBasic() error {
if p.Config == nil {
return sdkerrors.Wrap(ErrIncompleteProposal, "proposal is missing config")
}
if err := p.Config.ValidateBasic(); err != nil {
return err
}
return gov.ValidateAbstract(p)
}
// GetTitle returns the title of this proposal.
func (p *SetBatchConfigProposal) GetTitle() string {
return p.Title
}
// GetDescription returns the description of this proposal.
func (p *SetBatchConfigProposal) GetDescription() string {
return p.Description
}
// ProposalRoute returns router key of this proposal.
func (p *SetBatchConfigProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns proposal type of this proposal.
func (p *SetBatchConfigProposal) ProposalType() string {
return ProposalTypeOcrBatchSetConfig
}
// ValidateBasic returns ValidateBasic result of this proposal.
func (p *SetBatchConfigProposal) ValidateBasic() error {
if len(p.FeedProperties) == 0 {
return sdkerrors.Wrap(ErrIncompleteProposal, "proposal is missing feeds")
}
for _, feed := range p.FeedProperties {
f := FeedConfig{
Signers: p.Signers,
Transmitters: p.Transmitters,
F: feed.F,
OnchainConfig: feed.OnchainConfig,
OffchainConfigVersion: feed.OffchainConfigVersion,
OffchainConfig: feed.OffchainConfig,
ModuleParams: &ModuleParams{
FeedId: feed.FeedId,
MinAnswer: feed.MinAnswer,
MaxAnswer: feed.MaxAnswer,
LinkPerObservation: feed.LinkPerObservation,
LinkPerTransmission: feed.LinkPerTransmission,
LinkDenom: p.LinkDenom,
UniqueReports: feed.UniqueReports,
Description: feed.Description,
},
}
if err := f.ValidateBasic(); err != nil {
return err
}
}
return gov.ValidateAbstract(p)
}