|
|
@ -3,6 +3,8 @@ package governance |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"strconv" |
|
|
|
|
|
|
|
"strings" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
type Space struct { |
|
|
|
type Space struct { |
|
|
@ -71,8 +73,36 @@ type ProposalIPFSMsg struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type ProposalVoteMsgPayload struct { |
|
|
|
type ProposalVoteMsgPayload struct { |
|
|
|
Choice int `json:"choice,string"` |
|
|
|
Choice json.RawMessage `json:"choice"` |
|
|
|
Proposal string `json:"proposal"` |
|
|
|
Proposal string `json:"proposal"` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (p *ProposalVoteMsgPayload) choices() []int { |
|
|
|
|
|
|
|
var one int |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err := json.Unmarshal(p.Choice, &one) |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
return []int{one} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var many string |
|
|
|
|
|
|
|
err = json.Unmarshal(p.Choice, &many) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return []int{} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
splits := strings.Split(many, "-") |
|
|
|
|
|
|
|
ret := make([]int, 0, len(splits)) |
|
|
|
|
|
|
|
for _, split := range splits { |
|
|
|
|
|
|
|
number, err := strconv.Atoi(split) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return []int{} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret = append(ret, number) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type ProposalVoteMsg struct { |
|
|
|
type ProposalVoteMsg struct { |
|
|
|