write a default 0x0 when encoutering missing struct data

This commit is contained in:
Nguyen Khoi Nguyen 2024-04-19 10:04:25 +07:00
parent 823719b9e1
commit c54ba9b435
No known key found for this signature in database
GPG key ID: 3804FB59605EBE90

View file

@ -493,6 +493,10 @@ func (typedData *TypedData) EncodeData(primaryType string, data map[string]inter
buffer.Write(crypto.Keccak256(arrayBuffer.Bytes()))
} else if typedData.Types[field.Type] != nil {
if encValue == nil {
buffer.Write(common.Hash{}.Bytes())
continue
}
mapValue, ok := encValue.(map[string]interface{})
if !ok {
return nil, dataMismatchError(encType, encValue)