Thanks to visit codestin.com
Credit goes to github.com

Skip to content

invalid hex address on empty input array #294

@ypcat

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.

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