Skip to content

Commit

Permalink
fix: fix presence of params not enforced when parameters are mandat…
Browse files Browse the repository at this point in the history
…ory (#112)

Some formats require parameters to be set, but this is not enforced, leading to invalid resolved descriptors
  • Loading branch information
jnicoulaud-ledger authored Oct 23, 2024
1 parent a61e803 commit 5fdefac
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/erc7730/convert/resolved/convert_erc7730_input_to_resolved.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,26 @@ def _resolve_field_description(
constants: ConstantProvider,
out: OutputAdder,
) -> ResolvedFieldDescription | None:
match definition.format:
case None | FieldFormat.RAW | FieldFormat.AMOUNT | FieldFormat.TOKEN_AMOUNT | FieldFormat.DURATION:
pass
case (
FieldFormat.ADDRESS_NAME
| FieldFormat.CALL_DATA
| FieldFormat.NFT_NAME
| FieldFormat.DATE
| FieldFormat.UNIT
| FieldFormat.ENUM
):
if definition.params is None:
return out.error(
title="Missing parameters",
message=f"""Field format "{definition.format.value}" requires parameters to be defined, """
f"""they are missing for field "{definition.path}".""",
)
case _:
assert_never(definition.format)

params = resolve_field_parameters(prefix, definition.params, enums, constants, out)

if (path := constants.resolve_path(definition.path, out)) is None:
Expand Down

0 comments on commit 5fdefac

Please sign in to comment.