Skip to content

Commit 294f783

Browse files
fix: make domain.name optional in v2 to legacy EIP-712 conversion (#283)
Some EIP-712 contracts (e.g. Safe) do not include a `name` field in their EIP712Domain. The v2 to legacy EIP-712 converter was requiring `domain.name` to be present and failing with "Missing domain name" when it was absent. Make `dapp_name` fall back to `metadata.owner` when `domain.name` is not set, so descriptors for contracts with a minimal EIP712Domain (e.g. only chainId + verifyingContract) can still be converted. Made-with: Cursor
1 parent 83ba8bb commit 294f783

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/erc7730/convert/ledger/eip712/convert_erc7730_v2_to_eip712.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,6 @@ def _convert_resolved(
483483
domain = context.eip712.domain
484484
has_deployments = len(context.eip712.deployments) > 0
485485

486-
# Get dapp name from domain
487-
dapp_name: str | None = domain.name if domain is not None else None
488-
if dapp_name is None:
489-
return out.error(
490-
title="Missing domain name",
491-
message="EIP-712 domain name is required for legacy EIP-712 conversion.",
492-
)
493-
494486
# Get contract name from metadata
495487
contract_name = descriptor.metadata.owner
496488
if contract_name is None:
@@ -499,6 +491,9 @@ def _convert_resolved(
499491
message="metadata.owner is required for legacy EIP-712 conversion.",
500492
)
501493

494+
# Get dapp name: prefer domain.name, fall back to metadata.owner
495+
dapp_name: str = (domain.name if domain is not None and domain.name is not None else None) or contract_name
496+
502497
# Reconstruct EIP712Domain type
503498
domain_fields = _reconstruct_eip712_domain(domain, has_deployments, out)
504499

0 commit comments

Comments
 (0)