* accounts/abi/bind: fix duplicate field names in the generated go struct #24627
* accounts, cmd/abigen: resolve name conflicts
* ci lint, accounts/abi: remove unused function overloadedArgName
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
* accounts/abi: fix a bug in getTypeSize method
e.g. for "Tuple[2]" type, the element of the array is a tuple type and the size of the tuple may not be 32.
* accounts/abi: add unit test of getTypeSize method
* accounts/abi: allow overloaded argument names
In solidity it is possible to create the following contract:
```
contract Overloader {
struct F { uint _f; uint __f; uint f; }
function f(F memory f) public {}
}
```
This however resulted in a panic in the abi package.
* accounts/abi fixed error handling
* accounts/abi: fix various issues
The fixed issues include:
(1) If there is no return in a call function, unpack should
return nil error
(2) For some functions which have struct array as parameter,
it will also be detected and generate the struct definition
(3) For event, if it has non-indexed parameter, the parameter
name will also be assigned if empty. Also the internal struct
will be detected and generate struct defition if not exist.
(4) Fix annotation generation in event function
* accounts/abi: add new abi field internalType
* accounts: address comments and add tests
* accounts/abi: replace strings.ReplaceAll with strings.Replace
* 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: 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>
On solidity contract I have "uint32 []" type, when abigen creates Go
bindings - they are also "[]uint32" type on Go side. Even though it
looks like it should work - the actual type of the data coming from
the chain is of type " []*big.Int".
When executing contract function from Go side - getting unmarshal error:
abi: cannot unmarshal []*big.Int in to []uint32
The fix is to create array with the correct type
This fixed the issue reported in: https://github.com/ethereum/go-ethereum/issues/2802
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
Fixed up `[]byte` slice support such that `function print(bytes input)`
accepts `[]byte` as input and treats it as 1 element rather than a slice
of multiple elements.
Added support for variable length input parameters like `bytes` and
`strings`.
Removed old unmarshalling of return types: `abi.Call(...).([]byte)`.
This is now replaced by a new syntax:
```
var a []byte
err := abi.Call(&a, ...)
```
It also addresses a few issues with Bytes and Strings and can also
handle both fixed and arbitrary sized byte slices, including strings.