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

abi/bind: fix error-handling in generated wrappers for functions returning structs #22005

Merged
merged 1 commit into from
Dec 12, 2020

Conversation

connorwstein
Copy link
Contributor

@connorwstein connorwstein commented Dec 11, 2020

In this PR the template was changed which ended up producing code like:

	var out []interface{}
	err := _NonExistentStruct.contract.Call(opts, &out, "Struct")

	outstruct := new(struct {
		A *big.Int
		B *big.Int
	})

	outstruct.A = out[0].(*big.Int)
	outstruct.B = out[1].(*big.Int)

	return *outstruct, err

which will panic instead of returning an error if the contract doesn't exist. I moved the error handling up before the indexing to avoid that (analogous to how non-struct responses are handled)

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for noticing, and adding a test 👍

@connorwstein
Copy link
Contributor Author

@MariusVanDerWijden thanks for the quick review. The build failure looks like a flake - would you be able to re-run? Don't think I have permissions to do that.

@MariusVanDerWijden
Copy link
Member

restarted

@holiman holiman changed the title Fix err handling in generated wrappers for functions returning structs abi/bind: fix error-handling in generated wrappers for functions returning structs Dec 12, 2020
@holiman holiman merged commit 38c1d59 into ethereum:master Dec 12, 2020
@holiman
Copy link
Contributor

holiman commented Dec 12, 2020

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants