Skip to content

Commit

Permalink
index out of range panic #57 (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-gochain authored Feb 12, 2019
1 parent a47c563 commit 0dbd45b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions web3.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func CallConstantFunction(ctx context.Context, client Client, myabi abi.ABI, add
for _, t := range myabi.Methods[functionName].Outputs {
out = append(out, convertOutputParameter(t))
}
if len(myabi.Methods[functionName].Inputs) != len(parameters) {
return nil, errors.New("Wrong number of arguments expected:" + strconv.Itoa(len(myabi.Methods[functionName].Inputs)) + " given:" + strconv.Itoa(len(parameters)))
}

input, err := myabi.Pack(functionName, convertParameters(myabi.Methods[functionName], parameters)...)
if err != nil {
return nil, err
Expand Down Expand Up @@ -124,6 +128,10 @@ func CallConstantFunction(ctx context.Context, client Client, myabi abi.ABI, add
// CallTransactFunction submits a transaction to execute a smart contract function call.
func CallTransactFunction(ctx context.Context, client Client, myabi abi.ABI, address, privateKeyHex, functionName string, amount int, parameters ...interface{}) (*Transaction, error) {

if len(myabi.Methods[functionName].Inputs) != len(parameters) {
return nil, errors.New("Wrong number of arguments expected:" + strconv.Itoa(len(myabi.Methods[functionName].Inputs)) + " given:" + strconv.Itoa(len(parameters)))
}

input, err := myabi.Pack(functionName, convertParameters(myabi.Methods[functionName], parameters)...)
if err != nil {
return nil, err
Expand Down

0 comments on commit 0dbd45b

Please sign in to comment.