Skip to content

Commit

Permalink
accounts/abi: fix a bug in getTypeSize method (ethereum#21501)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tofudfy authored and unclezoro committed Jan 11, 2021
1 parent 4608da6 commit 670009d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion accounts/abi/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func isDynamicType(t Type) bool {
func getTypeSize(t Type) int {
if t.T == ArrayTy && !isDynamicType(*t.Elem) {
// Recursively calculate type size if it is a nested array
if t.Elem.T == ArrayTy {
if t.Elem.T == ArrayTy || t.Elem.T == TupleTy {
return t.Size * getTypeSize(*t.Elem)
}
return t.Size * 32
Expand Down

0 comments on commit 670009d

Please sign in to comment.