Update types.go

This commit is contained in:
crStiv 2025-01-11 23:21:05 +01:00 committed by GitHub
parent c78dcbccbe
commit 1df93d5c6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 11 deletions

View File

@ -499,17 +499,14 @@ func (typedData *TypedData) encodeArrayValue(encValue interface{}, encType strin
arrayBuffer := new(bytes.Buffer)
parsedType := strings.Split(encType, "[")[0]
// Special handling for bytes arrays
for _, item := range arrayValue {
if parsedType == "bytes" {
bytesValue, err := typedData.EncodePrimitiveValue(encType, encValue, depth)
bytesValue, err := typedData.EncodePrimitiveValue(parsedType, item, depth)
if err != nil {
return nil, err
}
return bytesValue, nil
}
for _, item := range arrayValue {
if reflect.TypeOf(item).Kind() == reflect.Slice ||
arrayBuffer.Write(bytesValue)
} else if reflect.TypeOf(item).Kind() == reflect.Slice ||
reflect.TypeOf(item).Kind() == reflect.Array {
encodedData, err := typedData.encodeArrayValue(item, parsedType, depth+1)
if err != nil {