Merge pull request #803 from alajko/cello_alok

Rest API fixing
pull/813/head
alajko 6 years ago committed by GitHub
commit 57b36f2e2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      api/service/restclientsupport/service.go
  2. 32
      contracts/Puzzle.go
  3. 18
      node/puzzle_contract.go

@ -35,8 +35,8 @@ type Service struct {
messageChan chan *msg_pb.Message
CallFaucetContract func(common.Address) common.Hash
GetAccountBalance func(common.Address) (*big.Int, error)
CreateTransactionForPlayMethod func(string) error
CreateTransactionForPayoutMethod func(string, int) error
CreateTransactionForPlayMethod func(string, string) error
CreateTransactionForPayoutMethod func(string, int, string) error
}
// New returns new client support service.
@ -45,8 +45,8 @@ 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) error,
CreateTransactionForPayoutMethod func(string, int) error) *Service {
CreateTransactionForPlayMethod func(string, string) error,
CreateTransactionForPayoutMethod func(string, 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("key", "{[0-9A-Fa-fx]*?}", "new_level", "{[0-9]*?}").HandlerFunc(s.Payout).Methods("GET")
s.router.Path("/payout").Queries("key", "{[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)
@ -243,6 +243,7 @@ func (s *Service) Winner(w http.ResponseWriter, r *http.Request) {
func (s *Service) Play(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
key := r.FormValue("key")
amount := r.FormValue("amount")
fmt.Println("puzzle-play", key)
res := &Response{
@ -254,8 +255,7 @@ func (s *Service) Play(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(res)
return
}
if err := s.CreateTransactionForPlayMethod(key); err != nil {
if err := s.CreateTransactionForPlayMethod(key, amount); err != nil {
utils.GetLogInstance().Error("puzzle-play, error", err)
json.NewEncoder(w).Encode(res)
return
@ -268,10 +268,13 @@ func (s *Service) Play(w http.ResponseWriter, r *http.Request) {
func (s *Service) Payout(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
key := r.FormValue("key")
newLevel := r.FormValue("new_level")
fmt.Println("payout: key", key, "new_level", newLevel)
newLevelInt, err := strconv.Atoi(newLevel)
level := r.FormValue("level")
sequence := r.FormValue("sequence")
fmt.Println("payout: key", key, "level", level, "sequence", sequence)
levelInt, err := strconv.Atoi(level)
if err != nil {
utils.GetLogInstance().Error("error", err)
}
fmt.Println("play")
res := &Response{
Success: false,
@ -282,7 +285,7 @@ func (s *Service) Payout(w http.ResponseWriter, r *http.Request) {
return
}
if err = s.CreateTransactionForPayoutMethod(key, newLevelInt); err != nil {
if err = s.CreateTransactionForPayoutMethod(key, levelInt, sequence); err != nil {
utils.GetLogInstance().Error("error", err)
json.NewEncoder(w).Encode(res)
return

@ -31,7 +31,7 @@ var (
const PuzzleABI = "[{\"constant\":false,\"inputs\":[{\"name\":\"player\",\"type\":\"address\"}],\"name\":\"endGame\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"manager\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"player\",\"type\":\"address\"},{\"name\":\"level\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"string\"}],\"name\":\"payout\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"player\",\"type\":\"address\"},{\"name\":\"level\",\"type\":\"uint256\"}],\"name\":\"setLevel\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getPlayers\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"play\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"player\",\"type\":\"address\"}],\"name\":\"resetPlayer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"reset\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"players\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]"
// PuzzleBin is the compiled bytecode used for deploying new contracts.
const PuzzleBin = `0x608060405234801561001057600080fd5b50600480546001600160a01b03191633179055610977806100326000396000f3fe6080604052600436106100865760003560e01c80638b5b9ccc116100595780638b5b9ccc146101e557806393e84cd91461024a578063c95e090914610252578063d826f88f14610285578063f71d96cb1461029a57610086565b80632a035b6c1461008b578063481c6a75146100c057806352bcd7c8146100f1578063722dcd8f146101ac575b600080fd5b34801561009757600080fd5b506100be600480360360208110156100ae57600080fd5b50356001600160a01b03166102c4565b005b3480156100cc57600080fd5b506100d56103ad565b604080516001600160a01b039092168252519081900360200190f35b6100be6004803603606081101561010757600080fd5b6001600160a01b038235169160208101359181019060608101604082013564010000000081111561013757600080fd5b82018360208201111561014957600080fd5b8035906020019184600183028401116401000000008311171561016b57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103bc945050505050565b3480156101b857600080fd5b506100be600480360360408110156101cf57600080fd5b506001600160a01b038135169060200135610569565b3480156101f157600080fd5b506101fa610585565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561023657818101518382015260200161021e565b505050509050019250505060405180910390f35b6100be6105e8565b34801561025e57600080fd5b506100be6004803603602081101561027557600080fd5b50356001600160a01b0316610722565b34801561029157600080fd5b506100be6107f6565b3480156102a657600080fd5b506100d5600480360360208110156102bd57600080fd5b50356108dc565b6004546040805180820190915260138152600160681b72556e617574686f72697a656420416363657373026020820152906001600160a01b0316331461038b57604051600160e51b62461bcd0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610350578181015183820152602001610338565b50505050905090810190601f16801561037d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506001600160a01b03166000908152600260205260409020805460ff19169055565b6004546001600160a01b031681565b6004546040805180820190915260138152600160681b72556e617574686f72697a656420416363657373026020820152906001600160a01b0316331461044757604051600160e51b62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610350578181015183820152602001610338565b506001600160a01b038316600090815260026020908152604091829020548251808401909352601f83527f506c61796572206973206e6f7420696e20616e206163746976652067616d65009183019190915260ff1615156001146104f057604051600160e51b62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610350578181015183820152602001610338565b506001600160a01b03831660009081526020819052604090205482036105168484610569565b6001600160a01b03841660008181526001602052604080822054905160059091048402929183156108fc02918491818181858888f19350505050158015610561573d6000803e3d6000fd5b505050505050565b6001600160a01b03909116600090815260208190526040902055565b606060058054806020026020016040519081016040528092919081815260200182805480156105dd57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116105bf575b505050505090505b90565b60408051808201909152601181527f496e73756666696369656e742046756e6400000000000000000000000000000060208201526801158e460913d0000034101561067857604051600160e51b62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610350578181015183820152602001610338565b503360009081526003602052604090205460ff1615156106ef57336000818152600360205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b03191690911790555b3360009081526020818152604080832083905560018083528184203490556002909252909120805460ff19169091179055565b6004546040805180820190915260138152600160681b72556e617574686f72697a656420416363657373026020820152906001600160a01b031633146107ad57604051600160e51b62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610350578181015183820152602001610338565b506001600160a01b031660009081526020818152604080832083905560028252808320805460ff1990811690915560018352818420849055600390925290912080549091169055565b6004546040805180820190915260138152600160681b72556e617574686f72697a656420416363657373026020820152906001600160a01b0316331461088157604051600160e51b62461bcd02815260040180806020018281038252838181518152602001915080519060200190808383600083811015610350578181015183820152602001610338565b5060055460005b818110156108ca5760006005828154811015156108a157fe5b6000918252602090912001546001600160a01b031690506108c181610722565b50600101610888565b5060006108d8600582610904565b5050565b60058054829081106108ea57fe5b6000918252602090912001546001600160a01b0316905081565b8154818355818111156109285760008381526020902061092891810190830161092d565b505050565b6105e591905b808211156109475760008155600101610933565b509056fea165627a7a72305820d77629ee8b56472dfdca022f06934c4f4dfcf700ce46dccd736c4eef81d380bc0029`
const PuzzleBin = `0x608060405234801561001057600080fd5b50600480546001600160a01b0319163317905561096d806100326000396000f3fe6080604052600436106100865760003560e01c80638b5b9ccc116100595780638b5b9ccc146101e557806393e84cd91461024a578063c95e090914610252578063d826f88f14610285578063f71d96cb1461029a57610086565b80632a035b6c1461008b578063481c6a75146100c057806352bcd7c8146100f1578063722dcd8f146101ac575b600080fd5b34801561009757600080fd5b506100be600480360360208110156100ae57600080fd5b50356001600160a01b03166102c4565b005b3480156100cc57600080fd5b506100d56103ad565b604080516001600160a01b039092168252519081900360200190f35b6100be6004803603606081101561010757600080fd5b6001600160a01b038235169160208101359181019060608101604082013564010000000081111561013757600080fd5b82018360208201111561014957600080fd5b8035906020019184600183028401116401000000008311171561016b57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103bc945050505050565b3480156101b857600080fd5b506100be600480360360408110156101cf57600080fd5b506001600160a01b038135169060200135610567565b3480156101f157600080fd5b506101fa610583565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561023657818101518382015260200161021e565b505050509050019250505060405180910390f35b6100be6105e6565b34801561025e57600080fd5b506100be6004803603602081101561027557600080fd5b50356001600160a01b031661071d565b34801561029157600080fd5b506100be6107f0565b3480156102a657600080fd5b506100d5600480360360208110156102bd57600080fd5b50356108d3565b6004546040805180820190915260138152600160681b72556e617574686f72697a656420416363657373026020820152906001600160a01b0316331461038b57604051600160e51b62461bcd0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610350578181015183820152602001610338565b50505050905090810190601f16801561037d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506001600160a01b03166000908152600260205260409020805460ff19169055565b6004546001600160a01b031681565b6004546040805180820190915260138152600160681b72556e617574686f72697a656420416363657373026020820152906001600160a01b0316331461044657604051600160e51b62461bcd028152602060048201818152835160248401528351909283926044909101919085019080838360008315610350578181015183820152602001610338565b506001600160a01b038316600090815260026020908152604091829020548251808401909352601f83527f506c61796572206973206e6f7420696e20616e206163746976652067616d65009183019190915260ff1615156001146104ee57604051600160e51b62461bcd028152602060048201818152835160248401528351909283926044909101919085019080838360008315610350578181015183820152602001610338565b506001600160a01b03831660009081526020819052604090205482036105148484610567565b6001600160a01b03841660008181526001602052604080822054905160059091048402929183156108fc02918491818181858888f1935050505015801561055f573d6000803e3d6000fd5b505050505050565b6001600160a01b03909116600090815260208190526040902055565b606060058054806020026020016040519081016040528092919081815260200182805480156105db57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116105bd575b505050505090505b90565b60408051808201909152601181527f496e73756666696369656e742046756e6400000000000000000000000000000060208201526801158e460913d0000034101561067557604051600160e51b62461bcd028152602060048201818152835160248401528351909283926044909101919085019080838360008315610350578181015183820152602001610338565b503360009081526003602052604090205460ff166106ea57336000818152600360205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b03191690911790555b3360009081526020818152604080832083905560018083528184203490556002909252909120805460ff19169091179055565b6004546040805180820190915260138152600160681b72556e617574686f72697a656420416363657373026020820152906001600160a01b031633146107a757604051600160e51b62461bcd028152602060048201818152835160248401528351909283926044909101919085019080838360008315610350578181015183820152602001610338565b506001600160a01b031660009081526020818152604080832083905560028252808320805460ff1990811690915560018352818420849055600390925290912080549091169055565b6004546040805180820190915260138152600160681b72556e617574686f72697a656420416363657373026020820152906001600160a01b0316331461087a57604051600160e51b62461bcd028152602060048201818152835160248401528351909283926044909101919085019080838360008315610350578181015183820152602001610338565b5060055460005b818110156108c15760006005828154811061089857fe5b6000918252602090912001546001600160a01b031690506108b88161071d565b50600101610881565b5060006108cf6005826108fa565b5050565b600581815481106108e057fe5b6000918252602090912001546001600160a01b0316905081565b81548183558181111561091e5760008381526020902061091e918101908301610923565b505050565b6105e391905b8082111561093d5760008155600101610929565b509056fea165627a7a7230582062a9296ff3394d1dc60def0222978a34a1ef4444a5fcee620e83cc345fd292660029`
// DeployPuzzle deploys a new Ethereum contract, binding an instance of Puzzle to it.
func DeployPuzzle(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Puzzle, error) {
@ -242,7 +242,7 @@ func (_Puzzle *PuzzleCallerSession) Manager() (common.Address, error) {
// Players is a free data retrieval call binding the contract method 0xf71d96cb.
//
// Solidity: function players(uint256 ) constant returns(address)
// Solidity: function players( uint256) constant returns(address)
func (_Puzzle *PuzzleCaller) Players(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) {
var (
ret0 = new(common.Address)
@ -254,56 +254,56 @@ func (_Puzzle *PuzzleCaller) Players(opts *bind.CallOpts, arg0 *big.Int) (common
// Players is a free data retrieval call binding the contract method 0xf71d96cb.
//
// Solidity: function players(uint256 ) constant returns(address)
// Solidity: function players( uint256) constant returns(address)
func (_Puzzle *PuzzleSession) Players(arg0 *big.Int) (common.Address, error) {
return _Puzzle.Contract.Players(&_Puzzle.CallOpts, arg0)
}
// Players is a free data retrieval call binding the contract method 0xf71d96cb.
//
// Solidity: function players(uint256 ) constant returns(address)
// Solidity: function players( uint256) constant returns(address)
func (_Puzzle *PuzzleCallerSession) Players(arg0 *big.Int) (common.Address, error) {
return _Puzzle.Contract.Players(&_Puzzle.CallOpts, arg0)
}
// EndGame is a paid mutator transaction binding the contract method 0x2a035b6c.
//
// Solidity: function endGame(address player) returns()
// Solidity: function endGame(player address) returns()
func (_Puzzle *PuzzleTransactor) EndGame(opts *bind.TransactOpts, player common.Address) (*types.Transaction, error) {
return _Puzzle.contract.Transact(opts, "endGame", player)
}
// EndGame is a paid mutator transaction binding the contract method 0x2a035b6c.
//
// Solidity: function endGame(address player) returns()
// Solidity: function endGame(player address) returns()
func (_Puzzle *PuzzleSession) EndGame(player common.Address) (*types.Transaction, error) {
return _Puzzle.Contract.EndGame(&_Puzzle.TransactOpts, player)
}
// EndGame is a paid mutator transaction binding the contract method 0x2a035b6c.
//
// Solidity: function endGame(address player) returns()
// Solidity: function endGame(player address) returns()
func (_Puzzle *PuzzleTransactorSession) EndGame(player common.Address) (*types.Transaction, error) {
return _Puzzle.Contract.EndGame(&_Puzzle.TransactOpts, player)
}
// Payout is a paid mutator transaction binding the contract method 0x52bcd7c8.
//
// Solidity: function payout(address player, uint256 level, string ) returns()
// Solidity: function payout(player address, level uint256, string) returns()
func (_Puzzle *PuzzleTransactor) Payout(opts *bind.TransactOpts, player common.Address, level *big.Int, arg2 string) (*types.Transaction, error) {
return _Puzzle.contract.Transact(opts, "payout", player, level, arg2)
}
// Payout is a paid mutator transaction binding the contract method 0x52bcd7c8.
//
// Solidity: function payout(address player, uint256 level, string ) returns()
// Solidity: function payout(player address, level uint256, string) returns()
func (_Puzzle *PuzzleSession) Payout(player common.Address, level *big.Int, arg2 string) (*types.Transaction, error) {
return _Puzzle.Contract.Payout(&_Puzzle.TransactOpts, player, level, arg2)
}
// Payout is a paid mutator transaction binding the contract method 0x52bcd7c8.
//
// Solidity: function payout(address player, uint256 level, string ) returns()
// Solidity: function payout(player address, level uint256, string) returns()
func (_Puzzle *PuzzleTransactorSession) Payout(player common.Address, level *big.Int, arg2 string) (*types.Transaction, error) {
return _Puzzle.Contract.Payout(&_Puzzle.TransactOpts, player, level, arg2)
}
@ -352,42 +352,42 @@ func (_Puzzle *PuzzleTransactorSession) Reset() (*types.Transaction, error) {
// ResetPlayer is a paid mutator transaction binding the contract method 0xc95e0909.
//
// Solidity: function resetPlayer(address player) returns()
// Solidity: function resetPlayer(player address) returns()
func (_Puzzle *PuzzleTransactor) ResetPlayer(opts *bind.TransactOpts, player common.Address) (*types.Transaction, error) {
return _Puzzle.contract.Transact(opts, "resetPlayer", player)
}
// ResetPlayer is a paid mutator transaction binding the contract method 0xc95e0909.
//
// Solidity: function resetPlayer(address player) returns()
// Solidity: function resetPlayer(player address) returns()
func (_Puzzle *PuzzleSession) ResetPlayer(player common.Address) (*types.Transaction, error) {
return _Puzzle.Contract.ResetPlayer(&_Puzzle.TransactOpts, player)
}
// ResetPlayer is a paid mutator transaction binding the contract method 0xc95e0909.
//
// Solidity: function resetPlayer(address player) returns()
// Solidity: function resetPlayer(player address) returns()
func (_Puzzle *PuzzleTransactorSession) ResetPlayer(player common.Address) (*types.Transaction, error) {
return _Puzzle.Contract.ResetPlayer(&_Puzzle.TransactOpts, player)
}
// SetLevel is a paid mutator transaction binding the contract method 0x722dcd8f.
//
// Solidity: function setLevel(address player, uint256 level) returns()
// Solidity: function setLevel(player address, level uint256) returns()
func (_Puzzle *PuzzleTransactor) SetLevel(opts *bind.TransactOpts, player common.Address, level *big.Int) (*types.Transaction, error) {
return _Puzzle.contract.Transact(opts, "setLevel", player, level)
}
// SetLevel is a paid mutator transaction binding the contract method 0x722dcd8f.
//
// Solidity: function setLevel(address player, uint256 level) returns()
// Solidity: function setLevel(player address, level uint256) returns()
func (_Puzzle *PuzzleSession) SetLevel(player common.Address, level *big.Int) (*types.Transaction, error) {
return _Puzzle.Contract.SetLevel(&_Puzzle.TransactOpts, player, level)
}
// SetLevel is a paid mutator transaction binding the contract method 0x722dcd8f.
//
// Solidity: function setLevel(address player, uint256 level) returns()
// Solidity: function setLevel(player address, level uint256) returns()
func (_Puzzle *PuzzleTransactorSession) SetLevel(player common.Address, level *big.Int) (*types.Transaction, error) {
return _Puzzle.Contract.SetLevel(&_Puzzle.TransactOpts, player, level)
}

@ -22,9 +22,6 @@ const (
Payout = "payout"
)
// OneEther represents one ether.
var OneEther = big.NewInt(params.Ether)
// AddPuzzleContract adds the demo puzzle contract the genesis block.
func (node *Node) AddPuzzleContract() {
// Add a puzzle demo contract.
@ -51,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) error {
func (node *Node) CreateTransactionForPlayMethod(priKey string, amount string) error {
var err error
toAddress := node.PuzzleContractAddress
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)
@ -72,7 +70,7 @@ func (node *Node) CreateTransactionForPlayMethod(priKey string) error {
if err != nil {
utils.GetLogInstance().Error("puzzle-play: can not get address", "error", err)
return err
} else if balance.Cmp(OneEther) == -1 {
} else if balance.Cmp(GameStake) == -1 {
utils.GetLogInstance().Error("puzzle-play: insufficient fund", "error", err)
return ErrPuzzleInsufficientFund
}
@ -81,7 +79,7 @@ func (node *Node) CreateTransactionForPlayMethod(priKey string) error {
nonce,
toAddress,
0,
OneEther,
GameStake,
params.TxGas*10,
nil,
bytesData,
@ -100,7 +98,7 @@ func (node *Node) CreateTransactionForPlayMethod(priKey string) error {
}
// CreateTransactionForPayoutMethod generates transaction for payout method and add it into pending tx list.
func (node *Node) CreateTransactionForPayoutMethod(address string, newLevel int) error {
func (node *Node) CreateTransactionForPayoutMethod(address string, level int, sequence string) error {
var err error
toAddress := node.PuzzleContractAddress
@ -109,9 +107,7 @@ func (node *Node) CreateTransactionForPayoutMethod(address string, newLevel int)
utils.GetLogInstance().Error("Failed to generate staking contract's ABI", "error", err)
return err
}
// add params for address payable player, uint8 new_level
// TODO(minh, rj)
bytesData, err := abi.Pack(Payout)
bytesData, err := abi.Pack("payout", address, level, sequence)
if err != nil {
utils.GetLogInstance().Error("Failed to generate ABI function bytes data", "error", err)
return err

Loading…
Cancel
Save