mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-04-14 05:38:37 +00:00
signer/core/apitypes: fix encoding of opening parenthesis (#33702)
This fixes a truncation bug that results in an invalid serialization of
empty EIP712.
For example:
```json
{
"method": "eth_signTypedData_v4",
"request": {
"types": {
"EIP712Domain": [
{
"name": "version",
"type": "string"
}
],
"Empty": []
},
"primaryType": "Empty",
"domain": {
"version": "0"
},
"message": {}
}
}
```
When calculating the type-hash for the stuct-hash, it will incorrectly
use `Empty)` instead of `Empty()`
This commit is contained in:
parent
289826fefb
commit
4da1e29320
1 changed files with 3 additions and 1 deletions
|
|
@ -454,7 +454,9 @@ func (typedData *TypedData) EncodeType(primaryType string) hexutil.Bytes {
|
|||
buffer.WriteString(obj.Name)
|
||||
buffer.WriteString(",")
|
||||
}
|
||||
buffer.Truncate(buffer.Len() - 1)
|
||||
if len(typedData.Types[dep]) > 0 {
|
||||
buffer.Truncate(buffer.Len() - 1)
|
||||
}
|
||||
buffer.WriteString(")")
|
||||
}
|
||||
return buffer.Bytes()
|
||||
|
|
|
|||
Loading…
Reference in a new issue