* accounts/abi: simplified reflection logic
* accounts/abi: simplified reflection logic
* accounts/abi: removed unpack
* accounts/abi: removed comments
* accounts/abi: removed uneccessary complications
* accounts/abi: minor changes in error messages
* accounts/abi: removed unnused code
* accounts/abi: fixed indexed argument unpacking
* accounts/abi: removed superfluous test cases
This commit removes two test cases. The first one is trivially invalid as we have the same
test cases as passing in packing_test.go L375. The second one passes now,
because we don't need the mapArgNamesToStructFields in unpack_atomic anymore.
Checking for purely underscored arg names generally should not be something we do
as the abi/contract is generally out of the control of the user.
* accounts/abi: removed comments, debug println
* accounts/abi: added commented out code
* accounts/abi: addressed comments
* accounts/abi: remove unnecessary dst.CanSet check
* accounts/abi: added dst.CanSet checks
* accounts/abi: added documentation
* accounts/abi: reduced usage of arguments.LengthNonIndexed
* accounts/abi: simplified reflection logic
* accounts/abi: moved testjson data into global declaration
* accounts/abi: removed duplicate test cases
* accounts/abi: reworked abi tests
* accounts/abi: added more tests for abi packing
* accounts/abi/bind: refactored base tests
* accounts/abi: run pack tests as subtests
* accounts/abi: removed duplicate tests
* accounts/abi: removed unnused arguments.LengthNonIndexed
Due to refactors to the code, we do not need the arguments.LengthNonIndexed function anymore.
You can still get the length by calling len(arguments.NonIndexed())
* accounts/abi: added type test
* accounts/abi: modified unpack test to pack test
* accounts/abi: length check on arrayTy
* accounts/abi: test invalid abi
* accounts/abi: fixed rebase error
* accounts/abi: fixed rebase errors
* accounts/abi: removed unused definition
* accounts/abi: merged packing/unpacking tests
* accounts/abi: fixed [][][32]bytes encoding
* accounts/abi: added tuple test cases
* accounts/abi: renamed getMockLog -> newMockLog
* accounts/abi: removed duplicate test
* accounts/abi: bools -> booleans
* 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
* accounts/abi, cmd/abigen: support tuple
accounts/abi/bind, cmd/abigen: add objc back
accounts/abi/bind: use byte[24] as function indicator
accounts/abi/bind: resolve struct slice or array
accounts/abi/bind: remove sort logic
accounts: fix issues in abi
* accounts/abi: address comment
* accounts/abi: fix name styling when unpacking abi fields w/ underscores
ABI fields with underscores that are being unpacked
into structs expect structs with following form:
int_one -> Int_one
whereas in abigen the generated structs are camelcased
int_one -> IntOne
so updated the unpack method to expect camelcased structs as well.
+ The event slice unpacker doesn't correctly extract element from the
slice. The indexed arguments are not ignored as they should be
(the data offset should not include the indexed arguments).
+ The `Elem()` call in the slice unpack doesn't work.
The Slice related tests fails because of that.
+ the check in the loop are suboptimal and have been extracted
out of the loop.
+ extracted common code from event and method tupleUnpack
* accounts/abi: reorganizing package and some notes and a quick correction of name.
Signed-off-by: RJ Catalano <rj@monax.io>
get rid of some imports
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: move file names
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: fix boolean decode function
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: fix for the array set and for creating a bool
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: be very very very correct
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: fix up error message and variable names
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: take out unnecessary argument in pack method
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: add bool unpack test and add a panic to readBool function
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: fix panic message
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: change from panic to basic error
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: fix nil to false
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: fill out type regex tests and fill with the correct type for integers
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: move packNumbers into pack.go.
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: separation of the testing suite into appropriately named files.
Signed-off-by: RJ Catalano <rj@monax.io>
* account/abi: change to hex string tests.
Signed-off-by: RJ Catalano <rj@monax.io>
* account/abi: fix up rest of tests to hex
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: declare bool at the package level
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: use errors package in the error file.
Signed-off-by: RJ Catalano <rj@monax.io>
* accounts/abi: fix ugly hack and fix error type declaration.
Signed-off-by: RJ Catalano <rj@monax.io>
Previously it was assumed that wheneven type `[]interface{}` was given
that the interface was empty. The abigen rightfully assumed that
interface slices which already have pre-allocated variable sets to be
assigned.
This PR fixes that by checking that the given `[]interface{}` is larger
than zero and assigns each value using the generic `set` function (this
function has also been moved to abi/reflect.go) and checks whether the
assignment was possible.
The generic assignment function `set` now also deals with pointers
(useful for interface slice mentioned above) by dereferencing the
pointer until it finds a setable type.
Refactored the abi package parsing and type handling. Relying mostly on
package reflect as opposed to most of our own type reflection. Our own
type reflection is still used however for cases such as Bytes and
FixedBytes (abi: bytes•).
This also inclused several fixes for slice handling of arbitrary and
fixed size for all supported types.
This also further removes implicit type casting such as assigning,
for example `[2]T{} = []T{1}` will fail, however `[2]T{} == []T{1, 2}`
(notice assigning *slice* to fixed size *array*). Assigning arrays to
slices will always succeed if they are of the same element type.
Incidentally also fixes#2379