local tests pass

pull/803/head
ak 6 years ago
parent 08f961b4de
commit 1fbf91e833
  1. 10
      api/service/restclientsupport/service.go
  2. 5
      node/puzzle_contract.go

@ -35,7 +35,7 @@ type Service struct {
messageChan chan *msg_pb.Message
CallFaucetContract func(common.Address) common.Hash
GetAccountBalance func(common.Address) (*big.Int, error)
CreateTransactionForPlayMethod func(string, int) error
CreateTransactionForPlayMethod func(string, string) error
CreateTransactionForPayoutMethod func(string, int, string) error
}
@ -45,7 +45,7 @@ func New(
GetResult func(string) ([]string, []*big.Int),
CreateTransactionForPickWinner func() error,
CallFaucetContract func(common.Address) common.Hash, GetAccountBalance func(common.Address) (*big.Int, error),
CreateTransactionForPlayMethod func(string, int) error,
CreateTransactionForPlayMethod func(string, string) error,
CreateTransactionForPayoutMethod func(string, int, string) error) *Service {
return &Service{
CreateTransactionForEnterMethod: CreateTransactionForEnterMethod,
@ -255,11 +255,7 @@ func (s *Service) Play(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(res)
return
}
amountInt, err := strconv.Atoi(amount)
if err != nil {
utils.GetLogInstance().Error("error", err)
}
if err := s.CreateTransactionForPlayMethod(key, amountInt); err != nil {
if err := s.CreateTransactionForPlayMethod(key, amount); err != nil {
utils.GetLogInstance().Error("puzzle-play, error", err)
json.NewEncoder(w).Encode(res)
return

@ -48,10 +48,11 @@ func (node *Node) AddPuzzleContract() {
}
// CreateTransactionForPlayMethod generates transaction for enter method and add it into pending tx list.
func (node *Node) CreateTransactionForPlayMethod(priKey string, amount int) error {
func (node *Node) CreateTransactionForPlayMethod(priKey string, amount string) error {
var err error
toAddress := node.PuzzleContractAddress
GameStake := amount * big.NewInt(params.Ether)
GameStake := new(big.Int)
GameStake, _ = GameStake.SetString(amount, 10)
abi, err := abi.JSON(strings.NewReader(contracts.PuzzleABI))
if err != nil {
utils.GetLogInstance().Error("puzzle-play: Failed to generate staking contract's ABI", "error", err)

Loading…
Cancel
Save