From 1fbf91e83354774ab7f114d37d1ed28e9f8a1a88 Mon Sep 17 00:00:00 2001 From: ak Date: Wed, 1 May 2019 22:16:52 -0700 Subject: [PATCH] local tests pass --- api/service/restclientsupport/service.go | 10 +++------- node/puzzle_contract.go | 5 +++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/api/service/restclientsupport/service.go b/api/service/restclientsupport/service.go index 207072085..ee6a7fccd 100644 --- a/api/service/restclientsupport/service.go +++ b/api/service/restclientsupport/service.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 diff --git a/node/puzzle_contract.go b/node/puzzle_contract.go index 411cbad9a..cb156d94c 100644 --- a/node/puzzle_contract.go +++ b/node/puzzle_contract.go @@ -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)