github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/gov/client/utils/utils.go (about)

     1  package utils
     2  
     3  import "github.com/fibonacci-chain/fbc/x/gov/types"
     4  
     5  // NormalizeVoteOption - normalize user specified vote option
     6  func NormalizeVoteOption(option string) string {
     7  	switch option {
     8  	case "Yes", "yes":
     9  		return types.OptionYes.String()
    10  
    11  	case "Abstain", "abstain":
    12  		return types.OptionAbstain.String()
    13  
    14  	case "No", "no":
    15  		return types.OptionNo.String()
    16  
    17  	case "NoWithVeto", "no_with_veto":
    18  		return types.OptionNoWithVeto.String()
    19  
    20  	default:
    21  		return ""
    22  	}
    23  }
    24  
    25  // NormalizeProposalType - normalize user specified proposal type
    26  func NormalizeProposalType(proposalType string) string {
    27  	switch proposalType {
    28  	case "Text", "text":
    29  		return types.ProposalTypeText
    30  
    31  	case "SoftwareUpgrade", "software_upgrade":
    32  		return types.ProposalTypeSoftwareUpgrade
    33  
    34  	default:
    35  		return ""
    36  	}
    37  }
    38  
    39  // NormalizeProposalStatus - normalize user specified proposal status
    40  func NormalizeProposalStatus(status string) string {
    41  	switch status {
    42  	case "DepositPeriod", "deposit_period":
    43  		return "DepositPeriod"
    44  	case "VotingPeriod", "voting_period":
    45  		return "VotingPeriod"
    46  	case "Passed", "passed":
    47  		return "Passed"
    48  	case "Rejected", "rejected":
    49  		return "Rejected"
    50  	}
    51  	return ""
    52  }