umbracle/ethgo

ABI parseMethodSignature does not handle signature without return

Closed this issue · 2 comments

The regex that checks a valid signature does not handle cases where a function does not have a return value.

function approve(address to, uint256 tokenId)

error:      no matches found
var funcRegexp = regexp.MustCompile("(.*)\\((.*)\\)(.*) returns \\((.*)\\)")

func parseMethodSignature(name string) (string, *Type, *Type, error) {
	name = strings.TrimPrefix(name, "function ")

	matches := funcRegexp.FindAllStringSubmatch(name, -1)
	if len(matches) == 0 {
		return "", nil, nil, fmt.Errorf("no matches found")
	}
    // ...
}

Could you test with #104?

Look like it works, thank you.