System information
Geth version: v1.14.12
CL client & version: Not related
OS & Version: OSX
Commit hash : (if develop)
Expected behaviour
Encode successfully
Actual behaviour
Get error:
failed to pack and hash typedData primary type: provided data '65' doesn't match type 'bytes'
Steps to reproduce the behaviour
-
Consider a message with a field sigs of type bytes[] in Solidity. In Go, this is represented as [][]uint8.
-
The func (typedData *TypedData) EncodeData(primaryType string, data map[string]interface{}, depth int) method recursively encodes each field. When it encounters the sigs array, it correctly identifies it as an array due to the trailing "]" in the type string.
encodeArrayValue is called, receiving the [][]uint8 as arrayValue and bytes as parsedType (correctly parsed from bytes[]).
- The problem arises within the loop of
encodeArrayValue. Each item in arrayValue (which is a []uint8 representing a Solidity bytes) is incorrectly treated as another array. This triggers a recursive call to encodeArrayValue.
- In the second, erroneous
encodeArrayValue call, the []uint8 is further split into individual uint8 values. The parsedType remains bytes (because strings.Split("bytes", "[")[0] is still bytes). This leads to an error because a single uint8 cannot be parsed as bytes.
Backtrace
When submitting logs: please submit them as text and not screenshots.
System information
Geth version: v1.14.12
CL client & version: Not related
OS & Version: OSX
Commit hash : (if
develop)Expected behaviour
Encode successfully
Actual behaviour
Get error:
Steps to reproduce the behaviour
Consider a message with a field
sigsof typebytes[]in Solidity. In Go, this is represented as[][]uint8.The
func (typedData *TypedData) EncodeData(primaryType string, data map[string]interface{}, depth int)method recursively encodes each field. When it encounters thesigsarray, it correctly identifies it as an array due to the trailing "]" in the type string.encodeArrayValueis called, receiving the[][]uint8asarrayValueandbytesasparsedType(correctly parsed frombytes[]).encodeArrayValue. Each item inarrayValue(which is a[]uint8representing a Soliditybytes) is incorrectly treated as another array. This triggers a recursive call toencodeArrayValue.encodeArrayValuecall, the[]uint8is further split into individualuint8values. TheparsedTyperemainsbytes(becausestrings.Split("bytes", "[")[0]is stillbytes). This leads to an error because a singleuint8cannot be parsed asbytes.Backtrace
When submitting logs: please submit them as text and not screenshots.