Skip to content

Conversation

@natsukagami
Copy link
Contributor

@natsukagami natsukagami commented Jul 7, 2020

This seems to be partially fixed by #19303, however the .validate() method of TypedDataDomain still errors out when there is no chain ID.

According to EIP 712, chainId is optional.

I have removed the non-nil check and changed it so that validate only rejects completely empty domains. Tests included.


This change is Reviewable

}

if len(domain.Name) == 0 && len(domain.Version) == 0 && len(domain.VerifyingContract) == 0 && len(domain.Salt) == 0 {
if domain.ChainId == nil && len(domain.Name) == 0 && len(domain.Version) == 0 && len(domain.VerifyingContract) == 0 && len(domain.Salt) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why you moved domain.ChainId == nil into this clause? I don't understand

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EIP-712 says the domain has to have at least one of the fields (chain ID, name, version, verifying contract or salt) (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#definition-of-domainseparator)
I supposed this check was responsibile for enforcing that condition.

@holiman holiman merged commit b2b14e6 into ethereum:master Aug 3, 2020
@holiman
Copy link
Contributor

holiman commented Aug 3, 2020

Thanks!

@holiman holiman added this to the 1.9.19 milestone Aug 3, 2020
enriquefynn pushed a commit to enriquefynn/go-ethereum that referenced this pull request Mar 10, 2021
…a ChainId (ethereum#21306)

* Do not check for a non-nil ChainId

* Add encoding test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants