OpenZeppelin / OpenZeppelin/ui-builder

Load Contract step requires fields to be filled in specific order

Open
#235 0 comments 0 reactions 1 assignee View on GitHub

@pasevin is already working on this.

Since Nov 13, 2025.

bug midnight
Dominant language
TypeScript
Stars
48
Forks
23
Avg merge
3h 1m
Merged PRs (30d)
10

Description

Problem Description

The "Load Contract" step in the UI Builder wizard has a field dependency issue that prevents users from progressing to the next step if they don't fill required fields in a specific top-down sequence.

Affected Adapter

This issue is most clearly manifested in the Midnight adapter, which requires three fields:

  1. Contract Address
  2. Private State ID
  3. Contract Artifacts ZIP file
Expected Behavior

Users should be able to fill these fields in any order and have the contract parsing trigger automatically once all required fields are present, enabling the Next button.

Actual Behavior

The Next button only enables (and parsing only triggers) if fields are filled in this exact sequence:

  1. Address → 2. Private State ID → 3. Artifacts ZIP

If fields are filled in a different order (e.g., Artifacts ZIP → Private State ID → Address), the parsing does not trigger and the Next button remains disabled, preventing progression.

Impact
  • User Experience: Users are forced to follow a specific field-filling order, which is unintuitive and frustrating
  • Scope: While most evident in the Midnight adapter, this may be a UI Builder-wide issue affecting any adapter with multiple required contract definition inputs

Technical Context

Key Components Involved
  • useAutoContractLoad hook - triggers automatic contract loading based on form state changes
  • useFormSync hook - synchronizes form values to the store and manages the needsContractDefinitionLoad flag
  • hasMissingRequiredContractInputs utility - validates that all adapter-declared required inputs are present
  • Form validation logic that checks formState.isValid and required field presence
Relevant Files
  • packages/builder/src/components/UIBuilder/StepContractDefinition/hooks/useAutoContractLoad.ts
  • packages/builder/src/components/UIBuilder/StepContractDefinition/hooks/useFormSync.ts
  • packages/builder/src/components/UIBuilder/StepContractDefinition/hooks/useContractForm.ts
  • packages/utils/src/contractInputs.ts

Requirements for Fix

The fix must work correctly in all scenarios:

  1. Fresh submission: User fills fields in any order → parsing triggers when all fields are complete
  2. Later amendments: User changes previously entered values → parsing re-triggers appropriately without breaking reactivity
Critical Constraints
  • Must not break existing reactivity when users modify already-entered values
  • Must maintain proper debouncing behavior to avoid excessive API calls
  • Must preserve the circuit breaker logic that prevents duplicate loads
  • Must handle edge cases like form resets, network changes, and configuration loading

Investigation Needed

A thorough analysis is required to understand:

  1. Why the needsContractDefinitionLoad flag is not being set correctly when fields are filled out of order
  2. How debounced values interact with the flag-setting logic
  3. Whether there are race conditions between different effects that sync form state
  4. How the validation logic determines when all required fields are present vs. when parsing should trigger

Notes

  • This is a delicate issue - a naive fix could break reactivity in amendment scenarios
  • The issue may affect other adapters beyond Midnight, so the fix should be chain-agnostic
  • No solution should be assumed until thorough analysis is complete

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.