Skip to content

Next button remains disabled after applying new artifacts in Midnight adapter #234

@pasevin

Description

@pasevin

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

  1. Create a Midnight contract configuration with a large artifacts ZIP file (>15MB threshold)
  2. Select a function, which triggers artifact trimming (ZIP is not saved due to performance reasons)
  3. Save the configuration
  4. Reload the page and open the saved configuration
  5. Navigate back to the contract loading step of the UI wizard
  6. Observe the notification that the artifact ZIP was not saved and needs to be provided again
  7. Upload the ZIP file again
  8. Observe that the system detects artifacts have changed and shows a "Reload contract" button
  9. Click the "Reload contract" button
  10. 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 requiresManualReload flag should be cleared

Technical Context

The wizard step validation logic is:

isValid: !!state.contractState.schema && !isTrimmedOnly

Where 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:

  1. The originalZipData field is not being properly set in contractDefinitionArtifacts after reload
  2. The contractState.schema is not being set correctly after reload
  3. The validation check is not re-evaluating after the state update
  4. 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 handler
  • packages/builder/src/components/UIBuilder/StepContractDefinition/hooks/useContractLoader.ts - Contract loading logic
  • packages/builder/src/components/UIBuilder/hooks/uiBuilderStore.ts - State management and setContractDefinitionResult
  • packages/adapter-midnight/src/adapter.ts - loadContractWithMetadata method
  • packages/adapter-midnight/src/utils/artifacts.ts - Artifact validation and conversion
  • packages/adapter-midnight/src/contract/loader.ts - loadMidnightContractWithMetadata return value

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmidnightMidnight Ecosystem Related Issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions