Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypedData.EncodeData should not reject a Domain without a ChainId #21306

Merged
merged 2 commits into from
Aug 3, 2020
Merged

TypedData.EncodeData should not reject a Domain without a ChainId #21306

merged 2 commits into from
Aug 3, 2020

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