accounts/abi: return error on fixed bytes with size larger than 32 bytes (#26075)

* fixed bytes with size larger than 32 bytes is not allowed

* add testcase
This commit is contained in:
Daniel Liu 2025-01-14 10:56:14 +08:00
parent 4292979685
commit 19085392a2
2 changed files with 10 additions and 0 deletions

View file

@ -153,6 +153,9 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
if varSize == 0 {
typ.T = BytesTy
} else {
if varSize > 32 {
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
}
typ.T = FixedBytesTy
typ.Size = varSize
}

View file

@ -366,3 +366,10 @@ func TestGetTypeSize(t *testing.T) {
}
}
}
func TestNewFixedBytesOver32(t *testing.T) {
_, err := NewType("bytes4096", "", nil)
if err == nil {
t.Errorf("fixed bytes with size over 32 is not spec'd")
}
}