Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid hex address on empty input array #294

Open
ypcat opened this issue Oct 11, 2024 · 1 comment
Open

invalid hex address on empty input array #294

ypcat opened this issue Oct 11, 2024 · 1 comment

Comments

@ypcat
Copy link

ypcat commented Oct 11, 2024

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.

@treeder
Copy link
Contributor

treeder commented Oct 12, 2024

PR welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants