cosmos-sdk/x/upgrade/types/proposal.go

69 lines
2.3 KiB
Go
Raw Normal View History

2019-11-08 06:40:56 -08:00
package types
import (
"fmt"
refactor: move legacy gov to v1beta1 (#10748) Ref: #9810 Moves all legacy gov code to `v1beta1`. This preserves all existing behavior (i.e. everything still uses v1beta1). It's merely moving things around to get everything in the right place logistically (hence the large diff still) --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-12-13 10:48:44 -08:00
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
2019-11-08 06:40:56 -08:00
)
const (
ProposalTypeSoftwareUpgrade string = "SoftwareUpgrade"
ProposalTypeCancelSoftwareUpgrade string = "CancelSoftwareUpgrade"
2019-11-08 06:40:56 -08:00
)
func NewSoftwareUpgradeProposal(title, description string, plan Plan) gov.Content {
return &SoftwareUpgradeProposal{title, description, plan}
2019-11-08 06:40:56 -08:00
}
// Implements Proposal Interface
var _ gov.Content = &SoftwareUpgradeProposal{}
2019-11-08 06:40:56 -08:00
func init() {
gov.RegisterProposalType(ProposalTypeSoftwareUpgrade)
gov.RegisterProposalTypeCodec(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal")
2019-11-08 06:40:56 -08:00
gov.RegisterProposalType(ProposalTypeCancelSoftwareUpgrade)
gov.RegisterProposalTypeCodec(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal")
2019-11-08 06:40:56 -08:00
}
func (sup *SoftwareUpgradeProposal) GetTitle() string { return sup.Title }
func (sup *SoftwareUpgradeProposal) GetDescription() string { return sup.Description }
func (sup *SoftwareUpgradeProposal) ProposalRoute() string { return RouterKey }
func (sup *SoftwareUpgradeProposal) ProposalType() string { return ProposalTypeSoftwareUpgrade }
func (sup *SoftwareUpgradeProposal) ValidateBasic() error {
2019-11-08 06:40:56 -08:00
if err := sup.Plan.ValidateBasic(); err != nil {
return err
}
return gov.ValidateAbstract(sup)
2019-11-08 06:40:56 -08:00
}
func (sup SoftwareUpgradeProposal) String() string {
return fmt.Sprintf(`Software Upgrade Proposal:
Title: %s
Description: %s
`, sup.Title, sup.Description)
}
func NewCancelSoftwareUpgradeProposal(title, description string) gov.Content {
return &CancelSoftwareUpgradeProposal{title, description}
2019-11-08 06:40:56 -08:00
}
// Implements Proposal Interface
var _ gov.Content = &CancelSoftwareUpgradeProposal{}
2019-11-08 06:40:56 -08:00
func (csup *CancelSoftwareUpgradeProposal) GetTitle() string { return csup.Title }
func (csup *CancelSoftwareUpgradeProposal) GetDescription() string { return csup.Description }
func (csup *CancelSoftwareUpgradeProposal) ProposalRoute() string { return RouterKey }
func (csup *CancelSoftwareUpgradeProposal) ProposalType() string {
2019-11-08 06:40:56 -08:00
return ProposalTypeCancelSoftwareUpgrade
}
func (csup *CancelSoftwareUpgradeProposal) ValidateBasic() error {
return gov.ValidateAbstract(csup)
2019-11-08 06:40:56 -08:00
}
func (csup CancelSoftwareUpgradeProposal) String() string {
2019-11-08 06:40:56 -08:00
return fmt.Sprintf(`Cancel Software Upgrade Proposal:
Title: %s
Description: %s
`, csup.Title, csup.Description)
2019-11-08 06:40:56 -08:00
}