OpenZeppelin / OpenZeppelin/ui-builder

Next button remains disabled after applying new artifacts in Midnight adapter

Open
#234 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

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

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.