File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -965,11 +965,7 @@ func isPrimitiveTypeValid(primitiveType string) bool {
965965// validate checks if the given domain is valid, i.e. contains at least
966966// the minimum viable keys and values
967967func (domain * TypedDataDomain ) validate () error {
968- if domain .ChainId == nil {
969- return errors .New ("chainId must be specified according to EIP-155" )
970- }
971-
972- if len (domain .Name ) == 0 && len (domain .Version ) == 0 && len (domain .VerifyingContract ) == 0 && len (domain .Salt ) == 0 {
968+ if domain .ChainId == nil && len (domain .Name ) == 0 && len (domain .Version ) == 0 && len (domain .VerifyingContract ) == 0 && len (domain .Salt ) == 0 {
973969 return errors .New ("domain is undefined" )
974970 }
975971
Original file line number Diff line number Diff line change @@ -245,6 +245,10 @@ func TestDomainChainId(t *testing.T) {
245245 if _ , ok := withoutChainID .Domain .Map ()["chainId" ]; ok {
246246 t .Errorf ("Expected the chainId key to not be present in the domain map" )
247247 }
248+ // should encode successfully
249+ if _ , err := withoutChainID .HashStruct ("EIP712Domain" , withoutChainID .Domain .Map ()); err != nil {
250+ t .Errorf ("Expected the typedData to encode the domain successfully, got %v" , err )
251+ }
248252 withChainID := core.TypedData {
249253 Types : core.Types {
250254 "EIP712Domain" : []core.Type {
@@ -261,6 +265,10 @@ func TestDomainChainId(t *testing.T) {
261265 if _ , ok := withChainID .Domain .Map ()["chainId" ]; ! ok {
262266 t .Errorf ("Expected the chainId key be present in the domain map" )
263267 }
268+ // should encode successfully
269+ if _ , err := withChainID .HashStruct ("EIP712Domain" , withChainID .Domain .Map ()); err != nil {
270+ t .Errorf ("Expected the typedData to encode the domain successfully, got %v" , err )
271+ }
264272}
265273
266274func TestHashStruct (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments