diff --git a/eth/client.go b/eth/client.go index 3c06a533b9..98bc467d4c 100644 --- a/eth/client.go +++ b/eth/client.go @@ -114,8 +114,8 @@ type LivepeerEthClient interface { // Governance Vote(ethcommon.Address, *big.Int) (*types.Transaction, error) - ProposalVote(*big.Int, uint8) (*types.Transaction, error) - ProposalVoteWithReason(*big.Int, uint8, string) (*types.Transaction, error) + ProposalVote(*big.Int, *big.Int) (*types.Transaction, error) + ProposalVoteWithReason(*big.Int, *big.Int, string) (*types.Transaction, error) // Helpers ContractAddresses() map[string]ethcommon.Address @@ -133,16 +133,16 @@ type client struct { transOpts bind.TransactOpts transOptsMu sync.RWMutex - controllerAddr ethcommon.Address - tokenAddr ethcommon.Address - serviceRegistryAddr ethcommon.Address - bondingManagerAddr ethcommon.Address - ticketBrokerAddr ethcommon.Address - roundsManagerAddr ethcommon.Address - minterAddr ethcommon.Address - verifierAddr ethcommon.Address - faucetAddr ethcommon.Address - governorAddr ethcommon.Address + controllerAddr ethcommon.Address + tokenAddr ethcommon.Address + serviceRegistryAddr ethcommon.Address + bondingManagerAddr ethcommon.Address + ticketBrokerAddr ethcommon.Address + roundsManagerAddr ethcommon.Address + minterAddr ethcommon.Address + verifierAddr ethcommon.Address + faucetAddr ethcommon.Address + livepeerGovernorAddr ethcommon.Address // Contracts controller *contracts.Controller @@ -330,22 +330,22 @@ func (c *client) setContracts(opts *bind.TransactOpts) error { glog.V(common.SHORT).Infof("LivepeerTokenFaucet: %v", c.faucetAddr.Hex()) - governorAddr, err := c.GetContract(crypto.Keccak256Hash([]byte("LivepeerGovernor"))) + livepeerGovernorAddr, err := c.GetContract(crypto.Keccak256Hash([]byte("LivepeerGovernor"))) if err != nil { glog.Errorf("Error getting Governor address: %v", err) return err } - c.governorAddr = governorAddr + c.livepeerGovernorAddr = livepeerGovernorAddr - governor, err := contracts.NewGovernor(governorAddr, c.backend) + governor, err := contracts.NewGovernor(livepeerGovernorAddr, c.backend) if err != nil { glog.Errorf("Error creating Governor binding: %v", err) return err } c.livepeerGovernor = governor - glog.V(common.SHORT).Infof("LivepeerGovernor: %v", c.governorAddr.Hex()) + glog.V(common.SHORT).Infof("LivepeerGovernor: %v", c.livepeerGovernorAddr.Hex()) return nil } @@ -1012,8 +1012,8 @@ func (c *client) Vote(pollAddr ethcommon.Address, choiceID *big.Int) (*types.Tra return poll.Vote(opts, choiceID) } -func (c *client) ProposalVote(proposalId *big.Int, support uint8) (*types.Transaction, error) { - return c.livepeerGovernor.CastVote(c.transactOpts(), proposalId, support) +func (c *client) ProposalVote(proposalId *big.Int, support *big.Int) (*types.Transaction, error) { + return c.livepeerGovernor.CastVote(c.transactOpts(), proposalId, uint8(support)) } func (c *client) ProposalVoteWithReason(proposalId *big.Int, support uint8, reason string) (*types.Transaction, error) { diff --git a/server/handlers.go b/server/handlers.go index 1733fc00b2..99a1ea47c1 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -1291,12 +1291,12 @@ func proposalVoteHandler(client eth.LivepeerEthClient) http.Handler { } supportStr := r.FormValue("support") - support, err := strconv.Atoi(supportStr) - if err != nil { + support, ok := new(big.Int).SetString(supportStr, 10) + if !ok { respond500(w, "support is not a valid integer value") return } - if !types.ProposalVoteChoice(support).IsValid() { + if !types.ProposalVoteChoice(int(support.Int64())).IsValid() { respond500(w, "invalid support") return } @@ -1305,10 +1305,11 @@ func proposalVoteHandler(client eth.LivepeerEthClient) http.Handler { // submit tx var tx *ethtypes.Transaction + var err error if reason != "" { - tx, err = client.ProposalVoteWithReason(proposalID, uint8(support), reason) + tx, err = client.ProposalVoteWithReason(proposalID, uint8(support.Uint64()), reason) } else { - tx, err = client.ProposalVote(proposalID, uint8(support)) + tx, err = client.ProposalVote(proposalID, uint8(support.Uint64())) } if err != nil { respond500(w, fmt.Sprintf("unable to submit proposal vote transaction err=%q", err))