diff --git a/api/service/restclientsupport/puzzle_service.go b/api/service/restclientsupport/puzzle_service.go index 158b0b3c7..96e9e7249 100644 --- a/api/service/restclientsupport/puzzle_service.go +++ b/api/service/restclientsupport/puzzle_service.go @@ -47,6 +47,7 @@ func (s *Service) Payout(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") address := r.FormValue("address") newLevel := r.FormValue("new_level") + sequence := r.FormValue("sequence") newLevelInt, err := strconv.Atoi(newLevel) fmt.Println("Payout: address", address, "new_level", newLevelInt) @@ -59,7 +60,7 @@ func (s *Service) Payout(w http.ResponseWriter, r *http.Request) { return } - if err = s.CreateTransactionForPayoutMethod(common.HexToAddress(address), uint8(newLevelInt), "" /* place holder for steps*/); err != nil { + if err = s.CreateTransactionForPayoutMethod(common.HexToAddress(address), newLevelInt, sequence); err != nil { utils.GetLogInstance().Error("Payout error", err) json.NewEncoder(w).Encode(res) return diff --git a/api/service/restclientsupport/service.go b/api/service/restclientsupport/service.go index fa7612369..f97840939 100644 --- a/api/service/restclientsupport/service.go +++ b/api/service/restclientsupport/service.go @@ -36,7 +36,7 @@ type Service struct { CallFaucetContract func(common.Address) common.Hash GetAccountBalance func(common.Address) (*big.Int, error) CreateTransactionForPlayMethod func(string, int64) error - CreateTransactionForPayoutMethod func(common.Address, uint8, string) error + CreateTransactionForPayoutMethod func(common.Address, int, string) error } // New returns new client support service. @@ -46,7 +46,7 @@ func New( CreateTransactionForPickWinner func() error, CallFaucetContract func(common.Address) common.Hash, GetAccountBalance func(common.Address) (*big.Int, error), CreateTransactionForPlayMethod func(string, int64) error, - CreateTransactionForPayoutMethod func(common.Address, uint8, string) error) *Service { + CreateTransactionForPayoutMethod func(common.Address, int, string) error) *Service { return &Service{ CreateTransactionForEnterMethod: CreateTransactionForEnterMethod, GetResult: GetResult, @@ -104,7 +104,7 @@ func (s *Service) Run() *http.Server { s.router.Path("/play").HandlerFunc(s.Play) // Set up router for payout. - s.router.Path("/payout").Queries("address", "{[0-9A-Fa-fx]*?}", "new_level", "{[0-9]*?}").HandlerFunc(s.Payout).Methods("GET") + s.router.Path("/payout").Queries("address", "{[0-9A-Fa-fx]*?}", "level", "{[0-9]*?}", "sequence", "{[A-Za-z]*?}").HandlerFunc(s.Payout).Methods("GET") s.router.Path("/payout").HandlerFunc(s.Payout) // Do serving now. utils.GetLogInstance().Info("Listening on ", "port: ", Port) diff --git a/node/puzzle_contract.go b/node/puzzle_contract.go index 1958607e9..62cd2c610 100644 --- a/node/puzzle_contract.go +++ b/node/puzzle_contract.go @@ -22,7 +22,6 @@ const ( Payout = "payout" ) -// OneEther represents one ether. var OneEther = big.NewInt(params.Ether) // AddPuzzleContract adds the demo puzzle contract the genesis block. @@ -54,7 +53,6 @@ func (node *Node) AddPuzzleContract() { func (node *Node) CreateTransactionForPlayMethod(priKey string, amount int64) error { var err error toAddress := node.PuzzleContractAddress - 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) @@ -85,7 +83,7 @@ func (node *Node) CreateTransactionForPlayMethod(priKey string, amount int64) er toAddress, node.NodeConfig.ShardID, Stake, - params.TxGas*10, + params.TxGas*100, nil, bytesData, ) @@ -103,7 +101,7 @@ func (node *Node) CreateTransactionForPlayMethod(priKey string, amount int64) er } // CreateTransactionForPayoutMethod generates transaction for payout method and add it into pending tx list. -func (node *Node) CreateTransactionForPayoutMethod(address common.Address, newLevel uint8, steps string) error { +func (node *Node) CreateTransactionForPayoutMethod(address common.Address, level int, sequence string) error { var err error toAddress := node.PuzzleContractAddress @@ -114,7 +112,7 @@ func (node *Node) CreateTransactionForPayoutMethod(address common.Address, newLe } // add params for address payable player, uint8 new_level, steps string fmt.Println("Payout: address", address) - bytesData, err := abi.Pack(Payout, address, big.NewInt(int64(newLevel)), steps) + bytesData, err := abi.Pack(Payout, address, big.NewInt(int64(level)), sequence) if err != nil { utils.GetLogInstance().Error("Failed to generate ABI function bytes data", "error", err) return err