I have a struct.
struct Order {
uint256 price;
uint256 quantity;
OrderType orderType;
}
enum OrderType {
BUY,
SELL
}
Question is, how should I create typehash for EIP712 in solidity. I'm doing this,
bytes32 public constant _ORDER_TYPEHASH =
keccak256(
"Order(uint256 price,uint256 quantity,OrderType orderType)"
);
And to create signature for test using ethers.js I'm creating type like this
Order: [
{
name: "price",
type: "uint256",
},
{
name: "quantity",
type: "uint256",
},
{
name: "orderType",
type: "uint8",
},
],
I'm using uint8
for OrderType as ethers.js don't know what enum
is. The signature generated from signing this is invalid.
When I remove OrderType
from Order
struct and from _ORDER_TYPEHASH
then signature generated is valid.
Now I do not know I'm doing wrong encoding in solidity or in javascript.