File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -965,11 +965,7 @@ func isPrimitiveTypeValid(primitiveType string) bool {
965
965
// validate checks if the given domain is valid, i.e. contains at least
966
966
// the minimum viable keys and values
967
967
func (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 {
973
969
return errors .New ("domain is undefined" )
974
970
}
975
971
Original file line number Diff line number Diff line change @@ -245,6 +245,10 @@ func TestDomainChainId(t *testing.T) {
245
245
if _ , ok := withoutChainID .Domain .Map ()["chainId" ]; ok {
246
246
t .Errorf ("Expected the chainId key to not be present in the domain map" )
247
247
}
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
+ }
248
252
withChainID := core.TypedData {
249
253
Types : core.Types {
250
254
"EIP712Domain" : []core.Type {
@@ -261,6 +265,10 @@ func TestDomainChainId(t *testing.T) {
261
265
if _ , ok := withChainID .Domain .Map ()["chainId" ]; ! ok {
262
266
t .Errorf ("Expected the chainId key be present in the domain map" )
263
267
}
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
+ }
264
272
}
265
273
266
274
func TestHashStruct (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments