-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Next button remains disabled after applying new artifacts in Midnight adapter
Description
When a user reloads a saved configuration with trimmed artifacts and uploads a new ZIP file to select a different function, the "Reload contract" button appears correctly. However, after clicking this button to apply the new artifacts, the main "Next" button of the wizard remains disabled, preventing the user from proceeding to the next step.
Steps to Reproduce
- Create a Midnight contract configuration with a large artifacts ZIP file (>15MB threshold)
- Select a function, which triggers artifact trimming (ZIP is not saved due to performance reasons)
- Save the configuration
- Reload the page and open the saved configuration
- Navigate back to the contract loading step of the UI wizard
- Observe the notification that the artifact ZIP was not saved and needs to be provided again
- Upload the ZIP file again
- Observe that the system detects artifacts have changed and shows a "Reload contract" button
- Click the "Reload contract" button
- Observe that the contract reloads successfully, but the "Next" button remains disabled
Expected Behavior
After clicking "Reload contract" and successfully reloading the contract with the new artifacts, the "Next" button should become enabled, allowing the user to proceed to the function selector step.
Actual Behavior
The "Next" button remains disabled after successfully reloading the contract, even though:
- The contract schema is loaded successfully
- The new artifacts (including
originalZipData) should be present - The
requiresManualReloadflag should be cleared
Technical Context
The wizard step validation logic is:
isValid: !!state.contractState.schema && !isTrimmedOnlyWhere isTrimmedOnly is computed as:
const hasTrimmed = !!(artifacts as Record<string, unknown>)?.['trimmedZipBase64'];
const hasOriginal = !!(artifacts as Record<string, unknown>)?.['originalZipData'];
return hasTrimmed && !hasOriginal;The issue likely stems from one of the following:
- The
originalZipDatafield is not being properly set incontractDefinitionArtifactsafter reload - The
contractState.schemais not being set correctly after reload - The validation check is not re-evaluating after the state update
- The artifact re-application logic is failing silently
Environment
- Adapter: Midnight (
@openzeppelin/contracts-ui-builder-adapter-midnight) - Artifact size: Large ZIP files (>15MB threshold for deferred persistence)
- Configuration state: Saved configuration with trimmed artifacts
Related Code Areas
packages/builder/src/components/UIBuilder/StepContractDefinition/StepContractDefinition.tsx- Manual reload handlerpackages/builder/src/components/UIBuilder/StepContractDefinition/hooks/useContractLoader.ts- Contract loading logicpackages/builder/src/components/UIBuilder/hooks/uiBuilderStore.ts- State management andsetContractDefinitionResultpackages/adapter-midnight/src/adapter.ts-loadContractWithMetadatamethodpackages/adapter-midnight/src/utils/artifacts.ts- Artifact validation and conversionpackages/adapter-midnight/src/contract/loader.ts-loadMidnightContractWithMetadatareturn value