Skip to content

Commit 670009d

Browse files
tofudfyunclezoro
authored andcommitted
accounts/abi: fix a bug in getTypeSize method (ethereum#21501)
* 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
1 parent 4608da6 commit 670009d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

accounts/abi/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func isDynamicType(t Type) bool {
350350
func getTypeSize(t Type) int {
351351
if t.T == ArrayTy && !isDynamicType(*t.Elem) {
352352
// Recursively calculate type size if it is a nested array
353-
if t.Elem.T == ArrayTy {
353+
if t.Elem.T == ArrayTy || t.Elem.T == TupleTy {
354354
return t.Size * getTypeSize(*t.Elem)
355355
}
356356
return t.Size * 32

0 commit comments

Comments
 (0)