github.com/InjectiveLabs/sdk-go@v1.53.0/chain/ocr/types/proposal.go (about) 1 package types 2 3 import ( 4 "cosmossdk.io/errors" 5 govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" 6 ) 7 8 // constants 9 const ( 10 ProposalTypeOcrSetConfig string = "ProposalTypeOcrSetConfig" 11 ProposalTypeOcrBatchSetConfig string = "ProposalTypeOcrBatchSetConfig" 12 ) 13 14 func init() { 15 govtypes.RegisterProposalType(ProposalTypeOcrSetConfig) 16 govtypes.RegisterProposalType(ProposalTypeOcrBatchSetConfig) 17 } 18 19 // Implements Proposal Interface 20 var _ govtypes.Content = &SetConfigProposal{} 21 var _ govtypes.Content = &SetBatchConfigProposal{} 22 23 // GetTitle returns the title of this proposal. 24 func (p *SetConfigProposal) GetTitle() string { 25 return p.Title 26 } 27 28 // GetDescription returns the description of this proposal. 29 func (p *SetConfigProposal) GetDescription() string { 30 return p.Description 31 } 32 33 // ProposalRoute returns router key of this proposal. 34 func (p *SetConfigProposal) ProposalRoute() string { return RouterKey } 35 36 // ProposalType returns proposal type of this proposal. 37 func (p *SetConfigProposal) ProposalType() string { 38 return ProposalTypeOcrSetConfig 39 } 40 41 // ValidateBasic returns ValidateBasic result of this proposal. 42 func (p *SetConfigProposal) ValidateBasic() error { 43 if p.Config == nil { 44 return errors.Wrap(ErrIncompleteProposal, "proposal is missing config") 45 } 46 47 if err := p.Config.ValidateBasic(); err != nil { 48 return err 49 } 50 51 return govtypes.ValidateAbstract(p) 52 } 53 54 // GetTitle returns the title of this proposal. 55 func (p *SetBatchConfigProposal) GetTitle() string { 56 return p.Title 57 } 58 59 // GetDescription returns the description of this proposal. 60 func (p *SetBatchConfigProposal) GetDescription() string { 61 return p.Description 62 } 63 64 // ProposalRoute returns router key of this proposal. 65 func (p *SetBatchConfigProposal) ProposalRoute() string { return RouterKey } 66 67 // ProposalType returns proposal type of this proposal. 68 func (p *SetBatchConfigProposal) ProposalType() string { 69 return ProposalTypeOcrBatchSetConfig 70 } 71 72 // ValidateBasic returns ValidateBasic result of this proposal. 73 func (p *SetBatchConfigProposal) ValidateBasic() error { 74 if len(p.FeedProperties) == 0 { 75 return errors.Wrap(ErrIncompleteProposal, "proposal is missing feeds") 76 } 77 78 for _, feed := range p.FeedProperties { 79 f := FeedConfig{ 80 Signers: p.Signers, 81 Transmitters: p.Transmitters, 82 F: feed.F, 83 OnchainConfig: feed.OnchainConfig, 84 OffchainConfigVersion: feed.OffchainConfigVersion, 85 OffchainConfig: feed.OffchainConfig, 86 ModuleParams: &ModuleParams{ 87 FeedId: feed.FeedId, 88 MinAnswer: feed.MinAnswer, 89 MaxAnswer: feed.MaxAnswer, 90 LinkPerObservation: feed.LinkPerObservation, 91 LinkPerTransmission: feed.LinkPerTransmission, 92 LinkDenom: p.LinkDenom, 93 UniqueReports: feed.UniqueReports, 94 Description: feed.Description, 95 }, 96 } 97 98 if err := f.ValidateBasic(); err != nil { 99 return err 100 } 101 } 102 return govtypes.ValidateAbstract(p) 103 }