forked from lavanet/lava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CNS-422: add proposal for plans delete
- Loading branch information
1 parent
4c25499
commit f6181fa
Showing
14 changed files
with
958 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package types | ||
|
||
import ( | ||
fmt "fmt" | ||
"strings" | ||
|
||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
commontypes "github.com/lavanet/lava/common/types" | ||
) | ||
|
||
const ( | ||
ProposalPlansDel = "PlansDel" | ||
) | ||
|
||
func init() { | ||
govtypes.RegisterProposalType(ProposalPlansDel) | ||
} | ||
|
||
func NewPlansDelProposal(title, description string, indices []string) *PlansDelProposal { | ||
return &PlansDelProposal{title, description, indices} | ||
} | ||
|
||
// GetTitle returns the title of a proposal. | ||
func (pcp *PlansDelProposal) GetTitle() string { return pcp.Title } | ||
|
||
// GetDescription returns the description of a proposal. | ||
func (pcp *PlansDelProposal) GetDescription() string { return pcp.Description } | ||
|
||
// ProposalRoute returns the routing key of a proposal. | ||
func (pcp *PlansDelProposal) ProposalRoute() string { return ProposalsRouterKey } | ||
|
||
// ProposalType returns the type of a proposal. | ||
func (pcp *PlansDelProposal) ProposalType() string { return ProposalPlansDel } | ||
|
||
// ValidateBasic validates the proposal | ||
func (pcp *PlansDelProposal) ValidateBasic() error { | ||
err := govtypes.ValidateAbstract(pcp) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(pcp.Plans) == 0 { | ||
return sdkerrors.Wrap(ErrEmptyPlans, "proposal plans delete cannot be empty") | ||
} | ||
for _, index := range pcp.Plans { | ||
if !commontypes.ValidateString(index, commontypes.NAME_RESTRICTIONS, nil) { | ||
return fmt.Errorf("invalid plan name: %s", index) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// String implements the Stringer interface. | ||
func (pcp PlansDelProposal) String() string { | ||
var b strings.Builder | ||
|
||
b.WriteString(fmt.Sprintf(`Plan Del Proposal: | ||
Title: %s | ||
Description: %s | ||
Deleted: %s | ||
`, pcp.Title, pcp.Description, strings.Join(pcp.Plans, ", "))) | ||
|
||
return b.String() | ||
} |
Oops, something went wrong.