2018-11-19 09:02:34 -08:00
|
|
|
package utils
|
2018-10-24 06:19:48 -07:00
|
|
|
|
2019-06-05 16:26:17 -07:00
|
|
|
import "github.com/cosmos/cosmos-sdk/x/gov/types"
|
2019-04-30 09:31:38 -07:00
|
|
|
|
2018-10-24 06:19:48 -07:00
|
|
|
// NormalizeVoteOption - normalize user specified vote option
|
|
|
|
func NormalizeVoteOption(option string) string {
|
|
|
|
switch option {
|
|
|
|
case "Yes", "yes":
|
2019-06-05 16:26:17 -07:00
|
|
|
return types.OptionYes.String()
|
2019-04-30 09:31:38 -07:00
|
|
|
|
2018-10-24 06:19:48 -07:00
|
|
|
case "Abstain", "abstain":
|
2019-06-05 16:26:17 -07:00
|
|
|
return types.OptionAbstain.String()
|
2019-04-30 09:31:38 -07:00
|
|
|
|
2018-10-24 06:19:48 -07:00
|
|
|
case "No", "no":
|
2019-06-05 16:26:17 -07:00
|
|
|
return types.OptionNo.String()
|
2019-04-30 09:31:38 -07:00
|
|
|
|
2018-10-24 06:19:48 -07:00
|
|
|
case "NoWithVeto", "no_with_veto":
|
2019-06-05 16:26:17 -07:00
|
|
|
return types.OptionNoWithVeto.String()
|
2019-04-30 09:31:38 -07:00
|
|
|
|
|
|
|
default:
|
2020-08-13 06:20:02 -07:00
|
|
|
return option
|
2018-10-24 06:19:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//NormalizeProposalType - normalize user specified proposal type
|
|
|
|
func NormalizeProposalType(proposalType string) string {
|
|
|
|
switch proposalType {
|
|
|
|
case "Text", "text":
|
2019-06-05 16:26:17 -07:00
|
|
|
return types.ProposalTypeText
|
2019-04-30 09:31:38 -07:00
|
|
|
|
|
|
|
default:
|
|
|
|
return ""
|
2018-10-24 06:19:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//NormalizeProposalStatus - normalize user specified proposal status
|
|
|
|
func NormalizeProposalStatus(status string) string {
|
|
|
|
switch status {
|
|
|
|
case "DepositPeriod", "deposit_period":
|
|
|
|
return "DepositPeriod"
|
|
|
|
case "VotingPeriod", "voting_period":
|
|
|
|
return "VotingPeriod"
|
|
|
|
case "Passed", "passed":
|
|
|
|
return "Passed"
|
|
|
|
case "Rejected", "rejected":
|
|
|
|
return "Rejected"
|
2020-08-11 07:22:30 -07:00
|
|
|
default:
|
|
|
|
return status
|
2018-10-24 06:19:48 -07:00
|
|
|
}
|
|
|
|
}
|