-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
encodeData
doesn't support array types
#4
Comments
I'm just trying to figure this out. In EIP712 specification it is stated: if (field.type == 'array') {
for (let v of value) {
encTypes.push('bytes32');
value = ethUtil.keccak256(encodeData(field.items.type, v))
encValues.push(value);
}
} |
@alko89 That only applies for fixed-length arrays, not for arrays of arbitrary length. In that case, the encoded hash of the array would be a single bytes32 that is just the keccak256 of: the encoded values of each element in the array in 32-byte chunks |
I have created a pull request where you can see an implementation that addresses this issue. To answer the question above, I will point out that:
So: Some examples:
Since there are no good Solidity examples of this out there either, I'll point out that implementing this in Solidity is pretty straightforward: construct an array |
One other note, since the spec is worded somewhat confusingly and is structured slightly differently than the code here. The In the spec, the inclusion of the type hash is part of the definition of |
Currently a placeholder error is thrown when abi encoding an array type. This should be replaced with a genuine implementation of the ABI encoding for arrays
The text was updated successfully, but these errors were encountered: