@@ -20,11 +20,11 @@ const BN_1 = BigInt(1);
20
20
const BN_MAX_UINT256 = BigInt ( "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" ) ;
21
21
22
22
export interface TypedDataDomain {
23
- name ?: string ;
24
- version ?: string ;
25
- chainId ?: BigNumberish ;
26
- verifyingContract ?: string ;
27
- salt ?: BytesLike ;
23
+ name ?: null | string ;
24
+ version ?: null | string ;
25
+ chainId ?: null | BigNumberish ;
26
+ verifyingContract ?: null | string ;
27
+ salt ?: null | BytesLike ;
28
28
} ;
29
29
30
30
export interface TypedDataField {
@@ -355,6 +355,7 @@ export class TypedDataEncoder {
355
355
static hashDomain ( domain : TypedDataDomain ) : string {
356
356
const domainFields : Array < TypedDataField > = [ ] ;
357
357
for ( const name in domain ) {
358
+ if ( ( < Record < string , any > > domain ) [ name ] == null ) { continue ; }
358
359
const type = domainFieldTypes [ name ] ;
359
360
assertArgument ( type , `invalid typed-data domain key: ${ JSON . stringify ( name ) } ` , "domain" , domain ) ;
360
361
domainFields . push ( { name, type } ) ;
@@ -384,6 +385,13 @@ export class TypedDataEncoder {
384
385
// Make a copy to isolate it from the object passed in
385
386
domain = Object . assign ( { } , domain ) ;
386
387
388
+ // Allow passing null to ignore value
389
+ for ( const key in domain ) {
390
+ if ( ( < Record < string , any > > domain ) [ key ] == null ) {
391
+ delete ( < Record < string , any > > domain ) [ key ] ;
392
+ }
393
+ }
394
+
387
395
// Look up all ENS names
388
396
const ensCache : Record < string , string > = { } ;
389
397
0 commit comments