-
Notifications
You must be signed in to change notification settings - Fork 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:
- Contract Address
- Private State ID
- 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:
- 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
useAutoContractLoadhook - triggers automatic contract loading based on form state changesuseFormSynchook - synchronizes form values to the store and manages theneedsContractDefinitionLoadflaghasMissingRequiredContractInputsutility - validates that all adapter-declared required inputs are present- Form validation logic that checks
formState.isValidand required field presence
Relevant Files
packages/builder/src/components/UIBuilder/StepContractDefinition/hooks/useAutoContractLoad.tspackages/builder/src/components/UIBuilder/StepContractDefinition/hooks/useFormSync.tspackages/builder/src/components/UIBuilder/StepContractDefinition/hooks/useContractForm.tspackages/utils/src/contractInputs.ts
Requirements for Fix
The fix must work correctly in all scenarios:
- Fresh submission: User fills fields in any order → parsing triggers when all fields are complete
- 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:
- Why the
needsContractDefinitionLoadflag is not being set correctly when fields are filled out of order - How debounced values interact with the flag-setting logic
- Whether there are race conditions between different effects that sync form state
- 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