This adds a tools.go file to import all command packages used for
go:generate. Doing so makes it possible to execute go-based code
generators using 'go run', locking in the tool version using go.mod.
Co-authored-by: Felix Lange <fjl@twurst.com>
This commit replaces ioutil.TempDir with t.TempDir in tests. The
directory created by t.TempDir is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using ioutil.TempDir
had to be removed manually by calling os.RemoveAll, which is omitted in
some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but t.TempDir handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This replaces the simple selector parser in signer/fourbyte with one that
can actually handle most types. The new parser is added in accounts/abi
to also make it useable elsewhere.
* accounts/abi: prevent recalculation of ID, Sig and String
* accounts/abi: fixed unpacking of no values
* accounts/abi: multiple fixes to arguments
* accounts/abi: refactored methodName and eventName
This commit moves the complicated logic of how we assign method names
and event names if they already exist into their own functions for
better readability.
* accounts/abi: prevent recalculation of internal
In this commit, I changed the way we calculate the string
representations, sig representations and the id's of methods. Before
that these fields would be recalculated everytime someone called .Sig()
.String() or .ID() on a method or an event.
Additionally this commit fixes issue #20856 as we assign names to inputs
with no name (input with name "" becomes "arg0")
* accounts/abi: added unnamed event params test
* accounts/abi: fixed rebasing errors in method sig
* accounts/abi: fixed rebasing errors in method sig
* accounts/abi: addressed comments
* accounts/abi: added FunctionType enumeration
* accounts/abi/bind: added test for unnamed arguments
* accounts/abi: improved readability in NewMethod, nitpicks
* accounts/abi: method/eventName -> overloadedMethodName
The abi package already supports function overload by adding a suffix to the overloaded function name, but it uses the function name with suffix to calculate signature(both for the event and method).
This PR fixes it by adding a new field named RawName, which can be used to calcuate all signatures but use Name to distinguish different overloaded function.