Skip to content

Allow null-ish properties in TypedData domains to imply unspecified #3623

Open
@frangio

Description

@frangio

Ethers Version

5.7.2

Search Terms

hashDomain

Describe the Problem

hashDomain throws an error when the argument is a domain object with name: undefined. Note that it correctly processes a domain object with no name at all, because it's an optional field. A name field with an undefined value should be treated the same way, if only because TypeScript can't distinguish a missing field from an undefined-valued field.

This probably applies to all the other optional domain fields as well, though I haven't tested.

Code Snippet

utils._TypedDataEncoder.hashDomain({ name: undefined })

Contract ABI

No response

Errors

Uncaught TypeError: Cannot read properties of undefined (reading 'length')
    at toUtf8Bytes (node_modules/@ethersproject/strings/lib/utf8.js:179:29)
    at id (node_modules/@ethersproject/hash/lib/id.js:7:65)
    at node_modules/@ethersproject/hash/lib/typed-data.js:161:32
    at node_modules/@ethersproject/hash/lib/typed-data.js:293:56

Environment

No response

Environment (Other)

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or improvement.minor-bumpPlanned for the next minor version bump.v5Issues regarding legacy-v5

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions