Skip to content

invalid hex address on empty input array #294

Description

@ypcat

Hi,

I found when calling contract from cli with empty array input would cause this error:

ERROR: Error calling constant function: invalid hex address:

I think the root cause should be that strings.Split on empty string results in a slice with one empty string ([""]) instead of 0-length ([]).

web3/web3.go

Lines 462 to 469 in c84726a

case abi.SliceTy, abi.ArrayTy:
s, ok := param.(string)
if !ok {
return nil, fmt.Errorf("invalid array: %s", s)
}
s = strings.TrimPrefix(s, "[")
s = strings.TrimSuffix(s, "]")
inputArray := strings.Split(s, ",")

I can submit a PR if needed.

Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions