-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Closed
Labels
Description
System information
Geth version: 1.10.25
OS & Version: Ubuntu 20.04.5 LTS
Description
Typed Data providing int
/uint
types that differ from the primitive golang types are not supported while being valid Solidity types.
According to EIP-712 atomic types of type int
/uint
can be a size ranging between 8 - 256 bits
Expected behaviour
Should be able to successfully encode typed data with valid int
/uint
types between 8 - 256.
Actual behaviour
Encoding fails due to unknown primitive type.
Steps to reproduce the behaviour
package main
import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethersphere/bee/pkg/crypto/eip712"
)
func main() {
typedData := eip712.TypedData{
Domain: eip712.TypedDataDomain{
Name: "ABC",
Version: "0.0.1",
ChainId: math.NewHexOrDecimal256(1),
},
Types: eip712.Types{
"EIP712Domain": {
{Name: "name", Type: "string"},
{Name: "version", Type: "string"},
{Name: "chainId", Type: "uint256"},
{Name: "verifyingContract", Type: "address"},
},
"MainType": {
{Name: "number1", Type: "int160"}, // missing valid Solidity type.
{Name: "number2", Type: "int24"}, // missing valid Solidity type.
},
},
PrimaryType: "MainType",
Message: eip712.TypedDataMessage{
"number1": "13",
"number2": "13",
},
}
_, err := typedData.HashStruct("EIP712Domain", typedData.Domain.Map())
if err != nil {
panic(err)
}
_, err = typedData.HashStruct(typedData.PrimaryType, typedData.Message)
if err != nil {
panic(err)
}
}
Error
unknown type "int160"
unknown type "int24"